Commit Graph

32667 Commits

Author SHA1 Message Date
Christian Hopps
346374b04f tests: will need new pid_exists if using pid namespaces
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-04-21 22:13:04 -04:00
Christian Hopps
2b62abe441 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.

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-04-21 22:10:54 -04:00
Christian Hopps
260268c45c 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.

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-04-21 22:10:54 -04:00
Christian Hopps
ff28990ee4 tests: add --logd option
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-04-21 22:10:54 -04:00
Christian Hopps
773fd82ed5 tests: add --pcap and --pause-at-end options
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-04-21 22:10:54 -04:00
Christian Hopps
249ac6f0f2 tests: cleanup access to pytest config
Rather than create a new global dict and copy all the config into it, just
expose the pytest config globally and use it directly.

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-04-21 22:10:54 -04:00
Christian Hopps
7592b2ccae tests: blacken re-format
Signed-off-by: Christian Hopps <chopps@labn.net>
2023-04-21 22:10:48 -04:00
Olivier Dugeon
30584b6f6a lib: Fix memory leak in in Link State
When using ls_stream2ted() function to parse Opaque Link State message to local
TED, in case of vertex or subnet deletion, the function return a pointer to the
deleted ls_element instead of NULL. This could lead into a potential pointer
corruption when caller try to access to the deleted ls_element.

This patch ensure that the ls_element pointer return by ls_stream2ted()
function is NULL when the message event is a delete operation for vertex and
subnet. Note that edge deletion was correctly handled.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2023-04-21 18:24:51 +02:00
David Lamparter
c53ab57b79
Merge pull request #13347 from donaldsharp/bgp_before_light 2023-04-21 18:23:17 +02:00
David Lamparter
3c034cb342
Merge pull request #13345 from donaldsharp/pim_after_dark 2023-04-21 18:22:39 +02:00
David Lamparter
6cfef15385
Merge pull request #13348 from donaldsharp/dplane_before_after 2023-04-21 18:22:22 +02:00
Olivier Dugeon
871b46e7eb lib: Link State memory corruption
In function ls_find_subnet(), prefix argument is directly copied into
subnet.key structure to find corresponding subnet in RB Tree. This could leadr
to a memory corruption. Function prefix_copy() must be used instead.

This patch replaces the direct prefix copy by a call to prefix_copy() function
to avoid this memory issue.

Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
2023-04-21 18:09:28 +02:00
David Lamparter
5523a505f4 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>
2023-04-21 16:30:32 +02:00
David Lamparter
ae19023b8e lib: typesafe hash table breadcrumbs
Looking at the coverity report, it complains that tabshift could be
zero, resulting in a uint32_t shifted by 33 (which is undefined.)

As I was confused by the "+ 1", in addition to the SA assume(), leave
some breadcumbs for next time this comes up.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-04-21 16:27:21 +02:00
Donald Sharp
de35b3c29a
Merge pull request #13327 from opensourcerouting/fix/rip_status_align
ripd: Align show ip rip status output for sources
2023-04-21 09:41:00 -04:00
David Lamparter
54c037a187 pimd: annotate some pointers as non-null
... make static analysis happy.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-04-21 15:30:43 +02:00
David Lamparter
ac4304d0fa 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>
2023-04-21 15:30:43 +02:00
Donald Sharp
a7209c2dbc lib: Make coverity happy about close
The error condition handled both failure to open
and a fstat failure.  Just double check that the close
is appropriate to call.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-04-21 09:12:08 -04:00
Donald Sharp
6f99cfcd89 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.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-04-21 08:54:51 -04:00
Donald Sharp
332133d19b bgpd: Ensure bgp_vrf is non-null
If we attempt to get the bgp_vrf and it fails then
ensure that we don't just de-ref and crash.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-04-21 08:04:06 -04:00
Donald Sharp
bc479b1b17 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

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-04-21 07:57:19 -04:00
Donald Sharp
852f96eb03 bgpd: All paths have already de-refed rd_str
Coverity points out that rd_str has already been
deref'ed in all paths leading to this spot.  No
need to keep at it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-04-21 07:54:00 -04:00
Donald Sharp
35801e6234 pimd: Tell coverity what is really going on
Fix a code path that coverity has decided a variable
is NULL when it never can be.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-04-21 07:38:11 -04:00
Donald Sharp
db865bf6ed pimd: Fix possible null of pim instance
Coverity shows a path where the pim instance may
be null.  In this code path if we have no pim
vrf there is nothing to do anyway so just return

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-04-21 07:08:53 -04:00
Olivier Dugeon
4dbef8567b
Merge pull request #13334 from louis-6wind/flexalgo-fixes
isisd: fixes for Flex-Algo
2023-04-21 08:58:22 +02:00
Jafar Al-Gharaibeh
719986cc3e
Merge pull request #13341 from donaldsharp/bgp_lcommunity_crash
bgpd: Fix lcom->str string length to correctly cover aliases
2023-04-21 00:54:45 -05:00
Chirag Shah
89844a9678 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.

Ticket:#3233019
Issue:3233019

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2023-04-20 15:45:39 -07:00
Chirag Shah
ad7685de28 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.

Ticket:#2873307
Reviewed By:
Testing Done:

Freeze MAC + two NEIGHs in local mobility event.
Delete MAC and NEIGH from kerenl.
bgp rsync remote mac route which puts MAC to remote state.

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2023-04-20 15:45:26 -07:00
Donald Sharp
8cb4892c06 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 ed0e57e3f0 modified
the string length to be a hard coded BUFSIZ.  When a route-map
like this is added:

route-map LARGE-OUT permit 10
 set large-community 4635:0:0 4635:1:906 4635:1:2906 4635:1:4515 4635:1:4594 4635:1:4641 4635:1:4760 4635:1:7979 4635:1:9253 4635:1:9293 4635:1:9304 4635:1:9908 4635:1:13335 4635:1:16265 4635:1:17924 4635:1:18013 4635:1:20940 4635:1:22822 4635:1:24429 4635:1:24482 4635:1:32590 4635:1:32934 4635:1:36692 4635:1:38008 4635:1:38819 4635:1:41378 4635:1:45753 4635:1:46489 4635:1:49544 4635:1:51847 4635:1:54574 4635:1:54994 4635:1:55720 4635:1:56059 4635:1:57724 4635:1:65021 4635:1:134823 4635:1:136907 4635:1:146961 24115:0:24115 24115:1:906 24115:1:2906 24115:1:4515 24115:1:4594 24115:1:4641 24115:1:4760 24115:1:7979 24115:1:9253 24115:1:9293 24115:1:9304 24115:1:9908 24115:1:13335 24115:1:16265 24115:1:17924 24115:1:18013 24115:1:20940 24115:1:22822 24115:1:24429 24115:1:24482 24115:1:32590 24115:1:32934 24115:1:36692 24115:1:38008 24115:1:38819 24115:1:41378 24115:1:45753 24115:1:46489 24115:1:49544 24115:1:51847 24115:1:54574 24115:1:54994 24115:1:55720 24115:1:56059 24115:1:57724 24115:1:65021 24115:1:134823 24115:1:136907 24115:1:100000 24115:1:100001 24115:1:100002
exit

BGP would have issues and crash.

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.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-04-20 16:51:56 -04:00
Philippe Guibert
7b343a9ed5
Merge pull request #12933 from Orange-OpenSource/link_state
lib: Update edge key in link state database
2023-04-20 18:33:21 +02:00
Louis Scalbert
3ae589b8a5 isisd: fix add an algorithm argument to show isis route
"show isis route algorithm ALGO json" display some text output before
printing the JSON one.

Do not print the text output in JSON mode.

Fixes: 0833c25180 ("isisd: add an algorithm argument to show isis route")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2023-04-20 16:23:50 +02:00
Louis Scalbert
60f9275a8c isisd: fix potential null pointer in isis_affinity_map_update()
Reported by coverity scanner #1560315

Do not attempt to update the affinity map if the main isis struct is not
yet created.

Fixes: 9a65cf35da ("isisd: add affinity-map configuration hooks")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2023-04-20 16:23:50 +02:00
Louis Scalbert
eb74bbd5b3 isisd: fix wrong pointer test in area_resign_level()
Fix a wrong pointer test issue reported by coverity scanner #1560314

Fixes: 860b75b40e ("isisd: calculate flex-algo constraint spf")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2023-04-20 16:23:50 +02:00
Louis Scalbert
eb2010de2a isisd: fix potential null pointer in isis_affinity_map_check_use()
Reported by coverity scanner #1560313

Do not consider the affinity map is in use if the main isis struct is
not yet created.

Fixes: 9a65cf35da ("isisd: add affinity-map configuration hooks")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2023-04-20 16:23:50 +02:00
Louis Scalbert
84aaf8d32a isisd: fix overrun in isis_flex_algo_constraint_drop()
Coverity scanner reported the overrun issue #1560312 because
reach->id length is 7 bytes and we are trying to copy 8 bytes
(ie. ISIS_SYS_ID_LEN + 2).

Fix the issue by using the %pPN to display directly the 7 bytes
system-id.

Fixes: 860b75b40e ("isisd: calculate flex-algo constraint spf")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2023-04-20 16:23:29 +02:00
Donatas Abraitis
696172d7bd tests: Align show ip rip status output in tests
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-04-19 22:08:03 +03:00
Donatas Abraitis
e2bebeb666
Merge pull request #13329 from Pdoijode/pdoijode/bgp-attr-crash-fix
bgpd: Fix for ain->attr corruption during path update
2023-04-19 21:48:34 +03:00
Donatas Abraitis
5db1931962
Merge pull request #13166 from Jafaral/ospf-external-metric
ospfd: use rib metric as the base for set metric +/-
2023-04-19 21:11:25 +03:00
Rafael Zalamena
5e69093713 doc: RIP BFD integration documentation
Let users know about the RIP BFD integration commands and increment the
used RFCs reference.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2023-04-19 11:17:55 -03:00
Rafael Zalamena
7001bdb7b2 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>
2023-04-19 11:17:52 -03:00
Renato Westphal
c262df828b ripd: support BFD integration
Implement RIP peer monitoring with BFD.

RFC 5882 Generic Application of Bidirectional Forwarding Detection
(BFD), Section 10.3 Interactions with RIP.

Co-authored-by: Renato Westphal <renato@opensourcerouting.org>
Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2023-04-19 09:15:01 -03:00
Pooja Jagadeesh Doijode
6e076ba523 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()

Signed-off-by: Pooja Jagadeesh Doijode <pdoijode@nvidia.com>
2023-04-18 18:40:06 -07:00
Donatas Abraitis
36608f6081 ripd: Align show ip rip status output for sources
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)
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-04-18 22:50:11 +03:00
Donatas Abraitis
0a2268c28e tests: Check if RIPd passive-interface works as expected
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-04-18 22:37:53 +03:00
Donatas Abraitis
6dbe6f12fa ripd: Create non default passive interface if defined so
Without this patch, it's never get non-passive and even listed under status:

Configuration:

```
router rip
 network 192.168.1.0/24
 network 10.10.10.1/32
 passive-interface default
 no passive-interface r2-eth0
 timers basic 5 15 10
exit
```

```
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#
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-04-18 21:19:34 +03:00
Mark Stapp
fec51f2e2b
Merge pull request #13323 from LabNConsulting/style-update
style: add format checker config and remove .dir-locals.el
2023-04-18 13:13:35 -04:00
Olivier Dugeon
fd4377d9a5
Merge pull request #11667 from louis-6wind/flexalgo-mpls
isisd: Flex-Algo for SR-MPLS
2023-04-18 14:45:30 +02:00
Russ White
59b2a1048f
Merge pull request #13236 from Orange-OpenSource/ospf-te
ospfd: Force Opaque LSA & co to default VRF
2023-04-18 08:32:20 -04:00
Louis Scalbert
cba6998236 doc: add isisd flex-algo documentation
Add the isisd flex-algo documentation

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2023-04-18 11:33:15 +02:00
Louis Scalbert
b95f9f37ea doc: fix debugging-isis reference
Debugging-isis tag was moved.

Move it to right place.

Fixes: 9389175b75 ("doc: add documentation for IS-IS Segment Routing")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2023-04-18 11:33:15 +02:00