]> git.puffer.fish Git - mirror/frr.git/log
mirror/frr.git
21 months agozebra: Further handle route replace semantics 14039/head
Donald Sharp [Mon, 17 Jul 2023 14:00:32 +0000 (10:00 -0400)]
zebra: Further handle route replace semantics

When an upper level protocol is installing a route X that needs to be
route replaced and at the same time the same or another protocol installs a
different route that depends on route X for nexthop resolution can leave
us with a state where the route is not accepted because zebra is still
really early in the route replace semantics ( route X is still on the work
Queue to be processed ) then the dependent route would not be installed.
This came up in the bgp_default_originate test cases frequently.

Further extendd the ROUTE_ENTR_ROUTE_REPLACING flag to cover this case
as well.  This has come up because the early route processing queueing
that was implemented late last year.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
(cherry picked from commit af80201876db00f339e2fbb9036942629aad9e67)

21 months agotools: Add what FRR thinks as the fib routes for support_bundle
Donald Sharp [Mon, 17 Jul 2023 13:56:06 +0000 (09:56 -0400)]
tools: Add what FRR thinks as the fib routes for support_bundle

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
(cherry picked from commit 33b1b8a04c2970a61ca38cbe0a016ffed394f329)

21 months agoMerge pull request #14035 from FRRouting/mergify/bp/dev/9.0/pr-14025
Donald Sharp [Mon, 17 Jul 2023 23:50:51 +0000 (19:50 -0400)]
Merge pull request #14035 from FRRouting/mergify/bp/dev/9.0/pr-14025

zebra: The command ipv6 nht xxx not work (backport #14025)

21 months agozebra: The command ipv6 nht xxx not work 14035/head
guozhongfeng [Fri, 14 Jul 2023 08:08:50 +0000 (16:08 +0800)]
zebra: The command ipv6 nht xxx not work

If the command is ipv6 nht protocol route-map rmap, this parameter should use AFI_IP6

Signed-off-by: guozhongfeng <guozhongfeng.gzf@alibaba-inc.com>
(cherry picked from commit 1193611f8ea9d2e38d40f17770f8ca1fbfa88ef9)

21 months agoMerge pull request #14031 from FRRouting/mergify/bp/dev/9.0/pr-14017
Donald Sharp [Mon, 17 Jul 2023 18:27:13 +0000 (14:27 -0400)]
Merge pull request #14031 from FRRouting/mergify/bp/dev/9.0/pr-14017

bgpd: Prevent use after free (backport #14017)

21 months agobgpd: Prevent use after free 14031/head
Donald Sharp [Fri, 14 Jul 2023 16:14:20 +0000 (12:14 -0400)]
bgpd: Prevent use after free

When running bgp_always_compare_med, I am frequently seeing a crash
After running with valgrind I am seeing this and a invalid write
immediately after this as well.

==311743== Invalid read of size 2
==311743==    at 0x4992421: route_map_counter_decrement (routemap.c:3308)
==311743==    by 0x35664D: peer_route_map_unset (bgpd.c:7259)
==311743==    by 0x306546: peer_route_map_unset_vty (bgp_vty.c:8037)
==311743==    by 0x3066AC: no_neighbor_route_map (bgp_vty.c:8081)
==311743==    by 0x49078DE: cmd_execute_command_real (command.c:990)
==311743==    by 0x4907A63: cmd_execute_command (command.c:1050)
==311743==    by 0x490801F: cmd_execute (command.c:1217)
==311743==    by 0x49C5535: vty_command (vty.c:551)
==311743==    by 0x49C7459: vty_execute (vty.c:1314)
==311743==    by 0x49C97D1: vtysh_read (vty.c:2223)
==311743==    by 0x49BE5E2: event_call (event.c:1995)
==311743==    by 0x494786C: frr_run (libfrr.c:1204)
==311743==    by 0x1F7655: main (bgp_main.c:505)
==311743==  Address 0x9ec2180 is 64 bytes inside a block of size 120 free'd
==311743==    at 0x484B27F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==311743==    by 0x495A1BA: qfree (memory.c:130)
==311743==    by 0x498D412: route_map_free_map (routemap.c:748)
==311743==    by 0x498D176: route_map_add (routemap.c:672)
==311743==    by 0x498D79B: route_map_get (routemap.c:857)
==311743==    by 0x499C256: lib_route_map_create (routemap_northbound.c:102)
==311743==    by 0x49702D8: nb_callback_create (northbound.c:1234)
==311743==    by 0x497107F: nb_callback_configuration (northbound.c:1578)
==311743==    by 0x4971693: nb_transaction_process (northbound.c:1709)
==311743==    by 0x496FCF4: nb_candidate_commit_apply (northbound.c:1103)
==311743==    by 0x496FE4E: nb_candidate_commit (northbound.c:1136)
==311743==    by 0x497798F: nb_cli_classic_commit (northbound_cli.c:49)
==311743==    by 0x4977B4F: nb_cli_pending_commit_check (northbound_cli.c:88)
==311743==    by 0x49078C1: cmd_execute_command_real (command.c:987)
==311743==    by 0x4907B44: cmd_execute_command (command.c:1068)
==311743==    by 0x490801F: cmd_execute (command.c:1217)
==311743==    by 0x49C5535: vty_command (vty.c:551)
==311743==    by 0x49C7459: vty_execute (vty.c:1314)
==311743==    by 0x49C97D1: vtysh_read (vty.c:2223)
==311743==    by 0x49BE5E2: event_call (event.c:1995)
==311743==    by 0x494786C: frr_run (libfrr.c:1204)
==311743==    by 0x1F7655: main (bgp_main.c:505)
==311743==  Block was alloc'd at
==311743==    at 0x484DA83: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==311743==    by 0x495A068: qcalloc (memory.c:105)
==311743==    by 0x498D0C8: route_map_new (routemap.c:646)
==311743==    by 0x498D128: route_map_add (routemap.c:658)
==311743==    by 0x498D79B: route_map_get (routemap.c:857)
==311743==    by 0x499C256: lib_route_map_create (routemap_northbound.c:102)
==311743==    by 0x49702D8: nb_callback_create (northbound.c:1234)
==311743==    by 0x497107F: nb_callback_configuration (northbound.c:1578)
==311743==    by 0x4971693: nb_transaction_process (northbound.c:1709)
==311743==    by 0x496FCF4: nb_candidate_commit_apply (northbound.c:1103)
==311743==    by 0x496FE4E: nb_candidate_commit (northbound.c:1136)
==311743==    by 0x497798F: nb_cli_classic_commit (northbound_cli.c:49)
==311743==    by 0x4977B4F: nb_cli_pending_commit_check (northbound_cli.c:88)
==311743==    by 0x49078C1: cmd_execute_command_real (command.c:987)
==311743==    by 0x4907B44: cmd_execute_command (command.c:1068)
==311743==    by 0x490801F: cmd_execute (command.c:1217)
==311743==    by 0x49C5535: vty_command (vty.c:551)
==311743==    by 0x49C7459: vty_execute (vty.c:1314)
==311743==    by 0x49C97D1: vtysh_read (vty.c:2223)
==311743==    by 0x49BE5E2: event_call (event.c:1995)
==311743==    by 0x494786C: frr_run (libfrr.c:1204)

Effectively the route_map that is being stored has been freed already
but we have not cleaned up properly yet.  Go through and clean the
code up by ensuring that the pointer actually exists instead of trusting
it does when doing the decrement operation.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
(cherry picked from commit 2ba2c284bab39f220eea3beabd5feeea216e3bfb)

21 months agoMerge pull request #14022 from FRRouting/mergify/bp/dev/9.0/pr-14019
Jafar Al-Gharaibeh [Mon, 17 Jul 2023 04:52:20 +0000 (23:52 -0500)]
Merge pull request #14022 from FRRouting/mergify/bp/dev/9.0/pr-14019

fix double lock bug and cmd resume early bugs (backport #14019)

21 months agotests: add regression test for issue $13920 14022/head
Christian Hopps [Fri, 14 Jul 2023 23:29:57 +0000 (19:29 -0400)]
tests: add regression test for issue $13920

Signed-off-by: Christian Hopps <chopps@labn.net>
21 months agovtysh: track and fix file-lock use in the workaround from 2004
Christian Hopps [Fri, 14 Jul 2023 22:21:55 +0000 (18:21 -0400)]
vtysh: track and fix file-lock use in the workaround from 2004

There's a workaround in the code from a bug from back in 2004, it ends
and re-enters config mode anytime an `exit` is done from a level below
the top-level config node (e.g., from a `router isis` node). We need to
re-enter config mode with or without a lock according to how we actually
entered it to begin with.

fixes #13920

Signed-off-by: Christian Hopps <chopps@labn.net>
21 months agolib: mgmtd: only clear pending for the in-progress command
Christian Hopps [Fri, 14 Jul 2023 20:13:54 +0000 (16:13 -0400)]
lib: mgmtd: only clear pending for the in-progress command

The lock/unlocks are being done short-circuit so they are never pending;
however, the handling of the unlock notification was always resuming the command
if pending was set. In all cases pending is set for another command. For example
implicit commit locks then when notified its done unlocks which was clearing the
set-config pending flag and resuming that command incorrectly.

Signed-off-by: Christian Hopps <chopps@labn.net>
21 months agoMerge pull request #13887 from FRRouting/mergify/bp/dev/9.0/pr-13866
Jafar Al-Gharaibeh [Sun, 16 Jul 2023 15:37:20 +0000 (10:37 -0500)]
Merge pull request #13887 from FRRouting/mergify/bp/dev/9.0/pr-13866

Changes for inclusive language and other cleanup (backport #13866)

21 months agoMerge pull request #14014 from FRRouting/mergify/bp/dev/9.0/pr-13993
Donatas Abraitis [Sun, 16 Jul 2023 14:20:47 +0000 (17:20 +0300)]
Merge pull request #14014 from FRRouting/mergify/bp/dev/9.0/pr-13993

lib: fix on-match when added to existing route-map entry (backport #13993)

21 months agomgmtd: convert map to darr use allowing dynamic registrations 13887/head
Christian Hopps [Sat, 24 Jun 2023 16:35:47 +0000 (12:35 -0400)]
mgmtd: convert map to darr use allowing dynamic registrations

- move from the static allocated and initialize xpath map to using the
new darr (dynamic array) code.

Signed-off-by: Christian Hopps <chopps@labn.net>
(cherry picked from commit 5447d16b7389703e6a8e0af7e9faaf153b2c4ad2)

21 months agolib: add dynamic array type
Christian Hopps [Fri, 23 Jun 2023 18:34:47 +0000 (14:34 -0400)]
lib: add dynamic array type

Signed-off-by: Christian Hopps <chopps@labn.net>
(cherry picked from commit e6e0c5bd25599c76bd05db3c2e3f32f6d3fe47bb)

# Conflicts:
# .clang-format

21 months agolib: fix on-match when added to existing route-map entry 14014/head
Alexander Chernavin [Fri, 14 Oct 2022 09:02:06 +0000 (09:02 +0000)]
lib: fix on-match when added to existing route-map entry

Currently, "on-match (next|goto)" only works if already present in a
route-map entry when the route-map is applied to the routes. However, if
the command is added to an existing route-map entry, the route-map is
not reapplied to the routes in order to accommodate the changes. And
service restart is needed. The problem is that setting the command
doesn't signal about the change to the listener (i.e. to a routing
daemon).

With this fix, signal to the listener about addition of "on-match
(next|goto)" to a route-map entry.

Signed-off-by: Alexander Chernavin <achernavin@netgate.com>
(cherry picked from commit 633eb6ee7742449d0644dda7fd83865e3c01f937)

21 months agoMerge pull request #13997 from ton31337/fix/backport_8f6c125167fd5fabd3f44632f6594398...
Donald Sharp [Thu, 13 Jul 2023 13:34:30 +0000 (09:34 -0400)]
Merge pull request #13997 from ton31337/fix/backport_8f6c125167fd5fabd3f44632f6594398c81f8c08_to_9.0

bgpd: free bgp vpn policy

21 months agobgpd: free bgp vpn policy 13997/head
ryndia [Tue, 27 Jun 2023 06:59:09 +0000 (10:59 +0400)]
bgpd: free bgp vpn policy

The bgp vpn policy had some attribute not free when the function bgp_free was called leading to memory leak as shown below.

./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251:Direct leak of 592 byte(s) in 2 object(s) allocated from:
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251-    #0 0x7f4b7ae92037 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251-    #1 0x7f4b7aa96e38 in qcalloc lib/memory.c:105
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251-    #2 0x7f4b7aa9bec9 in srv6_locator_chunk_alloc lib/srv6.c:135
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251-    #3 0x56396f8e56f8 in ensure_vrf_tovpn_sid_per_af bgpd/bgp_mplsvpn.c:752
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251-    #4 0x56396f8e608a in ensure_vrf_tovpn_sid bgpd/bgp_mplsvpn.c:846
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251-    #5 0x56396f8e075d in vpn_leak_postchange bgpd/bgp_mplsvpn.h:259
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251-    #6 0x56396f8f3e5b in vpn_leak_postchange_all bgpd/bgp_mplsvpn.c:3397
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251-    #7 0x56396fa920ef in bgp_zebra_process_srv6_locator_chunk bgpd/bgp_zebra.c:3238
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251-    #8 0x7f4b7abb2913 in zclient_read lib/zclient.c:4134
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251-    #9 0x7f4b7ab62010 in thread_call lib/thread.c:1991
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251-    #10 0x7f4b7aa5a418 in frr_run lib/libfrr.c:1185
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251-    #11 0x56396f7d756d in main bgpd/bgp_main.c:505
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251-    #12 0x7f4b7a479d09 in __libc_start_main ../csu/libc-start.c:308
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251-
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251:Direct leak of 32 byte(s) in 2 object(s) allocated from:
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251-    #0 0x7f4b7ae92037 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251-    #1 0x7f4b7aa96e38 in qcalloc lib/memory.c:105
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251-    #2 0x56396f8e31b8 in vpn_leak_zebra_vrf_sid_update_per_af bgpd/bgp_mplsvpn.c:386
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251-    #3 0x56396f8e3ae8 in vpn_leak_zebra_vrf_sid_update bgpd/bgp_mplsvpn.c:448
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251-    #4 0x56396f8e09b0 in vpn_leak_postchange bgpd/bgp_mplsvpn.h:271
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251-    #5 0x56396f8f3e5b in vpn_leak_postchange_all bgpd/bgp_mplsvpn.c:3397
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251-    #6 0x56396fa920ef in bgp_zebra_process_srv6_locator_chunk bgpd/bgp_zebra.c:3238
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251-    #7 0x7f4b7abb2913 in zclient_read lib/zclient.c:4134
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251-    #8 0x7f4b7ab62010 in thread_call lib/thread.c:1991
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251-    #9 0x7f4b7aa5a418 in frr_run lib/libfrr.c:1185
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251-    #10 0x56396f7d756d in main bgpd/bgp_main.c:505
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251-    #11 0x7f4b7a479d09 in __libc_start_main ../csu/libc-start.c:308
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251-
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251:Direct leak of 32 byte(s) in 2 object(s) allocated from:
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251-    #0 0x7f4b7ae92037 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251-    #1 0x7f4b7aa96e38 in qcalloc lib/memory.c:105
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251-    #2 0x56396f8e5730 in ensure_vrf_tovpn_sid_per_af bgpd/bgp_mplsvpn.c:753
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251-    #3 0x56396f8e608a in ensure_vrf_tovpn_sid bgpd/bgp_mplsvpn.c:846
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251-    #4 0x56396f8e075d in vpn_leak_postchange bgpd/bgp_mplsvpn.h:259
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251-    #5 0x56396f8f3e5b in vpn_leak_postchange_all bgpd/bgp_mplsvpn.c:3397
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251-    #6 0x56396fa920ef in bgp_zebra_process_srv6_locator_chunk bgpd/bgp_zebra.c:3238
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251-    #7 0x7f4b7abb2913 in zclient_read lib/zclient.c:4134
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251-    #8 0x7f4b7ab62010 in thread_call lib/thread.c:1991
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251-    #9 0x7f4b7aa5a418 in frr_run lib/libfrr.c:1185
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251-    #10 0x56396f7d756d in main bgpd/bgp_main.c:505
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251-    #11 0x7f4b7a479d09 in __libc_start_main ../csu/libc-start.c:308
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251-
./bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.bgpd.asan.603251-SUMMARY: AddressSanitizer: 656 byte(s) leaked in 6 allocation(s).

Signed-off-by: ryndia <dindyalsarvesh@gmail.com>
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
21 months agoMerge pull request #13953 from FRRouting/mergify/bp/dev/9.0/pr-13757
Donatas Abraitis [Sat, 8 Jul 2023 06:50:35 +0000 (09:50 +0300)]
Merge pull request #13953 from FRRouting/mergify/bp/dev/9.0/pr-13757

zebra: Fix crash when `dplane_fpm_nl` fails to process received routes (backport #13757)

21 months agozebra: Fix crash when `dplane_fpm_nl` fails to process received routes 13953/head
Carmine Scarpitta [Fri, 7 Jul 2023 00:57:07 +0000 (02:57 +0200)]
zebra: Fix crash when `dplane_fpm_nl` fails to process received routes

When `dplane_fpm_nl` receives a route, it allocates memory for a dplane
context and calls `netlink_route_change_read_unicast_internal` without
initializing the `intf_extra_list` contained in the dplane context. If
`netlink_route_change_read_unicast_internal` is not able to process the
route, we call `dplane_ctx_fini` to free the dplane context. This causes
a crash because `dplane_ctx_fini` attempts to access the intf_extra_list
which is not initialized.

To solve this issue, we can call `dplane_ctx_route_init`to initialize
the dplane route context properly, just after the dplane context
allocation.

(gdb) bt
#0 0x0000555dd5ceae80 in dplane_intf_extra_list_pop (h=0x7fae1c007e68) at ../zebra/zebra_dplane.c:427
#1 dplane_ctx_free_internal (ctx=0x7fae1c0074b0) at ../zebra/zebra_dplane.c:724
#2 0x0000555dd5cebc99 in dplane_ctx_free (pctx=0x7fae2aa88c98) at ../zebra/zebra_dplane.c:869
#3 dplane_ctx_free (pctx=0x7fae2aa88c98, pctx@entry=0x7fae2aa78c28) at ../zebra/zebra_dplane.c:855
#4 dplane_ctx_fini (pctx=pctx@entry=0x7fae2aa88c98) at ../zebra/zebra_dplane.c:890
#5 0x00007fae31e93f29 in fpm_read (t=) at ../zebra/dplane_fpm_nl.c:605
#6 0x00007fae325191dd in thread_call (thread=thread@entry=0x7fae2aa98da0) at ../lib/thread.c:2006
#7 0x00007fae324c42b8 in fpt_run (arg=0x555dd74777c0) at ../lib/frr_pthread.c:309
#8 0x00007fae32405ea7 in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#9 0x00007fae32325a2f in clone () from /lib/x86_64-linux-gnu/libc.so.6

Fixes: #13754
Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
(cherry picked from commit 7f2dec4f090500c65f54fb7ce3c2bab22eef5474)

21 months agozebra: Abstract `dplane_ctx_route_init` to init route without copying
Carmine Scarpitta [Fri, 7 Jul 2023 00:55:18 +0000 (02:55 +0200)]
zebra: Abstract `dplane_ctx_route_init` to init route without copying

The function `dplane_ctx_route_init` initializes a dplane route context
from the route object passed as an argument. Let's abstract this
function to allow initializing the dplane route context without actually
copying a route object.

This allows us to use this function for initializing a dplane route
context when we don't have any route to copy in it.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
(cherry picked from commit 745a0fcbb21a6bd7330454437abe34aff0bf82c0)

21 months agoMerge pull request #13943 from FRRouting/mergify/bp/dev/9.0/pr-13808
Donatas Abraitis [Thu, 6 Jul 2023 19:29:39 +0000 (22:29 +0300)]
Merge pull request #13943 from FRRouting/mergify/bp/dev/9.0/pr-13808

zebra: fix wrong nexthop check for kernel routes (backport #13808)

21 months agotests: Check if kernel routes work with changed vrf 13943/head
anlan_cs [Mon, 26 Jun 2023 10:20:58 +0000 (18:20 +0800)]
tests: Check if kernel routes work with changed vrf

Check `show ip route` for specific kernel routes after
the interface as their nexthop changes vrf.

After moving interface's vrf, there should be no kernel
route in old vrf.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
(cherry picked from commit 019ac03e5b9fd46c51bd14f9f3a16c746e28fdac)

21 months agozebra: fix wrong nexthop check for kernel routes
anlan_cs [Mon, 19 Jun 2023 02:21:28 +0000 (10:21 +0800)]
zebra: fix wrong nexthop check for kernel routes

When changing one interface's vrf, the kernel routes are wrongly kept
in old vrf.  Finally, the forwarding table in that old vrf can't forward
traffic correctly for those residual entries.

Follow these steps to make this problem happen:
( Firstly, "x1" interface of default vrf is with address of "6.6.6.6/24". )

```
anlan# ip route add 4.4.4.0/24 via 6.6.6.8 dev x1
anlan# ip link add vrf1 type vrf table 1
anlan# ip link set vrf1 up
anlan# ip link set x1 master vrf1
```

Then check `show ip route`, the route of "4.4.4.0/24" is still selected
in default vrf.

If the interface goes down, the kernel routes will be reevaluated.  Those
kernel routes with active interface of nexthop can be kept no change, it
is a fast path.  Otherwise, it enters into slow path to do careful examination
on this nexthop.

After the interface's vrf had been changed into new vrf, the down message of
this interface came.  It means the interface is not in old vrf although it
still exists during that checking, so the kernel routes should be dropped
after this nexthop matching against a default route in slow path. But, in
current code they are wrongly kept in fast path for not checking vrf.

So, modified the checking active nexthop with vrf comparision for the interface
during reevaluation.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
(cherry picked from commit 098519caf8836f1bb0df9568ecd5daa5b4d5140b)

21 months agozebra: Remove unnecessary condition check for kernel routes
anlan_cs [Mon, 19 Jun 2023 01:10:57 +0000 (09:10 +0800)]
zebra: Remove unnecessary condition check for kernel routes

There are relaxed nexthop requirements for kernel routes because we
trust kernel routes.

Two minor changes for kernel routes:

1. `if_is_up()` is one of the necessary conditions for `if_is_operative()`.
Here, we can remove this unnecessary check for clarity.

2. Since `nexthop_active()` doesn't distinguish whether it is kernel route,
modified the corresponding comment in it.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
(cherry picked from commit caf896d6ef18d917a9b9cee9cb48719ea9757e37)

21 months agoMerge pull request #13931 from FRRouting/mergify/bp/dev/9.0/pr-13892
Donatas Abraitis [Wed, 5 Jul 2023 06:53:54 +0000 (09:53 +0300)]
Merge pull request #13931 from FRRouting/mergify/bp/dev/9.0/pr-13892

ospf6d: unlock lsa (backport #13892)

21 months agoMerge pull request #13924 from FRRouting/mergify/bp/dev/9.0/pr-13894
Donatas Abraitis [Tue, 4 Jul 2023 18:25:46 +0000 (21:25 +0300)]
Merge pull request #13924 from FRRouting/mergify/bp/dev/9.0/pr-13894

lib: Add two places we were not counting route-map applied (backport #13894)

21 months agoospf6d: unlock lsa 13931/head
ryndia [Fri, 30 Jun 2023 11:02:27 +0000 (15:02 +0400)]
ospf6d: unlock lsa

The function ospf6_router_lsa_contains_adj(), ospf6_gr_check_adjs() and ospf6_find_interf_prefix_lsa() iterate through LSDB and lock each LSA. During testing, it was discovered that the lock count did not reach zero upon termination. The stack trace below indicates the leak. To resolve this issue, it was found that unlocking the LSA before returning from the functions solves the problem. This suggests that there was a missing unlock that caused the lock count to remain nonzero.

=================================================================
==22565==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 400 byte(s) in 2 object(s) allocated from:
    #0 0x7fa744ccea37 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
    #1 0x7fa744867562 in qcalloc ../lib/memory.c:105
    #2 0x555cdbb37506 in ospf6_lsa_alloc ../ospf6d/ospf6_lsa.c:710
    #3 0x555cdbb375d6 in ospf6_lsa_create ../ospf6d/ospf6_lsa.c:725
    #4 0x555cdbaf1008 in ospf6_receive_lsa ../ospf6d/ospf6_flood.c:912
    #5 0x555cdbb48ceb in ospf6_lsupdate_recv ../ospf6d/ospf6_message.c:1621
    #6 0x555cdbb4ac90 in ospf6_read_helper ../ospf6d/ospf6_message.c:1896
    #7 0x555cdbb4aecc in ospf6_receive ../ospf6d/ospf6_message.c:1925
    #8 0x7fa744950c33 in event_call ../lib/event.c:1995
    #9 0x7fa74483b34a in frr_run ../lib/libfrr.c:1213
    #10 0x555cdbacf1eb in main ../ospf6d/ospf6_main.c:250
    #11 0x7fa7443f9d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

Objects leaked above:
0x6110000606c0 (200 bytes)
0x611000060940 (200 bytes)

Indirect leak of 80 byte(s) in 2 object(s) allocated from:
    #0 0x7fa744cce867 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x7fa744867525 in qmalloc ../lib/memory.c:100
    #2 0x555cdbb37520 in ospf6_lsa_alloc ../ospf6d/ospf6_lsa.c:711
    #3 0x555cdbb375d6 in ospf6_lsa_create ../ospf6d/ospf6_lsa.c:725
    #4 0x555cdbaf1008 in ospf6_receive_lsa ../ospf6d/ospf6_flood.c:912
    #5 0x555cdbb48ceb in ospf6_lsupdate_recv ../ospf6d/ospf6_message.c:1621
    #6 0x555cdbb4ac90 in ospf6_read_helper ../ospf6d/ospf6_message.c:1896
    #7 0x555cdbb4aecc in ospf6_receive ../ospf6d/ospf6_message.c:1925
    #8 0x7fa744950c33 in event_call ../lib/event.c:1995
    #9 0x7fa74483b34a in frr_run ../lib/libfrr.c:1213
    #10 0x555cdbacf1eb in main ../ospf6d/ospf6_main.c:250
    #11 0x7fa7443f9d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

Objects leaked above:
0x6040000325d0 (40 bytes)
0x604000032650 (40 bytes)

SUMMARY: AddressSanitizer: 480 byte(s) leaked in 4 allocation(s).

=================================================================
==5483==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 2000 byte(s) in 10 object(s) allocated from:
    #0 0x7f2c3faeea37 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
    #1 0x7f2c3f68a6d9 in qcalloc ../lib/memory.c:105
    #2 0x56431b83633d in ospf6_lsa_alloc ../ospf6d/ospf6_lsa.c:710
    #3 0x56431b83640d in ospf6_lsa_create ../ospf6d/ospf6_lsa.c:725
    #4 0x56431b7efe13 in ospf6_receive_lsa ../ospf6d/ospf6_flood.c:912
    #5 0x56431b847b31 in ospf6_lsupdate_recv ../ospf6d/ospf6_message.c:1621
    #6 0x56431b849ad6 in ospf6_read_helper ../ospf6d/ospf6_message.c:1896
    #7 0x56431b849d12 in ospf6_receive ../ospf6d/ospf6_message.c:1925
    #8 0x7f2c3f773c62 in event_call ../lib/event.c:1995
    #9 0x7f2c3f65e2de in frr_run ../lib/libfrr.c:1213
    #10 0x56431b7cdff6 in main ../ospf6d/ospf6_main.c:221
    #11 0x7f2c3f21dd8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

Objects leaked above:
0x611000060800 (200 bytes)
0x611000060a80 (200 bytes)
0x611000060d00 (200 bytes)
0x611000060f80 (200 bytes)
0x611000061200 (200 bytes)
0x611000061480 (200 bytes)
0x611000061840 (200 bytes)
0x611000061ac0 (200 bytes)
0x61100006c740 (200 bytes)
0x61100006d500 (200 bytes)

Indirect leak of 460 byte(s) in 10 object(s) allocated from:
    #0 0x7f2c3faee867 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
    #1 0x7f2c3f68a69c in qmalloc ../lib/memory.c:100
    #2 0x56431b836357 in ospf6_lsa_alloc ../ospf6d/ospf6_lsa.c:711
    #3 0x56431b83640d in ospf6_lsa_create ../ospf6d/ospf6_lsa.c:725
    #4 0x56431b7efe13 in ospf6_receive_lsa ../ospf6d/ospf6_flood.c:912
    #5 0x56431b847b31 in ospf6_lsupdate_recv ../ospf6d/ospf6_message.c:1621
    #6 0x56431b849ad6 in ospf6_read_helper ../ospf6d/ospf6_message.c:1896
    #7 0x56431b849d12 in ospf6_receive ../ospf6d/ospf6_message.c:1925
    #8 0x7f2c3f773c62 in event_call ../lib/event.c:1995
    #9 0x7f2c3f65e2de in frr_run ../lib/libfrr.c:1213
    #10 0x56431b7cdff6 in main ../ospf6d/ospf6_main.c:221
    #11 0x7f2c3f21dd8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58

Objects leaked above:
0x604000033110 (40 bytes)
0x604000033190 (40 bytes)
0x604000033210 (44 bytes)
0x604000033290 (44 bytes)
0x604000033310 (44 bytes)
0x604000033390 (44 bytes)
0x604000033410 (44 bytes)
0x604000033490 (44 bytes)
0x604000034c90 (44 bytes)
0x6070000d3830 (72 bytes)

SUMMARY: AddressSanitizer: 2460 byte(s) leaked in 20 allocation(s).
Signed-off-by: ryndia <dindyalsarvesh@gmail.com>
(cherry picked from commit b3420b1570bcf058cbf699f0ce182aa9978a14f7)

21 months agolib: Add two places we were not counting route-map applied 13924/head
Donald Sharp [Fri, 30 Jun 2023 13:56:51 +0000 (09:56 -0400)]
lib: Add two places we were not counting route-map applied

There were a couple of places where it was possible a route-map
was applied( and DENIED ) but the count for the number of times
the application happen was not incremented.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
(cherry picked from commit bdcea06d6a9a610200f8be7b9f86d22bf9663be9)

21 months agoMerge pull request #13910 from FRRouting/mergify/bp/dev/9.0/pr-13900
Donald Sharp [Mon, 3 Jul 2023 12:35:26 +0000 (08:35 -0400)]
Merge pull request #13910 from FRRouting/mergify/bp/dev/9.0/pr-13900

ospf6d: Fix crash because neighbor structure was freed (backport #13900)

21 months agoospf6d: Fix crash because neighbor structure was freed 13910/head
Donald Sharp [Sat, 1 Jul 2023 15:18:06 +0000 (11:18 -0400)]
ospf6d: Fix crash because neighbor structure was freed

The loading_done event needs a event pointer to prevent
use after free's.  Testing found this:

    ERROR: AddressSanitizer: heap-use-after-free on address 0x613000035130 at pc 0x55ad42d54e5f bp 0x7ffff1e942a0 sp 0x7ffff1e94290
    READ of size 1 at 0x613000035130 thread T0
        #0 0x55ad42d54e5e in loading_done ospf6d/ospf6_neighbor.c:447
        #1 0x55ad42ed7be4 in event_call lib/event.c:1995
        #2 0x55ad42e1df75 in frr_run lib/libfrr.c:1213
        #3 0x55ad42cf332e in main ospf6d/ospf6_main.c:250
        #4 0x7f5798133c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)
        #5 0x55ad42cf2b19 in _start (/usr/lib/frr/ospf6d+0x248b19)

    0x613000035130 is located 48 bytes inside of 384-byte region [0x613000035100,0x613000035280)
    freed by thread T0 here:
        #0 0x7f57998d77a8 in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xde7a8)
        #1 0x55ad42e3b4b6 in qfree lib/memory.c:130
        #2 0x55ad42d5d049 in ospf6_neighbor_delete ospf6d/ospf6_neighbor.c:180
        #3 0x55ad42d1e1ea in interface_down ospf6d/ospf6_interface.c:930
        #4 0x55ad42ed7be4 in event_call lib/event.c:1995
        #5 0x55ad42ed84fe in _event_execute lib/event.c:2086
        #6 0x55ad42d26d7b in ospf6_interface_clear ospf6d/ospf6_interface.c:2847
        #7 0x55ad42d73f16 in ospf6_process_reset ospf6d/ospf6_top.c:755
        #8 0x55ad42d7e98c in clear_router_ospf6_magic ospf6d/ospf6_top.c:778
        #9 0x55ad42d7e98c in clear_router_ospf6 ospf6d/ospf6_top_clippy.c:42
        #10 0x55ad42dc2665 in cmd_execute_command_real lib/command.c:994
        #11 0x55ad42dc2b32 in cmd_execute_command lib/command.c:1053
        #12 0x55ad42dc2fa9 in cmd_execute lib/command.c:1221
        #13 0x55ad42ee3cd6 in vty_command lib/vty.c:591
        #14 0x55ad42ee4170 in vty_execute lib/vty.c:1354
        #15 0x55ad42eec94f in vtysh_read lib/vty.c:2362
        #16 0x55ad42ed7be4 in event_call lib/event.c:1995
        #17 0x55ad42e1df75 in frr_run lib/libfrr.c:1213
        #18 0x55ad42cf332e in main ospf6d/ospf6_main.c:250
        #19 0x7f5798133c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

    previously allocated by thread T0 here:
        #0 0x7f57998d7d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
        #1 0x55ad42e3ab22 in qcalloc lib/memory.c:105
        #2 0x55ad42d5c8ff in ospf6_neighbor_create ospf6d/ospf6_neighbor.c:119
        #3 0x55ad42d4c86a in ospf6_hello_recv ospf6d/ospf6_message.c:464
        #4 0x55ad42d4c86a in ospf6_read_helper ospf6d/ospf6_message.c:1884
        #5 0x55ad42d4c86a in ospf6_receive ospf6d/ospf6_message.c:1925
        #6 0x55ad42ed7be4 in event_call lib/event.c:1995
        #7 0x55ad42e1df75 in frr_run lib/libfrr.c:1213
        #8 0x55ad42cf332e in main ospf6d/ospf6_main.c:250
        #9 0x7f5798133c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

Add an actual event pointer and just track it appropriately.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
(cherry picked from commit 77e838eb9aa18ebba2c75b3edc7ae06e3cfbcb6e)

21 months agoMerge pull request #13904 from FRRouting/mergify/bp/dev/9.0/pr-13895
Donatas Abraitis [Mon, 3 Jul 2023 06:19:30 +0000 (09:19 +0300)]
Merge pull request #13904 from FRRouting/mergify/bp/dev/9.0/pr-13895

ospfd: check for NULLs in ldp-igp sync json code (backport #13895)

21 months agoMerge pull request #13907 from FRRouting/mergify/bp/dev/9.0/pr-13897
Donatas Abraitis [Mon, 3 Jul 2023 06:19:12 +0000 (09:19 +0300)]
Merge pull request #13907 from FRRouting/mergify/bp/dev/9.0/pr-13897

ospf6d: Stop crash in ospf6_write (backport #13897)

21 months agoospf6d: Stop crash in ospf6_write 13907/head
Donald Sharp [Fri, 30 Jun 2023 19:21:43 +0000 (15:21 -0400)]
ospf6d: Stop crash in ospf6_write

I'm seeing crashes in ospf6_write on the `assert(node)`.  The only
sequence of events that I see that could possibly cause this to happen
is this:

a) Someone has scheduled a outgoing write to the ospf6->t_write and
placed item(s) on the ospf6->oi_write_q
b) A decision is made in ospf6_send_lsupdate() to send an immediate
packet via a event_execute(..., ospf6_write,....).
c) ospf6_write is called and the oi_write_q is cleaned out.
d) the t_write event is now popped and the oi_write_q is empty
and FRR asserts on the `assert(node)` <crash>

When event_execute is called for ospf6_write, just cancel the t_write
event.  If ospf6_write has more data to send at the end of the function
it will reschedule itself.  I've only seen this crash one time and am
unable to reliably reproduce this at all.  But this is the only mechanism
that I can see that could make this happen, given how little the oi_write_q
is actually touched in code.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
(cherry picked from commit 3fa39a35ed32f32ed94c16d2884b24e0dae4a5fa)

21 months agoospfd: check for NULLs in vty code 13904/head
Mark Stapp [Fri, 30 Jun 2023 13:44:00 +0000 (09:44 -0400)]
ospfd: check for NULLs in vty code

There were a couple of cli paths that NULL-checked in the
vtysh output path, but not in the json path.

Signed-off-by: Mark Stapp <mjs@labn.net>
(cherry picked from commit 864a3bc1855ec8027fec8d6f400adb44e1ecbfcf)

22 months agoMerge pull request #13873 from FRRouting/mergify/bp/dev/9.0/pr-13870
Donatas Abraitis [Fri, 30 Jun 2023 08:01:43 +0000 (11:01 +0300)]
Merge pull request #13873 from FRRouting/mergify/bp/dev/9.0/pr-13870

bgpd: Ensure peer data structure is accessed only when BGPD is not te… (backport #13870)

22 months agoMerge pull request #13884 from FRRouting/mergify/bp/dev/9.0/pr-13869
Donatas Abraitis [Fri, 30 Jun 2023 07:47:25 +0000 (10:47 +0300)]
Merge pull request #13884 from FRRouting/mergify/bp/dev/9.0/pr-13869

pbrd: fix crash with match command (backport #13869)

22 months agomgmtd: remove unused "placeholder" code.
Christian Hopps [Tue, 27 Jun 2023 18:12:39 +0000 (14:12 -0400)]
mgmtd: remove unused "placeholder" code.

We don't need un-run/un-tested placeholder code we may never need.

Signed-off-by: Christian Hopps <chopps@labn.net>
(cherry picked from commit 70fb3910dbe81c8d44dcfa77c070b0a6e83d3607)

22 months agomgmtd: consolidate getcfg and getdata msgs into "get"
Christian Hopps [Tue, 27 Jun 2023 17:58:54 +0000 (13:58 -0400)]
mgmtd: consolidate getcfg and getdata msgs into "get"

eliminates tons of copy and paste code.

Signed-off-by: Christian Hopps <chopps@labn.net>
(cherry picked from commit dbb1bc6f355ae53ce1f2402a1ac196e9f9e18a42)

22 months agomgmtd: inclusive language change
Christian Hopps [Mon, 26 Jun 2023 16:59:59 +0000 (12:59 -0400)]
mgmtd: inclusive language change

'cfg_btch' -> 'batch' and 'btch_list' -> 'batch_list'

Signed-off-by: Christian Hopps <chopps@labn.net>
(cherry picked from commit 6267c2aaad2a503ae24885d3ffc9a7867fccb6c0)

22 months agopbrd: fix crash with match command 13884/head
anlan_cs [Wed, 28 Jun 2023 04:31:52 +0000 (12:31 +0800)]
pbrd: fix crash with match command

Crash with empty `ip-protocol`:
```
anlan(config-pbr-map)# match ip-protocol
vtysh: error reading from pbrd: Resource temporarily unavailable (11)Warning: closing connection to pbrd because of an I/O error!
```

So, give warning for empty `ip-protocol`.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
(cherry picked from commit 4e313ee450cb95cbc49cfe0b5bb9eb2e31549554)

22 months agoMerge pull request #13871 from FRRouting/mergify/bp/dev/9.0/pr-13850
Donatas Abraitis [Thu, 29 Jun 2023 08:20:28 +0000 (11:20 +0300)]
Merge pull request #13871 from FRRouting/mergify/bp/dev/9.0/pr-13850

pimd: Fix memory leak in PIM interface deletion (backport #13850)

22 months agobgpd: Ensure peer data structure is accessed only when BGPD is not terminating 13873/head
Naveen Thanikachalam [Mon, 4 Feb 2019 14:26:01 +0000 (06:26 -0800)]
bgpd: Ensure peer data structure is accessed only when BGPD is not terminating

With these changes,
the code ensures that the peer data-structures are accessed
only after it knows that BGPD is not terminating.

Authored-by: Naveen Thanikachalam <nthanikachal@vmware.com>
Signed-off-by: Iqra Siddiqui <imujeebsiddi@vmware.com>
(cherry picked from commit 7e28578bb69c0ad11c65126b984fd9a26b675956)

22 months agopimd: Fix memory leak in PIM interface deletion 13871/head
Keelan10 [Mon, 26 Jun 2023 10:56:26 +0000 (14:56 +0400)]
pimd: Fix memory leak in PIM interface deletion

This commit ensures proper cleanup by deleting the gm_join_list when a PIM interface is deleted. The gm_join_list was previously not being freed, causing a memory leak.

The ASan leak log for reference:
```
***********************************************************************************
Address Sanitizer Error detected in multicast_mld_join_topo1.test_multicast_mld_local_join/r1.asan.pim6d.28070

=================================================================
==28070==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 40 byte(s) in 1 object(s) allocated from:
    #0 0x7f3605dbfd28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    #1 0x56230373dd6b in qcalloc lib/memory.c:105
    #2 0x56230372180f in list_new lib/linklist.c:49
    #3 0x56230361b589 in pim_if_gm_join_add pimd/pim_iface.c:1313
    #4 0x562303642247 in lib_interface_gmp_address_family_static_group_create pimd/pim_nb_config.c:2868
    #5 0x562303767280 in nb_callback_create lib/northbound.c:1235
    #6 0x562303767280 in nb_callback_configuration lib/northbound.c:1579
    #7 0x562303768a1d in nb_transaction_process lib/northbound.c:1710
    #8 0x56230376904a in nb_candidate_commit_apply lib/northbound.c:1104
    #9 0x5623037692ba in nb_candidate_commit lib/northbound.c:1137
    #10 0x562303769dec in nb_cli_classic_commit lib/northbound_cli.c:49
    #11 0x56230376fb79 in nb_cli_pending_commit_check lib/northbound_cli.c:88
    #12 0x5623036c5bcb in cmd_execute_command_real lib/command.c:991
    #13 0x5623036c5f1b in cmd_execute_command lib/command.c:1053
    #14 0x5623036c6392 in cmd_execute lib/command.c:1221
    #15 0x5623037e75da in vty_command lib/vty.c:591
    #16 0x5623037e7a74 in vty_execute lib/vty.c:1354
    #17 0x5623037f0253 in vtysh_read lib/vty.c:2362
    #18 0x5623037db4e8 in event_call lib/event.c:1995
    #19 0x562303720f97 in frr_run lib/libfrr.c:1213
    #20 0x56230368615d in main pimd/pim6_main.c:184
    #21 0x7f360461bc86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

Indirect leak of 192 byte(s) in 4 object(s) allocated from:
    #0 0x7f3605dbfd28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    #1 0x56230373dd6b in qcalloc lib/memory.c:105
    #2 0x56230361b91d in gm_join_new pimd/pim_iface.c:1288
    #3 0x56230361b91d in pim_if_gm_join_add pimd/pim_iface.c:1326
    #4 0x562303642247 in lib_interface_gmp_address_family_static_group_create pimd/pim_nb_config.c:2868
    #5 0x562303767280 in nb_callback_create lib/northbound.c:1235
    #6 0x562303767280 in nb_callback_configuration lib/northbound.c:1579
    #7 0x562303768a1d in nb_transaction_process lib/northbound.c:1710
    #8 0x56230376904a in nb_candidate_commit_apply lib/northbound.c:1104
    #9 0x5623037692ba in nb_candidate_commit lib/northbound.c:1137
    #10 0x562303769dec in nb_cli_classic_commit lib/northbound_cli.c:49
    #11 0x56230376fb79 in nb_cli_pending_commit_check lib/northbound_cli.c:88
    #12 0x5623036c5bcb in cmd_execute_command_real lib/command.c:991
    #13 0x5623036c5f1b in cmd_execute_command lib/command.c:1053
    #14 0x5623036c6392 in cmd_execute lib/command.c:1221
    #15 0x5623037e75da in vty_command lib/vty.c:591
    #16 0x5623037e7a74 in vty_execute lib/vty.c:1354
    #17 0x5623037f0253 in vtysh_read lib/vty.c:2362
    #18 0x5623037db4e8 in event_call lib/event.c:1995
    #19 0x562303720f97 in frr_run lib/libfrr.c:1213
    #20 0x56230368615d in main pimd/pim6_main.c:184
    #21 0x7f360461bc86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

Indirect leak of 96 byte(s) in 4 object(s) allocated from:
    #0 0x7f3605dbfd28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    #1 0x56230373dd6b in qcalloc lib/memory.c:105
    #2 0x562303721651 in listnode_new lib/linklist.c:71
    #3 0x56230372182b in listnode_add lib/linklist.c:92
    #4 0x56230361ba9a in gm_join_new pimd/pim_iface.c:1295
    #5 0x56230361ba9a in pim_if_gm_join_add pimd/pim_iface.c:1326
    #6 0x562303642247 in lib_interface_gmp_address_family_static_group_create pimd/pim_nb_config.c:2868
    #7 0x562303767280 in nb_callback_create lib/northbound.c:1235
    #8 0x562303767280 in nb_callback_configuration lib/northbound.c:1579
    #9 0x562303768a1d in nb_transaction_process lib/northbound.c:1710
    #10 0x56230376904a in nb_candidate_commit_apply lib/northbound.c:1104
    #11 0x5623037692ba in nb_candidate_commit lib/northbound.c:1137
    #12 0x562303769dec in nb_cli_classic_commit lib/northbound_cli.c:49
    #13 0x56230376fb79 in nb_cli_pending_commit_check lib/northbound_cli.c:88
    #14 0x5623036c5bcb in cmd_execute_command_real lib/command.c:991
    #15 0x5623036c5f1b in cmd_execute_command lib/command.c:1053
    #16 0x5623036c6392 in cmd_execute lib/command.c:1221
    #17 0x5623037e75da in vty_command lib/vty.c:591
    #18 0x5623037e7a74 in vty_execute lib/vty.c:1354
    #19 0x5623037f0253 in vtysh_read lib/vty.c:2362
    #20 0x5623037db4e8 in event_call lib/event.c:1995
    #21 0x562303720f97 in frr_run lib/libfrr.c:1213
    #22 0x56230368615d in main pimd/pim6_main.c:184
    #23 0x7f360461bc86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

Indirect leak of 48 byte(s) in 1 object(s) allocated from:
    #0 0x7f3605dbfd28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    #1 0x56230373dd6b in qcalloc lib/memory.c:105
    #2 0x56230361b91d in gm_join_new pimd/pim_iface.c:1288
    #3 0x56230361b91d in pim_if_gm_join_add pimd/pim_iface.c:1326
    #4 0x562303642247 in lib_interface_gmp_address_family_static_group_create pimd/pim_nb_config.c:2868
    #5 0x562303767280 in nb_callback_create lib/northbound.c:1235
    #6 0x562303767280 in nb_callback_configuration lib/northbound.c:1579
    #7 0x562303768a1d in nb_transaction_process lib/northbound.c:1710
    #8 0x56230376904a in nb_candidate_commit_apply lib/northbound.c:1104
    #9 0x5623037692ba in nb_candidate_commit lib/northbound.c:1137
    #10 0x562303769dec in nb_cli_classic_commit lib/northbound_cli.c:49
    #11 0x56230376fb79 in nb_cli_pending_commit_check lib/northbound_cli.c:88
    #12 0x5623036c5bcb in cmd_execute_command_real lib/command.c:991
    #13 0x5623036c5f6f in cmd_execute_command lib/command.c:1072
    #14 0x5623036c6392 in cmd_execute lib/command.c:1221
    #15 0x5623037e75da in vty_command lib/vty.c:591
    #16 0x5623037e7a74 in vty_execute lib/vty.c:1354
    #17 0x5623037f0253 in vtysh_read lib/vty.c:2362
    #18 0x5623037db4e8 in event_call lib/event.c:1995
    #19 0x562303720f97 in frr_run lib/libfrr.c:1213
    #20 0x56230368615d in main pimd/pim6_main.c:184
    #21 0x7f360461bc86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

Indirect leak of 24 byte(s) in 1 object(s) allocated from:
    #0 0x7f3605dbfd28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    #1 0x56230373dd6b in qcalloc lib/memory.c:105
    #2 0x562303721651 in listnode_new lib/linklist.c:71
    #3 0x56230372182b in listnode_add lib/linklist.c:92
    #4 0x56230361ba9a in gm_join_new pimd/pim_iface.c:1295
    #5 0x56230361ba9a in pim_if_gm_join_add pimd/pim_iface.c:1326
    #6 0x562303642247 in lib_interface_gmp_address_family_static_group_create pimd/pim_nb_config.c:2868
    #7 0x562303767280 in nb_callback_create lib/northbound.c:1235
    #8 0x562303767280 in nb_callback_configuration lib/northbound.c:1579
    #9 0x562303768a1d in nb_transaction_process lib/northbound.c:1710
    #10 0x56230376904a in nb_candidate_commit_apply lib/northbound.c:1104
    #11 0x5623037692ba in nb_candidate_commit lib/northbound.c:1137
    #12 0x562303769dec in nb_cli_classic_commit lib/northbound_cli.c:49
    #13 0x56230376fb79 in nb_cli_pending_commit_check lib/northbound_cli.c:88
    #14 0x5623036c5bcb in cmd_execute_command_real lib/command.c:991
    #15 0x5623036c5f6f in cmd_execute_command lib/command.c:1072
    #16 0x5623036c6392 in cmd_execute lib/command.c:1221
    #17 0x5623037e75da in vty_command lib/vty.c:591
    #18 0x5623037e7a74 in vty_execute lib/vty.c:1354
    #19 0x5623037f0253 in vtysh_read lib/vty.c:2362
    #20 0x5623037db4e8 in event_call lib/event.c:1995
    #21 0x562303720f97 in frr_run lib/libfrr.c:1213
    #22 0x56230368615d in main pimd/pim6_main.c:184
    #23 0x7f360461bc86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

SUMMARY: AddressSanitizer: 400 byte(s) leaked in 11 allocation(s).
***********************************************************************************
```

Signed-off-by: Keelan Cannoo <keelan.cannoo@icloud.com>
(cherry picked from commit 24379f0bb29e276f2d9a06468973883f79dcaf45)

22 months agoMerge pull request #13863 from FRRouting/mergify/bp/dev/9.0/pr-13854
Donatas Abraitis [Wed, 28 Jun 2023 06:13:40 +0000 (09:13 +0300)]
Merge pull request #13863 from FRRouting/mergify/bp/dev/9.0/pr-13854

zebra: fix evpn rmac nh list cmp function (backport #13854)

22 months agozebra: fix evpn rmac nh list cmp function 13863/head
Chirag Shah [Mon, 26 Jun 2023 22:29:59 +0000 (15:29 -0700)]
zebra: fix evpn rmac nh list cmp function

EVPN RMAC (Router MAC) nexthop list compare
function needs to return all values so
the list element can be compared and added/deleted
properly.

Ticket:#3486989
Testing Done:
Originate EVPN Type-5 route with PIP IP and MAC as remote
nexthops.
Change the PIP IP address which triggers nexthop change.

Before fix:
When PIP IP changes RMAC is deleted from remote VTEPs.

TORS1# show evpn next-hops vni 4001 | include 00:02:00:00:00:2d
27.0.0.11       00:02:00:00:00:2d
TORS1# show evpn rmac vni 4001 | include 00:02:00:00:00:2d
00:02:00:00:00:2d 27.0.0.11

----- Remote VTEP change nexthop IP to 172.16.16.16 -----

TORS1# show evpn next-hops vni 4001 | include 00:02:00:00:00:2d
172.16.16.16    00:02:00:00:00:2d
TORS1# show evpn rmac vni 4001 | include 00:02:00:00:00:2d
TORS1#

After fix:
RMAC is retained as its nexthop list is not empty,
thus it is not deleted from remote VTEPs.

TORS1# show evpn rmac vni 4001 | include 00:02:00:00:00:2d
00:02:00:00:00:2d 172.16.16.16

Log:
2023/06/27 00:50:36.833474 ZEBRA: [XREH0-ZYMH6] L3VNI 4001 Remote VTEP
change(27.0.0.11 -> 172.16.16.16) for RMAC 00:02:00:00:00:2d

Signed-off-by: Chirag Shah <chirag@nvidia.com>
(cherry picked from commit a7d77ee58bdcc7dfaccfb124d94f738f2b2b4696)

22 months agoMerge pull request #13849 from FRRouting/mergify/bp/dev/9.0/pr-13839
Donatas Abraitis [Mon, 26 Jun 2023 15:03:34 +0000 (18:03 +0300)]
Merge pull request #13849 from FRRouting/mergify/bp/dev/9.0/pr-13839

staticd: remove unused YANG module (backport #13839)

22 months agostaticd: remove unused YANG module 13849/head
Christian Hopps [Fri, 23 Jun 2023 17:16:18 +0000 (13:16 -0400)]
staticd: remove unused YANG module

Signed-off-by: Christian Hopps <chopps@labn.net>
(cherry picked from commit 632440683f891669b5ea31f1d9dc8472e014e860)

22 months agoMerge pull request #13846 from LabNConsulting/chopps/backport-13795 frr-9.0-rc
Jafar Al-Gharaibeh [Sun, 25 Jun 2023 15:22:34 +0000 (10:22 -0500)]
Merge pull request #13846 from LabNConsulting/chopps/backport-13795

backport of #13795

22 months agomgmtd: fix memleak 13846/head
Christian Hopps [Sun, 18 Jun 2023 17:39:27 +0000 (13:39 -0400)]
mgmtd: fix memleak

Use northbound functions for replace and merge when possible, rather
than duplicating the code.

Signed-off-by: Christian Hopps <chopps@labn.net>
22 months agomgmtd: KISS the locking code
Christian Hopps [Sun, 18 Jun 2023 20:19:54 +0000 (16:19 -0400)]
mgmtd: KISS the locking code

Move away from things like "lock if not locked" type code, require the
user has locked prior to geting to that point.

For now we warn if we are taking a lock we already had; however, this
should really be a failure point.

New requirements:

SETCFG -
  not implicit commit - requires user has locked candidate DS and they
    must unlock after

  implicit commit - requires user has locked candidate and running DS
    both locks will be unlocked on reply to the SETCFG

COMMITCFG -
  requires user has locked candidate and running DS and they must unlock
  after

  rollback - this code now get both locks and then does an unlock and
  early return thing on the adapter side. It needs to be un-special
  cased in follow up work that would also include tests for this
  functionality.

Signed-off-by: Christian Hopps <chopps@labn.net>
22 months agomgmtd: simplify locking, removing read locks
Christian Hopps [Wed, 14 Jun 2023 13:32:16 +0000 (09:32 -0400)]
mgmtd: simplify locking, removing read locks

Signed-off-by: Christian Hopps <chopps@labn.net>
22 months agolib: mgmtd: use short-circuit for locking
Christian Hopps [Mon, 12 Jun 2023 08:59:19 +0000 (04:59 -0400)]
lib: mgmtd: use short-circuit for locking

Signed-off-by: Christian Hopps <chopps@labn.net>
22 months agolib: mgmtd: re-purpose is_short_circuit and fix depth variable inc/dec
Christian Hopps [Fri, 16 Jun 2023 11:19:53 +0000 (07:19 -0400)]
lib: mgmtd: re-purpose is_short_circuit and fix depth variable inc/dec

`is_short_circuit` now is set to true when a message is being
short-circuit handled.

`short_circuit_depth` was being inc/dec inside conditional macro, move
that out of the macro.

Signed-off-by: Christian Hopps <chopps@labn.net>
22 months agoMerge pull request #13843 from FRRouting/mergify/bp/dev/9.0/pr-13768
Donatas Abraitis [Sat, 24 Jun 2023 20:12:10 +0000 (23:12 +0300)]
Merge pull request #13843 from FRRouting/mergify/bp/dev/9.0/pr-13768

mgmtd: improvements in logging and commentary (backport #13768)

22 months agolib: mgmtd: improvements in logging and commentary 13843/head
Christian Hopps [Fri, 9 Jun 2023 20:54:54 +0000 (16:54 -0400)]
lib: mgmtd: improvements in logging and commentary

- log names of datastores not numbers
- improve logging for mgmt_msg_read
- Rather than use a bool, instead store the pending const string name of
the command being run that has postponed the CLI. This adds some nice
information to the logging when enabled.

Signed-off-by: Christian Hopps <chopps@labn.net>
(cherry picked from commit 96f9e7853bad7e21676f2eb126a915561e6c8dce)

22 months agoMerge pull request #13840 from FRRouting/mergify/bp/dev/9.0/pr-13766
Jafar Al-Gharaibeh [Sat, 24 Jun 2023 14:30:54 +0000 (09:30 -0500)]
Merge pull request #13840 from FRRouting/mergify/bp/dev/9.0/pr-13766

mgmtd cleanup/simplify some code (backport #13766)

22 months agomgmtd: complex redux in txn cleanup 13840/head
Christian Hopps [Mon, 12 Jun 2023 04:26:50 +0000 (00:26 -0400)]
mgmtd: complex redux in txn cleanup

Signed-off-by: Christian Hopps <chopps@labn.net>
(cherry picked from commit c9d153e5e9dc29459ec7d24640a817d3c6fcd222)

22 months agolib: mgmtd: simplify implicit commit code
Christian Hopps [Fri, 9 Jun 2023 20:52:56 +0000 (16:52 -0400)]
lib: mgmtd: simplify implicit commit code

Signed-off-by: Christian Hopps <chopps@labn.net>
(cherry picked from commit 70ff6bb80bf43e55171f328c96f0e45c634a4e1f)

22 months agoMerge pull request #13835 from FRRouting/mergify/bp/dev/9.0/pr-13764
Jafar Al-Gharaibeh [Fri, 23 Jun 2023 19:03:14 +0000 (14:03 -0500)]
Merge pull request #13835 from FRRouting/mergify/bp/dev/9.0/pr-13764

lib: mgmtd: make error handling more robust (backport #13764)

22 months agoMerge pull request #13833 from FRRouting/mergify/bp/dev/9.0/pr-13809
Jafar Al-Gharaibeh [Fri, 23 Jun 2023 13:35:57 +0000 (08:35 -0500)]
Merge pull request #13833 from FRRouting/mergify/bp/dev/9.0/pr-13809

doc: start of mgmtd developer doc (backport #13809)

22 months agolib: mgmtd: make error handling more robust 13835/head
Christian Hopps [Fri, 9 Jun 2023 15:03:54 +0000 (11:03 -0400)]
lib: mgmtd: make error handling more robust

Signed-off-by: Christian Hopps <chopps@labn.net>
(cherry picked from commit d694cd40f2cb566245ca2c7851730095bf90b1a8)

22 months agoMerge pull request #13834 from FRRouting/mergify/bp/dev/9.0/pr-13763
Jafar Al-Gharaibeh [Fri, 23 Jun 2023 02:09:24 +0000 (21:09 -0500)]
Merge pull request #13834 from FRRouting/mergify/bp/dev/9.0/pr-13763

fix 'exit' bug in config file processing, et al. (backport #13763)

22 months agoMerge pull request #13832 from FRRouting/mergify/bp/dev/9.0/pr-13734
Jafar Al-Gharaibeh [Fri, 23 Jun 2023 02:09:08 +0000 (21:09 -0500)]
Merge pull request #13832 from FRRouting/mergify/bp/dev/9.0/pr-13734

remove mentions of socat (backport #13734)

22 months agotests: add mgmtd config test 13834/head
Christian Hopps [Mon, 12 Jun 2023 04:58:03 +0000 (00:58 -0400)]
tests: add mgmtd config test

Testing early exits/ends from config files loaded with `vtysh -f cfgfile`
as well as `vtysh < cfgfile`, verify the same as non-mgmtd behavior.

Signed-off-by: Christian Hopps <chopps@labn.net>
(cherry picked from commit dac48df52ad6322b505aea7aae62319a726216b5)

22 months agolib: mgmtd: fix/stdize debug message macros
Christian Hopps [Mon, 12 Jun 2023 04:25:07 +0000 (00:25 -0400)]
lib: mgmtd: fix/stdize debug message macros

Signed-off-by: Christian Hopps <chopps@labn.net>
(cherry picked from commit 79d40972fddc2651b499bf2f5780aea97c9f5d07)

22 months agomgmtd: remove unused code
Christian Hopps [Fri, 9 Jun 2023 20:54:13 +0000 (16:54 -0400)]
mgmtd: remove unused code

Signed-off-by: Christian Hopps <chopps@labn.net>
(cherry picked from commit f0fa4c03700e775f7ed7ebf6cfef20d9d5ac7ef9)

22 months agolib: mgmtd: session create and destroy both short-circuit
Christian Hopps [Mon, 12 Jun 2023 02:13:48 +0000 (22:13 -0400)]
lib: mgmtd: session create and destroy both short-circuit

For creation this is the first thing done so short-circuit just means inline
sync response. However, for destroy there could be commands in-flight, these
will be discarded when they match no session, and the state cleaned up
immediately when the message short-circuits.

Signed-off-by: Christian Hopps <chopps@labn.net>
(cherry picked from commit 0fc08fa7381fdba03a0c2e5b745929954172915a)

22 months agolib: mgmtd: avoid recursion with vty_close and add error log
Christian Hopps [Mon, 12 Jun 2023 02:19:54 +0000 (22:19 -0400)]
lib: mgmtd: avoid recursion with vty_close and add error log

Avoid recursion into vty_close() when being notified of a session closure that
happened inside vty_close().

If a vty is closed with outstanding config yet to be commited
issue a warning that it is being lost.

Signed-off-by: Christian Hopps <chopps@labn.net>
(cherry picked from commit 4307fdd07047dc2f7c9daef7a74af6cddf635c34)

22 months agovtysh: stop reading config file if user `exit`s from root level.
Christian Hopps [Sun, 11 Jun 2023 21:53:10 +0000 (17:53 -0400)]
vtysh: stop reading config file if user `exit`s from root level.

This is required to make sure that we properly send the
XFRR_end_configuration tag to the daemons. Previously if the user had an
`exit` at the root level the parser would just drop out of the config
node and so XFRR_end_configuration, even if sent, would be ignored

Signed-off-by: Christian Hopps <chopps@labn.net>
(cherry picked from commit 315e9032e4087494063bbc6f7f52ec8c3d3ce757)

22 months agostaticd: staticd no longer loads config files
Christian Hopps [Sat, 10 Jun 2023 03:15:12 +0000 (23:15 -0400)]
staticd: staticd no longer loads config files

We need to ignore SIGHUP rather than reload config now.

Signed-off-by: Christian Hopps <chopps@labn.net>
(cherry picked from commit f7a2c2ab5ab6a4d70da298ad03cb28fdf9979afc)

22 months agodoc: start of mgmtd developer doc 13833/head
Christian Hopps [Mon, 19 Jun 2023 08:57:48 +0000 (04:57 -0400)]
doc: start of mgmtd developer doc

- docs on how to convert daemon to mgmtd and some diagrams
- and a fix for code-block in cspf.rst

Signed-off-by: Christian Hopps <chopps@labn.net>
(cherry picked from commit a552543640f3558199aebb79cc823d189dfcd083)

22 months agodoc: update doc removing socat req + remove unused tests code 13832/head
Christian Hopps [Thu, 8 Jun 2023 12:37:27 +0000 (08:37 -0400)]
doc: update doc removing socat req + remove unused tests code

Signed-off-by: Christian Hopps <chopps@labn.net>
(cherry picked from commit 17054f373e70b5be08e45f8fd004190f857e7394)

22 months agoMerge pull request #13816 from FRRouting/mergify/bp/dev/9.0/pr-13758
Donatas Abraitis [Wed, 21 Jun 2023 13:47:02 +0000 (16:47 +0300)]
Merge pull request #13816 from FRRouting/mergify/bp/dev/9.0/pr-13758

isisd: Fix read beyond end of stream of ASLA Sub-TLV parsing (backport #13758)

22 months agoisisd: Fix use beyond end of stream of ASLA Sub-TLV parsing 13816/head
Carmine Scarpitta [Sat, 10 Jun 2023 14:08:25 +0000 (16:08 +0200)]
isisd: Fix use beyond end of stream of ASLA Sub-TLV parsing

Fixes a crash associated with attempting to read beyond the end of the
stream when parsing ASLA Sub-TLV.

```
Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
    subtlv_len=13 '\r') at isisd/isis_tlvs.c:1473
    at isisd/isis_tlvs.c:3264
    context=<optimized out>, mtid=<optimized out>) at isisd/isis_tlvs.c:6078
    indent=4) at isisd/isis_tlvs.c:6142
    avail_len=<optimized out>, context=<optimized out>) at isisd/isis_tlvs.c:7032
    at isisd/isis_tlvs.c:7054
(gdb)
```

Caught by fuzzer.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
(cherry picked from commit 2a9e0824a7bd85d5436615065f0311910106c3cf)

22 months agoMerge pull request #13786 from FRRouting/mergify/bp/dev/9.0/pr-13612
Donald Sharp [Tue, 13 Jun 2023 20:03:28 +0000 (16:03 -0400)]
Merge pull request #13786 from FRRouting/mergify/bp/dev/9.0/pr-13612

ospfd: fix interface param type update (backport #13612)

22 months agoMerge pull request #13791 from FRRouting/mergify/bp/dev/9.0/pr-13589
Donald Sharp [Tue, 13 Jun 2023 20:03:04 +0000 (16:03 -0400)]
Merge pull request #13791 from FRRouting/mergify/bp/dev/9.0/pr-13589

pbrd, zebra: fix zapi and netlink rule encoding (backport #13589)

22 months agopbrd, zebra: fix zapi and netlink rule encoding 13791/head
Mark Stapp [Tue, 23 May 2023 19:31:31 +0000 (15:31 -0400)]
pbrd, zebra: fix zapi and netlink rule encoding

In pbrd, don't encode a rule without a table. There are cases
where the zapi encoding was incorrect because the 4-octet
table id was missing. In zebra, mask off the ECN bits in the
TOS byte when encoding an iprule to match netlink's
expectation.

Signed-off-by: Mark Stapp <mjs@labn.net>
(cherry picked from commit 4112baec9f7ec235c66e2c5992ba2288ca1557e7)

22 months agoospfd: fix interface param type update 13786/head
Chirag Shah [Fri, 26 May 2023 20:43:50 +0000 (13:43 -0700)]
ospfd: fix interface param type update

interface link update event needs
to be handle properly in ospf interface
cache.

Example:
When vrf (interface) is created its default type
would be set to BROADCAST because ifp->status
is not set to VRF.
Subsequent link event sets ifp->status to vrf,
ospf interface update need to compare current type
to new default type which would be VRF (OSPF_IFTYPE_LOOPBACK).
Since ospf type param was created in first add event,
ifp vrf link event didn't update ospf type param which
leads to treat vrf as non loopback interface.

Ticket:#3459451
Testing Done:

Running config suppose to bypass rendering default
network broadcast for loopback/vrf types.

Before fix:

vrf vrf1
 vni 4001
exit-vrf
!
interface vrf1
 ip ospf network broadcast
exit

After fix: (interface vrf1 is not displayed).

vrf vrf1
 vni 4001
exit-vrf

Signed-off-by: Chirag Shah <chirag@nvidia.com>
(cherry picked from commit 0d005b2d5c294d9d0a8db9d8beca83b97e0fd8ff)

22 months agoMerge pull request #13760 from FRRouting/mergify/bp/dev/9.0/pr-13675
Donatas Abraitis [Sun, 11 Jun 2023 18:40:02 +0000 (21:40 +0300)]
Merge pull request #13760 from FRRouting/mergify/bp/dev/9.0/pr-13675

bfd:fix version bits check (backport #13675)

22 months agobfdd: fix version bits check. 13760/head
zmw12306 [Sat, 3 Jun 2023 19:08:34 +0000 (15:08 -0400)]
bfdd: fix version bits check.

The version of bfd pkt is represented by 3 bits in B[0].
Signed-off-by: zmw12306 <zmw12306@gmail.com>
(cherry picked from commit 3f658e8b1cfc82e1644cc36fcbc1554c70f558d0)

22 months agoMerge pull request #13744 from FRRouting/mergify/bp/dev/9.0/pr-13726
Donatas Abraitis [Fri, 9 Jun 2023 12:37:42 +0000 (15:37 +0300)]
Merge pull request #13744 from FRRouting/mergify/bp/dev/9.0/pr-13726

tests: fixing pim6 topotest bugs (backport #13726)

22 months agoMerge pull request #13746 from FRRouting/mergify/bp/dev/9.0/pr-13739
Donatas Abraitis [Fri, 9 Jun 2023 12:37:05 +0000 (15:37 +0300)]
Merge pull request #13746 from FRRouting/mergify/bp/dev/9.0/pr-13739

zebra: Prevent crash because nl is NULL on shutdown (backport #13739)

22 months agoMerge pull request #13741 from FRRouting/mergify/bp/dev/9.0/pr-13364
Donatas Abraitis [Fri, 9 Jun 2023 07:15:15 +0000 (10:15 +0300)]
Merge pull request #13741 from FRRouting/mergify/bp/dev/9.0/pr-13364

bfd: fix missing Authentication in control pkt (backport #13364)

22 months agoMerge pull request #13736 from FRRouting/mergify/bp/dev/9.0/pr-13645
Jafar Al-Gharaibeh [Fri, 9 Jun 2023 04:47:51 +0000 (23:47 -0500)]
Merge pull request #13736 from FRRouting/mergify/bp/dev/9.0/pr-13645

bfdd: remove redundant nb destroy callbacks (backport #13645)

22 months agozebra: Prevent crash because nl is NULL on shutdown 13746/head
Donald Sharp [Thu, 8 Jun 2023 16:03:49 +0000 (12:03 -0400)]
zebra: Prevent crash because nl is NULL on shutdown

When shutting down the main pthread was first closing
the sockets associated with the dplane pthread and
then telling it to shutdown the pthread at a later point
in time.  This caused the dplane to crash because the nl
data has been freed already.  Change the shutdown order
to stop the dplane pthread *and* then close the sockets.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
(cherry picked from commit 977d7e24fff4e0eef4426bbcc32e491a60815b89)

22 months agotests: convert old pim test to more cleanly use pytest fixture 13744/head
Christian Hopps [Thu, 8 Jun 2023 08:12:26 +0000 (04:12 -0400)]
tests: convert old pim test to more cleanly use pytest fixture

This is a good way to run a per-test background helper process. Here the
helper object is created before the test function requesting it (through param
name match), and then cleaned up after the test function exits (pass or failed).

A context manager is used to further guarantee the cleanup is done.

Signed-off-by: Christian Hopps <chopps@labn.net>
(cherry picked from commit b28bc2561e7231e410e304f7ec23f9d795e3e479)

22 months agotests: fixing pim6 topotest bugs
Christian Hopps [Thu, 8 Jun 2023 06:42:32 +0000 (02:42 -0400)]
tests: fixing pim6 topotest bugs

- Remove use of bespoke socat
- Use ipv6 support in mcast-tester.py
- do not run processes in the background behind munet/micronet's
  back with `&` (ever) -- use popen or the helper class

Signed-off-by: Christian Hopps <chopps@labn.net>
(cherry picked from commit efedb1897616c6de76aaaff7a51f443dbbe93e31)

22 months agotests: mcast-tester.py handles IPv6
Christian Hopps [Thu, 8 Jun 2023 06:11:50 +0000 (02:11 -0400)]
tests: mcast-tester.py handles IPv6

Signed-off-by: Christian Hopps <chopps@labn.net>
(cherry picked from commit 71231d304f257aed9a086fcf6c2146052574b2f4)

22 months agobfd: fix missing Authentication in control pkt 13741/head
zmw12306 [Tue, 25 Apr 2023 17:48:18 +0000 (13:48 -0400)]
bfd: fix missing Authentication in control pkt

According RFC 5880, add a simpilfed version handling authentication
Signed-off-by: zmw12306 <zmw12306@gmail.com>
(cherry picked from commit 98707b04d425dfcc24670704d268a733bbf0bc3f)

22 months agobfdd: remove redundant nb destroy callbacks 13736/head
Igor Ryzhov [Wed, 31 May 2023 12:28:08 +0000 (15:28 +0300)]
bfdd: remove redundant nb destroy callbacks

Fixes warning logs:
```
2023/05/29 20:11:50 BFD: [ZKB8W-3S2Q4][EC 100663330] unneeded 'destroy' callback for '/frr-bfdd:bfdd/bfd/profile/minimum-ttl'
2023/05/29 20:11:50 BFD: [ZKB8W-3S2Q4][EC 100663330] unneeded 'destroy' callback for '/frr-bfdd:bfdd/bfd/sessions/multi-hop/minimum-ttl'
```

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
(cherry picked from commit f7884aedf7a1249e3aae71b6a66c9a0f0915c4ef)

22 months agoMerge pull request #13723 from FRRouting/mergify/bp/dev/9.0/pr-13624
Donatas Abraitis [Thu, 8 Jun 2023 05:35:22 +0000 (08:35 +0300)]
Merge pull request #13723 from FRRouting/mergify/bp/dev/9.0/pr-13624

bgpd: Free temp memory (backport #13624)

22 months agobgpd: Free temp memory 13723/head
Keelan10 [Mon, 29 May 2023 07:42:40 +0000 (11:42 +0400)]
bgpd: Free temp memory

This commit addresses a memory leak issue in the BGP Flowspec NLRI parsing function.

Previously when processing NLRI, dynamically allocated memory to `temp` was not being freed, leading to a memory leak.

The commit introduces the necessary code (XFREE) to properly free the temp memory after processing Flowspec NLRI.

The ASan leak log for reference:

```
./bgp_flowspec.test_bgp_flowspec_topo/r1.bgpd.asan.687689:Direct leak of 56 byte(s) in 2 object(s) allocated from:
./bgp_flowspec.test_bgp_flowspec_topo/r1.bgpd.asan.687689-    #0 0x7fc9872b5037 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
./bgp_flowspec.test_bgp_flowspec_topo/r1.bgpd.asan.687689-    #1 0x7fc986e5b1ee in qcalloc lib/memory.c:105
./bgp_flowspec.test_bgp_flowspec_topo/r1.bgpd.asan.687689-    #2 0x560421351bfe in bgp_nlri_parse_flowspec bgpd/bgp_flowspec.c:155
./bgp_flowspec.test_bgp_flowspec_topo/r1.bgpd.asan.687689-    #3 0x56042107d01c in bgp_nlri_parse bgpd/bgp_packet.c:350
./bgp_flowspec.test_bgp_flowspec_topo/r1.bgpd.asan.687689-    #4 0x560421086cf3 in bgp_update_receive bgpd/bgp_packet.c:2023
./bgp_flowspec.test_bgp_flowspec_topo/r1.bgpd.asan.687689-    #5 0x56042108deed in bgp_process_packet bgpd/bgp_packet.c:2933
./bgp_flowspec.test_bgp_flowspec_topo/r1.bgpd.asan.687689-    #6 0x7fc986f35bf7 in event_call lib/event.c:1995
./bgp_flowspec.test_bgp_flowspec_topo/r1.bgpd.asan.687689-    #7 0x7fc986e1e99d in frr_run lib/libfrr.c:1185
./bgp_flowspec.test_bgp_flowspec_topo/r1.bgpd.asan.687689-    #8 0x560420f3f59d in main bgpd/bgp_main.c:505
./bgp_flowspec.test_bgp_flowspec_topo/r1.bgpd.asan.687689-    #9 0x7fc986805d09 in __libc_start_main ../csu/libc-start.c:308
```

Signed-off-by: Keelan Cannoo <keelan.cannoo@icloud.com>
(cherry picked from commit 269a2d3dae0016a0c9688d18d0cce6dfd21b8ae3)

22 months agoMerge pull request #13712 from FRRouting/mergify/bp/dev/9.0/pr-13693
Donald Sharp [Wed, 7 Jun 2023 12:07:40 +0000 (08:07 -0400)]
Merge pull request #13712 from FRRouting/mergify/bp/dev/9.0/pr-13693

tools: fix list value remove in frr-reload (backport #13693)

22 months agoMerge pull request #13711 from FRRouting/mergify/bp/dev/9.0/pr-13706
Donatas Abraitis [Wed, 7 Jun 2023 10:23:14 +0000 (13:23 +0300)]
Merge pull request #13711 from FRRouting/mergify/bp/dev/9.0/pr-13706

lib: close config files after reading (coverity) (backport #13706)

22 months agoMerge pull request #13710 from FRRouting/mergify/bp/dev/9.0/pr-13707
Donatas Abraitis [Wed, 7 Jun 2023 09:49:27 +0000 (12:49 +0300)]
Merge pull request #13710 from FRRouting/mergify/bp/dev/9.0/pr-13707

mgmtd: assert an assertion for coverity (backport #13707)

22 months agotools: fix list value remove in frr-reload 13712/head
Chirag Shah [Tue, 6 Jun 2023 04:48:12 +0000 (21:48 -0700)]
tools: fix list value remove in frr-reload

There might be a time element(s) from
temporary list are removed more than once
which leads to valueError in certain python3
version.

commit-id 1543f58b5 did not handle valueError
properly. This caused regression where
prefix-list config leads to delete followed
by add.

The new fix should just pass the exception as
value removal from list_to_add or list_to_del
is best effort.
This allows prefix-list config has no change
then removes the lines from lines_to_del and
lines_to_add properly.

Ticket:#3490252
Testing:

Configure prefix-list in frr.conf and perform
multiple frr-reload. After first reload operatoin
subsequent ones should not result in delete followed
by add of the prefix-list but rather no-op operation.

(Pdb) lines_to_add
[(('ip prefix-list FOO permit 10.2.1.0/24',), None)]
(Pdb) lines_to_del
[(('ip prefix-list FOO seq 5 permit 10.2.1.0/24',), None),
 (('ip prefix-list FOO seq 10 permit 10.2.1.0/24',), None)]
(Pdb) lines_to_del_to_del
[(('ip prefix-list FOO seq 5 permit 10.2.1.0/24',), None),
 (('ip prefix-list FOO seq 10 permit 10.2.1.0/24',), None)]
(Pdb) lines_to_add_to_del
[(('ip prefix-list FOO permit 10.2.1.0/24',), None),
 (('ip prefix-list FOO permit 10.2.1.0/24',), None)]
(Pdb) c
> /usr/lib/frr/frr-reload.py(1562)ignore_delete_re_add_lines()
-> return (lines_to_add, lines_to_del)
(Pdb) lines_to_add
[]
(Pdb) lines_to_del
[]

Signed-off-by: Chirag Shah <chirag@nvidia.com>
(cherry picked from commit 9845c09d61a7e509bfae369648cb5f9893455ac4)

22 months agolib: close config files after reading (coverity) 13711/head
Christian Hopps [Tue, 6 Jun 2023 18:27:04 +0000 (14:27 -0400)]
lib: close config files after reading (coverity)

fixes coverity CID# 1564375

Signed-off-by: Christian Hopps <chopps@labn.net>
(cherry picked from commit f5626596ee5e052fc1116536704cd9c9ba5d7552)

22 months agomgmtd: assert an assertion for coverity 13710/head
Christian Hopps [Tue, 6 Jun 2023 19:12:58 +0000 (15:12 -0400)]
mgmtd: assert an assertion for coverity

I believe coverity can't tell the length of the return value from strftime based
on the format string (like we can), so it allows `n` to be larger than it could
be which then allows `sz - n` to be negative which is size_t positive and very
large so it thinks an overrun is possible.

CID#1563211

Signed-off-by: Christian Hopps <chopps@labn.net>
(cherry picked from commit 565139a6d5c2541e7b740a4a972dd7c18a87a984)

22 months agoMerge pull request #13701 from opensourcerouting/fix/update_show_ip_bgp_summary_doc base_9.0
Donald Sharp [Tue, 6 Jun 2023 18:55:52 +0000 (14:55 -0400)]
Merge pull request #13701 from opensourcerouting/fix/update_show_ip_bgp_summary_doc

doc: Document RFC8212 under `Displaying BGP Information` section

22 months agoMerge pull request #13687 from donaldsharp/eigrp_fakeout
Jafar Al-Gharaibeh [Tue, 6 Jun 2023 18:53:27 +0000 (13:53 -0500)]
Merge pull request #13687 from donaldsharp/eigrp_fakeout

tests: Babel tests do not need to log to eigrp