ppp: update to version 2.4.7.git-2018-06-23
[openwrt/openwrt.git] / package / network / services / ppp / patches / 110-debian_defaultroute.patch
index 1005c59ab51d0ff2c1c67c96cf8333b02c3db018..bdc271dbea54c1850bfb2abd883675e02f9ec043 100644 (file)
@@ -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
-@@ -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.
+@@ -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.
  .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
-@@ -734,7 +739,12 @@ disable both forms of hardware flow cont
+@@ -740,7 +745,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
-@@ -667,7 +667,7 @@ int  sif6addr __P((int, eui64_t, eui64_t
+@@ -681,7 +681,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 */
-@@ -1552,6 +1554,9 @@ static int read_route_table(struct rtent
+@@ -1570,6 +1572,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);
-@@ -1621,20 +1626,51 @@ int have_route_to(u_int32_t addr)
+@@ -1642,20 +1647,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 <jo@mein.io>
 -{
 -    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 <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))
++      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 <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]",
-+                      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));
-@@ -1649,10 +1685,16 @@ int sifdefaultroute (int unit, u_int32_t
+@@ -1671,10 +1708,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 <jo@mein.io>
  
      have_default_route = 1;
      return 1;
-@@ -1683,11 +1725,21 @@ int cifdefaultroute (int unit, u_int32_t
+@@ -1708,11 +1751,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()) {