add chaos_calmer branch
[15.05/openwrt.git] / package / network / services / ppp / patches / 340-populate_default_gateway.patch
1 pppd: Fill in default gateway on Linux
2
3 On Linux, when pppd creates the default route, it does not set the peer
4 address as gateway, leading to a default route without gateway address.
5
6 This behaviour breaks various downstream programs which attempt to infer
7 the default gateway IP address from the system default route entry.
8
9 This patch addresses the issue by filling in the peer address as gateway
10 when generating the default route entry.
11
12 Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
13
14 --- a/pppd/sys-linux.c
15 +++ b/pppd/sys-linux.c
16 @@ -1710,6 +1710,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 @@ -1717,7 +1720,7 @@ int sifdefaultroute (int unit, u_int32_t
27         SIN_ADDR(rt.rt_genmask) = 0L;
28      }
29  
30 -    rt.rt_flags = RTF_UP;
31 +    rt.rt_flags = RTF_UP | RTF_GATEWAY;
32      if (ioctl(sock_fd, SIOCADDRT, &rt) < 0) {
33         if (!ok_error(errno))
34             error("default route ioctl(SIOCADDRT): %m");