Magellan Linux

Annotation of /trunk/ppp/patches/ppp-2.4.4-killaddr-smarter.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: 4491 byte(s)
-added patches from gentoo

1 niro 797 diff -Nru ppp-2.4.4.orig/pppd/options.c ppp-2.4.4/pppd/options.c
2     --- ppp-2.4.4.orig/pppd/options.c 2006-06-18 14:26:00.000000000 +0300
3     +++ ppp-2.4.4/pppd/options.c 2006-08-22 07:37:59.273023000 +0300
4     @@ -100,6 +100,9 @@
5     char user[MAXNAMELEN]; /* Username for PAP */
6     char passwd[MAXSECRETLEN]; /* Password for PAP */
7     bool persist = 0; /* Reopen link after it goes down */
8     +bool killoldaddr = 0; /* If our IP is reassigned on
9     + reconnect, kill active TCP
10     + connections using the old IP. */
11     char our_name[MAXNAMELEN]; /* Our name for authentication purposes */
12     bool demand = 0; /* do dial-on-demand */
13     char *ipparam = NULL; /* Extra parameter for ip up/down scripts */
14     @@ -231,6 +234,11 @@
15     { "demand", o_bool, &demand,
16     "Dial on demand", OPT_INITONLY | 1, &persist },
17    
18     + { "killoldaddr", o_bool, &killoldaddr,
19     + "Kill connections from an old source address", 1},
20     + { "nokilloldaddr", o_bool,&killoldaddr,
21     + "Don't kill connections from an old source address" },
22     +
23     { "--version", o_special_noarg, (void *)showversion,
24     "Show version number" },
25     { "--help", o_special_noarg, (void *)showhelp,
26     diff -Nru ppp-2.4.4.orig/pppd/pppd.h ppp-2.4.4/pppd/pppd.h
27     --- ppp-2.4.4.orig/pppd/pppd.h 2005-08-26 02:59:34.000000000 +0300
28     +++ ppp-2.4.4/pppd/pppd.h 2006-08-22 07:37:59.273023000 +0300
29     @@ -297,6 +297,9 @@
30     extern char remote_name[MAXNAMELEN]; /* Peer's name for authentication */
31     extern bool explicit_remote;/* remote_name specified with remotename opt */
32     extern bool demand; /* Do dial-on-demand */
33     +extern bool killoldaddr; /* If our IP is reassigned on
34     + reconnect, kill active TCP
35     + connections using the old IP. */
36     extern char *ipparam; /* Extra parameter for ip up/down scripts */
37     extern bool cryptpap; /* Others' PAP passwords are encrypted */
38     extern int idle_time_limit;/* Shut down link if idle for this long */
39     diff -Nru ppp-2.4.4.orig/pppd/sys-linux.c ppp-2.4.4/pppd/sys-linux.c
40     --- ppp-2.4.4.orig/pppd/sys-linux.c 2005-08-27 01:44:35.000000000 +0300
41     +++ ppp-2.4.4/pppd/sys-linux.c 2006-08-22 07:37:59.277023250 +0300
42     @@ -165,6 +165,10 @@
43    
44     #endif /* INET6 */
45    
46     +#ifndef SIOCKILLADDR
47     +#define SIOCKILLADDR 0x8939
48     +#endif
49     +
50     /* We can get an EIO error on an ioctl if the modem has hung up */
51     #define ok_error(num) ((num)==EIO)
52    
53     @@ -209,6 +213,7 @@
54     static u_int32_t proxy_arp_addr; /* Addr for proxy arp entry added */
55     static char proxy_arp_dev[16]; /* Device for proxy arp entry */
56     static u_int32_t our_old_addr; /* for detecting address changes */
57     +static u_int32_t our_current_addr;
58     static int dynaddr_set; /* 1 if ip_dynaddr set */
59     static int looped; /* 1 if using loop */
60     static int link_mtu; /* mtu for the link (not bundle) */
61     @@ -537,6 +542,27 @@
62     return -1;
63     }
64    
65     +static void do_killaddr(u_int32_t oldaddr)
66     +{
67     + struct ifreq ifr;
68     +
69     + memset(&ifr,0,sizeof ifr);
70     +
71     + SET_SA_FAMILY (ifr.ifr_addr, AF_INET);
72     + SET_SA_FAMILY (ifr.ifr_dstaddr, AF_INET);
73     + SET_SA_FAMILY (ifr.ifr_netmask, AF_INET);
74     +
75     + SIN_ADDR(ifr.ifr_addr) = oldaddr;
76     +
77     + strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
78     +
79     + if(ioctl(sock_fd,SIOCKILLADDR,&ifr) < 0) {
80     + if (!ok_error (errno))
81     + error("ioctl(SIOCKILLADDR): %m(%d)", errno);
82     + return;
83     + }
84     +}
85     +
86     /********************************************************************
87     *
88     * tty_disestablish_ppp - Restore the serial port to normal operation.
89     @@ -2366,21 +2392,29 @@
90     }
91     }
92    
93     - /* set ip_dynaddr in demand mode if address changes */
94     - if (demand && tune_kernel && !dynaddr_set
95     - && our_old_addr && our_old_addr != our_adr) {
96     + if(persist && our_old_addr && our_old_addr != our_adr) {
97     +
98     + if(killoldaddr)
99     + do_killaddr(our_old_addr);
100     +
101     +
102     + /* set ip_dynaddr in persist mode if address changes */
103     + if (tune_kernel && !dynaddr_set) {
104     /* set ip_dynaddr if possible */
105     char *path;
106     int fd;
107    
108     path = path_to_procfs("/sys/net/ipv4/ip_dynaddr");
109     if (path != 0 && (fd = open(path, O_WRONLY)) >= 0) {
110     - if (write(fd, "1", 1) != 1)
111     - error("Couldn't enable dynamic IP addressing: %m");
112     - close(fd);
113     + if (write(fd, "1", 1) != 1)
114     + error("Couldn't enable dynamic IP addressing: %m");
115     + close(fd);
116     }
117     dynaddr_set = 1; /* only 1 attempt */
118     + }
119     }
120     +
121     + our_current_addr = our_adr;
122     our_old_addr = 0;
123    
124     return 1;
125     @@ -2436,7 +2470,8 @@
126     }
127    
128     our_old_addr = our_adr;
129     -
130     + our_current_addr = 0;
131     +
132     return 1;
133     }
134