Subject: Re: default route deleted incorrectly with dhclient
To: der Mouse <mouse@Rodents.Montreal.QC.CA>
From: Steven M. Bellovin <smb@cs.columbia.edu>
List: tech-net
Date: 07/20/2006 19:19:06
On Thu, 20 Jul 2006 11:35:46 -0400 (EDT), der Mouse
<mouse@Rodents.Montreal.QC.CA> wrote:

> >> (It would replace the current text of the delete_old_routes()
> >> function.)  [...]
> > I don't get it.  Isn't the old code and the new code equivalent?
> 
> No.
> 
> > Instead of calling:
> > 	route delete default "$router"
> > you call the new function
> > 	delete_default "$router"
> > which does the same if it finds that this route exists...
> 
> Yes.  The point is that "if...", which was missing from the old code.
> The point is to delete the default - but *only* if it points out the
> "correct" interface.  There's no way to tell "route delete" to delete
> the route only if it points through a particular interface.  (Or at
> least, if there is, I don't know about it, and it should be used
> instead of doing the loop.)
> 
> Actually, I don't like the loop.  I'd rather see it parse the output of
> "route get default" instead.
> 
The proper fix is in the kernel, I think, so that

	route delete foo bar

behaves differently from

	route delete foo

if the route to foo doesn't go through bar.  That fix was less obvious to
me, and less portable to other users of dhclient, so I coded what I did.

As for parsing the output of 'route get default' -- if I'd realized that
that worked, I'd probably have done that instead.  As is, I now have
running code that avoids a real problem for me, so I'll have to find more
energy to fix it properly instead.  But you're right, so I'll hold off on
committing my fix.


		--Steven M. Bellovin, http://www.cs.columbia.edu/~smb