X-Git-Url: http://git.openwrt.org/?a=blobdiff_plain;f=package%2Fnetwork%2Fservices%2Fppp%2Fpatches%2F110-debian_defaultroute.patch;h=21b329e5d5fe70f5e74b61cb04dde080de4095f5;hb=12a80e44b914a00fa39daae5474b3964f246ddc3;hp=41d28909be4511d2af4d8dcb651d2bdb34d1f3aa;hpb=405e21d16731b2764ab82aaaadcf36a813b105f7;p=openwrt%2Fstaging%2Fmkresin.git diff --git a/package/network/services/ppp/patches/110-debian_defaultroute.patch b/package/network/services/ppp/patches/110-debian_defaultroute.patch index 41d28909be..21b329e5d5 100644 --- a/package/network/services/ppp/patches/110-debian_defaultroute.patch +++ b/package/network/services/ppp/patches/110-debian_defaultroute.patch @@ -8,11 +8,11 @@ connections but not allow them to change the system default route. The patch originated from the Debian project. -Signed-off-by: Jo-Philipp Wich +Signed-off-by: Jo-Philipp Wich --- a/pppd/ipcp.c +++ b/pppd/ipcp.c -@@ -198,6 +198,14 @@ static option_t ipcp_option_list[] = { +@@ -197,6 +197,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 { "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 +279,7 @@ struct protent ipcp_protent = { +@@ -270,7 +278,7 @@ struct protent ipcp_protent = { ip_active_pkt }; @@ -36,7 +36,7 @@ Signed-off-by: Jo-Philipp Wich static void ipcp_script __P((char *, int)); /* Run an up/down script */ static void ipcp_script_done __P((void *)); -@@ -1742,7 +1750,8 @@ ip_demand_conf(u) +@@ -1760,7 +1768,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 default_route_set[u] = 1; if (wo->proxy_arp) if (sifproxyarp(u, wo->hisaddr)) -@@ -1830,7 +1839,8 @@ ipcp_up(f) +@@ -1848,7 +1857,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 if (go->ouraddr != wo->ouraddr) { warn("Local IP address changed to %I", go->ouraddr); script_setenv("OLDIPLOCAL", ip_ntoa(wo->ouraddr), 0); -@@ -1855,7 +1865,8 @@ ipcp_up(f) +@@ -1873,7 +1883,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 default_route_set[f->unit] = 1; /* Make a proxy ARP entry if requested. */ -@@ -1905,7 +1916,8 @@ ipcp_up(f) +@@ -1923,7 +1934,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 default_route_set[f->unit] = 1; /* Make a proxy ARP entry if requested. */ -@@ -1983,7 +1995,7 @@ ipcp_down(f) +@@ -2001,7 +2013,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 } /* Execute the ip-down script */ -@@ -1999,16 +2011,25 @@ ipcp_down(f) +@@ -2017,16 +2029,25 @@ ipcp_down(f) * proxy arp entries, etc. */ static void @@ -125,9 +125,9 @@ Signed-off-by: Jo-Philipp Wich bool old_vj; /* use old (short) form of VJ option? */ --- a/pppd/pppd.8 +++ b/pppd/pppd.8 -@@ -121,6 +121,11 @@ the gateway, when IPCP negotiation is su +@@ -133,6 +133,11 @@ the gateway, when IPv6CP negotiation is This entry is removed when the PPP connection is broken. This option - is privileged if the \fInodefaultroute\fR option has been specified. + is privileged if the \fInodefaultroute6\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 .B disconnect \fIscript Execute the command specified by \fIscript\fR, by passing it to a shell, after -@@ -717,7 +722,12 @@ disable both forms of hardware flow cont +@@ -756,7 +761,12 @@ disable both forms of hardware flow cont .TP .B nodefaultroute Disable the \fIdefaultroute\fR option. The system administrator who @@ -150,10 +150,10 @@ Signed-off-by: Jo-Philipp Wich +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 + .B nodefaultroute6 --- a/pppd/pppd.h +++ b/pppd/pppd.h -@@ -645,7 +645,7 @@ int sif6addr __P((int, eui64_t, eui64_t +@@ -684,7 +684,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 @@ -164,16 +164,16 @@ Signed-off-by: Jo-Philipp Wich /* Delete default route through i/f */ --- a/pppd/sys-linux.c +++ b/pppd/sys-linux.c -@@ -206,6 +206,8 @@ static unsigned char inbuf[512]; /* buff - - static int if_is_up; /* Interface has been marked up */ +@@ -209,6 +209,8 @@ static int if_is_up; /* Interface has be + 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 int have_default_route6; /* Gateway for default IPv6 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 */ -@@ -1544,6 +1546,9 @@ static int read_route_table(struct rtent +@@ -1577,6 +1579,9 @@ static int read_route_table(struct rtent p = NULL; } @@ -183,7 +183,7 @@ Signed-off-by: Jo-Philipp Wich 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); -@@ -1613,20 +1618,51 @@ int have_route_to(u_int32_t addr) +@@ -1649,20 +1654,52 @@ 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 -{ - struct rtentry rt; - -- if (defaultroute_exists(&rt) && strcmp(rt.rt_dev, ifname) != 0) { +- if (defaultroute_exists(&rt, dfl_route_metric) && 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)); +- error("not replacing existing default route via %I with metric %d", +- SIN_ADDR(rt.rt_gateway), dfl_route_metric); - else + * + * If the global default_rt_repl_rest flag is set, then this function @@ -218,16 +218,16 @@ Signed-off-by: Jo-Philipp Wich + 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)) ++ if (defaultroute_exists(&tmp_rt, dfl_route_metric)) + del_rt = &tmp_rt; -+ } else if (defaultroute_exists(&old_def_rt) && ++ } else if (defaultroute_exists(&old_def_rt, dfl_route_metric) && + 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", -+ SIN_ADDR(old_def_rt.rt_gateway)); ++ error("not replacing existing default route via %I with metric %d", ++ SIN_ADDR(old_def_rt.rt_gateway), dfl_route_metric); + return 0; + } else { + /* we need to copy rt_dev because we need it permanent too: */ @@ -235,20 +235,21 @@ Signed-off-by: Jo-Philipp Wich + 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, SIN_ADDR(old_def_rt.rt_gateway)); ++ 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); + default_rt_repl_rest = 1; + del_rt = &old_def_rt; + } + } else - error("not replacing existing default route through %s", -- rt.rt_dev); + error("not replacing existing default route through %s with metric %d", +- rt.rt_dev, dfl_route_metric); - return 0; -+ old_def_rt.rt_dev); ++ old_def_rt.rt_dev, dfl_route_metric); } memset (&rt, 0, sizeof (rt)); -@@ -1641,10 +1677,16 @@ int sifdefaultroute (int unit, u_int32_t +@@ -1678,10 +1715,16 @@ int sifdefaultroute (int unit, u_int32_t rt.rt_flags = RTF_UP; if (ioctl(sock_fd, SIOCADDRT, &rt) < 0) { @@ -266,7 +267,7 @@ Signed-off-by: Jo-Philipp Wich have_default_route = 1; return 1; -@@ -1675,11 +1717,21 @@ int cifdefaultroute (int unit, u_int32_t +@@ -1715,11 +1758,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()) { @@ -291,7 +292,7 @@ Signed-off-by: Jo-Philipp Wich } --- a/pppd/sys-solaris.c +++ b/pppd/sys-solaris.c -@@ -2036,12 +2036,18 @@ cifaddr(u, o, h) +@@ -2120,12 +2120,18 @@ cifaddr(u, o, h) * sifdefaultroute - assign a default route through the address given. */ int