* [RFC, PATCH] Purging local routes on NETDEV_DOWN event
@ 2006-11-05 14:00 Boris Sukholitko
2006-11-05 15:56 ` Thomas Graf
2006-11-05 21:16 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Boris Sukholitko @ 2006-11-05 14:00 UTC (permalink / raw)
To: netdev
[-- Attachment #1: Type: text/plain, Size: 744 bytes --]
Hi,
We've noticed that when taking network interface down the local route
for its address is preserved. The following console session
illustrates it:
# ip addr add 5.5.5.5 dev eth4
# ip route list table all | grep eth4
local 5.5.5.5 dev eth4 table 255 vrf 0 proto kernel scope host src 5.5.5.5
# ip link set eth4 down
local 5.5.5.5 dev eth4 table 255 vrf 0 proto kernel scope host src 5.5.5.5
There seems to be an asymmetry between NETDEV_UP and NETDEV_DOWN events
in fib_netdev_event at net/ipv4/fib_frontend.c. On NETDEV_UP we are adding
routes for interface addresses. However on NETDEV_DOWN we do not delete them.
The attached (for a fear of GMail tab munging :)) patch tries to change it.
What do you think?
Thanks,
Boris.
[-- Attachment #2: netdev-down.patch --]
[-- Type: text/x-patch, Size: 772 bytes --]
Signed-off-by: Boris Sukholitko (bobatonhu@gmail.com)
---
Index: linux-2.6.18/net/ipv4/fib_frontend.c
===================================================================
--- linux-2.6.18.orig/net/ipv4/fib_frontend.c 2006-11-01 18:15:31.000000000 +0200
+++ linux-2.6.18/net/ipv4/fib_frontend.c 2006-11-05 15:32:56.000000000 +0200
@@ -727,6 +727,8 @@
*/
for (ifa1 = in_dev->ifa_list; ifa1; ifa1 = ifa1->ifa_next) {
+ if (ifa == ifa1)
+ continue;
if (ifa->ifa_local == ifa1->ifa_local)
ok |= LOCAL_OK;
if (ifa->ifa_broadcast == ifa1->ifa_broadcast)
@@ -880,6 +882,9 @@
rt_cache_flush(-1);
break;
case NETDEV_DOWN:
+ for_ifa(in_dev) {
+ fib_del_ifaddr(ifa);
+ } endfor_ifa(in_dev);
fib_disable_ip(dev, 0);
break;
case NETDEV_CHANGEMTU:
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC, PATCH] Purging local routes on NETDEV_DOWN event
2006-11-05 14:00 [RFC, PATCH] Purging local routes on NETDEV_DOWN event Boris Sukholitko
@ 2006-11-05 15:56 ` Thomas Graf
2006-11-05 21:16 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Thomas Graf @ 2006-11-05 15:56 UTC (permalink / raw)
To: Boris Sukholitko; +Cc: netdev
* Boris Sukholitko <bobatonhu@gmail.com> 2006-11-05 16:00
> We've noticed that when taking network interface down the local route
> for its address is preserved. The following console session
> illustrates it:
>
> # ip addr add 5.5.5.5 dev eth4
> # ip route list table all | grep eth4
> local 5.5.5.5 dev eth4 table 255 vrf 0 proto kernel scope host src
> 5.5.5.5
> # ip link set eth4 down
> local 5.5.5.5 dev eth4 table 255 vrf 0 proto kernel scope host src
> 5.5.5.5
This example is incomplete and misleading. The local route is managed
completely synchroneous with the address itself. See the NETDEV_UP/
NETDEV_DOWN handlers of inetaddr events:
case NETDEV_UP:
fib_add_ifaddr(ifa);
case NETDEV_DOWN:
fib_del_ifaddr(ifa);
The broadcast routes are added/removed when the interface goes up
and down. The fib_addr_ifaddr() in the NETDEV_UP() handler only
exists to add broadcast routes for local address which have been added
while the interface was down.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC, PATCH] Purging local routes on NETDEV_DOWN event
2006-11-05 14:00 [RFC, PATCH] Purging local routes on NETDEV_DOWN event Boris Sukholitko
2006-11-05 15:56 ` Thomas Graf
@ 2006-11-05 21:16 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2006-11-05 21:16 UTC (permalink / raw)
To: bobatonhu; +Cc: netdev
From: "Boris Sukholitko" <bobatonhu@gmail.com>
Date: Sun, 5 Nov 2006 16:00:20 +0200
> We've noticed that when taking network interface down the local route
> for its address is preserved.
This behavior is intentional. IP addresses are associated with the
system, not a particular network interface. So if you want the IP and
it's local subnet route to go away, you must explicitly delete that IP
address from the interface, just downing the interface is not
sufficient.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-11-05 21:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-05 14:00 [RFC, PATCH] Purging local routes on NETDEV_DOWN event Boris Sukholitko
2006-11-05 15:56 ` Thomas Graf
2006-11-05 21:16 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).