1 pppd: Fill in default gateway on Linux
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.
6 This behaviour breaks various downstream programs which attempt to infer
7 the default gateway IP address from the system default route entry.
9 This patch addresses the issue by filling in the peer address as gateway
10 when generating the default route entry.
12 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
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);
20 + SET_SA_FAMILY(rt.rt_gateway, AF_INET);
21 + SIN_ADDR(rt.rt_gateway) = gateway;
24 rt.rt_metric = dfl_route_metric + 1; /* +1 for binary compatibility */
26 @@ -1718,7 +1721,7 @@ int sifdefaultroute (int unit, u_int32_t
27 SIN_ADDR(rt.rt_genmask) = 0L;
30 - rt.rt_flags = RTF_UP;
31 + rt.rt_flags = RTF_UP | RTF_GATEWAY;
32 if (ioctl(sock_fd, SIOCADDRT, &rt) < 0) {
34 error("default route ioctl(SIOCADDRT): %m");