]> git.ozlabs.org Git - ppp.git/commitdiff
Merge pull request #238 from pali/ipv6cp-demand
authorPaul Mackerras <paulus@ozlabs.org>
Tue, 26 Jan 2021 02:57:00 +0000 (13:57 +1100)
committerGitHub <noreply@github.com>
Tue, 26 Jan 2021 02:57:00 +0000 (13:57 +1100)
ipv6cp: Fix demand mode for IPv6

pppd/Makefile.linux
pppd/ipcp.c
pppd/pppd.8

index 312580bd1b47801c7d7c781590179d3afe8f852b..c3489fb5dbf06673ad849ee6a62eb3d1982892ac 100644 (file)
@@ -144,7 +144,7 @@ CFLAGS   += -DHAS_SHADOW
 #LIBS     += -lshadow $(LIBS)
 endif
 
-CRYPTHEADER = "\#include <utmp.h>"
+CRYPTHEADER = "\#include <crypt.h>"
 ifeq ($(shell echo $(CRYPTHEADER) | $(CC) -E - >/dev/null 2>&1 && echo yes),yes)
 CFLAGS  += -DHAVE_CRYPT_H=1
 LIBS   += -lcrypt
index 302ca40b4c83cecce9098bfff17dfe75b0bedba0..d17dbd28a04d225cd5d5d43dc40547c3e358eb3e 100644 (file)
@@ -678,8 +678,9 @@ ipcp_resetci(fsm *f)
     ipcp_options *go = &ipcp_gotoptions[f->unit];
     ipcp_options *ao = &ipcp_allowoptions[f->unit];
 
-    wo->req_addr = (wo->neg_addr || wo->old_addrs) &&
-       (ao->neg_addr || ao->old_addrs);
+    wo->req_addr = ((wo->neg_addr || wo->old_addrs) &&
+       (ao->neg_addr || ao->old_addrs)) ||
+       (wo->hisaddr && !wo->accept_remote);
     if (wo->ouraddr == 0)
        wo->accept_local = 1;
     if (wo->hisaddr == 0)
@@ -994,6 +995,7 @@ bad:
 static int
 ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject)
 {
+    ipcp_options *wo = &ipcp_wantoptions[f->unit];
     ipcp_options *go = &ipcp_gotoptions[f->unit];
     u_char cimaxslotindex, cicflag;
     u_char citype, cilen, *next;
@@ -1169,7 +1171,7 @@ ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject)
            GETLONG(l, p);
            ciaddr1 = htonl(l);
            if (ciaddr1 && go->accept_local)
-               try.ouraddr = ciaddr1;
+               try.ouraddr = wo->old_addrs ? ciaddr1 : 0;
            GETLONG(l, p);
            ciaddr2 = htonl(l);
            if (ciaddr2 && go->accept_remote)
@@ -1184,7 +1186,7 @@ ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject)
            ciaddr1 = htonl(l);
            if (ciaddr1 && go->accept_local)
                try.ouraddr = ciaddr1;
-           if (try.ouraddr != 0)
+           if (try.ouraddr != 0 && wo->neg_addr)
                try.neg_addr = 1;
            no.neg_addr = 1;
            break;
@@ -1470,7 +1472,7 @@ ipcp_reqci(fsm *f, u_char *inp,   int *len, int reject_if_disagree)
            if (ciaddr2 != wo->ouraddr) {
                if (ciaddr2 == 0 || !wo->accept_local) {
                    orc = CONFNAK;
-                   if (!reject_if_disagree) {
+                   if (!reject_if_disagree && wo->old_addrs) {
                        DECPTR(sizeof(u_int32_t), p);
                        tl = ntohl(wo->ouraddr);
                        PUTLONG(tl, p);
@@ -1647,7 +1649,8 @@ endswitch:
      * option safely.
      */
     if (rc != CONFREJ && !ho->neg_addr && !ho->old_addrs &&
-       wo->req_addr && !reject_if_disagree && !noremoteip) {
+       wo->req_addr && !reject_if_disagree &&
+       ((wo->hisaddr && !wo->accept_remote) || !noremoteip)) {
        if (rc == CONFACK) {
            rc = CONFNAK;
            ucp = inp;                  /* reset pointer */
@@ -1759,6 +1762,12 @@ ipcp_up(fsm *f)
     /*
      * We must have a non-zero IP address for both ends of the link.
      */
+
+    if (wo->hisaddr && !wo->accept_remote && (!(ho->neg_addr || ho->old_addrs) || ho->hisaddr != wo->hisaddr)) {
+       error("Peer refused to agree to his IP address");
+       ipcp_close(f->unit, "Refused his IP address");
+       return;
+    }
     if (!ho->neg_addr && !ho->old_addrs)
        ho->hisaddr = wo->hisaddr;
 
@@ -1822,9 +1831,10 @@ ipcp_up(fsm *f)
                wo->ouraddr = go->ouraddr;
            } else
                script_unsetenv("OLDIPLOCAL");
-           if (ho->hisaddr != wo->hisaddr && wo->hisaddr != 0) {
+           if (ho->hisaddr != wo->hisaddr) {
                warn("Remote IP address changed to %I", ho->hisaddr);
-               script_setenv("OLDIPREMOTE", ip_ntoa(wo->hisaddr), 0);
+               if (wo->hisaddr != 0)
+                   script_setenv("OLDIPREMOTE", ip_ntoa(wo->hisaddr), 0);
                wo->hisaddr = ho->hisaddr;
            } else
                script_unsetenv("OLDIPREMOTE");
index 36156d6ea9d6da4c2380f719e731728c6311cccf..f5597f6a6593db0ee00aeed7150ed725a0fc5e8e 100644 (file)
@@ -493,6 +493,18 @@ to send configure-Rejects instead to \fIn\fR (default 10).
 Set the maximum number of IPCP terminate-request transmissions to
 \fIn\fR (default 3).
 .TP
+.B ipcp\-no\-address
+Disable negotiation of addresses via IP-Address IPCP option.
+.TP
+.B ipcp\-no\-addresses
+Disable negotiation of addresses via old-style deprecated IP-Addresses
+IPCP option. pppd by default try to use new-style IP-Address IPCP option.
+If new-style is not supported by peer or is disabled by \fBipcp\-no\-address\fR
+option then pppd fallbacks to old-style deprecated IP-Addresses IPCP option.
+When both new-style and old-style are disabled by both \fBipcp\-no\-address\fR
+and \fBipcp\-no\-addresses\fR options then negotiation of IP addresses
+is completely disabled.
+.TP
 .B ipcp\-restart \fIn
 Set the IPCP restart interval (retransmission timeout) to \fIn\fR
 seconds (default 3).
@@ -924,6 +936,9 @@ situation, the ppp interface can be used for routing by creating
 device routes, but the peer itself cannot be addressed directly for IP
 traffic.
 .TP
+.B nosendip
+Don't send our local IP address to peer during IP address negotiation.
+.TP
 .B notty
 Normally, pppd requires a terminal device.  With this option, pppd
 will allocate itself a pseudo-tty master/slave pair and use the slave