How to make BIRD use the kernel routing metric?
Hello, I use BIRD 2.0.2 and want the OSPF daemon to announce the Linux kernel routing metric. For instance, if I run "ip route add table 44 to 10.2.3.0/24 metric 1234 dev eth0", I want this route to propagate into BIRD. Therefore I use the kernel protocol configured like this: protocol kernel { ipv4 { export all; import all; }; learn; kernel table 44; scan time 10; } My OSPF instance reads data from table master4. "show ospf state" displays my kernel route as "external", but with "metric2 10000". According to the documentation https://bird.network.cz/?get_doc&v=20&f=bird-6.html#ss6.6 I tried to use metric 0; but without any effect. Do I overlook something essential? Best regards Lukas Liebig
On Wed, 2018-11-14 at 08:21 +0100, Lukas Liebig wrote:
Hello,
I use BIRD 2.0.2 and want the OSPF daemon to announce the Linux kernel routing metric. For instance, if I run "ip route add table 44 to 10.2.3.0/24 metric 1234 dev eth0", I want this route to propagate into BIRD. Therefore I use the kernel protocol configured like this:
protocol kernel { ipv4 { export all; import all; }; learn; kernel table 44; scan time 10; }
You can define a preference value for kernel routes. E.g. protocol kernel { ipv4 { export all; import all; preference 1234; }; learn; kernel table 44; scan time 10; } But this gives you a global value for all kernel routes. I know that Quagga can import the kernel routes with their individual metrics. Not sure how to achieve the same in BIRD. /k
Not sure how to achieve the same in BIRD.
While you are at it … (sorry for riding along on your thread) It raises the general question of „how does one extract certain data from different protocols“, i.e. into a variable so it can be „mathed“ with and then re-used in an im- or export filter to be translated into another protocol’s metric. So in your case: Can the krt_metric attribute of routes „learned“ from the kernel be read and stored in a variable? In my case: How can I read the contents of each part of the tuplets/triplets from BGP communities? So far I only know of ways to test for the existence of particular values. (i.e. get the third part of a BGP large community with known first & second parts into a variable) Thanks for any hints provided - Clemens
On Wed, Nov 14, 2018 at 10:13:31AM +0100, Clemens Schrimpe wrote:
Not sure how to achieve the same in BIRD.
While you are at it … (sorry for riding along on your thread)
It raises the general question of „how does one extract certain data from different protocols“, i.e. into a variable so it can be „mathed“ with and then re-used in an im- or export filter to be translated into another protocol’s metric.
So in your case: Can the krt_metric attribute of routes „learned“ from the kernel be read and stored in a variable?
Well, krt_metric is already accessible for whole existence of the route. You could store it to a filter-local variable, or you could use it directly in computation. You could even do things like: if krt_metric < 1000 then ospf_metric1 = krt_metric * 10; else ospf_metric2 = krt_metric - 1000;
In my case: How can I read the contents of each part of the tuplets/triplets from BGP communities? So far I only know of ways to test for the existence of particular values. (i.e. get the third part of a BGP large community with known first & second parts into a variable)
The issue here is more that we does not have feature to iterate through sets/lists, e.g. AS_PATH and COMMUNITY attribute. -- Elen sila lumenn' omentielvo Ondrej 'Santiago' Zajicek (email: santiago@crfreenet.org) OpenPGP encrypted e-mails preferred (KeyID 0x11DEADC3, wwwkeys.pgp.net) "To err is human -- to blame it on a computer is even more so."
On Wed, Nov 14, 2018 at 08:21:12AM +0100, Lukas Liebig wrote:
Hello,
I use BIRD 2.0.2 and want the OSPF daemon to announce the Linux kernel routing metric. For instance, if I run "ip route add table 44 to 10.2.3.0/24 metric 1234 dev eth0", I want this route to propagate into BIRD. Therefore I use the kernel protocol configured like this:
protocol kernel { ipv4 { export all; import all; }; learn; kernel table 44; scan time 10; }
My OSPF instance reads data from table master4. "show ospf state" displays my kernel route as "external", but with "metric2 10000". According to the documentation https://bird.network.cz/?get_doc&v=20&f=bird-6.html#ss6.6 I tried to use metric 0; but without any effect. Do I overlook something essential?
Hi Kernel metric is stored in attribute krt_metric, OSPF metric is set by attribute ospf_metric1 or ospf_metric2. Therefore the required behavior could be achieved by: ospf_metric2 = krt_metric; in either kernel import filter or OSPF export filter. -- Elen sila lumenn' omentielvo Ondrej 'Santiago' Zajicek (email: santiago@crfreenet.org) OpenPGP encrypted e-mails preferred (KeyID 0x11DEADC3, wwwkeys.pgp.net) "To err is human -- to blame it on a computer is even more so."
Thank you for your answers! My problem is solved. filter ospfExport { if defined( krt_metric ) && krt_metric > 0 && krt_metric < 16777216 then { ospf_metric1 = krt_metric; accept "accepted"; } else { reject "rejected"; } } Am Mi., 14. Nov. 2018 um 14:43 Uhr schrieb Ondrej Zajicek < santiago@crfreenet.org>:
On Wed, Nov 14, 2018 at 08:21:12AM +0100, Lukas Liebig wrote:
Hello,
I use BIRD 2.0.2 and want the OSPF daemon to announce the Linux kernel routing metric. For instance, if I run "ip route add table 44 to 10.2.3.0/24 metric 1234 dev eth0", I want this route to propagate into BIRD. Therefore I use the kernel protocol configured like this:
protocol kernel { ipv4 { export all; import all; }; learn; kernel table 44; scan time 10; }
My OSPF instance reads data from table master4. "show ospf state" displays my kernel route as "external", but with "metric2 10000". According to the documentation https://bird.network.cz/?get_doc&v=20&f=bird-6.html#ss6.6 I tried to use metric 0; but without any effect. Do I overlook something essential?
Hi
Kernel metric is stored in attribute krt_metric, OSPF metric is set by attribute ospf_metric1 or ospf_metric2.
Therefore the required behavior could be achieved by:
ospf_metric2 = krt_metric;
in either kernel import filter or OSPF export filter.
-- Elen sila lumenn' omentielvo
Ondrej 'Santiago' Zajicek (email: santiago@crfreenet.org) OpenPGP encrypted e-mails preferred (KeyID 0x11DEADC3, wwwkeys.pgp.net) "To err is human -- to blame it on a computer is even more so."
participants (4)
-
Clemens Schrimpe -
Kenth Eriksson -
Lukas Liebig -
Ondrej Zajicek