NetBSD Problem Report #3508

Received: (qmail-queue invoked from smtpd); 17 Apr 1997 19:53:05 -0000
Message-Id: <199704171952.PAA00511@Twig.Rodents.Montreal.QC.CA>
Date: Thu, 17 Apr 1997 15:52:57 -0400 (EDT)
From: der Mouse  <mouse@Rodents.Montreal.QC.CA>
Reply-To: mouse@Rodents.Montreal.QC.CA
To: gnats-bugs@gnats.netbsd.org
Subject: [dM] ipforward_rt cache broken
X-Send-Pr-Version: 3.95

>Number:         3508
>Category:       kern
>Synopsis:       [dM] ipforward_rt cache broken
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    dyoung
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Apr 17 13:05:02 +0000 1997
>Closed-Date:    Wed Aug 10 19:08:51 +0000 2011
>Last-Modified:  Wed Aug 10 19:08:51 +0000 2011
>Originator:     der Mouse
>Release:        1.2_BETA (code inspection implies also in -current)
>Organization:
	Dis-
>Environment:
	Any (noticed on a SPARC IPC)
>Description:
	ipforward_rt, which appears to be a size-one cache for IP
	packet forwarding, can produce broken routing.

	In this particular case, a NetBSD/sparc machine is on a local
	Ethernet; let's say its address there is 123.45.6.7, and its
	default route is to 123.45.6.1.  A PPP user exists, whose
	remote address is always (say) 123.45.9.1.  For reasons not
	relevant here, the machine is always advertising routes to
	123.45.9.* even when the PPP link is down - when it's down,
	packets for 123.45.9.1 just bounce back and forth between
	123.45.6.7 and 123.45.6.1 until their TTL expires.

	When the PPP user dials in and causes ppp0 to come up, a route
	is (correctly) installed, pointing 123.45.9.1 down ppp0.  The
	problem is, if ipforward_rt happens to hold 123.45.9.1's route
	out the local ethernet to 123.45.6.1, packets for 123.45.9.1
	will still take that route even though that is not the current
	route.  Having the machine attempt to forward a packet to any
	other address promptly cures the problem.
>How-To-Repeat:
	See above.  It's not hard to provoke this deliberately - find a
	machine with no other forwarding traffic, ping a host through
	(not from) it, change the routing table in a way that affects
	that host's route, ping/traceroute again, and notice that the
	old route is still used.  Cause the machine to forward a packet
	for any other address and retry, and notice it's magically
	fixed itself.
>Fix:
	Not sure what the right fix is.  Since on a non-busy machine
	the load from routing lookups is low, and on a busy machine it
	seems reasonably likely that a cache as small as one will be
	missed more often than not, so I'd be tempted to remove the if
	entirely and always do the lookup.  Alternatively I'd add a
	heartbeat timer that clears that cache reasonably often wrt the
	sort of timescale on which routes appear and disappear, but
	seldom wrt inter-packet arrival times - from 1 to 0.1 Hz seems
	reasonable to me.

	The _right_ fix would probably be to explicitly clear that
	cache every time the routing tables get changed, or perhaps
	keep a routing-table generation count and have ip_forward
	ignore the cache if the routing table generation has changed.

	For this machine I'll prolly just toss the cache entirely and
	always do the lookup.  Does anyone have stats on the hit rate
	of that cache?  I didn't see any instrumentation in the code.

	This code has changed some between 1.2 and -current, but
	reading the code makes me think the bug is probably present in
	-current as well.

					der Mouse

			       mouse@rodents.montreal.qc.ca
		     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B
>Release-Note:
>Audit-Trail:

From: der Mouse  <mouse@Rodents.Montreal.QC.CA>
To: gnats-bugs@gnats.netbsd.org
Cc: netbsd-bugs@NetBSD.ORG
Subject: Re: kern/3508: [dM] ipforward_rt cache broken
Date: Mon, 21 Apr 1997 10:56:02 -0400 (EDT)

 > >Fix:
 > 	Not sure what the right fix is.  [...]

 Here's a patch I'm using.  It seems to cure the problem for me.  The
 patch is relative to 1.2's source, $NetBSD: ip_input.c,v 1.30
 1996/03/16 23:53:58 christos Exp $.

 This patch amounts to clearing ipforward_rt once a second, but does it
 in a way that doesn't carry the overhead of a heartbeat timeout or
 anything similar: it simply tosses a cached route if time.tv_sec has
 changed since it was cached.

 This should be fixed up a little if this fix is adopted; in particular,
 the declaration for ipforward_rt_stamp is gcc-specific.  (I just now
 realized it can be written as "typeof(time.tv_sec)" instead of the
 horrible mess I have there.)

 --- OLD/sys/netinet/ip_input.c	Thu Jan  1 00:00:00 1970
 +++ NEW/sys/netinet/ip_input.c	Thu Jan  1 00:00:00 1970
 @@ -145,6 +145,7 @@

  struct	sockaddr_in ipaddr = { sizeof(ipaddr), AF_INET };
  struct	route ipforward_rt;
 +typeof(((typeof(&time))0)->tv_sec) ipforward_rt_stamp;

  /*
   * Ip input routine.  Checksum and byte swap header.  If fragmented
 @@ -830,28 +831,51 @@
  }

  /*
 - * Given address of next destination (final or next hop),
 - * return internet address info of interface to be used to get there.
 + * Get, into ipforward_rt, the route to *to.  If there is no route
 + *  already in ipforward_rt, or it's not to the same place, or it's too
 + *  old, toss it and re-lookup.  (The last clause is to limit the
 + *  damage done by caching a route and then having the routing tables
 + *  change.  Without a timeout here, or clearing this route when the
 + *  routing tables change, a route can be cached and then used much
 + *  later, long after it's been rendered bogus by a change to the
 + *  tables.)
   */
 -struct in_ifaddr *
 -ip_rtaddr(dst)
 -	 struct in_addr dst;
 +static void
 +get_forward_rt(struct in_addr *to)
  {
  	register struct sockaddr_in *sin;

  	sin = satosin(&ipforward_rt.ro_dst);

 -	if (ipforward_rt.ro_rt == 0 || dst.s_addr != sin->sin_addr.s_addr) {
 +	if ((ipforward_rt.ro_rt == 0) ||
 +	    (to->s_addr != sin->sin_addr.s_addr) ||
 +	    (ipforward_rt_stamp != time.tv_sec)) {
 +
  		if (ipforward_rt.ro_rt) {
  			RTFREE(ipforward_rt.ro_rt);
  			ipforward_rt.ro_rt = 0;
  		}
 +
  		sin->sin_family = AF_INET;
  		sin->sin_len = sizeof(*sin);
 -		sin->sin_addr = dst;
 +		sin->sin_addr = *to;

  		rtalloc(&ipforward_rt);
 +
 +		ipforward_rt_stamp = time.tv_sec;
  	}
 +}
 +
 +/*
 + * Given address of next destination (final or next hop),
 + * return internet address info of interface to be used to get there.
 + */
 +struct in_ifaddr *
 +ip_rtaddr(dst)
 +	 struct in_addr dst;
 +{
 +	get_forward_rt(&dst);
 +
  	if (ipforward_rt.ro_rt == 0)
  		return ((struct in_ifaddr *)0);
  	return (ifatoia(ipforward_rt.ro_rt->rt_ifa));
 @@ -1005,7 +1029,6 @@
  	int srcrt;
  {
  	register struct ip *ip = mtod(m, struct ip *);
 -	register struct sockaddr_in *sin;
  	register struct rtentry *rt;
  	int error, type = 0, code = 0;
  	struct mbuf *mcopy;
 @@ -1030,23 +1053,12 @@
  	}
  	ip->ip_ttl -= IPTTLDEC;

 -	sin = satosin(&ipforward_rt.ro_dst);
 -	if ((rt = ipforward_rt.ro_rt) == 0 ||
 -	    ip->ip_dst.s_addr != sin->sin_addr.s_addr) {
 -		if (ipforward_rt.ro_rt) {
 -			RTFREE(ipforward_rt.ro_rt);
 -			ipforward_rt.ro_rt = 0;
 -		}
 -		sin->sin_family = AF_INET;
 -		sin->sin_len = sizeof(*sin);
 -		sin->sin_addr = ip->ip_dst;
 +	get_forward_rt(&ip->ip_dst);
 +	rt = ipforward_rt.ro_rt;

 -		rtalloc(&ipforward_rt);
 -		if (ipforward_rt.ro_rt == 0) {
 -			icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_HOST, dest, 0);
 -			return;
 -		}
 -		rt = ipforward_rt.ro_rt;
 +	if (rt == 0) {
 +		icmp_error(m, ICMP_UNREACH, ICMP_UNREACH_HOST, dest, 0);
 +		return;
  	}

  	/*

 					der Mouse

 			       mouse@rodents.montreal.qc.ca
 		     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B

From: Tad Hunt <tad@entrisphere.com>
To: gnats-bugs@netbsd.org, tech-net@netbsd.org, tech-kern@netbsd.org
Cc:  
Subject: kern/3508 bug: cached ip route and interface up/down.
Date: Tue, 12 Nov 2002 13:27:23 -0800

 Aside:
  In the future, should I direct problems having to do with the
  networking portion of the kernel to tech-net or tech-kern?  Or is
  it appropriate to send such things to both?

 Background:
  I'm using a NetBSD box as a router.  It happens to be running
  NetBSD 1.5, but after looking through the networking code, I
  believe that this is still a problem in NetBSD-current.

 Problem:
  The ip stack, when forwarding a packet, in ip_forward(), makes use
  of a cached route from a global variable called "ipforward_rt".
  When the interface that route directs outbound packets toward goes
  down the cached route is not cleared, so the packets don't get
  re-routed.  When the interface comes back up, the packets still
  don't get delivered to it.

  Hmm. I just looked in the PR database.  This appears to be
  a longstanding problem.  der Mouse reported PR3508, which is
  the same problem, way back in 1997.  As he said then, I believe
  this is still a problem in NetBSD-current.

 To Fix:
  I put in a call in if_down() and if_up() to free the cached route.
  The next time a packet is received, the route will be reallocated
  and everything will be happy.  This is just a hack to see if I'm
  on the right track.  However, PR3508 points out more ways that
  the cached route can be wrong.  I'm inclined to follow der Mouse's
  lead and get rid of the cached route entirely.

 To Reproduce:

 	Client1 <----> NetBSD Router <----> Client2
                     ifc0           ifc1

  1) Setup a NetBSD router with at least two interfaces (ifc0, ifc1)
     as above.

  2) Configure a default route on ifc0, and a route to Client2
     on ifc1.

  3) In the absence of any other traffic to be forwarded, ping
     Client2 from Client1. (The cached route is cleared whenever a
     packet for a different destination arrives)

  4) ifconfig ifc1 down

  5) notice the ping stops receiving the echo reply.

  6) ifconfig ifc1 up

  7) notice the ping still doesn't receive the echo reply.

  8) without stopping the first ping, ping another address which
     the router will also forward (doesn't have to respond)

  9) notice the first ping starts working again

From: Nick Amato <naamato@nexthop.com>
To: Tad Hunt <tad@entrisphere.com>
Cc: gnats-bugs@netbsd.org, tech-net@netbsd.org, tech-kern@netbsd.org
Subject: Re: kern/3508 bug: cached ip route and interface up/down.
Date: Tue, 12 Nov 2002 17:32:18 -0500

 On Tue, Nov 12, 2002 at 01:27:23PM -0800, Tad Hunt wrote:
 > (...)
 > Problem:
 >  The ip stack, when forwarding a packet, in ip_forward(), makes use
 >  of a cached route from a global variable called "ipforward_rt".
 >  When the interface that route directs outbound packets toward goes
 >  down the cached route is not cleared, so the packets don't get
 >  re-routed.  When the interface comes back up, the packets still
 >  don't get delivered to it.

 It's been pointed out on current-users that the kernel is "simple-minded"
 about routing.  In your case, if the interface a route was using goes down,
 it's still up to a userland program to reroute the traffic by changing
 the table.

 A program such as gated(8) watches for interface changes like this, and
 will update e.g. static routes as necessary.  So in this case, without
 alternate paths available, when ifc1 goes down, the route is deleted.
 When it comes back up, the route is re-added.  At this point ip_output()
 notices that the cached route is dead and fetches the new route.

 Nick


 >  Hmm. I just looked in the PR database.  This appears to be
 >  a longstanding problem.  der Mouse reported PR3508, which is
 >  the same problem, way back in 1997.  As he said then, I believe
 >  this is still a problem in NetBSD-current.
 > 
 > To Fix:
 >  I put in a call in if_down() and if_up() to free the cached route.
 >  The next time a packet is received, the route will be reallocated
 >  and everything will be happy.  This is just a hack to see if I'm
 >  on the right track.  However, PR3508 points out more ways that
 >  the cached route can be wrong.  I'm inclined to follow der Mouse's
 >  lead and get rid of the cached route entirely.
 >
 > To Reproduce:
 > 
 > 	Client1 <----> NetBSD Router <----> Client2
 >                     ifc0           ifc1
 > 
 >  1) Setup a NetBSD router with at least two interfaces (ifc0, ifc1)
 >     as above.
 > 
 >  2) Configure a default route on ifc0, and a route to Client2
 >     on ifc1.
 > 
 >  3) In the absence of any other traffic to be forwarded, ping
 >     Client2 from Client1. (The cached route is cleared whenever a
 >     packet for a different destination arrives)
 > 
 >  4) ifconfig ifc1 down
 > 
 >  5) notice the ping stops receiving the echo reply.
 > 
 >  6) ifconfig ifc1 up
 > 
 >  7) notice the ping still doesn't receive the echo reply.
 > 
 >  8) without stopping the first ping, ping another address which
 >     the router will also forward (doesn't have to respond)
 > 
 >  9) notice the first ping starts working again

From: der Mouse <mouse@Rodents.Montreal.QC.CA>
To: gnats-bugs@netbsd.org, tech-net@netbsd.org, tech-kern@netbsd.org
Cc:  
Subject: Re: kern/3508 bug: cached ip route and interface up/down.
Date: Tue, 12 Nov 2002 23:42:54 +0100 (CET)

 >>  The ip stack, when forwarding a packet, in ip_forward(), makes use
 >>  of a cached route from a global variable called "ipforward_rt".

 > It's been pointed out on current-users that the kernel is
 > "simple-minded" about routing.  In your case, if the interface a
 > route was using goes down, it's still up to a userland program to
 > reroute the traffic by changing the table.

 It's worse than that: even if userland _does_ change the routing table,
 it doesn't affect routing until the kernel wants to forward a packet to
 some other address.  Check out PR 3508.

 You write that

 > At this point ip_output() notices that the cached route is dead and
 > fetches the new route.

 I just had a look at -current's ip_output and I think what it does
 isn't enough:

         /*
          * If there is a cached route,
          * check that it is to the same destination
          * and is still up.  If not, free it and try again.
          * The address family should also be checked in case of sharing the
          * cache with IPv6.
          */

 The last two lines appear to be out of date, but the rest looks right:

         if (ro->ro_rt && ((ro->ro_rt->rt_flags & RTF_UP) == 0 ||
             dst->sin_family != AF_INET ||
             !in_hosteq(dst->sin_addr, ip->ip_dst))) {

 This won't fix anything in the scenario outlined in PR 3508.

 /~\ The ASCII				der Mouse
 \ / Ribbon Campaign
  X  Against HTML	       mouse@rodents.montreal.qc.ca
 / \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B

From: Tad Hunt <tad@entrisphere.com>
To: gnats-bugs@netbsd.org, tech-net@netbsd.org, tech-kern@netbsd.org
Cc:  
Subject: Re: kern/3508 bug: cached ip route and interface up/down. 
Date: Tue, 12 Nov 2002 15:08:15 -0800

 In message <20021112173218.C18167@wooj.nexthop.com>, Nick said:
 ;It's been pointed out on current-users that the kernel is "simple-minded"
 ;about routing.  In your case, if the interface a route was using goes down,
 ;it's still up to a userland program to reroute the traffic by changing
 ;the table.
 ;
 ;A program such as gated(8) watches for interface changes like this, and
 ;will update e.g. static routes as necessary.  So in this case, without
 ;alternate paths available, when ifc1 goes down, the route is deleted.
 ;When it comes back up, the route is re-added.  At this point ip_output()
 ;notices that the cached route is dead and fetches the new route.
 ;
 ;Nick

 Except it doesn't.  The interface changes were simply an easy way
 to cause a system to exhibit the problem.

 The problem is that this variable, "ipforward_rt", isn't part of
 the routing table, so modifying the routing table is not enough to
 fix the problem.  This variable is a cached copy of a route from
 the routing table in the ip stack.  It doesn't matter what my
 routing table says when the ip stack is not even referring to what
 is currently existing in the routing table.

 Previously, I had asked about separate interface issues, which were
 solved by running gated(8) so that it could manage the routing table.
 This works great, and solves those problems.  However, gated(8) cannot
 do anything about a cached route that is in the ip stack.

 You can cause the same problem without touching the interfaces,
 simply by modifying the routing table.

 Given such a routing table:

 	default        GW 192.167.1.1
 	192.168.1.0/24 GW 192.168.2.1

 1) Assume the traffic is using the second route.

 2) Delete the second route.

 3) The traffic still attempts to use the second route, even though
    it no longer exists in the routing table.

 4) Unless I'm mistaken, there is no user-process way to clear the
    cached route from the ipforward_rt variable.

 5) Another packet arriving which needs to be forwarded to a different
    destination will cause the contents of the ipforward_rt variable
    to be discarded and filled with a cached copy of the route for
    the new packet.  When a packet for the old destination then
    arrives, the cached route is replaced again.  That is, as soon
    as a packet arrives for a different destination, the problem
    goes away because the cache (of size 1) will be thrashed, and
    that fixes it.

 -Tad

From: Nick Amato <naamato@nexthop.com>
To: der Mouse <mouse@rodents.montreal.qc.ca>
Cc: gnats-bugs@netbsd.org, tech-net@netbsd.org, tech-kern@netbsd.org
Subject: Re: kern/3508 bug: cached ip route and interface up/down.
Date: Tue, 12 Nov 2002 19:15:52 -0500

 On Tue, Nov 12, 2002 at 11:42:54PM +0100, der Mouse wrote:
 > >>  The ip stack, when forwarding a packet, in ip_forward(), makes use
 > >>  of a cached route from a global variable called "ipforward_rt".
 > 
 > > It's been pointed out on current-users that the kernel is
 > > "simple-minded" about routing.  In your case, if the interface a
 > > route was using goes down, it's still up to a userland program to
 > > reroute the traffic by changing the table.
 > 
 > It's worse than that: even if userland _does_ change the routing table,
 > it doesn't affect routing until the kernel wants to forward a packet to
 > some other address.  Check out PR 3508.
 > 
 > You write that
 > 
 > > At this point ip_output() notices that the cached route is dead and
 > > fetches the new route.
 > 
 > I just had a look at -current's ip_output and I think what it does
 > isn't enough:
 > 
 >         /*
 >          * If there is a cached route,
 >          * check that it is to the same destination
 >          * and is still up.  If not, free it and try again.
 >          * The address family should also be checked in case of sharing the
 >          * cache with IPv6.
 >          */
 > 
 > The last two lines appear to be out of date, but the rest looks right:
 > 
 >         if (ro->ro_rt && ((ro->ro_rt->rt_flags & RTF_UP) == 0 ||
 >             dst->sin_family != AF_INET ||
 >             !in_hosteq(dst->sin_addr, ip->ip_dst))) {
 > 
 > This won't fix anything in the scenario outlined in PR 3508.

 Yes, it is true.  A routing daemon cannot fix the problems in PR 3508.

 However, as long as there is an absence of an alternate route (i.e. default)
 while a destination is unreachable, it still works.  When a route is deleted
 and added the old route has RTF_UP reset and the new route will be rtalloc'd
 in ip_output().

 Not very useful.  It seems to me that what needs to happen is to clear the
 cache whenever a more specific route than the cached route is added to
 the table.  I don't know how practical this is.

 Nick

From: Tad Hunt <tad@entrisphere.com>
To: Nick Amato <naamato@nexthop.com>
Cc: der Mouse <mouse@rodents.montreal.qc.ca>, gnats-bugs@netbsd.org,
  tech-net@netbsd.org, tech-kern@netbsd.org
Subject: Re: kern/3508 bug: cached ip route and interface up/down. 
Date: Tue, 12 Nov 2002 16:37:12 -0800

 In message <20021112191552.D18167@wooj.nexthop.com>, you said:
 ;
 ;Yes, it is true.  A routing daemon cannot fix the problems in PR 3508.
 ;
 ;However, as long as there is an absence of an alternate route (i.e. default)
 ;while a destination is unreachable, it still works. 

 Right, which is why hardly anybody is going to notice this problem,
 unless they're using NetBSD as a router with very little traffic.

 ;When a route is deleted and added the old route has RTF_UP reset and the
 ;new route will be rtalloc'd in ip_output().
 ;
 ;Not very useful.  It seems to me that what needs to happen is to clear the
 ;cache whenever a more specific route than the cached route is added to
 ;the table.  I don't know how practical this is.

 Not quite.  Because when there are alternate routes, and the more
 specific route was deleted, it needs to fall back to the less-specific
 route.

 I agree with Dennis Ferguson's point, that the routing table lookup
 should be made cheap enough that caching is not required.

 -Tad

From: Nick Amato <naamato@nexthop.com>
To: Tad Hunt <tad@entrisphere.com>
Cc: Nick Amato <naamato@nexthop.com>,
  der Mouse <mouse@rodents.montreal.qc.ca>, gnats-bugs@netbsd.org,
  tech-net@netbsd.org, tech-kern@netbsd.org
Subject: Re: kern/3508 bug: cached ip route and interface up/down.
Date: Tue, 12 Nov 2002 19:46:43 -0500

 On Tue, Nov 12, 2002 at 04:37:12PM -0800, Tad Hunt wrote:
 > In message <20021112191552.D18167@wooj.nexthop.com>, you said:
 > ;
 > ;Yes, it is true.  A routing daemon cannot fix the problems in PR 3508.
 > ;
 > ;However, as long as there is an absence of an alternate route (i.e. default)
 > ;while a destination is unreachable, it still works. 
 > 
 > Right, which is why hardly anybody is going to notice this problem,
 > unless they're using NetBSD as a router with very little traffic.
 > 
 > ;When a route is deleted and added the old route has RTF_UP reset and the
 > ;new route will be rtalloc'd in ip_output().
 > ;
 > ;Not very useful.  It seems to me that what needs to happen is to clear the
 > ;cache whenever a more specific route than the cached route is added to
 > ;the table.  I don't know how practical this is.
 > 
 > Not quite.  Because when there are alternate routes, and the more
 > specific route was deleted, it needs to fall back to the less-specific
 > route.

 Unless I'm mistaken, glancing over rtrequest1(), I think the code
 already does this.  When the more specific route is deleted, the
 rt_entry referenced by the cache has its RTF_UP cleared and this
 is noticed in ip_output().

 Nick

From: der Mouse <mouse@Rodents.Montreal.QC.CA>
To: gnats-bugs@netbsd.org, tech-net@netbsd.org, tech-kern@netbsd.org
Cc:  
Subject: Re: kern/3508 bug: cached ip route and interface up/down.
Date: Wed, 13 Nov 2002 01:53:55 +0100 (CET)

 > Unless I'm mistaken, glancing over rtrequest1(), I think the code
 > already does this.  When the more specific route is deleted, the
 > rt_entry referenced by the cache has its RTF_UP cleared and this is
 > noticed in ip_output().

 I'm not so sure.  How is the cached route located and where is its
 RTF_UP cleared?  The route being deleted has its RTF_UP cleared, but
 that's not the one ipforward_rt points to; unless the route is to a /32
 or the packet is to the all-0 host portion, it can't be - the cached
 route always has the exact /32 as its destination.

 ...Or Am I Missing Something?

 /~\ The ASCII				der Mouse
 \ / Ribbon Campaign
  X  Against HTML	       mouse@rodents.montreal.qc.ca
 / \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B

From: Tad Hunt <tad@entrisphere.com>
To: der Mouse <mouse@Rodents.Montreal.QC.CA>
Cc: gnats-bugs@netbsd.org, tech-net@netbsd.org, tech-kern@netbsd.org
Subject: Re: kern/3508 bug: cached ip route and interface up/down. 
Date: Tue, 12 Nov 2002 17:17:50 -0800

 Ah!

 -Tad

 In message <200211130103.UAA25883@Sparkle.Rodents.Montreal.QC.CA>, you said:
 ;> Unless I'm mistaken, glancing over rtrequest1(), I think the code
 ;> already does this.  When the more specific route is deleted, the
 ;> rt_entry referenced by the cache has its RTF_UP cleared and this is
 ;> noticed in ip_output().
 ;
 ;I'm not so sure.  How is the cached route located and where is its
 ;RTF_UP cleared?  The route being deleted has its RTF_UP cleared, but
 ;that's not the one ipforward_rt points to; unless the route is to a /32
 ;or the packet is to the all-0 host portion, it can't be - the cached
 ;route always has the exact /32 as its destination.
 ;
 ;...Or Am I Missing Something?
 ;
 ;/~\ The ASCII				der Mouse
 ;\ / Ribbon Campaign
 ; X  Against HTML	       mouse@rodents.montreal.qc.ca
 ;/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B

From: Nick Amato <naamato@nexthop.com>
To: der Mouse <mouse@rodents.montreal.qc.ca>
Cc: gnats-bugs@netbsd.org, tech-net@netbsd.org, tech-kern@netbsd.org
Subject: Re: kern/3508 bug: cached ip route and interface up/down.
Date: Tue, 12 Nov 2002 21:31:16 -0500

 On Wed, Nov 13, 2002 at 01:53:55AM +0100, der Mouse wrote:
 > > Unless I'm mistaken, glancing over rtrequest1(), I think the code
 > > already does this.  When the more specific route is deleted, the
 > > rt_entry referenced by the cache has its RTF_UP cleared and this is
 > > noticed in ip_output().
 > 
 > I'm not so sure.  How is the cached route located and where is its
 > RTF_UP cleared?  The route being deleted has its RTF_UP cleared, but
 > that's not the one ipforward_rt points to; unless the route is to a /32
 > or the packet is to the all-0 host portion, it can't be - the cached
 > route always has the exact /32 as its destination.

 That's not what I see.

 Rtalloc() should call rtalloc1(), which will find the "best matching"
 route (i.e. most specific).

 The cache, however, is still a "host" cache in that the full address
 of the packet being sent is checked.  The rtentry referenced by
 the cache may actually be a net route.

 Nick
State-Changed-From-To: open->feedback 
State-Changed-By: jdolecek 
State-Changed-When: Sun Oct 3 11:08:24 UTC 2004 
State-Changed-Why:  
Is this still problem in 20041003 -current and 2.0RC2? 

From: der Mouse <mouse@Rodents.Montreal.QC.CA>
To: gnats-bugs@gnats.netbsd.org, jdolecek@netbsd.org,
  kern-bug-people@netbsd.org
Cc:  
Subject: Re: kern/3508
Date: Fri, 8 Oct 2004 01:57:38 -0400 (EDT)

 (Sorry for the slow response;l I've been on the road for most of the
 past month, with little email access.)

 > Synopsis: [dM] ipforward_rt cache broken

 > Is this still problem in 20041003 -current and 2.0RC2?

 I don't know, as I have no systems running either.  (Are we up to RC2
 already?  I thought RC1 had just been cut.)

 /~\ The ASCII				der Mouse
 \ / Ribbon Campaign
  X  Against HTML	       mouse@rodents.montreal.qc.ca
 / \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B
State-Changed-From-To: feedback->open
State-Changed-By: jdolecek@netbsd.org
State-Changed-When: Wed, 17 Nov 2004 10:13:43 +0000
State-Changed-Why:
Seems it's still a problem.


Responsible-Changed-From-To: kern-bug-people->dyoung
Responsible-Changed-By: dyoung@netbsd.org
Responsible-Changed-When: Wed, 10 Jan 2007 07:55:45 +0000
Responsible-Changed-Why:
I have been working on a fix.


State-Changed-From-To: open->feedback
State-Changed-By: dyoung@NetBSD.org
State-Changed-When: Mon, 21 Jul 2008 05:17:46 +0000
State-Changed-Why:
The IP forwarding cache is invalidated by route changes, so this
bug ought to be fixed.


From: der Mouse <mouse@Rodents-Montreal.ORG>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/3508 ([dM] ipforward_rt cache broken)
Date: Mon, 21 Jul 2008 01:24:48 -0400 (EDT)

 > The IP forwarding cache is invalidated by route changes, so this bug
 > ought to be fixed.

 As of when was this change made?  I can test it, but I don't have any
 machines runningg -current, only releases - so I'm wondering what the
 earliest release with the fix is (or will be).

 					der Mouse

State-Changed-From-To: feedback->open
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sun, 26 Oct 2008 21:31:31 +0000
State-Changed-Why:
Feedback was received, and the submitter asked a question.
(I don't know the answer.)


State-Changed-From-To: open->feedback
State-Changed-By: dyoung@NetBSD.org
State-Changed-When: Wed, 05 May 2010 19:41:00 +0000
State-Changed-Why:
der Mouse should try NetBSD 5.0 to see if the bug is fixed there.
(I think that it is.)


From: der Mouse <mouse@Rodents-Montreal.ORG>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/3508 ([dM] ipforward_rt cache broken)
Date: Fri, 21 May 2010 09:28:05 -0400 (EDT)

 > der Mouse should try NetBSD 5.0 to see if the bug is fixed there.
 > (I think that it is.)

 Mouse doesn't have any 5.x machines at present, making it a bit more
 difficult.  I believe I can set one up without too much trouble, but it
 will take a little longer than testing something I have in live use
 would.  I'll write back once I have something to report.

 					Mouse

From: der Mouse <mouse@Rodents-Montreal.ORG>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: Re: kern/3508
Date: Tue, 22 Mar 2011 13:15:47 -0400 (EDT)

 Mouse finally tried this on 5.x (specifically, a 5.1 i386 machine set
 up for work which has not yet been put into production).

 While I didn't do full-on verification, initial indications are that
 dyoung is right, that the misbehaviour is gone in 5.x.

 /~\ The ASCII				  Mouse
 \ / Ribbon Campaign
  X  Against HTML		mouse@rodents-montreal.org
 / \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B

State-Changed-From-To: feedback->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Wed, 10 Aug 2011 19:08:51 +0000
State-Changed-Why:
Confirmed at least tentatively to be fixed in -5.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.