Donald Sharp [Fri, 21 Apr 2023 11:57:19 +0000 (07:57 -0400)]
bgpd: Coverity mistakenly believes we can fall through
Coverity has incorrectly found that a switch statement
can be fallen through. It is missing the fact that the
previous case statement has a return through every path
it can get too. Let's just appease coverity
bgpd: Fix for ain->attr corruption during path update
1. Consider a established L2VPN EVPN BGP peer with soft-reconfiguartion
inbound configured
2. When the interface of this directly connected BGP peer is shutdown,
bgp_soft_reconfig_table_update() is called, which memsets the evpn buffer
and calls bgp_update() with received attributes stored in ain table(ain->attr).
In bgp_update(), evpn_overlay attribute in ain->attr (which is an interned
attr) was modified by doing a memcpy
3. Above action causes 2 attributes in the attrhash (which were previously different)
to match!
4. Later during fsm change event of the peer, bgp_adj_in_remove() is called
to clean up the ain->attr. But, because 2 attrs in attrhash match, it causes
BGP to assert in bgp_attr_unintern()
Eric Kinzie [Fri, 2 Sep 2022 14:33:21 +0000 (16:33 +0200)]
lib: convert termtable to json
Add a function that returns a JSON-C structure containing a representation
of a termtable. This is intended to be a quick way to implement JSON
output to CLI commands.
Louis Scalbert [Thu, 10 Nov 2022 15:36:08 +0000 (16:36 +0100)]
isisd: add affinity-map configuration hooks
Add affinity-map hooks to check the utilization of affinity-map in
flex-algo contexts before its deletion and to update local TLVs when the
affinity-map bit-position is updated.
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Eric Kinzie [Fri, 1 Apr 2022 00:47:30 +0000 (00:47 +0000)]
isisd: fix merging flex-algo route nodes
As isis_route_verify_merge() builds a new route table, each (src,dst)
new node in the table is created by merging data from the same (src,dst)
pair present in all route tables. However, as it iterates over those
route nodes and copies SR data into the newly created node, it repeatedly
overwrites the isis_route_info pointer. This, in turn, pollutes the
isis_route_info structures in all of the other tables with partially
updated SR data.
After a route is deleted, this leaves pointers to freed memory in one
of the route trees.
Fixes: 26b0598f6b6f ("isisd: fix isis_route_merge_verify logic") Signed-off-by: Eric Kinzie <ekinzie@labn.net>
Louis Scalbert [Mon, 12 Dec 2022 15:00:58 +0000 (16:00 +0100)]
isisd: add ASLA support
Add the support of ASLA with the following TLV:
- Extended IS Reachability (already defined TLV 22)
- Application-Specific Link Attributes (Sub-TLV 16)
(to enable the Flex-Algo flag on a link)
- Admin-group (Sub-Sub-TLV 3)
- Extended Admin-group (Sub-Sub-TLV 14)
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Ospf segfault when Router Information is enabled in a non default VRF,
see issue #13144.
This patch forces vrf_id to default VRF for Opaque LSA and extension based
on Opaque LSA: Router Information, Traffic Engineering, Extended Prefix,
Extended Link and Segment Routing. Indeed, non default VRF is not yet
supported for Opaque LSA & co.
Hiroki Shirokura [Sat, 18 Dec 2021 08:11:58 +0000 (08:11 +0000)]
lib,vtysh,isisd,yang: algo cli/yang/callbacks
Define the IS-IS flex-algo structure in yang, the CLI configuration
commands and the skeletons of frontend and backend functions that are
called by the CLI code.
Signed-off-by: Hiroki Shirokura <hiroki.shirokura@linecorp.com> Signed-off-by: Eric Kinzie <ekinzie@labn.net> Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
isisd: add TLV_SIZE_MISMATCH for tlvs length mismatch
Basically in frrouting source code principle,
the log string should not be a complicated abstraction
or streamlined for grep.
But for log format for the "TLV size does not match ..."
can be unified, which makes development easier.
> $ grep "TLV size does not match expected size for" isisd/isis_tlvs.c
> "TLV size does not match expected size for Administrative Group!\n");
> "TLV size does not match expected size for Local IPv6 address!\n");
> ...(snip)...
> "TLV size does not match expected size for Adjacency SID!\n");
> "TLV size does not match expected size for Adjacency SID!\n");
> "TLV size does not match expected size for Adjacency SID!\n");
> "TLV size does not match expected size for LAN-Adjacency SID!\n");
> "TLV size does not match expected size for LAN-Adjacency SID!\n");
> "TLV size does not match expected size for LAN-Adjacency SID!\n");
>
> $ grep "TLV size does not match expected size for" isisd/isis_tlvs.c | wc -l
> 25
Signed-off-by: Hiroki Shirokura <hiroki.shirokura@linecorp.com> Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Many of the enum definitions defined in isis_tlvs.h
are often extended at the end. The c/c++ allows
commas at the end of a list. This commit simplifies
the patching of later extensions.
Signed-off-by: Hiroki Shirokura <hiroki.shirokura@linecorp.com> Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Hiroki Shirokura [Sun, 12 Dec 2021 09:20:21 +0000 (09:20 +0000)]
isisd: update struct isis_route_info has multiple sr info by algorithm
Before this commit, there was only one sr psid info
included in route_info.
In fact, in RFC8667, Algorithm ID, which is a property of
Prefix-SID, has 8 bits of information. That is, each Prefix
can hold up to 256 Prefix-SIDs. This commit implements it.
The previously implemented single Prefix-SID will be
continued as Algorithm 0.
Signed-off-by: Hiroki Shirokura <hiroki.shirokura@linecorp.com> Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
isisd: update struct isis_sr_psid_info with nh context
Prefix-SID nexthops and backup nexthops are stored respectively in
isis_route_info->nexthops and isis_route_info->backup->nexthops.
With Flex-Algo, there are multiple Prefix-SIDs for a single prefix in
different algorithms. Each of these Prefix-SIDs performs SPF calculation
with a separate contract and sets a nexthops, so it is necessary to
store a different set nexthops for each Prefix-SID.
Add a nexthops and backup nethops list into the Prefix-SID
isis_sr_psid_info struct and use these lists instead of the when needed
After this commit, the nexthops for each Prefix-SID is not
taken from route_info, but the nexthop set inside the
Prefix-SID is taken. This works for backup nexthops as well.
Signed-off-by: Hiroki Shirokura <hiroki.shirokura@linecorp.com> Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Hiroki Shirokura [Sat, 11 Dec 2021 06:22:42 +0000 (06:22 +0000)]
isisd: update isis_tlvs_add_*_reach() with multi algorithm
isis_tlvs_add_extended_ip_reach adds IS-IS Extended
IP reachability to the LSP. In this case, if the
pcfg argument is not NULL, you can add IGP
Prefix-SID as its sub tlv.
Before this commit, only one Prefix-SID can be added.
After this commit, the argument is not a single
pointer but an array of pointers, and multiple
Prefix-SIDs can be added.
This feature is necessary because Flex-Algo
requires multiple Prefix-SIDs for each Algorithm.
Signed-off-by: Hiroki Shirokura <hiroki.shirokura@linecorp.com> Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Hiroki Shirokura [Sat, 18 Dec 2021 09:03:01 +0000 (09:03 +0000)]
isisd: update SR_ALGORITHM_COUNT to 256
Before this commit, SR_ALGORITHM_COUNT was set to 2,
and each was hardcoded with router capability tlv.
When Flex-Algo is supported, SR-Algorithm may be
variably supported up to 256.
Signed-off-by: Hiroki Shirokura <hiroki.shirokura@linecorp.com> Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
ospfd: use rib metric as the base for set metric +/-
When using route maps with external routes in OSPF as follows:
```
set metric +10
```
The current behavior is to use the default ospf metric as the base and then add
to 10 to it. The behavior isn't useful as-is. A value 30 (20 dfeault + 10) can
be set directly instead. the behavior is also not consistent with bgp. bgp does
use the rib metric in this case as the base. The current behavior also doesn't
allow the metric to accumulate when crossing different routing domains such as
vrfs causing the metric to reset every time the route enters a new vrf with a new
ospf network.
This PR changes the behavior such that the rib metric is used as a base for
ospf exteral routes when used with `set metric -/+`
Hiroki Shirokura [Sat, 11 Dec 2021 03:01:07 +0000 (03:01 +0000)]
isisd: update struct isis_sr_psid_info with algorithm id
The information in prefix-sid has a new property
called algorithm id. This is used to identify
the algorithm that separates it in the same IGP
network. This is used in Flex-Algo.In all other
cases, the algorithm id is basically 0.
Signed-off-by: Hiroki Shirokura <hiroki.shirokura@linecorp.com> Signed-off-by: Eric Kinzie <ekinzie@labn.net> Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Hiroki Shirokura [Sat, 11 Dec 2021 02:21:30 +0000 (02:21 +0000)]
isisd: update struct sr_prefix_cfg with algorithm id
The information in prefix-sid has a new property
called algorithm id. This is used to identify
the algorithm that separates it in the same IGP
network. This is used in Flex-Algo.In all other
cases, the algorithm id is basically 0.
Signed-off-by: Hiroki Shirokura <hiroki.shirokura@linecorp.com> Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Hiroki Shirokura [Sat, 11 Dec 2021 02:09:23 +0000 (02:09 +0000)]
isisd: update struct isis_spftree with algorithm id
The spftree has a new property called algorithm
which is id used to identify the algorithm that
separates it in the same IGP network. This is
used in Flex-Algo. In other cases than Flex-Algo,
the algorithm id is always zero.
Signed-off-by: Hiroki Shirokura <hiroki.shirokura@linecorp.com> Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Christian Hopps [Mon, 17 Apr 2023 05:36:46 +0000 (01:36 -0400)]
tests: use a more specific xpath for finding the route JSON data
Rather than requesting the data for the entire model, just request the route
data for the specific prefix. This also tests the xpath code (which was
previously broken).
Christian Hopps [Mon, 17 Apr 2023 05:34:46 +0000 (01:34 -0400)]
tests: quick fix for --gdb-daemons=DAEMONLIST not working
When launching the daemons under gdb it takes a bit for them to come up, the
currently code only looks for pid files to determine if the daemon is running.
This test is no good as these files are left around by previous runs.
For now do a simple sleep when debugging with gdb to get things working.
Christian Hopps [Mon, 17 Apr 2023 05:16:32 +0000 (01:16 -0400)]
lib: fix broken "show yang operational-data" functionality
Previously was using an API that returned the root of the data tree given the
users input xpath value, and then used it like it was the leaf node (last not
first). So basically this CLI command only worked when one requested the root
node of the model.
Christian Hopps [Mon, 17 Apr 2023 05:09:05 +0000 (01:09 -0400)]
lib: add and use new yang function for finding schema nodes
Add a wrapper around lys_find_xpath which has an unfortunate API
returning an allocated set of schema nodes when we only ever expect and
want one.
Another libyang function `lys_find_path` returns a single node; however,
that function can assert/abort on invalid path values so is unsuitable
for user input.
Replace previous uses of `lys_find_path` with new API when dealing with
possible invalid path values (i.e., from a user).
bgpd:add correct value into dfAlgorithm json output
FRR "show bgp l2 evpn es <esi-id> json" output shows 'dfAlgorithm'
same as 'dfPreference' value instead of algorithm.
Modified the code to set the correct DF algorithm value into
'dfAlgorithm' field.
torm-11# show bgp l2 evpn es
ES Flags: B - bypass, L local, R remote, I inconsistent
VTEP Flags: E ESR/Type-4, A active nexthop
ESI Flags RD #VNIs
VTEPs
03:44:38:39:ff:ff:01:00:00:01 LR 27.0.0.15:15 10
27.0.0.16(EA),27.0.0.17(EA)
03:44:38:39:ff:ff:01:00:00:02 LR 27.0.0.15:16 10
27.0.0.16(EA),27.0.0.17(EA)
03:44:38:39:ff:ff:01:00:00:03 LR 27.0.0.15:17 10
27.0.0.16(EA),27.0.0.17(EA)
03:44:38:39:ff:ff:02:00:00:01 R - 10
27.0.0.18(A),27.0.0.19(A),27.0.0.20(A)
03:44:38:39:ff:ff:02:00:00:02 R - 10
27.0.0.18(A),27.0.0.19(A),27.0.0.20(A)
03:44:38:39:ff:ff:02:00:00:03 R - 10
27.0.0.18(A),27.0.0.19(A),27.0.0.20(A)
torm-11#
Before Fix:-
```
torm-11# show bgp l2 evpn es 03:44:38:39:ff:ff:01:00:00:01 json
{
"esi":"03:44:38:39:ff:ff:01:00:00:01",
"rd":"27.0.0.15:15",
"type":[
"local",
"remote"
],
"vteps":[
{
"vtep_ip":"27.0.0.16",
"flags":[
"esr",
"active"
],
"dfPreference":32767,
"dfAlgorithm":32767 =====> dfAlgorithm is same as dfPreference
},
{
"vtep_ip":"27.0.0.17",
"flags":[
"esr",
"active"
],
"dfPreference":32767,
"dfAlgorithm":32767 =====> dfAlgorithm is same as dfPreference
}
],
"flags":[
"up",
"advertiseEVI"
],
"originator_ip":"27.0.0.15",
"remoteVniCount":10,
"vrfCount":3,
"macipPathCount":33,
"macipGlobalPathCount":264,
"inconsistentVniVtepCount":0,
"localEsDfPreference":50000,
"fragments":[
{
"rd":"27.0.0.15:15",
"eviCount":10
}
]
}
torm-11#
```
Christian Hopps [Sat, 15 Apr 2023 13:37:30 +0000 (09:37 -0400)]
tests: restart bgpd to avoid warnings in follow on tests
The tests are killing bgpd and then ending, the next test is checking for all
daemons running and spewing warnings to stderr. Restart the daemons before
ending the test (like other tests in this same module) to avoid this.
tools: fix missing remote-as configuration when reload
From commit `411d1a2`, `bgp_delete_nbr_remote_as_line()` is added to
remove some specific bgp neighbors. But, when reloading the following
configuration, it will wrongly remove some good ones:
`neighbor 66.66.66.6 remote-as internal`:
tor-11# bridge -d fdb show | grep 00:65:00:00:00:01
00:65:00:00:00:01 dev hostbond1 vlan 1000 notify master bridge static
tor-12 receives sync MAC route:
Before fix:
----------
tor-12:/# bridge -d fdb show | grep 00:65:00:00:00:01
00:65:00:00:00:01 dev hostbond1 vlan 1000 notify master bridge static
After fix: inactive is set to MAC entry
----------
tor-12:/#bridge -d fdb show | grep 00:65:00:00:00:01
00:65:00:00:00:01 dev hostbond1 vlan 1000 notify inactive master bridge
static
Notice the difference in `inactive` post notify on tor-12
with the fix.
Signed-off-by: Trey Aspelund <taspelund@nvidia.com> Signed-off-by: Chirag Shah <chirag@nvidia.com>
Philippe Guibert [Fri, 14 Apr 2023 08:44:41 +0000 (10:44 +0200)]
lib: fix handle seg6local routes on default vrf
An L3VPN network can be configured on the main BGP instance,
with an SRv6 SID. By declaring a network, a seg6local route
is created but remains invalid.
The below BGP VPN configuration the default VRF has been
used:
> router bgp 1
> address-family ipv6 unicast
> sid vpn export auto
> rd vpn export 1:30
> rt vpn both 77:77
> import vpn
> export vpn
> network 2001:7::/64
> exit-address-family
The below seg6local route has been added:
> # show ipv6 route
> [..]
> B 2001:db8:2:2:300::/128 [20/0] is directly connected, unknown inactive, seg6local End.DT6 table 254, seg6 ::, weight 1, 00:00:07
>
When creating the seg6local route, an interface is used as nexthop.
The interface index is obtained from the vrf identifier. This is
true when using VRF interfaces, but is wrong when using the lo
interface which usually has the '1' ifindex whereas the vrf id for
the default VRF is 0.
Get the appropriate index from the vrf identifier.
The below seg6local route is visible:
lynne [Wed, 23 Jun 2021 17:15:17 +0000 (13:15 -0400)]
ospf6d: missing ECMP NHs in certain topologies
When ospf6 is started up and SPF is run depending on which route is
selected as the parent route we could miss adding a NH. If one
possible parent route has two equal cost paths and the second possible
parent route has only one depending on which one is selected first
determines if we have have one or two NHs.
In the network below when creating a route 2001:db8:3:4::/64 in R2.
When SPF is run there are two possible parent routes R3 and R4.
The problem was if we first created the route to 2001:db8:3:4::/64 with R3
as the parent route all is fine. The code was merging the NH from the parent
route and R3 has 2 NH, one pointing to R1 and one to R5. But if route
2001:db8:3:4::/64 was first created with parent as R4, it has only one NH
pointing to R1, and then later a new vertex was created pointing to R3 the
code would only copy the nhs from the vertex not from the parent route. The
vertex always has just one NH. But the parent route could have more. So
when we would bringup this setup one time we would see one NH for
2001:db8:3:4::/64 and the next time we would see two NHs. The code has been
modified so that it behaves the same when the route is first created, or when
a vertex is created, it selects the NHs from the parent route.