[PATCH v2 2/2] Babel: Add option to control ecmp nexthop weight
Daniel Gröber
dxld at darkboxed.org
Mon May 9 14:39:00 CEST 2022
---
doc/bird.sgml | 7 +++++++
proto/babel/babel.c | 1 +
proto/babel/babel.h | 2 ++
proto/babel/config.Y | 2 ++
4 files changed, 12 insertions(+)
diff --git a/doc/bird.sgml b/doc/bird.sgml
index d1e6376b..8d159b22 100644
--- a/doc/bird.sgml
+++ b/doc/bird.sgml
@@ -1880,6 +1880,7 @@ protocol babel [<name>] {
check link <switch>;
next hop ipv4 <address>;
next hop ipv6 <address>;
+ ecmp weight <num>;
authentication none|mac [permissive];
password "<text>";
password "<text>" {
@@ -2008,6 +2009,12 @@ protocol babel [<name>] {
source for Babel packets will be used. In normal operation, it should not
be necessary to set this option.
+ <tag><label id="babel-ecmp-weight">ecmp weight <m>number</m></tag>
+ This specifies the relative weight used for nexthops going through
+ the iface when ECMP is enabled. Larger weight values relative to other
+ nexthops attract more traffic. Valid values are 1-256. Default value
+ is 1.
+
<tag><label id="babel-authentication">authentication none|mac [permissive]</tag>
Selects authentication method to be used. <cf/none/ means that packets
are not authenticated at all, <cf/mac/ means MAC authentication is
diff --git a/proto/babel/babel.c b/proto/babel/babel.c
index 01ea3a44..cd732eab 100644
--- a/proto/babel/babel.c
+++ b/proto/babel/babel.c
@@ -639,6 +639,7 @@ babel_nexthop_insert(
{
nh->gw = r->next_hop;
nh->iface = r->neigh->ifa->iface;
+ nh->weight = r->neigh->ifa->cf->ecmp_weight;
/*
* If we cannot find a reachable neighbour, set the entry to be onlink. This
diff --git a/proto/babel/babel.h b/proto/babel/babel.h
index 46e268fd..06b82799 100644
--- a/proto/babel/babel.h
+++ b/proto/babel/babel.h
@@ -147,6 +147,8 @@ struct babel_iface_config {
int tx_tos;
int tx_priority;
+ u8 ecmp_weight;
+
ip_addr next_hop_ip4;
ip_addr next_hop_ip6;
diff --git a/proto/babel/config.Y b/proto/babel/config.Y
index 92e754cd..0da5025d 100644
--- a/proto/babel/config.Y
+++ b/proto/babel/config.Y
@@ -70,6 +70,7 @@ babel_iface_start:
BABEL_IFACE->tx_tos = IP_PREC_INTERNET_CONTROL;
BABEL_IFACE->tx_priority = sk_priority_control;
BABEL_IFACE->check_link = 1;
+ BABEL_IFACE->ecmp_weight = 0;
};
@@ -149,6 +150,7 @@ babel_iface_item:
| AUTHENTICATION NONE { BABEL_IFACE->auth_type = BABEL_AUTH_NONE; }
| AUTHENTICATION MAC { BABEL_IFACE->auth_type = BABEL_AUTH_MAC; BABEL_IFACE->auth_permissive = 0; }
| AUTHENTICATION MAC PERMISSIVE { BABEL_IFACE->auth_type = BABEL_AUTH_MAC; BABEL_IFACE->auth_permissive = 1; }
+ | ECMP WEIGHT expr { BABEL_IFACE->ecmp_weight = $3 - 1; if (($3<1) || ($3>256)) cf_error("ECMP weight must be in range 1-256"); }
| password_list
;
--
2.30.2
More information about the Bird-users
mailing list