ppp ver. bump
This commit is contained in:
@@ -11,7 +11,7 @@ from pisi.actionsapi import shelltools
|
|||||||
|
|
||||||
def setup():
|
def setup():
|
||||||
pisitools.cflags.add("-fPIC", "-D_GNU_SOURCE")
|
pisitools.cflags.add("-fPIC", "-D_GNU_SOURCE")
|
||||||
shelltools.copytree("%s/dhcp" % get.workDIR(), "pppd/plugins")
|
#shelltools.copytree("%s/dhcp" % get.workDIR(), "pppd/plugins")
|
||||||
pisitools.dosed("pppd/plugins/dhcp/Makefile.linux", "^(CFLAGS=.+)\s-O2", "\\1 %s" % get.CFLAGS())
|
pisitools.dosed("pppd/plugins/dhcp/Makefile.linux", "^(CFLAGS=.+)\s-O2", "\\1 %s" % get.CFLAGS())
|
||||||
|
|
||||||
# Enable atm
|
# Enable atm
|
||||||
|
|||||||
+164
@@ -0,0 +1,164 @@
|
|||||||
|
From 628de9d1198b724ec6427b9ca7de1c8e2e9ab9b3 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mike Frysinger <vapier@gentoo.org>
|
||||||
|
Date: Tue, 5 Jan 2021 11:13:53 +0100
|
||||||
|
Subject: [PATCH 01/14] Change Make vars to work in Gentoo builds
|
||||||
|
|
||||||
|
---
|
||||||
|
chat/Makefile.linux | 2 +-
|
||||||
|
configure | 4 ++--
|
||||||
|
pppd/plugins/Makefile.linux | 8 ++++++--
|
||||||
|
pppd/plugins/pppoatm/Makefile.linux | 3 +--
|
||||||
|
pppd/plugins/pppoe/Makefile.linux | 4 ++--
|
||||||
|
pppd/plugins/pppol2tp/Makefile.linux | 3 +--
|
||||||
|
pppd/plugins/radius/Makefile.linux | 6 +++---
|
||||||
|
7 files changed, 16 insertions(+), 14 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/chat/Makefile.linux b/chat/Makefile.linux
|
||||||
|
index 407cc12..9b09ae3 100644
|
||||||
|
--- a/chat/Makefile.linux
|
||||||
|
+++ b/chat/Makefile.linux
|
||||||
|
@@ -19,7 +19,7 @@ INSTALL= install
|
||||||
|
all: chat
|
||||||
|
|
||||||
|
chat: chat.o
|
||||||
|
- $(CC) $(LDFLAGS) -o chat chat.o
|
||||||
|
+ $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^
|
||||||
|
|
||||||
|
chat.o: chat.c
|
||||||
|
$(CC) -c $(CFLAGS) -o chat.o chat.c
|
||||||
|
diff --git a/configure b/configure
|
||||||
|
index f977663..bb72fba 100755
|
||||||
|
--- a/configure
|
||||||
|
+++ b/configure
|
||||||
|
@@ -7,7 +7,7 @@ SYSCONF=/etc
|
||||||
|
|
||||||
|
# Compile defaults
|
||||||
|
CROSS_COMPILE=
|
||||||
|
-CC=cc
|
||||||
|
+CC ?= cc
|
||||||
|
CFLAGS=
|
||||||
|
|
||||||
|
system=`uname -s`
|
||||||
|
@@ -20,7 +20,7 @@ case $system in
|
||||||
|
makext="linux";
|
||||||
|
ksrc="linux";
|
||||||
|
state="known";
|
||||||
|
- CFLAGS="-O2 -g -pipe";;
|
||||||
|
+ CFLAGS="$(CFLAGS)";;
|
||||||
|
SunOS)
|
||||||
|
karch=`/usr/bin/isainfo -k`
|
||||||
|
case $release in
|
||||||
|
diff --git a/pppd/plugins/Makefile.linux b/pppd/plugins/Makefile.linux
|
||||||
|
index 6403e3d..89cf5e7 100644
|
||||||
|
--- a/pppd/plugins/Makefile.linux
|
||||||
|
+++ b/pppd/plugins/Makefile.linux
|
||||||
|
@@ -8,7 +8,11 @@ MANDIR = $(DESTDIR)/share/man/man8
|
||||||
|
LIBDIR = $(DESTDIR)/lib/pppd/$(VERSION)
|
||||||
|
|
||||||
|
CFLAGS = $(COPTS) -I.. -I../../include -fPIC
|
||||||
|
-LDFLAGS_SHARED = -shared
|
||||||
|
+LDFLAGS_PROG := $(LDFLAGS)
|
||||||
|
+export LDFLAGS LDFLAGS_PROG
|
||||||
|
+LDFLAGS += -shared
|
||||||
|
+# need the following option, otherwise linking plugins might fail with undef errors (Gentoo bug 210837)
|
||||||
|
+LDFLAGS += -Wl,--allow-shlib-undefined
|
||||||
|
INSTALL = install
|
||||||
|
|
||||||
|
# EAP-TLS
|
||||||
|
@@ -35,7 +39,7 @@ all: $(PLUGINS)
|
||||||
|
for d in $(SUBDIRS); do $(MAKE) $(MFLAGS) -C $$d all || exit $$?; done
|
||||||
|
|
||||||
|
%.so: %.c
|
||||||
|
- $(CC) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED) $(CFLAGS) $^
|
||||||
|
+ $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^ $(LIBS)
|
||||||
|
|
||||||
|
VERSION = $(shell awk -F '"' '/VERSION/ { print $$2; }' ../patchlevel.h)
|
||||||
|
|
||||||
|
diff --git a/pppd/plugins/pppoatm/Makefile.linux b/pppd/plugins/pppoatm/Makefile.linux
|
||||||
|
index d3a8086..ad6b074 100644
|
||||||
|
--- a/pppd/plugins/pppoatm/Makefile.linux
|
||||||
|
+++ b/pppd/plugins/pppoatm/Makefile.linux
|
||||||
|
@@ -9,7 +9,6 @@ LIBDIR = $(DESTDIR)/lib/pppd/$(VERSION)
|
||||||
|
VERSION = $(shell awk -F '"' '/VERSION/ { print $$2; }' ../../patchlevel.h)
|
||||||
|
|
||||||
|
CFLAGS = $(COPTS) -I../.. -I../../../include -fPIC
|
||||||
|
-LDFLAGS_SHARED = -shared
|
||||||
|
INSTALL = install
|
||||||
|
|
||||||
|
PLUGIN := pppoatm.so
|
||||||
|
@@ -34,7 +33,7 @@ endif
|
||||||
|
all: $(PLUGIN)
|
||||||
|
|
||||||
|
$(PLUGIN): $(PLUGIN_OBJS)
|
||||||
|
- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(LDFLAGS_SHARED) $^ $(LIBS)
|
||||||
|
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
|
||||||
|
|
||||||
|
install: all
|
||||||
|
$(INSTALL) -d -m 755 $(LIBDIR)
|
||||||
|
diff --git a/pppd/plugins/pppoe/Makefile.linux b/pppd/plugins/pppoe/Makefile.linux
|
||||||
|
index c415ce3..e18c6de 100644
|
||||||
|
--- a/pppd/plugins/pppoe/Makefile.linux
|
||||||
|
+++ b/pppd/plugins/pppoe/Makefile.linux
|
||||||
|
@@ -29,7 +29,7 @@ CFLAGS=$(COPTS) -I../../../include
|
||||||
|
all: pppoe.so pppoe-discovery
|
||||||
|
|
||||||
|
pppoe-discovery: pppoe-discovery.o debug.o
|
||||||
|
- $(CC) $(LDFLAGS) -o pppoe-discovery pppoe-discovery.o debug.o
|
||||||
|
+ $(CC) $(LDFLAGS_PROG) $(CFLAGS) -o pppoe-discovery pppoe-discovery.o debug.o
|
||||||
|
|
||||||
|
pppoe-discovery.o: pppoe-discovery.c
|
||||||
|
$(CC) $(CFLAGS) -I../../.. -c -o pppoe-discovery.o pppoe-discovery.c
|
||||||
|
@@ -38,7 +38,7 @@ debug.o: debug.c
|
||||||
|
$(CC) $(CFLAGS) -I../../.. -c -o debug.o debug.c
|
||||||
|
|
||||||
|
pppoe.so: plugin.o discovery.o if.o common.o
|
||||||
|
- $(CC) $(LDFLAGS) -o pppoe.so -shared plugin.o discovery.o if.o common.o
|
||||||
|
+ $(CC) $(LDFLAGS) $(CFLAGS) -o pppoe.so -shared plugin.o discovery.o if.o common.o
|
||||||
|
|
||||||
|
install: all
|
||||||
|
$(INSTALL) -d -m 755 $(LIBDIR)
|
||||||
|
diff --git a/pppd/plugins/pppol2tp/Makefile.linux b/pppd/plugins/pppol2tp/Makefile.linux
|
||||||
|
index 1aa1c0b..899bb5f 100644
|
||||||
|
--- a/pppd/plugins/pppol2tp/Makefile.linux
|
||||||
|
+++ b/pppd/plugins/pppol2tp/Makefile.linux
|
||||||
|
@@ -9,7 +9,6 @@ LIBDIR = $(DESTDIR)/lib/pppd/$(VERSION)
|
||||||
|
VERSION = $(shell awk -F '"' '/VERSION/ { print $$2; }' ../../patchlevel.h)
|
||||||
|
|
||||||
|
CFLAGS = $(COPTS) -I. -I../.. -I../../../include -fPIC
|
||||||
|
-LDFLAGS_SHARED = -shared
|
||||||
|
INSTALL = install
|
||||||
|
|
||||||
|
PLUGINS := pppol2tp.so openl2tp.so
|
||||||
|
@@ -17,7 +16,7 @@ PLUGINS := pppol2tp.so openl2tp.so
|
||||||
|
all: $(PLUGINS)
|
||||||
|
|
||||||
|
%.so: %.o
|
||||||
|
- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(LDFLAGS_SHARED) $^ $(LIBS)
|
||||||
|
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
|
||||||
|
|
||||||
|
install: all
|
||||||
|
$(INSTALL) -d -m 755 $(LIBDIR)
|
||||||
|
diff --git a/pppd/plugins/radius/Makefile.linux b/pppd/plugins/radius/Makefile.linux
|
||||||
|
index 489aef2..df90b17 100644
|
||||||
|
--- a/pppd/plugins/radius/Makefile.linux
|
||||||
|
+++ b/pppd/plugins/radius/Makefile.linux
|
||||||
|
@@ -47,13 +47,13 @@ install: all
|
||||||
|
$(INSTALL) -c -m 444 pppd-radattr.8 $(MANDIR)
|
||||||
|
|
||||||
|
radius.so: radius.o libradiusclient.a
|
||||||
|
- $(CC) $(LDFLAGS) -o radius.so -shared radius.o libradiusclient.a
|
||||||
|
+ $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^
|
||||||
|
|
||||||
|
radattr.so: radattr.o
|
||||||
|
- $(CC) $(LDFLAGS) -o radattr.so -shared radattr.o
|
||||||
|
+ $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^
|
||||||
|
|
||||||
|
radrealms.so: radrealms.o
|
||||||
|
- $(CC) $(LDFLAGS) -o radrealms.so -shared radrealms.o
|
||||||
|
+ $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^
|
||||||
|
|
||||||
|
CLIENTOBJS = avpair.o buildreq.o config.o dict.o ip_util.o \
|
||||||
|
clientid.o sendserver.o lock.o util.o md5.o
|
||||||
|
--
|
||||||
|
2.30.0
|
||||||
|
|
||||||
+33
@@ -0,0 +1,33 @@
|
|||||||
|
From 15eee4a0233c0c8f019a9ca4d7d7aa24e8d48daa Mon Sep 17 00:00:00 2001
|
||||||
|
From: Sergey Popov <pinkbyte@gentoo.org>
|
||||||
|
Date: Fri, 3 Jan 2020 12:05:29 +0100
|
||||||
|
Subject: [PATCH 02/14] Use internal implementation of logwtmp function
|
||||||
|
|
||||||
|
to prevent utilities from sys-apps/coreutils to not detect authorized users
|
||||||
|
---
|
||||||
|
pppd/sys-linux.c | 2 --
|
||||||
|
1 file changed, 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/pppd/sys-linux.c b/pppd/sys-linux.c
|
||||||
|
index 85033d9..85b1512 100644
|
||||||
|
--- a/pppd/sys-linux.c
|
||||||
|
+++ b/pppd/sys-linux.c
|
||||||
|
@@ -2472,7 +2472,6 @@ int ppp_available(void)
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
|
-#ifndef HAVE_LOGWTMP
|
||||||
|
/********************************************************************
|
||||||
|
*
|
||||||
|
* Update the wtmp file with the appropriate user name and tty device.
|
||||||
|
@@ -2546,7 +2545,6 @@ void logwtmp (const char *line, const char *name, const char *host)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
-#endif /* HAVE_LOGWTMP */
|
||||||
|
|
||||||
|
/********************************************************************
|
||||||
|
*
|
||||||
|
--
|
||||||
|
2.30.0
|
||||||
|
|
||||||
@@ -0,0 +1,454 @@
|
|||||||
|
From e673f6cb45d5b82afbd90cc270792f63207a8f93 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mike Frysinger <vapier@gentoo.org>
|
||||||
|
Date: Fri, 3 Jan 2020 17:12:26 +0100
|
||||||
|
Subject: [PATCH 03/14] Add MPLSCP support
|
||||||
|
|
||||||
|
---
|
||||||
|
pppd/Makefile.linux | 6 +-
|
||||||
|
pppd/main.c | 4 +
|
||||||
|
pppd/mplscp.c | 371 ++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
pppd/mplscp.h | 8 +
|
||||||
|
4 files changed, 386 insertions(+), 3 deletions(-)
|
||||||
|
create mode 100644 pppd/mplscp.c
|
||||||
|
create mode 100644 pppd/mplscp.h
|
||||||
|
|
||||||
|
diff --git a/pppd/Makefile.linux b/pppd/Makefile.linux
|
||||||
|
index 22837c5..1351981 100644
|
||||||
|
--- a/pppd/Makefile.linux
|
||||||
|
+++ b/pppd/Makefile.linux
|
||||||
|
@@ -17,16 +17,16 @@ TARGETS = pppd
|
||||||
|
|
||||||
|
PPPDSRCS = main.c magic.c fsm.c lcp.c ipcp.c upap.c chap-new.c md5.c ccp.c \
|
||||||
|
ecp.c ipxcp.c auth.c options.c sys-linux.c md4.c chap_ms.c \
|
||||||
|
- demand.c utils.c tty.c eap.c chap-md5.c session.c
|
||||||
|
+ demand.c utils.c tty.c eap.c chap-md5.c session.c mplscp.c
|
||||||
|
|
||||||
|
HEADERS = ccp.h session.h chap-new.h ecp.h fsm.h ipcp.h \
|
||||||
|
ipxcp.h lcp.h magic.h md5.h patchlevel.h pathnames.h pppd.h \
|
||||||
|
- upap.h eap.h
|
||||||
|
+ upap.h eap.h mplscp.h
|
||||||
|
|
||||||
|
MANPAGES = pppd.8
|
||||||
|
PPPDOBJS = main.o magic.o fsm.o lcp.o ipcp.o upap.o chap-new.o md5.o ccp.o \
|
||||||
|
ecp.o auth.o options.o demand.o utils.o sys-linux.o ipxcp.o tty.o \
|
||||||
|
- eap.o chap-md5.o session.o
|
||||||
|
+ eap.o chap-md5.o session.o mplscp.o
|
||||||
|
|
||||||
|
#
|
||||||
|
# include dependencies if present
|
||||||
|
diff --git a/pppd/main.c b/pppd/main.c
|
||||||
|
index 87a5d29..0e8bc87 100644
|
||||||
|
--- a/pppd/main.c
|
||||||
|
+++ b/pppd/main.c
|
||||||
|
@@ -93,6 +93,9 @@
|
||||||
|
#include "fsm.h"
|
||||||
|
#include "lcp.h"
|
||||||
|
#include "ipcp.h"
|
||||||
|
+
|
||||||
|
+#include "mplscp.h"
|
||||||
|
+
|
||||||
|
#ifdef INET6
|
||||||
|
#include "ipv6cp.h"
|
||||||
|
#endif
|
||||||
|
@@ -269,6 +272,7 @@ struct protent *protocols[] = {
|
||||||
|
&cbcp_protent,
|
||||||
|
#endif
|
||||||
|
&ipcp_protent,
|
||||||
|
+ &mplscp_protent,
|
||||||
|
#ifdef INET6
|
||||||
|
&ipv6cp_protent,
|
||||||
|
#endif
|
||||||
|
diff --git a/pppd/mplscp.c b/pppd/mplscp.c
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..72b5a23
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/pppd/mplscp.c
|
||||||
|
@@ -0,0 +1,371 @@
|
||||||
|
+
|
||||||
|
+/* MPLSCP - Serge.Krier@advalvas.be (C) 2001 */
|
||||||
|
+
|
||||||
|
+#include <stdio.h>
|
||||||
|
+#include <string.h>
|
||||||
|
+#include <netdb.h>
|
||||||
|
+#include <sys/param.h>
|
||||||
|
+#include <sys/types.h>
|
||||||
|
+#include <sys/socket.h>
|
||||||
|
+#include <netinet/in.h>
|
||||||
|
+#include <arpa/inet.h>
|
||||||
|
+
|
||||||
|
+#include "pppd.h"
|
||||||
|
+#include "fsm.h"
|
||||||
|
+#include "mplscp.h"
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+/* local vars */
|
||||||
|
+/* static int mplscp_is_up; */ /* have called np_up() */
|
||||||
|
+
|
||||||
|
+/*
|
||||||
|
+ * Callbacks for fsm code. (CI = Configuration Information)
|
||||||
|
+ */
|
||||||
|
+static void mplscp_resetci (fsm *); /* Reset our CI */
|
||||||
|
+static int mplscp_cilen (fsm *); /* Return length of our CI */
|
||||||
|
+static void mplscp_addci (fsm *, u_char *, int *); /* Add our CI */
|
||||||
|
+static int mplscp_ackci (fsm *, u_char *, int); /* Peer ack'd our CI */
|
||||||
|
+static int mplscp_nakci (fsm *, u_char *, int); /* Peer nak'd our CI */
|
||||||
|
+static int mplscp_rejci (fsm *, u_char *, int); /* Peer rej'd our CI */
|
||||||
|
+static int mplscp_reqci (fsm *, u_char *, int *, int); /* Rcv CI */
|
||||||
|
+static void mplscp_up (fsm *); /* We're UP */
|
||||||
|
+static void mplscp_down (fsm *); /* We're DOWN */
|
||||||
|
+static void mplscp_finished (fsm *); /* Don't need lower layer */
|
||||||
|
+
|
||||||
|
+fsm mplscp_fsm[NUM_PPP]; /* MPLSCP fsm structure */
|
||||||
|
+
|
||||||
|
+static fsm_callbacks mplscp_callbacks = { /* MPLSCP callback routines */
|
||||||
|
+ mplscp_resetci, /* Reset our Configuration Information */
|
||||||
|
+ mplscp_cilen, /* Length of our Configuration Information */
|
||||||
|
+ mplscp_addci, /* Add our Configuration Information */
|
||||||
|
+ mplscp_ackci, /* ACK our Configuration Information */
|
||||||
|
+ mplscp_nakci, /* NAK our Configuration Information */
|
||||||
|
+ mplscp_rejci, /* Reject our Configuration Information */
|
||||||
|
+ mplscp_reqci, /* Request peer's Configuration Information */
|
||||||
|
+ mplscp_up, /* Called when fsm reaches OPENED state */
|
||||||
|
+ mplscp_down, /* Called when fsm leaves OPENED state */
|
||||||
|
+ NULL, /* Called when we want the lower layer up */
|
||||||
|
+ mplscp_finished, /* Called when we want the lower layer down */
|
||||||
|
+ NULL, /* Called when Protocol-Reject received */
|
||||||
|
+ NULL, /* Retransmission is necessary */
|
||||||
|
+ NULL, /* Called to handle protocol-specific codes */
|
||||||
|
+ "MPLSCP" /* String name of protocol */
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+static option_t mplscp_option_list[] = {
|
||||||
|
+ { "mpls", o_bool, &mplscp_protent.enabled_flag,
|
||||||
|
+ "Enable MPLSCP (and MPLS)", 1 },
|
||||||
|
+ { NULL } };
|
||||||
|
+
|
||||||
|
+/*
|
||||||
|
+ * Protocol entry points from main code.
|
||||||
|
+ */
|
||||||
|
+
|
||||||
|
+static void mplscp_init (int);
|
||||||
|
+static void mplscp_open (int);
|
||||||
|
+static void mplscp_close (int, char *);
|
||||||
|
+static void mplscp_lowerup (int);
|
||||||
|
+static void mplscp_lowerdown (int);
|
||||||
|
+static void mplscp_input (int, u_char *, int);
|
||||||
|
+static void mplscp_protrej (int);
|
||||||
|
+static int mplscp_printpkt (u_char *, int,
|
||||||
|
+ void (*) (void *, char *, ...), void *);
|
||||||
|
+
|
||||||
|
+struct protent mplscp_protent = {
|
||||||
|
+ PPP_MPLSCP,
|
||||||
|
+ mplscp_init,
|
||||||
|
+ mplscp_input,
|
||||||
|
+ mplscp_protrej,
|
||||||
|
+ mplscp_lowerup,
|
||||||
|
+ mplscp_lowerdown,
|
||||||
|
+ mplscp_open,
|
||||||
|
+ mplscp_close,
|
||||||
|
+ mplscp_printpkt,
|
||||||
|
+ NULL,
|
||||||
|
+ 0, /* MPLS not enabled by default */
|
||||||
|
+ "MPLSCP",
|
||||||
|
+ "MPLS",
|
||||||
|
+ mplscp_option_list,
|
||||||
|
+ NULL,
|
||||||
|
+ NULL,
|
||||||
|
+ NULL
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+/*
|
||||||
|
+ * mplscp_init - Initialize MPLSCP.
|
||||||
|
+ */
|
||||||
|
+static void
|
||||||
|
+mplscp_init(int unit) {
|
||||||
|
+
|
||||||
|
+ fsm *f = &mplscp_fsm[unit];
|
||||||
|
+
|
||||||
|
+ f->unit = unit;
|
||||||
|
+ f->protocol = PPP_MPLSCP;
|
||||||
|
+ f->callbacks = &mplscp_callbacks;
|
||||||
|
+ fsm_init(&mplscp_fsm[unit]);
|
||||||
|
+
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/*
|
||||||
|
+ * mplscp_open - MPLSCP is allowed to come up.
|
||||||
|
+ */
|
||||||
|
+static void
|
||||||
|
+mplscp_open(int unit) {
|
||||||
|
+
|
||||||
|
+ fsm_open(&mplscp_fsm[unit]);
|
||||||
|
+
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/*
|
||||||
|
+ * mplscp_close - Take MPLSCP down.
|
||||||
|
+ */
|
||||||
|
+static void
|
||||||
|
+mplscp_close(int unit, char *reason) {
|
||||||
|
+
|
||||||
|
+ fsm_close(&mplscp_fsm[unit], reason);
|
||||||
|
+
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/*
|
||||||
|
+ * mplscp_lowerup - The lower layer is up.
|
||||||
|
+ */
|
||||||
|
+static void
|
||||||
|
+mplscp_lowerup(int unit) {
|
||||||
|
+
|
||||||
|
+ fsm_lowerup(&mplscp_fsm[unit]);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/*
|
||||||
|
+ * mplscp_lowerdown - The lower layer is down.
|
||||||
|
+ */
|
||||||
|
+static void
|
||||||
|
+mplscp_lowerdown(int unit) {
|
||||||
|
+
|
||||||
|
+ fsm_lowerdown(&mplscp_fsm[unit]);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/*
|
||||||
|
+ * mplscp_input - Input MPLSCP packet.
|
||||||
|
+ */
|
||||||
|
+static void
|
||||||
|
+mplscp_input(int unit, u_char *p, int len) {
|
||||||
|
+
|
||||||
|
+ fsm_input(&mplscp_fsm[unit], p, len);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/*
|
||||||
|
+ * mplscp_protrej - A Protocol-Reject was received for MPLSCP.
|
||||||
|
+ * Pretend the lower layer went down, so we shut up.
|
||||||
|
+ */
|
||||||
|
+static void
|
||||||
|
+mplscp_protrej(int unit) {
|
||||||
|
+
|
||||||
|
+ fsm_lowerdown(&mplscp_fsm[unit]);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/*
|
||||||
|
+ * mplscp_resetci - Reset our CI.
|
||||||
|
+ * Called by fsm_sconfreq, Send Configure Request.
|
||||||
|
+ */
|
||||||
|
+static void
|
||||||
|
+mplscp_resetci(fsm *f) {
|
||||||
|
+
|
||||||
|
+ return;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/*
|
||||||
|
+ * mplscp_cilen - Return length of our CI.
|
||||||
|
+ * Called by fsm_sconfreq, Send Configure Request.
|
||||||
|
+ */
|
||||||
|
+static int
|
||||||
|
+mplscp_cilen(fsm *f) {
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/*
|
||||||
|
+ * mplscp_addci - Add our desired CIs to a packet.
|
||||||
|
+ * Called by fsm_sconfreq, Send Configure Request.
|
||||||
|
+ */
|
||||||
|
+static void
|
||||||
|
+mplscp_addci(fsm *f, u_char *ucp, int *lenp) {
|
||||||
|
+
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/*
|
||||||
|
+ * ipcp_ackci - Ack our CIs.
|
||||||
|
+ * Called by fsm_rconfack, Receive Configure ACK.
|
||||||
|
+ *
|
||||||
|
+ * Returns:
|
||||||
|
+ * 0 - Ack was bad.
|
||||||
|
+ * 1 - Ack was good.
|
||||||
|
+ */
|
||||||
|
+static int
|
||||||
|
+mplscp_ackci(fsm *f, u_char *p, int len) {
|
||||||
|
+
|
||||||
|
+ return 1;
|
||||||
|
+
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/*
|
||||||
|
+ * mplscp_nakci - Peer has sent a NAK for some of our CIs.
|
||||||
|
+ * This should not modify any state if the Nak is bad
|
||||||
|
+ * or if MPLSCP is in the OPENED state.
|
||||||
|
+ * Calback from fsm_rconfnakrej - Receive Configure-Nak or Configure-Reject.
|
||||||
|
+ *
|
||||||
|
+ * Returns:
|
||||||
|
+ * 0 - Nak was bad.
|
||||||
|
+ * 1 - Nak was good.
|
||||||
|
+ */
|
||||||
|
+static int
|
||||||
|
+mplscp_nakci(fsm *f, u_char *p, int len) {
|
||||||
|
+
|
||||||
|
+ return 1;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/*
|
||||||
|
+ * MPLSVP_rejci - Reject some of our CIs.
|
||||||
|
+ * Callback from fsm_rconfnakrej.
|
||||||
|
+ */
|
||||||
|
+static int
|
||||||
|
+mplscp_rejci(fsm *f, u_char *p, int len) {
|
||||||
|
+
|
||||||
|
+ return 1;
|
||||||
|
+
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/*
|
||||||
|
+ * mplscp_reqci - Check the peer's requested CIs and send appropriate response.
|
||||||
|
+ * Callback from fsm_rconfreq, Receive Configure Request
|
||||||
|
+ *
|
||||||
|
+ * Returns: CONFACK, CONFNAK or CONFREJ and input packet modified
|
||||||
|
+ * appropriately. If reject_if_disagree is non-zero, doesn't return
|
||||||
|
+ * CONFNAK; returns CONFREJ if it can't return CONFACK.
|
||||||
|
+ */
|
||||||
|
+static int
|
||||||
|
+mplscp_reqci(fsm *f, u_char *inp, int *len, int reject_if_disagree) {
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+ int rc = CONFACK; /* Final packet return code */
|
||||||
|
+
|
||||||
|
+ PUTCHAR(CONFACK,inp);
|
||||||
|
+
|
||||||
|
+ return rc;
|
||||||
|
+
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void
|
||||||
|
+mplscp_up(fsm *f) {
|
||||||
|
+
|
||||||
|
+ sifnpmode(f->unit, PPP_MPLS_UC, NPMODE_PASS);
|
||||||
|
+ /* sifnpmode(f->unit, PPP_MPLS_MC, NPMODE_PASS);*/
|
||||||
|
+
|
||||||
|
+ np_up(f->unit, PPP_MPLS_UC);
|
||||||
|
+ /* np_up(f->unit, PPP_MPLS_MC);*/
|
||||||
|
+ /* ipcp_is_up = 1;*/
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+#if 1
|
||||||
|
+ printf("MPLSCP is OPENED\n");
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void
|
||||||
|
+mplscp_down(fsm *f) {
|
||||||
|
+
|
||||||
|
+ sifnpmode(f->unit, PPP_MPLS_UC, NPMODE_DROP);
|
||||||
|
+ /* sifnpmode(f->unit, PPP_MPLS_MC, NPMODE_DROP);*/
|
||||||
|
+
|
||||||
|
+ sifdown(f->unit);
|
||||||
|
+
|
||||||
|
+#if 1
|
||||||
|
+ printf("MPLSCP is CLOSED\n");
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void
|
||||||
|
+mplscp_finished(fsm *f) {
|
||||||
|
+
|
||||||
|
+ np_finished(f->unit, PPP_MPLS_UC);
|
||||||
|
+ /* np_finished(f->unit, PPP_MPLS_MC);*/
|
||||||
|
+
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/*
|
||||||
|
+ * mpls_printpkt - print the contents of an MPLSCP packet.
|
||||||
|
+ */
|
||||||
|
+static char *mplscp_codenames[] = {
|
||||||
|
+ "ConfReq", "ConfAck", "ConfNak", "ConfRej",
|
||||||
|
+ "TermReq", "TermAck", "CodeRej"
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+static int
|
||||||
|
+mplscp_printpkt(u_char *p, int plen,
|
||||||
|
+ void (*printer) (void *, char *, ...),
|
||||||
|
+ void *arg) {
|
||||||
|
+
|
||||||
|
+ int code, id, len, olen;
|
||||||
|
+ u_char *pstart, *optend;
|
||||||
|
+
|
||||||
|
+ if (plen < HEADERLEN)
|
||||||
|
+ return 0;
|
||||||
|
+ pstart = p;
|
||||||
|
+ GETCHAR(code, p);
|
||||||
|
+ GETCHAR(id, p);
|
||||||
|
+ GETSHORT(len, p);
|
||||||
|
+ if (len < HEADERLEN || len > plen)
|
||||||
|
+ return 0;
|
||||||
|
+
|
||||||
|
+ if (code >= 1 && code <= sizeof(mplscp_codenames) / sizeof(char *))
|
||||||
|
+ printer(arg, " %s", mplscp_codenames[code-1]);
|
||||||
|
+ else
|
||||||
|
+ printer(arg, " code=0x%x", code);
|
||||||
|
+ printer(arg, " id=0x%x", id);
|
||||||
|
+ len -= HEADERLEN;
|
||||||
|
+ switch (code) {
|
||||||
|
+ case CONFREQ:
|
||||||
|
+ case CONFACK:
|
||||||
|
+ case CONFNAK:
|
||||||
|
+ case CONFREJ:
|
||||||
|
+ /* print option list */
|
||||||
|
+ while (len >= 2) {
|
||||||
|
+ GETCHAR(code, p);
|
||||||
|
+ GETCHAR(olen, p);
|
||||||
|
+ p -= 2;
|
||||||
|
+ if (olen < 2 || olen > len) {
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ printer(arg, " <");
|
||||||
|
+ len -= olen;
|
||||||
|
+ optend = p + olen;
|
||||||
|
+ while (p < optend) {
|
||||||
|
+ GETCHAR(code, p);
|
||||||
|
+ printer(arg, " %.2x", code);
|
||||||
|
+ }
|
||||||
|
+ printer(arg, ">");
|
||||||
|
+ }
|
||||||
|
+ break;
|
||||||
|
+
|
||||||
|
+ case TERMACK:
|
||||||
|
+ case TERMREQ:
|
||||||
|
+ if (len > 0 && *p >= ' ' && *p < 0x7f) {
|
||||||
|
+ printer(arg, " ");
|
||||||
|
+ print_string((char *)p, len, printer, arg);
|
||||||
|
+ p += len;
|
||||||
|
+ len = 0;
|
||||||
|
+ }
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /* print the rest of the bytes in the packet */
|
||||||
|
+ for (; len > 0; --len) {
|
||||||
|
+ GETCHAR(code, p);
|
||||||
|
+ printer(arg, " %.2x", code);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return p - pstart;
|
||||||
|
+
|
||||||
|
+}
|
||||||
|
diff --git a/pppd/mplscp.h b/pppd/mplscp.h
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..5e983d9
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/pppd/mplscp.h
|
||||||
|
@@ -0,0 +1,8 @@
|
||||||
|
+
|
||||||
|
+/* MPLSCP - Serge.Krier@advalvas.be (C) 2001 */
|
||||||
|
+
|
||||||
|
+#define PPP_MPLSCP 0x8281
|
||||||
|
+#define PPP_MPLS_UC 0x0281
|
||||||
|
+#define PPP_MPLS_MC 0x0283
|
||||||
|
+
|
||||||
|
+extern struct protent mplscp_protent;
|
||||||
|
--
|
||||||
|
2.30.0
|
||||||
|
|
||||||
@@ -0,0 +1,143 @@
|
|||||||
|
From 83c2de652b2b53a23b9e87d6eb3cb4085fe797c2 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mike Frysinger <vapier@gentoo.org>
|
||||||
|
Date: Fri, 3 Jan 2020 12:56:45 +0100
|
||||||
|
Subject: [PATCH 04/14] smarter killaddr
|
||||||
|
|
||||||
|
---
|
||||||
|
pppd/options.c | 8 ++++++++
|
||||||
|
pppd/pppd.h | 3 +++
|
||||||
|
pppd/sys-linux.c | 42 +++++++++++++++++++++++++++++++++++++++---
|
||||||
|
3 files changed, 50 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/pppd/options.c b/pppd/options.c
|
||||||
|
index f8d6c00..12d12fd 100644
|
||||||
|
--- a/pppd/options.c
|
||||||
|
+++ b/pppd/options.c
|
||||||
|
@@ -102,6 +102,9 @@ int maxconnect = 0; /* Maximum connect time */
|
||||||
|
char user[MAXNAMELEN]; /* Username for PAP */
|
||||||
|
char passwd[MAXSECRETLEN]; /* Password for PAP */
|
||||||
|
bool persist = 0; /* Reopen link after it goes down */
|
||||||
|
+bool killoldaddr = 0; /* If our IP is reassigned on
|
||||||
|
+ reconnect, kill active TCP
|
||||||
|
+ connections using the old IP. */
|
||||||
|
char our_name[MAXNAMELEN]; /* Our name for authentication purposes */
|
||||||
|
bool demand = 0; /* do dial-on-demand */
|
||||||
|
char *ipparam = NULL; /* Extra parameter for ip up/down scripts */
|
||||||
|
@@ -252,6 +255,11 @@ option_t general_options[] = {
|
||||||
|
{ "demand", o_bool, &demand,
|
||||||
|
"Dial on demand", OPT_INITONLY | 1, &persist },
|
||||||
|
|
||||||
|
+ { "killoldaddr", o_bool, &killoldaddr,
|
||||||
|
+ "Kill connections from an old source address", 1},
|
||||||
|
+ { "nokilloldaddr", o_bool,&killoldaddr,
|
||||||
|
+ "Don't kill connections from an old source address" },
|
||||||
|
+
|
||||||
|
{ "--version", o_special_noarg, (void *)showversion,
|
||||||
|
"Show version number" },
|
||||||
|
{ "--help", o_special_noarg, (void *)showhelp,
|
||||||
|
diff --git a/pppd/pppd.h b/pppd/pppd.h
|
||||||
|
index 612902f..bdb8778 100644
|
||||||
|
--- a/pppd/pppd.h
|
||||||
|
+++ b/pppd/pppd.h
|
||||||
|
@@ -310,6 +310,9 @@ extern char our_name[MAXNAMELEN];/* Our name for authentication purposes */
|
||||||
|
extern char remote_name[MAXNAMELEN]; /* Peer's name for authentication */
|
||||||
|
extern bool explicit_remote;/* remote_name specified with remotename opt */
|
||||||
|
extern bool demand; /* Do dial-on-demand */
|
||||||
|
+extern bool killoldaddr; /* If our IP is reassigned on
|
||||||
|
+ reconnect, kill active TCP
|
||||||
|
+ connections using the old IP. */
|
||||||
|
extern char *ipparam; /* Extra parameter for ip up/down scripts */
|
||||||
|
extern bool cryptpap; /* Others' PAP passwords are encrypted */
|
||||||
|
extern int idle_time_limit;/* Shut down link if idle for this long */
|
||||||
|
diff --git a/pppd/sys-linux.c b/pppd/sys-linux.c
|
||||||
|
index 85b1512..95f5a72 100644
|
||||||
|
--- a/pppd/sys-linux.c
|
||||||
|
+++ b/pppd/sys-linux.c
|
||||||
|
@@ -172,6 +172,10 @@ struct in6_ifreq {
|
||||||
|
static const eui64_t nulleui64;
|
||||||
|
#endif /* INET6 */
|
||||||
|
|
||||||
|
+#ifndef SIOCKILLADDR
|
||||||
|
+#define SIOCKILLADDR 0x8939
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
/* We can get an EIO error on an ioctl if the modem has hung up */
|
||||||
|
#define ok_error(num) ((num)==EIO)
|
||||||
|
|
||||||
|
@@ -220,6 +224,7 @@ static int default_rt_repl_rest; /* replace and restore old default rt */
|
||||||
|
static u_int32_t proxy_arp_addr; /* Addr for proxy arp entry added */
|
||||||
|
static char proxy_arp_dev[16]; /* Device for proxy arp entry */
|
||||||
|
static u_int32_t our_old_addr; /* for detecting address changes */
|
||||||
|
+static u_int32_t our_current_addr;
|
||||||
|
static int dynaddr_set; /* 1 if ip_dynaddr set */
|
||||||
|
static int looped; /* 1 if using loop */
|
||||||
|
static int link_mtu; /* mtu for the link (not bundle) */
|
||||||
|
@@ -566,6 +571,27 @@ int generic_establish_ppp (int fd)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
+static void do_killaddr(u_int32_t oldaddr)
|
||||||
|
+{
|
||||||
|
+ struct ifreq ifr;
|
||||||
|
+
|
||||||
|
+ memset(&ifr,0,sizeof ifr);
|
||||||
|
+
|
||||||
|
+ SET_SA_FAMILY (ifr.ifr_addr, AF_INET);
|
||||||
|
+ SET_SA_FAMILY (ifr.ifr_dstaddr, AF_INET);
|
||||||
|
+ SET_SA_FAMILY (ifr.ifr_netmask, AF_INET);
|
||||||
|
+
|
||||||
|
+ SIN_ADDR(ifr.ifr_addr) = oldaddr;
|
||||||
|
+
|
||||||
|
+ strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
|
||||||
|
+
|
||||||
|
+ if(ioctl(sock_fd,SIOCKILLADDR,&ifr) < 0) {
|
||||||
|
+ if (!ok_error (errno))
|
||||||
|
+ error("ioctl(SIOCKILLADDR): %m(%d)", errno);
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
/********************************************************************
|
||||||
|
*
|
||||||
|
* tty_disestablish_ppp - Restore the serial port to normal operation.
|
||||||
|
@@ -2747,9 +2773,14 @@ int sifaddr (int unit, u_int32_t our_adr, u_int32_t his_adr,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- /* set ip_dynaddr in demand mode if address changes */
|
||||||
|
- if (demand && tune_kernel && !dynaddr_set
|
||||||
|
- && our_old_addr && our_old_addr != our_adr) {
|
||||||
|
+ if(persist && our_old_addr && our_old_addr != our_adr) {
|
||||||
|
+
|
||||||
|
+ if(killoldaddr)
|
||||||
|
+ do_killaddr(our_old_addr);
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+ /* set ip_dynaddr in demand mode if address changes */
|
||||||
|
+ if (tune_kernel && !dynaddr_set) {
|
||||||
|
/* set ip_dynaddr if possible */
|
||||||
|
char *path;
|
||||||
|
int fd;
|
||||||
|
@@ -2761,7 +2792,10 @@ int sifaddr (int unit, u_int32_t our_adr, u_int32_t his_adr,
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
dynaddr_set = 1; /* only 1 attempt */
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ our_current_addr = our_adr;
|
||||||
|
our_old_addr = 0;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
@@ -2818,6 +2852,8 @@ int cifaddr (int unit, u_int32_t our_adr, u_int32_t his_adr)
|
||||||
|
|
||||||
|
our_old_addr = our_adr;
|
||||||
|
|
||||||
|
+ our_current_addr = 0;
|
||||||
|
+
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.30.0
|
||||||
|
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
From e16792c757200d679edc3918eea12a18ec12b5a8 Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?Alin=20N=C4=83stac?= <mrness@gentoo.org>
|
||||||
|
Date: Fri, 3 Jan 2020 17:16:17 +0100
|
||||||
|
Subject: [PATCH 05/14] Improve waiting for children on exit
|
||||||
|
|
||||||
|
Gentoo-bug: https://bugs.gentoo.org/122795
|
||||||
|
---
|
||||||
|
pppd/main.c | 51 ++++++++++++++++++++++++++++++++++-----------------
|
||||||
|
1 file changed, 34 insertions(+), 17 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/pppd/main.c b/pppd/main.c
|
||||||
|
index 0e8bc87..6c0a173 100644
|
||||||
|
--- a/pppd/main.c
|
||||||
|
+++ b/pppd/main.c
|
||||||
|
@@ -245,6 +245,7 @@ static void holdoff_end(void *);
|
||||||
|
static void forget_child(int pid, int status);
|
||||||
|
static int reap_kids(void);
|
||||||
|
static void childwait_end(void *);
|
||||||
|
+static void wait_children(void);
|
||||||
|
|
||||||
|
#ifdef USE_TDB
|
||||||
|
static void update_db_entry(void);
|
||||||
|
@@ -560,26 +561,12 @@ main(int argc, char *argv[])
|
||||||
|
if (!persist)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
- }
|
||||||
|
|
||||||
|
- /* Wait for scripts to finish */
|
||||||
|
- reap_kids();
|
||||||
|
- if (n_children > 0) {
|
||||||
|
- if (child_wait > 0)
|
||||||
|
- TIMEOUT(childwait_end, NULL, child_wait);
|
||||||
|
- if (debug) {
|
||||||
|
- struct subprocess *chp;
|
||||||
|
- dbglog("Waiting for %d child processes...", n_children);
|
||||||
|
- for (chp = children; chp != NULL; chp = chp->next)
|
||||||
|
- dbglog(" script %s, pid %d", chp->prog, chp->pid);
|
||||||
|
- }
|
||||||
|
- while (n_children > 0 && !childwait_done) {
|
||||||
|
- handle_events();
|
||||||
|
- if (kill_link && !childwait_done)
|
||||||
|
- childwait_end(NULL);
|
||||||
|
- }
|
||||||
|
+ wait_children();
|
||||||
|
}
|
||||||
|
|
||||||
|
+ wait_children();
|
||||||
|
+
|
||||||
|
die(status);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@@ -1831,6 +1818,36 @@ record_child(int pid, char *prog, void (*done)(void *), void *arg, int killable)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+/*
|
||||||
|
+ * wait_children - wait for scripts to finish.
|
||||||
|
+ * if child_wait is 0, wait indefinitely.
|
||||||
|
+ * else, kill'em all at the end of timeout
|
||||||
|
+ */
|
||||||
|
+static void
|
||||||
|
+wait_children()
|
||||||
|
+{
|
||||||
|
+ /* Wait for scripts to finish */
|
||||||
|
+ reap_kids();
|
||||||
|
+ if (n_children > 0) {
|
||||||
|
+ childwait_done = 0;
|
||||||
|
+ if (child_wait > 0)
|
||||||
|
+ TIMEOUT(childwait_end, NULL, child_wait);
|
||||||
|
+ if (debug) {
|
||||||
|
+ struct subprocess *chp;
|
||||||
|
+ dbglog("Waiting for %d child processes...", n_children);
|
||||||
|
+ for (chp = children; chp != NULL; chp = chp->next)
|
||||||
|
+ dbglog(" script %s, pid %d", chp->prog, chp->pid);
|
||||||
|
+ }
|
||||||
|
+ while (n_children > 0 && !childwait_done) {
|
||||||
|
+ handle_events();
|
||||||
|
+ if (asked_to_quit && !childwait_done)
|
||||||
|
+ childwait_end(NULL);
|
||||||
|
+ }
|
||||||
|
+ if (child_wait > 0)
|
||||||
|
+ UNTIMEOUT(childwait_end, NULL);
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
/*
|
||||||
|
* childwait_end - we got fed up waiting for the child processes to
|
||||||
|
* exit, send them all a SIGTERM.
|
||||||
|
--
|
||||||
|
2.30.0
|
||||||
|
|
||||||
+115
@@ -0,0 +1,115 @@
|
|||||||
|
From 8a17acdd63ae2b2726dc5a3272b23294f75a5883 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mike Frysinger <vapier@gentoo.org>
|
||||||
|
Date: Tue, 5 Jan 2021 11:29:29 +0100
|
||||||
|
Subject: [PATCH 06/14] Remove one of the 2 pidfiles (pidfilename or
|
||||||
|
linkpidfile)
|
||||||
|
|
||||||
|
---
|
||||||
|
pppd/auth.c | 2 +-
|
||||||
|
pppd/main.c | 25 ++++++++++++++++---------
|
||||||
|
pppd/multilink.c | 2 +-
|
||||||
|
pppd/pppd.h | 3 ++-
|
||||||
|
4 files changed, 20 insertions(+), 12 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/pppd/auth.c b/pppd/auth.c
|
||||||
|
index b1271c4..a1a831e 100644
|
||||||
|
--- a/pppd/auth.c
|
||||||
|
+++ b/pppd/auth.c
|
||||||
|
@@ -678,7 +678,7 @@ link_terminated(int unit)
|
||||||
|
* we delete its pid file.
|
||||||
|
*/
|
||||||
|
if (!doing_multilink && !demand)
|
||||||
|
- remove_pidfiles();
|
||||||
|
+ remove_pidfile(pidfilename);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If we may want to bring the link up again, transfer
|
||||||
|
diff --git a/pppd/main.c b/pppd/main.c
|
||||||
|
index 6c0a173..08c5306 100644
|
||||||
|
--- a/pppd/main.c
|
||||||
|
+++ b/pppd/main.c
|
||||||
|
@@ -130,7 +130,7 @@ struct channel *the_channel;
|
||||||
|
|
||||||
|
char *progname; /* Name of this program */
|
||||||
|
char hostname[MAXNAMELEN]; /* Our hostname */
|
||||||
|
-static char pidfilename[MAXPATHLEN]; /* name of pid file */
|
||||||
|
+char pidfilename[MAXPATHLEN]; /* name of pid file */
|
||||||
|
static char linkpidfile[MAXPATHLEN]; /* name of linkname pid file */
|
||||||
|
char ppp_devnam[MAXPATHLEN]; /* name of PPP tty (maybe ttypx) */
|
||||||
|
uid_t uid; /* Our real user-id */
|
||||||
|
@@ -241,6 +241,7 @@ static void chld(int);
|
||||||
|
static void toggle_debug(int);
|
||||||
|
static void open_ccp(int);
|
||||||
|
static void bad_signal(int);
|
||||||
|
+static void remove_pidfilenames(void);
|
||||||
|
static void holdoff_end(void *);
|
||||||
|
static void forget_child(int pid, int status);
|
||||||
|
static int reap_kids(void);
|
||||||
|
@@ -828,16 +829,22 @@ create_linkpidfile(int pid)
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
- * remove_pidfile - remove our pid files
|
||||||
|
+ * remove_pidfile - remove one of the 2 pidfiles (pidfilename or linkpidfile)
|
||||||
|
*/
|
||||||
|
-void remove_pidfiles(void)
|
||||||
|
+void remove_pidfile(char* filename)
|
||||||
|
{
|
||||||
|
- if (pidfilename[0] != 0 && unlink(pidfilename) < 0 && errno != ENOENT)
|
||||||
|
- warn("unable to delete pid file %s: %m", pidfilename);
|
||||||
|
- pidfilename[0] = 0;
|
||||||
|
- if (linkpidfile[0] != 0 && unlink(linkpidfile) < 0 && errno != ENOENT)
|
||||||
|
- warn("unable to delete pid file %s: %m", linkpidfile);
|
||||||
|
- linkpidfile[0] = 0;
|
||||||
|
+ if (filename[0] != 0 && unlink(filename) < 0 && errno != ENOENT)
|
||||||
|
+ warn("unable to delete pid file %s: %m", filename);
|
||||||
|
+ filename[0] = 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/*
|
||||||
|
+ * remove_pidfiles - remove our pid files
|
||||||
|
+ */
|
||||||
|
+static void remove_pidfiles()
|
||||||
|
+{
|
||||||
|
+ remove_pidfile(pidfilename);
|
||||||
|
+ remove_pidfile(linkpidfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
diff --git a/pppd/multilink.c b/pppd/multilink.c
|
||||||
|
index ddd848c..c9d93c3 100644
|
||||||
|
--- a/pppd/multilink.c
|
||||||
|
+++ b/pppd/multilink.c
|
||||||
|
@@ -267,7 +267,7 @@ void mp_bundle_terminated(void)
|
||||||
|
notice("Connection terminated.");
|
||||||
|
print_link_stats();
|
||||||
|
if (!demand) {
|
||||||
|
- remove_pidfiles();
|
||||||
|
+ remove_pidfile(pidfilename);
|
||||||
|
script_unsetenv("IFNAME");
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/pppd/pppd.h b/pppd/pppd.h
|
||||||
|
index bdb8778..88a1209 100644
|
||||||
|
--- a/pppd/pppd.h
|
||||||
|
+++ b/pppd/pppd.h
|
||||||
|
@@ -219,6 +219,7 @@ extern int hungup; /* Physical layer has disconnected */
|
||||||
|
extern int ifunit; /* Interface unit number */
|
||||||
|
extern char ifname[]; /* Interface name */
|
||||||
|
extern char hostname[]; /* Our hostname */
|
||||||
|
+extern char pidfilename[]; /* name of pid file */
|
||||||
|
extern u_char outpacket_buf[]; /* Buffer for outgoing packets */
|
||||||
|
extern int devfd; /* fd of underlying device */
|
||||||
|
extern int fd_ppp; /* fd for talking PPP */
|
||||||
|
@@ -531,7 +532,7 @@ void notify(struct notifier *, int);
|
||||||
|
int ppp_send_config(int, int, u_int32_t, int, int);
|
||||||
|
int ppp_recv_config(int, int, u_int32_t, int, int);
|
||||||
|
const char *protocol_name(int);
|
||||||
|
-void remove_pidfiles(void);
|
||||||
|
+void remove_pidfile(char *);
|
||||||
|
void lock_db(void);
|
||||||
|
void unlock_db(void);
|
||||||
|
|
||||||
|
--
|
||||||
|
2.30.0
|
||||||
|
|
||||||
+159
@@ -0,0 +1,159 @@
|
|||||||
|
From 27ac7224d354abba7b726519af0b552917002f4a Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mike Frysinger <vapier@gentoo.org>
|
||||||
|
Date: Tue, 5 Jan 2021 11:56:33 +0100
|
||||||
|
Subject: [PATCH 07/14] Run etc/ppp/auth-fail script if exists and
|
||||||
|
authentication failed
|
||||||
|
|
||||||
|
---
|
||||||
|
pppd/auth.c | 21 ++++++++++++++-------
|
||||||
|
pppd/pathnames.h | 1 +
|
||||||
|
pppd/pppd.8 | 14 ++++++++++++--
|
||||||
|
3 files changed, 27 insertions(+), 9 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/pppd/auth.c b/pppd/auth.c
|
||||||
|
index a1a831e..00b885e 100644
|
||||||
|
--- a/pppd/auth.c
|
||||||
|
+++ b/pppd/auth.c
|
||||||
|
@@ -294,7 +294,7 @@ static int scan_authfile(FILE *, char *, char *, char *,
|
||||||
|
struct wordlist **, struct wordlist **,
|
||||||
|
char *, int);
|
||||||
|
static void free_wordlist (struct wordlist *);
|
||||||
|
-static void auth_script (char *);
|
||||||
|
+static void auth_script (char *, int);
|
||||||
|
static void auth_script_done (void *);
|
||||||
|
static void set_allowed_addrs (int, struct wordlist *, struct wordlist *);
|
||||||
|
static int some_ip_ok (struct wordlist *);
|
||||||
|
@@ -732,7 +732,7 @@ link_down(int unit)
|
||||||
|
if (auth_script_state == s_up && auth_script_pid == 0) {
|
||||||
|
update_link_stats(unit);
|
||||||
|
auth_script_state = s_down;
|
||||||
|
- auth_script(_PATH_AUTHDOWN);
|
||||||
|
+ auth_script(_PATH_AUTHDOWN, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!doing_multilink) {
|
||||||
|
@@ -881,7 +881,7 @@ network_phase(int unit)
|
||||||
|
auth_state = s_up;
|
||||||
|
if (auth_script_state == s_down && auth_script_pid == 0) {
|
||||||
|
auth_script_state = s_up;
|
||||||
|
- auth_script(_PATH_AUTHUP);
|
||||||
|
+ auth_script(_PATH_AUTHUP, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -979,6 +979,7 @@ auth_peer_fail(int unit, int protocol)
|
||||||
|
* Authentication failure: take the link down
|
||||||
|
*/
|
||||||
|
status = EXIT_PEER_AUTH_FAILED;
|
||||||
|
+ auth_script(_PATH_AUTHFAIL, 1);
|
||||||
|
lcp_close(unit, "Authentication failed");
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1054,6 +1055,7 @@ auth_withpeer_fail(int unit, int protocol)
|
||||||
|
* authentication secrets.
|
||||||
|
*/
|
||||||
|
status = EXIT_AUTH_TOPEER_FAILED;
|
||||||
|
+ auth_script(_PATH_AUTHFAIL, 1);
|
||||||
|
lcp_close(unit, "Failed to authenticate ourselves to peer");
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1286,6 +1288,8 @@ auth_check_options(void)
|
||||||
|
if (user[0] == 0 && !explicit_user)
|
||||||
|
strlcpy(user, our_name, sizeof(user));
|
||||||
|
|
||||||
|
+ script_setenv("LOCALNAME", user, 0);
|
||||||
|
+
|
||||||
|
/*
|
||||||
|
* If we have a default route, require the peer to authenticate
|
||||||
|
* unless the noauth option was given or the real user is root.
|
||||||
|
@@ -2345,13 +2349,13 @@ auth_script_done(void *arg)
|
||||||
|
case s_up:
|
||||||
|
if (auth_state == s_down) {
|
||||||
|
auth_script_state = s_down;
|
||||||
|
- auth_script(_PATH_AUTHDOWN);
|
||||||
|
+ auth_script(_PATH_AUTHDOWN, 0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case s_down:
|
||||||
|
if (auth_state == s_up) {
|
||||||
|
auth_script_state = s_up;
|
||||||
|
- auth_script(_PATH_AUTHUP);
|
||||||
|
+ auth_script(_PATH_AUTHUP, 0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
@@ -2362,7 +2366,7 @@ auth_script_done(void *arg)
|
||||||
|
* interface-name peer-name real-user tty speed
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
-auth_script(char *script)
|
||||||
|
+auth_script(char *script, int wait)
|
||||||
|
{
|
||||||
|
char strspeed[32];
|
||||||
|
struct passwd *pw;
|
||||||
|
@@ -2386,7 +2390,10 @@ auth_script(char *script)
|
||||||
|
argv[5] = strspeed;
|
||||||
|
argv[6] = NULL;
|
||||||
|
|
||||||
|
- auth_script_pid = run_program(script, argv, 0, auth_script_done, NULL, 0);
|
||||||
|
+ if (wait)
|
||||||
|
+ run_program(script, argv, 0, NULL, NULL, 1);
|
||||||
|
+ else
|
||||||
|
+ auth_script_pid = run_program(script, argv, 0, auth_script_done, NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/pppd/pathnames.h b/pppd/pathnames.h
|
||||||
|
index 524d608..7647d49 100644
|
||||||
|
--- a/pppd/pathnames.h
|
||||||
|
+++ b/pppd/pathnames.h
|
||||||
|
@@ -32,6 +32,7 @@
|
||||||
|
#define _PATH_IPPREUP _ROOT_PATH "/etc/ppp/ip-pre-up"
|
||||||
|
#define _PATH_AUTHUP _ROOT_PATH "/etc/ppp/auth-up"
|
||||||
|
#define _PATH_AUTHDOWN _ROOT_PATH "/etc/ppp/auth-down"
|
||||||
|
+#define _PATH_AUTHFAIL _ROOT_PATH "/etc/ppp/auth-fail"
|
||||||
|
#define _PATH_TTYOPT _ROOT_PATH "/etc/ppp/options."
|
||||||
|
#define _PATH_CONNERRS _ROOT_PATH "/etc/ppp/connect-errors"
|
||||||
|
#define _PATH_PEERFILES _ROOT_PATH "/etc/ppp/peers/"
|
||||||
|
diff --git a/pppd/pppd.8 b/pppd/pppd.8
|
||||||
|
index 36156d6..fae91b2 100644
|
||||||
|
--- a/pppd/pppd.8
|
||||||
|
+++ b/pppd/pppd.8
|
||||||
|
@@ -1725,8 +1725,8 @@ We failed to authenticate ourselves to the peer.
|
||||||
|
Pppd invokes scripts at various stages in its processing which can be
|
||||||
|
used to perform site-specific ancillary processing. These scripts are
|
||||||
|
usually shell scripts, but could be executable code files instead.
|
||||||
|
-Pppd does not wait for the scripts to finish (except for the ip-pre-up
|
||||||
|
-script). The scripts are
|
||||||
|
+Pppd does not wait for the scripts to finish (except for the ip-pre-up,
|
||||||
|
+and auth-fail scripts). The scripts are
|
||||||
|
executed as root (with the real and effective user-id set to 0), so
|
||||||
|
that they can do things such as update routing tables or run
|
||||||
|
privileged daemons. Be careful that the contents of these scripts do
|
||||||
|
@@ -1754,6 +1754,11 @@ IPCP has come up.
|
||||||
|
The authenticated name of the peer. This is only set if the peer
|
||||||
|
authenticates itself.
|
||||||
|
.TP
|
||||||
|
+.B LOCALNAME
|
||||||
|
+The username passed to the user option of the pppd daemon. This is
|
||||||
|
+handy to identify which account was used for authentication purposes
|
||||||
|
+when multiple accounts are available.
|
||||||
|
+.TP
|
||||||
|
.B SPEED
|
||||||
|
The baud rate of the tty device.
|
||||||
|
.TP
|
||||||
|
@@ -1811,6 +1816,11 @@ A program or script which is executed when the link goes down, if
|
||||||
|
/etc/ppp/auth\-up was previously executed. It is executed in the same
|
||||||
|
manner with the same parameters as /etc/ppp/auth\-up.
|
||||||
|
.TP
|
||||||
|
+.B /etc/ppp/auth\-fail
|
||||||
|
+A program or script which is executed should authentication fail. pppd
|
||||||
|
+waits for this script to finish. It is executed in the same manner, with
|
||||||
|
+the same parameters as /etc/ppp/auth\-up.
|
||||||
|
+.TP
|
||||||
|
.B /etc/ppp/ip\-pre\-up
|
||||||
|
A program or script which is executed just before the ppp network
|
||||||
|
interface is brought up. It is executed with the same parameters as
|
||||||
|
--
|
||||||
|
2.30.0
|
||||||
|
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
From 9b3f313a860f301909dc17332a789ed39aa5a09b Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mike Frysinger <vapier@gentoo.org>
|
||||||
|
Date: Fri, 3 Jan 2020 17:18:27 +0100
|
||||||
|
Subject: [PATCH 08/14] Try to create /dev/ppp if not available
|
||||||
|
|
||||||
|
---
|
||||||
|
pppd/sys-linux.c | 11 +++++++++++
|
||||||
|
1 file changed, 11 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/pppd/sys-linux.c b/pppd/sys-linux.c
|
||||||
|
index 95f5a72..33f83ac 100644
|
||||||
|
--- a/pppd/sys-linux.c
|
||||||
|
+++ b/pppd/sys-linux.c
|
||||||
|
@@ -2382,6 +2382,17 @@ int ppp_available(void)
|
||||||
|
kernel_version = KVERSION(osmaj, osmin, ospatch);
|
||||||
|
|
||||||
|
fd = open("/dev/ppp", O_RDWR);
|
||||||
|
+ if (fd < 0) {
|
||||||
|
+ /* try making it and see if that helps. */
|
||||||
|
+ if (errno == ENOENT && mknod("/dev/ppp", S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP,
|
||||||
|
+ makedev(108, 0)) >= 0) {
|
||||||
|
+ fd = open("/dev/ppp", O_RDWR);
|
||||||
|
+ if (fd >= 0)
|
||||||
|
+ info("Created /dev/ppp device node");
|
||||||
|
+ else
|
||||||
|
+ unlink("/dev/ppp"); /* didn't work, undo the mknod */
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
if (fd >= 0) {
|
||||||
|
new_style_driver = 1;
|
||||||
|
|
||||||
|
--
|
||||||
|
2.30.0
|
||||||
|
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
From b67eb5595b232c0d936d38a595544a298f99517f Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mike Frysinger <vapier@gentoo.org>
|
||||||
|
Date: Fri, 3 Jan 2020 17:19:09 +0100
|
||||||
|
Subject: [PATCH 09/14] passwordfd: read early
|
||||||
|
|
||||||
|
---
|
||||||
|
pppd/plugins/passwordfd.c | 54 ++++++++++++++++++---------------------
|
||||||
|
1 file changed, 25 insertions(+), 29 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/pppd/plugins/passwordfd.c b/pppd/plugins/passwordfd.c
|
||||||
|
index c3f9793..48d04b2 100644
|
||||||
|
--- a/pppd/plugins/passwordfd.c
|
||||||
|
+++ b/pppd/plugins/passwordfd.c
|
||||||
|
@@ -16,11 +16,11 @@
|
||||||
|
|
||||||
|
char pppd_version[] = VERSION;
|
||||||
|
|
||||||
|
-static int passwdfd = -1;
|
||||||
|
static char save_passwd[MAXSECRETLEN];
|
||||||
|
|
||||||
|
+static int readpassword (char **);
|
||||||
|
static option_t options[] = {
|
||||||
|
- { "passwordfd", o_int, &passwdfd,
|
||||||
|
+ { "passwordfd", o_special, (void *)readpassword,
|
||||||
|
"Receive password on this file descriptor" },
|
||||||
|
{ NULL }
|
||||||
|
};
|
||||||
|
@@ -30,43 +30,39 @@ static int pwfd_check (void)
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
-static int pwfd_passwd (char *user, char *passwd)
|
||||||
|
+static int readpassword(char **argv)
|
||||||
|
{
|
||||||
|
- int readgood, red;
|
||||||
|
-
|
||||||
|
- if (passwdfd == -1)
|
||||||
|
- return -1;
|
||||||
|
+ char *arg = *argv;
|
||||||
|
+ int passwdfd = -1;
|
||||||
|
+ int chunk, len;
|
||||||
|
|
||||||
|
- if (passwd == NULL)
|
||||||
|
- return 1;
|
||||||
|
-
|
||||||
|
- if (passwdfd == -2) {
|
||||||
|
- strcpy (passwd, save_passwd);
|
||||||
|
- return 1;
|
||||||
|
+ if (sscanf(arg, "%d", &passwdfd) != 1 || passwdfd < 0)
|
||||||
|
+ {
|
||||||
|
+ error ("\"%s\" is not a valid file descriptor number", arg);
|
||||||
|
+ return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
- readgood = 0;
|
||||||
|
+ len = 0;
|
||||||
|
do {
|
||||||
|
- red = read (passwdfd, passwd + readgood, MAXSECRETLEN - 1 - readgood);
|
||||||
|
- if (red == 0)
|
||||||
|
- break;
|
||||||
|
- if (red < 0) {
|
||||||
|
- error ("Can't read secret from fd\n");
|
||||||
|
- readgood = -1;
|
||||||
|
+ chunk = read (passwdfd, save_passwd + len, MAXSECRETLEN - 1 - len);
|
||||||
|
+ if (chunk == 0)
|
||||||
|
break;
|
||||||
|
+ if (chunk < 0) {
|
||||||
|
+ error ("Can't read secret from fd %d", passwdfd);
|
||||||
|
+ return 0;
|
||||||
|
}
|
||||||
|
- readgood += red;
|
||||||
|
- } while (readgood < MAXSECRETLEN - 1);
|
||||||
|
-
|
||||||
|
+ len += chunk;
|
||||||
|
+ } while (len < MAXSECRETLEN - 1);
|
||||||
|
+ save_passwd[len] = 0;
|
||||||
|
close (passwdfd);
|
||||||
|
|
||||||
|
- if (readgood < 0)
|
||||||
|
- return 0;
|
||||||
|
-
|
||||||
|
- passwd[readgood] = 0;
|
||||||
|
- strcpy (save_passwd, passwd);
|
||||||
|
- passwdfd = -2;
|
||||||
|
+ return 1;
|
||||||
|
+}
|
||||||
|
|
||||||
|
+static int pwfd_passwd (char *user, char *passwd)
|
||||||
|
+{
|
||||||
|
+ if (passwd != NULL)
|
||||||
|
+ strcpy (passwd, save_passwd);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.30.0
|
||||||
|
|
||||||
+276
@@ -0,0 +1,276 @@
|
|||||||
|
From 369a393c957cc610e07e4bf4f07230eaf515b302 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mike Frysinger <vapier@gentoo.org>
|
||||||
|
Date: Fri, 3 Jan 2020 17:19:40 +0100
|
||||||
|
Subject: [PATCH 10/14] Add option to ask peer for WINS address
|
||||||
|
|
||||||
|
---
|
||||||
|
pppd/ipcp.c | 79 ++++++++++++++++++++++++++++++++++++++++-------------
|
||||||
|
pppd/ipcp.h | 2 ++
|
||||||
|
pppd/pppd.8 | 19 +++++++++++++
|
||||||
|
3 files changed, 81 insertions(+), 19 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/pppd/ipcp.c b/pppd/ipcp.c
|
||||||
|
index 302ca40..7db5156 100644
|
||||||
|
--- a/pppd/ipcp.c
|
||||||
|
+++ b/pppd/ipcp.c
|
||||||
|
@@ -89,6 +89,7 @@ struct notifier *ip_down_notifier = NULL;
|
||||||
|
static int default_route_set[NUM_PPP]; /* Have set up a default route */
|
||||||
|
static int proxy_arp_set[NUM_PPP]; /* Have created proxy arp entry */
|
||||||
|
static bool usepeerdns; /* Ask peer for DNS addrs */
|
||||||
|
+static bool usepeerwins; /* Ask peer for WINS addrs */
|
||||||
|
static int ipcp_is_up; /* have called np_up() */
|
||||||
|
static int ipcp_is_open; /* haven't called np_finished() */
|
||||||
|
static bool ask_for_local; /* request our address from peer */
|
||||||
|
@@ -217,6 +218,9 @@ static option_t ipcp_option_list[] = {
|
||||||
|
{ "usepeerdns", o_bool, &usepeerdns,
|
||||||
|
"Ask peer for DNS address(es)", 1 },
|
||||||
|
|
||||||
|
+ { "usepeerwins", o_bool, &usepeerwins,
|
||||||
|
+ "Ask peer for WINS address(es)", 1 },
|
||||||
|
+
|
||||||
|
{ "netmask", o_special, (void *)setnetmask,
|
||||||
|
"set netmask", OPT_PRIO | OPT_A2STRVAL | OPT_STATIC, netmask_str },
|
||||||
|
|
||||||
|
@@ -686,6 +690,8 @@ ipcp_resetci(fsm *f)
|
||||||
|
wo->accept_remote = 1;
|
||||||
|
wo->req_dns1 = usepeerdns; /* Request DNS addresses from the peer */
|
||||||
|
wo->req_dns2 = usepeerdns;
|
||||||
|
+ wo->req_wins1 = usepeerwins; /* Request WINS addresses from the peer */
|
||||||
|
+ wo->req_wins2 = usepeerwins;
|
||||||
|
*go = *wo;
|
||||||
|
if (!ask_for_local)
|
||||||
|
go->ouraddr = 0;
|
||||||
|
@@ -737,8 +743,8 @@ ipcp_cilen(fsm *f)
|
||||||
|
LENCIADDR(go->neg_addr) +
|
||||||
|
LENCIDNS(go->req_dns1) +
|
||||||
|
LENCIDNS(go->req_dns2) +
|
||||||
|
- LENCIWINS(go->winsaddr[0]) +
|
||||||
|
- LENCIWINS(go->winsaddr[1])) ;
|
||||||
|
+ LENCIWINS(go->req_wins1) +
|
||||||
|
+ LENCIWINS(go->req_wins2)) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -809,8 +815,8 @@ ipcp_addci(fsm *f, u_char *ucp, int *lenp)
|
||||||
|
neg = 0; \
|
||||||
|
}
|
||||||
|
|
||||||
|
-#define ADDCIWINS(opt, addr) \
|
||||||
|
- if (addr) { \
|
||||||
|
+#define ADDCIWINS(opt, neg, addr) \
|
||||||
|
+ if (neg) { \
|
||||||
|
if (len >= CILEN_ADDR) { \
|
||||||
|
u_int32_t l; \
|
||||||
|
PUTCHAR(opt, ucp); \
|
||||||
|
@@ -819,7 +825,7 @@ ipcp_addci(fsm *f, u_char *ucp, int *lenp)
|
||||||
|
PUTLONG(l, ucp); \
|
||||||
|
len -= CILEN_ADDR; \
|
||||||
|
} else \
|
||||||
|
- addr = 0; \
|
||||||
|
+ neg = 0; \
|
||||||
|
}
|
||||||
|
|
||||||
|
ADDCIADDRS(CI_ADDRS, !go->neg_addr && go->old_addrs, go->ouraddr,
|
||||||
|
@@ -834,9 +840,9 @@ ipcp_addci(fsm *f, u_char *ucp, int *lenp)
|
||||||
|
|
||||||
|
ADDCIDNS(CI_MS_DNS2, go->req_dns2, go->dnsaddr[1]);
|
||||||
|
|
||||||
|
- ADDCIWINS(CI_MS_WINS1, go->winsaddr[0]);
|
||||||
|
+ ADDCIWINS(CI_MS_WINS1, go->req_wins1, go->winsaddr[0]);
|
||||||
|
|
||||||
|
- ADDCIWINS(CI_MS_WINS2, go->winsaddr[1]);
|
||||||
|
+ ADDCIWINS(CI_MS_WINS2, go->req_wins2, go->winsaddr[1]);
|
||||||
|
|
||||||
|
*lenp -= len;
|
||||||
|
}
|
||||||
|
@@ -938,8 +944,8 @@ ipcp_ackci(fsm *f, u_char *p, int len)
|
||||||
|
goto bad; \
|
||||||
|
}
|
||||||
|
|
||||||
|
-#define ACKCIWINS(opt, addr) \
|
||||||
|
- if (addr) { \
|
||||||
|
+#define ACKCIWINS(opt, neg, addr) \
|
||||||
|
+ if (neg) { \
|
||||||
|
u_int32_t l; \
|
||||||
|
if ((len -= CILEN_ADDR) < 0) \
|
||||||
|
goto bad; \
|
||||||
|
@@ -965,9 +971,9 @@ ipcp_ackci(fsm *f, u_char *p, int len)
|
||||||
|
|
||||||
|
ACKCIDNS(CI_MS_DNS2, go->req_dns2, go->dnsaddr[1]);
|
||||||
|
|
||||||
|
- ACKCIWINS(CI_MS_WINS1, go->winsaddr[0]);
|
||||||
|
+ ACKCIWINS(CI_MS_WINS1, go->req_wins1, go->winsaddr[0]);
|
||||||
|
|
||||||
|
- ACKCIWINS(CI_MS_WINS2, go->winsaddr[1]);
|
||||||
|
+ ACKCIWINS(CI_MS_WINS2, go->req_wins2, go->winsaddr[1]);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If there are any remaining CIs, then this packet is bad.
|
||||||
|
@@ -998,7 +1004,7 @@ ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject)
|
||||||
|
u_char cimaxslotindex, cicflag;
|
||||||
|
u_char citype, cilen, *next;
|
||||||
|
u_short cishort;
|
||||||
|
- u_int32_t ciaddr1, ciaddr2, l, cidnsaddr;
|
||||||
|
+ u_int32_t ciaddr1, ciaddr2, l, cidnsaddr, ciwinsaddr;
|
||||||
|
ipcp_options no; /* options we've seen Naks for */
|
||||||
|
ipcp_options try; /* options to request next time */
|
||||||
|
|
||||||
|
@@ -1063,6 +1069,19 @@ ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject)
|
||||||
|
code \
|
||||||
|
}
|
||||||
|
|
||||||
|
+#define NAKCIWINS(opt, neg, code) \
|
||||||
|
+ if (go->neg && \
|
||||||
|
+ ((cilen = p[1]) == CILEN_ADDR) && \
|
||||||
|
+ len >= cilen && \
|
||||||
|
+ p[0] == opt) { \
|
||||||
|
+ len -= cilen; \
|
||||||
|
+ INCPTR(2, p); \
|
||||||
|
+ GETLONG(l, p); \
|
||||||
|
+ ciwinsaddr = htonl(l); \
|
||||||
|
+ no.neg = 1; \
|
||||||
|
+ code \
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
/*
|
||||||
|
* Accept the peer's idea of {our,his} address, if different
|
||||||
|
* from our idea, only if the accept_{local,remote} flag is set.
|
||||||
|
@@ -1139,6 +1158,22 @@ ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject)
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
+ NAKCIWINS(CI_MS_WINS1, req_wins1,
|
||||||
|
+ if (treat_as_reject) {
|
||||||
|
+ try.req_wins1 = 0;
|
||||||
|
+ } else {
|
||||||
|
+ try.winsaddr[0] = ciwinsaddr;
|
||||||
|
+ }
|
||||||
|
+ );
|
||||||
|
+
|
||||||
|
+ NAKCIWINS(CI_MS_WINS2, req_wins2,
|
||||||
|
+ if (treat_as_reject) {
|
||||||
|
+ try.req_wins2 = 0;
|
||||||
|
+ } else {
|
||||||
|
+ try.winsaddr[1] = ciwinsaddr;
|
||||||
|
+ }
|
||||||
|
+ );
|
||||||
|
+
|
||||||
|
/*
|
||||||
|
* There may be remaining CIs, if the peer is requesting negotiation
|
||||||
|
* on an option that we didn't include in our request packet.
|
||||||
|
@@ -1231,7 +1266,6 @@ bad:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
-
|
||||||
|
/*
|
||||||
|
* ipcp_rejci - Reject some of our CIs.
|
||||||
|
* Callback from fsm_rconfnakrej.
|
||||||
|
@@ -1326,8 +1360,8 @@ ipcp_rejci(fsm *f, u_char *p, int len)
|
||||||
|
try.neg = 0; \
|
||||||
|
}
|
||||||
|
|
||||||
|
-#define REJCIWINS(opt, addr) \
|
||||||
|
- if (addr && \
|
||||||
|
+#define REJCIWINS(opt, neg, addr) \
|
||||||
|
+ if (go->neg && \
|
||||||
|
((cilen = p[1]) == CILEN_ADDR) && \
|
||||||
|
len >= cilen && \
|
||||||
|
p[0] == opt) { \
|
||||||
|
@@ -1339,7 +1373,7 @@ ipcp_rejci(fsm *f, u_char *p, int len)
|
||||||
|
/* Check rejected value. */ \
|
||||||
|
if (cilong != addr) \
|
||||||
|
goto bad; \
|
||||||
|
- try.winsaddr[opt == CI_MS_WINS2] = 0; \
|
||||||
|
+ try.neg = 0; \
|
||||||
|
}
|
||||||
|
|
||||||
|
REJCIADDRS(CI_ADDRS, !go->neg_addr && go->old_addrs,
|
||||||
|
@@ -1354,9 +1388,9 @@ ipcp_rejci(fsm *f, u_char *p, int len)
|
||||||
|
|
||||||
|
REJCIDNS(CI_MS_DNS2, req_dns2, go->dnsaddr[1]);
|
||||||
|
|
||||||
|
- REJCIWINS(CI_MS_WINS1, go->winsaddr[0]);
|
||||||
|
+ REJCIWINS(CI_MS_WINS1, req_wins1, go->winsaddr[0]);
|
||||||
|
|
||||||
|
- REJCIWINS(CI_MS_WINS2, go->winsaddr[1]);
|
||||||
|
+ REJCIWINS(CI_MS_WINS2, req_wins2, go->winsaddr[1]);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If there are any remaining CIs, then this packet is bad.
|
||||||
|
@@ -1546,7 +1580,7 @@ ipcp_reqci(fsm *f, u_char *inp, int *len, int reject_if_disagree)
|
||||||
|
/* Microsoft primary or secondary WINS request */
|
||||||
|
d = citype == CI_MS_WINS2;
|
||||||
|
|
||||||
|
- /* If we do not have a DNS address then we cannot send it */
|
||||||
|
+ /* If we do not have a WINS address then we cannot send it */
|
||||||
|
if (ao->winsaddr[d] == 0 ||
|
||||||
|
cilen != CILEN_ADDR) { /* Check CI length */
|
||||||
|
orc = CONFREJ; /* Reject CI */
|
||||||
|
@@ -1795,6 +1829,13 @@ ipcp_up(fsm *f)
|
||||||
|
create_resolv(go->dnsaddr[0], go->dnsaddr[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ if (go->winsaddr[0])
|
||||||
|
+ script_setenv("WINS1", ip_ntoa(go->winsaddr[0]), 0);
|
||||||
|
+ if (go->winsaddr[1])
|
||||||
|
+ script_setenv("WINS2", ip_ntoa(go->winsaddr[1]), 0);
|
||||||
|
+ if (usepeerwins && (go->winsaddr[0] || go->winsaddr[1]))
|
||||||
|
+ script_setenv("USEPEERWINS", "1", 0);
|
||||||
|
+
|
||||||
|
/*
|
||||||
|
* Check that the peer is allowed to use the IP address it wants.
|
||||||
|
*/
|
||||||
|
diff --git a/pppd/ipcp.h b/pppd/ipcp.h
|
||||||
|
index 9c4f68d..2ec8190 100644
|
||||||
|
--- a/pppd/ipcp.h
|
||||||
|
+++ b/pppd/ipcp.h
|
||||||
|
@@ -76,6 +76,8 @@ typedef struct ipcp_options {
|
||||||
|
bool accept_remote; /* accept peer's value for hisaddr */
|
||||||
|
bool req_dns1; /* Ask peer to send primary DNS address? */
|
||||||
|
bool req_dns2; /* Ask peer to send secondary DNS address? */
|
||||||
|
+ bool req_wins1; /* Ask peer to send primary WINS address? */
|
||||||
|
+ bool req_wins2; /* Ask peer to send secondary WINS address? */
|
||||||
|
int vj_protocol; /* protocol value to use in VJ option */
|
||||||
|
int maxslotindex; /* values for RFC1332 VJ compression neg. */
|
||||||
|
bool cflag;
|
||||||
|
diff --git a/pppd/pppd.8 b/pppd/pppd.8
|
||||||
|
index fae91b2..bd188e4 100644
|
||||||
|
--- a/pppd/pppd.8
|
||||||
|
+++ b/pppd/pppd.8
|
||||||
|
@@ -1199,6 +1199,16 @@ USEPEERDNS will be set to 1. In addition, pppd will create an
|
||||||
|
/etc/ppp/resolv.conf file containing one or two nameserver lines with
|
||||||
|
the address(es) supplied by the peer.
|
||||||
|
.TP
|
||||||
|
+.B usepeerwins
|
||||||
|
+Ask the peer for up to 2 WINS server addresses. The addresses supplied
|
||||||
|
+by the peer (if any) are passed to the /etc/ppp/ip\-up script in the
|
||||||
|
+environment variables WINS1 and WINS2, and the environment variable
|
||||||
|
+USEPEERWINS will be set to 1.
|
||||||
|
+.LP
|
||||||
|
+Please note that some modems (like the Huawei E220) requires this option in
|
||||||
|
+order to avoid a race condition that results in the incorrect DNS servers
|
||||||
|
+being assigned.
|
||||||
|
+.TP
|
||||||
|
.B user \fIname
|
||||||
|
Sets the name used for authenticating the local system to the peer to
|
||||||
|
\fIname\fR.
|
||||||
|
@@ -1798,6 +1808,15 @@ option was given).
|
||||||
|
If the peer supplies DNS server addresses, this variable is set to the
|
||||||
|
second DNS server address supplied (whether or not the usepeerdns
|
||||||
|
option was given).
|
||||||
|
+.TP
|
||||||
|
+.B WINS1
|
||||||
|
+If the peer supplies WINS server addresses, this variable is set to the
|
||||||
|
+first WINS server address supplied.
|
||||||
|
+.TP
|
||||||
|
+.B WINS2
|
||||||
|
+If the peer supplies WINS server addresses, this variable is set to the
|
||||||
|
+second WINS server address supplied.
|
||||||
|
+.P
|
||||||
|
.P
|
||||||
|
Pppd invokes the following scripts, if they exist. It is not an error
|
||||||
|
if they don't exist.
|
||||||
|
--
|
||||||
|
2.30.0
|
||||||
|
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
From 9af9d0f69eda99cc034743adf789a0005fbb3f1b Mon Sep 17 00:00:00 2001
|
||||||
|
From: Mike Frysinger <vapier@gentoo.org>
|
||||||
|
Date: Fri, 3 Jan 2020 17:20:06 +0100
|
||||||
|
Subject: [PATCH 11/14] Log connect errors to /var/log/ppp-connect-errors
|
||||||
|
|
||||||
|
---
|
||||||
|
pppd/pathnames.h | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/pppd/pathnames.h b/pppd/pathnames.h
|
||||||
|
index 7647d49..2d7c621 100644
|
||||||
|
--- a/pppd/pathnames.h
|
||||||
|
+++ b/pppd/pathnames.h
|
||||||
|
@@ -34,7 +34,7 @@
|
||||||
|
#define _PATH_AUTHDOWN _ROOT_PATH "/etc/ppp/auth-down"
|
||||||
|
#define _PATH_AUTHFAIL _ROOT_PATH "/etc/ppp/auth-fail"
|
||||||
|
#define _PATH_TTYOPT _ROOT_PATH "/etc/ppp/options."
|
||||||
|
-#define _PATH_CONNERRS _ROOT_PATH "/etc/ppp/connect-errors"
|
||||||
|
+#define _PATH_CONNERRS _ROOT_PATH "/var/log/ppp-connect-errors"
|
||||||
|
#define _PATH_PEERFILES _ROOT_PATH "/etc/ppp/peers/"
|
||||||
|
#define _PATH_RESOLV _ROOT_PATH "/etc/ppp/resolv.conf"
|
||||||
|
|
||||||
|
--
|
||||||
|
2.30.0
|
||||||
|
|
||||||
+276
@@ -0,0 +1,276 @@
|
|||||||
|
From 6dd23d5e7f9301237d6a9b96fbbb7b9f6bbcf464 Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB?= <spike@lmu.name>
|
||||||
|
Date: Tue, 5 Jan 2021 12:28:03 +0100
|
||||||
|
Subject: [PATCH 12/14] Don't hang when starting pppoe connection without
|
||||||
|
server response
|
||||||
|
|
||||||
|
waitForPADO is part of PPPoE discovery procedure. This function ignores
|
||||||
|
timeout parameter and uses it only for delay in select(). If any pppoe
|
||||||
|
garbage packet recived, recive retried with waiting next packet with
|
||||||
|
SAME timeout value. In case of no response from server, continuous flow
|
||||||
|
PPPoE discovery packets in ethernet segment waitForPADO never return.
|
||||||
|
|
||||||
|
This actually occurs when pppoe server temporary fails and other clients
|
||||||
|
trying to recover connection.
|
||||||
|
|
||||||
|
So pppoe server did not reply because PADI request is sent for a long
|
||||||
|
time. New PADI should be sent but pppd only waits forever.
|
||||||
|
|
||||||
|
Gentoo-bug: https://bugs.gentoo.org/340267
|
||||||
|
---
|
||||||
|
pppd/plugins/pppoe/discovery.c | 158 ++++++++++++++-------------
|
||||||
|
pppd/plugins/pppoe/pppoe-discovery.c | 8 +-
|
||||||
|
2 files changed, 89 insertions(+), 77 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/pppd/plugins/pppoe/discovery.c b/pppd/plugins/pppoe/discovery.c
|
||||||
|
index 23089df..6923a2c 100644
|
||||||
|
--- a/pppd/plugins/pppoe/discovery.c
|
||||||
|
+++ b/pppd/plugins/pppoe/discovery.c
|
||||||
|
@@ -39,6 +39,7 @@ static char const RCSID[] =
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <signal.h>
|
||||||
|
+#include <time.h>
|
||||||
|
|
||||||
|
/* Calculate time remaining until *exp, return 0 if now >= *exp */
|
||||||
|
static int time_left(struct timeval *diff, struct timeval *exp)
|
||||||
|
@@ -246,6 +247,79 @@ parsePADSTags(UINT16_t type, UINT16_t len, unsigned char *data,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+/***********************************************************************
|
||||||
|
+*%FUNCTION: recvPacketForMe
|
||||||
|
+*%ARGUMENTS:
|
||||||
|
+* packet -- output parameter
|
||||||
|
+* len -- output parameter length
|
||||||
|
+* conn -- connection
|
||||||
|
+* start -- operation startup timestamp
|
||||||
|
+* timeout -- how long to wait (in seconds)
|
||||||
|
+*%RETURNS:
|
||||||
|
+* -1: error
|
||||||
|
+* 0: timed out
|
||||||
|
+* 1: packet received
|
||||||
|
+*%DESCRIPTION:
|
||||||
|
+* receive and filter junk packets
|
||||||
|
+***********************************************************************/
|
||||||
|
+
|
||||||
|
+static int
|
||||||
|
+recvPacketForMe(PPPoEPacket *packet, int *len, PPPoEConnection *conn, time_t start, int timeout)
|
||||||
|
+{
|
||||||
|
+ fd_set readable;
|
||||||
|
+ int r;
|
||||||
|
+ struct timeval tv;
|
||||||
|
+ time_t now;
|
||||||
|
+ int time_remain;
|
||||||
|
+
|
||||||
|
+ do {
|
||||||
|
+ time(&now);
|
||||||
|
+ time_remain = timeout - (int)difftime(now, start);
|
||||||
|
+ if (time_remain <= 0) return 0; /* Timed out */
|
||||||
|
+
|
||||||
|
+ if (BPF_BUFFER_IS_EMPTY) {
|
||||||
|
+ tv.tv_sec = time_remain;
|
||||||
|
+ tv.tv_usec = 0;
|
||||||
|
+
|
||||||
|
+ FD_ZERO(&readable);
|
||||||
|
+ FD_SET(conn->discoverySocket, &readable);
|
||||||
|
+
|
||||||
|
+ r = select(conn->discoverySocket+1, &readable, NULL, NULL, &tv);
|
||||||
|
+ if (r < 0)
|
||||||
|
+ {
|
||||||
|
+ if (errno == EINTR && !got_sigterm)
|
||||||
|
+ {
|
||||||
|
+ continue; /* interrupted, so retry */
|
||||||
|
+ } else
|
||||||
|
+ {
|
||||||
|
+ error("pppoe: recvPacketForMe: select: %m");
|
||||||
|
+ return -1;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (r == 0) return 0; /* Timed out */
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /* Get the packet */
|
||||||
|
+ receivePacket(conn->discoverySocket, packet, len);
|
||||||
|
+
|
||||||
|
+ /* Check length */
|
||||||
|
+ if (ntohs(packet->length) + HDR_SIZE > *len) {
|
||||||
|
+ error("Bogus PPPoE length field (%u)",
|
||||||
|
+ (unsigned int) ntohs(packet->length));
|
||||||
|
+ continue;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+#ifdef USE_BPF
|
||||||
|
+ /* If it's not a Discovery packet, loop again */
|
||||||
|
+ if (etherType(&packet) != Eth_PPPOE_Discovery) continue;
|
||||||
|
+#endif
|
||||||
|
+ /* If it's not for us, loop again */
|
||||||
|
+ }while ( ! packetIsForMe(conn, packet));
|
||||||
|
+
|
||||||
|
+ return 1;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
/***********************************************************************
|
||||||
|
*%FUNCTION: sendPADI
|
||||||
|
*%ARGUMENTS:
|
||||||
|
@@ -336,13 +410,12 @@ sendPADI(PPPoEConnection *conn)
|
||||||
|
void
|
||||||
|
waitForPADO(PPPoEConnection *conn, int timeout)
|
||||||
|
{
|
||||||
|
- fd_set readable;
|
||||||
|
int r;
|
||||||
|
- struct timeval tv;
|
||||||
|
struct timeval expire_at;
|
||||||
|
|
||||||
|
PPPoEPacket packet;
|
||||||
|
int len;
|
||||||
|
+ time_t start;
|
||||||
|
|
||||||
|
struct PacketCriteria pc;
|
||||||
|
pc.conn = conn;
|
||||||
|
@@ -359,43 +432,10 @@ waitForPADO(PPPoEConnection *conn, int timeout)
|
||||||
|
}
|
||||||
|
expire_at.tv_sec += timeout;
|
||||||
|
|
||||||
|
+ time(&start);
|
||||||
|
do {
|
||||||
|
- if (BPF_BUFFER_IS_EMPTY) {
|
||||||
|
- if (!time_left(&tv, &expire_at))
|
||||||
|
- return; /* Timed out */
|
||||||
|
-
|
||||||
|
- FD_ZERO(&readable);
|
||||||
|
- FD_SET(conn->discoverySocket, &readable);
|
||||||
|
-
|
||||||
|
- while(1) {
|
||||||
|
- r = select(conn->discoverySocket+1, &readable, NULL, NULL, &tv);
|
||||||
|
- if (r >= 0 || errno != EINTR || got_sigterm) break;
|
||||||
|
- }
|
||||||
|
- if (r < 0) {
|
||||||
|
- error("select (waitForPADO): %m");
|
||||||
|
- return;
|
||||||
|
- }
|
||||||
|
- if (r == 0)
|
||||||
|
- return; /* Timed out */
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- /* Get the packet */
|
||||||
|
- receivePacket(conn->discoverySocket, &packet, &len);
|
||||||
|
-
|
||||||
|
- /* Check length */
|
||||||
|
- if (ntohs(packet.length) + HDR_SIZE > len) {
|
||||||
|
- error("Bogus PPPoE length field (%u)",
|
||||||
|
- (unsigned int) ntohs(packet.length));
|
||||||
|
- continue;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
-#ifdef USE_BPF
|
||||||
|
- /* If it's not a Discovery packet, loop again */
|
||||||
|
- if (etherType(&packet) != Eth_PPPOE_Discovery) continue;
|
||||||
|
-#endif
|
||||||
|
-
|
||||||
|
- /* If it's not for us, loop again */
|
||||||
|
- if (!packetIsForMe(conn, &packet)) continue;
|
||||||
|
+ r = recvPacketForMe(&packet, &len, conn, start, timeout);
|
||||||
|
+ if (r<=0) return; /* Timed out or error */
|
||||||
|
|
||||||
|
if (packet.code == CODE_PADO) {
|
||||||
|
if (NOT_UNICAST(packet.ethHdr.h_source)) {
|
||||||
|
@@ -525,13 +565,12 @@ sendPADR(PPPoEConnection *conn)
|
||||||
|
static void
|
||||||
|
waitForPADS(PPPoEConnection *conn, int timeout)
|
||||||
|
{
|
||||||
|
- fd_set readable;
|
||||||
|
int r;
|
||||||
|
- struct timeval tv;
|
||||||
|
struct timeval expire_at;
|
||||||
|
|
||||||
|
PPPoEPacket packet;
|
||||||
|
int len;
|
||||||
|
+ time_t start;
|
||||||
|
|
||||||
|
if (get_time(&expire_at) < 0) {
|
||||||
|
error("get_time (waitForPADS): %m");
|
||||||
|
@@ -539,48 +578,15 @@ waitForPADS(PPPoEConnection *conn, int timeout)
|
||||||
|
}
|
||||||
|
expire_at.tv_sec += timeout;
|
||||||
|
|
||||||
|
+ time(&start);
|
||||||
|
conn->error = 0;
|
||||||
|
do {
|
||||||
|
- if (BPF_BUFFER_IS_EMPTY) {
|
||||||
|
- if (!time_left(&tv, &expire_at))
|
||||||
|
- return; /* Timed out */
|
||||||
|
-
|
||||||
|
- FD_ZERO(&readable);
|
||||||
|
- FD_SET(conn->discoverySocket, &readable);
|
||||||
|
-
|
||||||
|
- while(1) {
|
||||||
|
- r = select(conn->discoverySocket+1, &readable, NULL, NULL, &tv);
|
||||||
|
- if (r >= 0 || errno != EINTR || got_sigterm) break;
|
||||||
|
- }
|
||||||
|
- if (r < 0) {
|
||||||
|
- error("select (waitForPADS): %m");
|
||||||
|
- return;
|
||||||
|
- }
|
||||||
|
- if (r == 0)
|
||||||
|
- return; /* Timed out */
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- /* Get the packet */
|
||||||
|
- receivePacket(conn->discoverySocket, &packet, &len);
|
||||||
|
-
|
||||||
|
- /* Check length */
|
||||||
|
- if (ntohs(packet.length) + HDR_SIZE > len) {
|
||||||
|
- error("Bogus PPPoE length field (%u)",
|
||||||
|
- (unsigned int) ntohs(packet.length));
|
||||||
|
- continue;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
-#ifdef USE_BPF
|
||||||
|
- /* If it's not a Discovery packet, loop again */
|
||||||
|
- if (etherType(&packet) != Eth_PPPOE_Discovery) continue;
|
||||||
|
-#endif
|
||||||
|
+ r = recvPacketForMe(&packet, &len, conn, start, timeout);
|
||||||
|
+ if (r<=0) return; /* Timed out or error */
|
||||||
|
|
||||||
|
/* If it's not from the AC, it's not for me */
|
||||||
|
if (memcmp(packet.ethHdr.h_source, conn->peerEth, ETH_ALEN)) continue;
|
||||||
|
|
||||||
|
- /* If it's not for us, loop again */
|
||||||
|
- if (!packetIsForMe(conn, &packet)) continue;
|
||||||
|
-
|
||||||
|
/* Is it PADS? */
|
||||||
|
if (packet.code == CODE_PADS) {
|
||||||
|
/* Parse for goodies */
|
||||||
|
diff --git a/pppd/plugins/pppoe/pppoe-discovery.c b/pppd/plugins/pppoe/pppoe-discovery.c
|
||||||
|
index e41d286..1730f29 100644
|
||||||
|
--- a/pppd/plugins/pppoe/pppoe-discovery.c
|
||||||
|
+++ b/pppd/plugins/pppoe/pppoe-discovery.c
|
||||||
|
@@ -518,6 +518,8 @@ waitForPADO(PPPoEConnection *conn, int timeout)
|
||||||
|
struct timeval tv;
|
||||||
|
PPPoEPacket packet;
|
||||||
|
int len;
|
||||||
|
+ time_t start, now;
|
||||||
|
+ int time_remain;
|
||||||
|
|
||||||
|
struct PacketCriteria pc;
|
||||||
|
pc.conn = conn;
|
||||||
|
@@ -527,9 +529,13 @@ waitForPADO(PPPoEConnection *conn, int timeout)
|
||||||
|
pc.seenServiceName = 0;
|
||||||
|
conn->error = 0;
|
||||||
|
|
||||||
|
+ time(&start);
|
||||||
|
do {
|
||||||
|
+ time(&now);
|
||||||
|
+ time_remain = timeout - (int)difftime(now, start);
|
||||||
|
+ if (time_remain <= 0) return; /* Timed out */
|
||||||
|
if (BPF_BUFFER_IS_EMPTY) {
|
||||||
|
- tv.tv_sec = timeout;
|
||||||
|
+ tv.tv_sec = time_remain;
|
||||||
|
tv.tv_usec = 0;
|
||||||
|
|
||||||
|
FD_ZERO(&readable);
|
||||||
|
--
|
||||||
|
2.30.0
|
||||||
|
|
||||||
+31
@@ -0,0 +1,31 @@
|
|||||||
|
From 9a5431023f1389c6d4f3607b2e3336c56cb1ccee Mon Sep 17 00:00:00 2001
|
||||||
|
From: Lars Wendler <polynomial-c@gentoo.org>
|
||||||
|
Date: Tue, 5 Jan 2021 12:42:39 +0100
|
||||||
|
Subject: [PATCH 13/14] Add "defaultmetric" as compatibility option name
|
||||||
|
|
||||||
|
2.4.8 release introduced "defaultroute-metric" option but we patched
|
||||||
|
a similar option called "defautlmetric" into previous releases.
|
||||||
|
Simply adding the old option name and use dfl_route_metric from the new
|
||||||
|
option.
|
||||||
|
---
|
||||||
|
pppd/options.c | 4 ++++
|
||||||
|
1 file changed, 4 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/pppd/options.c b/pppd/options.c
|
||||||
|
index 12d12fd..022f9d9 100644
|
||||||
|
--- a/pppd/options.c
|
||||||
|
+++ b/pppd/options.c
|
||||||
|
@@ -325,6 +325,10 @@ option_t general_options[] = {
|
||||||
|
"Metric to use for the default route (Linux only; -1 for default behavior)",
|
||||||
|
OPT_PRIV|OPT_LLIMIT|OPT_INITONLY, NULL, 0, -1 },
|
||||||
|
|
||||||
|
+ { "defaultmetric", o_int, &dfl_route_metric,
|
||||||
|
+ "Old (deprecated) option for default route metric (Linux only; -1 for default behavior)",
|
||||||
|
+ OPT_PRIV|OPT_LLIMIT|OPT_INITONLY, NULL, 0, -1 },
|
||||||
|
+
|
||||||
|
{ "ip-up-script", o_string, path_ipup,
|
||||||
|
"Set pathname of ip-up script",
|
||||||
|
OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
|
||||||
|
--
|
||||||
|
2.30.0
|
||||||
|
|
||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
From 44693fba1884f8e5404fd259e371350ffc8d24be Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Nelo-T. Wallus" <nelo@wallus.de>
|
||||||
|
Date: Tue, 5 Jan 2021 12:45:00 +0100
|
||||||
|
Subject: [PATCH 14/14] Warn user of deprecated option defaultmetric
|
||||||
|
|
||||||
|
---
|
||||||
|
pppd/options.c | 5 +++++
|
||||||
|
1 file changed, 5 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/pppd/options.c b/pppd/options.c
|
||||||
|
index 022f9d9..d7da8c7 100644
|
||||||
|
--- a/pppd/options.c
|
||||||
|
+++ b/pppd/options.c
|
||||||
|
@@ -684,6 +684,11 @@ process_option(option_t *opt, char *cmd, char **argv)
|
||||||
|
current_option = opt->name;
|
||||||
|
if ((opt->flags & OPT_PRIVFIX) && privileged_option)
|
||||||
|
prio += OPRIO_ROOT;
|
||||||
|
+
|
||||||
|
+ if (current_option == "defaultmetric")
|
||||||
|
+ warn("Option '%s' is deprecated, switch to 'defaultroute-metric'",
|
||||||
|
+ current_option);
|
||||||
|
+
|
||||||
|
while (mainopt->flags & OPT_PRIOSUB)
|
||||||
|
--mainopt;
|
||||||
|
if (mainopt->flags & OPT_PRIO) {
|
||||||
|
--
|
||||||
|
2.30.0
|
||||||
|
|
||||||
@@ -13,40 +13,30 @@
|
|||||||
<IsA>service</IsA>
|
<IsA>service</IsA>
|
||||||
<Summary>Point-to-point protocol - patched for PPPOE</Summary>
|
<Summary>Point-to-point protocol - patched for PPPOE</Summary>
|
||||||
<Description>The Point-to-Point Protocol (PPP) provides a standard way to transmit datagrams over a serial link.</Description>
|
<Description>The Point-to-Point Protocol (PPP) provides a standard way to transmit datagrams over a serial link.</Description>
|
||||||
<Archive sha1sum="808b023172ea7189bc0d49935bf37a5382a1fe13" type="targz">https://www.samba.org/ftp/ppp/ppp-2.4.7.tar.gz</Archive>
|
<Archive sha1sum="56ba143f331f6436efa3a1d41c75691c828833ba" type="targz">https://www.samba.org/ftp/ppp/ppp-2.4.9.tar.gz</Archive>
|
||||||
<Archive sha1sum="1a0b02788d522f2137d0b66c749ffe6c96cceb94" type="targz">http://distfiles.gentoo.org/distfiles/ppp-dhcpc.tgz</Archive>
|
<Archive sha1sum="1a0b02788d522f2137d0b66c749ffe6c96cceb94" type="targz" target="ppp-2.4.9/pppd/plugins">http://distfiles.gentoo.org/distfiles/ppp-dhcpc.tgz</Archive>
|
||||||
<BuildDependencies>
|
<BuildDependencies>
|
||||||
<Dependency>libpcap-devel</Dependency>
|
<Dependency>libpcap-devel</Dependency>
|
||||||
<Dependency>openssl-devel</Dependency>
|
<Dependency>openssl-devel</Dependency>
|
||||||
<Dependency>pam-devel</Dependency>
|
<Dependency>pam-devel</Dependency>
|
||||||
</BuildDependencies>
|
</BuildDependencies>
|
||||||
<Patches>
|
<Patches>
|
||||||
<Patch level="1">gentoo/02_all_make-vars.patch</Patch>
|
<Patch level="1">gentoo/0001-Change-Make-vars-to-work-in-Gentoo-builds.patch</Patch>
|
||||||
<Patch level="1">gentoo/04_all_mpls.patch</Patch>
|
<Patch level="1">gentoo/0002-Use-internal-implementation-of-logwtmp-function.patch</Patch>
|
||||||
<Patch level="1">gentoo/06_all_killaddr-smarter.patch</Patch>
|
<Patch level="1">gentoo/0003-Add-MPLSCP-support.patch</Patch>
|
||||||
<Patch level="1">gentoo/08_all_wait-children.patch</Patch>
|
<Patch level="1">gentoo/0004-smarter-killaddr.patch</Patch>
|
||||||
<!-- <Patch level="1">gentoo/10_all_defaultgateway.patch</Patch> -->
|
<Patch level="1">gentoo/0005-Improve-waiting-for-children-on-exit.patch</Patch>
|
||||||
<Patch level="1">gentoo/12_all_linkpidfile.patch</Patch>
|
<Patch level="1">gentoo/0006-Remove-one-of-the-2-pidfiles-pidfilename-or-linkpidf.patch</Patch>
|
||||||
<Patch level="1">gentoo/16_all_auth-fail.patch</Patch>
|
<Patch level="1">gentoo/0007-Run-etc-ppp-auth-fail-script-if-exists-and-authentic.patch</Patch>
|
||||||
<!-- <Patch level="1">gentoo/18_all_defaultmetric.patch</Patch> -->
|
<Patch level="1">gentoo/0008-Try-to-create-dev-ppp-if-not-available.patch</Patch>
|
||||||
<Patch level="1">gentoo/20_all_dev-ppp.patch</Patch>
|
<Patch level="1">gentoo/0009-passwordfd-read-early.patch</Patch>
|
||||||
<Patch level="1">gentoo/24_all_passwordfd-read-early.patch</Patch>
|
<Patch level="1">gentoo/0010-Add-option-to-ask-peer-for-WINS-address.patch</Patch>
|
||||||
<Patch level="1">gentoo/26_all_pppd-usepeerwins.patch</Patch>
|
<Patch level="1">gentoo/0011-Log-connect-errors-to-var-log-ppp-connect-errors.patch</Patch>
|
||||||
<Patch level="1">gentoo/28_all_connect-errors.patch</Patch>
|
<Patch level="1">gentoo/0012-Don-t-hang-when-starting-pppoe-connection-without-se.patch</Patch>
|
||||||
<Patch level="1">gentoo/30_all_Makefile.patch</Patch>
|
<Patch level="1">gentoo/0013-Add-defaultmetric-as-compatibility-option-name.patch</Patch>
|
||||||
<Patch level="1">gentoo/32_all_pado-timeout.patch</Patch>
|
<Patch level="1">gentoo/0014-Warn-user-of-deprecated-option-defaultmetric.patch</Patch>
|
||||||
<Patch level="1">gentoo/34_all_lcp-echo-adaptive.patch</Patch>
|
<Patch level="1">gentoo/85_all_dhcp-make-vars.patch</Patch>
|
||||||
<Patch level="1">ppp-2.3.6-sample.patch</Patch>
|
<Patch level="1">gentoo/86_all_dhcp-sys_error_to_strerror.patch</Patch>
|
||||||
<Patch level="1">ppp-2.4.3-fix64.patch</Patch>
|
|
||||||
<Patch level="1">ppp-2.4.2-change_resolv_conf.patch</Patch>
|
|
||||||
<Patch level="1">nostrip.patch</Patch>
|
|
||||||
<Patch level="1">ppp-2.4.3-local.patch</Patch>
|
|
||||||
<Patch level="1">ppp-2.4.3-ipv6-accept-remote.patch</Patch>
|
|
||||||
<Patch level="1">ppp-2.4.5-ppp_resolv.patch</Patch>
|
|
||||||
<Patch level="1">ppp-2.4.5-var_run_ppp.patch</Patch>
|
|
||||||
<!-- <Patch level="1">ppp-2.4.6-eaptls-mppe-0.99.patch</Patch> -->
|
|
||||||
<Patch level="1">0029-pppoe-include-netinet-in.h-before-linux-in.h.patch</Patch>
|
|
||||||
<Patch level="1">ppp-openssl.patch</Patch>
|
|
||||||
</Patches>
|
</Patches>
|
||||||
</Source>
|
</Source>
|
||||||
|
|
||||||
@@ -91,6 +81,13 @@
|
|||||||
</Package>
|
</Package>
|
||||||
|
|
||||||
<History>
|
<History>
|
||||||
|
<Update release="6">
|
||||||
|
<Date>2021-02-25</Date>
|
||||||
|
<Version>2.4.9</Version>
|
||||||
|
<Comment>Version bump.</Comment>
|
||||||
|
<Name>Mustafa Cinasal</Name>
|
||||||
|
<Email>muscnsl@gmail.com</Email>
|
||||||
|
</Update>
|
||||||
<Update release="5">
|
<Update release="5">
|
||||||
<Date>2020-01-21</Date>
|
<Date>2020-01-21</Date>
|
||||||
<Version>2.4.7</Version>
|
<Version>2.4.7</Version>
|
||||||
|
|||||||
Reference in New Issue
Block a user