[713] in linux-net channel archive
Anybody knows BSD 4.3 semantics of SIOCADDRT/DELRT?
daemon@ATHENA.MIT.EDU (Miquel van Smoorenburg)
Mon Jul 17 21:34:13 1995
To: submit-linux-dev-net@ratatosk.yggdrasil.com
From: miquels@cistron.nl (Miquel van Smoorenburg)
Date: 18 Jul 1995 00:12:02 +0200
Hello,
I have been busy porting the 4.4 BSD routed back to Linux
(actually I took the one from NetBSD-current). In the
process, I got a bit confused about how Linux handled the
SIOCADDRT/DELRT ioctls.
This is what Linux did in 1.3.0 - 1.3.8:
When adding a route, ip_rt_add checks if there is already a
route installed to the same destination/netmask. If so, the existing
route is deleted, unless the existing route has a smaller metric then
the new route. This is fine, but when deleting a route, ip_rt_del does
not check the metric so you can't selectively delete one route.
So, I sent some patches to Alan and now the original behaviour
of ip_rt_add is back: not checking the metric before adding a route,
but deleting any existing route to the same destination.
I tried to find out what these ioctls did in BSD 4.3, but
even BSD Net-2 already uses the new RTM_ADD ioctl on a routing
socket stuff.
What I think the original BSD stuff did, was when adding a new route,
it was just added regardlessly (no check if already present).
Deleting a route only succeeded when the BSD ip_rt_delete finds an exact
match. This way, one can first add a new route and then delete the
old route, whereas you'd get a race condition (no route to host) if
you do it the other way around.
I think we can implement
1. only have one route at any time to a given destination
(as in kernel 1.3.9+)
2. The 1.3.8 behaviour where an existing route is not deleted if a route
with a smaller metric is added (why?). We have to change ip_rt_del to
try and match the metric if multiple routes with different metrics
to one destination are present.
3. Always treat routes with the same destination but different metrics
as different routes so you can selectively add / delete them without
side effects.
I don't know what is the most desireable behaviour. Probably (3),
if it is important to have multiple routes to the same destination
with different metrics (why do we want this?). Otherwise let's
leave it as it is now.
Mike.
--
Miquel van Smoorenburg, miquels@cistron.nl Cistron Internet Services
Mail info@cistron.nl An independent Dutch Internet Provider
for more information <A Href = "http://www.cistron.nl/">CIS</A>
+31-1720-19445 (Voice) 30979 (Fax) 42580 (Data) - Alphen a/d Rijn