340-populate_default_gateway.patch 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. pppd: Fill in default gateway on Linux
  2. On Linux, when pppd creates the default route, it does not set the peer
  3. address as gateway, leading to a default route without gateway address.
  4. This behaviour breaks various downstream programs which attempt to infer
  5. the default gateway IP address from the system default route entry.
  6. This patch addresses the issue by filling in the peer address as gateway
  7. when generating the default route entry.
  8. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
  9. --- a/pppd/sys-linux.c
  10. +++ b/pppd/sys-linux.c
  11. @@ -1710,6 +1710,9 @@ int sifdefaultroute (int unit, u_int32_t
  12. memset (&rt, 0, sizeof (rt));
  13. SET_SA_FAMILY (rt.rt_dst, AF_INET);
  14. + SET_SA_FAMILY(rt.rt_gateway, AF_INET);
  15. + SIN_ADDR(rt.rt_gateway) = gateway;
  16. +
  17. rt.rt_dev = ifname;
  18. if (kernel_version > KVERSION(2,1,0)) {
  19. @@ -1717,7 +1720,7 @@ int sifdefaultroute (int unit, u_int32_t
  20. SIN_ADDR(rt.rt_genmask) = 0L;
  21. }
  22. - rt.rt_flags = RTF_UP;
  23. + rt.rt_flags = RTF_UP | RTF_GATEWAY;
  24. if (ioctl(sock_fd, SIOCADDRT, &rt) < 0) {
  25. if (!ok_error(errno))
  26. error("default route ioctl(SIOCADDRT): %m");