ppp: update

This commit is contained in:
CN_SZTL 2019-12-06 13:21:22 +08:00
parent de202f9e20
commit bbbd9d231f
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
39 changed files with 958 additions and 266 deletions

View File

@ -74,7 +74,7 @@ ppp_generic_init_config() {
proto_config_add_string pppd_options
proto_config_add_string 'connect:file'
proto_config_add_string 'disconnect:file'
[ -e /proc/sys/net/ipv6 ] && proto_config_add_string ipv6
proto_config_add_string ipv6
proto_config_add_boolean authfail
proto_config_add_int mtu
proto_config_add_string pppname
@ -88,10 +88,7 @@ ppp_generic_setup() {
local config="$1"; shift
local localip
json_get_vars ip6table demand keepalive keepalive_adaptive username password pppd_options pppname unnumbered persist maxfail holdoff peerdns
[ ! -e /proc/sys/net/ipv6 ] && ipv6=0 || json_get_var ipv6 ipv6
json_get_vars ipv6 ip6table demand keepalive keepalive_adaptive username password pppd_options pppname unnumbered persist maxfail holdoff peerdns
if [ "$ipv6" = 0 ]; then
ipv6=""
elif [ -z "$ipv6" -o "$ipv6" = auto ]; then
@ -151,9 +148,9 @@ ppp_generic_setup() {
${connect:+connect "$connect"} \
${disconnect:+disconnect "$disconnect"} \
ip-up-script /lib/netifd/ppp-up \
${ipv6:+ipv6-up-script /lib/netifd/ppp6-up} \
ipv6-up-script /lib/netifd/ppp6-up \
ip-down-script /lib/netifd/ppp-down \
${ipv6:+ipv6-down-script /lib/netifd/ppp-down} \
ipv6-down-script /lib/netifd/ppp-down \
${mtu:+mtu $mtu mru $mtu} \
"$@" $pppd_options
}
@ -210,9 +207,6 @@ proto_pppoe_init_config() {
proto_config_add_string "ac"
proto_config_add_string "service"
proto_config_add_string "host_uniq"
proto_config_add_int "padi_attempts"
proto_config_add_int "padi_timeout"
lasterror=1
}
@ -230,16 +224,20 @@ proto_pppoe_setup() {
json_get_var ac ac
json_get_var service service
json_get_var host_uniq host_uniq
json_get_var padi_attempts padi_attempts
json_get_var padi_timeout padi_timeout
ppp_generic_setup "$config" \
#By 蝈蝈:并发拨号同步的前期准备
syncppp_option=""
[ "$(uci get syncdial.config.enabled)" == "1" ] && {
ppp_if_cnt=$(cat /etc/config/network | grep -c "proto 'pppoe'")
syncppp_option="syncppp $ppp_if_cnt"
shellsync $ppp_if_cnt 10
}
ppp_generic_setup "$config" \
$syncppp_option \
plugin rp-pppoe.so \
${ac:+rp_pppoe_ac "$ac"} \
${service:+rp_pppoe_service "$service"} \
${host_uniq:+host-uniq "$host_uniq"} \
${padi_attempts:+pppoe-padi-attempts $padi_attempts} \
${padi_timeout:+pppoe-padi-timeout $padi_timeout} \
"nic-$iface"
}

View File

@ -0,0 +1,39 @@
--- a/pppd/plugins/radius/Makefile.linux
+++ b/pppd/plugins/radius/Makefile.linux
@@ -43,13 +43,13 @@ install: all
$(INSTALL) -c -m 444 pppd-radattr.8 $(MANDIR)
radius.so: radius.o libradiusclient.a
- $(CC) -o radius.so -shared radius.o libradiusclient.a
+ $(CC) $(CFLAGS) -o radius.so -shared radius.o libradiusclient.a
radattr.so: radattr.o
- $(CC) -o radattr.so -shared radattr.o
+ $(CC) $(CFLAGS) -o radattr.so -shared radattr.o
radrealms.so: radrealms.o
- $(CC) -o radrealms.so -shared radrealms.o
+ $(CC) $(CFLAGS) -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
--- a/pppd/plugins/rp-pppoe/Makefile.linux
+++ b/pppd/plugins/rp-pppoe/Makefile.linux
@@ -30,7 +30,7 @@ CFLAGS=$(COPTS) -I../../../include '-DRP
all: rp-pppoe.so pppoe-discovery
pppoe-discovery: pppoe-discovery.o debug.o
- $(CC) -o pppoe-discovery pppoe-discovery.o debug.o
+ $(CC) $(CFLAGS) -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,7 +39,7 @@ 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) $(CFLAGS) -o rp-pppoe.so -shared plugin.o discovery.o if.o common.o
install: all
$(INSTALL) -d -m 755 $(LIBDIR)

View File

@ -12,7 +12,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
--- a/pppd/ipcp.c
+++ b/pppd/ipcp.c
@@ -1957,7 +1957,7 @@ ipcp_up(f)
@@ -1958,7 +1958,7 @@ ipcp_up(f)
*/
if (ipcp_script_state == s_down && ipcp_script_pid == 0) {
ipcp_script_state = s_up;
@ -21,7 +21,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
}
}
@@ -2007,7 +2007,7 @@ ipcp_down(f)
@@ -2008,7 +2008,7 @@ ipcp_down(f)
/* Execute the ip-down script */
if (ipcp_script_state == s_up && ipcp_script_pid == 0) {
ipcp_script_state = s_down;
@ -30,7 +30,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
}
}
@@ -2061,13 +2061,13 @@ ipcp_script_done(arg)
@@ -2062,13 +2062,13 @@ ipcp_script_done(arg)
case s_up:
if (ipcp_fsm[0].state != OPENED) {
ipcp_script_state = s_down;
@ -48,7 +48,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
}
--- a/pppd/main.c
+++ b/pppd/main.c
@@ -306,6 +306,9 @@ main(argc, argv)
@@ -316,6 +316,9 @@ main(argc, argv)
struct protent *protp;
char numbuf[16];
@ -60,18 +60,18 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
--- a/pppd/options.c
+++ b/pppd/options.c
@@ -117,6 +117,8 @@ bool tune_kernel; /* may alter kernel s
@@ -114,6 +114,8 @@ char linkname[MAXPATHLEN]; /* logical na
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 req_ifname[MAXIFNAMELEN]; /* requested interface name */
+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 */
@@ -316,6 +318,13 @@ option_t general_options[] = {
"Metric to use for the default route (Linux only; -1 for default behavior)",
OPT_PRIV|OPT_LLIMIT|OPT_INITONLY, NULL, 0, -1 },
@@ -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",
@ -85,10 +85,10 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
"Enable multilink operation", OPT_PRIO | 1 },
--- a/pppd/pppd.h
+++ b/pppd/pppd.h
@@ -332,6 +332,8 @@ extern int connect_delay; /* Time to del
@@ -318,6 +318,8 @@ extern bool tune_kernel; /* May alter ke
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 req_ifname[MAXIFNAMELEN]; /* interface name 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 */

View File

@ -12,7 +12,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
--- a/pppd/sys-linux.c
+++ b/pppd/sys-linux.c
@@ -460,6 +460,13 @@ int generic_establish_ppp (int fd)
@@ -458,6 +458,13 @@ int generic_establish_ppp (int fd)
if (new_style_driver) {
int flags;

View File

@ -11,7 +11,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
--- a/pppd/main.c
+++ b/pppd/main.c
@@ -776,8 +776,7 @@ detach()
@@ -773,8 +773,7 @@ detach()
/* update pid files if they have been written already */
if (pidfilename[0])
create_pidfile(pid);

View File

@ -18,7 +18,7 @@
#ifdef PPP_FILTER
#include <pcap-bpf.h>
#endif
@@ -220,6 +224,14 @@ loop_chars(p, n)
@@ -221,6 +225,14 @@ loop_chars(p, n)
int c, rv;
rv = 0;
@ -33,7 +33,7 @@
for (; n > 0; --n) {
c = *p++;
if (c == PPP_FLAG) {
@@ -298,17 +310,102 @@ loop_frame(frame, len)
@@ -299,17 +311,102 @@ loop_frame(frame, len)
* loopback, now that the real serial link is up.
*/
void
@ -139,7 +139,7 @@
} else {
--- a/pppd/ipcp.c
+++ b/pppd/ipcp.c
@@ -1882,7 +1882,7 @@ ipcp_up(f)
@@ -1883,7 +1883,7 @@ ipcp_up(f)
proxy_arp_set[f->unit] = 1;
}
@ -150,7 +150,7 @@
} else {
--- a/pppd/ipv6cp.c
+++ b/pppd/ipv6cp.c
@@ -1231,7 +1231,7 @@ ipv6cp_up(f)
@@ -1232,7 +1232,7 @@ ipv6cp_up(f)
}
}
@ -161,7 +161,7 @@
} else {
--- a/pppd/pppd.h
+++ b/pppd/pppd.h
@@ -599,7 +599,7 @@ void demand_conf __P((void)); /* config
@@ -585,7 +585,7 @@ void demand_conf __P((void)); /* config
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 */

View File

@ -12,7 +12,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
--- a/pppd/ipcp.c
+++ b/pppd/ipcp.c
@@ -197,6 +197,14 @@ static option_t ipcp_option_list[] = {
@@ -198,6 +198,14 @@ static option_t ipcp_option_list[] = {
"disable defaultroute option", OPT_ALIAS | OPT_A2CLR,
&ipcp_wantoptions[0].default_route },
@ -27,7 +27,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
{ "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,
@@ -270,7 +278,7 @@ struct protent ipcp_protent = {
@@ -271,7 +279,7 @@ struct protent ipcp_protent = {
ip_active_pkt
};
@ -36,7 +36,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
static void ipcp_script __P((char *, int)); /* Run an up/down script */
static void ipcp_script_done __P((void *));
@@ -1760,7 +1768,8 @@ ip_demand_conf(u)
@@ -1761,7 +1769,8 @@ ip_demand_conf(u)
if (!sifnpmode(u, PPP_IP, NPMODE_QUEUE))
return 0;
if (wo->default_route)
@ -46,7 +46,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
default_route_set[u] = 1;
if (wo->proxy_arp)
if (sifproxyarp(u, wo->hisaddr))
@@ -1848,7 +1857,8 @@ ipcp_up(f)
@@ -1849,7 +1858,8 @@ ipcp_up(f)
*/
if (demand) {
if (go->ouraddr != wo->ouraddr || ho->hisaddr != wo->hisaddr) {
@ -56,7 +56,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
if (go->ouraddr != wo->ouraddr) {
warn("Local IP address changed to %I", go->ouraddr);
script_setenv("OLDIPLOCAL", ip_ntoa(wo->ouraddr), 0);
@@ -1873,7 +1883,8 @@ ipcp_up(f)
@@ -1874,7 +1884,8 @@ ipcp_up(f)
/* assign a default route through the interface if required */
if (ipcp_wantoptions[f->unit].default_route)
@ -66,7 +66,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
default_route_set[f->unit] = 1;
/* Make a proxy ARP entry if requested. */
@@ -1923,7 +1934,8 @@ ipcp_up(f)
@@ -1924,7 +1935,8 @@ ipcp_up(f)
/* assign a default route through the interface if required */
if (ipcp_wantoptions[f->unit].default_route)
@ -76,7 +76,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
default_route_set[f->unit] = 1;
/* Make a proxy ARP entry if requested. */
@@ -2001,7 +2013,7 @@ ipcp_down(f)
@@ -2002,7 +2014,7 @@ ipcp_down(f)
sifnpmode(f->unit, PPP_IP, NPMODE_DROP);
sifdown(f->unit);
ipcp_clear_addrs(f->unit, ipcp_gotoptions[f->unit].ouraddr,
@ -85,7 +85,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
}
/* Execute the ip-down script */
@@ -2017,16 +2029,25 @@ ipcp_down(f)
@@ -2018,16 +2030,25 @@ ipcp_down(f)
* proxy arp entries, etc.
*/
static void
@ -125,9 +125,9 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
bool old_vj; /* use old (short) form of VJ option? */
--- a/pppd/pppd.8
+++ b/pppd/pppd.8
@@ -127,6 +127,11 @@ is no other default route with the same
value of -1, the route is only added if there is no default route at
all.
@@ -121,6 +121,11 @@ the gateway, when IPCP negotiation is su
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
@ -137,7 +137,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
.B disconnect \fIscript
Execute the command specified by \fIscript\fR, by passing it to a
shell, after
@@ -740,7 +745,12 @@ disable both forms of hardware flow cont
@@ -734,7 +739,12 @@ disable both forms of hardware flow cont
.TP
.B nodefaultroute
Disable the \fIdefaultroute\fR option. The system administrator who
@ -153,7 +153,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
.B nodeflate
--- a/pppd/pppd.h
+++ b/pppd/pppd.h
@@ -681,7 +681,7 @@ int sif6addr __P((int, eui64_t, eui64_t
@@ -667,7 +667,7 @@ int sif6addr __P((int, eui64_t, eui64_t
int cif6addr __P((int, eui64_t, eui64_t));
/* Remove an IPv6 address from i/f */
#endif
@ -173,7 +173,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
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 */
@@ -1570,6 +1572,9 @@ static int read_route_table(struct rtent
@@ -1552,6 +1554,9 @@ static int read_route_table(struct rtent
p = NULL;
}
@ -183,7 +183,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
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);
@@ -1642,20 +1647,52 @@ int have_route_to(u_int32_t addr)
@@ -1621,20 +1626,51 @@ int have_route_to(u_int32_t addr)
/********************************************************************
*
* sifdefaultroute - assign a default route through the address given.
@ -193,10 +193,10 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-{
- struct rtentry rt;
-
- if (defaultroute_exists(&rt, dfl_route_metric) && strcmp(rt.rt_dev, ifname) != 0) {
- if (defaultroute_exists(&rt) && strcmp(rt.rt_dev, ifname) != 0) {
- if (rt.rt_flags & RTF_GATEWAY)
- error("not replacing existing default route via %I with metric %d",
- SIN_ADDR(rt.rt_gateway), dfl_route_metric);
- error("not replacing existing default route via %I",
- SIN_ADDR(rt.rt_gateway));
- else
+ *
+ * If the global default_rt_repl_rest flag is set, then this function
@ -218,16 +218,16 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
+ 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, dfl_route_metric))
+ if (defaultroute_exists(&tmp_rt))
+ del_rt = &tmp_rt;
+ } else if (defaultroute_exists(&old_def_rt, dfl_route_metric) &&
+ } 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: */
+ if (old_def_rt.rt_flags & RTF_GATEWAY) {
+ if (!replace) {
+ error("not replacing existing default route via %I with metric %d",
+ SIN_ADDR(old_def_rt.rt_gateway), dfl_route_metric);
+ error("not replacing existing default route via %I",
+ SIN_ADDR(old_def_rt.rt_gateway));
+ return 0;
+ } else {
+ /* we need to copy rt_dev because we need it permanent too: */
@ -235,21 +235,20 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
+ strcpy(tmp_dev, old_def_rt.rt_dev);
+ old_def_rt.rt_dev = tmp_dev;
+
+ notice("replacing old default route to %s [%I] with metric %d",
+ old_def_rt.rt_dev, SIN_ADDR(old_def_rt.rt_gateway),
+ dfl_route_metric);
+ notice("replacing old default route to %s [%I]",
+ old_def_rt.rt_dev, SIN_ADDR(old_def_rt.rt_gateway));
+ default_rt_repl_rest = 1;
+ del_rt = &old_def_rt;
+ }
+ } else
error("not replacing existing default route through %s with metric %d",
- rt.rt_dev, dfl_route_metric);
error("not replacing existing default route through %s",
- rt.rt_dev);
- return 0;
+ old_def_rt.rt_dev, dfl_route_metric);
+ old_def_rt.rt_dev);
}
memset (&rt, 0, sizeof (rt));
@@ -1671,10 +1708,16 @@ int sifdefaultroute (int unit, u_int32_t
@@ -1649,10 +1685,16 @@ int sifdefaultroute (int unit, u_int32_t
rt.rt_flags = RTF_UP;
if (ioctl(sock_fd, SIOCADDRT, &rt) < 0) {
@ -267,7 +266,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
have_default_route = 1;
return 1;
@@ -1708,11 +1751,21 @@ int cifdefaultroute (int unit, u_int32_t
@@ -1683,11 +1725,21 @@ int cifdefaultroute (int unit, u_int32_t
rt.rt_flags = RTF_UP;
if (ioctl(sock_fd, SIOCDELRT, &rt) < 0 && errno != ESRCH) {
if (still_ppp()) {
@ -292,7 +291,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
}
--- a/pppd/sys-solaris.c
+++ b/pppd/sys-solaris.c
@@ -2038,12 +2038,18 @@ cifaddr(u, o, h)
@@ -2039,12 +2039,18 @@ cifaddr(u, o, h)
* sifdefaultroute - assign a default route through the address given.
*/
int

View File

@ -12,7 +12,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
--- a/pppd/main.c
+++ b/pppd/main.c
@@ -308,6 +308,8 @@ main(argc, argv)
@@ -318,6 +318,8 @@ main(argc, argv)
strlcpy(path_ipup, _PATH_IPUP, sizeof(path_ipup));
strlcpy(path_ipdown, _PATH_IPDOWN, sizeof(path_ipdown));
@ -23,8 +23,8 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
new_phase(PHASE_INITIALIZE);
--- a/pppd/options.c
+++ b/pppd/options.c
@@ -119,6 +119,8 @@ int req_unit = -1; /* requested interfa
char req_ifname[MAXIFNAMELEN]; /* requested interface name */
@@ -116,6 +116,8 @@ int connect_delay = 1000; /* wait this m
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 path_ipv6up[MAXPATHLEN]; /* pathname of ipv6-up script */
@ -32,7 +32,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
bool multilink = 0; /* Enable multilink operation */
char *bundle_name = NULL; /* bundle name for multilink */
bool dump_options; /* print out option values */
@@ -325,6 +327,13 @@ option_t general_options[] = {
@@ -308,6 +310,13 @@ option_t general_options[] = {
"Set pathname of ip-down script",
OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
@ -48,7 +48,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
"Enable multilink operation", OPT_PRIO | 1 },
--- a/pppd/ipv6cp.c
+++ b/pppd/ipv6cp.c
@@ -1268,7 +1268,7 @@ ipv6cp_up(f)
@@ -1269,7 +1269,7 @@ ipv6cp_up(f)
*/
if (ipv6cp_script_state == s_down && ipv6cp_script_pid == 0) {
ipv6cp_script_state = s_up;
@ -57,7 +57,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
}
}
@@ -1320,7 +1320,7 @@ ipv6cp_down(f)
@@ -1321,7 +1321,7 @@ ipv6cp_down(f)
/* Execute the ipv6-down script */
if (ipv6cp_script_state == s_up && ipv6cp_script_pid == 0) {
ipv6cp_script_state = s_down;
@ -66,7 +66,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
}
}
@@ -1363,13 +1363,13 @@ ipv6cp_script_done(arg)
@@ -1364,13 +1364,13 @@ ipv6cp_script_done(arg)
case s_up:
if (ipv6cp_fsm[0].state != OPENED) {
ipv6cp_script_state = s_down;
@ -84,8 +84,8 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
}
--- a/pppd/pppd.h
+++ b/pppd/pppd.h
@@ -334,6 +334,8 @@ extern int req_unit; /* interface unit n
extern char req_ifname[MAXIFNAMELEN]; /* interface name to use */
@@ -320,6 +320,8 @@ extern int max_data_rate; /* max bytes/s
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 path_ipv6up[MAXPATHLEN]; /* pathname of ipv6-up script */

View File

@ -1,6 +1,6 @@
--- a/pppd/lcp.c
+++ b/pppd/lcp.c
@@ -72,6 +72,7 @@ static void lcp_delayed_up __P((void *))
@@ -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 */
@ -8,7 +8,7 @@
bool lax_recv = 0; /* accept control chars in asyncmap */
bool noendpoint = 0; /* don't send/accept endpoint discriminator */
@@ -150,6 +151,8 @@ static option_t lcp_option_list[] = {
@@ -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 },
@ -17,7 +17,7 @@
{ "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,
@@ -2330,6 +2333,22 @@ LcpSendEchoRequest (f)
@@ -2331,6 +2334,22 @@ LcpSendEchoRequest (f)
}
}
@ -42,7 +42,7 @@
*/
--- a/pppd/pppd.8
+++ b/pppd/pppd.8
@@ -569,6 +569,11 @@ to 1) if the \fIproxyarp\fR option is us
@@ -563,6 +563,11 @@ to 1) if the \fIproxyarp\fR option is us
dynamic IP address option (i.e. set /proc/sys/net/ipv4/ip_dynaddr to
1) in demand mode if the local address changes.
.TP

View File

@ -0,0 +1,11 @@
--- a/pppd/plugins/rp-pppoe/config.h
+++ b/pppd/plugins/rp-pppoe/config.h
@@ -102,7 +102,7 @@
#define HAVE_NETPACKET_PACKET_H 1
/* Define if you have the <sys/cdefs.h> header file. */
-#define HAVE_SYS_CDEFS_H 1
+/* #undef HAVE_SYS_CDEFS_H */
/* Define if you have the <sys/dlpi.h> header file. */
/* #undef HAVE_SYS_DLPI_H */

View File

@ -0,0 +1,23 @@
--- a/pppd/pppd.h
+++ b/pppd/pppd.h
@@ -67,6 +67,9 @@
#define volatile
#endif
+#undef __P
+#define __P(args) args
+
#ifdef INET6
#include "eui64.h"
#endif
--- a/pppd/magic.h
+++ b/pppd/magic.h
@@ -42,6 +42,8 @@
* $Id: magic.h,v 1.5 2003/06/11 23:56:26 paulus Exp $
*/
+#include "pppd.h"
+
void magic_init __P((void)); /* Initialize the magic number generator */
u_int32_t magic __P((void)); /* Returns the next magic number */

View File

@ -0,0 +1,40 @@
--- a/pppd/sys-linux.c
+++ b/pppd/sys-linux.c
@@ -73,12 +73,12 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
-#include <sys/errno.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <sys/utsname.h>
#include <sys/sysmacros.h>
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <syslog.h>
@@ -102,22 +102,15 @@
#define MAX_ADDR_LEN 7
#endif
-#if __GLIBC__ >= 2
#include <asm/types.h> /* glibc 2 conflicts with linux/types.h */
#include <net/if.h>
#include <net/if_arp.h>
#include <net/route.h>
#include <netinet/if_ether.h>
-#else
-#include <linux/types.h>
-#include <linux/if.h>
-#include <linux/if_arp.h>
-#include <linux/route.h>
-#include <linux/if_ether.h>
-#endif
#include <netinet/in.h>
#include <arpa/inet.h>
+#include <linux/sockios.h>
#include <linux/ppp_defs.h>
#include <linux/if_ppp.h>

View File

@ -1,7 +1,7 @@
--- a/pppd/plugins/rp-pppoe/pppoe.h
+++ b/pppd/plugins/rp-pppoe/pppoe.h
@@ -48,11 +48,7 @@
#include <netinet/in.h>
#endif
/* Ugly header files on some Linux boxes... */
-#if defined(HAVE_LINUX_IF_H)
@ -12,13 +12,15 @@
#ifdef HAVE_NET_IF_TYPES_H
#include <net/if_types.h>
@@ -80,20 +76,7 @@ typedef unsigned long UINT32_t;
@@ -80,22 +76,8 @@ typedef unsigned long UINT32_t;
#error Could not find a 32-bit integer type
#endif
-#ifdef HAVE_LINUX_IF_ETHER_H
-#include <linux/if_ether.h>
-#endif
-
#include <netinet/in.h>
-
-#ifdef HAVE_NETINET_IF_ETHER_H
-#include <sys/types.h>
@ -33,4 +35,49 @@
+#include <net/ethernet.h>
/* Ethernet frame types according to RFC 2516 */
--- a/pppd/plugins/rp-pppoe/pppoe-discovery.c
+++ b/pppd/plugins/rp-pppoe/pppoe-discovery.c
@@ -16,6 +16,7 @@
#include <string.h>
#include "pppoe.h"
+#include "pppd/pppd.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
@@ -717,6 +718,23 @@ char *xstrdup(const char *s)
return ret;
}
+void
+error(char *fmt, ...)
+{
+ va_list pvar;
+
+#if defined(__STDC__)
+ va_start(pvar, fmt);
+#else
+ char *fmt;
+ va_start(pvar);
+ fmt = va_arg(pvar, char *);
+#endif
+
+ fprintf(stderr, fmt, pvar);
+ va_end(pvar);
+}
+
void usage(void)
{
fprintf(stderr, "Usage: pppoe-discovery [options]\n");
--- a/pppd/plugins/rp-pppoe/Makefile.linux
+++ b/pppd/plugins/rp-pppoe/Makefile.linux
@@ -33,7 +33,7 @@ pppoe-discovery: pppoe-discovery.o debug
$(CC) $(CFLAGS) -o pppoe-discovery pppoe-discovery.o debug.o
pppoe-discovery.o: pppoe-discovery.c
- $(CC) $(CFLAGS) -c -o pppoe-discovery.o pppoe-discovery.c
+ $(CC) $(CFLAGS) -I../../.. -c -o pppoe-discovery.o pppoe-discovery.c
debug.o: debug.c
$(CC) $(CFLAGS) -c -o debug.o debug.c

View File

@ -23,9 +23,9 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-USE_TDB=y
+#USE_TDB=y
# Uncomment the next line to enable Type=notify services in systemd
# If enabled, and the user sets the up_sdnotify option, then
@@ -85,7 +85,7 @@ MAXOCTETS=y
HAS_SHADOW=y
#USE_PAM=y
@@ -80,7 +80,7 @@ MAXOCTETS=y
INCLUDE_DIRS= -I../include
@ -34,12 +34,12 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
CFLAGS= $(COPTS) $(COMPILE_FLAGS) $(INCLUDE_DIRS) '-DDESTDIR="@DESTDIR@"'
@@ -125,10 +125,10 @@ CFLAGS += -DHAS_SHADOW
@@ -120,10 +120,10 @@ CFLAGS += -DHAS_SHADOW
#LIBS += -lshadow $(LIBS)
endif
-ifneq ($(wildcard $(shell $CC --print-sysroot)/usr/include/crypt.h),)
+#ifneq ($(wildcard $(shell $CC --print-sysroot)/usr/include/crypt.h),)
-ifneq ($(wildcard /usr/include/crypt.h),)
+#ifneq ($(wildcard /usr/include/crypt.h),)
CFLAGS += -DHAVE_CRYPT_H=1
LIBS += -lcrypt
-endif

View File

@ -88,7 +88,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
*/
--- a/pppd/ccp.c
+++ b/pppd/ccp.c
@@ -61,12 +61,10 @@ static int setdeflate __P((char **));
@@ -62,12 +62,10 @@ static int setdeflate __P((char **));
static char bsd_value[8];
static char deflate_value[8];
@ -104,7 +104,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
static option_t ccp_option_list[] = {
{ "noccp", o_bool, &ccp_protent.enabled_flag,
@@ -107,54 +105,36 @@ static option_t ccp_option_list[] = {
@@ -108,54 +106,36 @@ static option_t ccp_option_list[] = {
"don't allow Predictor-1", OPT_ALIAS | OPT_PRIOSUB | OPT_A2CLR,
&ccp_allowoptions[0].predictor_1 },
@ -188,7 +188,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
#endif /* MPPE */
{ NULL }
@@ -240,7 +220,7 @@ static fsm_callbacks ccp_callbacks = {
@@ -241,7 +221,7 @@ static fsm_callbacks ccp_callbacks = {
*/
#define ANY_COMPRESS(opt) ((opt).deflate || (opt).bsd_compress \
|| (opt).predictor_1 || (opt).predictor_2 \
@ -197,7 +197,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
/*
* Local state (mainly for handling reset-reqs and reset-acks).
@@ -343,6 +323,100 @@ setdeflate(argv)
@@ -344,6 +324,100 @@ setdeflate(argv)
return 1;
}
@ -298,7 +298,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
/*
* ccp_init - initialize CCP.
*/
@@ -377,6 +451,30 @@ ccp_init(unit)
@@ -378,6 +452,30 @@ ccp_init(unit)
ccp_allowoptions[0].bsd_bits = BSD_MAX_BITS;
ccp_allowoptions[0].predictor_1 = 1;
@ -329,7 +329,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
}
/*
@@ -454,11 +552,11 @@ ccp_input(unit, p, len)
@@ -455,11 +553,11 @@ ccp_input(unit, p, len)
if (oldstate == OPENED && p[0] == TERMREQ && f->state != OPENED) {
notice("Compression disabled by peer.");
#ifdef MPPE
@ -343,7 +343,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
}
/*
@@ -486,6 +584,15 @@ ccp_extcode(f, code, id, p, len)
@@ -487,6 +585,15 @@ ccp_extcode(f, code, id, p, len)
break;
/* send a reset-ack, which the transmitter will see and
reset its compression state. */
@ -359,7 +359,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
fsm_sdata(f, CCP_RESETACK, id, NULL, 0);
break;
@@ -514,12 +621,11 @@ ccp_protrej(unit)
@@ -515,12 +622,11 @@ ccp_protrej(unit)
fsm_lowerdown(&ccp_fsm[unit]);
#ifdef MPPE
@ -374,7 +374,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
}
/*
@@ -536,7 +642,7 @@ ccp_resetci(f)
@@ -537,7 +643,7 @@ ccp_resetci(f)
all_rejected[f->unit] = 0;
#ifdef MPPE
@ -383,7 +383,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
ccp_options *ao = &ccp_allowoptions[f->unit];
int auth_mschap_bits = auth_done[f->unit];
int numbits;
@@ -550,80 +656,109 @@ ccp_resetci(f)
@@ -551,80 +657,109 @@ ccp_resetci(f)
* NB: If MPPE is required, all other compression opts are invalid.
* So, we return right away if we can't do it.
*/
@ -560,7 +560,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
opt_buf[0] = CI_BSD_COMPRESS;
opt_buf[1] = CILEN_BSD_COMPRESS;
@@ -679,7 +814,8 @@ ccp_cilen(f)
+ (go->deflate && go->deflate_draft? CILEN_DEFLATE: 0)
+ (go->deflate? CILEN_DEFLATE: 0)
+ (go->predictor_1? CILEN_PREDICTOR_1: 0)
+ (go->predictor_2? CILEN_PREDICTOR_2: 0)
- + (go->mppe? CILEN_MPPE: 0);
@ -1459,7 +1459,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
bool deflate_draft; /* use draft RFC code for deflate? */
+ bool lzs; /* do Stac LZS? */
+ bool mppc; /* do MPPC? */
u_char mppe; /* MPPE bitfield */
bool mppe; /* do MPPE? */
+ bool mppe_40; /* allow 40 bit encryption? */
+ bool mppe_56; /* allow 56 bit encryption? */
+ bool mppe_128; /* allow 128 bit encryption? */
@ -1473,7 +1473,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
--- a/pppd/chap_ms.c
+++ b/pppd/chap_ms.c
@@ -962,13 +962,17 @@ set_mppe_enc_types(int policy, int types
@@ -963,13 +963,17 @@ set_mppe_enc_types(int policy, int types
/*
* Disable undesirable encryption types. Note that we don't ENABLE
* any encryption types, to avoid overriding manual configuration.

View File

@ -19,7 +19,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
clean:
--- a/pppd/Makefile.linux
+++ b/pppd/Makefile.linux
@@ -107,7 +107,7 @@ ifdef USE_SRP
@@ -102,7 +102,7 @@ ifdef USE_SRP
CFLAGS += -DUSE_SRP -DOPENSSL -I/usr/local/ssl/include
LIBS += -lsrp -L/usr/local/ssl/lib -lcrypto
TARGETS += srp-entry
@ -28,7 +28,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
MANPAGES += srp-entry.8
EXTRACLEAN += srp-entry.o
NEEDDES=y
@@ -219,7 +219,7 @@ all: $(TARGETS)
@@ -208,7 +208,7 @@ all: $(TARGETS)
install: pppd
mkdir -p $(BINDIR) $(MANDIR)
$(EXTRAINSTALL)

View File

@ -18,23 +18,6 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
# Uncomment the next line to include support for Microsoft's
# MS-CHAP authentication protocol.
@@ -43,13 +44,13 @@ install: all
$(INSTALL) -c -m 444 pppd-radattr.8 $(MANDIR)
radius.so: radius.o libradiusclient.a
- $(CC) $(LDFLAGS) -o radius.so -shared radius.o libradiusclient.a
+ $(CC) $(LDFLAGS) -fPIC -o radius.so -shared radius.o libradiusclient.a
radattr.so: radattr.o
- $(CC) $(LDFLAGS) -o radattr.so -shared radattr.o
+ $(CC) $(LDFLAGS) -fPIC -o radattr.so -shared radattr.o
radrealms.so: radrealms.o
- $(CC) $(LDFLAGS) -o radrealms.so -shared radrealms.o
+ $(CC) $(LDFLAGS) -fPIC -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
--- a/pppdump/Makefile.linux
+++ b/pppdump/Makefile.linux
@@ -2,7 +2,8 @@ DESTDIR = $(INSTROOT)@DESTDIR@
@ -50,11 +33,11 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
--- a/pppd/plugins/rp-pppoe/Makefile.linux
+++ b/pppd/plugins/rp-pppoe/Makefile.linux
@@ -39,7 +39,7 @@ debug.o: debug.c
$(CC) $(CFLAGS) -I../../.. -c -o debug.o debug.c
$(CC) $(CFLAGS) -c -o debug.o debug.c
rp-pppoe.so: plugin.o discovery.o if.o common.o
- $(CC) $(LDFLAGS) -o rp-pppoe.so -shared plugin.o discovery.o if.o common.o
+ $(CC) $(LDFLAGS) -fPIC -o rp-pppoe.so -shared plugin.o discovery.o if.o common.o
- $(CC) $(CFLAGS) -o rp-pppoe.so -shared plugin.o discovery.o if.o common.o
+ $(CC) $(CFLAGS) -fPIC -o rp-pppoe.so -shared plugin.o discovery.o if.o common.o
install: all
$(INSTALL) -d -m 755 $(LIBDIR)

View File

@ -1,6 +1,6 @@
--- a/pppd/plugins/radius/config.c
+++ b/pppd/plugins/radius/config.c
@@ -371,31 +371,37 @@ static int test_config(char *filename)
@@ -369,31 +369,37 @@ static int test_config(char *filename)
}
#endif

View File

@ -7,7 +7,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
--- a/pppd/plugins/rp-pppoe/discovery.c
+++ b/pppd/plugins/rp-pppoe/discovery.c
@@ -632,7 +632,9 @@ discovery(PPPoEConnection *conn)
@@ -644,7 +644,9 @@ discovery(PPPoEConnection *conn)
conn->discoveryState = STATE_SENT_PADI;
waitForPADO(conn, timeout);
@ -17,7 +17,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
} while (conn->discoveryState == STATE_SENT_PADI);
timeout = conn->discoveryTimeout;
@@ -647,7 +649,9 @@ discovery(PPPoEConnection *conn)
@@ -659,7 +661,9 @@ discovery(PPPoEConnection *conn)
sendPADR(conn);
conn->discoveryState = STATE_SENT_PADR;
waitForPADS(conn, timeout);

View File

@ -13,7 +13,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
--- a/pppd/main.c
+++ b/pppd/main.c
@@ -89,6 +89,7 @@
@@ -90,6 +90,7 @@
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
@ -21,7 +21,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
#include "pppd.h"
#include "magic.h"
@@ -226,6 +227,7 @@ static struct subprocess *children;
@@ -228,6 +229,7 @@ static struct subprocess *children;
/* Prototypes for procedures local to this file. */
@ -29,7 +29,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
static void setup_signals __P((void));
static void create_pidfile __P((int pid));
static void create_linkpidfile __P((int pid));
@@ -525,6 +527,7 @@ main(argc, argv)
@@ -535,6 +537,7 @@ main(argc, argv)
info("Starting link");
}
@ -37,7 +37,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
gettimeofday(&start_time, NULL);
script_unsetenv("CONNECT_TIME");
script_unsetenv("BYTES_SENT");
@@ -1270,6 +1273,36 @@ struct callout {
@@ -1267,6 +1270,36 @@ struct callout {
static struct callout *callout = NULL; /* Callout list */
static struct timeval timenow; /* Current time */
@ -74,7 +74,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
/*
* timeout - Schedule a timeout.
@@ -1340,6 +1373,8 @@ calltimeout()
@@ -1337,6 +1370,8 @@ calltimeout()
{
struct callout *p;
@ -83,7 +83,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
while (callout != NULL) {
p = callout;
@@ -1367,6 +1402,8 @@ timeleft(tvp)
@@ -1364,6 +1399,8 @@ timeleft(tvp)
{
if (callout == NULL)
return NULL;

View File

@ -8,7 +8,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
--- a/pppd/lcp.c
+++ b/pppd/lcp.c
@@ -1916,12 +1916,12 @@ lcp_up(f)
@@ -1917,12 +1917,12 @@ lcp_up(f)
* the interface MTU is set to the lowest of that, the
* MTU we want to use, and our link MRU.
*/

View File

@ -12,7 +12,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
--- a/pppd/main.c
+++ b/pppd/main.c
@@ -1051,7 +1051,8 @@ get_input()
@@ -1048,7 +1048,8 @@ get_input()
}
notice("Modem hangup");
hungup = 1;

View File

@ -7,7 +7,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
--- a/pppd/Makefile.linux
+++ b/pppd/Makefile.linux
@@ -189,8 +189,8 @@ endif
@@ -178,8 +178,8 @@ endif
ifdef FILTER
ifneq ($(wildcard /usr/include/pcap-bpf.h),)

View File

@ -23,7 +23,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
# Uncomment the next line to enable multilink PPP (enabled by default)
# Linux distributions: Please leave multilink ENABLED in your builds
# of pppd!
@@ -194,6 +197,14 @@ CFLAGS += -DPPP_FILTER -I$(STAGING_DIR)
@@ -183,6 +186,14 @@ CFLAGS += -DPPP_FILTER -I$(STAGING_DIR)
endif
endif
@ -48,7 +48,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
/*
* There have been 3 or 4 different names for this in libpcap CVS, but
* this seems to be what they have settled on...
@@ -169,6 +170,13 @@ static int setlogfile __P((char **));
@@ -165,6 +166,13 @@ static int setlogfile __P((char **));
static int loadplugin __P((char **));
#endif
@ -62,7 +62,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
#ifdef PPP_FILTER
static int setpassfilter __P((char **));
static int setactivefilter __P((char **));
@@ -361,6 +369,14 @@ option_t general_options[] = {
@@ -344,6 +352,14 @@ option_t general_options[] = {
"set filter for active pkts", OPT_PRIO },
#endif
@ -77,7 +77,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
#ifdef MAXOCTETS
{ "maxoctets", o_int, &maxoctets,
"Set connection traffic limit",
@@ -1510,6 +1526,29 @@ callfile(argv)
@@ -1493,6 +1509,29 @@ callfile(argv)
return ok;
}

View File

@ -0,0 +1,135 @@
pppd: Support arbitrary interface names
This patch implements a new string option "ifname" which allows to specify
fully custom PPP interface names on Linux. It does so by renaming the
allocated pppX device immediately after it has been created to the requested
interface name.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
--- a/pppd/main.c
+++ b/pppd/main.c
@@ -745,8 +745,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 (use_ifname[0] == 0)
+ slprintf(ifname, sizeof(ifname), "%s%d", PPP_DRV_NAME, ifunit);
+ else
+ slprintf(ifname, sizeof(ifname), "%s", use_ifname);
+ info("Using interface %s", ifname);
script_setenv("IFNAME", ifname, iskey);
if (iskey) {
create_pidfile(getpid()); /* write pid to file */
--- a/pppd/options.c
+++ b/pppd/options.c
@@ -112,6 +112,7 @@ int log_to_fd = 1; /* send log messages
bool log_default = 1; /* log_to_fd is default (stdout) */
int maxfail = 10; /* max # of unsuccessful connection attempts */
char linkname[MAXPATHLEN]; /* logical name for link */
+char use_ifname[IFNAMSIZ]; /* physical name for PPP 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 */
@@ -277,6 +278,9 @@ option_t general_options[] = {
{ "linkname", o_string, linkname,
"Set logical name for link",
OPT_PRIO | OPT_PRIV | OPT_STATIC, NULL, MAXPATHLEN },
+ { "ifname", o_string, use_ifname,
+ "Set physical name for PPP interface",
+ OPT_PRIO | OPT_PRIV | OPT_STATIC, NULL, IFNAMSIZ },
{ "maxfail", o_int, &maxfail,
"Maximum number of unsuccessful connection attempts to allow",
--- a/pppd/pppd.h
+++ b/pppd/pppd.h
@@ -74,6 +74,10 @@
#include "eui64.h"
#endif
+#ifndef IFNAMSIZ
+#define IFNAMSIZ 16
+#endif
+
/*
* Limits.
*/
@@ -317,6 +321,7 @@ extern char *record_file; /* File to rec
extern bool sync_serial; /* Device is synchronous serial device */
extern int maxfail; /* Max # of unsuccessful connection attempts */
extern char linkname[MAXPATHLEN]; /* logical name for link */
+extern char use_ifname[IFNAMSIZ]; /* physical name for PPP interface */
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 */
--- a/pppd/sys-linux.c
+++ b/pppd/sys-linux.c
@@ -161,6 +161,10 @@ struct in6_ifreq {
/* We can get an EIO error on an ioctl if the modem has hung up */
#define ok_error(num) ((num)==EIO)
+#if !defined(PPP_DRV_NAME)
+#define PPP_DRV_NAME "ppp"
+#endif /* !defined(PPP_DRV_NAME) */
+
static int tty_disc = N_TTY; /* The TTY discipline */
static int ppp_disc = N_PPP; /* The PPP discpline */
static int initfdflags = -1; /* Initial file descriptor flags for fd */
@@ -620,7 +624,8 @@ void generic_disestablish_ppp(int dev_fd
*/
static int make_ppp_unit()
{
- int x, flags;
+ struct ifreq ifr;
+ int x, flags, s;
if (ppp_dev_fd >= 0) {
dbglog("in make_ppp_unit, already had /dev/ppp open?");
@@ -643,6 +648,30 @@ static int make_ppp_unit()
}
if (x < 0)
error("Couldn't create new ppp unit: %m");
+
+ if (use_ifname[0] != 0) {
+ s = socket(PF_INET, SOCK_DGRAM, 0);
+ if (s < 0)
+ s = socket(PF_PACKET, SOCK_DGRAM, 0);
+ if (s < 0)
+ s = socket(PF_INET6, SOCK_DGRAM, 0);
+ if (s < 0)
+ s = socket(PF_UNIX, SOCK_DGRAM, 0);
+ if (s >= 0) {
+ slprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%s%d", PPP_DRV_NAME, ifunit);
+ slprintf(ifr.ifr_newname, sizeof(ifr.ifr_newname), "%s", use_ifname);
+ x = ioctl(s, SIOCSIFNAME, &ifr);
+ close(s);
+ } else {
+ x = s;
+ }
+ if (x < 0) {
+ error("Couldn't rename %s to %s", ifr.ifr_name, ifr.ifr_newname);
+ close(ppp_dev_fd);
+ ppp_dev_fd = -1;
+ }
+ }
+
return x;
}
--- a/pppstats/pppstats.c
+++ b/pppstats/pppstats.c
@@ -506,10 +506,12 @@ main(argc, argv)
if (argc > 0)
interface = argv[0];
+#if 0
if (sscanf(interface, PPP_DRV_NAME "%d", &unit) != 1) {
fprintf(stderr, "%s: invalid interface '%s' specified\n",
progname, interface);
}
+#endif
#ifndef STREAMS
{

View File

@ -8,15 +8,7 @@ Signed-off-by: George Kashperko <george@znau.edu.ua>
2 files changed, 53 insertions(+), 14 deletions(-)
--- a/pppd/multilink.c
+++ b/pppd/multilink.c
@@ -35,6 +35,7 @@
#include <signal.h>
#include <netinet/in.h>
#include <unistd.h>
+#include <net/if.h>
#include "pppd.h"
#include "fsm.h"
@@ -56,7 +57,8 @@ static void iterate_bundle_links __P((vo
@@ -56,7 +56,8 @@ static void iterate_bundle_links __P((vo
static int get_default_epdisc __P((struct epdisc *));
static int parse_num __P((char *str, const char *key, int *valp));
@ -26,7 +18,7 @@ Signed-off-by: George Kashperko <george@znau.edu.ua>
#define set_ip_epdisc(ep, addr) do { \
ep->length = 4; \
@@ -197,35 +199,38 @@ mp_join_bundle()
@@ -197,35 +198,38 @@ mp_join_bundle()
key.dptr = bundle_id;
key.dsize = p - bundle_id;
pid = tdb_fetch(pppdb, key);
@ -73,7 +65,7 @@ Signed-off-by: George Kashperko <george@znau.edu.ua>
}
/* we have to make a new bundle */
@@ -408,22 +413,45 @@ parse_num(str, key, valp)
@@ -408,22 +412,45 @@ parse_num(str, key, valp)
return 0;
}
@ -126,7 +118,7 @@ Signed-off-by: George Kashperko <george@znau.edu.ua>
&& memcmp(vd.dptr, key.dptr, vd.dsize) == 0;
--- a/pppd/sys-linux.c
+++ b/pppd/sys-linux.c
@@ -693,6 +693,16 @@ void cfg_bundle(int mrru, int mtru, int
@@ -698,6 +698,16 @@ void cfg_bundle(int mrru, int mtru, int
add_fd(ppp_dev_fd);
}
@ -143,7 +135,7 @@ Signed-off-by: George Kashperko <george@znau.edu.ua>
/*
* make_new_bundle - create a new PPP unit (i.e. a bundle)
* and connect our channel to it. This should only get called
@@ -711,6 +721,8 @@ void make_new_bundle(int mrru, int mtru,
@@ -716,6 +726,8 @@ void make_new_bundle(int mrru, int mtru,
/* set the mrru and flags */
cfg_bundle(mrru, mtru, rssn, tssn);

View File

@ -12,7 +12,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
--- a/pppd/sys-linux.c
+++ b/pppd/sys-linux.c
@@ -1760,6 +1760,7 @@ int cifdefaultroute (int unit, u_int32_t
@@ -1756,6 +1756,7 @@ int cifdefaultroute (int unit, u_int32_t
SIN_ADDR(rt.rt_genmask) = 0L;
}

View File

@ -21,9 +21,9 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
+ SIN_ADDR(rt.rt_gateway) = gateway;
+
rt.rt_dev = ifname;
rt.rt_metric = dfl_route_metric + 1; /* +1 for binary compatibility */
@@ -1718,7 +1721,7 @@ int sifdefaultroute (int unit, u_int32_t
if (kernel_version > KVERSION(2,1,0)) {
@@ -1717,7 +1720,7 @@ int sifdefaultroute (int unit, u_int32_t
SIN_ADDR(rt.rt_genmask) = 0L;
}

View File

@ -10,7 +10,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
--- a/pppd/sys-linux.c
+++ b/pppd/sys-linux.c
@@ -199,7 +199,7 @@ static int driver_is_old = 0;
@@ -196,7 +196,7 @@ static int driver_is_old = 0;
static int restore_term = 0; /* 1 => we've munged the terminal */
static struct termios inittermios; /* Initial TTY termios */
@ -19,7 +19,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
static char loop_name[20];
static unsigned char inbuf[512]; /* buffer for chars read from loopback */
@@ -217,8 +217,8 @@ static int looped; /* 1 if using loop
@@ -214,8 +214,8 @@ static int looped; /* 1 if using loop
static int link_mtu; /* mtu for the link (not bundle) */
static struct utsname utsname; /* for the kernel version */
@ -29,7 +29,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
#define MAX_IFS 100
@@ -1446,11 +1446,12 @@ int ccp_fatal_error (int unit)
@@ -1451,11 +1451,12 @@ int ccp_fatal_error (int unit)
*
* path_to_procfs - find the path to the proc file system mount point
*/
@ -44,7 +44,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
struct mntent *mntent;
FILE *fp;
@@ -1472,6 +1473,7 @@ static char *path_to_procfs(const char *
@@ -1477,6 +1478,7 @@ static char *path_to_procfs(const char *
fclose (fp);
}
}
@ -52,7 +52,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
strlcpy(proc_path + proc_path_len, tail,
sizeof(proc_path) - proc_path_len);
@@ -2133,15 +2135,19 @@ int ppp_available(void)
@@ -2129,15 +2131,19 @@ int ppp_available(void)
int my_version, my_modification, my_patch;
int osmaj, osmin, ospatch;
@ -72,7 +72,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
/* XXX should get from driver */
driver_version = 2;
@@ -2201,6 +2207,7 @@ int ppp_available(void)
@@ -2197,6 +2203,7 @@ int ppp_available(void)
if (ok && ((ifr.ifr_hwaddr.sa_family & ~0xFF) != ARPHRD_PPP))
ok = 0;
@ -80,7 +80,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
/*
* This is the PPP device. Validate the version of the driver at this
@@ -2737,6 +2744,7 @@ get_pty(master_fdp, slave_fdp, slave_nam
@@ -2730,6 +2737,7 @@ get_pty(master_fdp, slave_fdp, slave_nam
}
#endif /* TIOCGPTN */
@ -88,7 +88,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
if (sfd < 0) {
/* the old way - scan through the pty name space */
for (i = 0; i < 64; ++i) {
@@ -2755,6 +2763,7 @@ get_pty(master_fdp, slave_fdp, slave_nam
@@ -2748,6 +2756,7 @@ get_pty(master_fdp, slave_fdp, slave_nam
}
}
}
@ -125,7 +125,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
char *pppd_pppoe_service = NULL;
static char *acName = NULL;
static char *existingSession = NULL;
@@ -392,10 +389,6 @@ PPPoEDevnameHook(char *cmd, char **argv,
@@ -371,10 +368,6 @@ PPPoEDevnameHook(char *cmd, char **argv,
void
plugin_init(void)
{
@ -138,7 +138,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
info("RP-PPPoE plugin version %s compiled against pppd %s",
--- a/pppd/plugins/pppol2tp/pppol2tp.c
+++ b/pppd/plugins/pppol2tp/pppol2tp.c
@@ -490,12 +490,7 @@ static void pppol2tp_cleanup(void)
@@ -486,12 +486,7 @@ static void pppol2tp_cleanup(void)
void plugin_init(void)
{

View File

@ -7,7 +7,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
--- a/pppd/pppd.h
+++ b/pppd/pppd.h
@@ -323,7 +323,6 @@ extern int holdoff; /* Dead time before
@@ -317,7 +317,6 @@ extern int holdoff; /* Dead time before
extern bool holdoff_specified; /* true if user gave a holdoff value */
extern bool notty; /* Stdin/out is not a tty */
extern char *pty_socket; /* Socket to connect to pty */
@ -17,7 +17,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
extern char linkname[MAXPATHLEN]; /* logical name for link */
--- a/pppd/tty.c
+++ b/pppd/tty.c
@@ -145,7 +145,7 @@ char *disconnect_script = NULL; /* Scrip
@@ -146,7 +146,7 @@ char *disconnect_script = NULL; /* Scrip
char *welcomer = NULL; /* Script to run after phys link estab. */
char *ptycommand = NULL; /* Command to run on other side of pty */
bool notty = 0; /* Stdin/out is not a tty */
@ -26,7 +26,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
int max_data_rate; /* max bytes/sec through charshunt */
bool sync_serial = 0; /* Device is synchronous serial device */
char *pty_socket = NULL; /* Socket to connect to pty */
@@ -201,8 +201,10 @@ option_t tty_options[] = {
@@ -202,8 +202,10 @@ option_t tty_options[] = {
"Send and receive over socket, arg is host:port",
OPT_PRIO | OPT_DEVNAM },

View File

@ -7,7 +7,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
--- a/pppd/sys-linux.c
+++ b/pppd/sys-linux.c
@@ -2271,6 +2271,7 @@ int ppp_available(void)
@@ -2267,6 +2267,7 @@ int ppp_available(void)
void logwtmp (const char *line, const char *name, const char *host)
{
@ -15,7 +15,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
struct utmp ut, *utp;
pid_t mypid = getpid();
#if __GLIBC__ < 2
@@ -2336,6 +2337,7 @@ void logwtmp (const char *line, const ch
@@ -2332,6 +2333,7 @@ void logwtmp (const char *line, const ch
close (wtmp);
}
#endif

View File

@ -9,7 +9,7 @@ Signed-off-by: Jo-Philipp Wich <jo@mein.io>
--- a/pppd/options.c
+++ b/pppd/options.c
@@ -349,13 +349,14 @@ option_t general_options[] = {
@@ -336,13 +336,14 @@ option_t general_options[] = {
"Enable multilink operation", OPT_PRIOSUB | OPT_ALIAS | 1 },
{ "nomultilink", o_bool, &multilink,
"Disable multilink operation", OPT_PRIOSUB | 0 },

View File

@ -0,0 +1,214 @@
diff -Naur ppp-2.4.5.0/pppd/chap-new.c ppp-2.4.5/pppd/chap-new.c
--- ppp-2.4.5.0/pppd/chap-new.c 2012-04-18 15:44:46.000000000 +0800
+++ ppp-2.4.5/pppd/chap-new.c 2012-04-19 20:24:28.000000000 +0800
@@ -37,6 +37,8 @@
#include "chap-new.h"
#include "chap-md5.h"
+#include "syncppp.h"
+
#ifdef CHAPMS
#include "chap_ms.h"
#define MDTYPE_ALL (MDTYPE_MICROSOFT_V2 | MDTYPE_MICROSOFT | MDTYPE_MD5)
@@ -481,6 +483,19 @@
p[2] = len >> 8;
p[3] = len;
+ if (npppd > 1) {
+ if (syncppp(npppd) < 0) {
+ error("syncppp sync fail");
+ sem_unlink(SEM_COUNT_NAME);
+ sem_unlink(SEM_BLOCK_NAME);
+ } else {
+ info("syncppp sync succeeded");
+ }
+ } else {
+ info("syncppp not active");
+ }
+
+
output(0, response, PPP_HDRLEN + len);
}
diff -Naur ppp-2.4.5.0/pppd/Makefile.linux ppp-2.4.5/pppd/Makefile.linux
--- ppp-2.4.5.0/pppd/Makefile.linux 2012-04-18 15:44:46.000000000 +0800
+++ ppp-2.4.5/pppd/Makefile.linux 2012-04-19 20:01:05.000000000 +0800
@@ -13,16 +13,16 @@
PPPDSRCS = main.c magic.c fsm.c lcp.c ipcp.c upap.c chap-new.c md5.c ccp.c \
ecp.c ipxcp.c auth.c options.c sys-linux.c md4.c chap_ms.c \
- demand.c utils.c tty.c eap.c chap-md5.c session.c
+ demand.c utils.c tty.c eap.c chap-md5.c session.c syncppp.c
HEADERS = ccp.h session.h chap-new.h ecp.h fsm.h ipcp.h \
ipxcp.h lcp.h magic.h md5.h patchlevel.h pathnames.h pppd.h \
- upap.h eap.h
+ upap.h eap.h syncppp.h
MANPAGES = pppd.8
PPPDOBJS = main.o magic.o fsm.o lcp.o ipcp.o upap.o chap-new.o md5.o ccp.o \
ecp.o auth.o options.o demand.o utils.o sys-linux.o ipxcp.o tty.o \
- eap.o chap-md5.o session.o
+ eap.o chap-md5.o session.o syncppp.o
#
# include dependencies if present
@@ -33,7 +33,7 @@
# CC = gcc
#
COPTS = -O2 -pipe -Wall -g
-LIBS =
+LIBS = -lpthread
# Uncomment the next 2 lines to include support for Microsoft's
# MS-CHAP authentication protocol. Also, edit plugins/radius/Makefile.linux.
diff -Naur ppp-2.4.5.0/pppd/options.c ppp-2.4.5/pppd/options.c
--- ppp-2.4.5.0/pppd/options.c 2012-04-18 15:44:46.000000000 +0800
+++ ppp-2.4.5/pppd/options.c 2012-04-19 20:24:49.000000000 +0800
@@ -126,6 +126,7 @@
bool dryrun; /* print out option values and exit */
char *domain; /* domain name set by domain option */
int child_wait = 5; /* # seconds to wait for children at exit */
+int npppd = 0; /* synchronize between multiple pppd */
struct userenv *userenv_list; /* user environment variables */
#ifdef MAXOCTETS
@@ -311,6 +312,10 @@
"Set pathname of ipv6-down script",
OPT_PRIV|OPT_STATIC, NULL, MAXPATHLEN },
+ { "syncppp", o_int, &npppd,
+ "sync among multiple pppd when sending chap/pap respond", OPT_PRIO },
+
+
#ifdef HAVE_MULTILINK
{ "multilink", o_bool, &multilink,
"Enable multilink operation", OPT_PRIO | 1 },
diff -Naur ppp-2.4.5.0/pppd/pppd.h ppp-2.4.5/pppd/pppd.h
--- ppp-2.4.5.0/pppd/pppd.h 2012-04-18 15:44:46.000000000 +0800
+++ ppp-2.4.5/pppd/pppd.h 2012-04-19 20:25:02.000000000 +0800
@@ -327,6 +327,7 @@
extern bool dump_options; /* print out option values */
extern bool dryrun; /* check everything, print options, exit */
extern int child_wait; /* # seconds to wait for children at end */
+extern int npppd; /* synchronize between multiple pppd */
#ifdef MAXOCTETS
extern unsigned int maxoctets; /* Maximum octetes per session (in bytes) */
diff -Naur ppp-2.4.5.0/pppd/syncppp.c ppp-2.4.5/pppd/syncppp.c
--- ppp-2.4.5.0/pppd/syncppp.c 1970-01-01 08:00:00.000000000 +0800
+++ ppp-2.4.5/pppd/syncppp.c 2012-04-18 15:46:59.000000000 +0800
@@ -0,0 +1,75 @@
+#include<stdio.h>
+#include<semaphore.h>
+#include<fcntl.h>
+#include<stdlib.h>
+#include<time.h>
+#include<errno.h>
+#include "pppd.h"
+#include "syncppp.h"
+
+int syncppp(int nproc)
+{
+ int flags;
+ int value;
+ sem_t *block;
+ sem_t *count;
+ struct timespec ts;
+
+ if (nproc <= 1) {
+ error("syncppp: number of pppd should be larger than 1");
+ return -1;
+ }
+
+ if (clock_gettime(CLOCK_REALTIME, &ts) == -1) {
+ error("clock_gettime error");
+ return -1;
+ }
+ ts.tv_sec += SYNCPPP_TIMEOUT;
+
+
+ flags = O_RDWR | O_CREAT;
+ block = sem_open(SEM_BLOCK_NAME, flags, 0644, 0);
+ count = sem_open(SEM_COUNT_NAME, flags, 0644, 0);
+ if (block == SEM_FAILED || count == SEM_FAILED) {
+ error("syncppp: sem_open failed");
+ return -1;
+ }
+
+ if (sem_post(count) < 0) {
+ error("syncppp: sem_post failed");
+ return -1;
+ }
+ if (sem_getvalue(count, &value) < 0) {
+ error("syncppp: sem_getvalue failed");
+ return -1;
+ }
+ info("%d pppd have arrived, waiting for the left %d", value, nproc-value);
+ if (value >= nproc) {
+ while (nproc-1 > 0) {
+ if (sem_post(block) < 0) {
+ error("syncppp: sem_post failed");
+ return -1;
+ }
+ nproc--;
+ }
+ } else {
+ if (sem_timedwait(block, &ts) < 0) {
+ if (errno == ETIMEDOUT) {
+ error("syncppp: sem_timewait time out");
+ } else {
+ error("syncppp: sem_timewait error");
+ }
+ return -1;
+ }
+
+ }
+
+ sem_close(count);
+ sem_close(block);
+
+ sem_unlink(SEM_COUNT_NAME);
+ sem_unlink(SEM_BLOCK_NAME);
+
+ return 0;
+}
+
diff -Naur ppp-2.4.5.0/pppd/syncppp.h ppp-2.4.5/pppd/syncppp.h
--- ppp-2.4.5.0/pppd/syncppp.h 1970-01-01 08:00:00.000000000 +0800
+++ ppp-2.4.5/pppd/syncppp.h 2012-04-18 15:46:59.000000000 +0800
@@ -0,0 +1,3 @@
+#define SEM_BLOCK_NAME "block"
+#define SEM_COUNT_NAME "count"
+#define SYNCPPP_TIMEOUT 5
diff -Naur ppp-2.4.5.0/pppd/upap.c ppp-2.4.5/pppd/upap.c
--- ppp-2.4.5.0/pppd/upap.c 2012-04-18 15:44:46.000000000 +0800
+++ ppp-2.4.5/pppd/upap.c 2012-04-19 20:26:22.000000000 +0800
@@ -52,6 +52,8 @@
#include "pppd.h"
#include "upap.h"
+#include "syncppp.h"
+
static const char rcsid[] = RCSID;
static bool hide_password = 1;
@@ -568,6 +570,18 @@
PUTCHAR(u->us_passwdlen, outp);
BCOPY(u->us_passwd, outp, u->us_passwdlen);
+ if (npppd > 1) {
+ if (syncppp(npppd) < 0) {
+ error("syncppp sync fail");
+ sem_unlink(SEM_COUNT_NAME);
+ sem_unlink(SEM_BLOCK_NAME);
+ } else {
+ info("syncppp sync succeeded");
+ }
+ } else {
+ info("syncppp not active");
+ }
+
output(u->us_unit, outpacket_buf, outlen + PPP_HDRLEN);
TIMEOUT(upap_timeout, u, u->us_timeouttime);

View File

@ -0,0 +1,269 @@
--- a/pppd/plugins/rp-pppoe/common.c
+++ b/pppd/plugins/rp-pppoe/common.c
@@ -119,15 +119,11 @@ sendPADT(PPPoEConnection *conn, char con
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 */
--- 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
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 == 0);
}
/**********************************************************************
@@ -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 */
--- a/pppd/plugins/rp-pppoe/plugin.c
+++ b/pppd/plugins/rp-pppoe/plugin.c
@@ -65,6 +65,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[] = {
@@ -82,6 +83,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;
@@ -107,7 +110,6 @@ PPPOEInitDevice(void)
conn->ifName = devnam;
conn->discoverySocket = -1;
conn->sessionSocket = -1;
- conn->useHostUniq = 1;
conn->printACNames = printACNames;
conn->discoveryTimeout = PADI_TIMEOUT;
return 1;
@@ -163,6 +165,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));
--- a/pppd/plugins/rp-pppoe/pppoe-discovery.c
+++ b/pppd/plugins/rp-pppoe/pppoe-discovery.c
@@ -348,7 +348,7 @@ packetIsForMe(PPPoEConnection *conn, PPP
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;
@@ -474,16 +474,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);
@@ -645,7 +641,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);
@@ -654,7 +650,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");
--- 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
@@ -217,7 +219,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 */
@@ -273,6 +275,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) \

View File

@ -0,0 +1,11 @@
--- a/pppd/plugins/rp-pppoe/plugin.c
+++ b/pppd/plugins/rp-pppoe/plugin.c
@@ -275,7 +275,7 @@ PPPOEDisconnectDevice(void)
sizeof(struct sockaddr_pppox)) < 0)
error("Failed to disconnect PPPoE socket: %d %m", errno);
close(conn->sessionSocket);
- /* don't send PADT?? */
+ sendPADT(conn, NULL);
if (conn->discoverySocket >= 0)
close(conn->discoverySocket);
}

View File

@ -0,0 +1,14 @@
--- a/pppd/plugins/rp-pppoe/plugin.c
+++ b/pppd/plugins/rp-pppoe/plugin.c
@@ -271,9 +271,8 @@ PPPOEDisconnectDevice(void)
sp.sa_addr.pppoe.sid = 0;
memcpy(sp.sa_addr.pppoe.dev, conn->ifName, IFNAMSIZ);
memcpy(sp.sa_addr.pppoe.remote, conn->peerEth, ETH_ALEN);
- if (connect(conn->sessionSocket, (struct sockaddr *) &sp,
- sizeof(struct sockaddr_pppox)) < 0)
- error("Failed to disconnect PPPoE socket: %d %m", errno);
+ connect(conn->sessionSocket, (struct sockaddr *) &sp,
+ sizeof(struct sockaddr_pppox));
close(conn->sessionSocket);
sendPADT(conn, NULL);
if (conn->discoverySocket >= 0)

View File

@ -1,8 +1,8 @@
--- a/pppd/plugins/pppol2tp/pppol2tp.c
+++ b/pppd/plugins/pppol2tp/pppol2tp.c
@@ -152,6 +152,10 @@ static int setdevname_pppol2tp(char **ar
if (pppol2tp_fd_str == NULL)
novm("PPPoL2TP FD");
@@ -148,6 +148,10 @@ static int setdevname_pppol2tp(char **ar
fatal("PPPoL2TP kernel driver not installed");
}
+ pppol2tp_fd_str = strdup(*argv);
+ if (pppol2tp_fd_str == NULL)

View File

@ -0,0 +1,11 @@
--- a/pppd/options.c
+++ b/pppd/options.c
@@ -1013,7 +1013,7 @@ print_option(opt, mainopt, printer, arg)
p = (char *) opt->addr2;
if ((opt->flags & OPT_STATIC) == 0)
p = *(char **)p;
- printer("%q", p);
+ printer(arg, "%q", p);
} else if (opt->flags & OPT_A2LIST) {
struct option_value *ovp;

View File

@ -1,94 +0,0 @@
From 831dca008699d485f2c8e91749657ef2d0b06166 Mon Sep 17 00:00:00 2001
From: Martin Schiller <ms@dev.tdt.de>
Date: Thu, 6 Dec 2018 08:43:17 +0100
Subject: [PATCH] Revert "pppd: Use openssl for the DES instead of the libcrypt
/ glibc"
For musl and glibc2.27 we can keep linking to crypt; however if we
switch to glibc 2.28 we will have to link to one of the SSL libraries.
This reverts commit 3c7b86229f7bd2600d74db14b1fe5b3896be3875.
---
pppd/Makefile.linux | 7 +++----
pppd/pppcrypt.c | 18 +++++++++---------
2 files changed, 12 insertions(+), 13 deletions(-)
--- a/pppd/Makefile.linux
+++ b/pppd/Makefile.linux
@@ -35,10 +35,10 @@ endif
COPTS = -O2 -pipe -Wall -g
LIBS =
-# Uncomment the next line to include support for Microsoft's
+# Uncomment the next 2 lines to include support for Microsoft's
# MS-CHAP authentication protocol. Also, edit plugins/radius/Makefile.linux.
CHAPMS=y
-#USE_CRYPT=y
+USE_CRYPT=y
# Don't use MSLANMAN unless you really know what you're doing.
#MSLANMAN=y
# Uncomment the next line to include support for MPPE. CHAPMS (above) must
@@ -140,8 +140,7 @@ endif
ifdef NEEDDES
ifndef USE_CRYPT
-CFLAGS += -I$(shell $CC --print-sysroot)/usr/include/openssl
-LIBS += -lcrypto
+LIBS += -ldes $(LIBS)
else
CFLAGS += -DUSE_CRYPT=1
endif
--- a/pppd/pppcrypt.c
+++ b/pppd/pppcrypt.c
@@ -64,7 +64,7 @@ u_char *des_key; /* OUT 64 bit DES key w
des_key[7] = Get7Bits(key, 49);
#ifndef USE_CRYPT
- DES_set_odd_parity((DES_cblock *)des_key);
+ des_set_odd_parity((des_cblock *)des_key);
#endif
}
@@ -158,25 +158,25 @@ u_char *clear; /* OUT 8 octets */
}
#else /* USE_CRYPT */
-static DES_key_schedule key_schedule;
+static des_key_schedule key_schedule;
bool
DesSetkey(key)
u_char *key;
{
- DES_cblock des_key;
+ des_cblock des_key;
MakeKey(key, des_key);
- DES_set_key(&des_key, &key_schedule);
+ des_set_key(&des_key, key_schedule);
return (1);
}
bool
-DesEncrypt(clear, cipher)
+DesEncrypt(clear, key, cipher)
u_char *clear; /* IN 8 octets */
u_char *cipher; /* OUT 8 octets */
{
- DES_ecb_encrypt((DES_cblock *)clear, (DES_cblock *)cipher,
- &key_schedule, 1);
+ des_ecb_encrypt((des_cblock *)clear, (des_cblock *)cipher,
+ key_schedule, 1);
return (1);
}
@@ -185,8 +185,8 @@ DesDecrypt(cipher, clear)
u_char *cipher; /* IN 8 octets */
u_char *clear; /* OUT 8 octets */
{
- DES_ecb_encrypt((DES_cblock *)cipher, (DES_cblock *)clear,
- &key_schedule, 0);
+ des_ecb_encrypt((des_cblock *)cipher, (des_cblock *)clear,
+ key_schedule, 0);
return (1);
}