`setsockopt()` should be only called once with `MRT_TABLE`
in "enable" case, otherwise it will fail. In current code,
`mroute_socket` of "pim instance" with VRF can't be correctly
closed.
Skip it in the "disable" case to let `mroute_socket` safely
closed.
Christian Hopps [Wed, 19 Apr 2023 11:57:42 +0000 (07:57 -0400)]
tests: restore per-node logging functionality
After the munet switch we weren't passing the logger on to low-level
LinuxNamespace and thus Commander parent classes, so the lowest-level
`cmd_status` logs were missing from more specific log files in the run
directory.
Christian Hopps [Sat, 22 Apr 2023 01:59:33 +0000 (21:59 -0400)]
tests: fix check for daemon startup, remove sleep hack
- Remove the .pid and .vty files and then wait for them to show back up.
- Fix broken BGP GR test to not fail now that it's bug is exposed. It
only worked b/c when starting a daemon the pid file still existed and
blocked the bogus second BGP launch from happening.
David Lamparter [Fri, 21 Apr 2023 14:23:39 +0000 (16:23 +0200)]
lib: fix _hash_member() crash w/ empty hash
The typesafe hash _member() didn't check tabshift/count before
proceeding to look at the hash table, leading it to dereference a NULL
pointer when the hash table is in fact empty.
Test case added to tests/lib/test_typelist.
Note this function is not currently used anywhere. Only lib/cspf.c uses
_member(), but it does so on a RB-tree rather than a hash.
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
David Lamparter [Fri, 21 Apr 2023 13:14:43 +0000 (15:14 +0200)]
pimd: harden MLD code loop boundaries
Coverity complains about these being tainted/untrusted loop boundaries.
The way the code works, it's counting up groups/sources, but keeps
checking against remaining data length in the packet - which is
perfectly fine IMHO. Except Coverity doesn't understand it :(
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Donald Sharp [Fri, 21 Apr 2023 12:54:51 +0000 (08:54 -0400)]
zebra: ctx has to be non NULL at this point
Remove the pointer check for ctx. At this point in the
function it has to be non null since we deref'ed it.
Additionally the alloc function that creates it cannot
fail.
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
Chirag Shah [Sat, 22 Oct 2022 23:00:14 +0000 (16:00 -0700)]
zebra:fix evpn dup detected local mac del event
The current local mac delete event send to flag with force
always which breaks the duplicate detected MACs where
it requires to be resynced from bgpd to earlier state.
Chirag Shah [Wed, 1 Dec 2021 04:42:01 +0000 (20:42 -0800)]
zebra: evpn handle del event for dup detected mac
Upon receiving local mobility event for MAC + NEIGH,
both are detected as duplicate upon hitting DAD threshold.
Duplicated detected ( freezed) MAC + NEIGH are not known
to bgpd.
If locally learnt MAC + NEIGH are deleted in kernel,
the MAC is marked as AUTO after sending delete event
to bgpd.
Bgpd only reinstalls best route for MAC_IP route (NEIGH)
but not for MAC event.
This puts a situation where MAC is AUTO state and
associated neigh as remote.
Fix:
DUPLICATE + LOCAL MAC deletion, set MAC delete request
as reinstall from bgpd.
Donald Sharp [Thu, 20 Apr 2023 20:27:20 +0000 (16:27 -0400)]
bgpd: Fix lcom->str string length to correctly cover aliases
If you have a very large number of large communities whose
string length happened to be greater than BUFSIZ FRR's bgpd
would crash. This is because bgpd would write beyond
the end of the string.
Originally the code auto-calculated the string size appropriately
but commit ed0e57e3f079352714c3a3a8a5b0dddf4aadfe1d modified
the string length to be a hard coded BUFSIZ. When a route-map
like this is added:
Modify the code to correctly determine the string length of the communities
and to also double check if the string has an alias and ensure that the
string is still sufficiently large enough. If not auto size it again.
Rafael Zalamena [Mon, 27 Mar 2023 21:12:39 +0000 (18:12 -0300)]
topotests: RIP BFD integration topology test
Add new RIP topology to test the BFD integration and RIP ECMP:
shutdown a link and expect the RIP route change immediately instead of
regular RIP timer.
Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
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()
Before:
```
Routing Protocol is "rip"
Sending updates every 5 seconds with +/-50%, next due in 0 seconds
Timeout after 15 seconds, garbage collect after 10 seconds
Outgoing update filter list for all interface is not set
Incoming update filter list for all interface is not set
Default redistribution metric is 1
Redistributing:
Default version control: send version 2, receive any version
Interface Send Recv Key-chain
r1-eth0 2 1 2
Routing for Networks:
192.168.1.0/24
Routing Information Sources:
Gateway BadPackets BadRoutes Distance Last Update
192.168.1.2 0 0 120 00:00:05
192.168.1.3 0 0 120 00:00:04
Distance: (default is 120)
```
After:
```
Routing Protocol is "rip"
Sending updates every 5 seconds with +/-50%, next due in 4 seconds
Timeout after 15 seconds, garbage collect after 10 seconds
Outgoing update filter list for all interface is not set
Incoming update filter list for all interface is not set
Default redistribution metric is 1
Redistributing:
Default version control: send version 2, receive any version
Interface Send Recv Key-chain
r1-eth0 2 1 2
Routing for Networks:
192.168.1.0/24
Routing Information Sources:
Gateway BadPackets BadRoutes Distance Last Update
192.168.1.2 0 0 120 00:00:00
192.168.1.3 0 0 120 00:00:04
Distance: (default is 120)
```
```
r2# do sh ip rip status
Routing Protocol is "rip"
Sending updates every 5 seconds with +/-50%, next due in 4 seconds
Timeout after 15 seconds, garbage collect after 10 seconds
Outgoing update filter list for all interface is not set
Incoming update filter list for all interface is not set
Default redistribution metric is 1
Redistributing:
Default version control: send version 2, receive any version
Interface Send Recv Key-chain
lo 2 1 2
r2-eth0 2 1 2
Routing for Networks:
10.10.10.1/32
192.168.1.0/24
Passive Interface(s):
lo
r2-eth0
Routing Information Sources:
Gateway BadPackets BadRoutes Distance Last Update
192.168.1.3 0 0 120 00:00:04
Distance: (default is 120)
r2#
```
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>