X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=pppd%2Fsys-linux.c;h=e23315a3486a583092aa9796e3d77a4f58a881dc;hb=d6e4ac0c098b02de9cc7907133d209da1bbf99df;hp=e963c79786097d2957ac65b6ca2323d58edd44de;hpb=637346ba24c289c5a0485651c05baa3f7c22a6b8;p=ppp.git diff --git a/pppd/sys-linux.c b/pppd/sys-linux.c index e963c79..e23315a 100644 --- a/pppd/sys-linux.c +++ b/pppd/sys-linux.c @@ -205,7 +205,7 @@ static char loop_name[20]; static unsigned char inbuf[512]; /* buffer for chars read from loopback */ static int if_is_up; /* Interface has been marked up */ -static u_int32_t default_route_gateway; /* Gateway for default route added */ +static int have_default_route; /* Gateway for default route added */ 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 */ @@ -341,8 +341,8 @@ void sys_cleanup(void) /* * Delete any routes through the device. */ - if (default_route_gateway != 0) - cifdefaultroute(0, 0, default_route_gateway); + if (have_default_route) + cifdefaultroute(0, 0, 0); if (has_proxy_arp) cifproxyarp(0, proxy_arp_addr); @@ -1589,17 +1589,17 @@ int sifdefaultroute (int unit, u_int32_t ouraddr, u_int32_t gateway) struct rtentry rt; if (defaultroute_exists(&rt) && strcmp(rt.rt_dev, ifname) != 0) { - u_int32_t old_gateway = SIN_ADDR(rt.rt_gateway); - - if (old_gateway != gateway) - error("not replacing existing default route to %s [%I]", - rt.rt_dev, old_gateway); + if (rt.rt_flags & RTF_GATEWAY) + error("not replacing existing default route via %I", + SIN_ADDR(rt.rt_gateway)); + else + error("not replacing existing default route through %s", + rt.rt_dev); return 0; } - memset (&rt, '\0', sizeof (rt)); - SET_SA_FAMILY (rt.rt_dst, AF_INET); - SET_SA_FAMILY (rt.rt_gateway, AF_INET); + memset (&rt, 0, sizeof (rt)); + SET_SA_FAMILY (rt.rt_dst, AF_INET); rt.rt_dev = ifname; @@ -1608,16 +1608,14 @@ int sifdefaultroute (int unit, u_int32_t ouraddr, u_int32_t gateway) SIN_ADDR(rt.rt_genmask) = 0L; } - SIN_ADDR(rt.rt_gateway) = gateway; - - rt.rt_flags = RTF_UP | RTF_GATEWAY; + rt.rt_flags = RTF_UP; if (ioctl(sock_fd, SIOCADDRT, &rt) < 0) { if ( ! ok_error ( errno )) error("default route ioctl(SIOCADDRT): %m"); return 0; } - default_route_gateway = gateway; + have_default_route = 1; return 1; } @@ -1630,7 +1628,7 @@ int cifdefaultroute (int unit, u_int32_t ouraddr, u_int32_t gateway) { struct rtentry rt; - default_route_gateway = 0; + have_default_route = 0; memset (&rt, '\0', sizeof (rt)); SET_SA_FAMILY (rt.rt_dst, AF_INET); @@ -1641,9 +1639,7 @@ int cifdefaultroute (int unit, u_int32_t ouraddr, u_int32_t gateway) SIN_ADDR(rt.rt_genmask) = 0L; } - SIN_ADDR(rt.rt_gateway) = gateway; - - rt.rt_flags = RTF_UP | RTF_GATEWAY; + rt.rt_flags = RTF_UP; if (ioctl(sock_fd, SIOCDELRT, &rt) < 0 && errno != ESRCH) { if (still_ppp()) { if ( ! ok_error ( errno )) @@ -2808,8 +2804,8 @@ sys_check_options(void) if (ipxcp_protent.enabled_flag) { struct stat stat_buf; - if ((path = path_to_procfs("/net/ipx/interface")) == 0 - || (path = path_to_procfs("/net/ipx_interface")) == 0 + if ( ((path = path_to_procfs("/net/ipx/interface")) == NULL + && (path = path_to_procfs("/net/ipx_interface")) == NULL) || lstat(path, &stat_buf) < 0) { error("IPX support is not present in the kernel\n"); ipxcp_protent.enabled_flag = 0;