Magellan Linux

Annotation of /trunk/ppp/patches/ppp-2.4.4-defaultgateway.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 797 - (hide annotations) (download)
Mon May 11 09:46:04 2009 UTC (15 years ago) by niro
File size: 2779 byte(s)
-added patches from gentoo

1 niro 797 This patch reverses revision 1.114 of the pppd/sys-linux.c file.
2     The default gateway is needed by the openswan's %defaultroute.
3     diff -Nru ppp-2.4.4.orig/pppd/sys-linux.c ppp-2.4.4/pppd/sys-linux.c
4     --- ppp-2.4.4.orig/pppd/sys-linux.c 2006-10-05 09:58:39.000000000 +0300
5     +++ ppp-2.4.4/pppd/sys-linux.c 2006-10-05 10:06:37.000000000 +0300
6     @@ -209,7 +209,7 @@
7     static unsigned char inbuf[512]; /* buffer for chars read from loopback */
8    
9     static int if_is_up; /* Interface has been marked up */
10     -static int have_default_route; /* Gateway for default route added */
11     +static u_int32_t default_route_gateway; /* Gateway for default route added */
12     static u_int32_t proxy_arp_addr; /* Addr for proxy arp entry added */
13     static char proxy_arp_dev[16]; /* Device for proxy arp entry */
14     static u_int32_t our_old_addr; /* for detecting address changes */
15     @@ -346,8 +346,8 @@
16     /*
17     * Delete any routes through the device.
18     */
19     - if (have_default_route)
20     - cifdefaultroute(0, 0, 0);
21     + if (default_route_gateway != 0)
22     + cifdefaultroute(0, 0, default_route_gateway);
23    
24     if (has_proxy_arp)
25     cifproxyarp(0, proxy_arp_addr);
26     @@ -1615,17 +1615,17 @@
27     struct rtentry rt;
28    
29     if (defaultroute_exists(&rt) && strcmp(rt.rt_dev, ifname) != 0) {
30     - if (rt.rt_flags & RTF_GATEWAY)
31     - error("not replacing existing default route via %I",
32     - SIN_ADDR(rt.rt_gateway));
33     - else
34     - error("not replacing existing default route through %s",
35     - rt.rt_dev);
36     + u_int32_t old_gateway = SIN_ADDR(rt.rt_gateway);
37     +
38     + if (old_gateway != gateway)
39     + error("not replacing existing default route to %s [%I]",
40     + rt.rt_dev, old_gateway);
41     return 0;
42     }
43    
44     - memset (&rt, 0, sizeof (rt));
45     - SET_SA_FAMILY (rt.rt_dst, AF_INET);
46     + memset (&rt, '\0', sizeof (rt));
47     + SET_SA_FAMILY (rt.rt_dst, AF_INET);
48     + SET_SA_FAMILY (rt.rt_gateway, AF_INET);
49    
50     rt.rt_dev = ifname;
51    
52     @@ -1634,14 +1634,16 @@
53     SIN_ADDR(rt.rt_genmask) = 0L;
54     }
55    
56     - rt.rt_flags = RTF_UP;
57     + SIN_ADDR(rt.rt_gateway) = gateway;
58     +
59     + rt.rt_flags = RTF_UP | RTF_GATEWAY;
60     if (ioctl(sock_fd, SIOCADDRT, &rt) < 0) {
61     if ( ! ok_error ( errno ))
62     error("default route ioctl(SIOCADDRT): %m");
63     return 0;
64     }
65    
66     - have_default_route = 1;
67     + default_route_gateway = gateway;
68     return 1;
69     }
70    
71     @@ -1654,7 +1656,7 @@
72     {
73     struct rtentry rt;
74    
75     - have_default_route = 0;
76     + default_route_gateway = 0;
77    
78     memset (&rt, '\0', sizeof (rt));
79     SET_SA_FAMILY (rt.rt_dst, AF_INET);
80     @@ -1665,7 +1667,9 @@
81     SIN_ADDR(rt.rt_genmask) = 0L;
82     }
83    
84     - rt.rt_flags = RTF_UP;
85     + SIN_ADDR(rt.rt_gateway) = gateway;
86     +
87     + rt.rt_flags = RTF_UP | RTF_GATEWAY;
88     if (ioctl(sock_fd, SIOCDELRT, &rt) < 0 && errno != ESRCH) {
89     if (still_ppp()) {
90     if ( ! ok_error ( errno ))