View | Details | Raw Unified | Return to bug 9256
Collapse All | Expand All

(-)ppp-2.4.4-orig/pppd/ipcp.c (-8 / +29 lines)
Lines 197-202 Link Here
197
      "disable defaultroute option", OPT_ALIAS | OPT_A2CLR,
197
      "disable defaultroute option", OPT_ALIAS | OPT_A2CLR,
198
      &ipcp_wantoptions[0].default_route },
198
      &ipcp_wantoptions[0].default_route },
199
199
200
    { "replacedefaultroute", o_bool,
201
				&ipcp_wantoptions[0].replace_default_route,
202
      "Replace default route", 1
203
    },
204
    { "noreplacedefaultroute", o_bool,
205
				&ipcp_allowoptions[0].replace_default_route,
206
      "Never replace default route", OPT_A2COPY,
207
				&ipcp_wantoptions[0].replace_default_route },
200
    { "proxyarp", o_bool, &ipcp_wantoptions[0].proxy_arp,
208
    { "proxyarp", o_bool, &ipcp_wantoptions[0].proxy_arp,
201
      "Add proxy ARP entry", OPT_ENABLE|1, &ipcp_allowoptions[0].proxy_arp },
209
      "Add proxy ARP entry", OPT_ENABLE|1, &ipcp_allowoptions[0].proxy_arp },
202
    { "noproxyarp", o_bool, &ipcp_allowoptions[0].proxy_arp,
210
    { "noproxyarp", o_bool, &ipcp_allowoptions[0].proxy_arp,
Lines 263-269 Link Here
263
    ip_active_pkt
271
    ip_active_pkt
264
};
272
};
265
273
266
static void ipcp_clear_addrs __P((int, u_int32_t, u_int32_t));
274
static void ipcp_clear_addrs __P((int, u_int32_t, u_int32_t, bool));
267
static void ipcp_script __P((char *, int));	/* Run an up/down script */
275
static void ipcp_script __P((char *, int));	/* Run an up/down script */
268
static void ipcp_script_done __P((void *));
276
static void ipcp_script_done __P((void *));
269
277
Lines 1660-1666 Link Here
1660
    if (!sifnpmode(u, PPP_IP, NPMODE_QUEUE))
1668
    if (!sifnpmode(u, PPP_IP, NPMODE_QUEUE))
1661
	return 0;
1669
	return 0;
1662
    if (wo->default_route)
1670
    if (wo->default_route)
1663
	if (sifdefaultroute(u, wo->ouraddr, wo->hisaddr))
1671
	if (sifdefaultroute(u, wo->ouraddr, wo->hisaddr,
1672
		wo->replace_default_route))
1664
	    default_route_set[u] = 1;
1673
	    default_route_set[u] = 1;
1665
    if (wo->proxy_arp)
1674
    if (wo->proxy_arp)
1666
	if (sifproxyarp(u, wo->hisaddr))
1675
	if (sifproxyarp(u, wo->hisaddr))
Lines 1742-1748 Link Here
1742
     */
1751
     */
1743
    if (demand) {
1752
    if (demand) {
1744
	if (go->ouraddr != wo->ouraddr || ho->hisaddr != wo->hisaddr) {
1753
	if (go->ouraddr != wo->ouraddr || ho->hisaddr != wo->hisaddr) {
1745
	    ipcp_clear_addrs(f->unit, wo->ouraddr, wo->hisaddr);
1754
	    ipcp_clear_addrs(f->unit, wo->ouraddr, wo->hisaddr,
1755
				      wo->replace_default_route);
1746
	    if (go->ouraddr != wo->ouraddr) {
1756
	    if (go->ouraddr != wo->ouraddr) {
1747
		warn("Local IP address changed to %I", go->ouraddr);
1757
		warn("Local IP address changed to %I", go->ouraddr);
1748
		script_setenv("OLDIPLOCAL", ip_ntoa(wo->ouraddr), 0);
1758
		script_setenv("OLDIPLOCAL", ip_ntoa(wo->ouraddr), 0);
Lines 1767-1773 Link Here
1767
1777
1768
	    /* assign a default route through the interface if required */
1778
	    /* assign a default route through the interface if required */
1769
	    if (ipcp_wantoptions[f->unit].default_route) 
1779
	    if (ipcp_wantoptions[f->unit].default_route) 
1770
		if (sifdefaultroute(f->unit, go->ouraddr, ho->hisaddr))
1780
		if (sifdefaultroute(f->unit, go->ouraddr, ho->hisaddr,
1781
			wo->replace_default_route))
1771
		    default_route_set[f->unit] = 1;
1782
		    default_route_set[f->unit] = 1;
1772
1783
1773
	    /* Make a proxy ARP entry if requested. */
1784
	    /* Make a proxy ARP entry if requested. */
Lines 1817-1823 Link Here
1817
1828
1818
	/* assign a default route through the interface if required */
1829
	/* assign a default route through the interface if required */
1819
	if (ipcp_wantoptions[f->unit].default_route) 
1830
	if (ipcp_wantoptions[f->unit].default_route) 
1820
	    if (sifdefaultroute(f->unit, go->ouraddr, ho->hisaddr))
1831
	    if (sifdefaultroute(f->unit, go->ouraddr, ho->hisaddr,
1832
		    wo->replace_default_route))
1821
		default_route_set[f->unit] = 1;
1833
		default_route_set[f->unit] = 1;
1822
1834
1823
	/* Make a proxy ARP entry if requested. */
1835
	/* Make a proxy ARP entry if requested. */
Lines 1894-1900 Link Here
1894
	sifnpmode(f->unit, PPP_IP, NPMODE_DROP);
1906
	sifnpmode(f->unit, PPP_IP, NPMODE_DROP);
1895
	sifdown(f->unit);
1907
	sifdown(f->unit);
1896
	ipcp_clear_addrs(f->unit, ipcp_gotoptions[f->unit].ouraddr,
1908
	ipcp_clear_addrs(f->unit, ipcp_gotoptions[f->unit].ouraddr,
1897
			 ipcp_hisoptions[f->unit].hisaddr);
1909
			 ipcp_hisoptions[f->unit].hisaddr, 0);
1898
    }
1910
    }
1899
1911
1900
    /* Execute the ip-down script */
1912
    /* Execute the ip-down script */
Lines 1910-1925 Link Here
1910
 * proxy arp entries, etc.
1922
 * proxy arp entries, etc.
1911
 */
1923
 */
1912
static void
1924
static void
1913
ipcp_clear_addrs(unit, ouraddr, hisaddr)
1925
ipcp_clear_addrs(unit, ouraddr, hisaddr, replacedefaultroute)
1914
    int unit;
1926
    int unit;
1915
    u_int32_t ouraddr;  /* local address */
1927
    u_int32_t ouraddr;  /* local address */
1916
    u_int32_t hisaddr;  /* remote address */
1928
    u_int32_t hisaddr;  /* remote address */
1929
    bool replacedefaultroute;
1917
{
1930
{
1918
    if (proxy_arp_set[unit]) {
1931
    if (proxy_arp_set[unit]) {
1919
	cifproxyarp(unit, hisaddr);
1932
	cifproxyarp(unit, hisaddr);
1920
	proxy_arp_set[unit] = 0;
1933
	proxy_arp_set[unit] = 0;
1921
    }
1934
    }
1922
    if (default_route_set[unit]) {
1935
    /* If replacedefaultroute, sifdefaultroute will be called soon
1936
     * with replacedefaultroute set and that will overwrite the current
1937
     * default route. This is the case only when doing demand, otherwise
1938
     * during demand, this cifdefaultroute would restore the old default
1939
     * route which is not what we want in this case. In the non-demand
1940
     * case, we'll delete the default route and restore the old if there
1941
     * is one saved by an sifdefaultroute with replacedefaultroute.
1942
     */
1943
    if (!replacedefaultroute && default_route_set[unit]) {
1923
	cifdefaultroute(unit, ouraddr, hisaddr);
1944
	cifdefaultroute(unit, ouraddr, hisaddr);
1924
	default_route_set[unit] = 0;
1945
	default_route_set[unit] = 0;
1925
    }
1946
    }
(-)ppp-2.4.4-orig/pppd/ipcp.h (+1 lines)
Lines 70-75 Link Here
70
    bool old_addrs;		/* Use old (IP-Addresses) option? */
70
    bool old_addrs;		/* Use old (IP-Addresses) option? */
71
    bool req_addr;		/* Ask peer to send IP address? */
71
    bool req_addr;		/* Ask peer to send IP address? */
72
    bool default_route;		/* Assign default route through interface? */
72
    bool default_route;		/* Assign default route through interface? */
73
    bool replace_default_route;	/* Replace default route through interface? */
73
    bool proxy_arp;		/* Make proxy ARP entry for peer? */
74
    bool proxy_arp;		/* Make proxy ARP entry for peer? */
74
    bool neg_vj;		/* Van Jacobson Compression? */
75
    bool neg_vj;		/* Van Jacobson Compression? */
75
    bool old_vj;		/* use old (short) form of VJ option? */
76
    bool old_vj;		/* use old (short) form of VJ option? */
(-)ppp-2.4.4-orig/pppd/pppd.8 (-1 / +11 lines)
Lines 121-126 Link Here
121
This entry is removed when the PPP connection is broken.  This option
121
This entry is removed when the PPP connection is broken.  This option
122
is privileged if the \fInodefaultroute\fR option has been specified.
122
is privileged if the \fInodefaultroute\fR option has been specified.
123
.TP
123
.TP
124
.B replacedefaultroute
125
This option is a flag to the defaultroute option. If defaultroute is
126
set and this flag is also set, pppd replaces an existing default route
127
with the new default route.
128
.TP
124
.B disconnect \fIscript
129
.B disconnect \fIscript
125
Execute the command specified by \fIscript\fR, by passing it to a
130
Execute the command specified by \fIscript\fR, by passing it to a
126
shell, after
131
shell, after
Lines 706-712 Link Here
706
.TP
711
.TP
707
.B nodefaultroute
712
.B nodefaultroute
708
Disable the \fIdefaultroute\fR option.  The system administrator who
713
Disable the \fIdefaultroute\fR option.  The system administrator who
709
wishes to prevent users from creating default routes with pppd
714
wishes to prevent users from adding a default route with pppd
715
can do so by placing this option in the /etc/ppp/options file.
716
.TP
717
.B noreplacedefaultroute
718
Disable the \fIreplacedefaultroute\fR option. The system administrator who
719
wishes to prevent users from replacing a default route with pppd
710
can do so by placing this option in the /etc/ppp/options file.
720
can do so by placing this option in the /etc/ppp/options file.
711
.TP
721
.TP
712
.B nodeflate
722
.B nodeflate
(-)ppp-2.4.4-orig/pppd/pppd.h (-1 / +1 lines)
Lines 642-648 Link Here
642
int  cif6addr __P((int, eui64_t, eui64_t));
642
int  cif6addr __P((int, eui64_t, eui64_t));
643
				/* Remove an IPv6 address from i/f */
643
				/* Remove an IPv6 address from i/f */
644
#endif
644
#endif
645
int  sifdefaultroute __P((int, u_int32_t, u_int32_t));
645
int  sifdefaultroute __P((int, u_int32_t, u_int32_t, bool replace_default_rt));
646
				/* Create default route through i/f */
646
				/* Create default route through i/f */
647
int  cifdefaultroute __P((int, u_int32_t, u_int32_t));
647
int  cifdefaultroute __P((int, u_int32_t, u_int32_t));
648
				/* Delete default route through i/f */
648
				/* Delete default route through i/f */
(-)ppp-2.4.4-orig/pppd/sys-linux.c (-15 / +67 lines)
Lines 206-211 Link Here
206
206
207
static int	if_is_up;	/* Interface has been marked up */
207
static int	if_is_up;	/* Interface has been marked up */
208
static int	have_default_route;	/* Gateway for default route added */
208
static int	have_default_route;	/* Gateway for default route added */
209
static struct	rtentry old_def_rt;	/* Old default route */
210
static int	default_rt_repl_rest;	/* replace and restore old default rt */
209
static u_int32_t proxy_arp_addr;	/* Addr for proxy arp entry added */
211
static u_int32_t proxy_arp_addr;	/* Addr for proxy arp entry added */
210
static char proxy_arp_dev[16];		/* Device for proxy arp entry */
212
static char proxy_arp_dev[16];		/* Device for proxy arp entry */
211
static u_int32_t our_old_addr;		/* for detecting address changes */
213
static u_int32_t our_old_addr;		/* for detecting address changes */
Lines 1513-1518 Link Here
1513
	p = NULL;
1515
	p = NULL;
1514
    }
1516
    }
1515
1517
1518
    SET_SA_FAMILY (rt->rt_dst,     AF_INET);
1519
    SET_SA_FAMILY (rt->rt_gateway, AF_INET);
1520
1516
    SIN_ADDR(rt->rt_dst) = strtoul(cols[route_dest_col], NULL, 16);
1521
    SIN_ADDR(rt->rt_dst) = strtoul(cols[route_dest_col], NULL, 16);
1517
    SIN_ADDR(rt->rt_gateway) = strtoul(cols[route_gw_col], NULL, 16);
1522
    SIN_ADDR(rt->rt_gateway) = strtoul(cols[route_gw_col], NULL, 16);
1518
    SIN_ADDR(rt->rt_genmask) = strtoul(cols[route_mask_col], NULL, 16);
1523
    SIN_ADDR(rt->rt_genmask) = strtoul(cols[route_mask_col], NULL, 16);
Lines 1582-1601 Link Here
1582
/********************************************************************
1587
/********************************************************************
1583
 *
1588
 *
1584
 * sifdefaultroute - assign a default route through the address given.
1589
 * sifdefaultroute - assign a default route through the address given.
1585
 */
1590
 *
1586
1591
 * If the global default_rt_repl_rest flag is set, then this function
1587
int sifdefaultroute (int unit, u_int32_t ouraddr, u_int32_t gateway)
1592
 * already replaced the original system defaultroute with some other
1588
{
1593
 * route and it should just replace the current defaultroute with
1589
    struct rtentry rt;
1594
 * another one, without saving the current route. Use: demand mode,
1590
1595
 * when pppd sets first a defaultroute it it's temporary ppp0 addresses
1591
    if (defaultroute_exists(&rt) && strcmp(rt.rt_dev, ifname) != 0) {
1596
 * and then changes the temporary addresses to the addresses for the real
1592
	if (rt.rt_flags & RTF_GATEWAY)
1597
 * ppp connection when it has come up.
1593
	    error("not replacing existing default route via %I",
1598
 */
1594
		  SIN_ADDR(rt.rt_gateway));
1599
1595
	else
1600
int sifdefaultroute (int unit, u_int32_t ouraddr, u_int32_t gateway, bool replace)
1601
{
1602
    struct rtentry rt, tmp_rt;
1603
    struct rtentry *del_rt = NULL;
1604
1605
    if (default_rt_repl_rest) {
1606
	/* We have already replaced the original defaultroute, if we
1607
	   are called again, we will delete the current default route
1608
	   and set the new default route in this function.
1609
	   - this is normally only the case the doing demand: */
1610
	if (defaultroute_exists(&tmp_rt))
1611
	    del_rt = &tmp_rt;
1612
    } else if (defaultroute_exists(&old_def_rt) &&
1613
	       strcmp(old_def_rt.rt_dev, ifname) != 0) {
1614
	/* We did not yet replace an existing default route, let's
1615
	   check if we should save and replace a default route: */
1616
	if (old_def_rt.rt_flags & RTF_GATEWAY) {
1617
	    if (!replace) {
1618
		error("not replacing existing default route via %I",
1619
		      SIN_ADDR(old_def_rt.rt_gateway));
1620
		return 0;
1621
	    } else {
1622
		/* we need to copy rt_dev because we need it permanent too: */
1623
		char *tmp_dev = malloc(strlen(old_def_rt.rt_dev) + 1);
1624
		strcpy(tmp_dev, old_def_rt.rt_dev);
1625
		old_def_rt.rt_dev = tmp_dev;
1626
1627
		notice("replacing old default route to %s [%I]",
1628
			old_def_rt.rt_dev, SIN_ADDR(old_def_rt.rt_gateway));
1629
		default_rt_repl_rest = 1;
1630
		del_rt = &old_def_rt;
1631
	    }
1632
	} else
1596
	    error("not replacing existing default route through %s",
1633
	    error("not replacing existing default route through %s",
1597
		  rt.rt_dev);
1634
		  old_def_rt.rt_dev);
1598
	return 0;
1599
    }
1635
    }
1600
1636
1601
    memset (&rt, 0, sizeof (rt));
1637
    memset (&rt, 0, sizeof (rt));
Lines 1610-1619 Link Here
1610
1646
1611
    rt.rt_flags = RTF_UP;
1647
    rt.rt_flags = RTF_UP;
1612
    if (ioctl(sock_fd, SIOCADDRT, &rt) < 0) {
1648
    if (ioctl(sock_fd, SIOCADDRT, &rt) < 0) {
1613
	if ( ! ok_error ( errno ))
1649
	if (!ok_error(errno))
1614
	    error("default route ioctl(SIOCADDRT): %m");
1650
	    error("default route ioctl(SIOCADDRT): %m");
1615
	return 0;
1651
	return 0;
1616
    }
1652
    }
1653
    if (default_rt_repl_rest && del_rt)
1654
        if (ioctl(sock_fd, SIOCDELRT, del_rt) < 0) {
1655
	    if (!ok_error(errno))
1656
	        error("del old default route ioctl(SIOCDELRT): %m");
1657
	    return 0;
1658
        }
1617
1659
1618
    have_default_route = 1;
1660
    have_default_route = 1;
1619
    return 1;
1661
    return 1;
Lines 1642-1652 Link Here
1642
    rt.rt_flags = RTF_UP;
1684
    rt.rt_flags = RTF_UP;
1643
    if (ioctl(sock_fd, SIOCDELRT, &rt) < 0 && errno != ESRCH) {
1685
    if (ioctl(sock_fd, SIOCDELRT, &rt) < 0 && errno != ESRCH) {
1644
	if (still_ppp()) {
1686
	if (still_ppp()) {
1645
	    if ( ! ok_error ( errno ))
1687
	    if (!ok_error(errno))
1646
		error("default route ioctl(SIOCDELRT): %m");
1688
		error("default route ioctl(SIOCDELRT): %m");
1647
	    return 0;
1689
	    return 0;
1648
	}
1690
	}
1649
    }
1691
    }
1692
    if (default_rt_repl_rest) {
1693
	notice("restoring old default route to %s [%I]",
1694
		old_def_rt.rt_dev, SIN_ADDR(old_def_rt.rt_gateway));
1695
        if (ioctl(sock_fd, SIOCADDRT, &old_def_rt) < 0) {
1696
	    if (!ok_error(errno))
1697
	        error("restore default route ioctl(SIOCADDRT): %m");
1698
	    return 0;
1699
        }
1700
        default_rt_repl_rest = 0;
1701
    }
1650
1702
1651
    return 1;
1703
    return 1;
1652
}
1704
}
(-)ppp-2.4.4-orig/pppd/sys-solaris.c (-1 / +7 lines)
Lines 2036-2047 Link Here
2036
 * sifdefaultroute - assign a default route through the address given.
2036
 * sifdefaultroute - assign a default route through the address given.
2037
 */
2037
 */
2038
int
2038
int
2039
sifdefaultroute(u, l, g)
2039
sifdefaultroute(u, l, g, replace)
2040
    int u;
2040
    int u;
2041
    u_int32_t l, g;
2041
    u_int32_t l, g;
2042
    bool replace;
2042
{
2043
{
2043
    struct rtentry rt;
2044
    struct rtentry rt;
2044
2045
2046
    if (replace) {
2047
	error("replacedefaultroute not supported on this platform");
2048
	return 0;
2049
    }
2050
2045
#if defined(__USLC__)
2051
#if defined(__USLC__)
2046
    g = l;			/* use the local address as gateway */
2052
    g = l;			/* use the local address as gateway */
2047
#endif
2053
#endif

Return to bug 9256