Removing device-bound routes when interface is going down

Alexander Demenshin aldem-bird.2014 at nk7.net
Mon Aug 18 19:32:10 CEST 2014


Hi (again),

I've encountered a problem which is (most likely) is caused by a bug
in the Linux kernel, but significantly affects routing handling in bird
(everything else like quagga is most likely also affected).

When route is added manually/externally to the kernel, and bound to 
specific
interface, like this:

$ ip route add 10.1.1.0/24 dev eth0

...it is correctly identified by bird (via async netlink message), but 
when
the interface goes down, this route is not deleted, as there is no 
corresponding
netlink message (tested on most recent kernel, 3.16.1, and also on older 
3.11,
this happens only on if-down event, manual deletion works fine).

Since bird does not see the route removal, it is still kept in the 
routing table,
thus, it is still announced via OSPF (in my particular case), however 
the kernel
knows nothing about this.

Obviously, it is possible to set up periodic scanning of kernel table 
with small
interval, but even then, this removal will not be instant, and 
additionally,
it introduces additional CPU usage - even if the table in question is 
small by itself,
but there is another huge table, this scan will consume significant 
time,
in my case - it takes 0.3s to dump main table (~10 entries), all due to
huge BGP table (~500k entries), thus scanning every 10 seconds will 
consume 3% CPU
(mostly for nothing, as this kind of changes are relatively seldom).

Fixing this problem in the mainstream kernel (if this is indeed 
unintentional behavior)
will clearly take ages, but it could be easily solved in bird itself - 
if interface
is going down, all routes pointing to this device must be removed (not 
only
direct and static routes - where it works perfectly).

I feel that this workaround is quite easy to implement, but not sure 
where exactly
to look, thus I'll be really grateful for right directions :)

Thank you!

-- 
With best regards,
Alexander.




More information about the Bird-users mailing list