OpenWrt – Diff between revs 2 and 3

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 2 Rev 3
Line 123... Line 123...
123 bool proxy_arp; /* Make proxy ARP entry for peer? */ 123 bool proxy_arp; /* Make proxy ARP entry for peer? */
124 bool neg_vj; /* Van Jacobson Compression? */ 124 bool neg_vj; /* Van Jacobson Compression? */
125 bool old_vj; /* use old (short) form of VJ option? */ 125 bool old_vj; /* use old (short) form of VJ option? */
126 --- a/pppd/pppd.8 126 --- a/pppd/pppd.8
127 +++ b/pppd/pppd.8 127 +++ b/pppd/pppd.8
128 @@ -127,6 +127,11 @@ is no other default route with the same 128 @@ -121,6 +121,11 @@ the gateway, when IPCP negotiation is su
129 value of -1, the route is only added if there is no default route at 129 This entry is removed when the PPP connection is broken. This option
130 all. -  
-   130 is privileged if the \fInodefaultroute\fR option has been specified.
131 .TP 131 .TP
132 +.B replacedefaultroute 132 +.B replacedefaultroute
133 +This option is a flag to the defaultroute option. If defaultroute is 133 +This option is a flag to the defaultroute option. If defaultroute is
134 +set and this flag is also set, pppd replaces an existing default route 134 +set and this flag is also set, pppd replaces an existing default route
135 +with the new default route. 135 +with the new default route.
136 +.TP 136 +.TP
137 .B disconnect \fIscript 137 .B disconnect \fIscript
138 Execute the command specified by \fIscript\fR, by passing it to a 138 Execute the command specified by \fIscript\fR, by passing it to a
139 shell, after 139 shell, after
140 @@ -740,7 +745,12 @@ disable both forms of hardware flow cont 140 @@ -734,7 +739,12 @@ disable both forms of hardware flow cont
141 .TP 141 .TP
142 .B nodefaultroute 142 .B nodefaultroute
143 Disable the \fIdefaultroute\fR option. The system administrator who 143 Disable the \fIdefaultroute\fR option. The system administrator who
144 -wishes to prevent users from creating default routes with pppd 144 -wishes to prevent users from creating default routes with pppd
145 +wishes to prevent users from adding a default route with pppd 145 +wishes to prevent users from adding a default route with pppd
Line 151... Line 151...
151 can do so by placing this option in the /etc/ppp/options file. 151 can do so by placing this option in the /etc/ppp/options file.
152 .TP 152 .TP
153 .B nodeflate 153 .B nodeflate
154 --- a/pppd/pppd.h 154 --- a/pppd/pppd.h
155 +++ b/pppd/pppd.h 155 +++ b/pppd/pppd.h
156 @@ -681,7 +681,7 @@ int sif6addr __P((int, eui64_t, eui64_t 156 @@ -667,7 +667,7 @@ int sif6addr __P((int, eui64_t, eui64_t
157 int cif6addr __P((int, eui64_t, eui64_t)); 157 int cif6addr __P((int, eui64_t, eui64_t));
158 /* Remove an IPv6 address from i/f */ 158 /* Remove an IPv6 address from i/f */
159 #endif 159 #endif
160 -int sifdefaultroute __P((int, u_int32_t, u_int32_t)); 160 -int sifdefaultroute __P((int, u_int32_t, u_int32_t));
161 +int sifdefaultroute __P((int, u_int32_t, u_int32_t, bool replace_default_rt)); 161 +int sifdefaultroute __P((int, u_int32_t, u_int32_t, bool replace_default_rt));
Line 171... Line 171...
171 +static struct rtentry old_def_rt; /* Old default route */ 171 +static struct rtentry old_def_rt; /* Old default route */
172 +static int default_rt_repl_rest; /* replace and restore old default rt */ 172 +static int default_rt_repl_rest; /* replace and restore old default rt */
173 static u_int32_t proxy_arp_addr; /* Addr for proxy arp entry added */ 173 static u_int32_t proxy_arp_addr; /* Addr for proxy arp entry added */
174 static char proxy_arp_dev[16]; /* Device for proxy arp entry */ 174 static char proxy_arp_dev[16]; /* Device for proxy arp entry */
175 static u_int32_t our_old_addr; /* for detecting address changes */ 175 static u_int32_t our_old_addr; /* for detecting address changes */
176 @@ -1570,6 +1572,9 @@ static int read_route_table(struct rtent 176 @@ -1552,6 +1554,9 @@ static int read_route_table(struct rtent
177 p = NULL; 177 p = NULL;
178 } 178 }
Line 179... Line 179...
179 179
180 + SET_SA_FAMILY (rt->rt_dst, AF_INET); 180 + SET_SA_FAMILY (rt->rt_dst, AF_INET);
181 + SET_SA_FAMILY (rt->rt_gateway, AF_INET); 181 + SET_SA_FAMILY (rt->rt_gateway, AF_INET);
182 + 182 +
183 SIN_ADDR(rt->rt_dst) = strtoul(cols[route_dest_col], NULL, 16); 183 SIN_ADDR(rt->rt_dst) = strtoul(cols[route_dest_col], NULL, 16);
184 SIN_ADDR(rt->rt_gateway) = strtoul(cols[route_gw_col], NULL, 16); 184 SIN_ADDR(rt->rt_gateway) = strtoul(cols[route_gw_col], NULL, 16);
185 SIN_ADDR(rt->rt_genmask) = strtoul(cols[route_mask_col], NULL, 16); 185 SIN_ADDR(rt->rt_genmask) = strtoul(cols[route_mask_col], NULL, 16);
186 @@ -1642,20 +1647,52 @@ int have_route_to(u_int32_t addr) 186 @@ -1621,20 +1626,51 @@ int have_route_to(u_int32_t addr)
187 /******************************************************************** 187 /********************************************************************
188 * 188 *
189 * sifdefaultroute - assign a default route through the address given. 189 * sifdefaultroute - assign a default route through the address given.
190 - */ 190 - */
191 - 191 -
192 -int sifdefaultroute (int unit, u_int32_t ouraddr, u_int32_t gateway) 192 -int sifdefaultroute (int unit, u_int32_t ouraddr, u_int32_t gateway)
193 -{ 193 -{
194 - struct rtentry rt; 194 - struct rtentry rt;
195 - 195 -
196 - if (defaultroute_exists(&rt, dfl_route_metric) && strcmp(rt.rt_dev, ifname) != 0) { 196 - if (defaultroute_exists(&rt) && strcmp(rt.rt_dev, ifname) != 0) {
197 - if (rt.rt_flags & RTF_GATEWAY) 197 - if (rt.rt_flags & RTF_GATEWAY)
198 - error("not replacing existing default route via %I with metric %d", 198 - error("not replacing existing default route via %I",
199 - SIN_ADDR(rt.rt_gateway), dfl_route_metric); 199 - SIN_ADDR(rt.rt_gateway));
200 - else 200 - else
201 + * 201 + *
202 + * If the global default_rt_repl_rest flag is set, then this function 202 + * If the global default_rt_repl_rest flag is set, then this function
203 + * already replaced the original system defaultroute with some other 203 + * already replaced the original system defaultroute with some other
Line 216... Line 216...
216 + if (default_rt_repl_rest) { 216 + if (default_rt_repl_rest) {
217 + /* We have already reclaced the original defaultroute, if we 217 + /* We have already reclaced the original defaultroute, if we
218 + are called again, we will delete the current default route 218 + are called again, we will delete the current default route
219 + and set the new default route in this function. 219 + and set the new default route in this function.
220 + - this is normally only the case the doing demand: */ 220 + - this is normally only the case the doing demand: */
221 + if (defaultroute_exists(&tmp_rt, dfl_route_metric)) 221 + if (defaultroute_exists(&tmp_rt))
222 + del_rt = &tmp_rt; 222 + del_rt = &tmp_rt;
223 + } else if (defaultroute_exists(&old_def_rt, dfl_route_metric) && 223 + } else if (defaultroute_exists(&old_def_rt) &&
224 + strcmp(old_def_rt.rt_dev, ifname) != 0) { 224 + strcmp(old_def_rt.rt_dev, ifname) != 0) {
225 + /* We did not yet replace an existing default route, let's 225 + /* We did not yet replace an existing default route, let's
226 + check if we should save and replace a default route: */ 226 + check if we should save and replace a default route: */
227 + if (old_def_rt.rt_flags & RTF_GATEWAY) { 227 + if (old_def_rt.rt_flags & RTF_GATEWAY) {
228 + if (!replace) { 228 + if (!replace) {
229 + error("not replacing existing default route via %I with metric %d", 229 + error("not replacing existing default route via %I",
230 + SIN_ADDR(old_def_rt.rt_gateway), dfl_route_metric); 230 + SIN_ADDR(old_def_rt.rt_gateway));
231 + return 0; 231 + return 0;
232 + } else { 232 + } else {
233 + /* we need to copy rt_dev because we need it permanent too: */ 233 + /* we need to copy rt_dev because we need it permanent too: */
234 + char *tmp_dev = malloc(strlen(old_def_rt.rt_dev) + 1); 234 + char *tmp_dev = malloc(strlen(old_def_rt.rt_dev) + 1);
235 + strcpy(tmp_dev, old_def_rt.rt_dev); 235 + strcpy(tmp_dev, old_def_rt.rt_dev);
236 + old_def_rt.rt_dev = tmp_dev; 236 + old_def_rt.rt_dev = tmp_dev;
237 + 237 +
238 + notice("replacing old default route to %s [%I] with metric %d", 238 + notice("replacing old default route to %s [%I]",
239 + old_def_rt.rt_dev, SIN_ADDR(old_def_rt.rt_gateway), 239 + old_def_rt.rt_dev, SIN_ADDR(old_def_rt.rt_gateway));
240 + dfl_route_metric); -  
241 + default_rt_repl_rest = 1; 240 + default_rt_repl_rest = 1;
242 + del_rt = &old_def_rt; 241 + del_rt = &old_def_rt;
243 + } 242 + }
244 + } else 243 + } else
245 error("not replacing existing default route through %s with metric %d", 244 error("not replacing existing default route through %s",
246 - rt.rt_dev, dfl_route_metric); 245 - rt.rt_dev);
247 - return 0; 246 - return 0;
248 + old_def_rt.rt_dev, dfl_route_metric); 247 + old_def_rt.rt_dev);
249 } 248 }
Line 250... Line 249...
250 249
251 memset (&rt, 0, sizeof (rt)); 250 memset (&rt, 0, sizeof (rt));
Line 252... Line 251...
252 @@ -1671,10 +1708,16 @@ int sifdefaultroute (int unit, u_int32_t 251 @@ -1649,10 +1685,16 @@ int sifdefaultroute (int unit, u_int32_t
253 252
254 rt.rt_flags = RTF_UP; 253 rt.rt_flags = RTF_UP;
255 if (ioctl(sock_fd, SIOCADDRT, &rt) < 0) { 254 if (ioctl(sock_fd, SIOCADDRT, &rt) < 0) {
Line 265... Line 264...
265 + return 0; 264 + return 0;
266 + } 265 + }
Line 267... Line 266...
267 266
268 have_default_route = 1; 267 have_default_route = 1;
269 return 1; 268 return 1;
270 @@ -1708,11 +1751,21 @@ int cifdefaultroute (int unit, u_int32_t 269 @@ -1683,11 +1725,21 @@ int cifdefaultroute (int unit, u_int32_t
271 rt.rt_flags = RTF_UP; 270 rt.rt_flags = RTF_UP;
272 if (ioctl(sock_fd, SIOCDELRT, &rt) < 0 && errno != ESRCH) { 271 if (ioctl(sock_fd, SIOCDELRT, &rt) < 0 && errno != ESRCH) {
273 if (still_ppp()) { 272 if (still_ppp()) {
274 - if ( ! ok_error ( errno )) 273 - if ( ! ok_error ( errno ))