Changeset 2285


Ignore:
Timestamp:
Mar 15, 2013, 9:57:34 AM (6 years ago)
Author:
matthijs
Message:

ppp: Don't set gateway address when none is available

Sometimes, the peer doesn't supply any address. The noremoteip option to
pppd option can be used to simply accept this instead of complaining and
using a dummy IP address. However, an OpenWRT patch to pppd then breaks
the default route by trying to set 0.0.0.0 as the gateway.

This commit changes the patch to only set a patch when a gateway address
is actually available.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/openwrt/package/ppp/patches/340-populate_default_gateway.patch

    r2281 r2285  
    88
    99This patch addresses the issue by filling in the peer address as gateway
    10 when generating the default route entry.
     10when generating the default route entry, but only when an address is
     11available.
    1112
    1213Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
     14Signed-off-by: Matthijs Kooijman <matthijs@stdin.nl>
    1315
    1416--- a/pppd/sys-linux.c
    1517+++ b/pppd/sys-linux.c
    16 @@ -1709,6 +1709,9 @@ int sifdefaultroute (int unit, u_int32_t
    17      memset (&rt, 0, sizeof (rt));
    18      SET_SA_FAMILY (rt.rt_dst, AF_INET);
    19  
    20 +    SET_SA_FAMILY(rt.rt_gateway, AF_INET);
    21 +    SIN_ADDR(rt.rt_gateway) = gateway;
    22 +
    23      rt.rt_dev = ifname;
    24  
    25      if (kernel_version > KVERSION(2,1,0)) {
    26 @@ -1716,7 +1719,7 @@ int sifdefaultroute (int unit, u_int32_t
    27         SIN_ADDR(rt.rt_genmask) = 0L;
     18@@ -1717,6 +1717,13 @@
    2819     }
    2920 
    30 -    rt.rt_flags = RTF_UP;
    31 +    rt.rt_flags = RTF_UP | RTF_GATEWAY;
     21     rt.rt_flags = RTF_UP;
     22+
     23+    if (gateway) {
     24+       rt.rt_flags |= RTF_GATEWAY;
     25+       SET_SA_FAMILY(rt.rt_gateway, AF_INET);
     26+        SIN_ADDR(rt.rt_gateway) = gateway;
     27+    }
     28+
    3229     if (ioctl(sock_fd, SIOCADDRT, &rt) < 0) {
    3330        if (!ok_error(errno))
Note: See TracChangeset for help on using the changeset viewer.