bug: routes in linux kernel are not removed on withdraw if krt_metric is used

Ondrej Zajicek santiago at crfreenet.org
Tue May 28 17:50:35 CEST 2024


On Mon, May 27, 2024 at 07:42:03AM +0200, Leif Jakob via Bird-users wrote:
> 
> bird version: 2.0.12-7 (Debian stable)
> 
> Hi,
> 
> I use this config to install BGP routes into the linux kernel:
> 
> protocol kernel {
>   kernel table 300;
>   scan time 10;
>   learn on;
>   graceful restart;
>   metric 0; # needed to override in filter
> 
>   ipv6 {
>     import none; # kernel->bgp - nothing needed
>     export filter { # bgp->kernel
>       if ( proto = "xxx"       ) then { krt_metric = 20; accept; } # lower is choosed first by kernel
>       if ( proto = "yyy"       ) then { krt_metric = 30; accept; }
>       reject;
>     };
>   };
> }
> 
> This works fine. But when the route is removed (protocol gets down) it's still in the linux kernel.

Hi

Unfortunately, using krt_metric this way is rather unreliable.

We set this kernel attribute for route-add operation, and do not set it
for route-del operation (which should work like wildcard, assuming that
there is only one route for given net with 'proto bird', but it does not
work for route-replace operation where the new route has different metric
than the old route. In that case the new route is added while old route
is kept.

We should fix this by forcing add/remove instead of replace in this case.
But i would strongly suggest to set metric on per-protocol level with the
option 'metric', instead of using krt_metric route attribute.

Why do you need this? If you want alien/static routes to override some of
BIRD routes but not others, you could import them from kernel to BIRD,
make them override other BIRD routes in BIRD table so they would not be
exported to kernel.

-- 
Elen sila lumenn' omentielvo

Ondrej 'Santiago' Zajicek (email: santiago at crfreenet.org)
"To err is human -- to blame it on a computer is even more so."



More information about the Bird-users mailing list