Commit graph

6232 commits

Author SHA1 Message Date
Donald Sharp f0b2bc3b4c zebra: add ability to specify output file with fpm_listener
The fpm_listener didn't have the ability to specify the output
file location at all.  Modify the code to accept this.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2025-03-14 13:24:19 -04:00
Jafar Al-Gharaibeh 7945af0200
Merge pull request #18360 from raja-rajasekar/rajasekarr/fix_explicit_sid_allocation
zebra: ensure proper return for failure for Sid allocation
2025-03-14 09:57:41 -05:00
Mark Stapp 27953dd141
Merge pull request #18336 from routingrocks/rvaratharaj/bugfixmar
zebra: Fix neigh delete causing heap-use-after-free error
2025-03-12 08:09:29 -04:00
Rajesh Varatharaj 3060afc84d zebra: Fix neigh delete causing heap-use-after-free error
Issue:
Not freeing the neighbor n  within the same function can lead to
memory leak.
zebra_neigh_del_all() -> zebra_neigh_del() re lookup and free

Fix: not accessing n after its freed.
Directly free the neighbor entry (n) when its interface index matches
ifp->ifindex.

This fixes:
ERROR: AddressSanitizer: heap-use-after-free on address 0x6070001052e8 at pc 0x7f6bf7d09ddb bp 0x7ffd3366a000 sp 0x7ffd33669ff0
READ of size 8 at 0x6070001052e8 thread T0
    #0 0x7f6bf7d09dda in _rb_next lib/openbsd-tree.c:455
    #1 0x55f95a307261 in zebra_neigh_rb_head_RB_NEXT zebra/zebra_neigh.h:34
    #2 0x55f95a3082e9 in zebra_neigh_del_all zebra/zebra_neigh.c:162
    #3 0x55f95a121ee7 in zebra_interface_down_update zebra/redistribute.c:571
    #4 0x55f95a0f819d in if_down zebra/interface.c:1017
    #5 0x55f95a0fe168 in zebra_if_dplane_ifp_handling zebra/interface.c:2102
    #6 0x55f95a0ff10c in zebra_if_dplane_result zebra/interface.c:2241
    #7 0x55f95a27ce9c in rib_process_dplane_results zebra/zebra_rib.c:5015
    #8 0x7f6bf7da3ad9 in event_call lib/event.c:1984
    #9 0x7f6bf7c62141 in frr_run lib/libfrr.c:1246
    #10 0x55f95a11ca7f in main zebra/main.c:543
    #11 0x7f6bf7029d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #12 0x7f6bf7029e3f in __libc_start_main_impl ../csu/libc-start.c:392
    #13 0x55f95a0dd0b4 in _start (/usr/lib/frr/zebra+0x1a80b4)

Ticket: #18047

Signed-off-by: Rajesh Varatharaj <rvaratharaj@nvidia.com>
2025-03-11 13:41:40 -07:00
Mark Stapp d0cb3ad7cb
Merge pull request #16614 from louis-6wind/fix-otable-heap-after-free
zebra: fix table heap-after-free crash
2025-03-11 14:03:14 -04:00
Rajasekar Raja 5a63cf4c0d zebra: ensure proper return for failure for Sid allocation
The functions alloc_srv6_sid_func_explicit/dynamic expect to return bool
but we have places where we return a -1 or NULL which the caller is
assuming as a True/Valid and ending up allocating Sid

Without Fix:
2025/03/10 21:44:04.295350 ZEBRA: [XWV20-TGK70] alloc_srv6_sid_func_explicit: trying to allocate explicit SID function 65088 from block fcbb:bbbb::/32
2025/03/10 21:44:04.295351 ZEBRA: [MM61M-TQZNP] alloc_srv6_sid_func_explicit: elib s 10000 e 20000 wlib s 1000 ewlib s 30000 e 1000 SID_FUNC 65088
2025/03/10 21:44:04.295352 ZEBRA: [QGHMB-SWNFW] alloc_srv6_sid_func_explicit: function 65088 is outside ELIB [10000/20000] and EWLIB alloc ranges [30000/1000]
2025/03/10 21:44:04.295367 ZEBRA: [H0GZA-NNSWJ] get_srv6_sid_explicit: allocated explicit SRv6 SID fcbb:bbbb:1:fe40:: for context End.X nh6 2001::2
2025/03/10 21:44:04.295368 ZEBRA: [XBBYD-T1Q7P] srv6_manager_get_sid_internal: got new SRv6 SID for ctx End.X nh6 2001::2: sid_value=fcbb:bbbb:1:fe40:: (func=65088) (proto=4, instance=0, sessionId=0), notifying all clients

With Fix:
2025/03/10 22:04:25.052235 ZEBRA: [MM61M-TQZNP] alloc_srv6_sid_func_explicit: elib s 30000 e 31000 wlib s 31000 ewlib s 30000 e 31000 SID_FUNC 65056
2025/03/10 22:04:25.052236 ZEBRA: [YHMRC-EMYNX] alloc_srv6_sid_func_explicit: function 65056 is outside ELIB [30000/31000] and EWLIB alloc ranges [30000/31000]
2025/03/10 22:04:25.052254 ZEBRA: [XSG8X-Q2XJX] get_srv6_sid_explicit: invalid SM request arguments: failed to allocate SID function 65056 from block fcbb:bbbb::/32
2025/03/10 22:04:25.052257 ZEBRA: [YC52T-427SJ] srv6_manager_get_sid_internal: not got SRv6 SID for ctx End.DT6 vrf_id 4, sid_value=fcbb:bbbb:1:fe20::, locator_name=MAIN
root@rajasekarr:/tmp/topotests/static_srv6_sids.test_static_srv6_sids/r1#

Ticket :#
Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>
2025-03-10 15:26:38 -07:00
Louis Scalbert c6afe42455 lib, tests, zebra: keep table routes at vrf disabling
At VRF disabling, keep the route entries that was associated to its
table ID but not to the VRF itself. Kernel flushes these entries so we
need to reinstall them.

To do so, add a flag to mean that a route entry is owned by a table ID
and not by a VRF. If the VRF associated to the table ID is deleted, the
route entry must not be deleted.

Update to tests with new flag. 2057 is in hexa 0x809, meaning that the
new flag has been to some prefix.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2025-03-10 09:54:18 +01:00
Louis Scalbert 52a35e9592 zebra: fix vanished blackhole route
Fix vanished blackhole route when kernel routes are updated.

> root@router# echo "100 my_table" | tee -a /etc/iproute2/rt_tables
> root@router# ip l add du0 type dummy
> root@router# ifconfig du0 192.168.0.1/24 up
> root@router# ip route add blackhole default table 100
> root@router# ip route show table 100
> blackhole default
> root@router# vtysh -c 'show ip route table 100'
> [...]
> Table 100:
> K>* 0.0.0.0/0 [0/0] unreachable (blackhole), weight 1, 00:00:05
> root@router# ip l add red type vrf table 100
> root@router# vtysh -c 'show ip route table 100'
> [...]
> Table 100:
> K>* 0.0.0.0/0 [0/0] unreachable (blackhole), weight 1, 00:00:16
> root@router# ip l set du0 master red
> root@router# vtysh -c 'show ip route table 100'
> [...]
> Table 100:
> C>* 192.168.0.0/24 is directly connected, du0, weight 1, 00:00:02
> L>* 192.168.0.1/32 is directly connected, du0, weight 1, 00:00:02
> root@router# ip route show table 100
> blackhole default
> 192.168.0.0/24 dev du0 proto kernel scope link src 192.168.0.1
> local 192.168.0.1 dev du0 proto kernel scope host src 192.168.0.1
> broadcast 192.168.0.255 dev du0 proto kernel scope link src 192.168.0.1

Fixes: d528c02a20 ("zebra: Handle kernel routes appropriately")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2025-03-10 09:54:18 +01:00
Louis Scalbert 5cde97678e zebra: fix removed default route at vrf enabling
When a routing table (RT) already has a default route before being
assigned to a VRF, the default route vanishes in zebra after the VRF
assignment.

> root@router:~# ip route add blackhole default table 100
> root@router:~# ip route show table 100
> blackhole default
> root@router:~# vtysh -c 'show ip route table 100'
> [...]
> VRF default table 100:
> K>* 0.0.0.0/0 [0/0] unreachable (blackhole), 00:00:05
> root@router:~# ip l add red type vrf table 100
> root@router:~# vtysh -c 'show ip route table 100'
> root@router:~#

Do not override the default route if it exists.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2025-03-10 09:54:18 +01:00
Louis Scalbert fb8bf9cf59 zebra: remove vrf route entries at vrf disabling
This is the continuation of the previous commit.

When a VRF is deleted, the kernel retains only its own routing entries
in the former VRF table and removes all others.

This change ensures that routing entries created by FRR daemons are also
removed from the former zebra VRF table when the VRF is disabled.

To test:

> echo "100 my_table" | tee -a /etc/iproute2/rt_tables
> ip l add du0 type dummy
> ifconfig du0 192.168.0.1/24 up
> ip route add blackhole default table 100
> ip route show table 100
> ip l add red type vrf table 100
> ip l set du0 master red
> vtysh -c 'configure' -c 'vrf red' -c 'ip route 10.0.0.0/24 192.168.0.254'
> vtysh -c 'show ip route table 100'
> sleep 0.1
> ip l del red
> sleep 0.1
> vtysh -c 'show ip route table 100'
> ip l add red type vrf table 100
> ip l set du0 master red
> vtysh -c 'configure' -c 'vrf red' -c 'ip route 10.0.0.0/24 192.168.0.254'
> vtysh -c 'show ip route table 100'
> sleep 0.1
> ip l del red
> sleep 0.1
> vtysh -c 'show ip route table 100'

Fixes: d8612e6 ("zebra: Track tables allocated by vrf and cleanup")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2025-03-10 09:54:18 +01:00
Louis Scalbert 7395e399b1 zebra: fix table heap-after-free crash
Fix a heap-after-free that causes zebra to crash even without
address-sanitizer. To reproduce:

> echo "100 my_table" | tee -a /etc/iproute2/rt_tables
> ip route add blackhole default table 100
> ip route show table 100
> ip l add red type vrf table 100
> ip l del red
> ip route del blackhole default table 100

Zebra manages routing tables for all existing Linux RT tables,
regardless of whether they are assigned to a VRF interface. When a table
is not assigned to any VRF, zebra arbitrarily assigns it to the default
VRF, even though this is not strictly accurate (the code expects this
behavior).

When an RT table is created after a VRF, zebra correctly assigns the
table to the VRF. However, if a VRF interface is assigned to an existing
RT table, zebra does not update the table owner, which remains as the
default VRF. As a result, existing routing entries remain under the
default VRF, while new entries are correctly assigned to the VRF. The
VRF mismatch is unexpected in the code and creates crashes and memory
related issues.

Furthermore, Linux does not automatically delete RT tables when they are
unassigned from a VRF. It is incorrect to delete these tables from zebra.

Instead, at VRF disabling, do not release the table but reassign it to
the default VRF. At VRF enabling, change the table owner back to the
appropriate VRF.

> ==2866266==ERROR: AddressSanitizer: heap-use-after-free on address 0x606000154f54 at pc 0x7fa32474b83f bp 0x7ffe94f67d90 sp 0x7ffe94f67d88
> READ of size 1 at 0x606000154f54 thread T0
>     #0 0x7fa32474b83e in rn_hash_node_const_find lib/table.c:28
>     #1 0x7fa32474bab1 in rn_hash_node_find lib/table.c:28
>     #2 0x7fa32474d783 in route_node_get lib/table.c:283
>     #3 0x7fa3247328dd in srcdest_rnode_get lib/srcdest_table.c:231
>     #4 0x55b0e4fa8da4 in rib_find_rn_from_ctx zebra/zebra_rib.c:1957
>     #5 0x55b0e4fa8e31 in rib_process_result zebra/zebra_rib.c:1988
>     #6 0x55b0e4fb9d64 in rib_process_dplane_results zebra/zebra_rib.c:4894
>     #7 0x7fa32476689c in event_call lib/event.c:1996
>     #8 0x7fa32463b7b2 in frr_run lib/libfrr.c:1232
>     #9 0x55b0e4e6c32a in main zebra/main.c:526
>     #10 0x7fa32424fd09 in __libc_start_main ../csu/libc-start.c:308
>     #11 0x55b0e4e2d649 in _start (/usr/lib/frr/zebra+0x1a1649)
>
> 0x606000154f54 is located 20 bytes inside of 56-byte region [0x606000154f40,0x606000154f78)
> freed by thread T0 here:
>     #0 0x7fa324ca9b6f in __interceptor_free ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:123
>     #1 0x7fa324668d8f in qfree lib/memory.c:130
>     #2 0x7fa32474c421 in route_table_free lib/table.c:126
>     #3 0x7fa32474bf96 in route_table_finish lib/table.c:46
>     #4 0x55b0e4fbca3a in zebra_router_free_table zebra/zebra_router.c:191
>     #5 0x55b0e4fbccea in zebra_router_release_table zebra/zebra_router.c:214
>     #6 0x55b0e4fd428e in zebra_vrf_disable zebra/zebra_vrf.c:219
>     #7 0x7fa32476fabf in vrf_disable lib/vrf.c:326
>     #8 0x7fa32476f5d4 in vrf_delete lib/vrf.c:231
>     #9 0x55b0e4e4ad36 in interface_vrf_change zebra/interface.c:1478
>     #10 0x55b0e4e4d5d2 in zebra_if_dplane_ifp_handling zebra/interface.c:1949
>     #11 0x55b0e4e4fb89 in zebra_if_dplane_result zebra/interface.c:2268
>     #12 0x55b0e4fb9f26 in rib_process_dplane_results zebra/zebra_rib.c:4954
>     #13 0x7fa32476689c in event_call lib/event.c:1996
>     #14 0x7fa32463b7b2 in frr_run lib/libfrr.c:1232
>     #15 0x55b0e4e6c32a in main zebra/main.c:526
>     #16 0x7fa32424fd09 in __libc_start_main ../csu/libc-start.c:308
>
> previously allocated by thread T0 here:
>     #0 0x7fa324caa037 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
>     #1 0x7fa324668c4d in qcalloc lib/memory.c:105
>     #2 0x7fa32474bf33 in route_table_init_with_delegate lib/table.c:38
>     #3 0x7fa32474e73c in route_table_init lib/table.c:512
>     #4 0x55b0e4fbc353 in zebra_router_get_table zebra/zebra_router.c:137
>     #5 0x55b0e4fd4da0 in zebra_vrf_table_create zebra/zebra_vrf.c:358
>     #6 0x55b0e4fd3d30 in zebra_vrf_enable zebra/zebra_vrf.c:140
>     #7 0x7fa32476f9b2 in vrf_enable lib/vrf.c:286
>     #8 0x55b0e4e4af76 in interface_vrf_change zebra/interface.c:1533
>     #9 0x55b0e4e4d612 in zebra_if_dplane_ifp_handling zebra/interface.c:1968
>     #10 0x55b0e4e4fb89 in zebra_if_dplane_result zebra/interface.c:2268
>     #11 0x55b0e4fb9f26 in rib_process_dplane_results zebra/zebra_rib.c:4954
>     #12 0x7fa32476689c in event_call lib/event.c:1996
>     #13 0x7fa32463b7b2 in frr_run lib/libfrr.c:1232
>     #14 0x55b0e4e6c32a in main zebra/main.c:526
>     #15 0x7fa32424fd09 in __libc_start_main ../csu/libc-start.c:308

Fixes: d8612e6 ("zebra: Track tables allocated by vrf and cleanup")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2025-03-10 09:54:18 +01:00
Donald Sharp 9bf22f603e zebra: Add mpls-forwarding to yang state model
The mpls-forwarding state was missing from the model
add it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2025-03-07 22:24:42 -05:00
Donald Sharp 633ef005bd zebra: Don't use MTYPE_TMP for l2 vni data
Convert over from MTYPE_TMP to MTYPE_L2_VNI as the
data type.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2025-03-07 11:50:41 -05:00
Donald Sharp b648479cb4 zebra: Declutter zebra_vxlan_if_add_update_vni
This function has equivalent code on both sides
of a if statement.  Let's consolidate this.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2025-03-07 11:48:05 -05:00
Donald Sharp 45e2f0fc6e zebra: malloc functions cannot fail
Let's try to remember that when using a malloc function
it can never fail and as such testing for NULL does
nothing.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2025-03-07 11:48:05 -05:00
Donatas Abraitis 26d1e5ce17
Merge pull request #18214 from soumyar-roy/soumya/ra514nei
zebra: Bring up 514 BGP neighbor sessions
2025-03-06 20:15:19 +02:00
Soumya Roy 6a75d33b5c zebra: Bring up 514 BGP neighbor sessions
Issue:
When 514 inerfaces/neighbors are configured, it creates socket error,
"Cannot allocate memory", when back to back V6 RA messages are tried
to be sent over the socket. This prevents interface, to know its peer's
link local address. Socket error comes when 1) try to join ICMPv6 all
router multicast group, back to back for all interfaces 2)send back to
back RA for all interfaces

Fix:
1)For ICMPv6 join case, we check if the interface has already joined
all router group, if not try to join. On failure, retry joining after
random amount of time determined 1 ms to ICMPV6_JOIN_TIMER_EXP_MS(100 ms)
2) For RA issue case, batch sending of RA mesages using wheel timer

Testing:
Monitor BGP session running sh bgp summary command

Before fix:
r1# sh bgp summary

IPv4 Unicast Summary:
BGP router identifier 192.168.1.1, local AS number 1001 VRF default vrf-id 0
BGP table version 0
RIB entries 0, using 0 bytes of memory
Peers 515, using 12 MiB of memory

Neighbor        V         AS   MsgRcvd   MsgSent   TblVer  InQ OutQ  Up/Down State/PfxRcd   PfxSnt Desc
r1-eth0         4       1002        89        90        0    0    0 00:07:10            0        0 N/A
r1-eth1         4       1002        89        90        0    0    0 00:07:10            0        0 N/A
r1-eth2         4       1002        89        90        0    0    0 00:07:10            0        0 N/A
r1-eth3         4       1002        89        90        0    0    0 00:07:10            0        0 N/A
r1-eth4         4       1002        89        90        0    0    0 00:07:10            0        0 N/A
r1-eth5         4       1002        89        90        0    0    0 00:07:10            0        0 N/A

…..<snip>...
r1-eth252       4       1002        31        29        0    0    0 00:02:08            0        0 N/A
r1-eth253       4       1002        31        29        0    0    0 00:02:08            0        0 N/A
r1-eth254       4       1002        31        29        0    0    0 00:02:08            0        0 N/A
r1-eth255       4       1002        31        29        0    0    0 00:02:08            0        0 N/A
r1-eth256       4          0         0         0        0    0    0    never         Idle        0 N/A
r1-eth257       4          0         0         0        0    0    0    never         Idle        0 N/A
r1-eth258       4          0         0         0        0    0    0    never         Idle        0 N/A
r1-eth259       4          0         0         0        0    0    0    never         Idle        0 N/A
r1-eth260       4          0         0         0        0    0    0    never         Idle        0 N/A
……..<snip>…..
r1-eth511       4          0         0         0        0    0    0    never         Idle        0 N/A
r1-eth512       4          0         0         0        0    0    0    never         Idle        0 N/A
r1-eth513       4          0         0         0        0    0    0    never         Idle        0 N/A
r1-eth514       4          0         0         0        0    0    0    never         Idle        0 N/A
After fix:
r1# show bgp summary

IPv4 Unicast Summary:
BGP router identifier 192.168.1.1, local AS number 1001 VRF default vrf-id 0
BGP table version 0
RIB entries 0, using 0 bytes of memory
Peers 515, using 12 MiB of memory

Neighbor        V         AS   MsgRcvd   MsgSent   TblVer  InQ OutQ  Up/Down State/PfxRcd   PfxSnt Desc
r1-eth0         4       1002        87        87        0    0    0 00:07:04            0        0 N/A
r1-eth1         4       1002        87        87        0    0    0 00:07:04            0        0 N/A
r1-eth2         4       1002        87        87        0    0    0 00:07:04            0        0 N/A
r1-eth3         4       1002        64        67        0    0    0 00:05:09            0        0 N/A
r1-eth4         4       1002        87        87        0    0    0 00:07:04            0        0 N/A
r1-eth5         4       1002        87        87        0    0    0 00:07:04            0        0 N/A
r1-eth6         4       1002        67        70        0    0    0 00:05:22            0        0 N/A
r1-eth7         4       1002        87        87        0    0    0 00:07:04            0        0 N/A
r1-eth8         4       1002        87        87        0    0    0 00:07:04            0        0 N/A
....
r1-eth499       4       1002        43        43        0    0    0 00:03:22            0        0 N/A
r1-eth500       4       1002        43        43        0    0    0 00:03:22            0        0 N/A
r1-eth501       4       1002        19        22        0    0    0 00:01:21            0        0 N/A
r1-eth502       4       1002        43        43        0    0    0 00:03:22            0        0 N/A
r1-eth503       4       1002        43        43        0    0    0 00:03:22            0        0 N/A
r1-eth504       4       1002        20        23        0    0    0 00:01:30            0        0 N/A
r1-eth505       4       1002        43        43        0    0    0 00:03:22            0        0 N/A
r1-eth506       4       1002        43        43        0    0    0 00:03:22            0        0 N/A
r1-eth507       4       1002        22        25        0    0    0 00:01:39            0        0 N/A
r1-eth508       4       1002        43        43        0    0    0 00:03:22            0        0 N/A
r1-eth509       4       1002        17        20        0    0    0 00:01:13            0        0 N/A
r1-eth510       4       1002        43        43        0    0    0 00:03:22            0        0 N/A
r1-eth511       4       1002        43        43        0    0    0 00:03:22            0        0 N/A
r1-eth512       4       1002        19        22        0    0    0 00:01:22            0        0 N/A
r1-eth513       4       1002        43        43        0    0    0 00:03:22            0        0 N/A
r1-eth514       4       1002        43        43        0    0    0 00:03:22            0        0 N/A

Signed-off-by: Soumya Roy <souroy@nvidia.com>
2025-03-05 06:15:56 +00:00
Russ White 0b094a772c
Merge pull request #18253 from dksharp5/yang_zebra
Allow retrieval of v4/v6 forwarding state via NB
2025-03-04 09:25:24 -05:00
Mark Stapp b66145b8ca
Merge pull request #18030 from fdumontet6WIND/mem_alloc_stream
zebra: reduce memory usage by streams when redistributing routes
2025-03-03 11:09:47 -05:00
Donna Sharp 9a073f663f zebra: allow retrieval of ipv6 forwarding state
Allow the retrieval of ipv6 forwarding state from
within the yang framework as that it was missing.

Signed-off-by: Donna Sharp <dksharp5@gmail.com>
2025-03-01 14:45:18 -05:00
Donna Sharp 453154497e zebra: allow retrieval of ip forwarding state
There was no ability to retrieve the ip-forwarding state
of zebra.  Add this to yang under the state container.

Signed-off-by: Donna Sharp <dksharp5@gmail.com>
2025-03-01 14:39:07 -05:00
Francois Dumontet 8c9b007a0c zebra: reduce memory usage by streams when redistributing routes
required stream size is evaluated as a fix part and variable one.
the variable one depend on the number of nexthops.

Signed-off-by: Francois Dumontet <francois.dumontet@6wind.com>
2025-02-27 16:51:05 +01:00
Donald Sharp 594f65d888
Merge pull request #18242 from kaffarell/master
fabricd: add option to treat dummy interfaces as loopback interfaces
2025-02-26 11:18:22 -05:00
Carmine Scarpitta ec5ff367b1 staticd: Extend static_zebra_request_srv6_sid to request SRv6 uA SIDs
In order to configure an SRv6 uA SID in staticd, staticd should request
SRv6 SID Manager to allocate a SID bound to the uA behavior.
Currently, `static_zebra_request_srv6_sid` does not support requesting
SIDs bound to the uA behavior.

This commit extends the `static_zebra_request_srv6_sid` function to
enable staticd to request SIDs bound to the uA behavior.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2025-02-26 07:19:51 +01:00
Gabriel Goller 80e96712e4 zebra: add ZEBRA_IF_DUMMY flag for dummy interfaces
Introduce ZEBRA_IF_DUMMY interface flag to identify Linux dummy interfaces [0].
These interfaces behave similarly to loopback interfaces and can be
specially handled by daemons.

[0]: https://github.com/torvalds/linux/blob/master/drivers/net/dummy.c

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
2025-02-25 10:13:34 +01:00
Donna Sharp e0387cd17f zebra: use provider function to receive data directly
Signed-off-by: Donna Sharp <dksharp5@gmail.com>
2025-02-24 14:51:12 -05:00
Donald Sharp 03ebdc3c4a zebra: Add operational retrieval of Multipath Number
The multipath number specified is not available through
the yang data and is not retrievable.  Make it so.
At this point in time do not allow this to be set from
yang.  Perhaps in the future.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2025-02-23 11:14:47 -05:00
Donald Sharp f7fd861fda *: Remove unneeded IPV6_JOIN|LEAVE_GROUP
Headers include this stuff now.  No need for it
in our code base.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2025-02-20 16:16:35 -05:00
Donald Sharp 66434fc2ee
Merge pull request #18108 from opensourcerouting/fix/zebra_no_vni_validation
zebra: Do not flush an existing vni configuration trying to remove wrong vni
2025-02-19 07:22:03 -05:00
David Schweizer 1eef3a77e3
lib,zebra: Allow class E prefixes in RIB
Changes allow ipv4 class E addresses and prefixes in the 240.0.0.0/4
range to be configured on interfaces, imported from the kernel routing
table and redistributed as connected routes in zebra by default.

Changes also fix routes with class E prefixes in kernel routing table
getting rejected by zebra during early daemon startup.

Drivin this change in default behavior are cloud providers (with
customers still using obsolete ipv4 protocol, i.e. Azure, AWS) running
out of ip space and abusing class E for addressing instances (announced
via BGP) over tunneling connections back to customers on premise
infrastructure.

Signed-off-by: David Schweizer <dschweizer@opensourcerouting.org>
2025-02-14 15:05:08 +01:00
Donald Sharp 40744f4f3d zebra: Use tableid when displaying prefix
Found some more instances of tableid not being
displayed when trying to debug something.  Fix.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2025-02-13 10:40:52 -05:00
Donatas Abraitis 44fe3981ee zebra: Do not flush an existing vni configuration trying to remove wrong vni
Before:

```
pc.donatas.net(config)# do sh run | include vni
vni 1
pc.donatas.net(config)# no vni 2
pc.donatas.net(config)# do sh run | include vni
pc.donatas.net(config)#
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2025-02-12 23:37:20 +02:00
Donald Sharp 54dc8382eb zebra: Allow fpm_listener to continue to try to read
Currently when the fpm_listener attempts to read say X
bytes it may only get Y( which is less than X ).  In this
case we should assume that the dplane_fpm_nl code is just
being slow, as that we know it is possible for it to send
a partial fpm message.  Let's just loosen the constraints
a bit and allow data to flow.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2025-02-11 12:42:02 -05:00
Jafar Al-Gharaibeh 92288c9069
Merge pull request #17865 from donaldsharp/coverity_2024_new_hotness
Coverity 2024 new hotness
2025-02-06 10:15:55 -06:00
Donald Sharp 0b42b4ce6d
Merge pull request #17901 from opensourcerouting/nexthop_hashing
lib: actually hash all 16 bytes of IPv6 addresses, not just 4
2025-02-05 09:14:58 -05:00
Russ White 3fabd4f4f9
Merge pull request #18014 from donaldsharp/nexthop_leak
Nexthop leak
2025-02-05 08:32:13 -05:00
Donald Sharp abbfcc49f9 zebra: Fix srv6 segment nexthop memory leak.
The srv6 segment was being set but never freed
on the statically allocated nexthop.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2025-02-04 15:13:48 -05:00
Russ White 1cbb4b9e3d
Merge pull request #17962 from donaldsharp/fpm_problems
Fpm problems
2025-02-04 15:09:05 -05:00
Donald Sharp 29dcfd415f zebra: Stop leaking labels when receiving nexthops from kernel
This leak is happening:
Direct leak of 96 byte(s) in 2 object(s) allocated from:
    0 0x7f6922eb83b7 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:77
    1 0x7f6922a38ebb in qcalloc lib/memory.c:106
    2 0x7f6922a553d6 in nexthop_add_srv6_seg6 lib/nexthop.c:652
    3 0x562825e56b38 in parse_nexthop_unicast zebra/rt_netlink.c:589
    4 0x562825e58c4a in netlink_route_change_read_unicast_internal zebra/rt_netlink.c:1291
    5 0x562825e58eef in netlink_route_change_read_unicast zebra/rt_netlink.c:1321
    6 0x562825e64921 in netlink_route_change zebra/rt_netlink.c:1494
    7 0x562825e43407 in netlink_information_fetch zebra/kernel_netlink.c:407
    8 0x562825e439b5 in netlink_parse_info zebra/kernel_netlink.c:1148
    9 0x562825e44060 in kernel_read zebra/kernel_netlink.c:510
    10 0x7f6922aeca72 in event_call lib/event.c:1984
    11 0x7f6922a19e01 in frr_run lib/libfrr.c:1246
    12 0x562825e4b0b9 in main zebra/main.c:543
    13 0x7f692250c249 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

Just check to see if it has been allocated.  The nexthop is a stack
variable so it's a bit odd.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2025-02-04 15:00:12 -05:00
Russ White 4349cab51b
Merge pull request #17953 from donaldsharp/limit_ip_protocol
lib: Remove System routes from ip protocol route map choices
2025-02-04 11:43:10 -05:00
Mark Stapp 704372bf4b
Merge pull request #17969 from donaldsharp/fpm_lost_sends
zebra: Ensure dplane does not send work back to master at wrong time
2025-02-04 11:18:07 -05:00
Chirag Shah 1d4f5b9b19 zebra: evpn svd hash avoid double free
Upon zebra shutdown hash_clean_and_free is called
where user free function is passed,
The free function should not call hash_release
which lead to double free of hash bucket.

Fix:
The fix is to avoid calling hash_release from
free function if its called from hash_clean_and_free
path.

10 0x00007f0422b7df1f in free () from /lib/x86_64-linux-gnu/libc.so.6
11 0x00007f0422edd779 in qfree (mt=0x7f0423047ca0 <MTYPE_HASH_BUCKET>,
    ptr=0x55fc8bc81980) at ../lib/memory.c:130
12 0x00007f0422eb97e2 in hash_clean (hash=0x55fc8b979a60,
    free_func=0x55fc8a529478 <svd_nh_del_terminate>) at
    ../lib/hash.c:290
13 0x00007f0422eb98a1 in hash_clean_and_free (hash=0x55fc8a675920
    <svd_nh_table>, free_func=0x55fc8a529478 <svd_nh_del_terminate>) at
    ../lib/hash.c:305
14 0x000055fc8a5323a5 in zebra_vxlan_terminate () at
    ../zebra/zebra_vxlan.c:6099
15 0x000055fc8a4c9227 in zebra_router_terminate () at
    ../zebra/zebra_router.c:276
16 0x000055fc8a4413b3 in zebra_finalize (dummy=0x7fffb881c1d0) at
    ../zebra/main.c:269
17 0x00007f0422f44387 in event_call (thread=0x7fffb881c1d0) at
    ../lib/event.c:2011
18 0x00007f0422ecb6fa in frr_run (master=0x55fc8b733cb0) at
    ../lib/libfrr.c:1243
19 0x000055fc8a441987 in main (argc=14, argv=0x7fffb881c4a8) at
    ../zebra/main.c:584

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2025-02-03 16:09:20 -08:00
Donald Sharp 64709ec2a9 zebra: Ensure dplane does not send work back to master at wrong time
When looping through the dplane providers, the worklist was
being populated with items from the last provider and then
the event system was checked to see if we should stop processing.
If the event system says `yes` then the dplane code would stop
and send the worklist to the master zebra pthread for collection.
This obviously skipped the next dplane provider on the list
which is double plus not good.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2025-01-31 15:05:40 -05:00
Donald Sharp 07a803a7b3 zebra: Stop buffering output from fpm_listener
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2025-01-31 15:05:40 -05:00
Donald Sharp c58da10d2a zebra: Limit mutex for obuf to when we access obuf
The mutex that wraps access to the output buffer
is being held for the entire time the data is
being generated to send down the pipe.  Since
the generation has absolutely nothing to do
with the obuf, let's limit the mutex holding some.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2025-01-31 15:05:40 -05:00
Donald Sharp e71d29983a zebra: fpm_listener allow continued operation
In fpm_listener, when a error is detected it would
stop listening and not recover.  Modify the code
to close the socket and allow the connection to
recover.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2025-01-31 15:05:40 -05:00
Donald Sharp b2fc167978 zebra: Fix pass back of data from dplane through fpm pipe
A recent code change 29122bc9b8
changed the passing of data up the fpm from passing the
tableid and vrf to the sonic expected tableid contains
the vrfid.  This violates the assumptions in the code
that the netlink message passes up the tableid as the
tableid.  Additionally this code change did not modify
the rib_find_rn_from_ctx to actually properly decode
what could be passed up.  Let's just fix this and let
Sonic carry the patch as appropriate for themselves
since they are not the only users of dplane_fpm_nl.c

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2025-01-31 15:05:40 -05:00
Donald Sharp c41155221e zebra: Ensure dplane does not send work back to master at wrong time
When looping through the dplane providers, the worklist was
being populated with items from the last provider and then
the event system was checked to see if we should stop processing.
If the event system says `yes` then the dplane code would stop
and send the worklist to the master zebra pthread for collection.
This obviously skipped the next dplane provider on the list
which is double plus not good.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2025-01-31 12:38:20 -05:00
Carmine Scarpitta a879aebf69 zebra: Fix SRv6 SID Manager
The SRv6 SID Manager does not allow allocating an SRv6 End/uN function
even though it is already supported by staticd.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2025-01-30 19:28:34 +01:00
David Lamparter b666ee510e zebra: guard against junk in nexthop->rmap_src
rmap_src wasn't initialized, so for IPv4 the unused 12 bytes would
contain whatever junk is on the stack on function entry.  Also move
the IPv4 parse before the IPv6 parse so if it's successful we can be
sure the other bytes haven't been touched.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2025-01-29 16:48:37 +01:00
Donald Sharp f849511c47
Merge pull request #17935 from mjstapp/fix_nhg_hash_equal
zebra: include resolving nexthops in nhg hash
2025-01-29 10:14:37 -05:00
Donald Sharp fb8e399e4f lib: Remove System routes from ip protocol route map choices
Do not allow system routes to be selected for ip protocol

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2025-01-29 09:31:53 -05:00
Russ White bd82864d03
Merge pull request #17941 from opensourcerouting/fix-dst-src
static: fix botched staticd YANG conversion for dst-src
2025-01-28 12:23:06 -05:00
David Lamparter 2af780650f lib, zebra: carry source prefix in route_notify
When a daemon wants to know about its routes, make it possible to have
that work for dst-src routes.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2025-01-28 15:40:17 +01:00
David Lamparter 1d341d461e zebra: install dst-src routes without NHG
The Linux kernel doesn't support dst-src routes with NHGs as nexthop,
for some (rather dubious) caching reasons.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2025-01-28 11:10:31 +01:00
Mark Stapp cb7cf73992 zebra: include resolving nexthops in nhg hash
Ensure that the nhg hash comparison function includes all
nexthops, including recursive-resolving nexthops.

Signed-off-by: Mark Stapp <mjs@cisco.com>
2025-01-27 14:17:24 -05:00
Rafael Zalamena 28a9ca3405 lib,zebra: VRF table-direct support
Implement the necessary data structures and code changes to support sending
table-direct routes to protocols running in different VRFs.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2025-01-23 14:37:09 -03:00
Pooja Jagadeesh Doijode 8c6489bc56 zebra: Return error if v6 prefix is passed to show ip route
Return error if IPv6 address or prefix is passed as an argument
to "show ip route" command.

UT:
r1# show ip route 2::3/128
% Cannot specify IPv6 address/prefix for IPv4 table
r1#
r1# show ip route 2::3
% Cannot specify IPv6 address/prefix for IPv4 table
r1#

Signed-off-by: Pooja Jagadeesh Doijode <pdoijode@nvidia.com>
2025-01-22 10:09:03 -08:00
Donatas Abraitis 76ed8f61d8
Merge pull request #17814 from donaldsharp/nhg_removal_in_some_situations 2025-01-17 17:31:19 +02:00
Donald Sharp 19af3f3d7a zebra: Ensure that changes to dg_update_list are protected by mutex
The dg_update_list access is controlled by the dg_mutex in all
other locations.  Let's just add a mutex usage around the initialization
of the dg_update_list even if it's part of the startup, just to keep
things consistent.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2025-01-17 10:16:48 -05:00
Donald Sharp 4b96752737 zebra: Add some documentation on when zserv_open should be used
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2025-01-17 10:16:48 -05:00
Igor Ryzhov 300f8dbda4 lib: introduce global -w option for VRF netns backend
Current -n option is only for zebra and mgmtd. All other daemons receive
the VRF backend configuration from zebra upon connection to it. This
leads to a potential race condition - daemons need to know the backend
before they start reading their config, but they can be not connected to
zebra yet at this point. As the VRF backend cannot change during runtime,
let's introduce a new global -w option for setting netns backend, to
make sure that all daemons know their VRF backend immediately after
start.

The reason for introducing a new option instead of making -n global is
that ospfd already uses -n for another purposes.

Signed-off-by: Igor Ryzhov <idryzhov@gmail.com>
2025-01-15 23:38:27 +02:00
Igor Ryzhov 6f214d97d1 lib, zebra: move ns context intialization to zebra
vrf->ns_ctxt is only ever used in zebra, so move its initialization to
zebra's callback. Ideally this pointer shouldn't even be a part of
library's vrf struct, and moved to zebra-specific struct, but this is
the first step.

Signed-off-by: Igor Ryzhov <idryzhov@gmail.com>
2025-01-15 23:38:27 +02:00
Igor Ryzhov 4877f2f685 lib: remove VRF_BACKEND_UNKNOWN
The backend type cannot be unknown. It is configured to VRF_LITE by
default in zebra anyway, so just init to VRF_LITE in the lib and remove
the UNKNOWN type.

Signed-off-by: Igor Ryzhov <idryzhov@gmail.com>
2025-01-15 23:38:27 +02:00
Donald Sharp 953d5fd526
Merge pull request #17799 from LabNConsulting/chopps/backend-yang-model
mgmtd backend yang model (depends on #17796)
2025-01-15 10:22:11 -05:00
Donatas Abraitis 93ea9748cf
Merge pull request #17859 from donaldsharp/active_routes_are_active
Active routes are active
2025-01-15 15:01:59 +02:00
Donald Sharp ec6a000b0b zebra: On Nexthop install failure don't set Installation failed
Currently FRR when installing a nexthop group, the installation can fail.
The assumption with the code was that the current nexthop group was
not already installed.  This leaves a problem state where if the
users of the nexthop group are removed, the nexthop group will be
removed possibly leaving a orphaned nexthop group in the data plane.

FRR on a nexthop group installation does not actually know the status
of the nexthop group in the kernel.  It's possible that a earlier
version of the nexthop group is left in play.  It's possible that
there is no nexthop group in the kernel at all.  Leaving the
Installed flag alone allows upon Zebra removing the nexthop
group when it is removed from zebra.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2025-01-14 16:23:40 -05:00
Donald Sharp b61424a717 zebra: Nexthops need to be ACTIVE in some cases
Currently if you have an interface down event, Zebra
sets the nexthop(s) as !ACTIVE that use it.  On
interface up events the singleton nexthops are not being
set as ACTIVE.  Due to timing events it is sometimes
possible to end up with a route that is using a singleton

Change singleton nexthops to set the nexthop to ACTIVE.
This will allow the nexthop to be reinstalled appropriately
as well.

I was able to easily reproduce this using sharpd since
it does not attempt to reinstall the routes when a interface
goes up/down.

Before:

D>* 10.0.0.0/32 [150/0] via 192.168.102.34, dummy2, weight 1, 00:00:01

sharpd@eva ~/frr5 (master)> sudo ip link set dummy2 down ; sudo ip link set dummy2 up

D>  10.0.0.0/32 [150/0] (350) via 192.168.102.34, dummy2 inactive, weight 1, 00:00:10

After code change:

D>* 10.0.0.0/32 [150/0] (73) via 192.168.102.34, dummy2, weight 1, 00:00:14

sharpd@eva ~/frr5 (master)> sudo ip link set dummy2 down ; sudo ip link set dummy2 up

D>* 10.0.0.0/32 [150/0] (73) via 192.168.102.34, dummy2, weight 1, 00:00:21

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2025-01-14 15:12:32 -05:00
Christian Hopps 5f2a927d7b lib: northbound/mgmtd: add backend model support
Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-14 18:48:59 +00:00
Donald Sharp 5f35096123
Merge pull request #17796 from LabNConsulting/chopps/datastore-notifications
operational-state (datastore) change notifications
2025-01-14 13:47:28 -05:00
Donald Sharp 67da971218
Merge pull request #17581 from mjstapp/fix_fpm_netlink
zebra: avoid race between FPM pthread and zebra main pthread in netlink encode/decode
2025-01-14 13:42:29 -05:00
Christian Hopps 80c6f98ea7 lib: if: track oper-state inline
Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-13 23:40:52 -05:00
Christian Hopps e64966876c lib: vrf: track oper-state inline
Signed-off-by: Christian Hopps <chopps@labn.net>
2025-01-13 23:40:52 -05:00
Rajasekar Raja e77954e5d9 zebra: Optimize invoking nhg compare func
In some cases, the old_re nhe and the newnhe is same and there is no
point in comparing them both since they are the same. Skip comparing in
such cases.

Ex:
2025/01/09 23:49:27.489020 ZEBRA: [W4Z4R-NTSMD] zebra_nhg_rib_find_nhe: => nhe 0x555f611d30c0 (44[38/39/45])
2025/01/09 23:49:27.489021 ZEBRA: [ZH3FQ-TE9NV] zebra_nhg_rib_compare_old_nhe: 0.0.0.0/0 new id: 44 old id: 44
2025/01/09 23:49:27.489021 ZEBRA: [YB8HE-Z86GN] zebra_nhg_rib_compare_old_nhe: 0.0.0.0/0 NEW 0x555f611d30c0 (44[38/39/45])
2025/01/09 23:49:27.489023 ZEBRA: [ZSB1Z-XM2V3] 0.0.0.0/0: NH 20.1.1.9[0] vrf default(0) wgt 1, with flags
2025/01/09 23:49:27.489024 ZEBRA: [ZSB1Z-XM2V3] 0.0.0.0/0: NH 30.1.2.9[0] vrf default(0) wgt 1, with flags
2025/01/09 23:49:27.489025 ZEBRA: [ZSB1Z-XM2V3] 0.0.0.0/0: NH 20.1.1.2[4] vrf default(0) wgt 1, with flags ACTIVE
2025/01/09 23:49:27.489026 ZEBRA: [ZM3BX-HPETZ] zebra_nhg_rib_compare_old_nhe: 0.0.0.0/0 OLD 0x555f611d30c0 (44[38/39/45])
2025/01/09 23:49:27.489027 ZEBRA: [ZSB1Z-XM2V3] 0.0.0.0/0: NH 20.1.1.9[0] vrf default(0) wgt 1, with flags
2025/01/09 23:49:27.489028 ZEBRA: [ZSB1Z-XM2V3] 0.0.0.0/0: NH 30.1.2.9[0] vrf default(0) wgt 1, with flags
2025/01/09 23:49:27.489028 ZEBRA: [ZSB1Z-XM2V3] 0.0.0.0/0: NH 20.1.1.2[4] vrf default(0) wgt 1, with flags ACTIVE

Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>
2025-01-10 13:39:12 -08:00
Donald Sharp 4c166947a8 zebra: Uninstall NHG in some situations
If you have this series of events:

a) Decision to install a NHG is made in zebra, enqueue to DPLANE
b) Changes to NHG are made and we remove it in the master pthread
   Since this NHG is not marked as installed it is not removed
   but the NHG data structure is deleted
c) DPLANE installs the NHG

In the end the NHG stays installed but ZEBRA has lost track of it.

Modify the removal code to check to see if the NHG is queued.
There are 2 cases:

a) NHG is kept around for a bit before being deleted.  In this case
just see that the NHG is Queued and keep it around too.

b) NHG is not kept around and we are just removing it.  In this case
check to see if it is queued and send another deletion event.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2025-01-10 09:35:35 -05:00
Donald Sharp 97fa24e70b zebra: Fix leaked nhe
During route processing in zebra, Zebra will create a nexthop
group that matches the nexthops passed down from the routing
protocol.  Then Zebra will look to see if it can re-use a
nhe from a previous version of the route entry( say a interface
goes down ).  If Zebra decides to re-use an nhe it was just dropping
the route entry created.  Which led to nexthop group's that had
a refcount of 0 and in some cases these nexthop groups were installed
into the kernel.

Add a bit of code to see if the returned entry is not being used
and it has no reference count and if so, properly dispose of it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2025-01-09 12:34:50 -05:00
Russ White 7f2be9a595
Merge pull request #17474 from sougata-github-nvidia/rib_ip_protocol_cleanup
zebra: Fix ip protocol route-map issue.
2025-01-07 08:45:07 -05:00
Sougata Barik 86b294698f zebra: Fix ip protocol route-map issue.
"ip/ipv6 protocol any route-map <route map>" cli is setting
wrong route type ( ZEBRA_ROUTE_MAX ), It should set route type
ZEBRA_ROUTE_ALL.

Ticket: #4101560

Signed-off-by: Sougata Barik <sougatab@nvidia.com>
2025-01-06 17:02:21 +05:30
Jafar Al-Gharaibeh 8ca4c3d098
Merge pull request #17752 from raja-rajasekar/rajasekarr/comp_issue
zebra: fix dpdk compilation error
2025-01-05 20:15:20 -06:00
Rajasekar Raja eced678d34 zebra: fix dpdk compilation error
Fixing compilation error in a switch statement case

Fixes :aa4786642c9a65c282d0fd5247a35b0f14fa1c3c

Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>
2025-01-03 11:13:02 -08:00
Donatas Abraitis 73fad72213
Merge pull request #17737 from chiragshah6/fdev7
zebra:check DAD freeze action before notifying bgp
2025-01-03 09:34:54 +02:00
Chirag Shah 5aa9c8652e zebra:check DAD freeze action before notifying bgp
If Duplicate Address Detection action is freeze
(permanent or definite time means not warn only mode)
then locally duplicate detected MAC delete notification
is not require to inform,
instead ask BGP to sync previous remote MAC entry.
In freeze case local MAC event is not known to BGP,
instead BGP is pointing to remote VTEP for the MAC.

Ticket: #3652383
Issue: 3652383

Signed-off-by: Chirag Shah <chirag@nvidia.com>
2024-12-30 14:39:27 -08:00
Donald Sharp 54ec9f3888 zebra: Fix resetting valid flags for NHG dependents
Upon if_down, we don't reset the valid flag for dependents
and unset the INSTALLED flag.

So when its time for the NHG to be deleted (routes dereferenced),
zebra deletes it since refcnt goes to 0, but stale NHG remains in kernel.

Ticket :#4200788

Signed-off-by: Donald Sharp <sharpd@nvidia.com>

Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>
2024-12-30 08:40:44 -08:00
Carmine Scarpitta 13f3c7c679 zebra: Remove tests for srv6_locator_alloc failure
`srv6_locator_alloc` can never fail. Let's remove the tests for
allocation failure.

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
2024-12-22 09:01:59 +01:00
Russ White c8ba5b09b3
Merge pull request #17544 from anlancs/zebra/fix-plug-interface
zebra: fix wrong nexthop status for kernel routes
2024-12-17 11:16:32 -05:00
anlan_cs 4d2ac714f0 zebra: check kernel routes when interface becomes up
Just like `link down`, check all kernel routes when interface become up.
And, they maybe will be selected as the best one by zebra.

Signed-off-by: anlan_cs <anlan_cs@126.com>
2024-12-17 16:14:30 +08:00
anlan_cs 298bc623e7 zebra: don't uninstall kernel routes
After the nexthop check is fixed, zebra will wrongly uninstall the kernel routes
with inactive nexthop.

This commit would skip the uninstallation for kernel routes.

Signed-off-by: anlan_cs <anlan_cs@126.com>
2024-12-17 16:14:30 +08:00
anlan_cs b9538fe481 zebra: fix wrong nexthop check
The kernel routes are wrongly selected even the nexthop interface is linkdown.

Use `ip link set dev <interface> down` on the other box to set the box's
nexthop interface linkdown. The kernel routes will be kept as `linkdown`,
but are still with active nexthop in `zebra`.

Add three changes/commits for kernel routes in this PR:

1) The active nexthop should be the operative interface.
2) Don't uninstall the kernel routes from `zebra` even no active nexthops.
   (It doesn't affect the kernel routes' deletion from kernel netlink messages.)
3) Update the kernel routes when the nexthop interface becomes up.

Before: (during nexthop interface is linkdown)
```
K>* 3.3.3.3/32 [0/0] via 88.88.88.1, enp2s0, weight 1, 00:00:14
```

After: (during nexthop interface is linkdown, with all three changes)
```
K   3.3.3.3/32 [0/0] via 88.88.88.1, enp2s0 inactive, weight 1, 00:00:07
```

This commit is 1st change:
Improve the judgment for "active" nexthop to be more accurate, the active
nexthop should be the operative interface.

Signed-off-by: anlan_cs <anlan_cs@126.com>
2024-12-17 16:14:30 +08:00
Rafael Zalamena 3bebb7be92
Merge pull request #17252 from nabahr/mcast-mode
Fix PIMD RPF lookup mode and nexthop tracking
2024-12-16 09:57:31 -03:00
Donald Sharp 3a53b2dc4f zebra: Give a bit more data about zclient connection on errors
When debugging a crash I noticed that sometimes we talked about
a zclient connection in relation to the fd associated with it
and sometimes we did not.  Let's just always give the data
associated with the fd.  It will make it a bit easier for me
to follow the transitions.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-12-13 11:21:26 -05:00
Nathan Bahr 8983d24282 zebra: Improve multicast safi route show commands
Add `mrib` flag to existing "show ip route" commands which then use
the multicast safi rather than the unicast safi. Updated the vty output
to include the AFI and SAFI string when printing the table.
Deprecate `show ip rpf` command, aliased to `show ip route mrib`.
Removed `show ip rpf A.B.C.D`.

Signed-off-by: Nathan Bahr <nbahr@atcorp.com>
2024-12-12 13:50:31 +00:00
Nathan Bahr bf8728dcf6 zebra,yang: Completely remove multicast mode from zebra
Multicast mode belongs in PIM, so removing it completely from zebra.
Modified `show (ip|ipv6) rpf ADDRESS` to always lookup from SAFI_MULTICAST.
This means this command is now specific to the multicast table and does
not necessarily reflect the PIM RPF lookup, but that should be implemented
in PIM instead.

Signed-off-by: Nathan Bahr <nbahr@atcorp.com>
2024-12-12 13:50:31 +00:00
Nathan Bahr 4250eae00d zebra,pimd,lib: Modify ZEBRA_NEXTHOP_LOOKUP_MRIB
Modified ZEBRA_NEXTHOP_LOOKUP_MRIB to include the SAFI from which to do the lookup.
This generalizes the API away from MRIB specifically and allows the user to decide how it should do lookups.
Rename ZEBRA_NEXTHOP_LOOKUP_MRIB to ZEBRA_NEXTHOP_LOOKUP now that it is more generalized.
This change is in preperation to remove multicast lookup mode completely from zebra.

Signed-off-by: Nathan Bahr <nbahr@atcorp.com>
2024-12-12 13:50:31 +00:00
Donatas Abraitis 492750f8bc
Merge pull request #17638 from donaldsharp/zebra_metaq_stuff
zebra: Remove tests for allocation failure
2024-12-12 11:10:31 +02:00
Donald Sharp 5d8bf74f0a zebra: Remove tests for allocation failure
This cannot happen.  No need to test

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-12-11 11:43:48 -05:00
Donald Sharp da7393b8fd zebra: Fix another ships in the night issue with WFI
Effectively When bgp would send a route update down
to zebra and immediately after that a asic update
from the kernel was read.  Zebra would choose the
asic update and drop the bgp update leaving us in
a state where bgp was not used as the true source.

Modify the code so that in rib_multipath_nhe
we notice that we have an unprocessed route update
from bgp.  And if so just drop this kernel update
about an older version of the route since it is
no longer needed.

Ticket: 2722533
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-12-09 12:35:42 -05:00
Donald Sharp b3facc23df zebra: Reduce memory usage of streams for encoding packets
For those packets that we are not sending 16k of data, but something
far less than 256 bytes.  Reduce those stream sizes we allocate
to something much more reasonable.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-12-09 12:31:29 -05:00
vivek e2b20dfb33 zebra: Reset MAC's remote sequence number appropriately
When a MAC gets deleted but associated neighbors remain, the MAC is
kept in the zebra MAC database as an internal ("auto") entry. When
this happens, reset the MAC's remote sequence number. This ensures that
when the host with the MAC later comes up behind a remote VTEP, the
local switch accepts the MAC and installs it into the bridge FDB and
we don't end up in a situation where remote MACs are not installed
into the bridge FDB.

This fix is a corollary of CM-22753 and is this time done for local
MACs upon delete.

Note: Commit is marked Cumulus-only because I need to evalute more
comprehensive changes before upstreaming it.

Ticket: CM-29581
Reviewed By: As above
Testing Done:
1. Multiple rounds of manual testing
2. Two rounds of evpn-smoke, 1 round of precommit

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Acked-by:      Chirag Shah <chirag@cumulusnetworks.com>
Acked-by:      Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2024-12-09 12:29:38 -05:00
Donatas Abraitis 17a0d92ffd
Merge pull request #17589 from anlancs/master_up
zebra: use macro for one check
2024-12-07 22:35:12 +02:00
Igor Ryzhov e51c6dd256 zebra: add deprecation notice for no-op netns command
Signed-off-by: Igor Ryzhov <idryzhov@gmail.com>
2024-12-07 17:02:58 +02:00