Module Name: src
Committed By: martin
Date: Wed Dec 17 19:25:40 UTC 2014
Modified Files:
src/doc [netbsd-7]: 3RDPARTY
src/external/bsd/ppp [netbsd-7]: ppp2netbsd
src/external/bsd/ppp/dist [netbsd-7]: README
src/external/bsd/ppp/dist/pppd [netbsd-7]: chap_ms.c ipcp.c ipv6cp.c
ipv6cp.h options.c patchlevel.h pppd.h tty.c utils.c
src/external/bsd/ppp/dist/pppd/plugins/pppol2tp [netbsd-7]: pppol2tp.c
src/external/bsd/ppp/usr.sbin/pppd [netbsd-7]: sys-bsd.c
Log Message:
Pullup the import of pppd 2.4.7, requested by christos in #331:
* Fixed a potential security issue in parsing option files
(CVE-2014-3158).
* There is a new "stop-bits" option, which takes an argument of
1 or 2, indicating the number of stop bits to use for async
serial ports.
* Various bug fixes.
To generate a diff of this commit:
cvs rdiff -u -r1.1145.2.2 -r1.1145.2.3 src/doc/3RDPARTY
cvs rdiff -u -r1.1 -r1.1.6.1 src/external/bsd/ppp/ppp2netbsd
cvs rdiff -u -r1.1.1.1 -r1.1.1.1.6.1 src/external/bsd/ppp/dist/README
cvs rdiff -u -r1.2 -r1.2.6.1 src/external/bsd/ppp/dist/pppd/chap_ms.c \
src/external/bsd/ppp/dist/pppd/ipcp.c \
src/external/bsd/ppp/dist/pppd/ipv6cp.c \
src/external/bsd/ppp/dist/pppd/ipv6cp.h \
src/external/bsd/ppp/dist/pppd/options.c \
src/external/bsd/ppp/dist/pppd/patchlevel.h \
src/external/bsd/ppp/dist/pppd/pppd.h \
src/external/bsd/ppp/dist/pppd/tty.c \
src/external/bsd/ppp/dist/pppd/utils.c
cvs rdiff -u -r1.1.1.1 -r1.1.1.1.6.1 \
src/external/bsd/ppp/dist/pppd/plugins/pppol2tp/pppol2tp.c
cvs rdiff -u -r1.1 -r1.1.6.1 src/external/bsd/ppp/usr.sbin/pppd/sys-bsd.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/doc/3RDPARTY
diff -u src/doc/3RDPARTY:1.1145.2.2 src/doc/3RDPARTY:1.1145.2.3
--- src/doc/3RDPARTY:1.1145.2.2 Tue Nov 18 18:32:29 2014
+++ src/doc/3RDPARTY Wed Dec 17 19:25:39 2014
@@ -1,4 +1,4 @@
-# $NetBSD: 3RDPARTY,v 1.1145.2.2 2014/11/18 18:32:29 snj Exp $
+# $NetBSD: 3RDPARTY,v 1.1145.2.3 2014/12/17 19:25:39 martin Exp $
#
# This file contains a list of the software that has been integrated into
# NetBSD where we are not the primary maintainer.
@@ -1118,8 +1118,8 @@ directory layout (the easiest way to che
set-permissions'').
Package: ppp
-Version: 2.4.5
-Current Vers: 2.4.6
+Version: 2.4.7
+Current Vers: 2.4.7
Maintainer: Paul Mackerras <[email protected]>
Archive Site: ftp://ftp.samba.org/pub/ppp/
Home Page:
Index: src/external/bsd/ppp/ppp2netbsd
diff -u src/external/bsd/ppp/ppp2netbsd:1.1 src/external/bsd/ppp/ppp2netbsd:1.1.6.1
--- src/external/bsd/ppp/ppp2netbsd:1.1 Thu Nov 28 22:33:42 2013
+++ src/external/bsd/ppp/ppp2netbsd Wed Dec 17 19:25:39 2014
@@ -38,8 +38,7 @@ UNUSED_DIRS="${UNUSED_DIRS} .git"
UNUSED_FILES="Changes-2.3 README.linux README.pppoe README.sol2 configure"
UNUSED_FILES="${UNUSED_FILES} pppd/md[45].* pppd/sha1.* pppd/srp-entry.*"
UNUSED_FILES="${UNUSED_FILES} pppd/sys-linux.c pppd/sys-solaris.c"
-UNUSED_FILES="${UNUSED_FILES} pppdump/zlib.* pppdump/ppp-comp.h .gitignore"
-UNUSED_FILES="${UNUSED_FILES} pppdump/.gitignore pppdump/bsd-comp.c"
+UNUSED_FILES="${UNUSED_FILES} pppdump/zlib.* pppdump/ppp-comp.h"
# Stuff we don't want
GPL_DIRS="pppd/plugins/pppoatm pppd/plugins/radius pppd/plugins/rp-pppoe"
@@ -67,4 +66,10 @@ find . -type f -name 'Makefile*' | while
done
echo; echo
+echo -n "Removing .gitignore... "
+find . -type f -name '.gitignore' | while read m; do
+ rm -f ${m}
+ echo -n "${m} "
+done
+echo; echo
cleantags .
Index: src/external/bsd/ppp/dist/README
diff -u src/external/bsd/ppp/dist/README:1.1.1.1 src/external/bsd/ppp/dist/README:1.1.1.1.6.1
--- src/external/bsd/ppp/dist/README:1.1.1.1 Thu Nov 28 21:53:41 2013
+++ src/external/bsd/ppp/dist/README Wed Dec 17 19:25:39 2014
@@ -61,9 +61,39 @@ use any IP address. (This only applies
authenticating itself to you, of course.)
-What's new in ppp-2.4.5.
+What's new in ppp-2.4.7.
************************
+* Fixed a potential security issue in parsing option files (CVE-2014-3158).
+
+* There is a new "stop-bits" option, which takes an argument of 1 or 2,
+ indicating the number of stop bits to use for async serial ports.
+
+* Various bug fixes.
+
+
+What was new in ppp-2.4.6.
+**************************
+
+* Man page updates.
+
+* Several bug fixes.
+
+* Options files can now set and unset environment variables for
+ scripts.
+
+* The timeout for chat scripts can now be taken from an environment
+ variable.
+
+* There is a new option, master_detach, which allows pppd to detach
+ from the controlling terminal when it is the multilink bundle master
+ but its own link has terminated, even if the nodetach option has
+ been given.
+
+
+What was new in ppp-2.4.5.
+**************************
+
* Under Linux, pppd can now operate in a mode where it doesn't request
the peer's IP address, as some peers refuse to supply an IP address.
Since Linux supports device routes as well as gateway routes, it's
Index: src/external/bsd/ppp/dist/pppd/chap_ms.c
diff -u src/external/bsd/ppp/dist/pppd/chap_ms.c:1.2 src/external/bsd/ppp/dist/pppd/chap_ms.c:1.2.6.1
--- src/external/bsd/ppp/dist/pppd/chap_ms.c:1.2 Thu Nov 28 22:33:42 2013
+++ src/external/bsd/ppp/dist/pppd/chap_ms.c Wed Dec 17 19:25:40 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: chap_ms.c,v 1.2 2013/11/28 22:33:42 christos Exp $ */
+/* $NetBSD: chap_ms.c,v 1.2.6.1 2014/12/17 19:25:40 martin Exp $ */
/*
* chap_ms.c - Microsoft MS-CHAP compatible implementation.
@@ -81,7 +81,7 @@
#define RCSID "Id: chap_ms.c,v 1.38 2007/12/01 20:10:51 carlsonj Exp "
static const char rcsid[] = RCSID;
#else
-__RCSID("$NetBSD: chap_ms.c,v 1.2 2013/11/28 22:33:42 christos Exp $");
+__RCSID("$NetBSD: chap_ms.c,v 1.2.6.1 2014/12/17 19:25:40 martin Exp $");
#endif
#ifdef CHAPMS
@@ -391,7 +391,7 @@ chapms2_make_response(unsigned char *res
unsigned char *private)
{
const struct chapms2_response_cache_entry *cache_entry;
- unsigned char auth_response[MS_AUTH_RESPONSE_LENGTH];
+ unsigned char auth_response[MS_AUTH_RESPONSE_LENGTH+1];
challenge++; /* skip length, should be 16 */
*response++ = MS_CHAP2_RESPONSE_LEN;
Index: src/external/bsd/ppp/dist/pppd/ipcp.c
diff -u src/external/bsd/ppp/dist/pppd/ipcp.c:1.2 src/external/bsd/ppp/dist/pppd/ipcp.c:1.2.6.1
--- src/external/bsd/ppp/dist/pppd/ipcp.c:1.2 Thu Nov 28 22:33:42 2013
+++ src/external/bsd/ppp/dist/pppd/ipcp.c Wed Dec 17 19:25:40 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: ipcp.c,v 1.2 2013/11/28 22:33:42 christos Exp $ */
+/* $NetBSD: ipcp.c,v 1.2.6.1 2014/12/17 19:25:40 martin Exp $ */
/*
* ipcp.c - PPP IP Control Protocol.
@@ -47,7 +47,7 @@
#define RCSID "Id: ipcp.c,v 1.73 2008/05/26 08:33:22 paulus Exp "
static const char rcsid[] = RCSID;
#else
-__RCSID("$NetBSD: ipcp.c,v 1.2 2013/11/28 22:33:42 christos Exp $");
+__RCSID("$NetBSD: ipcp.c,v 1.2.6.1 2014/12/17 19:25:40 martin Exp $");
#endif
/*
@@ -969,6 +969,21 @@ ipcp_ackci(f, p, len)
goto bad; \
}
+#define ACKCIWINS(opt, addr) \
+ if (addr) { \
+ u_int32_t l; \
+ if ((len -= CILEN_ADDR) < 0) \
+ goto bad; \
+ GETCHAR(citype, p); \
+ GETCHAR(cilen, p); \
+ if (cilen != CILEN_ADDR || citype != opt) \
+ goto bad; \
+ GETLONG(l, p); \
+ cilong = htonl(l); \
+ if (addr != cilong) \
+ goto bad; \
+ }
+
ACKCIADDRS(CI_ADDRS, !go->neg_addr && go->old_addrs, go->ouraddr,
go->hisaddr);
@@ -981,6 +996,10 @@ ipcp_ackci(f, p, len)
ACKCIDNS(CI_MS_DNS2, go->req_dns2, go->dnsaddr[1]);
+ ACKCIWINS(CI_MS_WINS1, go->winsaddr[0]);
+
+ ACKCIWINS(CI_MS_WINS2, go->winsaddr[1]);
+
/*
* If there are any remaining CIs, then this packet is bad.
*/
Index: src/external/bsd/ppp/dist/pppd/ipv6cp.c
diff -u src/external/bsd/ppp/dist/pppd/ipv6cp.c:1.2 src/external/bsd/ppp/dist/pppd/ipv6cp.c:1.2.6.1
--- src/external/bsd/ppp/dist/pppd/ipv6cp.c:1.2 Thu Nov 28 22:33:42 2013
+++ src/external/bsd/ppp/dist/pppd/ipv6cp.c Wed Dec 17 19:25:40 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: ipv6cp.c,v 1.2 2013/11/28 22:33:42 christos Exp $ */
+/* $NetBSD: ipv6cp.c,v 1.2.6.1 2014/12/17 19:25:40 martin Exp $ */
/*
* ipv6cp.c - PPP IPV6 Control Protocol.
@@ -145,7 +145,7 @@
#define RCSID "Id: ipv6cp.c,v 1.21 2005/08/25 23:59:34 paulus Exp "
static const char rcsid[] = RCSID;
#else
-__RCSID("$NetBSD: ipv6cp.c,v 1.2 2013/11/28 22:33:42 christos Exp $");
+__RCSID("$NetBSD: ipv6cp.c,v 1.2.6.1 2014/12/17 19:25:40 martin Exp $");
#endif
/*
@@ -257,10 +257,8 @@ static option_t ipv6cp_option_list[] = {
{ "ipv6cp-use-ipaddr", o_bool, &ipv6cp_allowoptions[0].use_ip,
"Use (default) IPv4 address as interface identifier", 1 },
-#if defined(SOL2) || defined(__linux__)
{ "ipv6cp-use-persistent", o_bool, &ipv6cp_wantoptions[0].use_persistent,
"Use uniquely-available persistent value for link local address", 1 },
-#endif /* defined(SOL2) */
{ "ipv6cp-restart", o_int, &ipv6cp_fsm[0].timeouttime,
"Set timeout for IPv6CP", OPT_PRIO },
@@ -1096,7 +1094,6 @@ ipv6_check_options()
if (!ipv6cp_protent.enabled_flag)
return;
-#if defined(SOL2) || defined(__linux__)
/*
* Persistent link-local id is only used when user has not explicitly
* configure/hard-code the id
@@ -1116,7 +1113,6 @@ ipv6_check_options()
wo->opt_local = 1;
}
}
-#endif
if (!wo->opt_local) { /* init interface identifier */
if (wo->use_ip && eui64_iszero(wo->ourid)) {
@@ -1154,15 +1150,8 @@ ipv6_demand_conf(u)
{
ipv6cp_options *wo = &ipv6cp_wantoptions[u];
-#if defined(__linux__) || defined(SOL2) || (defined(SVR4) && (defined(SNI) || defined(__USLC__)))
-#if defined(SOL2)
if (!sif6up(u))
return 0;
-#else
- if (!sifup(u))
- return 0;
-#endif /* defined(SOL2) */
-#endif
if (!sif6addr(u, wo->ourid, wo->hisid))
return 0;
#if !defined(__linux__) && !(defined(SVR4) && (defined(SNI) || defined(__USLC__)))
@@ -1255,43 +1244,20 @@ ipv6cp_up(f)
sifnpmode(f->unit, PPP_IPV6, NPMODE_PASS);
} else {
- /*
- * Set LL addresses
- */
-#if !defined(__linux__) && !defined(SOL2) && !(defined(SVR4) && (defined(SNI) || defined(__USLC__)))
- if (!sif6addr(f->unit, go->ourid, ho->hisid)) {
- if (debug)
- warn("sif6addr failed");
- ipv6cp_close(f->unit, "Interface configuration failed");
- return;
- }
-#endif
-
/* bring the interface up for IPv6 */
-#if defined(SOL2)
if (!sif6up(f->unit)) {
if (debug)
- warn("sifup failed (IPV6)");
+ warn("sif6up failed (IPV6)");
ipv6cp_close(f->unit, "Interface configuration failed");
return;
}
-#else
- if (!sifup(f->unit)) {
- if (debug)
- warn("sifup failed (IPV6)");
- ipv6cp_close(f->unit, "Interface configuration failed");
- return;
- }
-#endif /* defined(SOL2) */
-#if defined(__linux__) || defined(SOL2) || (defined(SVR4) && (defined(SNI) || defined(__USLC__)))
if (!sif6addr(f->unit, go->ourid, ho->hisid)) {
if (debug)
warn("sif6addr failed");
ipv6cp_close(f->unit, "Interface configuration failed");
return;
}
-#endif
sifnpmode(f->unit, PPP_IPV6, NPMODE_PASS);
notice("local LL address %s", llv6_ntoa(go->ourid));
@@ -1348,16 +1314,14 @@ ipv6cp_down(f)
} else {
sifnpmode(f->unit, PPP_IPV6, NPMODE_DROP);
#if !defined(__linux__) && !(defined(SVR4) && (defined(SNI) || defined(__USLC)))
-#if defined(SOL2)
sif6down(f->unit);
-#else
- sifdown(f->unit);
-#endif /* defined(SOL2) */
#endif
ipv6cp_clear_addrs(f->unit,
ipv6cp_gotoptions[f->unit].ourid,
ipv6cp_hisoptions[f->unit].hisid);
-#if defined(__linux__) || (defined(SVR4) && (defined(SNI) || defined(__USLC)))
+#if defined(__linux__)
+ sif6down(f->unit);
+#elif defined(SVR4) && (defined(SNI) || defined(__USLC))
sifdown(f->unit);
#endif
}
Index: src/external/bsd/ppp/dist/pppd/ipv6cp.h
diff -u src/external/bsd/ppp/dist/pppd/ipv6cp.h:1.2 src/external/bsd/ppp/dist/pppd/ipv6cp.h:1.2.6.1
--- src/external/bsd/ppp/dist/pppd/ipv6cp.h:1.2 Thu Nov 28 22:33:42 2013
+++ src/external/bsd/ppp/dist/pppd/ipv6cp.h Wed Dec 17 19:25:40 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: ipv6cp.h,v 1.2 2013/11/28 22:33:42 christos Exp $ */
+/* $NetBSD: ipv6cp.h,v 1.2.6.1 2014/12/17 19:25:40 martin Exp $ */
/*
* ipv6cp.h - PPP IPV6 Control Protocol.
@@ -156,9 +156,7 @@ typedef struct ipv6cp_options {
int opt_local; /* ourtoken set by option */
int opt_remote; /* histoken set by option */
int use_ip; /* use IP as interface identifier */
-#if defined(SOL2) || defined(__linux__)
int use_persistent; /* use uniquely persistent value for address */
-#endif /* defined(SOL2) */
int neg_vj; /* Van Jacobson Compression? */
u_short vj_protocol; /* protocol value to use in VJ option */
eui64_t ourid, hisid; /* Interface identifiers */
Index: src/external/bsd/ppp/dist/pppd/options.c
diff -u src/external/bsd/ppp/dist/pppd/options.c:1.2 src/external/bsd/ppp/dist/pppd/options.c:1.2.6.1
--- src/external/bsd/ppp/dist/pppd/options.c:1.2 Thu Nov 28 22:33:42 2013
+++ src/external/bsd/ppp/dist/pppd/options.c Wed Dec 17 19:25:40 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: options.c,v 1.2 2013/11/28 22:33:42 christos Exp $ */
+/* $NetBSD: options.c,v 1.2.6.1 2014/12/17 19:25:40 martin Exp $ */
/*
* options.c - handles option processing for PPP.
@@ -47,7 +47,7 @@
#define RCSID "Id: options.c,v 1.102 2008/06/15 06:53:06 paulus Exp "
static const char rcsid[] = RCSID;
#else
-__RCSID("$NetBSD: options.c,v 1.2 2013/11/28 22:33:42 christos Exp $");
+__RCSID("$NetBSD: options.c,v 1.2.6.1 2014/12/17 19:25:40 martin Exp $");
#endif
#include <ctype.h>
@@ -792,10 +792,13 @@ process_option(opt, cmd, argv)
if (opt->flags & OPT_STATIC) {
strlcpy((char *)(opt->addr), *argv, opt->upper_limit);
} else {
+ char **optptr = (char **)(opt->addr);
sv = strdup(*argv);
if (sv == NULL)
novm("option argument");
- *(char **)(opt->addr) = sv;
+ if (*optptr)
+ free(*optptr);
+ *optptr = sv;
}
break;
@@ -1299,9 +1302,10 @@ getword(f, word, newlinep, filename)
/*
* Store the resulting character for the escape sequence.
*/
- if (len < MAXWORDLEN-1)
+ if (len < MAXWORDLEN) {
word[len] = value;
- ++len;
+ ++len;
+ }
if (!got)
c = getc(f);
@@ -1339,9 +1343,10 @@ getword(f, word, newlinep, filename)
/*
* An ordinary character: store it in the word and get another.
*/
- if (len < MAXWORDLEN-1)
+ if (len < MAXWORDLEN) {
word[len] = c;
- ++len;
+ ++len;
+ }
c = getc(f);
}
Index: src/external/bsd/ppp/dist/pppd/patchlevel.h
diff -u src/external/bsd/ppp/dist/pppd/patchlevel.h:1.2 src/external/bsd/ppp/dist/pppd/patchlevel.h:1.2.6.1
--- src/external/bsd/ppp/dist/pppd/patchlevel.h:1.2 Thu Nov 28 22:33:42 2013
+++ src/external/bsd/ppp/dist/pppd/patchlevel.h Wed Dec 17 19:25:40 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: patchlevel.h,v 1.2 2013/11/28 22:33:42 christos Exp $ */
+/* $NetBSD: patchlevel.h,v 1.2.6.1 2014/12/17 19:25:40 martin Exp $ */
-#define VERSION "2.4.5"
-#define DATE "17 November 2009"
+#define VERSION "2.4.7"
+#define DATE "9 August 2014"
Index: src/external/bsd/ppp/dist/pppd/pppd.h
diff -u src/external/bsd/ppp/dist/pppd/pppd.h:1.2 src/external/bsd/ppp/dist/pppd/pppd.h:1.2.6.1
--- src/external/bsd/ppp/dist/pppd/pppd.h:1.2 Thu Nov 28 22:33:42 2013
+++ src/external/bsd/ppp/dist/pppd/pppd.h Wed Dec 17 19:25:40 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: pppd.h,v 1.2 2013/11/28 22:33:42 christos Exp $ */
+/* $NetBSD: pppd.h,v 1.2.6.1 2014/12/17 19:25:40 martin Exp $ */
/*
* pppd.h - PPP daemon global declarations.
@@ -280,6 +280,7 @@ extern int kdebugflag; /* Tell kernel to
extern int default_device; /* Using /dev/tty or equivalent */
extern char devnam[MAXPATHLEN]; /* Device name */
extern int crtscts; /* Use hardware flow control */
+extern int stop_bits; /* Number of serial port stop bits */
extern bool modem; /* Use modem control lines */
extern int inspeed; /* Input/Output speed requested */
extern u_int32_t netmask; /* IP netmask to set on interface */
@@ -663,6 +664,8 @@ int cifaddr __P((int, u_int32_t, u_int3
/* Reset i/f IP addresses */
#ifdef INET6
int ether_to_eui64(eui64_t *p_eui64); /* convert eth0 hw address to EUI64 */
+int sif6up __P((int)); /* Configure i/f up for IPv6 */
+int sif6down __P((int)); /* Configure i/f down for IPv6 */
int sif6addr __P((int, eui64_t, eui64_t));
/* Configure IPv6 addresses for i/f */
int cif6addr __P((int, eui64_t, eui64_t));
Index: src/external/bsd/ppp/dist/pppd/tty.c
diff -u src/external/bsd/ppp/dist/pppd/tty.c:1.2 src/external/bsd/ppp/dist/pppd/tty.c:1.2.6.1
--- src/external/bsd/ppp/dist/pppd/tty.c:1.2 Thu Nov 28 22:33:42 2013
+++ src/external/bsd/ppp/dist/pppd/tty.c Wed Dec 17 19:25:40 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: tty.c,v 1.2 2013/11/28 22:33:42 christos Exp $ */
+/* $NetBSD: tty.c,v 1.2.6.1 2014/12/17 19:25:40 martin Exp $ */
/*
* tty.c - code for handling serial ports in pppd.
@@ -75,7 +75,7 @@
#define RCSID "Id: tty.c,v 1.27 2008/07/01 12:27:56 paulus Exp "
static const char rcsid[] = RCSID;
#else
-__RCSID("$NetBSD: tty.c,v 1.2 2013/11/28 22:33:42 christos Exp $");
+__RCSID("$NetBSD: tty.c,v 1.2.6.1 2014/12/17 19:25:40 martin Exp $");
#endif
#include <stdio.h>
@@ -144,6 +144,7 @@ struct stat devstat; /* result of stat(
/* option variables */
int crtscts = 0; /* Use hardware flow control */
+int stop_bits = 1; /* Number of serial port stop bits */
bool modem = 1; /* Use modem control lines */
int inspeed = 0; /* Input/Output speed requested */
bool lockflag = 0; /* Create lock file to lock the serial dev */
@@ -229,6 +230,9 @@ option_t tty_options[] = {
OPT_PRIOSUB | OPT_ALIAS | OPT_NOARG | OPT_VAL(-1) },
{ "xonxoff", o_special_noarg, (void *)setxonxoff,
"Set software (XON/XOFF) flow control", OPT_PRIOSUB },
+ { "stop-bits", o_int, &stop_bits,
+ "Number of stop bits in serial port",
+ OPT_PRIO | OPT_PRIVFIX | OPT_LIMITS, NULL, 2, 1 },
{ "modem", o_bool, &modem,
"Use modem control lines", OPT_PRIO | 1 },
Index: src/external/bsd/ppp/dist/pppd/utils.c
diff -u src/external/bsd/ppp/dist/pppd/utils.c:1.2 src/external/bsd/ppp/dist/pppd/utils.c:1.2.6.1
--- src/external/bsd/ppp/dist/pppd/utils.c:1.2 Thu Nov 28 22:33:42 2013
+++ src/external/bsd/ppp/dist/pppd/utils.c Wed Dec 17 19:25:40 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: utils.c,v 1.2 2013/11/28 22:33:42 christos Exp $ */
+/* $NetBSD: utils.c,v 1.2.6.1 2014/12/17 19:25:40 martin Exp $ */
/*
* utils.c - various utility functions used in pppd.
@@ -35,7 +35,7 @@
#define RCSID "Id: utils.c,v 1.25 2008/06/03 12:06:37 paulus Exp "
static const char rcsid[] = RCSID;
#else
-__RCSID("$NetBSD: utils.c,v 1.2 2013/11/28 22:33:42 christos Exp $");
+__RCSID("$NetBSD: utils.c,v 1.2.6.1 2014/12/17 19:25:40 martin Exp $");
#endif
#include <stdio.h>
@@ -268,6 +268,8 @@ vslprintf(buf, buflen, fmt, args)
case 'q': /* quoted string */
quoted = c == 'q';
p = va_arg(args, unsigned char *);
+ if (p == NULL)
+ p = (unsigned char *)"<NULL>";
if (fillch == '0' && prec >= 0) {
n = prec;
} else {
Index: src/external/bsd/ppp/dist/pppd/plugins/pppol2tp/pppol2tp.c
diff -u src/external/bsd/ppp/dist/pppd/plugins/pppol2tp/pppol2tp.c:1.1.1.1 src/external/bsd/ppp/dist/pppd/plugins/pppol2tp/pppol2tp.c:1.1.1.1.6.1
--- src/external/bsd/ppp/dist/pppd/plugins/pppol2tp/pppol2tp.c:1.1.1.1 Thu Nov 28 21:53:45 2013
+++ src/external/bsd/ppp/dist/pppd/plugins/pppol2tp/pppol2tp.c Wed Dec 17 19:25:40 2014
@@ -74,8 +74,6 @@ struct channel pppol2tp_channel;
static void (*old_snoop_recv_hook)(unsigned char *p, int len) = NULL;
static void (*old_snoop_send_hook)(unsigned char *p, int len) = NULL;
-static void (*old_ip_up_hook)(void) = NULL;
-static void (*old_ip_down_hook)(void) = NULL;
/* Hook provided to allow other plugins to handle ACCM changes */
void (*pppol2tp_send_accm_hook)(int tunnel_id, int session_id,
@@ -436,22 +434,18 @@ static void pppol2tp_lcp_snoop_send(unsi
* Interface up/down events
*****************************************************************************/
-static void pppol2tp_ip_up_hook(void)
+static void pppol2tp_ip_up(void *opaque, int arg)
{
- if (old_ip_up_hook != NULL)
- (*old_ip_up_hook)();
-
+ /* may get called twice (for IPv4 and IPv6) but the hook handles that well */
if (pppol2tp_ip_updown_hook != NULL) {
(*pppol2tp_ip_updown_hook)(pppol2tp_tunnel_id,
pppol2tp_session_id, 1);
}
}
-static void pppol2tp_ip_down_hook(void)
+static void pppol2tp_ip_down(void *opaque, int arg)
{
- if (old_ip_down_hook != NULL)
- (*old_ip_down_hook)();
-
+ /* may get called twice (for IPv4 and IPv6) but the hook handles that well */
if (pppol2tp_ip_updown_hook != NULL) {
(*pppol2tp_ip_updown_hook)(pppol2tp_tunnel_id,
pppol2tp_session_id, 0);
@@ -478,14 +472,6 @@ static void pppol2tp_check_options(void)
snoop_recv_hook = pppol2tp_lcp_snoop_recv;
snoop_send_hook = pppol2tp_lcp_snoop_send;
}
-
- /* Hook up ip up/down hooks to send indicator to openl2tpd
- * that the link is up
- */
- old_ip_up_hook = ip_up_hook;
- ip_up_hook = pppol2tp_ip_up_hook;
- old_ip_down_hook = ip_down_hook;
- ip_down_hook = pppol2tp_ip_down_hook;
}
/* Called just before pppd exits.
@@ -509,6 +495,14 @@ void plugin_init(void)
fatal("No PPPoL2TP support on this OS");
#endif
add_options(pppol2tp_options);
+
+ /* Hook up ip up/down notifiers to send indicator to openl2tpd
+ * that the link is up
+ */
+ add_notifier(&ip_up_notifier, pppol2tp_ip_up, NULL);
+ add_notifier(&ip_down_notifier, pppol2tp_ip_down, NULL);
+ add_notifier(&ipv6_up_notifier, pppol2tp_ip_up, NULL);
+ add_notifier(&ipv6_down_notifier, pppol2tp_ip_down, NULL);
}
struct channel pppol2tp_channel = {
Index: src/external/bsd/ppp/usr.sbin/pppd/sys-bsd.c
diff -u src/external/bsd/ppp/usr.sbin/pppd/sys-bsd.c:1.1 src/external/bsd/ppp/usr.sbin/pppd/sys-bsd.c:1.1.6.1
--- src/external/bsd/ppp/usr.sbin/pppd/sys-bsd.c:1.1 Thu Nov 28 22:33:43 2013
+++ src/external/bsd/ppp/usr.sbin/pppd/sys-bsd.c Wed Dec 17 19:25:40 2014
@@ -189,6 +189,7 @@ static fd_set in_fds; /* set of fds tha
static int max_in_fd; /* highest fd set in in_fds */
static int if_is_up; /* the interface is currently up */
+static int if6_is_up; /* the interface is currently up */
static u_int32_t ifaddrs[2]; /* local and remote addresses we set */
static u_int32_t default_route_gateway; /* gateway addr for default route */
static u_int32_t proxy_arp_addr; /* remote addr for proxy arp */
@@ -199,6 +200,7 @@ static void set_flags(int, int);
static int dodefaultroute(u_int32_t, int);
static int get_ether_addr(u_int32_t, struct sockaddr_dl *);
static void restore_loop(void); /* Transfer ppp unit back to loopback */
+static int setifstate(int, int);
static void
@@ -1400,11 +1402,79 @@ sifvjcomp(int u, int vjcomp, int cidcomp
return 1;
}
-/*
+/********************************************************************
+ *
* sifup - Config the interface up and enable IP packets to pass.
*/
-int
-sifup(int u)
+
+int sifup(int u)
+{
+ int ret;
+
+ if ((ret = setifstate(u, 1)))
+ if_is_up++;
+
+ return ret;
+}
+
+/********************************************************************
+ *
+ * sifdown - Disable the indicated protocol and config the interface
+ * down if there are no remaining protocols.
+ */
+
+int sifdown (int u)
+{
+ if (if_is_up && --if_is_up > 0)
+ return 1;
+
+#ifdef INET6
+ if (if6_is_up)
+ return 1;
+#endif /* INET6 */
+
+ return setifstate(u, 0);
+}
+
+#ifdef INET6
+/********************************************************************
+ *
+ * sif6up - Config the interface up for IPv6
+ */
+
+int sif6up(int u)
+{
+ int ret;
+
+ if ((ret = setifstate(u, 1)))
+ if6_is_up = 1;
+
+ return ret;
+}
+
+/********************************************************************
+ *
+ * sif6down - Disable the IPv6CP protocol and config the interface
+ * down if there are no remaining protocols.
+ */
+
+int sif6down (int u)
+{
+ if6_is_up = 0;
+
+ if (if_is_up)
+ return 1;
+
+ return setifstate(u, 0);
+}
+#endif /* INET6 */
+
+/********************************************************************
+ *
+ * setifstate - Config the interface up or down
+ */
+
+static int setifstate (int u, int state)
{
struct ifreq ifr;
@@ -1413,7 +1483,10 @@ sifup(int u)
error("%s: ioctl (SIOCGIFFLAGS): %m", __func__);
return 0;
}
- ifr.ifr_flags |= IFF_UP;
+ if (state)
+ ifr.ifr_flags |= IFF_UP;
+ else
+ ifr.ifr_flags &= ~IFF_UP;
if (ioctl(sock_fd, SIOCSIFFLAGS, (caddr_t) &ifr) < 0) {
error("%s: ioctl(SIOCSIFFLAGS): %m", __func__);
return 0;
@@ -1440,37 +1513,6 @@ sifnpmode(int u, int proto, enum NPmode
}
/*
- * sifdown - Config the interface down and disable IP.
- */
-int
-sifdown(int u)
-{
- struct ifreq ifr;
- int rv;
- struct npioctl npi;
-
- rv = 1;
- npi.protocol = PPP_IP;
- npi.mode = NPMODE_ERROR;
- ioctl(ppp_fd, PPPIOCSNPMODE, (caddr_t) &npi);
- /* ignore errors, because ppp_fd might have been closed by now. */
-
- strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
- if (ioctl(sock_fd, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) {
- error("%s: ioctl (SIOCGIFFLAGS): %m", __func__);
- rv = 0;
- } else {
- ifr.ifr_flags &= ~IFF_UP;
- if (ioctl(sock_fd, SIOCSIFFLAGS, (caddr_t) &ifr) < 0) {
- error("%s: ioctl(SIOCSIFFLAGS): %m", __func__);
- rv = 0;
- } else
- if_is_up = 0;
- }
- return rv;
-}
-
-/*
* SET_SA_FAMILY - set the sa_family field of a struct sockaddr,
* if it exists.
*/
@@ -2069,3 +2111,54 @@ unlock(void)
}
}
#endif
+
+#ifdef INET6
+/*
+ * ether_to_eui64 - Convert 48-bit Ethernet address into 64-bit EUI
+ *
+ * convert the 48-bit MAC address of eth0 into EUI 64. caller also assumes
+ * that the system has a properly configured Ethernet interface for this
+ * function to return non-zero.
+ */
+int
+ether_to_eui64(eui64_t *p_eui64)
+{
+ struct ifaddrs *ifap, *ifa;
+
+ if (getifaddrs(&ifap) != 0) {
+ warn("%s: getifaddrs: %m", __func__);
+ return 0;
+ }
+ for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
+ /*
+ * Check the interface's internet address.
+ */
+ if (ifa->ifa_addr->sa_family != AF_LINK)
+ continue;
+ /*
+ * Check that the interface is up, and not point-to-point or loopback.
+ */
+ if ((ifa->ifa_flags & (IFF_UP|IFF_POINTOPOINT|IFF_LOOPBACK)) == IFF_UP)
+ {
+ /*
+ * And convert the EUI-48 into EUI-64, per RFC 2472 [sec 4.1]
+ */
+ unsigned char *ptr = (void *)ifa->ifa_addr;
+ p_eui64->e8[0] = ptr[0] | 0x02;
+ p_eui64->e8[1] = ptr[1];
+ p_eui64->e8[2] = ptr[2];
+ p_eui64->e8[3] = 0xFF;
+ p_eui64->e8[4] = 0xFE;
+ p_eui64->e8[5] = ptr[3];
+ p_eui64->e8[6] = ptr[4];
+ p_eui64->e8[7] = ptr[5];
+ freeifaddrs(ifap);
+ return 1;
+ }
+ }
+ warn("%s: can't find a link address", __func__);
+ freeifaddrs(ifap);
+
+ return 0;
+}
+#endif