summaryrefslogtreecommitdiffstats
path: root/patches/ppp-2.4.7
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2017-06-02 14:56:07 +0200
committerMichael Olbrich <m.olbrich@pengutronix.de>2017-06-21 09:37:01 +0200
commitcb8f516bb52bd0a197b11e03ae33e4c1343f11d0 (patch)
tree446cc7f910fc578596dcadcabc761001538c831b /patches/ppp-2.4.7
parentc98f14fbc7867cdef1246a22cd6a6b8be46bf74e (diff)
downloadptxdist-cb8f516bb52bd0a197b11e03ae33e4c1343f11d0.tar.gz
ptxdist-cb8f516bb52bd0a197b11e03ae33e4c1343f11d0.tar.xz
ppp: version bump to 2.4.7
This updates ppp to version 2.4.7. The former 2.4.5 version had the Debian package patches applied plus some ptxdist specific patches. The Debian patches have been updated to the recent 2.4.7 Debian patches, the ptxdist specific patches have been forward ported from the 2.4.5 ptxdist package. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Diffstat (limited to 'patches/ppp-2.4.7')
-rw-r--r--patches/ppp-2.4.7/0001-adaptive_echos.patch69
-rw-r--r--patches/ppp-2.4.7/0002-Makefiles-cleanup.patch291
-rw-r--r--patches/ppp-2.4.7/0003-Bug-306261-pppd-does-not-properly-close-dev-ppp-on-p.patch38
-rw-r--r--patches/ppp-2.4.7/0004-Bug-284382-ppp-linkpidfile-is-not-created-upon-detac.patch44
-rw-r--r--patches/ppp-2.4.7/0005-support-building-pppdump-with-the-system-zlib.patch57
-rw-r--r--patches/ppp-2.4.7/0006-disable-unneeded-code-in-the-pppoatm-plugin.patch88
-rw-r--r--patches/ppp-2.4.7/0007-cosmetic-cleanup-of-the-pppoatm-plugin.patch85
-rw-r--r--patches/ppp-2.4.7/0008-pppoe_noads.patch22
-rw-r--r--patches/ppp-2.4.7/0009-make-_PATH_CONNERRS-world-readable.patch22
-rw-r--r--patches/ppp-2.4.7/0010-Correct-unkown-unknown-typo.patch39
-rw-r--r--patches/ppp-2.4.7/0011-pppoe-custom-host-uniq-tag.patch298
-rw-r--r--patches/ppp-2.4.7/0012-scripts_redialer.patch162
-rw-r--r--patches/ppp-2.4.7/0013-Add-replacedefaultroute-option.patch319
-rw-r--r--patches/ppp-2.4.7/0014-ppp-2.3.11-oedod.patch191
-rw-r--r--patches/ppp-2.4.7/0015-add-support-for-the-Framed-MTU-Radius-attribute.patch26
-rw-r--r--patches/ppp-2.4.7/0016-ip-up_option.patch103
-rw-r--r--patches/ppp-2.4.7/0017-ppp-2.4.2-stripMSdomain.patch44
-rw-r--r--patches/ppp-2.4.7/0018-export-CALL_FILE-to-the-link-scripts.patch35
-rw-r--r--patches/ppp-2.4.7/0019-ipv6-accept-remote.patch70
-rw-r--r--patches/ppp-2.4.7/0020-allow-use-of-arbitrary-interface-names.patch210
-rw-r--r--patches/ppp-2.4.7/0021-fix-a-potential-buffer-overflow-in-clientid.c-rc_map.patch38
-rw-r--r--patches/ppp-2.4.7/0022-scripts-README.patch30
-rw-r--r--patches/ppp-2.4.7/0023-no_crypt_hack.patch61
-rw-r--r--patches/ppp-2.4.7/0024-resolv.conf_no_log.patch21
-rw-r--r--patches/ppp-2.4.7/0025-Debian-specific-changes.patch86
-rw-r--r--patches/ppp-2.4.7/0026-secure-card-interpreter-fix.patch26
-rw-r--r--patches/ppp-2.4.7/0027-Fix-buffer-overflow-in-rc_mksid.patch30
-rw-r--r--patches/ppp-2.4.7/0028-Add-a-SONAME-to-the-pppd-binary.patch38
-rw-r--r--patches/ppp-2.4.7/0029-Fix-FTBFS-in-rp-pppoe.patch36
-rw-r--r--patches/ppp-2.4.7/0030-pppd-make-makefile-sysroot-aware.patch38
-rw-r--r--patches/ppp-2.4.7/0031-pppd-make-the-self-made-configure-cross-aware.patch44
-rw-r--r--patches/ppp-2.4.7/series34
32 files changed, 2695 insertions, 0 deletions
diff --git a/patches/ppp-2.4.7/0001-adaptive_echos.patch b/patches/ppp-2.4.7/0001-adaptive_echos.patch
new file mode 100644
index 000000000..c736a350d
--- /dev/null
+++ b/patches/ppp-2.4.7/0001-adaptive_echos.patch
@@ -0,0 +1,69 @@
+From: Marco d'Itri <md@linux.it>
+Date: Thu, 1 Jun 2017 16:18:34 +0200
+Subject: [PATCH] adaptive_echos
+
+---
+ pppd/lcp.c | 19 +++++++++++++++++++
+ pppd/pppd.8 | 5 +++++
+ 2 files changed, 24 insertions(+)
+
+diff --git a/pppd/lcp.c b/pppd/lcp.c
+index 8ed2778bfb67..c97a64b7774f 100644
+--- a/pppd/lcp.c
++++ b/pppd/lcp.c
+@@ -73,6 +73,7 @@ static void lcp_delayed_up __P((void *));
+ */
+ int lcp_echo_interval = 0; /* Interval between LCP echo-requests */
+ int lcp_echo_fails = 0; /* Tolerance to unanswered echo-requests */
++bool lcp_echo_adaptive = 0; /* request echo only if the link was idle */
+ bool lax_recv = 0; /* accept control chars in asyncmap */
+ bool noendpoint = 0; /* don't send/accept endpoint discriminator */
+
+@@ -151,6 +152,8 @@ static option_t lcp_option_list[] = {
+ OPT_PRIO },
+ { "lcp-echo-interval", o_int, &lcp_echo_interval,
+ "Set time in seconds between LCP echo requests", OPT_PRIO },
++ { "lcp-echo-adaptive", o_bool, &lcp_echo_adaptive,
++ "Suppress LCP echo requests if traffic was received", 1 },
+ { "lcp-restart", o_int, &lcp_fsm[0].timeouttime,
+ "Set time in seconds between LCP retransmissions", OPT_PRIO },
+ { "lcp-max-terminate", o_int, &lcp_fsm[0].maxtermtransmits,
+@@ -2332,6 +2335,22 @@ LcpSendEchoRequest (f)
+ }
+
+ /*
++ * If adaptive echos have been enabled, only send the echo request if
++ * no traffic was received since the last one.
++ */
++ if (lcp_echo_adaptive) {
++ static unsigned int last_pkts_in = 0;
++
++ update_link_stats(f->unit);
++ link_stats_valid = 0;
++
++ if (link_stats.pkts_in != last_pkts_in) {
++ last_pkts_in = link_stats.pkts_in;
++ return;
++ }
++ }
++
++ /*
+ * Make and send the echo request frame.
+ */
+ if (f->state == OPENED) {
+diff --git a/pppd/pppd.8 b/pppd/pppd.8
+index e2768b135273..b7fd0bdaab52 100644
+--- a/pppd/pppd.8
++++ b/pppd/pppd.8
+@@ -558,6 +558,11 @@ to 1) if the \fIproxyarp\fR option is used, and will enable the
+ dynamic IP address option (i.e. set /proc/sys/net/ipv4/ip_dynaddr to
+ 1) in demand mode if the local address changes.
+ .TP
++.B lcp\-echo\-adaptive
++If this option is used with the \fIlcp\-echo\-failure\fR option then
++pppd will send LCP echo\-request frames only if no traffic was received
++from the peer since the last echo\-request was sent.
++.TP
+ .B lcp\-echo\-failure \fIn
+ If this option is given, pppd will presume the peer to be dead
+ if \fIn\fR LCP echo\-requests are sent without receiving a valid LCP
diff --git a/patches/ppp-2.4.7/0002-Makefiles-cleanup.patch b/patches/ppp-2.4.7/0002-Makefiles-cleanup.patch
new file mode 100644
index 000000000..94871e177
--- /dev/null
+++ b/patches/ppp-2.4.7/0002-Makefiles-cleanup.patch
@@ -0,0 +1,291 @@
+From: Marco d'Itri <md@linux.it>
+Date: Thu, 1 Jun 2017 16:19:36 +0200
+Subject: [PATCH] Makefiles cleanup
+
+Factor-out $COPTS and $LDOPTS to allow distributions to easily override
+them. Properly use $LDFLAGS when linking and $CFLAGS when compiling.
+Do not strip the installed binaries: this should be done by the
+packaging system if required.
+---
+ chat/Makefile.linux | 5 +++--
+ pppd/Makefile.linux | 7 ++++---
+ pppd/plugins/Makefile.linux | 4 ++--
+ pppd/plugins/pppoatm/Makefile.linux | 4 ++--
+ pppd/plugins/pppol2tp/Makefile.linux | 4 ++--
+ pppd/plugins/radius/Makefile.linux | 16 +++++++++-------
+ pppd/plugins/rp-pppoe/Makefile.linux | 10 ++++++----
+ pppdump/Makefile.linux | 9 ++++++---
+ pppstats/Makefile.linux | 7 ++++---
+ 9 files changed, 38 insertions(+), 28 deletions(-)
+
+diff --git a/chat/Makefile.linux b/chat/Makefile.linux
+index 1065ac519576..a41d485b4168 100644
+--- a/chat/Makefile.linux
++++ b/chat/Makefile.linux
+@@ -12,20 +12,21 @@ CDEFS= $(CDEF1) $(CDEF2) $(CDEF3) $(CDEF4)
+
+ COPTS= -O2 -g -pipe
+ CFLAGS= $(COPTS) $(CDEFS)
++LDFLAGS=$(LDOPTS)
+
+ INSTALL= install
+
+ all: chat
+
+ chat: chat.o
+- $(CC) -o chat chat.o
++ $(CC) $(LDFLAGS) -o chat chat.o
+
+ chat.o: chat.c
+ $(CC) -c $(CFLAGS) -o chat.o chat.c
+
+ install: chat
+ mkdir -p $(BINDIR) $(MANDIR)
+- $(INSTALL) -s -c chat $(BINDIR)
++ $(INSTALL) -c chat $(BINDIR)
+ $(INSTALL) -c -m 644 chat.8 $(MANDIR)
+
+ clean:
+diff --git a/pppd/Makefile.linux b/pppd/Makefile.linux
+index a74c914fd3ac..16b3ee879791 100644
+--- a/pppd/Makefile.linux
++++ b/pppd/Makefile.linux
+@@ -83,6 +83,7 @@ INCLUDE_DIRS= -I../include
+ COMPILE_FLAGS= -DHAVE_PATHS_H -DIPX_CHANGE -DHAVE_MMAP
+
+ CFLAGS= $(COPTS) $(COMPILE_FLAGS) $(INCLUDE_DIRS) '-DDESTDIR="@DESTDIR@"'
++LDFLAGS=$(LDOPTS)
+
+ ifdef CHAPMS
+ CFLAGS += -DCHAPMS=1
+@@ -102,7 +103,7 @@ ifdef USE_SRP
+ CFLAGS += -DUSE_SRP -DOPENSSL -I/usr/local/ssl/include
+ LIBS += -lsrp -L/usr/local/ssl/lib -lcrypto
+ TARGETS += srp-entry
+-EXTRAINSTALL = $(INSTALL) -s -c -m 555 srp-entry $(BINDIR)/srp-entry
++EXTRAINSTALL = $(INSTALL) -c -m 555 srp-entry $(BINDIR)/srp-entry
+ MANPAGES += srp-entry.8
+ EXTRACLEAN += srp-entry.o
+ NEEDDES=y
+@@ -208,13 +209,13 @@ all: $(TARGETS)
+ install: pppd
+ mkdir -p $(BINDIR) $(MANDIR)
+ $(EXTRAINSTALL)
+- $(INSTALL) -s -c -m 555 pppd $(BINDIR)/pppd
++ $(INSTALL) -c -m 555 pppd $(BINDIR)/pppd
+ if chgrp pppusers $(BINDIR)/pppd 2>/dev/null; then \
+ chmod o-rx,u+s $(BINDIR)/pppd; fi
+ $(INSTALL) -c -m 444 pppd.8 $(MANDIR)
+
+ pppd: $(PPPDOBJS)
+- $(CC) $(CFLAGS) $(LDFLAGS) -o pppd $(PPPDOBJS) $(LIBS)
++ $(CC) $(LDFLAGS) -o pppd $(PPPDOBJS) $(LIBS)
+
+ srp-entry: srp-entry.c
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ srp-entry.c $(LIBS)
+diff --git a/pppd/plugins/Makefile.linux b/pppd/plugins/Makefile.linux
+index ab8cf50d9472..732cc8b411d2 100644
+--- a/pppd/plugins/Makefile.linux
++++ b/pppd/plugins/Makefile.linux
+@@ -1,7 +1,7 @@
+ #CC = gcc
+ COPTS = -O2 -g
+ CFLAGS = $(COPTS) -I.. -I../../include -fPIC
+-LDFLAGS = -shared
++LDFLAGS = $(LDOPTS)
+ INSTALL = install
+
+ DESTDIR = $(INSTROOT)@DESTDIR@
+@@ -30,7 +30,7 @@ all: $(PLUGINS)
+ for d in $(SUBDIRS); do $(MAKE) $(MFLAGS) -C $$d all; done
+
+ %.so: %.c
+- $(CC) -o $@ $(LDFLAGS) $(CFLAGS) $^
++ $(CC) -o $@ $(LDFLAGS) -shared $(CFLAGS) $^
+
+ VERSION = $(shell awk -F '"' '/VERSION/ { print $$2; }' ../patchlevel.h)
+
+diff --git a/pppd/plugins/pppoatm/Makefile.linux b/pppd/plugins/pppoatm/Makefile.linux
+index 20f62e631d23..002603c6cbef 100644
+--- a/pppd/plugins/pppoatm/Makefile.linux
++++ b/pppd/plugins/pppoatm/Makefile.linux
+@@ -1,7 +1,7 @@
+ #CC = gcc
+ COPTS = -O2 -g
+ CFLAGS = $(COPTS) -I../.. -I../../../include -fPIC
+-LDFLAGS = -shared
++LDFLAGS = $(LDOPTS)
+ INSTALL = install
+
+ #***********************************************************************
+@@ -33,7 +33,7 @@ endif
+ all: $(PLUGIN)
+
+ $(PLUGIN): $(PLUGIN_OBJS)
+- $(CC) $(CFLAGS) -o $@ -shared $^ $(LIBS)
++ $(CC) $(LDFLAGS) -o $@ -shared $^ $(LIBS)
+
+ install: all
+ $(INSTALL) -d -m 755 $(LIBDIR)
+diff --git a/pppd/plugins/pppol2tp/Makefile.linux b/pppd/plugins/pppol2tp/Makefile.linux
+index ea3538e22d56..de5cc12e79c3 100644
+--- a/pppd/plugins/pppol2tp/Makefile.linux
++++ b/pppd/plugins/pppol2tp/Makefile.linux
+@@ -1,7 +1,7 @@
+ #CC = gcc
+ COPTS = -O2 -g
+ CFLAGS = $(COPTS) -I. -I../.. -I../../../include -fPIC
+-LDFLAGS = -shared
++LDFLAGS = $(LDOPTS)
+ INSTALL = install
+
+ #***********************************************************************
+@@ -16,7 +16,7 @@ PLUGINS := pppol2tp.so openl2tp.so
+ all: $(PLUGINS)
+
+ %.so: %.o
+- $(CC) $(CFLAGS) -o $@ -shared $^ $(LIBS)
++ $(CC) $(LDFLAGS) -o $@ -shared $^ $(LIBS)
+
+ install: all
+ $(INSTALL) -d -m 755 $(LIBDIR)
+diff --git a/pppd/plugins/radius/Makefile.linux b/pppd/plugins/radius/Makefile.linux
+index 24ed3e580c4d..436ff2fd0c23 100644
+--- a/pppd/plugins/radius/Makefile.linux
++++ b/pppd/plugins/radius/Makefile.linux
+@@ -12,7 +12,9 @@ VERSION = $(shell awk -F '"' '/VERSION/ { print $$2; }' ../../patchlevel.h)
+ INSTALL = install
+
+ PLUGIN=radius.so radattr.so radrealms.so
+-CFLAGS=-I. -I../.. -I../../../include -O2 -fPIC -DRC_LOG_FACILITY=LOG_DAEMON
++COPTS=-g -O2
++CFLAGS = $(COPTS) -I. -I../.. -I../../../include -fPIC -DRC_LOG_FACILITY=LOG_DAEMON
++LDFLAGS= $(LDOPTS)
+
+ # Uncomment the next line to include support for Microsoft's
+ # MS-CHAP authentication protocol.
+@@ -36,20 +38,20 @@ all: $(PLUGIN)
+
+ install: all
+ $(INSTALL) -d -m 755 $(LIBDIR)
+- $(INSTALL) -s -c -m 755 radius.so $(LIBDIR)
+- $(INSTALL) -s -c -m 755 radattr.so $(LIBDIR)
+- $(INSTALL) -s -c -m 755 radrealms.so $(LIBDIR)
++ $(INSTALL) -c -m 755 radius.so $(LIBDIR)
++ $(INSTALL) -c -m 755 radattr.so $(LIBDIR)
++ $(INSTALL) -c -m 755 radrealms.so $(LIBDIR)
+ $(INSTALL) -c -m 444 pppd-radius.8 $(MANDIR)
+ $(INSTALL) -c -m 444 pppd-radattr.8 $(MANDIR)
+
+ radius.so: radius.o libradiusclient.a
+- $(CC) -o radius.so -shared radius.o libradiusclient.a
++ $(CC) $(LDFLAGS) -o radius.so -shared radius.o libradiusclient.a
+
+ radattr.so: radattr.o
+- $(CC) -o radattr.so -shared radattr.o
++ $(CC) $(LDFLAGS) -o radattr.so -shared radattr.o
+
+ radrealms.so: radrealms.o
+- $(CC) -o radrealms.so -shared radrealms.o
++ $(CC) $(LDFLAGS) -o radrealms.so -shared radrealms.o
+
+ CLIENTOBJS = avpair.o buildreq.o config.o dict.o ip_util.o \
+ clientid.o sendserver.o lock.o util.o md5.o
+diff --git a/pppd/plugins/rp-pppoe/Makefile.linux b/pppd/plugins/rp-pppoe/Makefile.linux
+index 5d7a2719545d..00e0af6da20c 100644
+--- a/pppd/plugins/rp-pppoe/Makefile.linux
++++ b/pppd/plugins/rp-pppoe/Makefile.linux
+@@ -27,10 +27,12 @@ RP_VERSION=3.8p
+
+ COPTS=-O2 -g
+ CFLAGS=$(COPTS) -I../../../include '-DRP_VERSION="$(RP_VERSION)"'
++LDFLAGS=$(LDOPTS)
++
+ all: rp-pppoe.so pppoe-discovery
+
+ pppoe-discovery: pppoe-discovery.o debug.o
+- $(CC) -o pppoe-discovery pppoe-discovery.o debug.o
++ $(CC) $(LDFLAGS) -o pppoe-discovery pppoe-discovery.o debug.o
+
+ pppoe-discovery.o: pppoe-discovery.c
+ $(CC) $(CFLAGS) -c -o pppoe-discovery.o pppoe-discovery.c
+@@ -39,13 +41,13 @@ debug.o: debug.c
+ $(CC) $(CFLAGS) -c -o debug.o debug.c
+
+ rp-pppoe.so: plugin.o discovery.o if.o common.o
+- $(CC) -o rp-pppoe.so -shared plugin.o discovery.o if.o common.o
++ $(CC) $(LDFLAGS) -o rp-pppoe.so -shared $^
+
+ install: all
+ $(INSTALL) -d -m 755 $(LIBDIR)
+- $(INSTALL) -s -c -m 4550 rp-pppoe.so $(LIBDIR)
++ $(INSTALL) -c -m 4550 rp-pppoe.so $(LIBDIR)
+ $(INSTALL) -d -m 755 $(BINDIR)
+- $(INSTALL) -s -c -m 555 pppoe-discovery $(BINDIR)
++ $(INSTALL) -c -m 555 pppoe-discovery $(BINDIR)
+
+ clean:
+ rm -f *.o *.so pppoe-discovery
+diff --git a/pppdump/Makefile.linux b/pppdump/Makefile.linux
+index ac028f6bf4f0..65e5c14914fb 100644
+--- a/pppdump/Makefile.linux
++++ b/pppdump/Makefile.linux
+@@ -2,7 +2,10 @@ DESTDIR = $(INSTROOT)@DESTDIR@
+ BINDIR = $(DESTDIR)/sbin
+ MANDIR = $(DESTDIR)/share/man/man8
+
+-CFLAGS= -O -I../include/net
++COPTS=-O2 -g
++CFLAGS= $(COPTS) -I../include/net
++LDFLAGS=$(LDOPTS)
++
+ OBJS = pppdump.o bsd-comp.o deflate.o zlib.o
+
+ INSTALL= install
+@@ -10,12 +13,12 @@ INSTALL= install
+ all: pppdump
+
+ pppdump: $(OBJS)
+- $(CC) -o pppdump $(OBJS)
++ $(CC) $(LDFLAGS) -o pppdump $(OBJS)
+
+ clean:
+ rm -f pppdump $(OBJS) *~
+
+ install:
+ mkdir -p $(BINDIR) $(MANDIR)
+- $(INSTALL) -s -c pppdump $(BINDIR)
++ $(INSTALL) -c pppdump $(BINDIR)
+ $(INSTALL) -c -m 444 pppdump.8 $(MANDIR)
+diff --git a/pppstats/Makefile.linux b/pppstats/Makefile.linux
+index cca6f0f61d87..9ec8e803665a 100644
+--- a/pppstats/Makefile.linux
++++ b/pppstats/Makefile.linux
+@@ -10,23 +10,24 @@ PPPSTATSRCS = pppstats.c
+ PPPSTATOBJS = pppstats.o
+
+ #CC = gcc
+-COPTS = -O
++COPTS = -O2 -g
+ COMPILE_FLAGS = -I../include
+ LIBS =
+
+ INSTALL= install
+
+ CFLAGS = $(COPTS) $(COMPILE_FLAGS)
++LDFLAGS= $(LDOPTS)
+
+ all: pppstats
+
+ install: pppstats
+ -mkdir -p $(MANDIR)
+- $(INSTALL) -s -c pppstats $(BINDIR)
++ $(INSTALL) -c pppstats $(BINDIR)
+ $(INSTALL) -c -m 444 pppstats.8 $(MANDIR)
+
+ pppstats: $(PPPSTATSRCS)
+- $(CC) $(CFLAGS) -o pppstats pppstats.c $(LIBS)
++ $(CC) $(LDFLAGS) $(CFLAGS) -o pppstats pppstats.c $(LIBS)
+
+ clean:
+ rm -f pppstats *~ #* core
diff --git a/patches/ppp-2.4.7/0003-Bug-306261-pppd-does-not-properly-close-dev-ppp-on-p.patch b/patches/ppp-2.4.7/0003-Bug-306261-pppd-does-not-properly-close-dev-ppp-on-p.patch
new file mode 100644
index 000000000..4c598ea63
--- /dev/null
+++ b/patches/ppp-2.4.7/0003-Bug-306261-pppd-does-not-properly-close-dev-ppp-on-p.patch
@@ -0,0 +1,38 @@
+From: Simon Peter <dn.tlp@gmx.net>
+Date: Fri, 2 Jun 2017 11:03:30 +0200
+Subject: [PATCH] Bug#306261: pppd does not properly close /dev/ppp on persist
+
+When using the kernel PPPoE driver, pppd never
+closes /dev/ppp when the link has come down.
+
+It opens superfluous fds to the device each time it re-opens the
+connection, with the unclosed ones falsely reported always ready for
+data by select().
+
+This makes pppd eat up 100% CPU time after the first persist because of
+the always instantly returning select() on the unclosed fds.
+
+The problem also occurs with the upstream version, but does not occur
+when a pty/tty device is used for the ppp connection.
+---
+ pppd/sys-linux.c | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/pppd/sys-linux.c b/pppd/sys-linux.c
+index e5e9baf8821f..f92174854207 100644
+--- a/pppd/sys-linux.c
++++ b/pppd/sys-linux.c
+@@ -458,6 +458,13 @@ int generic_establish_ppp (int fd)
+ if (new_style_driver) {
+ int flags;
+
++ /* if a ppp_fd is already open, close it first */
++ if(ppp_fd > 0) {
++ close(ppp_fd);
++ remove_fd(ppp_fd);
++ ppp_fd = -1;
++ }
++
+ /* Open an instance of /dev/ppp and connect the channel to it */
+ if (ioctl(fd, PPPIOCGCHAN, &chindex) == -1) {
+ error("Couldn't get channel number: %m");
diff --git a/patches/ppp-2.4.7/0004-Bug-284382-ppp-linkpidfile-is-not-created-upon-detac.patch b/patches/ppp-2.4.7/0004-Bug-284382-ppp-linkpidfile-is-not-created-upon-detac.patch
new file mode 100644
index 000000000..cc65303ad
--- /dev/null
+++ b/patches/ppp-2.4.7/0004-Bug-284382-ppp-linkpidfile-is-not-created-upon-detac.patch
@@ -0,0 +1,44 @@
+From: "herbert@gondor.apana.org.au" <herbert@gondor.apana.org.au>
+Date: Fri, 2 Jun 2017 11:08:21 +0200
+Subject: [PATCH] Bug#284382: ppp: linkpidfile is not created upon detachment
+
+Package: ppp
+Version: 2.4.2+20040428-2
+Severity: wishlist
+
+When pppd detaches from the parent normally, that is, without nodetach
+or updetach set, the linkpidfile is not created even when linkname is
+set.
+
+This is because the create_linkpidfile call in detach() is only made
+if the linkpidfile is filled in. However, linkpidfile is never filled
+in until create_linkpidfile has been called.
+
+IMHO the call should be made uncondtionally in detach() since
+create_linkpidfile does its own check on linkname anyway.
+
+Please note that the version of pppd in woody always wrote the
+linkpidfile after detaching. It did so in main() however. That
+call has now been removed which is why I'm seeing this problem.
+
+[...]
+
+--
+---
+ pppd/main.c | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/pppd/main.c b/pppd/main.c
+index 6d50d1bac1d9..439fedced8ff 100644
+--- a/pppd/main.c
++++ b/pppd/main.c
+@@ -770,8 +770,7 @@ detach()
+ /* update pid files if they have been written already */
+ if (pidfilename[0])
+ create_pidfile(pid);
+- if (linkpidfile[0])
+- create_linkpidfile(pid);
++ create_linkpidfile(pid);
+ exit(0); /* parent dies */
+ }
+ setsid();
diff --git a/patches/ppp-2.4.7/0005-support-building-pppdump-with-the-system-zlib.patch b/patches/ppp-2.4.7/0005-support-building-pppdump-with-the-system-zlib.patch
new file mode 100644
index 000000000..ef5ef1e6d
--- /dev/null
+++ b/patches/ppp-2.4.7/0005-support-building-pppdump-with-the-system-zlib.patch
@@ -0,0 +1,57 @@
+From: Marco d'Itri <md@linux.it>
+Date: Fri, 2 Jun 2017 11:09:30 +0200
+Subject: [PATCH] support building pppdump with the system zlib
+
+---
+ pppdump/Makefile.linux | 28 ++++++++++++++++++++++++++--
+ 1 file changed, 26 insertions(+), 2 deletions(-)
+
+diff --git a/pppdump/Makefile.linux b/pppdump/Makefile.linux
+index 65e5c14914fb..87777fab5e94 100644
+--- a/pppdump/Makefile.linux
++++ b/pppdump/Makefile.linux
+@@ -2,18 +2,42 @@ DESTDIR = $(INSTROOT)@DESTDIR@
+ BINDIR = $(DESTDIR)/sbin
+ MANDIR = $(DESTDIR)/share/man/man8
+
++DO_DEFLATE=y
++DO_BSD_COMPRESS=y
++HAVE_ZLIB=n
++
+ COPTS=-O2 -g
+ CFLAGS= $(COPTS) -I../include/net
+ LDFLAGS=$(LDOPTS)
+
+-OBJS = pppdump.o bsd-comp.o deflate.o zlib.o
++OBJS = pppdump.o
++LIBS =
++
++ifdef DO_DEFLATE
++CFLAGS += -DDO_DEFLATE=1
++OBJS += deflate.o
++ifdef HAVE_ZLIB
++LIBS += -lz
++else
++OBJS += zlib.o
++endif
++else
++CFLAGS += -DDO_DEFLATE=0
++endif
++
++ifdef DO_BSD_COMPRESS
++CFLAGS += -DDO_BSD_COMPRESS=1
++OBJS += bsd-comp.o
++else
++CFLAGS += -DDO_BSD_COMPRESS=0
++endif
+
+ INSTALL= install
+
+ all: pppdump
+
+ pppdump: $(OBJS)
+- $(CC) $(LDFLAGS) -o pppdump $(OBJS)
++ $(CC) $(LDFLAGS) -o pppdump $(OBJS) $(LIBS)
+
+ clean:
+ rm -f pppdump $(OBJS) *~
diff --git a/patches/ppp-2.4.7/0006-disable-unneeded-code-in-the-pppoatm-plugin.patch b/patches/ppp-2.4.7/0006-disable-unneeded-code-in-the-pppoatm-plugin.patch
new file mode 100644
index 000000000..55e262592
--- /dev/null
+++ b/patches/ppp-2.4.7/0006-disable-unneeded-code-in-the-pppoatm-plugin.patch
@@ -0,0 +1,88 @@
+From: Marco d'Itri <md@linux.it>
+Date: Fri, 2 Jun 2017 11:10:13 +0200
+Subject: [PATCH] disable unneeded code in the pppoatm plugin
+
+This patch halves the size of the PPPoA plugin by disabling features
+which are never used with normal DSL connections (i.e. parsing of QoS
+configuration directives and DNS resolution of VP/VC addresses).
+It is especially useful for install images and embedded systems.
+
+A next step could be removing text2qos.c, text2atm.c, misc.c and ans.c
+and encourage users interested in the complete features to link the
+plugin with the real libatm. I really doubt anybody cares, anyway.
+---
+ pppd/plugins/pppoatm/Makefile.linux | 4 ++++
+ pppd/plugins/pppoatm/pppoatm.c | 4 ++++
+ pppd/plugins/pppoatm/text2atm.c | 4 ++++
+ 3 files changed, 12 insertions(+)
+
+diff --git a/pppd/plugins/pppoatm/Makefile.linux b/pppd/plugins/pppoatm/Makefile.linux
+index 002603c6cbef..76d81aced70a 100644
+--- a/pppd/plugins/pppoatm/Makefile.linux
++++ b/pppd/plugins/pppoatm/Makefile.linux
+@@ -25,9 +25,13 @@ ifdef HAVE_LIBATM
+ LIBS := -latm
+ else
+ CFLAGS += -I.
++PLUGIN_OBJS += text2atm.o
++ifdef USE_FULL_ATM_RESOLVER
++CFLAGS += -DUSE_FULL_ATM_RESOLVER
+ PLUGIN_OBJS += text2qos.o text2atm.o misc.o ans.o
+ LIBS := -lresolv
+ endif
++endif
+
+ #*********
+ all: $(PLUGIN)
+diff --git a/pppd/plugins/pppoatm/pppoatm.c b/pppd/plugins/pppoatm/pppoatm.c
+index d693350bc473..a7560e9fb0c6 100644
+--- a/pppd/plugins/pppoatm/pppoatm.c
++++ b/pppd/plugins/pppoatm/pppoatm.c
+@@ -142,8 +142,12 @@ static int connect_pppoatm(void)
+ qos.txtp.traffic_class = qos.rxtp.traffic_class = ATM_UBR;
+ /* TODO: support simplified QoS setting */
+ if (qosstr != NULL)
++#ifdef USE_FULL_ATM_RESOLVER
+ if (text2qos(qosstr, &qos, 0))
+ fatal("Can't parse QoS: \"%s\"");
++#else
++ fatal("qos support has not been compiled in");
++#endif
+ qos.txtp.max_sdu = lcp_allowoptions[0].mru + pppoatm_overhead();
+ qos.rxtp.max_sdu = lcp_wantoptions[0].mru + pppoatm_overhead();
+ qos.aal = ATM_AAL5;
+diff --git a/pppd/plugins/pppoatm/text2atm.c b/pppd/plugins/pppoatm/text2atm.c
+index c283b52b4120..f7fa8cac3a6f 100644
+--- a/pppd/plugins/pppoatm/text2atm.c
++++ b/pppd/plugins/pppoatm/text2atm.c
+@@ -72,6 +72,7 @@ static int try_pvc(const char *text,struct sockaddr_atmpvc *addr,int flags)
+ }
+
+
++#ifdef USE_FULL_ATM_RESOLVER
+ static int do_try_nsap(const char *text,struct sockaddr_atmsvc *addr,int flags)
+ {
+ const char *walk;
+@@ -221,6 +222,7 @@ static int try_name(const char *text,struct sockaddr *addr,int length,
+ (void) fclose(file);
+ return result;
+ }
++#endif
+
+
+ int text2atm(const char *text,struct sockaddr *addr,int length,int flags)
+@@ -234,6 +236,7 @@ int text2atm(const char *text,struct sockaddr *addr,int length,int flags)
+ result = try_pvc(text,(struct sockaddr_atmpvc *) addr,flags);
+ if (result != TRY_OTHER) return result;
+ }
++#ifdef USE_FULL_ATM_RESOLVER
+ if ((flags & T2A_SVC) && length >= sizeof(struct sockaddr_atmsvc)) {
+ result = try_nsap(text,(struct sockaddr_atmsvc *) addr,flags);
+ if (result != TRY_OTHER) return result;
+@@ -245,5 +248,6 @@ int text2atm(const char *text,struct sockaddr *addr,int length,int flags)
+ if (result == TRY_OTHER && !(flags & T2A_LOCAL))
+ result = ans_byname(text,(struct sockaddr_atmsvc *) addr,length,flags);
+ if (result != TRY_OTHER) return result;
++#endif
+ return -1;
+ }
diff --git a/patches/ppp-2.4.7/0007-cosmetic-cleanup-of-the-pppoatm-plugin.patch b/patches/ppp-2.4.7/0007-cosmetic-cleanup-of-the-pppoatm-plugin.patch
new file mode 100644
index 000000000..551bb2dbb
--- /dev/null
+++ b/patches/ppp-2.4.7/0007-cosmetic-cleanup-of-the-pppoatm-plugin.patch
@@ -0,0 +1,85 @@
+From: Marco d'Itri <md@linux.it>
+Date: Fri, 2 Jun 2017 11:10:33 +0200
+Subject: [PATCH] cosmetic cleanup of the pppoatm plugin
+
+Removed some debugging messages and generally cleaned up the source.
+---
+ pppd/plugins/pppoatm/pppoatm.c | 23 +++++++++++++----------
+ 1 file changed, 13 insertions(+), 10 deletions(-)
+
+diff --git a/pppd/plugins/pppoatm/pppoatm.c b/pppd/plugins/pppoatm/pppoatm.c
+index a7560e9fb0c6..90d0c9a85d9f 100644
+--- a/pppd/plugins/pppoatm/pppoatm.c
++++ b/pppd/plugins/pppoatm/pppoatm.c
+@@ -70,18 +70,20 @@ static int setdevname_pppoatm(const char *cp, const char **argv, int doit)
+ {
+ struct sockaddr_atmpvc addr;
+ extern struct stat devstat;
++
+ if (device_got_set)
+ return 0;
+- //info("PPPoATM setdevname_pppoatm: '%s'", cp);
++
+ memset(&addr, 0, sizeof addr);
+ if (text2atm(cp, (struct sockaddr *) &addr, sizeof(addr),
+- T2A_PVC | T2A_NAME) < 0) {
+- if(doit)
+- info("atm does not recognize: %s", cp);
++ T2A_PVC | T2A_NAME | T2A_WILDCARD) < 0) {
++ if (doit)
++ info("cannot parse the ATM address: %s", cp);
+ return 0;
+- }
+- if (!doit) return 1;
+- //if (!dev_set_ok()) return -1;
++ }
++ if (!doit)
++ return 1;
++
+ memcpy(&pvcaddr, &addr, sizeof pvcaddr);
+ strlcpy(devnam, cp, sizeof devnam);
+ devstat.st_mode = S_IFSOCK;
+@@ -93,7 +95,6 @@ static int setdevname_pppoatm(const char *cp, const char **argv, int doit)
+ lcp_allowoptions[0].neg_asyncmap = 0;
+ lcp_wantoptions[0].neg_pcompression = 0;
+ }
+- info("PPPoATM setdevname_pppoatm - SUCCESS:%s", cp);
+ device_got_set = 1;
+ return 1;
+ }
+@@ -108,6 +109,7 @@ static void no_device_given_pppoatm(void)
+ static void set_line_discipline_pppoatm(int fd)
+ {
+ struct atm_backend_ppp be;
++
+ be.backend_num = ATM_BACKEND_PPP;
+ if (!llc_encaps)
+ be.encaps = PPPOATM_ENCAPS_VC;
+@@ -115,6 +117,7 @@ static void set_line_discipline_pppoatm(int fd)
+ be.encaps = PPPOATM_ENCAPS_LLC;
+ else
+ be.encaps = PPPOATM_ENCAPS_AUTODETECT;
++
+ if (ioctl(fd, ATM_SETBACKEND, &be) < 0)
+ fatal("ioctl(ATM_SETBACKEND): %m");
+ }
+@@ -172,7 +175,7 @@ static void disconnect_pppoatm(void)
+
+ void plugin_init(void)
+ {
+-#if defined(__linux__)
++#ifdef linux
+ extern int new_style_driver; /* From sys-linux.c */
+ if (!ppp_available() && !new_style_driver)
+ fatal("Kernel doesn't support ppp_generic - "
+@@ -180,9 +183,9 @@ void plugin_init(void)
+ #else
+ fatal("No PPPoATM support on this OS");
+ #endif
+- info("PPPoATM plugin_init");
+ add_options(pppoa_options);
+ }
++
+ struct channel pppoa_channel = {
+ options: pppoa_options,
+ process_extra_options: NULL,
diff --git a/patches/ppp-2.4.7/0008-pppoe_noads.patch b/patches/ppp-2.4.7/0008-pppoe_noads.patch
new file mode 100644
index 000000000..7274b2de4
--- /dev/null
+++ b/patches/ppp-2.4.7/0008-pppoe_noads.patch
@@ -0,0 +1,22 @@
+From: Marco d'Itri <md@linux.it>
+Date: Fri, 2 Jun 2017 11:11:22 +0200
+Subject: [PATCH] pppoe_noads
+
+---
+ pppd/plugins/rp-pppoe/plugin.c | 3 ---
+ 1 file changed, 3 deletions(-)
+
+diff --git a/pppd/plugins/rp-pppoe/plugin.c b/pppd/plugins/rp-pppoe/plugin.c
+index a8c2bb4f4a6a..c4c85b462afd 100644
+--- a/pppd/plugins/rp-pppoe/plugin.c
++++ b/pppd/plugins/rp-pppoe/plugin.c
+@@ -376,9 +376,6 @@ plugin_init(void)
+ }
+
+ add_options(Options);
+-
+- info("RP-PPPoE plugin version %s compiled against pppd %s",
+- RP_VERSION, VERSION);
+ }
+
+ void pppoe_check_options(void)
diff --git a/patches/ppp-2.4.7/0009-make-_PATH_CONNERRS-world-readable.patch b/patches/ppp-2.4.7/0009-make-_PATH_CONNERRS-world-readable.patch
new file mode 100644
index 000000000..2c6b0a7e2
--- /dev/null
+++ b/patches/ppp-2.4.7/0009-make-_PATH_CONNERRS-world-readable.patch
@@ -0,0 +1,22 @@
+From: Marco d'Itri <md@linux.it>
+Date: Fri, 2 Jun 2017 11:12:17 +0200
+Subject: [PATCH] make _PATH_CONNERRS world readable
+
+There is nothing security-sensitive there.
+---
+ pppd/main.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/pppd/main.c b/pppd/main.c
+index 439fedced8ff..23d21d427df7 100644
+--- a/pppd/main.c
++++ b/pppd/main.c
+@@ -1678,7 +1678,7 @@ device_script(program, in, out, dont_wait)
+ if (log_to_fd >= 0)
+ errfd = log_to_fd;
+ else
+- errfd = open(_PATH_CONNERRS, O_WRONLY | O_APPEND | O_CREAT, 0600);
++ errfd = open(_PATH_CONNERRS, O_WRONLY | O_APPEND | O_CREAT, 0644);
+
+ ++conn_running;
+ pid = safe_fork(in, out, errfd);
diff --git a/patches/ppp-2.4.7/0010-Correct-unkown-unknown-typo.patch b/patches/ppp-2.4.7/0010-Correct-unkown-unknown-typo.patch
new file mode 100644
index 000000000..450b05e9d
--- /dev/null
+++ b/patches/ppp-2.4.7/0010-Correct-unkown-unknown-typo.patch
@@ -0,0 +1,39 @@
+From: Chris Boot <bootc@debian.org>
+Date: Fri, 2 Jun 2017 11:12:56 +0200
+Subject: [PATCH] Correct unkown => unknown typo
+
+---
+ pppd/plugins/radius/config.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/pppd/plugins/radius/config.c b/pppd/plugins/radius/config.c
+index a29e5e8da909..f892ca7b1bf5 100644
+--- a/pppd/plugins/radius/config.c
++++ b/pppd/plugins/radius/config.c
+@@ -271,7 +271,7 @@ char *rc_conf_str(char *optname)
+ option = find_option(optname, OT_STR);
+
+ if (option == NULL)
+- fatal("rc_conf_str: unkown config option requested: %s", optname);
++ fatal("rc_conf_str: unknown config option requested: %s", optname);
+ return (char *)option->val;
+ }
+
+@@ -282,7 +282,7 @@ int rc_conf_int(char *optname)
+ option = find_option(optname, OT_INT|OT_AUO);
+
+ if (option == NULL)
+- fatal("rc_conf_int: unkown config option requested: %s", optname);
++ fatal("rc_conf_int: unknown config option requested: %s", optname);
+ return *((int *)option->val);
+ }
+
+@@ -293,7 +293,7 @@ SERVER *rc_conf_srv(char *optname)
+ option = find_option(optname, OT_SRV);
+
+ if (option == NULL)
+- fatal("rc_conf_srv: unkown config option requested: %s", optname);
++ fatal("rc_conf_srv: unknown config option requested: %s", optname);
+ return (SERVER *)option->val;
+ }
+
diff --git a/patches/ppp-2.4.7/0011-pppoe-custom-host-uniq-tag.patch b/patches/ppp-2.4.7/0011-pppoe-custom-host-uniq-tag.patch
new file mode 100644
index 000000000..9b4e4a796
--- /dev/null
+++ b/patches/ppp-2.4.7/0011-pppoe-custom-host-uniq-tag.patch
@@ -0,0 +1,298 @@
+From: Matteo Croce <matteo@openwrt.org>
+Date: Sat, 21 Nov 2015 18:45:43 +0100
+Subject: [PATCH] pppoe: custom host-uniq tag
+
+Add pppoe 'host-uniq' option to set an arbitrary
+host-uniq tag instead of the pppd pid.
+Some ISPs use such tag to authenticate the CPE,
+so it must be set to a proper value to connect.
+
+Signed-off-by: Matteo Croce <matteo@openwrt.org>
+Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
+---
+ pppd/plugins/rp-pppoe/common.c | 14 ++++-----
+ pppd/plugins/rp-pppoe/discovery.c | 51 +++++++++++++--------------------
+ pppd/plugins/rp-pppoe/plugin.c | 7 ++++-
+ pppd/plugins/rp-pppoe/pppoe-discovery.c | 38 +++++++++++++++---------
+ pppd/plugins/rp-pppoe/pppoe.h | 31 +++++++++++++++++++-
+ 5 files changed, 86 insertions(+), 55 deletions(-)
+
+diff --git a/pppd/plugins/rp-pppoe/common.c b/pppd/plugins/rp-pppoe/common.c
+index 89c633c773f9..8f175ece345b 100644
+--- a/pppd/plugins/rp-pppoe/common.c
++++ b/pppd/plugins/rp-pppoe/common.c
+@@ -119,15 +119,11 @@ sendPADT(PPPoEConnection *conn, char const *msg)
+ conn->session = 0;
+
+ /* If we're using Host-Uniq, copy it over */
+- if (conn->useHostUniq) {
+- PPPoETag hostUniq;
+- pid_t pid = getpid();
+- hostUniq.type = htons(TAG_HOST_UNIQ);
+- hostUniq.length = htons(sizeof(pid));
+- memcpy(hostUniq.payload, &pid, sizeof(pid));
+- memcpy(cursor, &hostUniq, sizeof(pid) + TAG_HDR_SIZE);
+- cursor += sizeof(pid) + TAG_HDR_SIZE;
+- plen += sizeof(pid) + TAG_HDR_SIZE;
++ if (conn->hostUniq.length) {
++ int len = ntohs(conn->hostUniq.length);
++ memcpy(cursor, &conn->hostUniq, len + TAG_HDR_SIZE);
++ cursor += len + TAG_HDR_SIZE;
++ plen += len + TAG_HDR_SIZE;
+ }
+
+ /* Copy error message */
+diff --git a/pppd/plugins/rp-pppoe/discovery.c b/pppd/plugins/rp-pppoe/discovery.c
+index 04877cb8295f..5db8d0defc37 100644
+--- a/pppd/plugins/rp-pppoe/discovery.c
++++ b/pppd/plugins/rp-pppoe/discovery.c
+@@ -80,13 +80,10 @@ static void
+ parseForHostUniq(UINT16_t type, UINT16_t len, unsigned char *data,
+ void *extra)
+ {
+- int *val = (int *) extra;
+- if (type == TAG_HOST_UNIQ && len == sizeof(pid_t)) {
+- pid_t tmp;
+- memcpy(&tmp, data, len);
+- if (tmp == getpid()) {
+- *val = 1;
+- }
++ PPPoETag *tag = extra;
++
++ if (type == TAG_HOST_UNIQ && len == ntohs(tag->length)) {
++ tag->length = memcmp(data, tag->payload, len);
+ }
+ }
+
+@@ -104,16 +101,16 @@ parseForHostUniq(UINT16_t type, UINT16_t len, unsigned char *data,
+ static int
+ packetIsForMe(PPPoEConnection *conn, PPPoEPacket *packet)
+ {
+- int forMe = 0;
++ PPPoETag hostUniq = conn->hostUniq;
+
+ /* If packet is not directed to our MAC address, forget it */
+ if (memcmp(packet->ethHdr.h_dest, conn->myEth, ETH_ALEN)) return 0;
+
+ /* If we're not using the Host-Unique tag, then accept the packet */
+- if (!conn->useHostUniq) return 1;
++ if (!conn->hostUniq.length) return 1;
+
+- parsePacket(packet, parseForHostUniq, &forMe);
+- return forMe;
++ parsePacket(packet, parseForHostUniq, &hostUniq);
++ return !hostUniq.length;
+ }
+
+ /**********************************************************************
+@@ -301,16 +298,12 @@ sendPADI(PPPoEConnection *conn)
+ }
+
+ /* If we're using Host-Uniq, copy it over */
+- if (conn->useHostUniq) {
+- PPPoETag hostUniq;
+- pid_t pid = getpid();
+- hostUniq.type = htons(TAG_HOST_UNIQ);
+- hostUniq.length = htons(sizeof(pid));
+- memcpy(hostUniq.payload, &pid, sizeof(pid));
+- CHECK_ROOM(cursor, packet.payload, sizeof(pid) + TAG_HDR_SIZE);
+- memcpy(cursor, &hostUniq, sizeof(pid) + TAG_HDR_SIZE);
+- cursor += sizeof(pid) + TAG_HDR_SIZE;
+- plen += sizeof(pid) + TAG_HDR_SIZE;
++ if (conn->hostUniq.length) {
++ int len = ntohs(conn->hostUniq.length);
++ CHECK_ROOM(cursor, packet.payload, len + TAG_HDR_SIZE);
++ memcpy(cursor, &conn->hostUniq, len + TAG_HDR_SIZE);
++ cursor += len + TAG_HDR_SIZE;
++ plen += len + TAG_HDR_SIZE;
+ }
+
+ /* Add our maximum MTU/MRU */
+@@ -478,16 +471,12 @@ sendPADR(PPPoEConnection *conn)
+ cursor += namelen + TAG_HDR_SIZE;
+
+ /* If we're using Host-Uniq, copy it over */
+- if (conn->useHostUniq) {
+- PPPoETag hostUniq;
+- pid_t pid = getpid();
+- hostUniq.type = htons(TAG_HOST_UNIQ);
+- hostUniq.length = htons(sizeof(pid));
+- memcpy(hostUniq.payload, &pid, sizeof(pid));
+- CHECK_ROOM(cursor, packet.payload, sizeof(pid)+TAG_HDR_SIZE);
+- memcpy(cursor, &hostUniq, sizeof(pid) + TAG_HDR_SIZE);
+- cursor += sizeof(pid) + TAG_HDR_SIZE;
+- plen += sizeof(pid) + TAG_HDR_SIZE;
++ if (conn->hostUniq.length) {
++ int len = ntohs(conn->hostUniq.length);
++ CHECK_ROOM(cursor, packet.payload, len+TAG_HDR_SIZE);
++ memcpy(cursor, &conn->hostUniq, len + TAG_HDR_SIZE);
++ cursor += len + TAG_HDR_SIZE;
++ plen += len + TAG_HDR_SIZE;
+ }
+
+ /* Add our maximum MTU/MRU */
+diff --git a/pppd/plugins/rp-pppoe/plugin.c b/pppd/plugins/rp-pppoe/plugin.c
+index c4c85b462afd..1a7e1e1b4e53 100644
+--- a/pppd/plugins/rp-pppoe/plugin.c
++++ b/pppd/plugins/rp-pppoe/plugin.c
+@@ -68,6 +68,7 @@ static char *existingSession = NULL;
+ static int printACNames = 0;
+ static char *pppoe_reqd_mac = NULL;
+ unsigned char pppoe_reqd_mac_addr[6];
++static char *host_uniq = NULL;
+
+ static int PPPoEDevnameHook(char *cmd, char **argv, int doit);
+ static option_t Options[] = {
+@@ -85,6 +86,8 @@ static option_t Options[] = {
+ "Be verbose about discovered access concentrators"},
+ { "pppoe-mac", o_string, &pppoe_reqd_mac,
+ "Only connect to specified MAC address" },
++ { "host-uniq", o_string, &host_uniq,
++ "Specify custom Host-Uniq" },
+ { NULL }
+ };
+ int (*OldDevnameHook)(char *cmd, char **argv, int doit) = NULL;
+@@ -110,7 +113,6 @@ PPPOEInitDevice(void)
+ conn->ifName = devnam;
+ conn->discoverySocket = -1;
+ conn->sessionSocket = -1;
+- conn->useHostUniq = 1;
+ conn->printACNames = printACNames;
+ conn->discoveryTimeout = PADI_TIMEOUT;
+ return 1;
+@@ -166,6 +168,9 @@ PPPOEConnectDevice(void)
+ if (lcp_wantoptions[0].mru > ifr.ifr_mtu - TOTAL_OVERHEAD)
+ lcp_wantoptions[0].mru = ifr.ifr_mtu - TOTAL_OVERHEAD;
+
++ if (host_uniq && !parseHostUniq(host_uniq, &conn->hostUniq))
++ fatal("Illegal value for host-uniq option");
++
+ conn->acName = acName;
+ conn->serviceName = pppd_pppoe_service;
+ strlcpy(ppp_devnam, devnam, sizeof(ppp_devnam));
+diff --git a/pppd/plugins/rp-pppoe/pppoe-discovery.c b/pppd/plugins/rp-pppoe/pppoe-discovery.c
+index 3d3bf4eecc81..f4f527128c2f 100644
+--- a/pppd/plugins/rp-pppoe/pppoe-discovery.c
++++ b/pppd/plugins/rp-pppoe/pppoe-discovery.c
+@@ -347,7 +347,7 @@ packetIsForMe(PPPoEConnection *conn, PPPoEPacket *packet)
+ if (memcmp(packet->ethHdr.h_dest, conn->myEth, ETH_ALEN)) return 0;
+
+ /* If we're not using the Host-Unique tag, then accept the packet */
+- if (!conn->useHostUniq) return 1;
++ if (!conn->hostUniq.length) return 1;
+
+ parsePacket(packet, parseForHostUniq, &forMe);
+ return forMe;
+@@ -473,16 +473,12 @@ sendPADI(PPPoEConnection *conn)
+ cursor += namelen + TAG_HDR_SIZE;
+
+ /* If we're using Host-Uniq, copy it over */
+- if (conn->useHostUniq) {
+- PPPoETag hostUniq;
+- pid_t pid = getpid();
+- hostUniq.type = htons(TAG_HOST_UNIQ);
+- hostUniq.length = htons(sizeof(pid));
+- memcpy(hostUniq.payload, &pid, sizeof(pid));
+- CHECK_ROOM(cursor, packet.payload, sizeof(pid) + TAG_HDR_SIZE);
+- memcpy(cursor, &hostUniq, sizeof(pid) + TAG_HDR_SIZE);
+- cursor += sizeof(pid) + TAG_HDR_SIZE;
+- plen += sizeof(pid) + TAG_HDR_SIZE;
++ if (conn->hostUniq.length) {
++ int len = ntohs(conn->hostUniq.length);
++ CHECK_ROOM(cursor, packet.payload, len + TAG_HDR_SIZE);
++ memcpy(cursor, &conn->hostUniq, len + TAG_HDR_SIZE);
++ cursor += len + TAG_HDR_SIZE;
++ plen += len + TAG_HDR_SIZE;
+ }
+
+ packet.length = htons(plen);
+@@ -644,7 +640,7 @@ int main(int argc, char *argv[])
+
+ memset(conn, 0, sizeof(PPPoEConnection));
+
+- while ((opt = getopt(argc, argv, "I:D:VUAS:C:h")) > 0) {
++ while ((opt = getopt(argc, argv, "I:D:VUW:AS:C:h")) > 0) {
+ switch(opt) {
+ case 'S':
+ conn->serviceName = xstrdup(optarg);
+@@ -653,7 +649,23 @@ int main(int argc, char *argv[])
+ conn->acName = xstrdup(optarg);
+ break;
+ case 'U':
+- conn->useHostUniq = 1;
++ if(conn->hostUniq.length) {
++ fprintf(stderr, "-U and -W are mutually exclusive\n");
++ exit(EXIT_FAILURE);
++ }
++ char pidbuf[5];
++ snprintf(pidbuf, sizeof(pidbuf), "%04x", getpid());
++ parseHostUniq(pidbuf, &conn->hostUniq);
++ break;
++ case 'W':
++ if(conn->hostUniq.length) {
++ fprintf(stderr, "-U and -W are mutually exclusive\n");
++ exit(EXIT_FAILURE);
++ }
++ if (!parseHostUniq(optarg, &conn->hostUniq)) {
++ fprintf(stderr, "Invalid host-uniq argument: %s\n", optarg);
++ exit(EXIT_FAILURE);
++ }
+ break;
+ case 'D':
+ conn->debugFile = fopen(optarg, "w");
+diff --git a/pppd/plugins/rp-pppoe/pppoe.h b/pppd/plugins/rp-pppoe/pppoe.h
+index 9ab2eee3914c..86d2b1e47a25 100644
+--- a/pppd/plugins/rp-pppoe/pppoe.h
++++ b/pppd/plugins/rp-pppoe/pppoe.h
+@@ -21,6 +21,8 @@
+
+ #include <stdio.h> /* For FILE */
+ #include <sys/types.h> /* For pid_t */
++#include <ctype.h>
++#include <string.h>
+
+ /* How do we access raw Ethernet devices? */
+ #undef USE_LINUX_PACKET
+@@ -235,7 +237,7 @@ typedef struct PPPoEConnectionStruct {
+ char *serviceName; /* Desired service name, if any */
+ char *acName; /* Desired AC name, if any */
+ int synchronous; /* Use synchronous PPP */
+- int useHostUniq; /* Use Host-Uniq tag */
++ PPPoETag hostUniq; /* Use Host-Uniq tag */
+ int printACNames; /* Just print AC names */
+ FILE *debugFile; /* Debug file for dumping packets */
+ int numPADOs; /* Number of PADO packets received */
+@@ -291,6 +293,33 @@ void pppoe_printpkt(PPPoEPacket *packet,
+ void (*printer)(void *, char *, ...), void *arg);
+ void pppoe_log_packet(const char *prefix, PPPoEPacket *packet);
+
++static inline int parseHostUniq(const char *uniq, PPPoETag *tag)
++{
++ int i, len = strlen(uniq);
++
++#define hex(x) \
++ (((x) <= '9') ? ((x) - '0') : \
++ (((x) <= 'F') ? ((x) - 'A' + 10) : \
++ ((x) - 'a' + 10)))
++
++ if (len % 2)
++ return 0;
++
++ for (i = 0; i < len; i += 2)
++ {
++ if (!isxdigit(uniq[i]) || !isxdigit(uniq[i+1]))
++ return 0;
++
++ tag->payload[i / 2] = (char)(16 * hex(uniq[i]) + hex(uniq[i+1]));
++ }
++
++#undef hex
++
++ tag->type = htons(TAG_HOST_UNIQ);
++ tag->length = htons(len / 2);
++ return 1;
++}
++
+ #define SET_STRING(var, val) do { if (var) free(var); var = strDup(val); } while(0);
+
+ #define CHECK_ROOM(cursor, start, len) \
diff --git a/patches/ppp-2.4.7/0012-scripts_redialer.patch b/patches/ppp-2.4.7/0012-scripts_redialer.patch
new file mode 100644
index 000000000..19b963bae
--- /dev/null
+++ b/patches/ppp-2.4.7/0012-scripts_redialer.patch
@@ -0,0 +1,162 @@
+From: Marco d'Itri <md@linux.it>
+Date: Fri, 2 Jun 2017 11:14:10 +0200
+Subject: [PATCH] scripts_redialer
+
+---
+ scripts/redialer | 133 ++++++++++++++++++++++---------------------------------
+ 1 file changed, 53 insertions(+), 80 deletions(-)
+
+diff --git a/scripts/redialer b/scripts/redialer
+index 5bbde4e9da4e..c0b748ad0e53 100755
+--- a/scripts/redialer
++++ b/scripts/redialer
+@@ -1,96 +1,69 @@
+ #!/bin/sh
+-###################################################################
+ #
+-# These parameters control the attack dialing sequence.
++# A chatscript that will attempt to dial multiple numbers in sequence, until
++# you get connected.
+ #
+-# Maximum number of attempts to reach the telephone number(s)
+-MAX_ATTEMPTS=10
+-
+-# Delay between each of the attempts. This is a parameter to sleep
+-# so use "15s" for 15 seconds, "1m" for 1 minute, etc.
+-SLEEP_DELAY=15s
+-
+-###################################################################
++# To use: edit /etc/peers/provider, and change the connect line to read:
++# connect "/usr/local/bin/redialer"
+ #
+-# This is a list of telephone numbers. Add new numbers if you wish
+-# and see the function 'callall' below for the dial process.
+-PHONE1=555-1212
+-PHONE2=411
++# See below for configuration.
+
+-###################################################################
++# This is a list of chatscripts to use to get connected, and (optional)
++# telephone numbers to call for each of those chatscripts.
+ #
+-# If you use the ppp-on script, then these are passed to this routine
+-# automatically. There is no need to define them here. If not, then
+-# you will need to set the values.
+-#
+-ACCOUNT=my_account_name
+-PASSWORD=my_password
++# Note that in the chatscripts, you may use #NUMBER#, this will be replaced
++# with the number it is calling. You might want to use this to only have one
++# chatscript that is used for all numbers, or you might need multiple
++# chatscripts.
+
+-###################################################################
+-#
+-# Function to initialize the modem and ensure that it is in command
+-# state. This may not be needed, but it doesn't hurt.
+-#
+-function initialize
+-{
+- chat -v TIMEOUT 3 '' AT 'OK-+++\c-OK'
+- return
+-}
++PHONE1=123456789
++CHAT1=/etc/chatscripts/provider
+
+-###################################################################
+-#
+-# Script to dial a telephone
+-#
+-function callnumber
+-{
+-chat -v \
+- ABORT '\nBUSY\r' \
+- ABORT '\nNO ANSWER\r' \
+- ABORT '\nRINGING\r\n\r\nRINGING\r' \
+- '' ATDT$1 \
+- CONNECT '' \
+- ogin:--ogin: $ACCOUNT \
+- assword: $PASSWORD
+-#
+-# If the connection was successful then end the whole script with a
+-# success.
+-#
+- if [ "$?" = "0" ]; then
+- exit 0
+- fi
++PHONE2=912345678
++CHAT2=/etc/chatscripts/provider
+
+- return
+-}
++PHONE3=891234567
++CHAT3=/etc/chatscripts/provider
+
+-###################################################################
+-#
+-# Script to dial any telephone number
+-#
+-function callall
+-{
+-# echo "dialing attempt number: $1" >/dev/console
+- callnumber $PHONE1
+-# callnumber $PHONE2
+-}
++PHONE4=789123456
++CHAT4=/etc/chatscripts/provider
+
+-###################################################################
+-#
+-# Initialize the modem to ensure that it is in the command state
+-#
+-initialize
+-if [ ! "$?" = "0" ]; then
+- exit 1
+-fi
++PHONE5=001234567
++CHAT5=/etc/chatscripts/provider
+
++# How long to sleep between retries:
+ #
+-# Dial telephone numbers until one answers
+-#
++# Note that this is a parameter to sleep so use "15s" for 15 seconds,
++# "1m" for 1 minute, etc
++SLEEP_DELAY=1s
++
++# The code below does the dialing.
++
+ attempt=0
+ while : ; do
+- attempt=`expr $attempt + 1`
+- callall $attempt
+- if [ "$attempt" = "$MAX_ATTEMPTS" ]; then
+- exit 1
+- fi
+- sleep "$SLEEP_DELAY"
++ attempt=`expr $attempt + 1`
++ NUMBER=`eval echo '$PHONE'$attempt`
++ CHAT=`eval echo '$CHAT'$attempt`
++ if [ ! "$CHAT" ]; then
++ attempt=0
++ else
++ logger "Dialing attempt number: $attempt"
++ sed s/#NUMBER#/$NUMBER/ $CHAT >/etc/chatscripts/tmpchat
++ /usr/sbin/chat -v -f /etc/chatscripts/tmpchat
++ rm -f /etc/chatscripts/tmpchat
++ case $? in
++ 0) logger Connection established ; exit 0;;
++ 1) logger chat: exit 1, see manpage for details. ; exit 1;;
++ 2) logger chat: exit 2, see manpage for details. ; exit 2;;
++ 3) logger chat: exit 3, see manpage for details. ;;
++ 4) logger Line busy. ;;
++ 5) logger No Carrier. ;;
++ 6) logger A call is coming. Exiting! ; exit 1;;
++ 7) logger No dialtone. ;;
++ 8) logger An error occured. Exiting! ; exit 1;;
++ *) logger chat: exit $?, see manpage for details. ;;
++ esac
++ logger "Waiting $SLEEP_DELAY seconds before next try."
++ sleep $SLEEP_DELAY
++ fi
+ done
diff --git a/patches/ppp-2.4.7/0013-Add-replacedefaultroute-option.patch b/patches/ppp-2.4.7/0013-Add-replacedefaultroute-option.patch
new file mode 100644
index 000000000..376b3453a
--- /dev/null
+++ b/patches/ppp-2.4.7/0013-Add-replacedefaultroute-option.patch
@@ -0,0 +1,319 @@
+From: Marco d'Itri <md@linux.it>
+Date: Fri, 2 Jun 2017 11:15:32 +0200
+Subject: [PATCH] Add replacedefaultroute option
+
+Adds an option to pppd to control whether to replace existing default routes
+when using the 'defaultroute' option.
+
+If defaultroute and replacedefaultroute are both set, pppd replaces an existing
+default route with the new default route. The old default route is restored when
+the connection is taken down.
+
+Origin: vendor, https://build.opensuse.org/source/network/ppp/ppp-2.4.2-cifdefroute.diff?rev=7a0fdeff0b29437dd7f4581c95c7255a
+Forwarded: no
+Reviewed-by: Chris Boot <bootc@debian.org>
+Last-Update: 2014-01-26
+---
+ pppd/ipcp.c | 45 +++++++++++++++++++++++++++----
+ pppd/ipcp.h | 1 +
+ pppd/pppd.8 | 12 ++++++++-
+ pppd/pppd.h | 4 +++
+ pppd/sys-linux.c | 82 +++++++++++++++++++++++++++++++++++++++++++++-----------
+ 5 files changed, 123 insertions(+), 21 deletions(-)
+
+diff --git a/pppd/ipcp.c b/pppd/ipcp.c
+index e9738fe4d894..c8fe279d4ede 100644
+--- a/pppd/ipcp.c
++++ b/pppd/ipcp.c
+@@ -198,6 +198,16 @@ static option_t ipcp_option_list[] = {
+ "disable defaultroute option", OPT_ALIAS | OPT_A2CLR,
+ &ipcp_wantoptions[0].default_route },
+
++#ifdef __linux__
++ { "replacedefaultroute", o_bool,
++ &ipcp_wantoptions[0].replace_default_route,
++ "Replace default route", 1
++ },
++ { "noreplacedefaultroute", o_bool,
++ &ipcp_allowoptions[0].replace_default_route,
++ "Never replace default route", OPT_A2COPY,
++ &ipcp_wantoptions[0].replace_default_route },
++#endif
+ { "proxyarp", o_bool, &ipcp_wantoptions[0].proxy_arp,
+ "Add proxy ARP entry", OPT_ENABLE|1, &ipcp_allowoptions[0].proxy_arp },
+ { "noproxyarp", o_bool, &ipcp_allowoptions[0].proxy_arp,
+@@ -271,7 +281,7 @@ struct protent ipcp_protent = {
+ ip_active_pkt
+ };
+
+-static void ipcp_clear_addrs __P((int, u_int32_t, u_int32_t));
++static void ipcp_clear_addrs __P((int, u_int32_t, u_int32_t, bool));
+ static void ipcp_script __P((char *, int)); /* Run an up/down script */
+ static void ipcp_script_done __P((void *));
+
+@@ -1761,7 +1771,12 @@ ip_demand_conf(u)
+ if (!sifnpmode(u, PPP_IP, NPMODE_QUEUE))
+ return 0;
+ if (wo->default_route)
++#ifndef __linux__
+ if (sifdefaultroute(u, wo->ouraddr, wo->hisaddr))
++#else
++ if (sifdefaultroute(u, wo->ouraddr, wo->hisaddr,
++ wo->replace_default_route))
++#endif
+ default_route_set[u] = 1;
+ if (wo->proxy_arp)
+ if (sifproxyarp(u, wo->hisaddr))
+@@ -1849,7 +1864,8 @@ ipcp_up(f)
+ */
+ if (demand) {
+ if (go->ouraddr != wo->ouraddr || ho->hisaddr != wo->hisaddr) {
+- ipcp_clear_addrs(f->unit, wo->ouraddr, wo->hisaddr);
++ ipcp_clear_addrs(f->unit, wo->ouraddr, wo->hisaddr,
++ wo->replace_default_route);
+ if (go->ouraddr != wo->ouraddr) {
+ warn("Local IP address changed to %I", go->ouraddr);
+ script_setenv("OLDIPLOCAL", ip_ntoa(wo->ouraddr), 0);
+@@ -1874,7 +1890,12 @@ ipcp_up(f)
+
+ /* assign a default route through the interface if required */
+ if (ipcp_wantoptions[f->unit].default_route)
++#ifndef __linux__
+ if (sifdefaultroute(f->unit, go->ouraddr, ho->hisaddr))
++#else
++ if (sifdefaultroute(f->unit, go->ouraddr, ho->hisaddr,
++ wo->replace_default_route))
++#endif
+ default_route_set[f->unit] = 1;
+
+ /* Make a proxy ARP entry if requested. */
+@@ -1924,7 +1945,12 @@ ipcp_up(f)
+
+ /* assign a default route through the interface if required */
+ if (ipcp_wantoptions[f->unit].default_route)
++#ifndef __linux__
+ if (sifdefaultroute(f->unit, go->ouraddr, ho->hisaddr))
++#else
++ if (sifdefaultroute(f->unit, go->ouraddr, ho->hisaddr,
++ wo->replace_default_route))
++#endif
+ default_route_set[f->unit] = 1;
+
+ /* Make a proxy ARP entry if requested. */
+@@ -2002,7 +2028,7 @@ ipcp_down(f)
+ sifnpmode(f->unit, PPP_IP, NPMODE_DROP);
+ sifdown(f->unit);
+ ipcp_clear_addrs(f->unit, ipcp_gotoptions[f->unit].ouraddr,
+- ipcp_hisoptions[f->unit].hisaddr);
++ ipcp_hisoptions[f->unit].hisaddr, 0);
+ }
+
+ /* Execute the ip-down script */
+@@ -2018,16 +2044,25 @@ ipcp_down(f)
+ * proxy arp entries, etc.
+ */
+ static void
+-ipcp_clear_addrs(unit, ouraddr, hisaddr)
++ipcp_clear_addrs(unit, ouraddr, hisaddr, replacedefaultroute)
+ int unit;
+ u_int32_t ouraddr; /* local address */
+ u_int32_t hisaddr; /* remote address */
++ bool replacedefaultroute;
+ {
+ if (proxy_arp_set[unit]) {
+ cifproxyarp(unit, hisaddr);
+ proxy_arp_set[unit] = 0;
+ }
+- if (default_route_set[unit]) {
++ /* If replacedefaultroute, sifdefaultroute will be called soon
++ * with replacedefaultroute set and that will overwrite the current
++ * default route. This is the case only when doing demand, otherwise
++ * during demand, this cifdefaultroute would restore the old default
++ * route which is not what we want in this case. In the non-demand
++ * case, we'll delete the default route and restore the old if there
++ * is one saved by an sifdefaultroute with replacedefaultroute.
++ */
++ if (!replacedefaultroute && default_route_set[unit]) {
+ cifdefaultroute(unit, ouraddr, hisaddr);
+ default_route_set[unit] = 0;
+ }
+diff --git a/pppd/ipcp.h b/pppd/ipcp.h
+index 6cf14c990578..7ecfa79d8668 100644
+--- a/pppd/ipcp.h
++++ b/pppd/ipcp.h
+@@ -70,6 +70,7 @@ typedef struct ipcp_options {
+ bool old_addrs; /* Use old (IP-Addresses) option? */
+ bool req_addr; /* Ask peer to send IP address? */
+ bool default_route; /* Assign default route through interface? */
++ bool replace_default_route; /* Replace default route through interface? */
+ bool proxy_arp; /* Make proxy ARP entry for peer? */
+ bool neg_vj; /* Van Jacobson Compression? */
+ bool old_vj; /* use old (short) form of VJ option? */
+diff --git a/pppd/pppd.8 b/pppd/pppd.8
+index b7fd0bdaab52..67181083808b 100644
+--- a/pppd/pppd.8
++++ b/pppd/pppd.8
+@@ -121,6 +121,11 @@ the gateway, when IPCP negotiation is successfully completed.
+ This entry is removed when the PPP connection is broken. This option
+ is privileged if the \fInodefaultroute\fR option has been specified.
+ .TP
++.B replacedefaultroute
++This option is a flag to the defaultroute option. If defaultroute is
++set and this flag is also set, pppd replaces an existing default route
++with the new default route.
++.TP
+ .B disconnect \fIscript
+ Execute the command specified by \fIscript\fR, by passing it to a
+ shell, after
+@@ -739,7 +744,12 @@ disable both forms of hardware flow control.
+ .TP
+ .B nodefaultroute
+ Disable the \fIdefaultroute\fR option. The system administrator who
+-wishes to prevent users from creating default routes with pppd
++wishes to prevent users from adding a default route with pppd
++can do so by placing this option in the /etc/ppp/options file.
++.TP
++.B noreplacedefaultroute
++Disable the \fIreplacedefaultroute\fR option. The system administrator who
++wishes to prevent users from replacing a default route with pppd
+ can do so by placing this option in the /etc/ppp/options file.
+ .TP
+ .B nodeflate
+diff --git a/pppd/pppd.h b/pppd/pppd.h
+index 247fa153739b..8ade4d817092 100644
+--- a/pppd/pppd.h
++++ b/pppd/pppd.h
+@@ -665,7 +665,11 @@ int sif6addr __P((int, eui64_t, eui64_t));
+ int cif6addr __P((int, eui64_t, eui64_t));
+ /* Remove an IPv6 address from i/f */
+ #endif
++#ifndef __linux__
+ int sifdefaultroute __P((int, u_int32_t, u_int32_t));
++#else
++int sifdefaultroute __P((int, u_int32_t, u_int32_t, bool replace_default_rt));
++#endif
+ /* Create default route through i/f */
+ int cifdefaultroute __P((int, u_int32_t, u_int32_t));
+ /* Delete default route through i/f */
+diff --git a/pppd/sys-linux.c b/pppd/sys-linux.c
+index f92174854207..86cde57664af 100644
+--- a/pppd/sys-linux.c
++++ b/pppd/sys-linux.c
+@@ -207,6 +207,8 @@ static unsigned char inbuf[512]; /* buffer for chars read from loopback */
+ static int if_is_up; /* Interface has been marked up */
+ static int if6_is_up; /* Interface has been marked up for IPv6, to help differentiate */
+ static int have_default_route; /* Gateway for default route added */
++static struct rtentry old_def_rt; /* Old default route */
++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 */
+@@ -1552,6 +1554,9 @@ static int read_route_table(struct rtentry *rt)
+ p = NULL;
+ }
+
++ SET_SA_FAMILY (rt->rt_dst, AF_INET);
++ SET_SA_FAMILY (rt->rt_gateway, AF_INET);
++
+ SIN_ADDR(rt->rt_dst) = strtoul(cols[route_dest_col], NULL, 16);
+ SIN_ADDR(rt->rt_gateway) = strtoul(cols[route_gw_col], NULL, 16);
+ SIN_ADDR(rt->rt_genmask) = strtoul(cols[route_mask_col], NULL, 16);
+@@ -1621,22 +1626,53 @@ int have_route_to(u_int32_t addr)
+ /********************************************************************
+ *
+ * sifdefaultroute - assign a default route through the address given.
+- */
+-
+-int sifdefaultroute (int unit, u_int32_t ouraddr, u_int32_t gateway)
+-{
+- struct rtentry rt;
+-
+- if (defaultroute_exists(&rt) && strcmp(rt.rt_dev, ifname) != 0) {
+- if (rt.rt_flags & RTF_GATEWAY)
+- error("not replacing existing default route via %I",
+- SIN_ADDR(rt.rt_gateway));
+- else
+- error("not replacing existing default route through %s",
+- rt.rt_dev);
+- return 0;
++ *
++ * If the global default_rt_repl_rest flag is set, then this function
++ * already replaced the original system defaultroute with some other
++ * route and it should just replace the current defaultroute with
++ * another one, without saving the current route. Use: demand mode,
++ * when pppd sets first a defaultroute it it's temporary ppp0 addresses
++ * and then changes the temporary addresses to the addresses for the real
++ * ppp connection when it has come up.
++ */
++
++int sifdefaultroute (int unit, u_int32_t ouraddr, u_int32_t gateway, bool replace)
++{
++ struct rtentry rt, tmp_rt;
++ struct rtentry *del_rt = NULL;
++
++ if (default_rt_repl_rest) {
++ /* We have already reclaced the original defaultroute, if we
++ * are called again, we will delete the current default route
++ * and set the new default route in this function.
++ * - this is normally only the case the doing demand: */
++ if (defaultroute_exists( &tmp_rt ))
++ del_rt = &tmp_rt;
++ } else if ( defaultroute_exists( &old_def_rt ) &&
++ strcmp( old_def_rt.rt_dev, ifname ) != 0) {
++ /* We did not yet replace an existing default route, let's
++ * check if we should save and replace a default route:
++ */
++ u_int32_t old_gateway = SIN_ADDR(old_def_rt.rt_gateway);
++
++ if (old_gateway != gateway) {
++ if (!replace) {
++ error("not replacing default route to %s [%I]",
++ old_def_rt.rt_dev, old_gateway);
++ return 0;
++ } else {
++ // we need to copy rt_dev because we need it permanent too:
++ char * tmp_dev = malloc(strlen(old_def_rt.rt_dev)+1);
++ strcpy(tmp_dev, old_def_rt.rt_dev);
++ old_def_rt.rt_dev = tmp_dev;
++
++ notice("replacing old default route to %s [%I]",
++ old_def_rt.rt_dev, old_gateway);
++ default_rt_repl_rest = 1;
++ del_rt = &old_def_rt;
++ }
++ }
+ }
+-
+ memset (&rt, 0, sizeof (rt));
+ SET_SA_FAMILY (rt.rt_dst, AF_INET);
+
+@@ -1653,6 +1689,12 @@ int sifdefaultroute (int unit, u_int32_t ouraddr, u_int32_t gateway)
+ error("default route ioctl(SIOCADDRT): %m");
+ return 0;
+ }
++ if (default_rt_repl_rest && del_rt)
++ if (ioctl(sock_fd, SIOCDELRT, del_rt) < 0) {
++ if ( ! ok_error ( errno ))
++ error("del old default route ioctl(SIOCDELRT): %m(%d)", errno);
++ return 0;
++ }
+
+ have_default_route = 1;
+ return 1;
+@@ -1688,6 +1730,16 @@ int cifdefaultroute (int unit, u_int32_t ouraddr, u_int32_t gateway)
+ return 0;
+ }
+ }
++ if (default_rt_repl_rest) {
++ notice("restoring old default route to %s [%I]",
++ old_def_rt.rt_dev, SIN_ADDR(old_def_rt.rt_gateway));
++ if (ioctl(sock_fd, SIOCADDRT, &old_def_rt) < 0) {
++ if ( ! ok_error ( errno ))
++ error("restore default route ioctl(SIOCADDRT): %m(%d)", errno);
++ return 0;
++ }
++ default_rt_repl_rest = 0;
++ }
+
+ return 1;
+ }
diff --git a/patches/ppp-2.4.7/0014-ppp-2.3.11-oedod.patch b/patches/ppp-2.4.7/0014-ppp-2.3.11-oedod.patch
new file mode 100644
index 000000000..ed160e882
--- /dev/null
+++ b/patches/ppp-2.4.7/0014-ppp-2.3.11-oedod.patch
@@ -0,0 +1,191 @@
+From: Marco d'Itri <md@linux.it>
+Date: Fri, 2 Jun 2017 11:16:31 +0200
+Subject: [PATCH] ppp-2.3.11-oedod
+
+---
+ pppd/demand.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
+ pppd/ipcp.c | 2 +-
+ pppd/ipv6cp.c | 2 +-
+ pppd/pppd.h | 2 +-
+ 4 files changed, 101 insertions(+), 4 deletions(-)
+
+diff --git a/pppd/demand.c b/pppd/demand.c
+index 5e57658ea831..3eddf3016d98 100644
+--- a/pppd/demand.c
++++ b/pppd/demand.c
+@@ -36,6 +36,8 @@
+ #include <errno.h>
+ #include <fcntl.h>
+ #include <netdb.h>
++#include <unistd.h>
++#include <syslog.h>
+ #include <sys/param.h>
+ #include <sys/types.h>
+ #include <sys/wait.h>
+@@ -43,6 +45,8 @@
+ #include <sys/resource.h>
+ #include <sys/stat.h>
+ #include <sys/socket.h>
++#include <netinet/in.h>
++#include <arpa/inet.h>
+ #ifdef PPP_FILTER
+ #include <pcap-bpf.h>
+ #endif
+@@ -221,6 +225,14 @@ loop_chars(p, n)
+ int c, rv;
+
+ rv = 0;
++
++/* check for synchronous connection... */
++
++ if ( (p[0] == 0xFF) && (p[1] == 0x03) ) {
++ rv = loop_frame(p,n);
++ return rv;
++ }
++
+ for (; n > 0; --n) {
+ c = *p++;
+ if (c == PPP_FLAG) {
+@@ -299,17 +311,102 @@ loop_frame(frame, len)
+ * loopback, now that the real serial link is up.
+ */
+ void
+-demand_rexmit(proto)
++demand_rexmit(proto, newip)
+ int proto;
++ u_int32_t newip;
+ {
+ struct packet *pkt, *prev, *nextpkt;
++ unsigned short checksum;
++ unsigned short pkt_checksum = 0;
++ unsigned iphdr;
++ struct timeval tv;
++ char cv = 0;
++ char ipstr[16];
+
+ prev = NULL;
+ pkt = pend_q;
+ pend_q = NULL;
++ tv.tv_sec = 1;
++ tv.tv_usec = 0;
++ select(0,NULL,NULL,NULL,&tv); /* Sleep for 1 Seconds */
+ for (; pkt != NULL; pkt = nextpkt) {
+ nextpkt = pkt->next;
+ if (PPP_PROTOCOL(pkt->data) == proto) {
++ if ( (proto == PPP_IP) && newip ) {
++ /* Get old checksum */
++
++ iphdr = (pkt->data[4] & 15) << 2;
++ checksum = *((unsigned short *) (pkt->data+14));
++ if (checksum == 0xFFFF) {
++ checksum = 0;
++ }
++
++
++ if (pkt->data[13] == 17) {
++ pkt_checksum = *((unsigned short *) (pkt->data+10+iphdr));
++ if (pkt_checksum) {
++ cv = 1;
++ if (pkt_checksum == 0xFFFF) {
++ pkt_checksum = 0;
++ }
++ }
++ else {
++ cv = 0;
++ }
++ }
++
++ if (pkt->data[13] == 6) {
++ pkt_checksum = *((unsigned short *) (pkt->data+20+iphdr));
++ cv = 1;
++ if (pkt_checksum == 0xFFFF) {
++ pkt_checksum = 0;
++ }
++ }
++
++ /* Delete old Source-IP-Address */
++ checksum -= *((unsigned short *) (pkt->data+16)) ^ 0xFFFF;
++ checksum -= *((unsigned short *) (pkt->data+18)) ^ 0xFFFF;
++
++ pkt_checksum -= *((unsigned short *) (pkt->data+16)) ^ 0xFFFF;
++ pkt_checksum -= *((unsigned short *) (pkt->data+18)) ^ 0xFFFF;
++
++ /* Change Source-IP-Address */
++ * ((u_int32_t *) (pkt->data + 16)) = newip;
++
++ /* Add new Source-IP-Address */
++ checksum += *((unsigned short *) (pkt->data+16)) ^ 0xFFFF;
++ checksum += *((unsigned short *) (pkt->data+18)) ^ 0xFFFF;
++
++ pkt_checksum += *((unsigned short *) (pkt->data+16)) ^ 0xFFFF;
++ pkt_checksum += *((unsigned short *) (pkt->data+18)) ^ 0xFFFF;
++
++ /* Write new checksum */
++ if (!checksum) {
++ checksum = 0xFFFF;
++ }
++ *((unsigned short *) (pkt->data+14)) = checksum;
++ if (pkt->data[13] == 6) {
++ *((unsigned short *) (pkt->data+20+iphdr)) = pkt_checksum;
++ }
++ if (cv && (pkt->data[13] == 17) ) {
++ *((unsigned short *) (pkt->data+10+iphdr)) = pkt_checksum;
++ }
++
++ /* Log Packet */
++ strcpy(ipstr,inet_ntoa(*( (struct in_addr *) (pkt->data+16))));
++ if (pkt->data[13] == 1) {
++ syslog(LOG_INFO,"Open ICMP %s -> %s\n",
++ ipstr,
++ inet_ntoa(*( (struct in_addr *) (pkt->data+20))));
++ } else {
++ syslog(LOG_INFO,"Open %s %s:%d -> %s:%d\n",
++ pkt->data[13] == 6 ? "TCP" : "UDP",
++ ipstr,
++ ntohs(*( (short *) (pkt->data+iphdr+4))),
++ inet_ntoa(*( (struct in_addr *) (pkt->data+20))),
++ ntohs(*( (short *) (pkt->data+iphdr+6))));
++ }
++ }
+ output(0, pkt->data, pkt->length);
+ free(pkt);
+ } else {
+diff --git a/pppd/ipcp.c b/pppd/ipcp.c
+index c8fe279d4ede..dceca807542a 100644
+--- a/pppd/ipcp.c
++++ b/pppd/ipcp.c
+@@ -1904,7 +1904,7 @@ ipcp_up(f)
+ proxy_arp_set[f->unit] = 1;
+
+ }
+- demand_rexmit(PPP_IP);
++ demand_rexmit(PPP_IP,go->ouraddr);
+ sifnpmode(f->unit, PPP_IP, NPMODE_PASS);
+
+ } else {
+diff --git a/pppd/ipv6cp.c b/pppd/ipv6cp.c
+index 356ff84ead41..c1602f41c206 100644
+--- a/pppd/ipv6cp.c
++++ b/pppd/ipv6cp.c
+@@ -1232,7 +1232,7 @@ ipv6cp_up(f)
+ }
+
+ }
+- demand_rexmit(PPP_IPV6);
++ demand_rexmit(PPP_IPV6,0);
+ sifnpmode(f->unit, PPP_IPV6, NPMODE_PASS);
+
+ } else {
+diff --git a/pppd/pppd.h b/pppd/pppd.h
+index 8ade4d817092..2121bc0aa588 100644
+--- a/pppd/pppd.h
++++ b/pppd/pppd.h
+@@ -583,7 +583,7 @@ void demand_conf __P((void)); /* config interface(s) for demand-dial */
+ void demand_block __P((void)); /* set all NPs to queue up packets */
+ void demand_unblock __P((void)); /* set all NPs to pass packets */
+ void demand_discard __P((void)); /* set all NPs to discard packets */
+-void demand_rexmit __P((int)); /* retransmit saved frames for an NP */
++void demand_rexmit __P((int, u_int32_t)); /* retransmit saved frames for an NP*/
+ int loop_chars __P((unsigned char *, int)); /* process chars from loopback */
+ int loop_frame __P((unsigned char *, int)); /* should we bring link up? */
+
diff --git a/patches/ppp-2.4.7/0015-add-support-for-the-Framed-MTU-Radius-attribute.patch b/patches/ppp-2.4.7/0015-add-support-for-the-Framed-MTU-Radius-attribute.patch
new file mode 100644
index 000000000..273d7e25a
--- /dev/null
+++ b/patches/ppp-2.4.7/0015-add-support-for-the-Framed-MTU-Radius-attribute.patch
@@ -0,0 +1,26 @@
+From: Alexander Klepikov <klepikov_a@up.ua>
+Date: Fri, 2 Jun 2017 11:21:27 +0200
+Subject: [PATCH] add support for the Framed-MTU Radius attribute
+
+http://ppp.samba.org/cgi-bin/ppp-bugs/incoming?id=1532
+
+This patch allows radius plugin to deal with Framed-MTU Radius attribute and to
+set MTU on interface.
+---
+ pppd/plugins/radius/radius.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/pppd/plugins/radius/radius.c b/pppd/plugins/radius/radius.c
+index 4ba5f523ea07..06e00590b635 100644
+--- a/pppd/plugins/radius/radius.c
++++ b/pppd/plugins/radius/radius.c
+@@ -651,6 +651,9 @@ radius_setparams(VALUE_PAIR *vp, char *msg, REQUEST_INFO *req_info,
+ memcpy(rstate.class, vp->strvalue, rstate.class_len);
+ } /* else too big for our buffer - ignore it */
+ break;
++ case PW_FRAMED_MTU:
++ netif_set_mtu(rstate.client_port,MIN(netif_get_mtu(rstate.client_port),vp->lvalue));
++ break;
+ }
+
+
diff --git a/patches/ppp-2.4.7/0016-ip-up_option.patch b/patches/ppp-2.4.7/0016-ip-up_option.patch
new file mode 100644
index 000000000..93ef02c5b
--- /dev/null
+++ b/patches/ppp-2.4.7/0016-ip-up_option.patch
@@ -0,0 +1,103 @@
+From: Marco d'Itri <md@linux.it>
+Date: Fri, 2 Jun 2017 11:22:08 +0200
+Subject: [PATCH] ip-up_option
+
+---
+ pppd/ipcp.c | 8 ++++----
+ pppd/main.c | 3 +++
+ pppd/options.c | 9 +++++++++
+ pppd/pppd.h | 2 ++
+ 4 files changed, 18 insertions(+), 4 deletions(-)
+
+diff --git a/pppd/ipcp.c b/pppd/ipcp.c
+index dceca807542a..d6e0e2a699fe 100644
+--- a/pppd/ipcp.c
++++ b/pppd/ipcp.c
+@@ -1984,7 +1984,7 @@ ipcp_up(f)
+ */
+ if (ipcp_script_state == s_down && ipcp_script_pid == 0) {
+ ipcp_script_state = s_up;
+- ipcp_script(_PATH_IPUP, 0);
++ ipcp_script(path_ipup, 0);
+ }
+ }
+
+@@ -2034,7 +2034,7 @@ ipcp_down(f)
+ /* Execute the ip-down script */
+ if (ipcp_script_state == s_up && ipcp_script_pid == 0) {
+ ipcp_script_state = s_down;
+- ipcp_script(_PATH_IPDOWN, 0);
++ ipcp_script(path_ipdown, 0);
+ }
+ }
+
+@@ -2097,13 +2097,13 @@ ipcp_script_done(arg)
+ case s_up:
+ if (ipcp_fsm[0].state != OPENED) {
+ ipcp_script_state = s_down;
+- ipcp_script(_PATH_IPDOWN, 0);
++ ipcp_script(path_ipdown, 0);
+ }
+ break;
+ case s_down:
+ if (ipcp_fsm[0].state == OPENED) {
+ ipcp_script_state = s_up;
+- ipcp_script(_PATH_IPUP, 0);
++ ipcp_script(path_ipup, 0);
+ }
+ break;
+ }
+diff --git a/pppd/main.c b/pppd/main.c
+index 23d21d427df7..59aad6f3854f 100644
+--- a/pppd/main.c
++++ b/pppd/main.c
+@@ -316,6 +316,9 @@ main(argc, argv)
+ struct protent *protp;
+ char numbuf[16];
+
++ strlcpy(path_ipup, _PATH_IPUP, sizeof(path_ipup));
++ strlcpy(path_ipdown, _PATH_IPDOWN, sizeof(path_ipdown));
++
+ link_stats_valid = 0;
+ new_phase(PHASE_INITIALIZE);
+
+diff --git a/pppd/options.c b/pppd/options.c
+index f66b7657bc31..dc2d7329a93d 100644
+--- a/pppd/options.c
++++ b/pppd/options.c
+@@ -114,6 +114,8 @@ char linkname[MAXPATHLEN]; /* logical name for link */
+ bool tune_kernel; /* may alter kernel settings */
+ int connect_delay = 1000; /* wait this many ms after connect script */
+ int req_unit = -1; /* requested interface unit */
++char path_ipup[MAXPATHLEN]; /* pathname of ip-up script */
++char path_ipdown[MAXPATHLEN];/* pathname of ip-down script */
+ bool multilink = 0; /* Enable multilink operation */
+ char *bundle_name = NULL; /* bundle name for multilink */
+ bool dump_options; /* print out option values */
+@@ -299,6 +301,13 @@ option_t general_options[] = {
+ "Unset user environment variable",
+ OPT_A2PRINTER | OPT_NOPRINT, (void *)user_unsetprint },
+
++ { "ip-up-script", o_string, path_ipup,
++ "Set pathname of ip-up script",
++ OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
++ { "ip-down-script", o_string, path_ipdown,
++ "Set pathname of ip-down script",
++ OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
++
+ #ifdef HAVE_MULTILINK
+ { "multilink", o_bool, &multilink,
+ "Enable multilink operation", OPT_PRIO | 1 },
+diff --git a/pppd/pppd.h b/pppd/pppd.h
+index 2121bc0aa588..2be649adf582 100644
+--- a/pppd/pppd.h
++++ b/pppd/pppd.h
+@@ -318,6 +318,8 @@ extern bool tune_kernel; /* May alter kernel settings as necessary */
+ extern int connect_delay; /* Time to delay after connect script */
+ extern int max_data_rate; /* max bytes/sec through charshunt */
+ extern int req_unit; /* interface unit number to use */
++extern char path_ipup[MAXPATHLEN]; /* pathname of ip-up script */
++extern char path_ipdown[MAXPATHLEN]; /* pathname of ip-down script */
+ extern bool multilink; /* enable multilink operation */
+ extern bool noendpoint; /* don't send or accept endpt. discrim. */
+ extern char *bundle_name; /* bundle name for multilink */
diff --git a/patches/ppp-2.4.7/0017-ppp-2.4.2-stripMSdomain.patch b/patches/ppp-2.4.7/0017-ppp-2.4.2-stripMSdomain.patch
new file mode 100644
index 000000000..5ac426e19
--- /dev/null
+++ b/patches/ppp-2.4.7/0017-ppp-2.4.2-stripMSdomain.patch
@@ -0,0 +1,44 @@
+From: Marco d'Itri <md@linux.it>
+Date: Fri, 2 Jun 2017 11:22:53 +0200
+Subject: [PATCH] ppp-2.4.2-stripMSdomain
+
+---
+ pppd/chap-new.c | 11 +++++++++++
+ 1 file changed, 11 insertions(+)
+
+diff --git a/pppd/chap-new.c b/pppd/chap-new.c
+index 2714bff64785..7fd7087a5e2c 100644
+--- a/pppd/chap-new.c
++++ b/pppd/chap-new.c
+@@ -58,6 +58,7 @@ int (*chap_verify_hook)(char *name, char *ourname, int id,
+ int chap_timeout_time = 3;
+ int chap_max_transmits = 10;
+ int chap_rechallenge_time = 0;
++int chapms_strip_domain = 0;
+
+ /*
+ * Command-line options.
+@@ -69,6 +70,8 @@ static option_t chap_option_list[] = {
+ "Set max #xmits for challenge", OPT_PRIO },
+ { "chap-interval", o_int, &chap_rechallenge_time,
+ "Set interval for rechallenge", OPT_PRIO },
++ { "chapms-strip-domain", o_bool, &chapms_strip_domain,
++ "Strip the domain prefix before the Username", 1 },
+ { NULL }
+ };
+
+@@ -336,6 +339,14 @@ chap_handle_response(struct chap_server_state *ss, int id,
+ /* Null terminate and clean remote name. */
+ slprintf(rname, sizeof(rname), "%.*v", len, name);
+ name = rname;
++
++ /* strip the MS domain name */
++ if (chapms_strip_domain && strrchr(rname, '\\')) {
++ char tmp[MAXNAMELEN+1];
++
++ strcpy(tmp, strrchr(rname, '\\') + 1);
++ strcpy(rname, tmp);
++ }
+ }
+
+ if (chap_verify_hook)
diff --git a/patches/ppp-2.4.7/0018-export-CALL_FILE-to-the-link-scripts.patch b/patches/ppp-2.4.7/0018-export-CALL_FILE-to-the-link-scripts.patch
new file mode 100644
index 000000000..6bce58107
--- /dev/null
+++ b/patches/ppp-2.4.7/0018-export-CALL_FILE-to-the-link-scripts.patch
@@ -0,0 +1,35 @@
+From: Marco d'Itri <md@linux.it>
+Date: Fri, 2 Jun 2017 11:23:29 +0200
+Subject: [PATCH] export $CALL_FILE to the link scripts
+
+---
+ pppd/options.c | 1 +
+ pppd/pppd.8 | 3 +++
+ 2 files changed, 4 insertions(+)
+
+diff --git a/pppd/options.c b/pppd/options.c
+index dc2d7329a93d..2de65f9aa8d5 100644
+--- a/pppd/options.c
++++ b/pppd/options.c
+@@ -1477,6 +1477,7 @@ callfile(argv)
+ if ((fname = (char *) malloc(l)) == NULL)
+ novm("call file name");
+ slprintf(fname, l, "%s%s", _PATH_PEERFILES, arg);
++ script_setenv("CALL_FILE", arg, 0);
+
+ ok = options_from_file(fname, 1, 1, 1);
+
+diff --git a/pppd/pppd.8 b/pppd/pppd.8
+index 67181083808b..f6c9e909254c 100644
+--- a/pppd/pppd.8
++++ b/pppd/pppd.8
+@@ -1656,6 +1656,9 @@ the connection.
+ .B LINKNAME
+ The logical name of the link, set with the \fIlinkname\fR option.
+ .TP
++.B CALL_FILE
++The value of the \fIcall\fR option.
++.TP
+ .B DNS1
+ If the peer supplies DNS server addresses, this variable is set to the
+ first DNS server address supplied (whether or not the usepeerdns
diff --git a/patches/ppp-2.4.7/0019-ipv6-accept-remote.patch b/patches/ppp-2.4.7/0019-ipv6-accept-remote.patch
new file mode 100644
index 000000000..e83406d3b
--- /dev/null
+++ b/patches/ppp-2.4.7/0019-ipv6-accept-remote.patch
@@ -0,0 +1,70 @@
+From: Marco d'Itri <md@linux.it>
+Date: Fri, 2 Jun 2017 11:24:22 +0200
+Subject: [PATCH] ipv6-accept-remote
+
+---
+ pppd/ipv6cp.c | 5 ++++-
+ pppd/ipv6cp.h | 3 ++-
+ pppd/pppd.8 | 5 +++++
+ 3 files changed, 11 insertions(+), 2 deletions(-)
+
+diff --git a/pppd/ipv6cp.c b/pppd/ipv6cp.c
+index c1602f41c206..432170462196 100644
+--- a/pppd/ipv6cp.c
++++ b/pppd/ipv6cp.c
+@@ -245,6 +245,8 @@ static option_t ipv6cp_option_list[] = {
+
+ { "ipv6cp-accept-local", o_bool, &ipv6cp_allowoptions[0].accept_local,
+ "Accept peer's interface identifier for us", 1 },
++ { "ipv6cp-accept-remote", o_bool, &ipv6cp_allowoptions[0].accept_remote,
++ "Accept peer's interface identifier for itself", 1 },
+
+ { "ipv6cp-use-ipaddr", o_bool, &ipv6cp_allowoptions[0].use_ip,
+ "Use (default) IPv4 address as interface identifier", 1 },
+@@ -435,6 +437,7 @@ ipv6cp_init(unit)
+ memset(ao, 0, sizeof(*ao));
+
+ wo->accept_local = 1;
++ wo->accept_remote = 1;
+ wo->neg_ifaceid = 1;
+ ao->neg_ifaceid = 1;
+
+@@ -960,7 +963,7 @@ ipv6cp_reqci(f, inp, len, reject_if_disagree)
+ orc = CONFREJ; /* Reject CI */
+ break;
+ }
+- if (!eui64_iszero(wo->hisid) &&
++ if (!eui64_iszero(wo->hisid) && !wo->accept_remote &&
+ !eui64_equals(ifaceid, wo->hisid) &&
+ eui64_iszero(go->hisid)) {
+
+diff --git a/pppd/ipv6cp.h b/pppd/ipv6cp.h
+index 2f4c06ddc189..1617707ebbde 100644
+--- a/pppd/ipv6cp.h
++++ b/pppd/ipv6cp.h
+@@ -150,7 +150,8 @@
+ typedef struct ipv6cp_options {
+ int neg_ifaceid; /* Negotiate interface identifier? */
+ int req_ifaceid; /* Ask peer to send interface identifier? */
+- int accept_local; /* accept peer's value for iface id? */
++ int accept_local; /* accept peer's value for our iface id? */
++ int accept_remote; /* accept peer's value for his iface id? */
+ int opt_local; /* ourtoken set by option */
+ int opt_remote; /* histoken set by option */
+ int use_ip; /* use IP as interface identifier */
+diff --git a/pppd/pppd.8 b/pppd/pppd.8
+index f6c9e909254c..f226392c0280 100644
+--- a/pppd/pppd.8
++++ b/pppd/pppd.8
+@@ -463,6 +463,11 @@ With this option, pppd will accept the peer's idea of our local IPv6
+ interface identifier, even if the local IPv6 interface identifier
+ was specified in an option.
+ .TP
++.B ipv6cp\-accept\-remote
++With this option, pppd will accept the peer's idea of its (remote)
++IPv6 interface identifier, even if the remote IPv6 interface
++identifier was specified in an option.
++.TP
+ .B ipv6cp\-max\-configure \fIn
+ Set the maximum number of IPv6CP configure-request transmissions to
+ \fIn\fR (default 10).
diff --git a/patches/ppp-2.4.7/0020-allow-use-of-arbitrary-interface-names.patch b/patches/ppp-2.4.7/0020-allow-use-of-arbitrary-interface-names.patch
new file mode 100644
index 000000000..3fb234038
--- /dev/null
+++ b/patches/ppp-2.4.7/0020-allow-use-of-arbitrary-interface-names.patch
@@ -0,0 +1,210 @@
+From: Marco d'Itri <md@linux.it>
+Date: Fri, 2 Jun 2017 11:25:19 +0200
+Subject: [PATCH] allow use of arbitrary interface names
+
+This is a modified version of a patch from openSUSE that enables PPP interfaces
+to be called arbitrary names, rather than simply pppX where X is the unit
+number.
+
+The modifications from the stock openSUSE patch are:
+- refresh patch on top of 018_ip-up_option.diff
+- fix a printf format-string vulnerability in pppd/main.c:set_ifunit()
+- clarify the pppd.8 manpage additions
+- patch pppstats/pppstats.c to query renamed interfaces without complaint
+
+Origin: vendor, https://build.opensuse.org/source/network/ppp/ppp-2.4.2-ifname.diff?rev=7a0fdeff0b29437dd7f4581c95c7255a
+Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=458646
+Forwarded: no
+Reviewed-by: Chris Boot <bootc@debian.org>
+Last-Update: 2014-01-12
+---
+ pppd/main.c | 16 ++++++----------
+ pppd/options.c | 5 +++++
+ pppd/pppd.8 | 8 +++++++-
+ pppd/pppd.h | 11 +++++++++++
+ pppd/sys-linux.c | 15 +++++++++++++++
+ pppstats/pppstats.c | 12 ++++++------
+ 6 files changed, 50 insertions(+), 17 deletions(-)
+
+diff --git a/pppd/main.c b/pppd/main.c
+index 59aad6f3854f..3871aa2b3a5e 100644
+--- a/pppd/main.c
++++ b/pppd/main.c
+@@ -124,7 +124,7 @@
+ static const char rcsid[] = RCSID;
+
+ /* interface vars */
+-char ifname[32]; /* Interface name */
++char ifname[MAXIFNAMELEN]; /* Interface name */
+ int ifunit; /* Interface unit number */
+
+ struct channel *the_channel;
+@@ -298,13 +298,6 @@ struct protent *protocols[] = {
+ NULL
+ };
+
+-/*
+- * If PPP_DRV_NAME is not defined, use the default "ppp" as the device name.
+- */
+-#if !defined(PPP_DRV_NAME)
+-#define PPP_DRV_NAME "ppp"
+-#endif /* !defined(PPP_DRV_NAME) */
+-
+ int
+ main(argc, argv)
+ int argc;
+@@ -740,8 +733,11 @@ void
+ set_ifunit(iskey)
+ int iskey;
+ {
+- info("Using interface %s%d", PPP_DRV_NAME, ifunit);
+- slprintf(ifname, sizeof(ifname), "%s%d", PPP_DRV_NAME, ifunit);
++ if (req_ifname[0] != '\0')
++ slprintf(ifname, sizeof(ifname), "%s", req_ifname);
++ else
++ slprintf(ifname, sizeof(ifname), "%s%d", PPP_DRV_NAME, ifunit);
++ info("Using interface %s", ifname);
+ script_setenv("IFNAME", ifname, iskey);
+ if (iskey) {
+ create_pidfile(getpid()); /* write pid to file */
+diff --git a/pppd/options.c b/pppd/options.c
+index 2de65f9aa8d5..340797386dd6 100644
+--- a/pppd/options.c
++++ b/pppd/options.c
+@@ -116,6 +116,7 @@ int connect_delay = 1000; /* wait this many ms after connect script */
+ int req_unit = -1; /* requested interface unit */
+ char path_ipup[MAXPATHLEN]; /* pathname of ip-up script */
+ char path_ipdown[MAXPATHLEN];/* pathname of ip-down script */
++char req_ifname[MAXIFNAMELEN]; /* requested interface name */
+ bool multilink = 0; /* Enable multilink operation */
+ char *bundle_name = NULL; /* bundle name for multilink */
+ bool dump_options; /* print out option values */
+@@ -285,6 +286,10 @@ option_t general_options[] = {
+ "PPP interface unit number to use if possible",
+ OPT_PRIO | OPT_LLIMIT, 0, 0 },
+
++ { "ifname", o_string, req_ifname,
++ "Set PPP interface name",
++ OPT_PRIO | OPT_PRIV | OPT_STATIC, NULL, MAXIFNAMELEN },
++
+ { "dump", o_bool, &dump_options,
+ "Print out option values after parsing all options", 1 },
+ { "dryrun", o_bool, &dryrun,
+diff --git a/pppd/pppd.8 b/pppd/pppd.8
+index f226392c0280..65bbe721f761 100644
+--- a/pppd/pppd.8
++++ b/pppd/pppd.8
+@@ -1093,7 +1093,13 @@ under Linux and FreeBSD 2.2.8 and later.
+ .TP
+ .B unit \fInum
+ Sets the ppp unit number (for a ppp0 or ppp1 etc interface name) for outbound
+-connections.
++connections. If the unit is already in use a dynamically allocated number will
++be used.
++.TP
++.B ifname \fIstring
++Set the ppp interface name for outbound connections. If the interface name is
++already in use, or if the name cannot be used for any other reason, pppd will
++terminate.
+ .TP
+ .B unset \fIname
+ Remove a variable from the environment variable for scripts that are
+diff --git a/pppd/pppd.h b/pppd/pppd.h
+index 2be649adf582..b11670586244 100644
+--- a/pppd/pppd.h
++++ b/pppd/pppd.h
+@@ -80,6 +80,16 @@
+ #define MAXARGS 1 /* max # args to a command */
+ #define MAXNAMELEN 256 /* max length of hostname or name for auth */
+ #define MAXSECRETLEN 256 /* max length of password or secret */
++#define MAXIFNAMELEN 32 /* max length of interface name; or use IFNAMSIZ, can we
++ always include net/if.h? */
++
++/*
++ * If PPP_DRV_NAME is not defined, use the default "ppp" as the device name.
++ * Where should PPP_DRV_NAME come from? Do we include it here?
++ */
++#if !defined(PPP_DRV_NAME)
++#define PPP_DRV_NAME "ppp"
++#endif /* !defined(PPP_DRV_NAME) */
+
+ /*
+ * Option descriptor structure.
+@@ -320,6 +330,7 @@ extern int max_data_rate; /* max bytes/sec through charshunt */
+ extern int req_unit; /* interface unit number to use */
+ extern char path_ipup[MAXPATHLEN]; /* pathname of ip-up script */
+ extern char path_ipdown[MAXPATHLEN]; /* pathname of ip-down script */
++extern char req_ifname[MAXIFNAMELEN]; /* interface name to use */
+ extern bool multilink; /* enable multilink operation */
+ extern bool noendpoint; /* don't send or accept endpt. discrim. */
+ extern char *bundle_name; /* bundle name for multilink */
+diff --git a/pppd/sys-linux.c b/pppd/sys-linux.c
+index 86cde57664af..878f83bdfe3b 100644
+--- a/pppd/sys-linux.c
++++ b/pppd/sys-linux.c
+@@ -650,6 +650,21 @@ static int make_ppp_unit()
+ }
+ if (x < 0)
+ error("Couldn't create new ppp unit: %m");
++
++ if (x == 0 && req_ifname[0] != '\0') {
++ struct ifreq ifr;
++ char t[MAXIFNAMELEN];
++ memset(&ifr, 0, sizeof(struct ifreq));
++ slprintf(t, sizeof(t), "%s%d", PPP_DRV_NAME, ifunit);
++ strncpy(ifr.ifr_name, t, IF_NAMESIZE);
++ strncpy(ifr.ifr_newname, req_ifname, IF_NAMESIZE);
++ x = ioctl(sock_fd, SIOCSIFNAME, &ifr);
++ if (x < 0)
++ error("Couldn't rename interface %s to %s: %m", t, req_ifname);
++ else
++ info("Renamed interface %s to %s", t, req_ifname);
++ }
++
+ return x;
+ }
+
+diff --git a/pppstats/pppstats.c b/pppstats/pppstats.c
+index 6367988eb96b..46cb9c24942b 100644
+--- a/pppstats/pppstats.c
++++ b/pppstats/pppstats.c
+@@ -88,7 +88,6 @@ int aflag; /* print absolute values, not deltas */
+ int dflag; /* print data rates, not bytes */
+ int interval, count;
+ int infinite;
+-int unit;
+ int s; /* socket or /dev/ppp file descriptor */
+ int signalled; /* set if alarm goes off "early" */
+ char *progname;
+@@ -449,6 +448,7 @@ main(argc, argv)
+ {
+ int c;
+ #ifdef STREAMS
++ int unit;
+ char *dev;
+ #endif
+
+@@ -506,11 +506,6 @@ main(argc, argv)
+ if (argc > 0)
+ interface = argv[0];
+
+- if (sscanf(interface, PPP_DRV_NAME "%d", &unit) != 1) {
+- fprintf(stderr, "%s: invalid interface '%s' specified\n",
+- progname, interface);
+- }
+-
+ #ifndef STREAMS
+ {
+ struct ifreq ifr;
+@@ -535,6 +530,11 @@ main(argc, argv)
+ }
+
+ #else /* STREAMS */
++ if (sscanf(interface, PPP_DRV_NAME "%d", &unit) != 1) {
++ fprintf(stderr, "%s: invalid interface '%s' specified\n",
++ progname, interface);
++ }
++
+ #ifdef __osf__
+ dev = "/dev/streams/ppp";
+ #else
diff --git a/patches/ppp-2.4.7/0021-fix-a-potential-buffer-overflow-in-clientid.c-rc_map.patch b/patches/ppp-2.4.7/0021-fix-a-potential-buffer-overflow-in-clientid.c-rc_map.patch
new file mode 100644
index 000000000..31edc06cb
--- /dev/null
+++ b/patches/ppp-2.4.7/0021-fix-a-potential-buffer-overflow-in-clientid.c-rc_map.patch
@@ -0,0 +1,38 @@
+From: Marco d'Itri <md@linux.it>
+Date: Fri, 2 Jun 2017 11:25:56 +0200
+Subject: [PATCH] fix a potential buffer overflow in clientid.c:rc_map2id()
+
+This fixes the following compile-time warning when building with
+-D_FORTIFY_SOURCE=2:
+
+In file included from /usr/include/string.h:638:0,
+ from ./includes.h:26,
+ from clientid.c:12:
+In function 'strncat',
+ inlined from 'rc_map2id' at clientid.c:113:9:
+/usr/include/i386-linux-gnu/bits/string3.h:150:3: warning: call to
+__builtin___strncat_chk might overflow destination buffer [enabled by default]
+ return __builtin___strncat_chk (__dest, __src, __len, __bos (__dest));
+ ^
+
+Origin: vendor, https://build.opensuse.org/source/network/ppp/ppp-2.4.4-strncatfix.patch?rev=7a0fdeff0b29437dd7f4581c95c7255a
+Forwarded: no
+Reviewed-by: Chris Boot <bootc@debian.org>
+Last-Update: 2014-01-12
+---
+ pppd/plugins/radius/clientid.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/pppd/plugins/radius/clientid.c b/pppd/plugins/radius/clientid.c
+index d49579c43cc3..7de021139b56 100644
+--- a/pppd/plugins/radius/clientid.c
++++ b/pppd/plugins/radius/clientid.c
+@@ -110,7 +110,7 @@ UINT4 rc_map2id(char *name)
+ if (*name != '/')
+ strcpy(ttyname, "/dev/");
+
+- strncat(ttyname, name, sizeof(ttyname));
++ strncat(ttyname, name, sizeof(ttyname)-strlen(ttyname)-1);
+
+ for(p = map2id_list; p; p = p->next)
+ if (!strcmp(ttyname, p->name)) return p->id;
diff --git a/patches/ppp-2.4.7/0022-scripts-README.patch b/patches/ppp-2.4.7/0022-scripts-README.patch
new file mode 100644
index 000000000..f786cc81d
--- /dev/null
+++ b/patches/ppp-2.4.7/0022-scripts-README.patch
@@ -0,0 +1,30 @@
+From: Marco d'Itri <md@linux.it>
+Date: Fri, 2 Jun 2017 11:26:37 +0200
+Subject: [PATCH] scripts README
+
+---
+ scripts/README | 14 ++++++++++++++
+ 1 file changed, 14 insertions(+)
+
+diff --git a/scripts/README b/scripts/README
+index 00e032ca6ad4..439c900d657a 100644
+--- a/scripts/README
++++ b/scripts/README
+@@ -141,3 +141,17 @@ option. In addition, all ASCII control characters [0x00 to 0x1f], plus 0xff,
+ are escaped. This may need to be modified depending on the ssh (or
+ pseudo-tty) implementation which may differ across platforms, for further
+ optimizations.
++
++------------------------------------------------------------------------
++
++12. pon, poff and ip-up
++
++These are modified version of the pon/poff/ip-up scripts contributed by Yann
++Dirson <dirson@debian.org>. They allow you to call "pon quick" respectively
++"pon quick my-isp" to just call the provider for running you ip-up scripts in
++/etc/ppp/ip-up.d. This can be useful to check for incoming/flush outgoing
++mail, without the necessary delay before hangup introduced by diald or such.
++
++These scripts break the possibility to connect to multiple ISPs at once, so
++they are included only here.
++
diff --git a/patches/ppp-2.4.7/0023-no_crypt_hack.patch b/patches/ppp-2.4.7/0023-no_crypt_hack.patch
new file mode 100644
index 000000000..5e8d51bbf
--- /dev/null
+++ b/patches/ppp-2.4.7/0023-no_crypt_hack.patch
@@ -0,0 +1,61 @@
+From: Marco d'Itri <md@linux.it>
+Date: Fri, 2 Jun 2017 11:27:15 +0200
+Subject: [PATCH] no_crypt_hack
+
+The udeb package does not have crypt(3). This patch makes
+authentication always fail, since it is not needed anyway for dialout.
+---
+ pppd/Makefile.linux | 4 ++++
+ pppd/auth.c | 2 ++
+ pppd/session.c | 2 ++
+ 3 files changed, 8 insertions(+)
+
+diff --git a/pppd/Makefile.linux b/pppd/Makefile.linux
+index 16b3ee879791..a8694fccd85e 100644
+--- a/pppd/Makefile.linux
++++ b/pppd/Makefile.linux
+@@ -121,10 +121,14 @@ CFLAGS += -DHAS_SHADOW
+ #LIBS += -lshadow $(LIBS)
+ endif
+
++ifdef NO_CRYPT_HACK
++CFLAGS += -DNO_CRYPT_HACK
++else
+ ifneq ($(wildcard /usr/include/crypt.h),)
+ CFLAGS += -DHAVE_CRYPT_H=1
+ LIBS += -lcrypt
+ endif
++endif
+
+ ifdef USE_LIBUTIL
+ CFLAGS += -DHAVE_LOGWTMP=1
+diff --git a/pppd/auth.c b/pppd/auth.c
+index 4271af687102..931c6b45043b 100644
+--- a/pppd/auth.c
++++ b/pppd/auth.c
+@@ -1442,8 +1442,10 @@ check_passwd(unit, auser, userlen, apasswd, passwdlen, msg)
+ if (secret[0] != 0 && !login_secret) {
+ /* password given in pap-secrets - must match */
+ if (cryptpap || strcmp(passwd, secret) != 0) {
++#ifndef NO_CRYPT_HACK
+ char *cbuf = crypt(passwd, secret);
+ if (!cbuf || strcmp(cbuf, secret) != 0)
++#endif
+ ret = UPAP_AUTHNAK;
+ }
+ }
+diff --git a/pppd/session.c b/pppd/session.c
+index 56385dd63874..977139665218 100644
+--- a/pppd/session.c
++++ b/pppd/session.c
+@@ -351,8 +351,10 @@ session_start(flags, user, passwd, ttyName, msg)
+ */
+ if (pw->pw_passwd == NULL || strlen(pw->pw_passwd) < 2)
+ return SESSION_FAILED;
++#ifndef NO_CRYPT_HACK
+ cbuf = crypt(passwd, pw->pw_passwd);
+ if (!cbuf || strcmp(cbuf, pw->pw_passwd) != 0)
++#endif
+ return SESSION_FAILED;
+ }
+
diff --git a/patches/ppp-2.4.7/0024-resolv.conf_no_log.patch b/patches/ppp-2.4.7/0024-resolv.conf_no_log.patch
new file mode 100644
index 000000000..ebdcc2d12
--- /dev/null
+++ b/patches/ppp-2.4.7/0024-resolv.conf_no_log.patch
@@ -0,0 +1,21 @@
+From: Marco d'Itri <md@linux.it>
+Date: Fri, 2 Jun 2017 11:27:40 +0200
+Subject: [PATCH] resolv.conf_no_log
+
+---
+ pppd/ipcp.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/pppd/ipcp.c b/pppd/ipcp.c
+index d6e0e2a699fe..b81b2fd0a29f 100644
+--- a/pppd/ipcp.c
++++ b/pppd/ipcp.c
+@@ -2152,7 +2152,7 @@ create_resolv(peerdns1, peerdns2)
+
+ f = fopen(_PATH_RESOLV, "w");
+ if (f == NULL) {
+- error("Failed to create %s: %m", _PATH_RESOLV);
++ /* error("Failed to create %s: %m", _PATH_RESOLV); */
+ return;
+ }
+
diff --git a/patches/ppp-2.4.7/0025-Debian-specific-changes.patch b/patches/ppp-2.4.7/0025-Debian-specific-changes.patch
new file mode 100644
index 000000000..fcbba6357
--- /dev/null
+++ b/patches/ppp-2.4.7/0025-Debian-specific-changes.patch
@@ -0,0 +1,86 @@
+From: Marco d'Itri <md@linux.it>
+Date: Fri, 2 Jun 2017 11:28:30 +0200
+Subject: [PATCH] Debian-specific changes.
+
+---
+ pppd/Makefile.linux | 6 ++----
+ pppd/pathnames.h | 2 +-
+ pppd/pppd.h | 2 +-
+ pppdump/Makefile.linux | 4 ++--
+ 4 files changed, 6 insertions(+), 8 deletions(-)
+
+diff --git a/pppd/Makefile.linux b/pppd/Makefile.linux
+index a8694fccd85e..a90cbdcf8bb1 100644
+--- a/pppd/Makefile.linux
++++ b/pppd/Makefile.linux
+@@ -61,14 +61,14 @@ HAVE_MULTILINK=y
+ USE_TDB=y
+
+ HAS_SHADOW=y
+-#USE_PAM=y
++USE_PAM=y
+ HAVE_INET6=y
+
+ # Enable plugins
+ PLUGIN=y
+
+ # Enable Microsoft proprietary Callback Control Protocol
+-#CBCP=y
++CBCP=y
+
+ # Enable EAP SRP-SHA1 authentication (requires libsrp)
+ #USE_SRP=y
+@@ -182,11 +182,9 @@ LIBS += -ldl
+ endif
+
+ ifdef FILTER
+-ifneq ($(wildcard /usr/include/pcap-bpf.h),)
+ LIBS += -lpcap
+ CFLAGS += -DPPP_FILTER
+ endif
+-endif
+
+ ifdef HAVE_INET6
+ PPPDSRCS += ipv6cp.c eui64.c
+diff --git a/pppd/pathnames.h b/pppd/pathnames.h
+index a33f0466c9d6..46972601fc92 100644
+--- a/pppd/pathnames.h
++++ b/pppd/pathnames.h
+@@ -28,7 +28,7 @@
+ #define _PATH_AUTHUP _ROOT_PATH "/etc/ppp/auth-up"
+ #define _PATH_AUTHDOWN _ROOT_PATH "/etc/ppp/auth-down"
+ #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"
+
+diff --git a/pppd/pppd.h b/pppd/pppd.h
+index b11670586244..567d702181ca 100644
+--- a/pppd/pppd.h
++++ b/pppd/pppd.h
+@@ -870,7 +870,7 @@ extern void (*snoop_send_hook) __P((unsigned char *p, int len));
+ || defined(DEBUGCHAP) || defined(DEBUG) || defined(DEBUGIPV6CP)
+ #define LOG_PPP LOG_LOCAL2
+ #else
+-#define LOG_PPP LOG_DAEMON
++#define LOG_PPP LOG_LOCAL2
+ #endif
+ #endif /* LOG_PPP */
+
+diff --git a/pppdump/Makefile.linux b/pppdump/Makefile.linux
+index 87777fab5e94..1eeeafe20111 100644
+--- a/pppdump/Makefile.linux
++++ b/pppdump/Makefile.linux
+@@ -2,9 +2,9 @@ DESTDIR = $(INSTROOT)@DESTDIR@
+ BINDIR = $(DESTDIR)/sbin
+ MANDIR = $(DESTDIR)/share/man/man8
+
+-DO_DEFLATE=y
++#DO_DEFLATE=y
+ DO_BSD_COMPRESS=y
+-HAVE_ZLIB=n
++HAVE_ZLIB=y
+
+ COPTS=-O2 -g
+ CFLAGS= $(COPTS) -I../include/net
diff --git a/patches/ppp-2.4.7/0026-secure-card-interpreter-fix.patch b/patches/ppp-2.4.7/0026-secure-card-interpreter-fix.patch
new file mode 100644
index 000000000..fb54a5e9d
--- /dev/null
+++ b/patches/ppp-2.4.7/0026-secure-card-interpreter-fix.patch
@@ -0,0 +1,26 @@
+From: Marco d'Itri <md@linux.it>
+Date: Fri, 2 Jun 2017 11:29:20 +0200
+Subject: [PATCH] secure-card-interpreter-fix
+
+This fixes the lintian warning:
+I: ppp: example-wrong-path-for-interpreter
+ usr/share/doc/ppp/examples/scripts/secure-card
+ (#!/usr/local/bin/expect != /usr/bin/expect)
+
+Author: Chris Boot <bootc@debian.org>
+Forwarded: not-needed
+Last-Update: 2013-09-09
+---
+ scripts/secure-card | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/scripts/secure-card b/scripts/secure-card
+index 0002365e4edb..ae3ae50c14f4 100755
+--- a/scripts/secure-card
++++ b/scripts/secure-card
+@@ -1,4 +1,4 @@
+-#!/usr/local/bin/expect -f
++#!/usr/bin/expect -f
+ #
+ # This script was written by Jim Isaacson <jcisaac@crl.com>. It is
+ # designed to work as a script to use the SecureCARD(tm) device. This
diff --git a/patches/ppp-2.4.7/0027-Fix-buffer-overflow-in-rc_mksid.patch b/patches/ppp-2.4.7/0027-Fix-buffer-overflow-in-rc_mksid.patch
new file mode 100644
index 000000000..29a6ea1d6
--- /dev/null
+++ b/patches/ppp-2.4.7/0027-Fix-buffer-overflow-in-rc_mksid.patch
@@ -0,0 +1,30 @@
+From: Emanuele Rocca <ema@debian.org>
+Date: Fri, 2 Jun 2017 11:30:48 +0200
+Subject: [PATCH] Fix buffer overflow in rc_mksid()
+
+rc_mksid converts the PID of pppd to hex to generate a pseudo-unique string.
+
+If the process id is bigger than 65535 (FFFF), its hex representation will be
+longer than 4 characters, resulting in a buffer overflow.
+
+The bug can be exploited to cause a remote DoS.
+
+Bug-Debian: https://bugs.debian.org/782450
+Last-Update: <2015-04-14>
+---
+ pppd/plugins/radius/util.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/pppd/plugins/radius/util.c b/pppd/plugins/radius/util.c
+index 6f976a712951..166bd5f31d7a 100644
+--- a/pppd/plugins/radius/util.c
++++ b/pppd/plugins/radius/util.c
+@@ -77,7 +77,7 @@ rc_mksid (void)
+ static unsigned short int cnt = 0;
+ sprintf (buf, "%08lX%04X%02hX",
+ (unsigned long int) time (NULL),
+- (unsigned int) getpid (),
++ (unsigned int) getpid () % 65535,
+ cnt & 0xFF);
+ cnt++;
+ return buf;
diff --git a/patches/ppp-2.4.7/0028-Add-a-SONAME-to-the-pppd-binary.patch b/patches/ppp-2.4.7/0028-Add-a-SONAME-to-the-pppd-binary.patch
new file mode 100644
index 000000000..df533456a
--- /dev/null
+++ b/patches/ppp-2.4.7/0028-Add-a-SONAME-to-the-pppd-binary.patch
@@ -0,0 +1,38 @@
+From: Chris Boot <bootc@debian.org>
+Date: Fri, 2 Jun 2017 11:31:35 +0200
+Subject: [PATCH] Add a SONAME to the pppd binary
+
+ This hack inserts a SONAME into the pppd binary, which allows us to
+ run dpkg-gensymbols/dh_makeshlibs over the resulting binary. This is
+ useful so that we can use Debian's standard build infrastructure to
+ help track the ppp binary's ABI, which is used by plugins.
+
+Forwarded: not-needed
+Last-Update: 2015-12-05
+---
+ pppd/Makefile.linux | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/pppd/Makefile.linux b/pppd/Makefile.linux
+index a90cbdcf8bb1..f1b2c90bb510 100644
+--- a/pppd/Makefile.linux
++++ b/pppd/Makefile.linux
+@@ -206,6 +206,8 @@ endif
+
+ INSTALL= install
+
++VERSION = $(shell awk -F '"' '/VERSION/ { print $$2; }' patchlevel.h)
++
+ all: $(TARGETS)
+
+ install: pppd
+@@ -217,7 +219,8 @@ install: pppd
+ $(INSTALL) -c -m 444 pppd.8 $(MANDIR)
+
+ pppd: $(PPPDOBJS)
+- $(CC) $(LDFLAGS) -o pppd $(PPPDOBJS) $(LIBS)
++ $(CC) $(LDFLAGS) -o pppd $(PPPDOBJS) $(LIBS) \
++ -Wl,-soname,pppd.so.$(VERSION)
+
+ srp-entry: srp-entry.c
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ srp-entry.c $(LIBS)
diff --git a/patches/ppp-2.4.7/0029-Fix-FTBFS-in-rp-pppoe.patch b/patches/ppp-2.4.7/0029-Fix-FTBFS-in-rp-pppoe.patch
new file mode 100644
index 000000000..9a9d34760
--- /dev/null
+++ b/patches/ppp-2.4.7/0029-Fix-FTBFS-in-rp-pppoe.patch
@@ -0,0 +1,36 @@
+From: Chris Boot <bootc@debian.org>
+Date: Fri, 2 Jun 2017 11:32:22 +0200
+Subject: [PATCH] Fix FTBFS in rp-pppoe
+
+ Include netinet/in.h earlier to avoid a conflict with linux/in.h. See Bug
+ #824442 (on src:glibc) for information related to this.
+
+Bug-Debian: https://bugs.debian.org/824442
+Forwarded: no
+Last-Update: 2016-11-11
+---
+ pppd/plugins/rp-pppoe/pppoe.h | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/pppd/plugins/rp-pppoe/pppoe.h b/pppd/plugins/rp-pppoe/pppoe.h
+index 86d2b1e47a25..fee9ab62ee21 100644
+--- a/pppd/plugins/rp-pppoe/pppoe.h
++++ b/pppd/plugins/rp-pppoe/pppoe.h
+@@ -49,6 +49,8 @@
+ #include <sys/socket.h>
+ #endif
+
++#include <netinet/in.h>
++
+ /* Ugly header files on some Linux boxes... */
+ #if defined(HAVE_LINUX_IF_H)
+ #include <linux/if.h>
+@@ -86,8 +88,6 @@ typedef unsigned long UINT32_t;
+ #include <linux/if_ether.h>
+ #endif
+
+-#include <netinet/in.h>
+-
+ #ifdef HAVE_NETINET_IF_ETHER_H
+ #include <sys/types.h>
+
diff --git a/patches/ppp-2.4.7/0030-pppd-make-makefile-sysroot-aware.patch b/patches/ppp-2.4.7/0030-pppd-make-makefile-sysroot-aware.patch
new file mode 100644
index 000000000..098b526c6
--- /dev/null
+++ b/patches/ppp-2.4.7/0030-pppd-make-makefile-sysroot-aware.patch
@@ -0,0 +1,38 @@
+From: Marc Kleine-Budde <m.kleine-budde@pengutronix.de>
+Date: Wed, 25 Jan 2012 17:50:07 +0100
+Subject: [PATCH] pppd: make makefile sysroot aware
+
+The pppd Makefile is not SYSROOT aware. This patch replaces all
+occurrences of absolute paths by their corresponding SYSROOT relative
+ones.
+
+Signed-off-by: Marc Kleine-Budde <m.kleine-budde@pengutronix.de>
+Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
+---
+ pppd/Makefile.linux | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/pppd/Makefile.linux b/pppd/Makefile.linux
+index f1b2c90bb510..8b88f2b4811d 100644
+--- a/pppd/Makefile.linux
++++ b/pppd/Makefile.linux
+@@ -100,8 +100,8 @@ endif
+
+ # EAP SRP-SHA1
+ ifdef USE_SRP
+-CFLAGS += -DUSE_SRP -DOPENSSL -I/usr/local/ssl/include
+-LIBS += -lsrp -L/usr/local/ssl/lib -lcrypto
++CFLAGS += -DUSE_SRP -DOPENSSL -I$(SYSROOT)/usr/local/ssl/include
++LIBS += -lsrp -L$(SYSROOT)/usr/local/ssl/lib -lcrypto
+ TARGETS += srp-entry
+ EXTRAINSTALL = $(INSTALL) -c -m 555 srp-entry $(BINDIR)/srp-entry
+ MANPAGES += srp-entry.8
+@@ -124,7 +124,7 @@ endif
+ ifdef NO_CRYPT_HACK
+ CFLAGS += -DNO_CRYPT_HACK
+ else
+-ifneq ($(wildcard /usr/include/crypt.h),)
++ifdef USE_CRYPT
+ CFLAGS += -DHAVE_CRYPT_H=1
+ LIBS += -lcrypt
+ endif
diff --git a/patches/ppp-2.4.7/0031-pppd-make-the-self-made-configure-cross-aware.patch b/patches/ppp-2.4.7/0031-pppd-make-the-self-made-configure-cross-aware.patch
new file mode 100644
index 000000000..0747d58b6
--- /dev/null
+++ b/patches/ppp-2.4.7/0031-pppd-make-the-self-made-configure-cross-aware.patch
@@ -0,0 +1,44 @@
+From: Juergen Beisert <juergen@kreuzholzen.de>
+Date: Wed, 25 Jan 2012 17:50:07 +0100
+Subject: [PATCH] pppd: make the self made configure cross aware
+
+Give us a chance to setup targets Kernel and arch.
+
+Signed-off-by: Juergen Beisert <juergen@kreuzholzen.de>
+---
+ configure | 10 ++++++++++
+ pppd/plugins/Makefile.linux | 2 +-
+ 2 files changed, 11 insertions(+), 1 deletion(-)
+
+diff --git a/configure b/configure
+index 6a55e0f08be4..3886564fa495 100755
+--- a/configure
++++ b/configure
+@@ -14,6 +14,16 @@ SYSCONF=/etc
+ # fi
+ state="unknown"
+
++if [ -n $TARGET_OS ]; then
++ system=$TARGET_OS
++fi
++if [ -n $TARGET_OS_VER ]; then
++ release=$TARGET_OS_VER
++fi
++if [ -n $TARGET_OS_ARCH ]; then
++ arch=$TARGET_OS_ARCH
++fi
++
+ case $system in
+ Linux)
+ makext="linux";
+diff --git a/pppd/plugins/Makefile.linux b/pppd/plugins/Makefile.linux
+index 732cc8b411d2..193d884b898b 100644
+--- a/pppd/plugins/Makefile.linux
++++ b/pppd/plugins/Makefile.linux
+@@ -44,5 +44,5 @@ clean:
+ for d in $(SUBDIRS); do $(MAKE) $(MFLAGS) -C $$d clean; done
+
+ depend:
+- $(CPP) -M $(CFLAGS) *.c >.depend
++ $(CC) -M $(CFLAGS) *.c >.depend
+ for d in $(SUBDIRS); do $(MAKE) $(MFLAGS) -C $$d depend; done
diff --git a/patches/ppp-2.4.7/series b/patches/ppp-2.4.7/series
new file mode 100644
index 000000000..16d682fd7
--- /dev/null
+++ b/patches/ppp-2.4.7/series
@@ -0,0 +1,34 @@
+# generated by git-ptx-patches
+#tag:base --start-number 1
+0001-adaptive_echos.patch
+0002-Makefiles-cleanup.patch
+0003-Bug-306261-pppd-does-not-properly-close-dev-ppp-on-p.patch
+0004-Bug-284382-ppp-linkpidfile-is-not-created-upon-detac.patch
+0005-support-building-pppdump-with-the-system-zlib.patch
+0006-disable-unneeded-code-in-the-pppoatm-plugin.patch
+0007-cosmetic-cleanup-of-the-pppoatm-plugin.patch
+0008-pppoe_noads.patch
+0009-make-_PATH_CONNERRS-world-readable.patch
+0010-Correct-unkown-unknown-typo.patch
+0011-pppoe-custom-host-uniq-tag.patch
+0012-scripts_redialer.patch
+0013-Add-replacedefaultroute-option.patch
+0014-ppp-2.3.11-oedod.patch
+0015-add-support-for-the-Framed-MTU-Radius-attribute.patch
+0016-ip-up_option.patch
+0017-ppp-2.4.2-stripMSdomain.patch
+0018-export-CALL_FILE-to-the-link-scripts.patch
+0019-ipv6-accept-remote.patch
+0020-allow-use-of-arbitrary-interface-names.patch
+0021-fix-a-potential-buffer-overflow-in-clientid.c-rc_map.patch
+0022-scripts-README.patch
+0023-no_crypt_hack.patch
+0024-resolv.conf_no_log.patch
+0025-Debian-specific-changes.patch
+0026-secure-card-interpreter-fix.patch
+0027-Fix-buffer-overflow-in-rc_mksid.patch
+0028-Add-a-SONAME-to-the-pppd-binary.patch
+0029-Fix-FTBFS-in-rp-pppoe.patch
+0030-pppd-make-makefile-sysroot-aware.patch
+0031-pppd-make-the-self-made-configure-cross-aware.patch
+# f55804e4f06ed6ed1e5f0e3f1db50b6a - git-ptx-patches magic