1 diff -Naur ppp-2.4.4.orig/pppd/ipcp.c ppp-2.4.4/pppd/ipcp.c
2 --- ppp-2.4.4.orig/pppd/ipcp.c 2009-05-09 02:55:46.000000000 -0400
3 +++ ppp-2.4.4/pppd/ipcp.c 2009-05-09 02:58:31.000000000 -0400
5 "disable defaultroute option", OPT_ALIAS | OPT_A2CLR,
6 &ipcp_wantoptions[0].default_route },
8 + { "replacedefaultroute", o_bool,
9 + &ipcp_wantoptions[0].replace_default_route,
10 + "Replace default route", 1
12 + { "noreplacedefaultroute", o_bool,
13 + &ipcp_allowoptions[0].replace_default_route,
14 + "Never replace default route", OPT_A2COPY,
15 + &ipcp_wantoptions[0].replace_default_route },
16 { "proxyarp", o_bool, &ipcp_wantoptions[0].proxy_arp,
17 "Add proxy ARP entry", OPT_ENABLE|1, &ipcp_allowoptions[0].proxy_arp },
18 { "noproxyarp", o_bool, &ipcp_allowoptions[0].proxy_arp,
23 -static void ipcp_clear_addrs __P((int, u_int32_t, u_int32_t));
24 +static void ipcp_clear_addrs __P((int, u_int32_t, u_int32_t, bool));
25 static void ipcp_script __P((char *, int)); /* Run an up/down script */
26 static void ipcp_script_done __P((void *));
29 if (!sifnpmode(u, PPP_IP, NPMODE_QUEUE))
31 if (wo->default_route)
32 - if (sifdefaultroute(u, wo->ouraddr, wo->hisaddr))
33 + if (sifdefaultroute(u, wo->ouraddr, wo->hisaddr,
34 + wo->replace_default_route))
35 default_route_set[u] = 1;
37 if (sifproxyarp(u, wo->hisaddr))
41 if (go->ouraddr != wo->ouraddr || ho->hisaddr != wo->hisaddr) {
42 - ipcp_clear_addrs(f->unit, wo->ouraddr, wo->hisaddr);
43 + ipcp_clear_addrs(f->unit, wo->ouraddr, wo->hisaddr,
44 + wo->replace_default_route);
45 if (go->ouraddr != wo->ouraddr) {
46 warn("Local IP address changed to %I", go->ouraddr);
47 script_setenv("OLDIPLOCAL", ip_ntoa(wo->ouraddr), 0);
50 /* assign a default route through the interface if required */
51 if (ipcp_wantoptions[f->unit].default_route)
52 - if (sifdefaultroute(f->unit, go->ouraddr, ho->hisaddr))
53 + if (sifdefaultroute(f->unit, go->ouraddr, ho->hisaddr,
54 + wo->replace_default_route))
55 default_route_set[f->unit] = 1;
57 /* Make a proxy ARP entry if requested. */
60 /* assign a default route through the interface if required */
61 if (ipcp_wantoptions[f->unit].default_route)
62 - if (sifdefaultroute(f->unit, go->ouraddr, ho->hisaddr))
63 + if (sifdefaultroute(f->unit, go->ouraddr, ho->hisaddr,
64 + wo->replace_default_route))
65 default_route_set[f->unit] = 1;
67 /* Make a proxy ARP entry if requested. */
69 sifnpmode(f->unit, PPP_IP, NPMODE_DROP);
71 ipcp_clear_addrs(f->unit, ipcp_gotoptions[f->unit].ouraddr,
72 - ipcp_hisoptions[f->unit].hisaddr);
73 + ipcp_hisoptions[f->unit].hisaddr, 0);
76 /* Execute the ip-down script */
77 @@ -1910,16 +1922,25 @@
78 * proxy arp entries, etc.
81 -ipcp_clear_addrs(unit, ouraddr, hisaddr)
82 +ipcp_clear_addrs(unit, ouraddr, hisaddr, replacedefaultroute)
84 u_int32_t ouraddr; /* local address */
85 u_int32_t hisaddr; /* remote address */
86 + bool replacedefaultroute;
88 if (proxy_arp_set[unit]) {
89 cifproxyarp(unit, hisaddr);
90 proxy_arp_set[unit] = 0;
92 - if (default_route_set[unit]) {
93 + /* If replacedefaultroute, sifdefaultroute will be called soon
94 + * with replacedefaultroute set and that will overwrite the current
95 + * default route. This is the case only when doing demand, otherwise
96 + * during demand, this cifdefaultroute would restore the old default
97 + * route which is not what we want in this case. In the non-demand
98 + * case, we'll delete the default route and restore the old if there
99 + * is one saved by an sifdefaultroute with replacedefaultroute.
101 + if (!replacedefaultroute && default_route_set[unit]) {
102 cifdefaultroute(unit, ouraddr, hisaddr);
103 default_route_set[unit] = 0;
105 diff -Naur ppp-2.4.4.orig/pppd/ipcp.h ppp-2.4.4/pppd/ipcp.h
106 --- ppp-2.4.4.orig/pppd/ipcp.h 2009-05-09 02:54:59.000000000 -0400
107 +++ ppp-2.4.4/pppd/ipcp.h 2009-05-09 02:58:31.000000000 -0400
109 bool old_addrs; /* Use old (IP-Addresses) option? */
110 bool req_addr; /* Ask peer to send IP address? */
111 bool default_route; /* Assign default route through interface? */
112 + bool replace_default_route; /* Replace default route through interface? */
113 bool proxy_arp; /* Make proxy ARP entry for peer? */
114 bool neg_vj; /* Van Jacobson Compression? */
115 bool old_vj; /* use old (short) form of VJ option? */
116 diff -Naur ppp-2.4.4.orig/pppd/pppd.8 ppp-2.4.4/pppd/pppd.8
117 --- ppp-2.4.4.orig/pppd/pppd.8 2009-05-09 02:54:59.000000000 -0400
118 +++ ppp-2.4.4/pppd/pppd.8 2009-05-09 02:58:31.000000000 -0400
120 This entry is removed when the PPP connection is broken. This option
121 is privileged if the \fInodefaultroute\fR option has been specified.
123 +.B replacedefaultroute
124 +This option is a flag to the defaultroute option. If defaultroute is
125 +set and this flag is also set, pppd replaces an existing default route
126 +with the new default route.
128 .B disconnect \fIscript
129 Execute the command specified by \fIscript\fR, by passing it to a
134 Disable the \fIdefaultroute\fR option. The system administrator who
135 -wishes to prevent users from creating default routes with pppd
136 +wishes to prevent users from adding a default route with pppd
137 +can do so by placing this option in the /etc/ppp/options file.
139 +.B noreplacedefaultroute
140 +Disable the \fIreplacedefaultroute\fR option. The system administrator who
141 +wishes to prevent users from replacing a default route with pppd
142 can do so by placing this option in the /etc/ppp/options file.
145 diff -Naur ppp-2.4.4.orig/pppd/pppd.h ppp-2.4.4/pppd/pppd.h
146 --- ppp-2.4.4.orig/pppd/pppd.h 2009-05-09 02:55:46.000000000 -0400
147 +++ ppp-2.4.4/pppd/pppd.h 2009-05-09 02:58:31.000000000 -0400
149 int cif6addr __P((int, eui64_t, eui64_t));
150 /* Remove an IPv6 address from i/f */
152 -int sifdefaultroute __P((int, u_int32_t, u_int32_t));
153 +int sifdefaultroute __P((int, u_int32_t, u_int32_t, bool replace_default_rt));
154 /* Create default route through i/f */
155 int cifdefaultroute __P((int, u_int32_t, u_int32_t));
156 /* Delete default route through i/f */
157 diff -Naur ppp-2.4.4.orig/pppd/sys-linux.c ppp-2.4.4/pppd/sys-linux.c
158 --- ppp-2.4.4.orig/pppd/sys-linux.c 2009-05-09 02:55:46.000000000 -0400
159 +++ ppp-2.4.4/pppd/sys-linux.c 2009-05-09 02:58:31.000000000 -0400
162 static int if_is_up; /* Interface has been marked up */
163 static int have_default_route; /* Gateway for default route added */
164 +static struct rtentry old_def_rt; /* Old default route */
165 +static int default_rt_repl_rest; /* replace and restore old default rt */
166 static u_int32_t proxy_arp_addr; /* Addr for proxy arp entry added */
167 static char proxy_arp_dev[16]; /* Device for proxy arp entry */
168 static u_int32_t our_old_addr; /* for detecting address changes */
169 @@ -1520,6 +1522,9 @@
173 + SET_SA_FAMILY (rt->rt_dst, AF_INET);
174 + SET_SA_FAMILY (rt->rt_gateway, AF_INET);
176 SIN_ADDR(rt->rt_dst) = strtoul(cols[route_dest_col], NULL, 16);
177 SIN_ADDR(rt->rt_gateway) = strtoul(cols[route_gw_col], NULL, 16);
178 SIN_ADDR(rt->rt_genmask) = strtoul(cols[route_mask_col], NULL, 16);
179 @@ -1589,20 +1594,51 @@
180 /********************************************************************
182 * sifdefaultroute - assign a default route through the address given.
185 -int sifdefaultroute (int unit, u_int32_t ouraddr, u_int32_t gateway)
189 - if (defaultroute_exists(&rt) && strcmp(rt.rt_dev, ifname) != 0) {
190 - if (rt.rt_flags & RTF_GATEWAY)
191 - error("not replacing existing default route via %I",
192 - SIN_ADDR(rt.rt_gateway));
195 + * If the global default_rt_repl_rest flag is set, then this function
196 + * already replaced the original system defaultroute with some other
197 + * route and it should just replace the current defaultroute with
198 + * another one, without saving the current route. Use: demand mode,
199 + * when pppd sets first a defaultroute it it's temporary ppp0 addresses
200 + * and then changes the temporary addresses to the addresses for the real
201 + * ppp connection when it has come up.
204 +int sifdefaultroute (int unit, u_int32_t ouraddr, u_int32_t gateway, bool replace)
206 + struct rtentry rt, tmp_rt;
207 + struct rtentry *del_rt = NULL;
209 + if (default_rt_repl_rest) {
210 + /* We have already reclaced the original defaultroute, if we
211 + are called again, we will delete the current default route
212 + and set the new default route in this function.
213 + - this is normally only the case the doing demand: */
214 + if (defaultroute_exists(&tmp_rt))
216 + } else if (defaultroute_exists(&old_def_rt) &&
217 + strcmp(old_def_rt.rt_dev, ifname) != 0) {
218 + /* We did not yet replace an existing default route, let's
219 + check if we should save and replace a default route: */
220 + if (old_def_rt.rt_flags & RTF_GATEWAY) {
222 + error("not replacing existing default route via %I",
223 + SIN_ADDR(old_def_rt.rt_gateway));
226 + /* we need to copy rt_dev because we need it permanent too: */
227 + char *tmp_dev = malloc(strlen(old_def_rt.rt_dev) + 1);
228 + strcpy(tmp_dev, old_def_rt.rt_dev);
229 + old_def_rt.rt_dev = tmp_dev;
231 + notice("replacing old default route to %s [%I]",
232 + old_def_rt.rt_dev, SIN_ADDR(old_def_rt.rt_gateway));
233 + default_rt_repl_rest = 1;
234 + del_rt = &old_def_rt;
237 error("not replacing existing default route through %s",
240 + old_def_rt.rt_dev);
243 memset (&rt, 0, sizeof (rt));
244 @@ -1617,10 +1653,16 @@
246 rt.rt_flags = RTF_UP;
247 if (ioctl(sock_fd, SIOCADDRT, &rt) < 0) {
248 - if ( ! ok_error ( errno ))
249 + if (!ok_error(errno))
250 error("default route ioctl(SIOCADDRT): %m");
253 + if (default_rt_repl_rest && del_rt)
254 + if (ioctl(sock_fd, SIOCDELRT, del_rt) < 0) {
255 + if (!ok_error(errno))
256 + error("del old default route ioctl(SIOCDELRT): %m");
260 have_default_route = 1;
262 @@ -1649,11 +1691,21 @@
263 rt.rt_flags = RTF_UP;
264 if (ioctl(sock_fd, SIOCDELRT, &rt) < 0 && errno != ESRCH) {
266 - if ( ! ok_error ( errno ))
267 + if (!ok_error(errno))
268 error("default route ioctl(SIOCDELRT): %m");
272 + if (default_rt_repl_rest) {
273 + notice("restoring old default route to %s [%I]",
274 + old_def_rt.rt_dev, SIN_ADDR(old_def_rt.rt_gateway));
275 + if (ioctl(sock_fd, SIOCADDRT, &old_def_rt) < 0) {
276 + if (!ok_error(errno))
277 + error("restore default route ioctl(SIOCADDRT): %m");
280 + default_rt_repl_rest = 0;
285 diff -Naur ppp-2.4.4.orig/pppd/sys-solaris.c ppp-2.4.4/pppd/sys-solaris.c
286 --- ppp-2.4.4.orig/pppd/sys-solaris.c 2009-05-09 02:54:59.000000000 -0400
287 +++ ppp-2.4.4/pppd/sys-solaris.c 2009-05-09 02:58:31.000000000 -0400
288 @@ -2036,12 +2036,18 @@
289 * sifdefaultroute - assign a default route through the address given.
292 -sifdefaultroute(u, l, g)
293 +sifdefaultroute(u, l, g, replace)
301 + error("replacedefaultroute not supported on this platform");
305 #if defined(__USLC__)
306 g = l; /* use the local address as gateway */
308 diff -Naur ppp-2.4.4.orig/pppd/ipcp.c ppp-2.4.4/pppd/ipcp.c
309 --- ppp-2.4.4.orig/pppd/ipcp.c 2009-05-09 02:55:46.000000000 -0400
310 +++ ppp-2.4.4/pppd/ipcp.c 2009-05-09 02:58:31.000000000 -0400
312 "disable defaultroute option", OPT_ALIAS | OPT_A2CLR,
313 &ipcp_wantoptions[0].default_route },
315 + { "replacedefaultroute", o_bool,
316 + &ipcp_wantoptions[0].replace_default_route,
317 + "Replace default route", 1
319 + { "noreplacedefaultroute", o_bool,
320 + &ipcp_allowoptions[0].replace_default_route,
321 + "Never replace default route", OPT_A2COPY,
322 + &ipcp_wantoptions[0].replace_default_route },
323 { "proxyarp", o_bool, &ipcp_wantoptions[0].proxy_arp,
324 "Add proxy ARP entry", OPT_ENABLE|1, &ipcp_allowoptions[0].proxy_arp },
325 { "noproxyarp", o_bool, &ipcp_allowoptions[0].proxy_arp,
330 -static void ipcp_clear_addrs __P((int, u_int32_t, u_int32_t));
331 +static void ipcp_clear_addrs __P((int, u_int32_t, u_int32_t, bool));
332 static void ipcp_script __P((char *, int)); /* Run an up/down script */
333 static void ipcp_script_done __P((void *));
335 @@ -1660,7 +1668,8 @@
336 if (!sifnpmode(u, PPP_IP, NPMODE_QUEUE))
338 if (wo->default_route)
339 - if (sifdefaultroute(u, wo->ouraddr, wo->hisaddr))
340 + if (sifdefaultroute(u, wo->ouraddr, wo->hisaddr,
341 + wo->replace_default_route))
342 default_route_set[u] = 1;
344 if (sifproxyarp(u, wo->hisaddr))
345 @@ -1742,7 +1751,8 @@
348 if (go->ouraddr != wo->ouraddr || ho->hisaddr != wo->hisaddr) {
349 - ipcp_clear_addrs(f->unit, wo->ouraddr, wo->hisaddr);
350 + ipcp_clear_addrs(f->unit, wo->ouraddr, wo->hisaddr,
351 + wo->replace_default_route);
352 if (go->ouraddr != wo->ouraddr) {
353 warn("Local IP address changed to %I", go->ouraddr);
354 script_setenv("OLDIPLOCAL", ip_ntoa(wo->ouraddr), 0);
355 @@ -1767,7 +1777,8 @@
357 /* assign a default route through the interface if required */
358 if (ipcp_wantoptions[f->unit].default_route)
359 - if (sifdefaultroute(f->unit, go->ouraddr, ho->hisaddr))
360 + if (sifdefaultroute(f->unit, go->ouraddr, ho->hisaddr,
361 + wo->replace_default_route))
362 default_route_set[f->unit] = 1;
364 /* Make a proxy ARP entry if requested. */
365 @@ -1817,7 +1828,8 @@
367 /* assign a default route through the interface if required */
368 if (ipcp_wantoptions[f->unit].default_route)
369 - if (sifdefaultroute(f->unit, go->ouraddr, ho->hisaddr))
370 + if (sifdefaultroute(f->unit, go->ouraddr, ho->hisaddr,
371 + wo->replace_default_route))
372 default_route_set[f->unit] = 1;
374 /* Make a proxy ARP entry if requested. */
375 @@ -1894,7 +1906,7 @@
376 sifnpmode(f->unit, PPP_IP, NPMODE_DROP);
378 ipcp_clear_addrs(f->unit, ipcp_gotoptions[f->unit].ouraddr,
379 - ipcp_hisoptions[f->unit].hisaddr);
380 + ipcp_hisoptions[f->unit].hisaddr, 0);
383 /* Execute the ip-down script */
384 @@ -1910,16 +1922,25 @@
385 * proxy arp entries, etc.
388 -ipcp_clear_addrs(unit, ouraddr, hisaddr)
389 +ipcp_clear_addrs(unit, ouraddr, hisaddr, replacedefaultroute)
391 u_int32_t ouraddr; /* local address */
392 u_int32_t hisaddr; /* remote address */
393 + bool replacedefaultroute;
395 if (proxy_arp_set[unit]) {
396 cifproxyarp(unit, hisaddr);
397 proxy_arp_set[unit] = 0;
399 - if (default_route_set[unit]) {
400 + /* If replacedefaultroute, sifdefaultroute will be called soon
401 + * with replacedefaultroute set and that will overwrite the current
402 + * default route. This is the case only when doing demand, otherwise
403 + * during demand, this cifdefaultroute would restore the old default
404 + * route which is not what we want in this case. In the non-demand
405 + * case, we'll delete the default route and restore the old if there
406 + * is one saved by an sifdefaultroute with replacedefaultroute.
408 + if (!replacedefaultroute && default_route_set[unit]) {
409 cifdefaultroute(unit, ouraddr, hisaddr);
410 default_route_set[unit] = 0;
412 diff -Naur ppp-2.4.4.orig/pppd/ipcp.h ppp-2.4.4/pppd/ipcp.h
413 --- ppp-2.4.4.orig/pppd/ipcp.h 2009-05-09 02:54:59.000000000 -0400
414 +++ ppp-2.4.4/pppd/ipcp.h 2009-05-09 02:58:31.000000000 -0400
416 bool old_addrs; /* Use old (IP-Addresses) option? */
417 bool req_addr; /* Ask peer to send IP address? */
418 bool default_route; /* Assign default route through interface? */
419 + bool replace_default_route; /* Replace default route through interface? */
420 bool proxy_arp; /* Make proxy ARP entry for peer? */
421 bool neg_vj; /* Van Jacobson Compression? */
422 bool old_vj; /* use old (short) form of VJ option? */
423 diff -Naur ppp-2.4.4.orig/pppd/pppd.8 ppp-2.4.4/pppd/pppd.8
424 --- ppp-2.4.4.orig/pppd/pppd.8 2009-05-09 02:54:59.000000000 -0400
425 +++ ppp-2.4.4/pppd/pppd.8 2009-05-09 02:58:31.000000000 -0400
427 This entry is removed when the PPP connection is broken. This option
428 is privileged if the \fInodefaultroute\fR option has been specified.
430 +.B replacedefaultroute
431 +This option is a flag to the defaultroute option. If defaultroute is
432 +set and this flag is also set, pppd replaces an existing default route
433 +with the new default route.
435 .B disconnect \fIscript
436 Execute the command specified by \fIscript\fR, by passing it to a
441 Disable the \fIdefaultroute\fR option. The system administrator who
442 -wishes to prevent users from creating default routes with pppd
443 +wishes to prevent users from adding a default route with pppd
444 +can do so by placing this option in the /etc/ppp/options file.
446 +.B noreplacedefaultroute
447 +Disable the \fIreplacedefaultroute\fR option. The system administrator who
448 +wishes to prevent users from replacing a default route with pppd
449 can do so by placing this option in the /etc/ppp/options file.
452 diff -Naur ppp-2.4.4.orig/pppd/pppd.h ppp-2.4.4/pppd/pppd.h
453 --- ppp-2.4.4.orig/pppd/pppd.h 2009-05-09 02:55:46.000000000 -0400
454 +++ ppp-2.4.4/pppd/pppd.h 2009-05-09 02:58:31.000000000 -0400
456 int cif6addr __P((int, eui64_t, eui64_t));
457 /* Remove an IPv6 address from i/f */
459 -int sifdefaultroute __P((int, u_int32_t, u_int32_t));
460 +int sifdefaultroute __P((int, u_int32_t, u_int32_t, bool replace_default_rt));
461 /* Create default route through i/f */
462 int cifdefaultroute __P((int, u_int32_t, u_int32_t));
463 /* Delete default route through i/f */
464 diff -Naur ppp-2.4.4.orig/pppd/sys-linux.c ppp-2.4.4/pppd/sys-linux.c
465 --- ppp-2.4.4.orig/pppd/sys-linux.c 2009-05-09 02:55:46.000000000 -0400
466 +++ ppp-2.4.4/pppd/sys-linux.c 2009-05-09 02:58:31.000000000 -0400
469 static int if_is_up; /* Interface has been marked up */
470 static int have_default_route; /* Gateway for default route added */
471 +static struct rtentry old_def_rt; /* Old default route */
472 +static int default_rt_repl_rest; /* replace and restore old default rt */
473 static u_int32_t proxy_arp_addr; /* Addr for proxy arp entry added */
474 static char proxy_arp_dev[16]; /* Device for proxy arp entry */
475 static u_int32_t our_old_addr; /* for detecting address changes */
476 @@ -1520,6 +1522,9 @@
480 + SET_SA_FAMILY (rt->rt_dst, AF_INET);
481 + SET_SA_FAMILY (rt->rt_gateway, AF_INET);
483 SIN_ADDR(rt->rt_dst) = strtoul(cols[route_dest_col], NULL, 16);
484 SIN_ADDR(rt->rt_gateway) = strtoul(cols[route_gw_col], NULL, 16);
485 SIN_ADDR(rt->rt_genmask) = strtoul(cols[route_mask_col], NULL, 16);
486 @@ -1589,20 +1594,51 @@
487 /********************************************************************
489 * sifdefaultroute - assign a default route through the address given.
492 -int sifdefaultroute (int unit, u_int32_t ouraddr, u_int32_t gateway)
496 - if (defaultroute_exists(&rt) && strcmp(rt.rt_dev, ifname) != 0) {
497 - if (rt.rt_flags & RTF_GATEWAY)
498 - error("not replacing existing default route via %I",
499 - SIN_ADDR(rt.rt_gateway));
502 + * If the global default_rt_repl_rest flag is set, then this function
503 + * already replaced the original system defaultroute with some other
504 + * route and it should just replace the current defaultroute with
505 + * another one, without saving the current route. Use: demand mode,
506 + * when pppd sets first a defaultroute it it's temporary ppp0 addresses
507 + * and then changes the temporary addresses to the addresses for the real
508 + * ppp connection when it has come up.
511 +int sifdefaultroute (int unit, u_int32_t ouraddr, u_int32_t gateway, bool replace)
513 + struct rtentry rt, tmp_rt;
514 + struct rtentry *del_rt = NULL;
516 + if (default_rt_repl_rest) {
517 + /* We have already reclaced the original defaultroute, if we
518 + are called again, we will delete the current default route
519 + and set the new default route in this function.
520 + - this is normally only the case the doing demand: */
521 + if (defaultroute_exists(&tmp_rt))
523 + } else if (defaultroute_exists(&old_def_rt) &&
524 + strcmp(old_def_rt.rt_dev, ifname) != 0) {
525 + /* We did not yet replace an existing default route, let's
526 + check if we should save and replace a default route: */
527 + if (old_def_rt.rt_flags & RTF_GATEWAY) {
529 + error("not replacing existing default route via %I",
530 + SIN_ADDR(old_def_rt.rt_gateway));
533 + /* we need to copy rt_dev because we need it permanent too: */
534 + char *tmp_dev = malloc(strlen(old_def_rt.rt_dev) + 1);
535 + strcpy(tmp_dev, old_def_rt.rt_dev);
536 + old_def_rt.rt_dev = tmp_dev;
538 + notice("replacing old default route to %s [%I]",
539 + old_def_rt.rt_dev, SIN_ADDR(old_def_rt.rt_gateway));
540 + default_rt_repl_rest = 1;
541 + del_rt = &old_def_rt;
544 error("not replacing existing default route through %s",
547 + old_def_rt.rt_dev);
550 memset (&rt, 0, sizeof (rt));
551 @@ -1617,10 +1653,16 @@
553 rt.rt_flags = RTF_UP;
554 if (ioctl(sock_fd, SIOCADDRT, &rt) < 0) {
555 - if ( ! ok_error ( errno ))
556 + if (!ok_error(errno))
557 error("default route ioctl(SIOCADDRT): %m");
560 + if (default_rt_repl_rest && del_rt)
561 + if (ioctl(sock_fd, SIOCDELRT, del_rt) < 0) {
562 + if (!ok_error(errno))
563 + error("del old default route ioctl(SIOCDELRT): %m");
567 have_default_route = 1;
569 @@ -1649,11 +1691,21 @@
570 rt.rt_flags = RTF_UP;
571 if (ioctl(sock_fd, SIOCDELRT, &rt) < 0 && errno != ESRCH) {
573 - if ( ! ok_error ( errno ))
574 + if (!ok_error(errno))
575 error("default route ioctl(SIOCDELRT): %m");
579 + if (default_rt_repl_rest) {
580 + notice("restoring old default route to %s [%I]",
581 + old_def_rt.rt_dev, SIN_ADDR(old_def_rt.rt_gateway));
582 + if (ioctl(sock_fd, SIOCADDRT, &old_def_rt) < 0) {
583 + if (!ok_error(errno))
584 + error("restore default route ioctl(SIOCADDRT): %m");
587 + default_rt_repl_rest = 0;
592 diff -Naur ppp-2.4.4.orig/pppd/sys-solaris.c ppp-2.4.4/pppd/sys-solaris.c
593 --- ppp-2.4.4.orig/pppd/sys-solaris.c 2009-05-09 02:54:59.000000000 -0400
594 +++ ppp-2.4.4/pppd/sys-solaris.c 2009-05-09 02:58:31.000000000 -0400
595 @@ -2036,12 +2036,18 @@
596 * sifdefaultroute - assign a default route through the address given.
599 -sifdefaultroute(u, l, g)
600 +sifdefaultroute(u, l, g, replace)
608 + error("replacedefaultroute not supported on this platform");
612 #if defined(__USLC__)
613 g = l; /* use the local address as gateway */