On Mon, Apr 02, 2001 at 06:52:00PM +0200, Alexander Leidinger wrote:
> On 31 Mar, Ruslan Ermilov wrote:
> 
> [-isdn CCed,]
> 
> Dear -isdn readers, we are talking about the actual behavior of
> -current, see -current and -net for the beginning of the discussion.
> 
> >> >> If I use
> >> >>   route add default -interface isp1
> >> >> I wan't to have the packets routed trough isp1. I don't care about how
> >> >> the routing table is held consistent, but I if the route is discarded
> >> >> without my interaction it not only violates POLA, in this case it's
> >> >> prohibits a valid use of the -interface feature (dial on demand via sppp
> >> >> is broken at the moment).
> >> >> 
> >> > OK, finally got it.  When the interface goes down, the address is still
> >> > valid, and there is no reason to delete (static?) routes that use this
> >> > address, but the new code does.  I was confused by the code comment below
> >> 
> >> I didn't have a static IP address. The only static thing in this context
> >> is the interface the defaultroute is assigned to. At every
> >> dial-on-demand I get another IP.
> >> 
> > Well, if address is deleted from an interface, all routes that use it
> > will be invalidated (deleted) to avoid using the wrong address.  This
> > patch only fixes interface down/up case, when address does not change.
> 
> If "isp1" is a valid address in this context: it doesn't change.
> 
Nope, "isp1" is not an address, it is the pointer to an interface.
Routing table entry has both pointer to an interface, and a pointer
to one of its addresses.  That is what you see in the output from
``route -vn get default'' command, as IFP and IFA sockaddrs.

> Here a little bit of cut&paste (your "#if 0" patch is applied)
> which perhaps gives you a hint what I have here:
> ---snip---
> (3) netchild@ttyp1 % ifconfig isp1
> isp1: flags=a010<POINTOPOINT,LINK1,MULTICAST> mtu 1500
>         inet 0.0.0.0 --> 0.0.0.1 netmask 0xffff0000 
>         ether 00:00:00:00:00:00
> 
> (4) netchild@ttyp1 % netstat -rn
> Routing tables
> 
> Internet:
> Destination        Gateway            Flags     Refs     Use     Netif Expire
> default            0:0:0:0:0:0        USc         0        1     isp1
> 0.0.0.1            0.0.0.0            UH          0        0     isp1
> 127.0.0.1          127.0.0.1          UH          2     4613      lo0
> 192.168.1          link#1             UC          1        0      ed0 =>
> 
> (5) netchild@ttyp1 % isdn-up   # this is a SUID wrapper for "ifconfig isp1 up"
> 
> (6) netchild@ttyp1 % ifconfig isp1
> isp1: flags=a011<UP,POINTOPOINT,LINK1,MULTICAST> mtu 1500
>         inet 0.0.0.0 --> 0.0.0.1 netmask 0xffff0000 
>         ether 00:00:00:00:00:00 
> 
> (7) netchild@ttyp1 % netstat -rn  
> Routing tables
> 
> Internet:
> Destination        Gateway            Flags     Refs     Use     Netif Expire
> default            0:0:0:0:0:0        USc         0        1     isp1
> 0.0.0.1            0.0.0.0            UH          0        0     isp1
> 0.0.0.2            0.0.0.0            UH          0        0     isp0
> 127.0.0.1          127.0.0.1          UH          2     4613      lo0
> 192.168.1          link#1             UC          1        0      ed0 =>
> ---snip---
> 
> isp1 gets a new IP address after the ppp negotiation of sppp/isdnd.
> 0.0.0.0 -> 0.0.0.1 uses a documented hack in the i4b stack which
> discards the first packet to don't let go a packet with a wrong address
> (0.0.0.0) out of the computer. After a timeout or an "ifconfig isp1
> down" it hangs up and the dynamic IP address of isp1 get's replaced by
> 0.0.0.0 again. The actual behavior of -current breaks the documented way
> of enabling dial-on-demand with sppp/isdnd.
> (To -isdn readers: after the first "ifconfig isp1 down" the defaultroute
> vanishes, after a manual "route add default -interface isp1" the route
> stays even with subsequent "ifconfig isp1 down", doing an additional
> "route add ..." is annoying, needs additional privileges and violates
> POLA)
> 
OK, we fixed the "ifconfig down" case already.  The attached patch alters
inet routing code so that it does not delete routes with the "default"
source address of 0.0.0.0; ip_output() will take care of choosing the
right address.  Please let me know if it works for you.


Cheers,
-- 
Ruslan Ermilov          Oracle Developer/DBA,
[EMAIL PROTECTED]           Sunbay Software AG,
[EMAIL PROTECTED]          FreeBSD committer,
+380.652.512.251        Simferopol, Ukraine

http://www.FreeBSD.org  The Power To Serve
http://www.oracle.com   Enabling The Information Age
Index: in_rmx.c
===================================================================
RCS file: /home/ncvs/src/sys/netinet/in_rmx.c,v
retrieving revision 1.39
diff -u -p -u -r1.39 in_rmx.c
--- in_rmx.c    2001/03/19 09:16:16     1.39
+++ in_rmx.c    2001/04/02 17:25:57
@@ -416,6 +416,9 @@ in_ifadown(struct ifaddr *ifa)
        if (ifa->ifa_addr->sa_family != AF_INET)
                return 1;
 
+       if (((struct sockaddr_in *)ifa->ifa_addr)->sin_addr.s_addr == INADDR_ANY)
+               return 0;
+
        arg.rnh = rnh = rt_tables[AF_INET];
        arg.ifa = ifa;
        rnh->rnh_walktree(rnh, in_ifadownkill, &arg);

Reply via email to