]> git.puffer.fish Git - mirror/frr.git/log
mirror/frr.git
9 months agopimd: fix crash on non-existent interface 16433/head
Louis Scalbert [Fri, 28 Jun 2024 11:22:36 +0000 (13:22 +0200)]
pimd: fix crash on non-existent interface

Fix the following crash when pim options are (un)configured on an
non-existent interface.

> r1(config)# int fgljdsf
> r1(config-if)# no ip pim unicast-bsm
> vtysh: error reading from pimd: Connection reset by peer (104)Warning: closing connection to pimd because of an I/O error!

> #0  raise (sig=<optimized out>) at ../sysdeps/unix/sysv/linux/raise.c:50
> #1  0x00007f70c8f32249 in core_handler (signo=11, siginfo=0x7fffff88e4f0, context=0x7fffff88e3c0) at lib/sigevent.c:258
> #2  <signal handler called>
> #3  0x0000556cfdd9b16d in lib_interface_pim_address_family_unicast_bsm_modify (args=0x7fffff88f130) at pimd/pim_nb_config.c:1910
> #4  0x00007f70c8efdcb5 in nb_callback_modify (context=0x556d00032b60, nb_node=0x556cffeeb9b0, event=NB_EV_APPLY, dnode=0x556d00031670, resource=0x556d00032b48, errmsg=0x7fffff88f710 "", errmsg_len=8192)
>     at lib/northbound.c:1538
> #5  0x00007f70c8efe949 in nb_callback_configuration (context=0x556d00032b60, event=NB_EV_APPLY, change=0x556d00032b10, errmsg=0x7fffff88f710 "", errmsg_len=8192) at lib/northbound.c:1888
> #6  0x00007f70c8efee82 in nb_transaction_process (event=NB_EV_APPLY, transaction=0x556d00032b60, errmsg=0x7fffff88f710 "", errmsg_len=8192) at lib/northbound.c:2016
> #7  0x00007f70c8efd658 in nb_candidate_commit_apply (transaction=0x556d00032b60, save_transaction=true, transaction_id=0x0, errmsg=0x7fffff88f710 "", errmsg_len=8192) at lib/northbound.c:1356
> #8  0x00007f70c8efd78e in nb_candidate_commit (context=..., candidate=0x556cffeb0e80, save_transaction=true, comment=0x0, transaction_id=0x0, errmsg=0x7fffff88f710 "", errmsg_len=8192) at lib/northbound.c:1389
> #9  0x00007f70c8f03e58 in nb_cli_classic_commit (vty=0x556d00025a80) at lib/northbound_cli.c:51
> #10 0x00007f70c8f043f8 in nb_cli_apply_changes_internal (vty=0x556d00025a80,
>     xpath_base=0x7fffff893bb0 "/frr-interface:lib/interface[name='fgljdsf']/frr-pim:pim/address-family[address-family='frr-routing:ipv4']", clear_pending=false) at lib/northbound_cli.c:178
> #11 0x00007f70c8f0475d in nb_cli_apply_changes (vty=0x556d00025a80, xpath_base_fmt=0x556cfdde9fe0 "./frr-pim:pim/address-family[address-family='%s']") at lib/northbound_cli.c:234
> #12 0x0000556cfdd8298f in pim_process_no_unicast_bsm_cmd (vty=0x556d00025a80) at pimd/pim_cmd_common.c:3493
> #13 0x0000556cfddcf782 in no_ip_pim_ucast_bsm (self=0x556cfde40b20 <no_ip_pim_ucast_bsm_cmd>, vty=0x556d00025a80, argc=4, argv=0x556d00031500) at pimd/pim_cmd.c:4950
> #14 0x00007f70c8e942f0 in cmd_execute_command_real (vline=0x556d00032070, vty=0x556d00025a80, cmd=0x0, up_level=0) at lib/command.c:1002
> #15 0x00007f70c8e94451 in cmd_execute_command (vline=0x556d00032070, vty=0x556d00025a80, cmd=0x0, vtysh=0) at lib/command.c:1061
> #16 0x00007f70c8e9499f in cmd_execute (vty=0x556d00025a80, cmd=0x556d00030320 "no ip pim unicast-bsm", matched=0x0, vtysh=0) at lib/command.c:1227
> #17 0x00007f70c8f51e44 in vty_command (vty=0x556d00025a80, buf=0x556d00030320 "no ip pim unicast-bsm") at lib/vty.c:616
> #18 0x00007f70c8f53bdd in vty_execute (vty=0x556d00025a80) at lib/vty.c:1379
> #19 0x00007f70c8f55d59 in vtysh_read (thread=0x7fffff896600) at lib/vty.c:2374
> #20 0x00007f70c8f4b209 in event_call (thread=0x7fffff896600) at lib/event.c:2011
> #21 0x00007f70c8ed109e in frr_run (master=0x556cffdb4ea0) at lib/libfrr.c:1217
> #22 0x0000556cfdddec12 in main (argc=2, argv=0x7fffff896828, envp=0x7fffff896840) at pimd/pim_main.c:165
> (gdb) f 3
> #3  0x0000556cfdd9b16d in lib_interface_pim_address_family_unicast_bsm_modify (args=0x7fffff88f130) at pimd/pim_nb_config.c:1910
> 1910 pim_ifp->ucast_bsm_accept =
> (gdb) list
> 1905 case NB_EV_ABORT:
> 1906 break;
> 1907 case NB_EV_APPLY:
> 1908 ifp = nb_running_get_entry(args->dnode, NULL, true);
> 1909 pim_ifp = ifp->info;
> 1910 pim_ifp->ucast_bsm_accept =
> 1911 yang_dnode_get_bool(args->dnode, NULL);
> 1912
> 1913 break;
> 1914 }
> (gdb) p pim_ifp
> $1 = (struct pim_interface *) 0x0

Fixes: 3bb513c399 ("lib: adapt to version 2 of libyang")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
(cherry picked from commit 6952bea5cdd38057bf8c0a5e9c0fbe916dc73953)

9 months agoMerge pull request #16404 from FRRouting/mergify/bp/dev/10.1/pr-16368
Donatas Abraitis [Wed, 17 Jul 2024 05:08:00 +0000 (22:08 -0700)]
Merge pull request #16404 from FRRouting/mergify/bp/dev/10.1/pr-16368

bgpd: backpressure - fix to properly remove dest for bgp under deletion (backport #16368)

9 months agoMerge pull request #16399 from FRRouting/mergify/bp/dev/10.1/pr-16374
Jafar Al-Gharaibeh [Wed, 17 Jul 2024 00:07:15 +0000 (20:07 -0400)]
Merge pull request #16399 from FRRouting/mergify/bp/dev/10.1/pr-16374

bgpd: Mark VRF instance as auto created if import vrf is configured for this instance (backport #16374)

9 months agoMerge pull request #16379 from FRRouting/mergify/bp/dev/10.1/pr-16350
Donatas Abraitis [Tue, 16 Jul 2024 23:00:05 +0000 (16:00 -0700)]
Merge pull request #16379 from FRRouting/mergify/bp/dev/10.1/pr-16350

zebra: Fix to avoid two Vrfs with same table ids (backport #16350)

9 months agoMerge pull request #16395 from FRRouting/mergify/bp/dev/10.1/pr-16365
Donatas Abraitis [Tue, 16 Jul 2024 22:51:01 +0000 (15:51 -0700)]
Merge pull request #16395 from FRRouting/mergify/bp/dev/10.1/pr-16365

isisd: fix crash when calculating the neighbor spanning tree based on the fragmented LSP (backport #16365)

9 months agobgpd: backpressure - Improve debuggability 16404/head
Rajasekar Raja [Thu, 11 Jul 2024 03:17:14 +0000 (20:17 -0700)]
bgpd: backpressure - Improve debuggability

Improve debuggability in backpressure code.

Ticket :#3980988

Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>
(cherry picked from commit 186db96c06e4f44b4450fcba88f0fa680ee0b92d)

9 months agobgpd: backpressure - fix to properly remove dest for bgp under deletion
Rajasekar Raja [Wed, 10 Jul 2024 23:46:29 +0000 (16:46 -0700)]
bgpd: backpressure - fix to properly remove dest for bgp under deletion

In case of imported routes (L3vni/vrf leaks), when a bgp instance is
being deleted, the peer->bgp comparision with the incoming bgp to remove
the dest from the pending fifo is wrong. This can lead to the fifo
having stale entries resulting in crash.

Two changes are done here.
 - Instead of pop/push items in list if the struct bgp doesnt match,
   simply iterate the list and remove the expected ones.

 - Corrected the way bgp is fetched from dest rather than relying on
   path_info->peer so that it works for all kinds of routes.

Ticket :#3980988

Signed-off-by: Chirag Shah <chirag @nvidia.com>
Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>
(cherry picked from commit 4395fcd8e120958a91d3a11f918e9071b1cb5619)

9 months agobgpd: Skip empty (auto created) VRF instances when deleting a default BGP instance 16399/head
Donatas Abraitis [Mon, 15 Jul 2024 13:20:31 +0000 (16:20 +0300)]
bgpd: Skip empty (auto created) VRF instances when deleting a default BGP instance

Auto created VRF instances does not have any config, so it's not relevant
depending on them.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
(cherry picked from commit bfedb38110e8d3e5471718a0f9abe8836ffc7143)

9 months agotests: Check if VRF instance has a different ASN than a default VRF
Donatas Abraitis [Sat, 13 Jul 2024 10:14:33 +0000 (13:14 +0300)]
tests: Check if VRF instance has a different ASN than a default VRF

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
(cherry picked from commit c6c0403c61c157a9507781c332e152a2b220da52)

9 months agobgpd: Skip automatically created BGP instances for show CMDs
Donatas Abraitis [Sat, 13 Jul 2024 20:19:57 +0000 (23:19 +0300)]
bgpd: Skip automatically created BGP instances for show CMDs

When using e.g. `adverise-all-vni`, and/or `import vrf ...`, the VRF instance
is created with a default's VRF ASN and tagged as AUTO_VRF. We MUST skip them
here also.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
(cherry picked from commit 03c086866bdee9daf55420b88593345b9eb6be15)

9 months agotests: Check if multiple VRF instances can have different ASNs
Donatas Abraitis [Sat, 13 Jul 2024 09:43:31 +0000 (12:43 +0300)]
tests: Check if multiple VRF instances can have different ASNs

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
(cherry picked from commit 7540364e58b08da7442927c1a9ffbd535d94fc46)

9 months agobgpd: Mark VRF instance as auto created if import vrf is configured for this instance
Donatas Abraitis [Fri, 12 Jul 2024 14:09:16 +0000 (17:09 +0300)]
bgpd: Mark VRF instance as auto created if import vrf is configured for this instance

If we create a new BGP instance (in this case VRF instance), it MUST be marked
as auto created, to avoid bgpd changing VRF instance's ASN to the default VRF's.

That's because of the ordering when FRR reload is happening.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
(cherry picked from commit 80a4f87c9a38d5e893f7e24da11cc0c885db682e)

9 months agoisisd: fix crash when calculating the neighbor spanning tree based on the fragmented LSP 16395/head
zhou-run [Thu, 11 Jul 2024 03:35:34 +0000 (11:35 +0800)]
isisd: fix crash when calculating the neighbor spanning tree based on the fragmented LSP

1. When the root IS regenerates an LSP, it calls lsp_build() -> lsp_clear_data() to free the TLV memory of the first fragment and all other fragments. If the number of fragments in the regenerated LSP decreases or if no fragmentation is needed, the extra LSP fragments are not immediately deleted. Instead, lsp_seqno_update() -> lsp_purge() is called to set the remaining time to zero and start aging, while also notifying other IS nodes to age these fragments. lsp_purge() usually does not reset lsp->hdr.seqno to zero because the LSP might recover during the aging process.
2. When other IS nodes receive an LSP, they always call process_lsp() -> isis_unpack_tlvs() to allocate TLV memory for the LSP. This does not differentiate whether the received LSP has a remaining lifetime of zero. Therefore, it is rare for an LSP of a non-root IS to have empty TLVs. Of course, if an LSP with a remaining time of zero and already corrupted is received, lsp_update() -> lsp_purge() will be called to free the TLV memory of the LSP, but this scenario is rare.
3. In LFA calculations, neighbors of the root IS are traversed, and each neighbor is taken as a new root to compute the neighbor SPT. During this process, the old root IS will serve as a neighbor of the new root IS, triggering a call to isis_spf_process_lsp() to parse the LSP of the old root IS and obtain its IP vertices and neighboring IS vertices. However, isis_spf_process_lsp() only checks whether the TLVs in the first fragment of the LSP exist, and does not check the TLVs in the fragmented LSP. If the TLV memory of the fragmented LSP of the old root IS has been freed, it can lead to a null pointer access, causing the current crash.

Additionally, for the base SPT, there are only two places where the LSP of the root IS is parsed:
1. When obtaining the UP neighbors of the root IS via spf_adj_list_parse_lsp().
2. When preloading the IP vertices of the root IS via isis_lsp_iterate_ip_reach().
Both of these checks ensure that frag->tlvs is not null, and they do not subsequently call isis_spf_process_lsp() to parse the root IS's LSP. It is very rare for non-root IS LSPs to have empty TLVs unless they are corrupted LSPs awaiting deletion. If it happens, a crash will occur.

The backtrace is as follows:
(gdb) bt
#0  0x00007f3097281fe1 in raise () from /lib/x86_64-linux-gnu/libpthread.so.0
#1  0x00007f30973a2972 in core_handler (signo=11, siginfo=0x7ffce66c2870, context=0x7ffce66c2740) at ../lib/sigevent.c:261
#2  <signal handler called>
#3  0x000055dfa805512b in isis_spf_process_lsp (spftree=0x55dfa950eee0, lsp=0x55dfa94cb590, cost=10, depth=1, root_sysid=0x55dfa950ef6c "", parent=0x55dfa952fca0)
    at ../isisd/isis_spf.c:898
#4  0x000055dfa805743b in isis_spf_loop (spftree=0x55dfa950eee0, root_sysid=0x55dfa950ef6c "") at ../isisd/isis_spf.c:1688
#5  0x000055dfa805784f in isis_run_spf (spftree=0x55dfa950eee0) at ../isisd/isis_spf.c:1808
#6  0x000055dfa8037ff5 in isis_spf_run_neighbors (spftree=0x55dfa9474440) at ../isisd/isis_lfa.c:1259
#7  0x000055dfa803ac17 in isis_spf_run_lfa (area=0x55dfa9477510, spftree=0x55dfa9474440) at ../isisd/isis_lfa.c:2300
#8  0x000055dfa8057964 in isis_run_spf_with_protection (area=0x55dfa9477510, spftree=0x55dfa9474440) at ../isisd/isis_spf.c:1827
#9  0x000055dfa8057c15 in isis_run_spf_cb (thread=0x7ffce66c38e0) at ../isisd/isis_spf.c:1889
#10 0x00007f30973bbf04 in thread_call (thread=0x7ffce66c38e0) at ../lib/thread.c:1990
#11 0x00007f309735497b in frr_run (master=0x55dfa91733c0) at ../lib/libfrr.c:1198
#12 0x000055dfa8029d5d in main (argc=5, argv=0x7ffce66c3b08, envp=0x7ffce66c3b38) at ../isisd/isis_main.c:273
(gdb) f 3
#3  0x000055dfa805512b in isis_spf_process_lsp (spftree=0x55dfa950eee0, lsp=0x55dfa94cb590, cost=10, depth=1, root_sysid=0x55dfa950ef6c "", parent=0x55dfa952fca0)
    at ../isisd/isis_spf.c:898
898     ../isisd/isis_spf.c: No such file or directory.
(gdb) p te_neighs
$1 = (struct isis_item_list *) 0x120
(gdb) p lsp->tlvs
$2 = (struct isis_tlvs *) 0x0
(gdb) p lsp->hdr
$3 = {pdu_len = 27, rem_lifetime = 0, lsp_id = "\000\000\000\000\000\001\000\001", seqno = 4, checksum = 59918, lsp_bits = 1 '\001'}

The backtrace provided above pertains to version 8.5.4, but it seems that the same issue exists in the code of the master branch as well.

I have reviewed the process for calculating the SPT based on the LSP, and isis_spf_process_lsp() is the only function that does not check whether the TLVs in the fragments are empty. Therefore, I believe that modifying this function alone should be sufficient. If the TLVs of the current fragment are already empty, we do not need to continue processing subsequent fragments. This is consistent with the behavior where we do not process fragments if the TLVs of the first fragment are empty.
Of course, one could argue that lsp_purge() should still retain the TLV memory, freeing it and then reallocating it if needed. However, this is a debatable point because in some scenarios, it is permissible for the LSP to have empty TLVs. For example, after receiving an SNP (Sequence Number PDU) message, an empty LSP (with lsp->hdr.seqno = 0) might be created by calling lsp_new. If the corresponding LSP message is discarded due to domain or area authentication failure, the TLV memory wouldn't be allocated.

Test scenario:
In an LFA network, importing a sufficient number of static routes to cause LSP fragmentation, and then rolling back the imported static routes so that the LSP is no longer fragmented, can easily result in this issue.

Signed-off-by: zhou-run <zhou.run@h3c.com>
(cherry picked from commit e905177a8c9d67713682d46934c7a87a0913c250)

9 months agoMerge pull request #16387 from FRRouting/mergify/bp/dev/10.1/pr-16373
Mark Stapp [Tue, 16 Jul 2024 11:55:28 +0000 (07:55 -0400)]
Merge pull request #16387 from FRRouting/mergify/bp/dev/10.1/pr-16373

staticd: fix missing static routes (backport #16373)

9 months agozebra: fix missing static routes 16387/head
anlan_cs [Fri, 12 Jul 2024 09:03:03 +0000 (17:03 +0800)]
zebra: fix missing static routes

Use `vtysh` with this input file:
```
ip route A nh1
ip route A nh2
ip route B nh1
ip route B nh2
```

When running "ip route B" with "nh1" and "nh2", the procedure maybe is:
1) Create the two nexthops: "nh1" and "nh2".
2) Register "nh1" with `static_zebra_nht_register()`, then the states of both
   "nh1" and "nht2" are set to "STATIC_SENT_TO_ZEBRA".
3) Register "nh2" with `static_zebra_nht_register()`, then only the routes with
   nexthop of "STATIC_START" will be sent to zebra.

So, send the routes with the nexthop of "STATIC_SENT_TO_ZEBRA" to zebra.

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

9 months agoMerge pull request #16378 from FRRouting/mergify/bp/dev/10.1/pr-16363
Jafar Al-Gharaibeh [Mon, 15 Jul 2024 18:43:21 +0000 (14:43 -0400)]
Merge pull request #16378 from FRRouting/mergify/bp/dev/10.1/pr-16363

tests: tweak timers to avoid frequent failures on slow CI hardware (backport #16363)

9 months agozebra: Fix to avoid two Vrfs with same table ids 16379/head
Rajasekar Raja [Fri, 5 Jul 2024 23:02:12 +0000 (16:02 -0700)]
zebra: Fix to avoid two Vrfs with same table ids

During internal testing, when the following sequence is followed, two
non default vrfs end up pointing to the same table-id

 - Initially vrf201 has table id 1002
 - ip link add dev vrf202 type vrf table 1002
 - ip link set dev vrf202 up
 - ip link set dev <intrerface> master vrf202

This will ideally lead to zebra exit since this is a misconfiguration as
expected.

However if we perform a restart frr.service at this point, we end up
having two vrfs pointing to same table-id and bad things can happen.
This is because in the interface_vrf_change, we incorrectly check for
vrf_lookup_by_id() to evaluate if there is a misconfig. This works well
for a non restart case but not for the startup case.

root@mlx-3700-20:mgmt:/var/log/frr# sudo vtysh -c "sh vrf"
vrf mgmt id 37 table 1001
vrf vrf201 id 46 table 1002
vrf vrf202 id 59 table 1002 >>>>

Fix: in all cases of misconfiguration, exit zebra as expected.

Ticket :#3970414

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

9 months agotests: tweak timers to avoid frequent failures on slow CI hardware 16378/head
Jafar Al-Gharaibeh [Wed, 10 Jul 2024 19:18:51 +0000 (14:18 -0500)]
tests: tweak timers to avoid frequent failures on slow CI hardware

Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
(cherry picked from commit ad7a1f9487edc75fbfaf932e929a008c8bcbc4f9)

9 months agoMerge pull request #16335 from FRRouting/mergify/bp/dev/10.1/pr-16226
Donald Sharp [Wed, 3 Jul 2024 12:41:01 +0000 (08:41 -0400)]
Merge pull request #16335 from FRRouting/mergify/bp/dev/10.1/pr-16226

ldpd: fix wrong gtsm count (backport #16226)

9 months agoMerge pull request #16328 from FRRouting/mergify/bp/dev/10.1/pr-16303
Jafar Al-Gharaibeh [Tue, 2 Jul 2024 20:55:12 +0000 (16:55 -0400)]
Merge pull request #16328 from FRRouting/mergify/bp/dev/10.1/pr-16303

isisd: fix crash when obtaining the next hop to calculate LFA on LAN links (backport #16303)

9 months agoldpd: fix wrong gtsm count 16335/head
anlan_cs [Sat, 15 Jun 2024 12:34:20 +0000 (20:34 +0800)]
ldpd: fix wrong gtsm count

In linux networking stack, the received mpls packets will be processed
by the host *twice*, one as mpls packet, the other as ip packet, so
its ttl decreased 1.

So, we need release the `IP_MINTTL` value if gtsm is enabled, it is for the
mpls packets of neighbor session caused by the command:
`label local advertise explicit-null`.

This change makes the gtsm mechanism a bit deviation.

Fix PR #8313

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

9 months agoisisd: fix crash when obtaining the next hop to calculate LFA on LAN links 16328/head
zhou-run [Thu, 27 Jun 2024 03:51:02 +0000 (11:51 +0800)]
isisd: fix crash when obtaining the next hop to calculate LFA on LAN links

When a neighbor connection is disconnected, it may trigger LSP re-generation as a timer task, but this process may be delayed. As a result, the list of neighbors in area->adjacency_list may be inconsistent with the neighbors in lsp->tlvs->oldstyle_reach/extended_reach. For example, the area->adjacency_list may lack certain neighbors even though they are present in the LSP. When computing SPF, the call to isis_spf_build_adj_list() generates the spftree->sadj_list, which reflects the real neighbors in the area->adjacency_list. However, in the case of LAN links, spftree->sadj_list may include additional pseudo neighbors.
The pre-loading of tents through the call to isis_spf_preload_tent involves two steps:
1. isis_spf_process_lsp() is called to generate real neighbor vertices based on the root LSP and pseudo LSP.
2. isis_spf_add_local() is called to add corresponding next hops to the vertex->Adj_N list for the real neighbor vertices.
In the case of LAN links, the absence of corresponding real neighbors in the spftree->sadj_list prevents the execution of the second step. Consequently, the vertex->Adj_N list for the real neighbor vertices lacks corresponding next hops. This leads to a null pointer access when isis_lfa_compute() is called to calculate LFA.
As for P2P links, since there are no pseudo neighbors, only the second step is executed, which does not create real neighbor vertices and therefore does not encounter this issue.
The backtrace is as follows:
(gdb) bt
#0  0x00007fd065277fe1 in raise () from /lib/x86_64-linux-gnu/libpthread.so.0
#1  0x00007fd065398972 in core_handler (signo=11, siginfo=0x7ffc5c0636b0, context=0x7ffc5c063580) at ../lib/sigevent.c:261
#2  <signal handler called>
#3  0x00005564d82f8408 in isis_lfa_compute (area=0x5564d8b143f0, circuit=0x5564d8b21d10, spftree=0x5564d8b06bf0, resource=0x7ffc5c064410) at ../isisd/isis_lfa.c:2134
#4  0x00005564d82f8d78 in isis_spf_run_lfa (area=0x5564d8b143f0, spftree=0x5564d8b06bf0) at ../isisd/isis_lfa.c:2344
#5  0x00005564d8315964 in isis_run_spf_with_protection (area=0x5564d8b143f0, spftree=0x5564d8b06bf0) at ../isisd/isis_spf.c:1827
#6  0x00005564d8315c15 in isis_run_spf_cb (thread=0x7ffc5c064590) at ../isisd/isis_spf.c:1889
#7  0x00007fd0653b1f04 in thread_call (thread=0x7ffc5c064590) at ../lib/thread.c:1990
#8  0x00007fd06534a97b in frr_run (master=0x5564d88103c0) at ../lib/libfrr.c:1198
#9  0x00005564d82e7d5d in main (argc=5, argv=0x7ffc5c0647b8, envp=0x7ffc5c0647e8) at ../isisd/isis_main.c:273
(gdb) f 3
#3  0x00005564d82f8408 in isis_lfa_compute (area=0x5564d8b143f0, circuit=0x5564d8b21d10, spftree=0x5564d8b06bf0, resource=0x7ffc5c064410) at ../isisd/isis_lfa.c:2134
2134    ../isisd/isis_lfa.c: No such file or directory.
(gdb) p vadj_primary
$1 = (struct isis_vertex_adj *) 0x0
(gdb) p vertex->Adj_N->head
$2 = (struct listnode *) 0x0
(gdb) p (struct isis_vertex *)spftree->paths->l.list->head->next->next->next->next->data
$8 = (struct isis_vertex *) 0x5564d8b5b240
(gdb) p $8->type
$9 = VTYPE_NONPSEUDO_TE_IS
(gdb) p $8->N.id
$10 = "\000\000\000\000\000\002"
(gdb) p $8->Adj_N->count
$11 = 0
(gdb) p (struct isis_vertex *)spftree->paths->l.list->head->next->next->next->next->next->data
$12 = (struct isis_vertex *) 0x5564d8b73dd0
(gdb) p $12->type
$13 = VTYPE_NONPSEUDO_TE_IS
(gdb) p $12->N.id
$14 = "\000\000\000\000\000\003"
(gdb) p $12->Adj_N->count
$15 = 0
(gdb) p area->adjacency_list->count
$16 = 0
The backtrace provided above pertains to version 8.5.4, but it seems that the same issue exists in the code of the master branch as well.
The scenario where a vertex has no next hop is normal. For example, the "clear isis neighbor" command invokes isis_vertex_adj_del() to delete the next hop of a vertex. Upon reviewing all the instances where the vertex->Adj_N list is used, I found that only isis_lfa_compute() lacks a null check. Therefore, I believe that modifying this part will be sufficient. Additionally, the vertex->parents list for IP vertices is guaranteed not to be empty.
Test scenario:
Setting up LFA for LAN links and executing the "clear isis neighbor" command easily reproduces the issue.

Signed-off-by: zhou-run <zhou.run@h3c.com>
(cherry picked from commit a970bb51b5fe32335c783860a03bb02ce74a49aa)

9 months agoMerge pull request #16312 from FRRouting/mergify/bp/dev/10.1/pr-16305
Russ White [Tue, 2 Jul 2024 12:00:43 +0000 (08:00 -0400)]
Merge pull request #16312 from FRRouting/mergify/bp/dev/10.1/pr-16305

bgpd: Ignore RFC8212 for BGP Confederations (backport #16305)

9 months agoMerge pull request #16318 from FRRouting/mergify/bp/dev/10.1/pr-16233
Russ White [Tue, 2 Jul 2024 11:59:50 +0000 (07:59 -0400)]
Merge pull request #16318 from FRRouting/mergify/bp/dev/10.1/pr-16233

ripd/ripd.c - rip_auth_md5 : Change the start value of sequence 1 to 0 (backport #16233)

9 months agoripd: Change the start value of sequence 1 to 0 16318/head
T-Nicolas [Mon, 17 Jun 2024 13:05:58 +0000 (15:05 +0200)]
ripd: Change the start value of sequence 1 to 0

Signed-off-by: T-Nicolas <github@toselli.email>
(cherry picked from commit 1a64fe4254759245a67fb279d67478922e00255e)

9 months agotests: Test if RFC 8212 is not involved for BGP confederations 16312/head
Donatas Abraitis [Thu, 27 Jun 2024 19:53:24 +0000 (22:53 +0300)]
tests: Test if RFC 8212 is not involved for BGP confederations

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
(cherry picked from commit dd6a679e3a0e9415827643942bcc103c48a89adb)

9 months agobgpd: Ignore RFC8212 for BGP Confederations
Donatas Abraitis [Thu, 27 Jun 2024 19:46:58 +0000 (22:46 +0300)]
bgpd: Ignore RFC8212 for BGP Confederations

RFC 8212 should be restricted for eBGP peers.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
(cherry picked from commit fa2cc09d45d3f843564f7bd1e02346373c5741a8)

9 months agoMerge pull request #16306 from FRRouting/mergify/bp/dev/10.1/pr-16068
Donatas Abraitis [Sun, 30 Jun 2024 16:03:38 +0000 (18:03 +0200)]
Merge pull request #16306 from FRRouting/mergify/bp/dev/10.1/pr-16068

bgpd: Ignore routes from evpn if VRF is unknown (backport #16068)

10 months agobgpd: Ignore routes from evpn if VRF is unknown 16306/head
Piotr Suchy [Wed, 22 May 2024 08:41:52 +0000 (10:41 +0200)]
bgpd: Ignore routes from evpn if VRF is unknown

Fix for a bug, where FRR fails to install route received for an unknown but later-created VRF - detailed description can be found here https://github.com/FRRouting/frr/issues/13708

Signed-off-by: Piotr Suchy <psuchy@akamai.com>
(cherry picked from commit 8044d733009dd428c291460eb8b0e539b53b78fa)

10 months agoMerge pull request #16302 from FRRouting/mergify/bp/dev/10.1/pr-16271
Donald Sharp [Thu, 27 Jun 2024 16:16:28 +0000 (12:16 -0400)]
Merge pull request #16302 from FRRouting/mergify/bp/dev/10.1/pr-16271

bgpd: avoid clearing routes for peers that were never established (backport #16271)

10 months agobgpd: avoid clearing routes for peers that were never established 16302/head
Loïc Sang [Wed, 19 Jun 2024 14:19:22 +0000 (16:19 +0200)]
bgpd: avoid clearing routes for peers that were never established

Under heavy system load with many peers in passive mode and a large
number of routes, bgpd can enter an infinite loop. This occurs while
processing timeout BGP_OPEN messages, which prevents it from accepting
new connections. The following log entries illustrate the issue:
>bgpd[6151]: [VX6SM-8YE5W][EC 33554460] 3.3.2.224: nexthop_set failed, resetting connection - intf 0x0
>bgpd[6151]: [P790V-THJKS][EC 100663299] bgp_open_receive: bgp_getsockname() failed for peer: 3.3.2.224
>bgpd[6151]: [HTQD2-0R1WR][EC 33554451] bgp_process_packet: BGP OPEN receipt failed for peer: 3.3.2.224
... repeating

The issue occurs when bgpd handles a massive number of routes in the RIB
while receiving numerous BGP_OPEN packets. If bgpd is overloaded, it
fails to process these packets promptly, leading the remote peer to
close the connection and resend BGP_OPEN packets.

When bgpd eventually starts processing these timeout BGP_OPEN packets,
it finds the TCP connection closed by the remote peer, resulting in
"bgp_stop()" being called. For each timeout peer, bgpd must iterate
through the routing table, which is time-consuming and causes new
incoming BGP_OPEN packets to timeout, perpetuating the infinite loop.

To address this issue, the code is modified to check if the peer has
been established at least once before calling "bgp_clear_route_all()".
This ensures that routes are only cleared for peers that had a
successful session, preventing unnecessary iterations over the routing
table for peers that never established a connection.

With this change, BGP_OPEN timeout messages may still occur, but in the
worst case, bgpd will stabilize. Before this patch, bgpd could enter a
loop where it was unable to accpet any new connections.

Signed-off-by: Loïc Sang <loic.sang@6wind.com>
(cherry picked from commit e0ae285eb8beeef7b43bdadc073d8ae346eaeb6c)

10 months agoMerge pull request #16285 from FRRouting/mergify/bp/dev/10.1/pr-15838
Russ White [Tue, 25 Jun 2024 12:42:02 +0000 (08:42 -0400)]
Merge pull request #16285 from FRRouting/mergify/bp/dev/10.1/pr-15838

 bgpd: fix "bgp as-pah access-list" with "set aspath exclude" set/unset issue (backport #15838)

10 months agoMerge pull request #16284 from FRRouting/mergify/bp/dev/10.1/pr-16261
Donatas Abraitis [Tue, 25 Jun 2024 11:49:39 +0000 (14:49 +0300)]
Merge pull request #16284 from FRRouting/mergify/bp/dev/10.1/pr-16261

zebra: clear evpn dup-addr return error-msg when there is no vni (backport #16261)

10 months agoMerge pull request #16291 from FRRouting/mergify/bp/dev/10.1/pr-16214
Russ White [Tue, 25 Jun 2024 11:30:45 +0000 (07:30 -0400)]
Merge pull request #16291 from FRRouting/mergify/bp/dev/10.1/pr-16214

bgpd: A couple more fixes for Tunnel encapsulation handling (backport #16214)

10 months agoMerge pull request #16289 from FRRouting/mergify/bp/dev/10.1/pr-16273
Russ White [Tue, 25 Jun 2024 11:30:24 +0000 (07:30 -0400)]
Merge pull request #16289 from FRRouting/mergify/bp/dev/10.1/pr-16273

bgpd: Relax OAD (One-Administration-Domain) for RFC8212 (backport #16273)

10 months agobgpd: Check if we have real stream data for tunnel encapsulation sub-tlvs 16291/head
Donatas Abraitis [Thu, 13 Jun 2024 06:00:21 +0000 (09:00 +0300)]
bgpd: Check if we have real stream data for tunnel encapsulation sub-tlvs

When the packet is malformed it can use whatever values it wants. Let's check
what the real data we have in a stream instead of relying on malformed values.

Reported-by: Iggy Frankovic <iggyfran@amazon.com>
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
(cherry picked from commit 9929486d6bdb28469a5b626a17d5bc9991c83ce3)

10 months agobgpd: Adjust the length of tunnel encap sub-tlv by sub-tlv type
Donatas Abraitis [Thu, 13 Jun 2024 05:43:21 +0000 (08:43 +0300)]
bgpd: Adjust the length of tunnel encap sub-tlv by sub-tlv type

Fixes: 79563af564ad0fe5b9c8d95bf080d570f87b1859 ("bgpd: Get 1 or 2 octets for Sub-TLV length (Tunnel Encap attr)")
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
(cherry picked from commit 34b209f0ae2caca0d1ebcde9d4095375ac31b562)

10 months agobgpd: Relax OAD (One-Administration-Domain) for RFC8212 16289/head
Donatas Abraitis [Mon, 24 Jun 2024 17:16:16 +0000 (20:16 +0300)]
bgpd: Relax OAD (One-Administration-Domain) for RFC8212

RFC 8212 defines leak prevention for eBGP peers, but BGP-OAD defines a new
peering type One Administrative Domain (OAD), where multiple ASNs could be used
inside a single administrative domain. OAD allows sending non-transitive attributes,
so this prevention should be relaxed too.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
(cherry picked from commit 3b98ddf5018cf7526b50c15018cbaf71a38fa752)

10 months agoMerge pull request #16281 from FRRouting/mergify/bp/dev/10.1/pr-16213
Donatas Abraitis [Tue, 25 Jun 2024 10:48:18 +0000 (13:48 +0300)]
Merge pull request #16281 from FRRouting/mergify/bp/dev/10.1/pr-16213

bgpd: Check if we have really enough data before doing memcpy for FQDN capability (backport #16213)

10 months agoMerge pull request #16278 from FRRouting/mergify/bp/dev/10.1/pr-16211
Donatas Abraitis [Tue, 25 Jun 2024 10:47:50 +0000 (13:47 +0300)]
Merge pull request #16278 from FRRouting/mergify/bp/dev/10.1/pr-16211

bgpd: Check if we have really enough data before doing memcpy for software version (backport #16211)

10 months agoMerge pull request #16239 from FRRouting/mergify/bp/dev/10.1/pr-16224
Donatas Abraitis [Tue, 25 Jun 2024 10:47:33 +0000 (13:47 +0300)]
Merge pull request #16239 from FRRouting/mergify/bp/dev/10.1/pr-16224

zebra: Prevent starvation in dplane_thread_loop (backport #16224)

10 months agoMerge pull request #16274 from FRRouting/mergify/bp/dev/10.1/pr-16242
Jafar Al-Gharaibeh [Tue, 25 Jun 2024 05:25:25 +0000 (01:25 -0400)]
Merge pull request #16274 from FRRouting/mergify/bp/dev/10.1/pr-16242

bgpd: Set last reset reason to admin shutdown if it was manually (backport #16242)

10 months agotests: improve tests for aspath exclude and bgp access list 16285/head
Francois Dumontet [Wed, 24 Apr 2024 12:34:48 +0000 (14:34 +0200)]
tests: improve tests for aspath exclude and bgp access list

add some match in route map rules
add some set unset bgp access path list
add another prefix for better tests discrimination
update expected results

Signed-off-by: Francois Dumontet <francois.dumontet@6wind.com>
(cherry picked from commit 0df2e149970beff39915d0095614d56d5859f3ff)

10 months agobgpd: fix "bgp as-pah access-list" with "set aspath exclude" set/unset issues
Francois Dumontet [Tue, 23 Apr 2024 09:16:24 +0000 (11:16 +0200)]
bgpd: fix "bgp as-pah access-list" with "set aspath exclude" set/unset issues

whith the following config

router bgp 65001
 no bgp ebgp-requires-policy
 neighbor 192.168.1.2 remote-as external
 neighbor 192.168.1.2 timers 3 10
 !
 address-family ipv4 unicast
  neighbor 192.168.1.2 route-map r2 in
 exit-address-family
exit
!
bgp as-path access-list FIRST seq 5 permit ^65
bgp as-path access-list SECOND seq 5 permit 2$
!
route-map r2 permit 6
 match ip address prefix-list p2
 set as-path exclude as-path-access-list SECOND
exit
!
route-map r2 permit 10
 match ip address prefix-list p1
 set as-path exclude 65003
exit
!
route-map r2 permit 20
 match ip address prefix-list p3
 set as-path exclude all
exit

making some
no bgp as-path access-list SECOND permit 2$
bgp as-path access-list SECOND permit 3$

clear bgp *

no bgp as-path access-list SECOND permit 3$
bgp as-path access-list SECOND permit 2$

clear bgp *

will induce some crashes

thus  we rework the links between aslists and aspath_exclude

Signed-off-by: Francois Dumontet <francois.dumontet@6wind.com>
(cherry picked from commit 094dcc3cdac19d3da65b38effc45aa88d960909f)

10 months agozebra: clear evpn dup-addr return error-msg when there is no vni 16284/head
Sindhu Parvathi Gopinathan [Wed, 19 Jun 2024 14:35:31 +0000 (07:35 -0700)]
zebra: clear evpn dup-addr return error-msg when there is no vni

clear evpn dup-addr cli returns error-msg for below conditions,

 - If evpn is not enabled &
 - If there is no VNI exists.

supported command:

```
clear evpn dup-addr vni <vni-id>
```

Ticket: #3495573

Testing:

bharat# clear evpn dup-addr vni all
Error type: validation
Error description: % EVPN not enabled

bharat# clear evpn dup-addr vni 20
Error type: validation
Error description: % VNI 20 does not exist

Signed-off-by: Sindhu Parvathi Gopinathan's <sgopinathan@nvidia.com>
Signed-off-by: Chirag Shah <chirag@nvidia.com>
(cherry picked from commit 56c16ee529b546058c8d1fabbb701d8ed2fded75)

10 months agobgpd: Check if we have really enough data before doing memcpy for FQDN capability 16281/head
Donatas Abraitis [Thu, 13 Jun 2024 05:12:10 +0000 (08:12 +0300)]
bgpd: Check if we have really enough data before doing memcpy for FQDN capability

We advance data pointer (data++), but we do memcpy() with the length that is 1-byte
over, which is technically heap overflow.

```
==411461==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x50600011da1a at pc 0xc4f45a9786f0 bp 0xffffed1e2740 sp 0xffffed1e1f30
READ of size 4 at 0x50600011da1a thread T0
    0 0xc4f45a9786ec in __asan_memcpy (/home/ubuntu/frr-public/frr_public_private-libfuzzer/bgpd/.libs/bgpd+0x3586ec) (BuildId: e794c5f796eee20c8973d7efb9bf5735e54d44cd)
    1 0xc4f45abf15f8 in bgp_dynamic_capability_fqdn /home/ubuntu/frr-public/frr_public_private-libfuzzer/bgpd/bgp_packet.c:3457:4
    2 0xc4f45abdd408 in bgp_capability_msg_parse /home/ubuntu/frr-public/frr_public_private-libfuzzer/bgpd/bgp_packet.c:3911:4
    3 0xc4f45abdbeb4 in bgp_capability_receive /home/ubuntu/frr-public/frr_public_private-libfuzzer/bgpd/bgp_packet.c:3980:9
    4 0xc4f45abde2cc in bgp_process_packet /home/ubuntu/frr-public/frr_public_private-libfuzzer/bgpd/bgp_packet.c:4109:11
    5 0xc4f45a9b6110 in LLVMFuzzerTestOneInput /home/ubuntu/frr-public/frr_public_private-libfuzzer/bgpd/bgp_main.c:582:3
```

Found by fuzzing.

Reported-by: Iggy Frankovic <iggyfran@amazon.com>
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
(cherry picked from commit b685ab5e1bdec0848502c20e9596b9716b236639)

10 months agobgpd: Check if we have really enough data before doing memcpy for software version 16278/head
Donatas Abraitis [Wed, 12 Jun 2024 19:54:45 +0000 (22:54 +0300)]
bgpd: Check if we have really enough data before doing memcpy for software version

If we receive CAPABILITY message (software-version), we SHOULD check if we really
have enough data before doing memcpy(), that could also lead to buffer overflow.

(data + len > end) is not enough, because after this check we do data++ and later
memcpy(..., data, len). That means we have one more byte.

Hit this through fuzzing by

```
    0 0xaaaaaadf872c in __asan_memcpy (/home/ubuntu/frr-public/frr_public_private-libfuzzer/bgpd/.libs/bgpd+0x35872c) (BuildId: 9c6e455d0d9a20f5a4d2f035b443f50add9564d7)
    1 0xaaaaab06bfbc in bgp_dynamic_capability_software_version /home/ubuntu/frr-public/frr_public_private-libfuzzer/bgpd/bgp_packet.c:3713:3
    2 0xaaaaab05ccb4 in bgp_capability_msg_parse /home/ubuntu/frr-public/frr_public_private-libfuzzer/bgpd/bgp_packet.c:3839:4
    3 0xaaaaab05c074 in bgp_capability_receive /home/ubuntu/frr-public/frr_public_private-libfuzzer/bgpd/bgp_packet.c:3980:9
    4 0xaaaaab05e48c in bgp_process_packet /home/ubuntu/frr-public/frr_public_private-libfuzzer/bgpd/bgp_packet.c:4109:11
    5 0xaaaaaae36150 in LLVMFuzzerTestOneInput /home/ubuntu/frr-public/frr_public_private-libfuzzer/bgpd/bgp_main.c:582:3
```

Hit this again by Iggy \m/

Reported-by: Iggy Frankovic <iggyfran@amazon.com>
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
(cherry picked from commit 5d7af51c4f7980507135babd94d392ca179c1bf7)

10 months agobgpd: Remove redundant whitespace before printing the reason of the failed peer 16274/head
Donatas Abraitis [Wed, 19 Jun 2024 11:32:16 +0000 (14:32 +0300)]
bgpd: Remove redundant whitespace before printing the reason of the failed peer

Before:

```
Neighbor        EstdCnt DropCnt ResetTime Reason
127.0.0.1             0       0     never  Waiting for peer OPEN (n/a)
```

After:

```
Neighbor        EstdCnt DropCnt ResetTime Reason
127.0.0.1             0       0     never Waiting for peer OPEN (n/a)
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
(cherry picked from commit b5bd626a82b2541bee8e3120139e19ba05e444c8)

10 months agobgpd: Set last reset reason to admin shutdown if it was manually
Donatas Abraitis [Wed, 19 Jun 2024 11:09:00 +0000 (14:09 +0300)]
bgpd: Set last reset reason to admin shutdown if it was manually

Before this patch, we always printed the last reason "Waiting for OPEN", but
if it's a manual shutdown, then we technically are not waiting for OPEN.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
(cherry picked from commit c25c7e929d550c2faca3af74a29593b8c0b75db3)

10 months agoMerge pull request #16255 from FRRouting/mergify/bp/dev/10.1/pr-16059
Donatas Abraitis [Fri, 21 Jun 2024 14:51:43 +0000 (17:51 +0300)]
Merge pull request #16255 from FRRouting/mergify/bp/dev/10.1/pr-16059

bgpd: fixed failing to remove VRF if there is a stale l3vni (backport #16059)

10 months agoMerge pull request #16264 from FRRouting/mergify/bp/dev/10.1/pr-16252
Donatas Abraitis [Fri, 21 Jun 2024 14:50:52 +0000 (17:50 +0300)]
Merge pull request #16264 from FRRouting/mergify/bp/dev/10.1/pr-16252

zebra: fix evpn mh bond member proto reinstall (backport #16252)

10 months agoMerge pull request #16262 from FRRouting/mergify/bp/dev/10.1/pr-16260
Donatas Abraitis [Fri, 21 Jun 2024 14:50:20 +0000 (17:50 +0300)]
Merge pull request #16262 from FRRouting/mergify/bp/dev/10.1/pr-16260

bgpd: fix do not use api.backup_nexthop in ZAPI message (backport #16260)

10 months agozebra: fix evpn mh bond member proto reinstall 16264/head
Chirag Shah [Wed, 19 Jun 2024 00:21:49 +0000 (17:21 -0700)]
zebra: fix evpn mh bond member proto reinstall

In case of EVPN MH bond, a member port going in
protodown state due to external reason (one case being linkflap),
frr updates the state correctly but upon manually
clearing external reason trigger FRR to reinstate
protodown without any reason code.

Fix is to ensure if the protodown reason was external
and new state is to have protodown 'off' then do no reinstate
protodown.

Ticket: #3947432
Testing:
switch:#ip link show swp1
4: swp1: <NO-CARRIER,BROADCAST,MULTICAST,SLAVE,UP> mtu 9216 qdisc
   pfifo_fast master bond1 state DOWN mode DEFAULT group default qlen
   1000
       link/ether 1c:34:da:2c:aa:68 brd ff:ff:ff:ff:ff:ff protodown on
       protodown_reason <linkflap>

switch:#ip link set swp1 protodown off protodown_reason linkflap off
switch:#ip link show swp1
 4: swp1: <NO-CARRIER,BROADCAST,MULTICAST,SLAVE,UP> mtu 9216 qdisc
    pfifo_fast master bond1 state DOWN mode DEFAULT group default qlen
    1000
        link/ether 1c:34:da:2c:aa:68 brd ff:ff:ff:ff:ff:ff

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

10 months agobgpd: fix do not use api.backup_nexthop in ZAPI message 16262/head
Philippe Guibert [Thu, 20 Jun 2024 16:02:26 +0000 (18:02 +0200)]
bgpd: fix do not use api.backup_nexthop in ZAPI message

The backup_nexthop entry list has been populated by mistake,
and should not. Fix this by reverting the introduced behavior.

Fixes: 237ebf8d4503 ("bgpd: rework bgp_zebra_announce() function, separate nexthop handling")
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
(cherry picked from commit d4390fc21795b09b84a6b95b1f8fa1ac2b3dcda9)

10 months agobgpd: fixed failing remove of vrf if there is a stale l3vni 16255/head
Kacper Kwaśny [Mon, 27 May 2024 09:03:30 +0000 (11:03 +0200)]
bgpd: fixed failing remove of vrf if there is a stale l3vni

Problem statement:
==================
When a vrf is deleted from the kernel, before its removed from the FRR
config, zebra gets to delete the the vrf and assiciated state.

It does so by sending a request to delete the l3 vni associated with the
vrf followed by a request to delete the vrf itself.

2023/10/06 06:22:18 ZEBRA: [JAESH-BABB8] Send L3_VNI_DEL 1001 VRF
testVRF1001 to bgp
2023/10/06 06:22:18 ZEBRA: [XC3P3-1DG4D] MESSAGE: ZEBRA_VRF_DELETE
testVRF1001

The zebra client communication is asynchronous and about 1/5 cases the
bgp client process them in a different order.

2023/10/06 06:22:18 BGP: [VP18N-HB5R6] VRF testVRF1001(766) is to be
deleted.
2023/10/06 06:22:18 BGP: [RH4KQ-X3CYT] VRF testVRF1001(766) is to be
disabled.
2023/10/06 06:22:18 BGP: [X8ZE0-9TS5H] VRF disable testVRF1001 id 766
2023/10/06 06:22:18 BGP: [X67AQ-923PR] Deregistering VRF 766
2023/10/06 06:22:18 BGP: [K52W0-YZ4T8] VRF Deletion:
testVRF1001(4294967295)
.. and a bit later :
2023/10/06 06:22:18 BGP: [MRXGD-9MHNX] DJERNAES: process L3VNI 1001 DEL
2023/10/06 06:22:18 BGP: [NCEPE-BKB1G][EC 33554467] Cannot process L3VNI
1001 Del - Could not find BGP instance

When the bgp vrf config is removed later it fails on the sanity check if
l3vni is removed.

        if (bgp->l3vni) {
            vty_out(vty, "%% Please unconfigure l3vni %u\n",
                bgp->l3vni);
            return CMD_WARNING_CONFIG_FAILED;
        }

Solution:
=========
The solution is to make bgp cleanup the l3vni a bgp instance is going
down.

The fix:
========
The fix is to add a function in bgp_evpn.c to be responsible for for
deleting the local vni, if it should be needed, and call the function
from bgp_instance_down().

Testing:
========
Created a test, which can run in container lab that remove the vrf on
the host before removing the vrf and the bgp config form frr. Running
this test in a loop trigger the problem 18 times of 100 runs. After the
fix it did not fail.

To verify the fix a log message (which is not in the code any longer)
were used when we had a stale l3vni and needed to call
bgp_evpn_local_l3vni_del() to do the cleanup. This were hit 20 times in
100 test runs.

Signed-off-by: Kacper Kwasny <kkwasny@akamai.com>
bgpd: braces {} are not necessary for single line block

Signed-off-by: Kacper Kwasny <kkwasny@akamai.com>
(cherry picked from commit 171d2583d0373b456335477dea6688d2e9e95db7)

10 months agozebra: Prevent starvation in dplane_thread_loop 16239/head
Donald Sharp [Fri, 14 Jun 2024 17:36:51 +0000 (13:36 -0400)]
zebra: Prevent starvation in dplane_thread_loop

When removing a large number of routes, the linux kernel can take the
cpu for an extended amount of time, leaving a situation where FRR
detects a starvation event.

r1# sharp install routes 10.0.0.0 nexthop 192.168.44.33 1000000 repeat 10
2024-06-14 12:55:49.365 [NTFY] sharpd: [M7Q4P-46WDR] vty[5]@# sharp install routes 10.0.0.0 nexthop 192.168.44.33 1000000 repeat 10
2024-06-14 12:55:49.365 [DEBG] sharpd: [YP4TQ-01TYK] Inserting 1000000 routes
2024-06-14 12:55:57.256 [DEBG] sharpd: [TPHKD-3NYSB] Installed All Items 7.890085
2024-06-14 12:55:57.256 [DEBG] sharpd: [YJ486-NX5R1] Removing 1000000 routes
2024-06-14 12:56:07.802 [WARN] zebra: [QH9AB-Y4XMZ][EC 100663314] STARVATION: task dplane_thread_loop (634377bc8f9e) ran for 7078ms (cpu time 220ms)
2024-06-14 12:56:25.039 [DEBG] sharpd: [WTN53-GK9Y5] Removed all Items 27.783668
2024-06-14 12:56:25.039 [DEBG] sharpd: [YP4TQ-01TYK] Inserting 1000000 routes
2024-06-14 12:56:32.783 [DEBG] sharpd: [TPHKD-3NYSB] Installed All Items 7.743524
2024-06-14 12:56:32.783 [DEBG] sharpd: [YJ486-NX5R1] Removing 1000000 routes
2024-06-14 12:56:41.447 [WARN] zebra: [QH9AB-Y4XMZ][EC 100663314] STARVATION: task dplane_thread_loop (634377bc8f9e) ran for 5175ms (cpu time 179ms)

Let's modify the loop in dplane_thread_loop such that after a provider
has been run, check to see if the event should yield, if so, stop
and reschedule this for the future.

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

10 months agoMerge pull request #16210 from LabNConsulting/chopps/fix-bug
Jafar Al-Gharaibeh [Thu, 13 Jun 2024 05:14:16 +0000 (00:14 -0500)]
Merge pull request #16210 from LabNConsulting/chopps/fix-bug

lib: fix incorrect use of error checking macro

10 months agolib: fix incorrect use of error checking macro 16210/head
Christian Hopps [Wed, 12 Jun 2024 22:48:02 +0000 (18:48 -0400)]
lib: fix incorrect use of error checking macro

Signed-off-by: Christian Hopps <chopps@labn.net>
10 months agoMerge pull request #16191 from pguibert6WIND/srte_color_not_copied base_10.1
Donatas Abraitis [Wed, 12 Jun 2024 12:39:10 +0000 (15:39 +0300)]
Merge pull request #16191 from pguibert6WIND/srte_color_not_copied

lib: fix copy srte_color from zapi_nexthop structure

10 months agoMerge pull request #16190 from trots/master
Russ White [Tue, 11 Jun 2024 18:44:14 +0000 (14:44 -0400)]
Merge pull request #16190 from trots/master

doc: Add reloading script into Python dependency section

10 months agoMerge pull request #16050 from rgirada/ospfv3_helper
Russ White [Tue, 11 Jun 2024 15:48:05 +0000 (11:48 -0400)]
Merge pull request #16050 from rgirada/ospfv3_helper

ospf6d: Handling Topo Change in GR-HELPER mode for max-age lsas

10 months agodoc: Add reloading script into Python dependency section 16190/head
Alexander Trotsenko [Sat, 8 Jun 2024 22:10:02 +0000 (01:10 +0300)]
doc: Add reloading script into Python dependency section

Signed-off-by: Alexander Trotsenko <trotsenko93@mail.ru>
10 months agoMerge pull request #16193 from opensourcerouting/fix/ecommunity_linkbw_present_overrun
Russ White [Tue, 11 Jun 2024 15:21:42 +0000 (11:21 -0400)]
Merge pull request #16193 from opensourcerouting/fix/ecommunity_linkbw_present_overrun

bgpd: Check against extended community unit size for link bandwidth

10 months agoMerge pull request #16187 from opensourcerouting/isis_tilfa_topo_rework
Donald Sharp [Tue, 11 Jun 2024 13:49:35 +0000 (09:49 -0400)]
Merge pull request #16187 from opensourcerouting/isis_tilfa_topo_rework

isis_tilfa_topo1 rework

10 months agobgpd: Check against extended community unit size for link bandwidth 16193/head
Donatas Abraitis [Tue, 11 Jun 2024 07:03:17 +0000 (10:03 +0300)]
bgpd: Check against extended community unit size for link bandwidth

If we receive a malformed packets, this could lead ptr_get_be64() reading
the packets more than needed (heap overflow).

```
Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1".
    0 0xaaaaaadf86ec in __asan_memcpy (/home/ubuntu/frr-public/frr_public_private-libfuzzer/bgpd/.libs/bgpd+0x3586ec) (BuildId: 78123cd26ada92b8b59fc0d74d292ba70c9d2e01)
    1 0xaaaaaaeb60fc in ptr_get_be64 /home/ubuntu/frr-public/frr_public_private-libfuzzer/./lib/stream.h:377:2
    2 0xaaaaaaeb5b90 in ecommunity_linkbw_present /home/ubuntu/frr-public/frr_public_private-libfuzzer/bgpd/bgp_ecommunity.c:1895:10
    3 0xaaaaaae50f30 in bgp_attr_ext_communities /home/ubuntu/frr-public/frr_public_private-libfuzzer/bgpd/bgp_attr.c:2639:8
    4 0xaaaaaae49d58 in bgp_attr_parse /home/ubuntu/frr-public/frr_public_private-libfuzzer/bgpd/bgp_attr.c:3776:10
    5 0xaaaaab063260 in bgp_update_receive /home/ubuntu/frr-public/frr_public_private-libfuzzer/bgpd/bgp_packet.c:2371:20
    6 0xaaaaab05df00 in bgp_process_packet /home/ubuntu/frr-public/frr_public_private-libfuzzer/bgpd/bgp_packet.c:4063:11
    7 0xaaaaaae36110 in LLVMFuzzerTestOneInput /home/ubuntu/frr-public/frr_public_private-libfuzzer/bgpd/bgp_main.c:582:3
```

This is triggered when receiving such a packet (malformed):

```
(gdb) bt
0  ecommunity_linkbw_present (ecom=0x555556287990, bw=bw@entry=0x7fffffffda68)
    at bgpd/bgp_ecommunity.c:1802
1  0x000055555564fcac in bgp_attr_ext_communities (args=0x7fffffffd840) at bgpd/bgp_attr.c:2619
2  bgp_attr_parse (peer=peer@entry=0x55555628cdf0, attr=attr@entry=0x7fffffffd960, size=size@entry=20,
    mp_update=mp_update@entry=0x7fffffffd940, mp_withdraw=mp_withdraw@entry=0x7fffffffd950)
    at bgpd/bgp_attr.c:3755
3  0x00005555556aa655 in bgp_update_receive (connection=connection@entry=0x5555562aa030,
    peer=peer@entry=0x55555628cdf0, size=size@entry=41) at bgpd/bgp_packet.c:2324
4  0x00005555556afab7 in bgp_process_packet (thread=<optimized out>) at bgpd/bgp_packet.c:3897
5  0x00007ffff7ac2f73 in event_call (thread=thread@entry=0x7fffffffdc70) at lib/event.c:2011
6  0x00007ffff7a6fb90 in frr_run (master=0x555555bc7c90) at lib/libfrr.c:1212
7  0x00005555556457e1 in main (argc=<optimized out>, argv=<optimized out>) at bgpd/bgp_main.c:543
(gdb) p *ecom
$1 = {refcnt = 1, unit_size = 8 '\b', disable_ieee_floating = false, size = 2, val = 0x555556282150 "",
  str = 0x5555562a9c30 "UNK:0, 255 UNK:2, 6"}
```

Reported-by: Iggy Frankovic <iggyfran@amazon.com>
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
10 months agoMerge pull request #16183 from LabNConsulting/chopps/notif-doc-update
Donatas Abraitis [Mon, 10 Jun 2024 19:25:10 +0000 (22:25 +0300)]
Merge pull request #16183 from LabNConsulting/chopps/notif-doc-update

mgmtd: add empty notif xpath map for completeness

10 months agotests: introduce method to update reference data in isis_tilfa_topo1 16187/head
Renato Westphal [Fri, 7 Jun 2024 15:03:17 +0000 (12:03 -0300)]
tests: introduce method to update reference data in isis_tilfa_topo1

The isis_tilfa_topo1 topotest is comprehensive and contains a large
amount of reference data. One problem is that, when changes occur,
updating this reference data can be difficult.

To address this problem, this commit introduces a method to
automatically regenerate the reference data by setting the `REGEN_DATA`
environment variable.

Usage:
$ REGEN_DATA=true python3 ./test_isis_tilfa_topo1.py

When `REGEN_DATA` is set, the topotest regenerates reference data
from the current run instead of comparing against existing reference
data. Note that regenerated data must be manually verified for
correctness.

This commit also simplifies the reference data by replacing all diff
files with complete JSON snapshots.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
10 months agotests: rework isis_tilfa_topo1 to fix timing issues
Renato Westphal [Fri, 7 Jun 2024 13:41:38 +0000 (10:41 -0300)]
tests: rework isis_tilfa_topo1 to fix timing issues

In this topotest, steps 10-15 were added to test the IS-IS switchover
functionality. In short, two cases were tested: switchover after a
link down event and switchover after a BFD down event. Both cases
were tested in sequence on the same router, rt6. This involved the
following steps:
- Setting the SPF delay timer to 15 seconds
- Shutting down the eth-rt5 interface from the switch side
- Testing the post-switchover RIB and LIB (triggered by the link down
  event)
- Testing the post-SPF RIB and LIB
- Bringing the eth-rt5 interface back up
- Configuring a BFD session between rt6 and rt5
- Shutting down the eth-rt5 interface from the switch side once again
- Testing the post-switchover RIB and LIB (triggered by the BFD down
  event)
- Testing the post-SPF RIB and LIB

Since the time window to test the post-switchover RIB and LIB was too
narrow (10 seconds), these tests were having sporadic failures.

To resolve this problem, we can simplify the switchover test as follows:
- Setting the SPF delay timer to 60 seconds (not 15)
- Disabling "link-detect" on rt6's eth-rt5 interface
- Shutting down the eth-rt5 interface from the switch side
- On rt6, testing the post-switchover RIB and LIB (triggered by the
  BFD down event)
- On rt5, testing the post-switchover RIB and LIB (triggered by the
  link down event)

Notice how we can test both post-link-down and post-BFD-down switchover
cases simultaneously by having different "link-detect" configurations
on rt5 and rt6. Additionally, by using a larger SPF delay timer, the
time window to test the post-switchover RIB and LIB is much larger
and less prone to sporadic failures.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
10 months agolib: fix copy srte_color from zapi_nexthop structure 16191/head
Philippe Guibert [Sun, 17 Dec 2023 20:04:31 +0000 (21:04 +0100)]
lib: fix copy srte_color from zapi_nexthop structure

When switching from nexthop to zapi_nexthop, the srte color
is copied. Do the same in reverse.

Fixes: 31f937fb43f4 ("lib, zebra: Add SR-TE policy infrastructure to zebra")
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
10 months agoMerge pull request #16093 from louis-6wind/fix-show-route-memory
Donatas Abraitis [Mon, 10 Jun 2024 08:26:23 +0000 (11:26 +0300)]
Merge pull request #16093 from louis-6wind/fix-show-route-memory

zebra: fix Out Of Memory issue when displaying large route tables in JSON

10 months agoMerge pull request #16189 from LabNConsulting/chopps/triage-github-action
Donald Sharp [Sun, 9 Jun 2024 01:34:42 +0000 (21:34 -0400)]
Merge pull request #16189 from LabNConsulting/chopps/triage-github-action

10 months agoci: do apt-get update before installing required modules 16189/head
Christian Hopps [Sat, 8 Jun 2024 19:37:47 +0000 (15:37 -0400)]
ci: do apt-get update before installing required modules

- Use `uname -r` to also install specific module versions since
  with github runners the running kernel can become out-dated with
  the deployed packages.

Signed-off-by: Christian Hopps <chopps@labn.net>
10 months agoMerge pull request #15900 from mikemallin/v6-vtep-lib-upstream
Donald Sharp [Fri, 7 Jun 2024 18:34:11 +0000 (14:34 -0400)]
Merge pull request #15900 from mikemallin/v6-vtep-lib-upstream

lib, bgpd, tests, zebra: prefix_sg changes for V6 VTEP

10 months agodoc: add some text on native message API and notif xpath array 16183/head
Christian Hopps [Thu, 6 Jun 2024 23:49:40 +0000 (19:49 -0400)]
doc: add some text on native message API and notif xpath array

Signed-off-by: Christian Hopps <chopps@labn.net>
10 months agomgmtd: add empty notif xpath map for completeness
Christian Hopps [Thu, 6 Jun 2024 18:08:00 +0000 (14:08 -0400)]
mgmtd: add empty notif xpath map for completeness

New back-end clients may need to add notification static allocations so
we should have it available for those users, rather than requiring the
new user delve into the mgmtd infra and modify it themselves.

Signed-off-by: Christian Hopps <chopps@labn.net>
10 months agotests: check show route vrf all json output 16093/head
Louis Scalbert [Mon, 27 May 2024 08:35:26 +0000 (10:35 +0200)]
tests: check show route vrf all json output

Check that "show ip route vrf XXX json" and the JSON at key "XXX" of
"show ip route vrf all json" gives the same output.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
10 months agozebra: fix show route memory consumption
Louis Scalbert [Fri, 24 May 2024 14:34:23 +0000 (16:34 +0200)]
zebra: fix show route memory consumption

When displaying a route table in JSON, a table JSON object is storing
all the prefix JSON objects containing the prefix information. This
results in excessive memory allocation for JSON objects, potentially
leading to an out-of-memory error on the machine with large routing
tables.

To Fix the memory consumption issue for the "show ip[v6] route [vrf XX]
json" command, display the prefixes one by one and free the memory of
each JSON object after it has been displayed.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
10 months agozebra: fix show route vrf all memory consumption
Louis Scalbert [Fri, 24 May 2024 15:06:59 +0000 (17:06 +0200)]
zebra: fix show route vrf all memory consumption

0e2fc3d67f ("vtysh, zebra: Fix malformed json output for multiple vrfs
in command 'show ip route vrf all json'") has been reverted in the
previous commit. Although the fix was correct, it was consuming too muca
memory when displaying large route tables.

A root JSON object was storing all the JSON objects containing the route
tables, each containing their respective prefixes in JSON objects. This
resulted in excessive memory allocation for JSON objects, potentially
leading to an out-of-memory error on the machine.

To Fix the memory consumption issue for the "show ip[v6] route vrf all
json" command, display the tables one by one and free the memory of each
JSON object after it has been displayed.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
10 months agolib: add helpers to print json keys
Louis Scalbert [Mon, 27 May 2024 08:04:14 +0000 (10:04 +0200)]
lib: add helpers to print json keys

Add helpers to print json keys in order to prepare the next commits.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
10 months agoRevert "vtysh, zebra: Fix malformed json output for multiple vrfs in command 'show...
Louis Scalbert [Fri, 24 May 2024 14:46:17 +0000 (16:46 +0200)]
Revert "vtysh, zebra: Fix malformed json output for multiple vrfs in command 'show ip route vrf all json'"

This reverts commit 0e2fc3d67f1d358896a764373f41cb59c095eda9.

This fix was correct but not optimal for memory consumption at scale.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
10 months agoMerge pull request #16143 from eremcan/patch-1
Donatas Abraitis [Fri, 7 Jun 2024 07:49:55 +0000 (10:49 +0300)]
Merge pull request #16143 from eremcan/patch-1

docker: fix chmod issues when running container for debian

10 months agoMerge pull request #11906 from louis-6wind/show_isis_db_json
Russ White [Thu, 6 Jun 2024 20:27:57 +0000 (16:27 -0400)]
Merge pull request #11906 from louis-6wind/show_isis_db_json

isisd: fix show isis database [detail] json

10 months agoMerge pull request #15434 from louis-6wind/labels-hash
Russ White [Thu, 6 Jun 2024 20:27:38 +0000 (16:27 -0400)]
Merge pull request #15434 from louis-6wind/labels-hash

bgpd: move labels from extra to extra->labels and add them to adj-rib-in and adj-rib-out

10 months agoMerge pull request #16151 from pguibert6WIND/srv6_fix_source_address
Donald Sharp [Thu, 6 Jun 2024 16:22:15 +0000 (12:22 -0400)]
Merge pull request #16151 from pguibert6WIND/srv6_fix_source_address

zebra: display srv6 encapsulation source-address when configured

10 months agoMerge pull request #16171 from mjstapp/fix_fpm_nl_len_check
Donald Sharp [Thu, 6 Jun 2024 12:20:53 +0000 (08:20 -0400)]
Merge pull request #16171 from mjstapp/fix_fpm_nl_len_check

zebra: fix incoming FPM message length validation

10 months agoMerge pull request #16176 from LabNConsulting/chopps/munet-version-update
Donald Sharp [Thu, 6 Jun 2024 12:20:37 +0000 (08:20 -0400)]
Merge pull request #16176 from LabNConsulting/chopps/munet-version-update

tests: munet: update to version 0.14.9

10 months agoospf6d: Handling Topo Change in GR-HELPER mode for max-age lsas 16050/head
Rajesh Girada [Mon, 20 May 2024 16:34:41 +0000 (09:34 -0700)]
ospf6d: Handling Topo Change in GR-HELPER mode for max-age lsas

Description:
OSPF6 GR HELPER router should  consider as TOPOCHANGE when
it receives lsas with max age and should exit from Helper.
But, it is not exiting from helper because this max age lsa is
considered as duplicated lsa since the sender uses same seq
number for max age lsa from the previous lsa update.
Currently, topo change is not considered for duplicated lsas.
So removed the duplicated check when validating TOPOCHNAGE.

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
10 months agotests: munet: update to version 0.14.9 16176/head
Christian Hopps [Thu, 6 Jun 2024 08:50:05 +0000 (08:50 +0000)]
tests: munet: update to version 0.14.9

Topotest relevant changes:

    - add support for `timeout` arg to `cmd_*()`
    - handle invalid regexp in CLI commands
    - fix long interface name support

Full munet changelog:

    munet: 0.14.9: add support for `timeout` arg to `cmd_*()`
    munet: 0.14.8: cleanup the cleanup (kill) on launch options
    munet: 0.14.7: allow multiple extra commands for shell console init
    munet: 0.14.6:
      - qemu: gather gcda files where munet can find them
      - handle invalid regexp in CLI commands
    munet: 0.14.5:
      - (podman) pull missing images for containers
      - fix long interface name support
      - add another router example
    munet: 0.14.4: mutest: add color to PASS/FAIL indicators on tty consoles
    munet: 0.14.3: Add hostnet node that runs it's commands in the host network namespace.
    munet: 0.14.2:
      - always fail mutest tests on bad json inputs
      - improve ssh-remote for common use-case of connecting to host connected devices
      - fix ready-cmd for python v3.11+
    munet: 0.14.1: Improved host interface support.

Signed-off-by: Christian Hopps <chopps@labn.net>
10 months agoMerge pull request #16170 from LabNConsulting/dleroy/nhrpd-shortcut-cleanup
Donald Sharp [Wed, 5 Jun 2024 18:39:14 +0000 (14:39 -0400)]
Merge pull request #16170 from LabNConsulting/dleroy/nhrpd-shortcut-cleanup

nhrpd: cleans up shortcut cache entries on termination

10 months agozebra: fix incoming FPM message length validation 16171/head
Mark Stapp [Wed, 5 Jun 2024 18:37:41 +0000 (14:37 -0400)]
zebra: fix incoming FPM message length validation

Validate incoming message length against correct
(struct rtmsg) len, not top-level netlink message header size.

Signed-off-by: Mark Stapp <mjs@cisco.com>
10 months agonhrpd: cleans up shortcut cache entries on termination 16170/head
Dave LeRoy [Wed, 5 Jun 2024 17:22:57 +0000 (10:22 -0700)]
nhrpd: cleans up shortcut cache entries on termination

nhrp_shortcut_terminate() previously was just freeing the associated AFI shortcut
RIBs and not addressing existing shortcut cache entries. This cause a use after
free issue in vrf_terminate() later in the terminate sequence

NHRP: Received signal 7 at 1717516286 (si_addr 0x1955d, PC 0x7098786912c0); aborting...
NHRP: zlog_signal+0xf5                   709878ad1255     7fff3d992eb0 /usr/lib/frr/libfrr.so.0 (mapped at 0x709878a00000)
NHRP: core_handler+0xb5                  709878b0db85     7fff3d992ff0 /usr/lib/frr/libfrr.so.0 (mapped at 0x709878a00000)
NHRP: __sigaction+0x50                   709878642520     7fff3d993140 /lib/x86_64-linux-gnu/libc.so.6 (mapped at 0x709878600000)
NHRP:     ---- signal ----
NHRP: __lll_lock_wait_private+0x90       7098786912c0     7fff3d9936d8 /lib/x86_64-linux-gnu/libc.so.6 (mapped at 0x709878600000)
NHRP: pthread_mutex_lock+0x112           709878698002     7fff3d9936e0 /lib/x86_64-linux-gnu/libc.so.6 (mapped at 0x709878600000)
NHRP: _event_add_read_write+0x63         709878b1f423     7fff3d993700 /usr/lib/frr/libfrr.so.0 (mapped at 0x709878a00000)
NHRP: zclient_send_message+0xd4          709878b37614     7fff3d993770 /usr/lib/frr/libfrr.so.0 (mapped at 0x709878a00000)
NHRP: nhrp_route_announce+0x1ad          5ab34d63d39d     7fff3d993790 /usr/lib/frr/nhrpd (mapped at 0x5ab34d621000)
NHRP: nhrp_shortcut_cache_notify+0xd8     5ab34d63e758     7fff3d99d4e0 /usr/lib/frr/nhrpd (mapped at 0x5ab34d621000)
NHRP: nhrp_cache_free+0x165              5ab34d632f25     7fff3d99d510 /usr/lib/frr/nhrpd (mapped at 0x5ab34d621000)
NHRP: hash_iterate+0x4d                  709878ab949d     7fff3d99d540 /usr/lib/frr/libfrr.so.0 (mapped at 0x709878a00000)
NHRP: nhrp_cache_interface_del+0x37      5ab34d633eb7     7fff3d99d580 /usr/lib/frr/nhrpd (mapped at 0x5ab34d621000)
NHRP: nhrp_if_delete_hook+0x26           5ab34d6350d6     7fff3d99d5a0 /usr/lib/frr/nhrpd (mapped at 0x5ab34d621000)
NHRP: if_delete_retain+0x3d              709878abcd1d     7fff3d99d5c0 /usr/lib/frr/libfrr.so.0 (mapped at 0x709878a00000)
NHRP: if_delete+0x4c                     709878abd87c     7fff3d99d600 /usr/lib/frr/libfrr.so.0 (mapped at 0x709878a00000)
NHRP: if_terminate+0x53                  709878abda83     7fff3d99d630 /usr/lib/frr/libfrr.so.0 (mapped at 0x709878a00000)
NHRP: vrf_terminate_single+0x24          709878b23c74     7fff3d99d670 /usr/lib/frr/libfrr.so.0 (mapped at 0x709878a00000)
NHRP: nhrp_request_stop+0x34             5ab34d636844     7fff3d99d690 /usr/lib/frr/nhrpd (mapped at 0x5ab34d621000)
NHRP: frr_sigevent_process+0x53          709878b0df53     7fff3d99d6a0 /usr/lib/frr/libfrr.so.0 (mapped at 0x709878a00000)
NHRP: event_fetch+0x6c5                  709878b20405     7fff3d99d6c0 /usr/lib/frr/libfrr.so.0 (mapped at 0x709878a00000)
NHRP: frr_run+0xd3                       709878ac8163     7fff3d99d840 /usr/lib/frr/libfrr.so.0 (mapped at 0x709878a00000)
NHRP: main+0x195                         5ab34d631915     7fff3d99d960 /usr/lib/frr/nhrpd (mapped at 0x5ab34d621000)
NHRP: __libc_init_first+0x90             709878629d90     7fff3d99d980 /lib/x86_64-linux-gnu/libc.so.6 (mapped at 0x709878600000)
NHRP: __libc_start_main+0x80             709878629e40     7fff3d99da20 /lib/x86_64-linux-gnu/libc.so.6 (mapped at 0x709878600000)
NHRP: _start+0x25                        5ab34d631b65     7fff3d99da70 /usr/lib/frr/nhrpd (mapped at 0x5ab34d621000)

Signed-off-by: Dave LeRoy <dleroy@labn.net>
10 months agoMerge pull request #16164 from opensourcerouting/fix/doc_clear_bgp_by_asn
Donald Sharp [Wed, 5 Jun 2024 17:07:04 +0000 (13:07 -0400)]
Merge pull request #16164 from opensourcerouting/fix/doc_clear_bgp_by_asn

doc: Add missing `clear bgp ASNUM` command

10 months agoMerge pull request #16159 from opensourcerouting/fix/ignore_auto_created_vrf_bgp_inst...
Donald Sharp [Wed, 5 Jun 2024 13:51:09 +0000 (09:51 -0400)]
Merge pull request #16159 from opensourcerouting/fix/ignore_auto_created_vrf_bgp_instances

bgpd: Ignore auto created VRF BGP instances

10 months agoMerge pull request #16163 from LabNConsulting/aceelindem/ospfv3-auth-sa-id-checking
Donald Sharp [Wed, 5 Jun 2024 13:48:45 +0000 (09:48 -0400)]
Merge pull request #16163 from LabNConsulting/aceelindem/ospfv3-auth-sa-id-checking

 ospf6d: OSPFv3 manual key authentication neglects checking the SA ID.

10 months agoMerge pull request #16155 from httpstorm/gcc-14-compatibility
Donald Sharp [Wed, 5 Jun 2024 13:47:44 +0000 (09:47 -0400)]
Merge pull request #16155 from httpstorm/gcc-14-compatibility

zebra: fix compilation with GCC14

10 months agobgpd: fix label in adj-rib-out 15434/head
Philippe Guibert [Thu, 23 Feb 2023 14:38:11 +0000 (15:38 +0100)]
bgpd: fix label in adj-rib-out

After modifying the "label vpn export value", the vpn label information
of the VRF is not updated to the peers.

For example, the 192.168.0.0/24 prefix is announced to the peer with a
label value of 222.

> router bgp 65500
> [..]
>  neighbor 192.0.2.2 remote-as 65501
>  address-family ipv4-vpn
>   neighbor 192.0.2.2 activate
>  exit-address-family
> exit
> router bgp 65500 vrf vrf2
>  address-family ipv4 unicast
>   network 192.168.0.0/24
>   label vpn export 222
>   rd vpn export 444:444
>   rt vpn both 53:100
>   export vpn
>   import vpn
>  exit-address-family

Changing the label with "label vpn export" does not update the label
value to the peer unless the BGP sessions is re-established.

No labels are stored are stored struct bgp_adj_out so that it is
impossible to compare the current value with the previous value
in adj-RIB-out.

Reference the bgp_labels pointer in struct bgp_adj_out and compare the
values when updating adj-RIB-out.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
10 months agobgpd: fix labels in adj-rib-in
Philippe Guibert [Fri, 13 Jan 2023 14:59:52 +0000 (15:59 +0100)]
bgpd: fix labels in adj-rib-in

In a BGP L3VPN context using ADJ-RIB-IN (ie. enabled with
'soft-reconfiguration inbound'), after applying a deny route-map and
removing it, the remote MPLS label information is lost. As a result, BGP
is unable to re-install the related routes in the RIB.

For example,

> router bgp 65500
> [..]
>  neighbor 192.0.2.2 remote-as 65501
>  address-family ipv4 vpn
>   neighbor 192.0.2.2 activate
>   neighbor 192.0.2.2 soft-reconfiguration inbound

The 192.168.0.0/24 prefix has a remote label value of 102 in the BGP
RIB.

> # show bgp ipv4 vpn 192.168.0.0/24
>  BGP routing table entry for 444:1:192.168.0.0/24, version 2
>  [..]
>      192.168.0.0 from 192.0.2.2
>        Origin incomplete, metric 0, valid, external, best (First path received)
>        Extended Community: RT:52:100
>        Remote label: 102

A route-map now filter all incoming BGP updates:

> route-map rmap deny 1
> router bgp 65500
>  address-family ipv4 vpn
>   neighbor 192.0.2.2 route-map rmap in

The prefix is now filtered:

> # show bgp ipv4 vpn 192.168.0.0/24
> #

The route-map is detached:

> router bgp 65500
>  address-family ipv4 vpn
>   no neighbor 192.168.0.1 route-map rmap in

The BGP RIB entry is present but the remote label is lost:

> # show bgp ipv4 vpn 192.168.0.0/24
>  BGP routing table entry for 444:1:192.168.0.0/24, version 2
>  [..]
>      192.168.0.0 from 192.0.2.2
>        Origin incomplete, metric 0, valid, external, best (First path received)
>        Extended Community: RT:52:100

The reason for the loose is that labels are stored within struct attr ->
struct extra -> struct bgp_labels but not in the struct bgp_adj_in.

Reference the bgp_labels pointer in struct bgp_adj_in and use its values
when doing a soft reconfiguration of the BGP table.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
10 months agobgpd: get rid of has_valid_label in bgp_update()
Louis Scalbert [Mon, 26 Feb 2024 15:55:11 +0000 (16:55 +0100)]
bgpd: get rid of has_valid_label in bgp_update()

Get rid of has_valid_label in bgp_update() to prepare the next commits.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
10 months agobgpd: move labels from extra to extra->labels
Louis Scalbert [Mon, 26 Feb 2024 17:23:11 +0000 (18:23 +0100)]
bgpd: move labels from extra to extra->labels

Move labels from extra to extra->labels. Labels are now stored in a hash
list.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
10 months agobgpd: add bgp_labels hash
Louis Scalbert [Fri, 23 Feb 2024 14:18:03 +0000 (15:18 +0100)]
bgpd: add bgp_labels hash

Add bgp_labels type and hash list.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>