]> git.puffer.fish Git - mirror/frr.git/log
mirror/frr.git
7 months agoospfd: Fix heap corruption vulnerability when parsing SR-Algorithm TLV 16863/head
Acee Lindem [Wed, 18 Sep 2024 18:09:19 +0000 (18:09 +0000)]
ospfd: Fix heap corruption vulnerability when parsing SR-Algorithm TLV

When parsing the SR-Algorithm TLV in the OSPF Router Information Opaque
LSA, assure that not more than the maximum number of supported
algorithms are copied from the TLV.

Signed-off-by: Acee Lindem <acee@lindem.com>
(cherry picked from commit 0dc969185fdd75fd007c9b29e11be57a078236df)

7 months agoMerge pull request #16843 from FRRouting/mergify/bp/stable/10.0/pr-16809
Donald Sharp [Tue, 17 Sep 2024 17:40:42 +0000 (13:40 -0400)]
Merge pull request #16843 from FRRouting/mergify/bp/stable/10.0/pr-16809

isisd: fix rcap tlv double-free crash (backport #16809)

7 months agotests: update isisd fuzz test 16843/head
Louis Scalbert [Mon, 16 Sep 2024 11:43:26 +0000 (13:43 +0200)]
tests: update isisd fuzz test

Since the previous commit, if a router capability subTLV is not
readable, the previously read subTLVs are kept.

Update of the ISIS fuzz test.

> $ wuschl rebuild tests/isisd/test_fuzz_isis_tlv
> $ gzip -9 tests/isisd/test_fuzz_isis_tlv_tests.h

> $ ./test_fuzz_isis_tlv 2>/dev/null | grep failed
> Test 139 failed, output differs.
> Test 150 failed, output differs.
> 2 of 405 tests failed.
>
> $ ./test_fuzz_isis_tlv 139 2>/dev/null
> Test 139 failed, output differs.
> Expected output:
> Unpack log:
> Unpacking 564 bytes of TLVs...
>   Unpacking TLV...
>     Found TLV of type 193 and len 13.
>     Skipping unknown TLV 193 (13 bytes)
>   Unpacking TLV...
>     Found TLV of type 0 and len 0.
>     Skipping unknown TLV 0 (0 bytes)
>   Unpacking TLV...
>     Found TLV of type 0 and len 0.
>     Skipping unknown TLV 0 (0 bytes)
>   Unpacking TLV...
>     Found TLV of type 242 and len 12.
>     Unpacking Router Capability TLV...
>     WARNING: Router Capability subTLV length too large compared to expected size
> Unpacked TLVs:
> Received output:
> Unpack log:
> Unpacking 564 bytes of TLVs...
>   Unpacking TLV...
>     Found TLV of type 193 and len 13.
>     Skipping unknown TLV 193 (13 bytes)
>   Unpacking TLV...
>     Found TLV of type 0 and len 0.
>     Skipping unknown TLV 0 (0 bytes)
>   Unpacking TLV...
>     Found TLV of type 0 and len 0.
>     Skipping unknown TLV 0 (0 bytes)
>   Unpacking TLV...
>     Found TLV of type 242 and len 12.
>     Unpacking Router Capability TLV...
>     WARNING: Router Capability subTLV length too large compared to expected size
> Unpacked TLVs:
> Router Capability: 253.212.128.242 , D:1, S:1
>
> $ ./test_fuzz_isis_tlv 150 2>/dev/null
> Test 150 failed, output differs.
> Expected output:
> Unpack log:
> Unpacking 403 bytes of TLVs...
>   Unpacking TLV...
>     Found TLV of type 129 and len 13.
>     Unpacking Protocols Supported TLV...
>       Protocols Supported: 73, 16, 255, 255, 255, 101, 10, 11, 11, 11, 11, 11, 11
>   Unpacking TLV...
>     Found TLV of type 11 and len 11.
>     Skipping unknown TLV 11 (11 bytes)
>   Unpacking TLV...
>     Found TLV of type 242 and len 12.
>     Unpacking Router Capability TLV...
>     WARNING: Router Capability subTLV length too large compared to expected size
> Unpacked TLVs:
> Protocols Supported: 73, 16, 255, 255, 255, 101, 10, 11, 11, 11, 11, 11, 11
> Received output:
> Unpack log:
> Unpacking 403 bytes of TLVs...
>   Unpacking TLV...
>     Found TLV of type 129 and len 13.
>     Unpacking Protocols Supported TLV...
>       Protocols Supported: 73, 16, 255, 255, 255, 101, 10, 11, 11, 11, 11, 11, 11
>   Unpacking TLV...
>     Found TLV of type 11 and len 11.
>     Skipping unknown TLV 11 (11 bytes)
>   Unpacking TLV...
>     Found TLV of type 242 and len 12.
>     Unpacking Router Capability TLV...
>     WARNING: Router Capability subTLV length too large compared to expected size
> Unpacked TLVs:
> Protocols Supported: 73, 16, 255, 255, 255, 101, 10, 11, 11, 11, 11, 11, 11
> Router Capability: 253.212.128.242 , D:1, S:1

Link: https://pypi.org/project/wuschl/
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
(cherry picked from commit cfd050a0e5a636efae93865d982714da9dbf06a6)

7 months agoisisd: fix rcap tlv double-free crash
Louis Scalbert [Thu, 12 Sep 2024 07:31:49 +0000 (09:31 +0200)]
isisd: fix rcap tlv double-free crash

A double-free crash happens when a subTLV of the "Router Capability"
TLV is not readable and a previous "Router Capability" TLV was read.

rcap was supposed to be freed later by isis_free_tlvs() ->
free_tlv_router_cap(). In 78774bbcd5 ("isisd: add isis flex-algo lsp
advertisement"), this was not the case because rcap was not saved to
tlvs->router_cap when the function returned early because of a subTLV
length issue.

Always set tlvs->router_cap to free the memory.

Note that this patch has the consequence that in case of subTLV error,
the previously read "Router Capability" subTLVs are kept in memory.

Fixes: 49efc80d34 ("isisd: Ensure rcap is freed in error case")
Fixes: 78774bbcd5 ("isisd: add isis flex-algo lsp advertisement")
Reported-by: Iggy Frankovic <iggyfran@amazon.com>
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
(cherry picked from commit d61758140d33972c10ecbb72d0a3e528049dd8d6)

7 months agoMerge pull request #16820 from FRRouting/mergify/bp/stable/10.0/pr-16808
Donald Sharp [Fri, 13 Sep 2024 23:53:32 +0000 (19:53 -0400)]
Merge pull request #16820 from FRRouting/mergify/bp/stable/10.0/pr-16808

nhrpd: fixes duplicate auth extension (backport #16808)

7 months agoMerge pull request #16823 from FRRouting/mergify/bp/stable/10.0/pr-16818
Donald Sharp [Fri, 13 Sep 2024 23:52:52 +0000 (19:52 -0400)]
Merge pull request #16823 from FRRouting/mergify/bp/stable/10.0/pr-16818

ospfd: missing '[no]ip ospf graceful-restart hello-delay <N>' commands (backport #16818)

7 months agoospfd: fix missing '[no]ip ospf graceful-restart hello-delay <N>' commands 16823/head
Dmitrii Turlupov [Fri, 13 Sep 2024 13:22:18 +0000 (16:22 +0300)]
ospfd: fix missing '[no]ip ospf graceful-restart hello-delay <N>' commands

Signed-off-by: Dmitrii Turlupov <turlupov@bk.ru>
(cherry picked from commit 69e31a547f8520fd967cc34dc0cd3a8f915d07f8)

7 months agonhrpd: fixes duplicate auth extension 16820/head
Denys Haryachyy [Thu, 12 Sep 2024 07:28:28 +0000 (07:28 +0000)]
nhrpd: fixes duplicate auth extension

When an NHRP peer was forwarding a message, it was copying all
extensions from the originally received packet. The authentication
extension must be regenerated hop by hop per RFC2332.
This fix checks for the auth extension when copying extensions
and omits the original packet auth and instead regenerates a new auth extension.

Fix bug #16507

Signed-off-by: Denys Haryachyy <garyachy@gmail.com>
(cherry picked from commit 8e3c278bbcd0ced1d4058cc7a2c9aebdfbc8b651)

7 months agoMerge pull request #16805 from opensourcerouting/fix/backport_ABUILD_APK_INDEX_OPTS_10.0
Donald Sharp [Thu, 12 Sep 2024 12:22:23 +0000 (08:22 -0400)]
Merge pull request #16805 from opensourcerouting/fix/backport_ABUILD_APK_INDEX_OPTS_10.0

10.0 Backport docker ABUILD_APK_INDEX_OPTS

7 months agoFRR Release 10.0.2 rc/10.0.2 docker/10.0.2 frr-10.0.2
Donatas Abraitis [Thu, 12 Sep 2024 07:30:00 +0000 (10:30 +0300)]
FRR Release 10.0.2

- bgpd
-    Fix as-path exclude modify crash
-    Fix, do not access peer->notify.data when it is null
-    Fix crash at no rpki
-    Ignore RFC8212 for BGP Confederations
-    Fix for CVE-2024-44070
-    Relax OAD (One-Administration-Domain) for RFC8212
-    Fix "bgp as-pah access-list" with "set aspath exclude" set/unset issues
-    Check if we have really enough data before doing memcpy for FQDN capability
-    Check if we have really enough data before doing memcpy for software version
-    Set last reset reason to admin shutdown if it was manually
-    Fix do not use api.backup_nexthop in ZAPI message
- isisd
-    Fix crash when reading asla
-    Add missing `exit` statement
-    Fix update link params after circuit is up
-    Fix crash at flex-algo without mpls-te
-    Fix memory handling in isis_adj_process_threeway()
-    Fix crash when calculating the neighbor spanning tree based on the fragmented LSP
-    Fix crash when obtaining the next hop to calculate LFA on LAN links
-    Fix memory leaks when the transition of neighbor state from non-UP to DOWN
-    fix crash when displaying asla in json
- pimd
-    Fix crash in pimd
-    Fix msdp setting of sa->rp
-    Fix crash on non-existent interface
- nhrpd
-    Fix sending /32 shortcut
- mgmtd
-    Don't add implicit state data when reading config from file
-    Fix too early daemon detach of mgmtd
- ripd
-    Fix show run output for distribute-list
- lib
-    Fix distribute-list deletion
-    Fix crash on distribute-list delete
-    Fix incorrect use of error checking macro
- yang
-    Added missed prefix to the yang file
- ospfd
-    Fix internal ldp-sync state flags when feature is disabled
- ldpd
-    Fix wrong gtsm count
- ripd
-    Change the start value of sequence 1 to 0
- zebra
-    Fix evpn mh bond member proto reinstall
-    Fix to avoid two Vrfs with same table ids
-    Fix missing static routes
-    Ensure non-equal id's are not same nhg's

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
7 months agodocker: Set ABUILD_APK_INDEX_OPTS for frr build 16805/head
Donatas Abraitis [Fri, 14 Jun 2024 13:33:32 +0000 (16:33 +0300)]
docker: Set ABUILD_APK_INDEX_OPTS for frr build

In build() stage of abuild, it does `apk index ...` where frr* packages
are unsigned. We don't sign them here, and thus we need to specify `--allow-untrusted`.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
7 months agodocker: Set ABUILD_APK_INDEX_OPTS for libyang
Donatas Abraitis [Fri, 14 Jun 2024 08:37:23 +0000 (11:37 +0300)]
docker: Set ABUILD_APK_INDEX_OPTS for libyang

In build() stage of abuild, it does `apk index ...` where libyang* packages
are unsigned. We don't sign them here, and thus we need to specify `--allow-untrusted`.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
7 months agoMerge pull request #16795 from opensourcerouting/fix/5e1b7f5a69505c76999e610d8773f5ab...
Donald Sharp [Wed, 11 Sep 2024 19:55:32 +0000 (15:55 -0400)]
Merge pull request #16795 from opensourcerouting/fix/5e1b7f5a69505c76999e610d8773f5abd63fe1a2_10.0

bgpd: fix as-path exclude modify crash

7 months agoMerge pull request #16784 from FRRouting/mergify/bp/stable/10.0/pr-16718
Donatas Abraitis [Wed, 11 Sep 2024 07:55:48 +0000 (10:55 +0300)]
Merge pull request #16784 from FRRouting/mergify/bp/stable/10.0/pr-16718

isisd: fix crash when reading asla (backport #16718)

7 months agobgpd: fix as-path exclude modify crash 16795/head
Louis Scalbert [Tue, 10 Sep 2024 12:06:38 +0000 (14:06 +0200)]
bgpd: fix as-path exclude modify crash

Fix a crash when modifying a route-map with set as-path exclude without
as-path-access-list:

> router(config)# route-map routemaptest deny 1
> router(config-route-map)# set as-path exclude 33 34 35
> router(config-route-map)# set as-path exclude as-path-access-list test

> #0  raise (sig=<optimized out>) at ../sysdeps/unix/sysv/linux/raise.c:50
> #1  0x00007fb3959327de in core_handler (signo=11, siginfo=0x7ffd122da530, context=0x7ffd122da400) at lib/sigevent.c:258
> #2  <signal handler called>
> #3  0x000055ab2762a1bd in as_list_list_del (h=0x55ab27897680 <as_exclude_list_orphan>, item=0x55ab28204e20) at ./bgpd/bgp_aspath.h:77
> #4  0x000055ab2762d1a8 in as_exclude_remove_orphan (ase=0x55ab28204e20) at bgpd/bgp_aspath.c:1574
> #5  0x000055ab27550538 in route_aspath_exclude_free (rule=0x55ab28204e20) at bgpd/bgp_routemap.c:2366
> #6  0x00007fb39591f00c in route_map_rule_delete (list=0x55ab28203498, rule=0x55ab28204170) at lib/routemap.c:1357
> #7  0x00007fb39591f87c in route_map_add_set (index=0x55ab28203460, set_name=0x55ab276ad2aa "as-path exclude", set_arg=0x55ab281e4f70 "as-path-access-list test") at lib/routemap.c:1674
> #8  0x00007fb39591d3f3 in generic_set_add (index=0x55ab28203460, command=0x55ab276ad2aa "as-path exclude", arg=0x55ab281e4f70 "as-path-access-list test", errmsg=0x7ffd122db870 "",
>     errmsg_len=8192) at lib/routemap.c:533
> #9  0x000055ab2755e78e in lib_route_map_entry_set_action_rmap_set_action_exclude_as_path_modify (args=0x7ffd122db290) at bgpd/bgp_routemap_nb_config.c:2427
> #10 0x00007fb3958fe417 in nb_callback_modify (context=0x55ab28205aa0, nb_node=0x55ab27cb31e0, event=NB_EV_APPLY, dnode=0x55ab28202690, resource=0x55ab27c32148, errmsg=0x7ffd122db870 "",
>     errmsg_len=8192) at lib/northbound.c:1538
> #11 0x00007fb3958ff0ab in nb_callback_configuration (context=0x55ab28205aa0, event=NB_EV_APPLY, change=0x55ab27c32110, errmsg=0x7ffd122db870 "", errmsg_len=8192) at lib/northbound.c:1888
> #12 0x00007fb3958ff5e4 in nb_transaction_process (event=NB_EV_APPLY, transaction=0x55ab28205aa0, errmsg=0x7ffd122db870 "", errmsg_len=8192) at lib/northbound.c:2016
> #13 0x00007fb3958fddba in nb_candidate_commit_apply (transaction=0x55ab28205aa0, save_transaction=true, transaction_id=0x0, errmsg=0x7ffd122db870 "", errmsg_len=8192)
>     at lib/northbound.c:1356
> #14 0x00007fb3958fdef0 in nb_candidate_commit (context=..., candidate=0x55ab27c2c9a0, save_transaction=true, comment=0x0, transaction_id=0x0, errmsg=0x7ffd122db870 "", errmsg_len=8192)
>     at lib/northbound.c:1389
> #15 0x00007fb3959045ba in nb_cli_classic_commit (vty=0x55ab281f6680) at lib/northbound_cli.c:57
> #16 0x00007fb395904b5a in nb_cli_apply_changes_internal (vty=0x55ab281f6680, xpath_base=0x7ffd122dfd10 "/frr-route-map:lib/route-map[name='routemaptest']/entry[sequence='1']",
>     clear_pending=false) at lib/northbound_cli.c:184
> #17 0x00007fb395904ebf in nb_cli_apply_changes (vty=0x55ab281f6680, xpath_base_fmt=0x0) at lib/northbound_cli.c:240
> --Type <RET> for more, q to quit, c to continue without paging--
> #18 0x000055ab27557d2e in set_aspath_exclude_access_list_magic (self=0x55ab2775c300 <set_aspath_exclude_access_list_cmd>, vty=0x55ab281f6680, argc=5, argv=0x55ab28204c80,
>     as_path_filter_name=0x55ab28202040 "test") at bgpd/bgp_routemap.c:6397
> #19 0x000055ab2754bdea in set_aspath_exclude_access_list (self=0x55ab2775c300 <set_aspath_exclude_access_list_cmd>, vty=0x55ab281f6680, argc=5, argv=0x55ab28204c80)
>     at ./bgpd/bgp_routemap_clippy.c:856
> #20 0x00007fb39589435d in cmd_execute_command_real (vline=0x55ab281e61f0, vty=0x55ab281f6680, cmd=0x0, up_level=0) at lib/command.c:1003
> #21 0x00007fb3958944be in cmd_execute_command (vline=0x55ab281e61f0, vty=0x55ab281f6680, cmd=0x0, vtysh=0) at lib/command.c:1062
> #22 0x00007fb395894a0c in cmd_execute (vty=0x55ab281f6680, cmd=0x55ab28200f20 "set as-path exclude as-path-access-list test", matched=0x0, vtysh=0) at lib/command.c:1228
> #23 0x00007fb39595242c in vty_command (vty=0x55ab281f6680, buf=0x55ab28200f20 "set as-path exclude as-path-access-list test") at lib/vty.c:625
> #24 0x00007fb3959541c5 in vty_execute (vty=0x55ab281f6680) at lib/vty.c:1388
> #25 0x00007fb3959563db in vtysh_read (thread=0x7ffd122e2bb0) at lib/vty.c:2400
> #26 0x00007fb39594b785 in event_call (thread=0x7ffd122e2bb0) at lib/event.c:1996
> #27 0x00007fb3958d1365 in frr_run (master=0x55ab27b56d70) at lib/libfrr.c:1231
> #28 0x000055ab2747f1cc in main (argc=3, argv=0x7ffd122e2e08) at bgpd/bgp_main.c:555

Fixes: 094dcc3cda ("bgpd: fix "bgp as-pah access-list" with "set aspath exclude" set/unset issues")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
7 months agoisisd: fix crash when reading asla 16784/head
Louis Scalbert [Mon, 2 Sep 2024 08:26:57 +0000 (10:26 +0200)]
isisd: fix crash when reading asla

isisd is crashing when reading a ASLA sub-TLV with Application
Identifier Bit Mask length greater than 1 octet.

Set a limit of 8 bytes in accordance with RFC9479 and check that the
received value does not exceed the limit.

Reported-by: Iggy Frankovic <iggyfran@amazon.com>
Link: https://www.rfc-editor.org/rfc/rfc9479.html#name-application-identifier-bit-
Fixes: 5749ac83a8 ("isisd: add ASLA support")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
(cherry picked from commit f1bc6c5d81e8cc0d31ee61abb295193f30db4f5a)

7 months agoMerge pull request #16740 from FRRouting/mergify/bp/stable/10.0/pr-16724
Donald Sharp [Wed, 4 Sep 2024 13:31:33 +0000 (09:31 -0400)]
Merge pull request #16740 from FRRouting/mergify/bp/stable/10.0/pr-16724

isisd: Add missing `exit` statement to `show running-config` output (backport #16724)

7 months agoisisd: Add missing `exit` statement 16740/head
Carmine Scarpitta [Mon, 2 Sep 2024 21:57:53 +0000 (23:57 +0200)]
isisd: Add missing `exit` statement

Add missing `exit` statement to `show running-config` output.

```
router isis ISIS_CORE
 is-type level-2-only
 net 49.0001.0000.0000.0004.00
 lsp-mtu 1300
 topology ipv6-unicast
 log-adjacency-changes
 segment-routing srv6
  locator ISIS_LOC
 exit   <<<<<<<<<<<<<<<<<<<<<<<<
exit
```

Fixes https://github.com/FRRouting/frr/issues/16694

Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
(cherry picked from commit 8be8864ffd674ab87570f37f9f2e7c9afc20798f)

7 months agoMerge pull request #16729 from FRRouting/mergify/bp/stable/10.0/pr-16667
Donald Sharp [Tue, 3 Sep 2024 20:22:59 +0000 (16:22 -0400)]
Merge pull request #16729 from FRRouting/mergify/bp/stable/10.0/pr-16667

isisd: fix update link params after circuit is up (backport #16667)

7 months agoisisd: fix update link params after circuit is up 16729/head
Louis Scalbert [Tue, 27 Aug 2024 16:22:27 +0000 (18:22 +0200)]
isisd: fix update link params after circuit is up

If the link-params are set when the circuit not yet up, the link-params
are never updated.

isis_link_params_update() is called from isis_circuit_up() but returns
immediately because circuit->state != C_STATE_UP. circuit->state is
updated in isis_csm_state_change after isis_circuit_up().

> struct isis_circuit *isis_csm_state_change(enum isis_circuit_event event,
>     struct isis_circuit *circuit,
>     void *arg)
> {
> [...]
>  if (isis_circuit_up(circuit) != ISIS_OK) {
>  isis_circuit_deconfigure(circuit, area);
>  break;
>  }
>  circuit->state = C_STATE_UP;
>  isis_event_circuit_state_change(circuit, circuit->area,
>  1);

Do not return isis_link_params_update() if circuit->state != C_STATE_UP.

Fixes: 0fdd8b2b11 ("isisd: update link params after circuit is up")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
(cherry picked from commit 6ce6b7a8564f661495fec17f3ea33eeaf9e2f48c)

7 months agoMerge pull request #16709 from FRRouting/mergify/bp/stable/10.0/pr-16673
Donald Sharp [Sat, 31 Aug 2024 10:51:56 +0000 (06:51 -0400)]
Merge pull request #16709 from FRRouting/mergify/bp/stable/10.0/pr-16673

tests: Fix bgp_default_originate_topo1_3 (backport #16673)

7 months agoMerge pull request #16707 from FRRouting/mergify/bp/stable/10.0/pr-16683
Donald Sharp [Sat, 31 Aug 2024 10:51:39 +0000 (06:51 -0400)]
Merge pull request #16707 from FRRouting/mergify/bp/stable/10.0/pr-16683

tests: ospf_netns_vrf should give more time for coming up (backport #16683)

7 months agoMerge pull request #16703 from FRRouting/mergify/bp/stable/10.0/pr-16687
Donald Sharp [Fri, 30 Aug 2024 23:37:11 +0000 (19:37 -0400)]
Merge pull request #16703 from FRRouting/mergify/bp/stable/10.0/pr-16687

tests: increase the timeout for packet padding check (backport #16687)

7 months agoMerge pull request #16705 from FRRouting/mergify/bp/stable/10.0/pr-16682
Donald Sharp [Fri, 30 Aug 2024 23:36:36 +0000 (19:36 -0400)]
Merge pull request #16705 from FRRouting/mergify/bp/stable/10.0/pr-16682

tests: Ensure bgp suppress fib has a chance to transmit data to peer (backport #16682)

7 months agotests: Fix bgp_default_originate_topo1_3 16709/head
Donald Sharp [Tue, 27 Aug 2024 21:08:38 +0000 (17:08 -0400)]
tests: Fix bgp_default_originate_topo1_3

This test was killing bgp on r1 and r2
and then immediately testing that the
default route transitioned.  Unfortunately
the test was written that under load the
system might be in a bad state.  Let's
modify the code to check for a bgp version
change and then that the bgp state has
come back up

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

7 months agotests: ospf_netns_vrf should give more time for coming up 16707/head
Donald Sharp [Wed, 28 Aug 2024 19:10:04 +0000 (15:10 -0400)]
tests: ospf_netns_vrf should give more time for coming up

Test fails:

            test_func = partial(
                topotest.router_json_cmp,
                router,
                "show ip ospf vrf {0}-ospf-cust1 json".format(rname),
                expected,
            )
            _, diff = topotest.run_and_expect(test_func, None, count=10, wait=0.5)
            assertmsg = '"{}" JSON output mismatches'.format(rname)
>           assert diff is None, assertmsg
E           AssertionError: "r1" JSON output mismatches
E           assert Generated JSON diff error report:
E
E             > $->r1-ospf-cust1->areas->0.0.0.0->nbrFullAdjacentCounter: output has element with value '1' but in expected it has value '2'

/home/sharpd/frr2/tests/topotests/ospf_netns_vrf/test_ospf_netns_vrf.py:239: AssertionError

Support bundle has this data:
r1# show ip ospf vrf all neighbor
% 2024/08/28 14:55:54.763

VRF Name: r1-ospf-cust1

Neighbor ID     Pri State           Up Time         Dead Time Address         Interface                        RXmtL RqstL DBsmL
10.0.255.3        1 Full/DR         10.547s           39.456s 10.0.3.1        r1-eth1:10.0.3.2                     0     0     0
10.0.255.2        1 Full/Backup     0.543s            38.378s 10.0.3.3        r1-eth1:10.0.3.2                     1     0     0

So immediately after the test fails this test, the neighbor comes up.
Let's give the test a bit more time for failure to not happen

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

7 months agotests: Ensure bgp suppress fib has a chance to transmit data to peer 16705/head
Donald Sharp [Wed, 28 Aug 2024 19:05:40 +0000 (15:05 -0400)]
tests: Ensure bgp suppress fib has a chance to transmit data to peer

Giving only 5 seconds to pass bgp data to peers on a heavily
loaded system is a recipe for not having fun.  Add more time.

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

7 months agotests: increase the timeout for packet padding check 16703/head
Jafar Al-Gharaibeh [Thu, 29 Aug 2024 16:40:50 +0000 (11:40 -0500)]
tests: increase the timeout for packet padding check

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

8 months agoMerge pull request #16668 from FRRouting/mergify/bp/stable/10.0/pr-16665
Jafar Al-Gharaibeh [Wed, 28 Aug 2024 04:37:56 +0000 (00:37 -0400)]
Merge pull request #16668 from FRRouting/mergify/bp/stable/10.0/pr-16665

isisd: fix crash at flex-algo without mpls-te (backport #16665)

8 months agoMerge pull request #16661 from Jafaral/ospfv3-10.0-fix-test
Russ White [Tue, 27 Aug 2024 19:24:53 +0000 (15:24 -0400)]
Merge pull request #16661 from Jafaral/ospfv3-10.0-fix-test

tests: Fix ospfv3 basic functionality test (backport #16657)

8 months agoisisd: fix crash at flex-algo without mpls-te 16668/head
Louis Scalbert [Tue, 27 Aug 2024 13:45:38 +0000 (15:45 +0200)]
isisd: fix crash at flex-algo without mpls-te

Fix crash when flex-algo is configured and mpls-te is disabled.

> interface eth0
>  ip router isis 1
> !
> router isis 1
>  flex-algo 129
>   dataplane sr-mpls
>   advertise-definition

> #0  __pthread_kill_implementation (no_tid=0, signo=11, threadid=140486233631168) at ./nptl/pthread_kill.c:44
> #1  __pthread_kill_internal (signo=11, threadid=140486233631168) at ./nptl/pthread_kill.c:78
> #2  __GI___pthread_kill (threadid=140486233631168, signo=signo@entry=11) at ./nptl/pthread_kill.c:89
> #3  0x00007fc5802e9476 in __GI_raise (sig=11) at ../sysdeps/posix/raise.c:26
> #4  0x00007fc58076021f in core_handler (signo=11, siginfo=0x7ffd38d42470, context=0x7ffd38d42340) at lib/sigevent.c:248
> #5  <signal handler called>
> #6  0x000055c527f798c9 in isis_link_params_update_asla (circuit=0x55c52aaed3c0, ifp=0x55c52a1044e0) at isisd/isis_te.c:176
> #7  0x000055c527fb29da in isis_instance_flex_algo_create (args=0x7ffd38d43120) at isisd/isis_nb_config.c:2875
> #8  0x00007fc58072655b in nb_callback_create (context=0x55c52ab1d2f0, nb_node=0x55c529f72950, event=NB_EV_APPLY, dnode=0x55c52ab06230, resource=0x55c52ab189f8, errmsg=0x7ffd38d43750 "",
>     errmsg_len=8192) at lib/northbound.c:1262
> #9  0x00007fc580727625 in nb_callback_configuration (context=0x55c52ab1d2f0, event=NB_EV_APPLY, change=0x55c52ab189c0, errmsg=0x7ffd38d43750 "", errmsg_len=8192) at lib/northbound.c:1662
> #10 0x00007fc580727c39 in nb_transaction_process (event=NB_EV_APPLY, transaction=0x55c52ab1d2f0, errmsg=0x7ffd38d43750 "", errmsg_len=8192) at lib/northbound.c:1794
> #11 0x00007fc580725f77 in nb_candidate_commit_apply (transaction=0x55c52ab1d2f0, save_transaction=true, transaction_id=0x0, errmsg=0x7ffd38d43750 "", errmsg_len=8192)
>     at lib/northbound.c:1131
> #12 0x00007fc5807260d1 in nb_candidate_commit (context=..., candidate=0x55c529f0a730, save_transaction=true, comment=0x0, transaction_id=0x0, errmsg=0x7ffd38d43750 "", errmsg_len=8192)
>     at lib/northbound.c:1164
> #13 0x00007fc58072d220 in nb_cli_classic_commit (vty=0x55c52a0fc6b0) at lib/northbound_cli.c:51
> #14 0x00007fc58072d839 in nb_cli_apply_changes_internal (vty=0x55c52a0fc6b0,
>     xpath_base=0x7ffd38d477f0 "/frr-isisd:isis/instance[area-tag='1'][vrf='default']/flex-algos/flex-algo[flex-algo='129']", clear_pending=false) at lib/northbound_cli.c:178
> #15 0x00007fc58072dbcf in nb_cli_apply_changes (vty=0x55c52a0fc6b0, xpath_base_fmt=0x55c528014de0 "./flex-algos/flex-algo[flex-algo='%ld']") at lib/northbound_cli.c:234
> #16 0x000055c527fd3403 in flex_algo_magic (self=0x55c52804f1a0 <flex_algo_cmd>, vty=0x55c52a0fc6b0, argc=2, argv=0x55c52ab00ec0, algorithm=129, algorithm_str=0x55c52ab120d0 "129")
>     at isisd/isis_cli.c:3752
> #17 0x000055c527fc97cb in flex_algo (self=0x55c52804f1a0 <flex_algo_cmd>, vty=0x55c52a0fc6b0, argc=2, argv=0x55c52ab00ec0) at ./isisd/isis_cli_clippy.c:6445
> #18 0x00007fc5806b9abc in cmd_execute_command_real (vline=0x55c52aaf78f0, vty=0x55c52a0fc6b0, cmd=0x0, up_level=0) at lib/command.c:984
> #19 0x00007fc5806b9c35 in cmd_execute_command (vline=0x55c52aaf78f0, vty=0x55c52a0fc6b0, cmd=0x0, vtysh=0) at lib/command.c:1043
> #20 0x00007fc5806ba1e5 in cmd_execute (vty=0x55c52a0fc6b0, cmd=0x55c52aae6bd0 "flex-algo 129\n", matched=0x0, vtysh=0) at lib/command.c:1209
> #21 0x00007fc580782ae1 in vty_command (vty=0x55c52a0fc6b0, buf=0x55c52aae6bd0 "flex-algo 129\n") at lib/vty.c:615
> #22 0x00007fc580784a05 in vty_execute (vty=0x55c52a0fc6b0) at lib/vty.c:1378
> #23 0x00007fc580787131 in vtysh_read (thread=0x7ffd38d4ab10) at lib/vty.c:2373
> #24 0x00007fc58077b605 in event_call (thread=0x7ffd38d4ab10) at lib/event.c:2011
> #25 0x00007fc5806f8976 in frr_run (master=0x55c529df9b30) at lib/libfrr.c:1212
> #26 0x000055c527f301bc in main (argc=5, argv=0x7ffd38d4ad58, envp=0x7ffd38d4ad88) at isisd/isis_main.c:350
> (gdb) f 6
> #6  0x000055c527f798c9 in isis_link_params_update_asla (circuit=0x55c52aaed3c0, ifp=0x55c52a1044e0) at isisd/isis_te.c:176
> 176                     list_delete_all_node(ext->aslas);
> (gdb) p ext
> $1 = (struct isis_ext_subtlvs *) 0x0

Fixes: ae27101e6f ("isisd: fix building asla at first flex-algo config")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
(cherry picked from commit cd81d28ae253e64665ce7c45e18e479e3fc2f90d)

8 months agotests: Fix ospfv3 basic functionality test (backport #16657) 16661/head
Jafar Al-Gharaibeh [Tue, 27 Aug 2024 03:40:20 +0000 (22:40 -0500)]
tests: Fix ospfv3 basic functionality test (backport #16657)

Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
8 months agoMerge pull request #16645 from FRRouting/mergify/bp/stable/10.0/pr-16640
Jafar Al-Gharaibeh [Sat, 24 Aug 2024 21:40:04 +0000 (17:40 -0400)]
Merge pull request #16645 from FRRouting/mergify/bp/stable/10.0/pr-16640

nhrpd: fix sending /32 shortcut (backport #16640)

8 months agoMerge pull request #16648 from FRRouting/mergify/bp/stable/10.0/pr-16646
Jafar Al-Gharaibeh [Sat, 24 Aug 2024 21:39:48 +0000 (17:39 -0400)]
Merge pull request #16648 from FRRouting/mergify/bp/stable/10.0/pr-16646

pimd: Fix crash in pimd (backport #16646)

8 months agopimd: Fix crash in pimd 16648/head
Corey Siltala [Fri, 23 Aug 2024 18:04:26 +0000 (18:04 +0000)]
pimd: Fix crash in pimd

ifp->info is not always set in PIM. So add a guard here to stop
it from crashing when addresses are added to a non-PIM enabled interface
and PIM zebra debugging is enabled.

Signed-off-by: Corey Siltala <csiltala@atcorp.com>
(cherry picked from commit 12a783d313fccb0a2793f32be57b687dba736e0d)

8 months agonhrpd: fix sending /32 shortcut 16645/head
Louis Scalbert [Fri, 23 Aug 2024 14:05:45 +0000 (16:05 +0200)]
nhrpd: fix sending /32 shortcut

The remote spoke always sends a 32 prefix length to a shortcut request.
In the example, the remote spoke as the IP address 192.168.2.1/24.

spoke1# sh ip nhrp shortcut
Type     Prefix                   Via                      Identity
dynamic  192.168.2.1/32           10.255.255.2

Do not deal with local routes in nhrpd. Now:

spoke1# sh ip nhrp shortcut
Type     Prefix                   Via                      Identity
dynamic  192.168.2.0/24           10.255.255.2

Fixes: d4aa24ba7d ("*: Introduce Local Host Routes to FRR")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
(cherry picked from commit af54901405474b0623bda1899424ec18a3240c71)

8 months agoMerge pull request #16623 from FRRouting/mergify/bp/stable/10.0/pr-16546
Donald Sharp [Thu, 22 Aug 2024 12:20:15 +0000 (08:20 -0400)]
Merge pull request #16623 from FRRouting/mergify/bp/stable/10.0/pr-16546

bgpd: fix, do not access peer->notify.data when it is null (backport #16546)

8 months agotopotest: test_bgp_snmp_bgpv4v2_notification 16623/head
Dmytro Shytyi [Thu, 8 Aug 2024 13:42:40 +0000 (15:42 +0200)]
topotest: test_bgp_snmp_bgpv4v2_notification

This test checks the bgp crash on rt2 when 2 commands
launched consequently:
T0: rr, config -> router bgp 65004 -> neighbor 192.168.12.2 password 8888
T1: rt2, snmpwalk -v 2c -c public 127.0.0.1 .1.3.6.1.4.1.7336.4.2.1
T2: test if rt2 bgp is crashed.

Signed-off-by: Dmytro Shytyi <dmytro.shytyi@6wind.com>
(cherry picked from commit e23005f407be4c284aaafa4c379d54581b7a8e78)

8 months agobgpd: fix, do not access peer->notify.data when it is null
Dmytro Shytyi [Thu, 8 Aug 2024 13:53:11 +0000 (15:53 +0200)]
bgpd: fix, do not access peer->notify.data when it is null

bgp crash on rt2 spotted when 2 commands
launched consequently:
T0: rr, config -> router bgp 65004 -> neighbor 192.168.12.2 password
8888
T1: rt2, snmpwalk -v 2c -c public 127.0.0.1 .1.3.6.1.4.1.7336.4.2.1
T2: rt2 bgp is crashed.

config rt2-bgp:
---------------

!
debug bgp updates
!
router bgp 65002
 no bgp ebgp-requires-policy
 no bgp network import-check
 no bgp default ipv4-unicast
 neighbor 192.168.12.4 remote-as external
 neighbor 192.168.12.4 timers 1 3
 neighbor 192.168.12.4 timers connect 1
 neighbor 2001:db8::12:4 remote-as external
 neighbor 2001:db8::12:4 timers 1 3
 neighbor 2001:db8::12:4 timers connect 1
 !
 address-family ipv4 unicast
  neighbor 192.168.12.4 activate
  neighbor 192.168.12.4 addpath-tx-all-paths

 exit-address-family
 address-family ipv6 unicast
  neighbor 2001:db8::12:4 activate
 exit-address-family
!
agentx
!

config rt2-snmpd:
agentAddress 127.0.0.1,[::1]

group public_group v1 public
group public_group v2c public
access public_group "" any noauth prefix all all none

rocommunity public default

view all included .1

iquerySecName frr
rouser frr

master agentx

agentXSocket /etc/frr/agentx
agentXPerms 777 755 root frr

config rt2-zebra:
-----------------

!
interface r2-eth0
 ip address 192.168.12.2/24
 ipv6 address 2001:db8::12:2/64
!

config rr-bgpd:
---------------

!
debug bgp updates
!
router bgp 65004
 no bgp ebgp-requires-policy
 no bgp network import-check
 no bgp default ipv4-unicast
 neighbor 192.168.12.1 remote-as external
 neighbor 192.168.12.1 timers 1 3
 neighbor 192.168.12.1 timers connect 1
 neighbor 192.168.12.2 remote-as external
 neighbor 192.168.12.2 timers 1 3
 neighbor 192.168.12.2 timers connect 1
 neighbor 192.168.12.3 remote-as external
 neighbor 192.168.12.3 timers 1 3
 neighbor 192.168.12.3 timers connect 1
 neighbor 2001:db8::12:1 remote-as external
 neighbor 2001:db8::12:1 timers 1 3
 neighbor 2001:db8::12:1 timers connect 1
 neighbor 2001:db8::12:2 remote-as external
 neighbor 2001:db8::12:2 timers 1 3
 neighbor 2001:db8::12:2 timers connect 1
 neighbor 2001:db8::12:3 remote-as external
 neighbor 2001:db8::12:3 timers 1 3
 neighbor 2001:db8::12:3 timers connect 1
 !
 address-family ipv4 unicast
  neighbor 192.168.12.1 activate
  neighbor 192.168.12.1 addpath-tx-all-paths
  neighbor 192.168.12.1 route-server-client
  neighbor 192.168.12.2 activate
  neighbor 192.168.12.2 addpath-tx-all-paths
  neighbor 192.168.12.2 route-server-client
  neighbor 192.168.12.3 activate
  neighbor 192.168.12.3 addpath-tx-all-paths
  neighbor 192.168.12.3 route-server-client
 exit-address-family
 address-family ipv6 unicast
  neighbor 2001:db8::12:1 activate
  neighbor 2001:db8::12:1 route-server-client
  neighbor 2001:db8::12:2 activate
  neighbor 2001:db8::12:2 route-server-client
  neighbor 2001:db8::12:3 activate
  neighbor 2001:db8::12:3 route-server-client
 exit-address-family
!
agentx
!

config rr-zebra:
----------------
!
interface rr-eth0
 ip address 192.168.12.4/24
 ipv6 address 2001:db8::12:4/64
!

Fixes: 2d8fff6b81bb ("bgpd: Implement BGP4V2-MIB(bgp4V2PeerErrorsTable)")
Signed-off-by: Dmytro Shytyi <dmytro.shytyi@6wind.com>
(cherry picked from commit d53460554552c288831524c60dd98c303cba7c26)

8 months agoMerge pull request #16618 from FRRouting/mergify/bp/stable/10.0/pr-16608
Jafar Al-Gharaibeh [Thu, 22 Aug 2024 04:00:20 +0000 (00:00 -0400)]
Merge pull request #16618 from FRRouting/mergify/bp/stable/10.0/pr-16608

bgpd: fix crash at no rpki (backport #16608)

8 months agobgpd: fix crash at no rpki 16618/head
Louis Scalbert [Tue, 20 Aug 2024 08:33:30 +0000 (10:33 +0200)]
bgpd: fix crash at no rpki

When 'no rpki' is requested and the rtrlib RPKI object was freed, bgpd
is crashing.

RPKI is configured in VRF red.

> ip l set red down
> ip l del red
> printf 'conf\n vrf red\n no rpki' | vtysh

> Core was generated by `/usr/bin/bgpd -A 127.0.0.1 -M snmp -M rpki -M bmp'.
> Program terminated with signal SIGSEGV, Segmentation fault.
> #0  __pthread_kill_implementation (no_tid=0, signo=11, threadid=140411103615424) at ./nptl/pthread_kill.c:44
> 44 ./nptl/pthread_kill.c: No such file or directory.
> [Current thread is 1 (Thread 0x7fb401f419c0 (LWP 190226))]
> (gdb) bt
> #0  __pthread_kill_implementation (no_tid=0, signo=11, threadid=140411103615424) at ./nptl/pthread_kill.c:44
> #1  __pthread_kill_internal (signo=11, threadid=140411103615424) at ./nptl/pthread_kill.c:78
> #2  __GI___pthread_kill (threadid=140411103615424, signo=signo@entry=11) at ./nptl/pthread_kill.c:89
> #3  0x00007fb4021ad476 in __GI_raise (sig=11) at ../sysdeps/posix/raise.c:26
> #4  0x00007fb4025ce22b in core_handler (signo=11, siginfo=0x7fff831b2d70, context=0x7fff831b2c40) at lib/sigevent.c:248
> #5  <signal handler called>
> #6  rtr_mgr_remove_group (config=0x55fe8789f750, preference=11) at /build/make-pkg/output/source/DIST_RTRLIB/rtrlib/rtrlib/rtr_mgr.c:607
> #7  0x00007fb40145f518 in rpki_delete_all_cache_nodes (rpki_vrf=0x55fe8789f4f0) at bgpd/bgp_rpki.c:442
> #8  0x00007fb401463098 in no_rpki_magic (self=0x7fb40146bba0 <no_rpki_cmd>, vty=0x55fe877f5130, argc=2, argv=0x55fe877fccd0) at bgpd/bgp_rpki.c:1732
> #9  0x00007fb40145c09a in no_rpki (self=0x7fb40146bba0 <no_rpki_cmd>, vty=0x55fe877f5130, argc=2, argv=0x55fe877fccd0) at ./bgpd/bgp_rpki_clippy.c:37
> #10 0x00007fb402527abc in cmd_execute_command_real (vline=0x55fe877fd150, vty=0x55fe877f5130, cmd=0x0, up_level=0) at lib/command.c:984
> #11 0x00007fb402527c35 in cmd_execute_command (vline=0x55fe877fd150, vty=0x55fe877f5130, cmd=0x0, vtysh=0) at lib/command.c:1043
> #12 0x00007fb4025281e5 in cmd_execute (vty=0x55fe877f5130, cmd=0x55fe877fb8c0 "no rpki\n", matched=0x0, vtysh=0) at lib/command.c:1209
> #13 0x00007fb4025f0aed in vty_command (vty=0x55fe877f5130, buf=0x55fe877fb8c0 "no rpki\n") at lib/vty.c:615
> #14 0x00007fb4025f2a11 in vty_execute (vty=0x55fe877f5130) at lib/vty.c:1378
> #15 0x00007fb4025f513d in vtysh_read (thread=0x7fff831b5fa0) at lib/vty.c:2373
> #16 0x00007fb4025e9611 in event_call (thread=0x7fff831b5fa0) at lib/event.c:2011
> #17 0x00007fb402566976 in frr_run (master=0x55fe871a14a0) at lib/libfrr.c:1212
> #18 0x000055fe857829fa in main (argc=9, argv=0x7fff831b6218) at bgpd/bgp_main.c:549

Fixes: 8156765abe ("bgpd: Add `no rpki` command")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
(cherry picked from commit 4e053d65f1c7edbcc3391026300388513d4c31b0)

8 months agoMerge pull request #16561 from FRRouting/mergify/bp/stable/10.0/pr-16554
Donald Sharp [Tue, 13 Aug 2024 12:45:42 +0000 (08:45 -0400)]
Merge pull request #16561 from FRRouting/mergify/bp/stable/10.0/pr-16554

zebra: Ensure non-equal id's are not same nhg's (backport #16554)

8 months agoMerge pull request #16565 from FRRouting/mergify/bp/stable/10.0/pr-16545
Donald Sharp [Tue, 13 Aug 2024 12:44:59 +0000 (08:44 -0400)]
Merge pull request #16565 from FRRouting/mergify/bp/stable/10.0/pr-16545

isisd: fix memory handling in isis_adj_process_threeway() (backport #16545)

8 months agoMerge pull request #16569 from FRRouting/mergify/bp/stable/10.0/pr-16551
Donald Sharp [Tue, 13 Aug 2024 12:44:49 +0000 (08:44 -0400)]
Merge pull request #16569 from FRRouting/mergify/bp/stable/10.0/pr-16551

lib: fix distribute-list deletion (backport #16551)

8 months agolib: fix distribute-list deletion 16569/head
Igor Ryzhov [Fri, 9 Aug 2024 22:32:55 +0000 (01:32 +0300)]
lib: fix distribute-list deletion

When a whole distribute-list is deleted (can be done only using API),
all its children must be cleaned up manually.

Fixes #16538

Signed-off-by: Igor Ryzhov <idryzhov@gmail.com>
(cherry picked from commit 8fad4f317ebd3de7677d7600e7a024f713b20d70)

8 months agoisisd: fix memory handling in isis_adj_process_threeway() 16565/head
Mark Stapp [Fri, 9 Aug 2024 14:08:21 +0000 (10:08 -0400)]
isisd: fix memory handling in isis_adj_process_threeway()

The adj_process_threeway() api may call the adj_state_change()
api, which may delete the adj struct being examined. Change the
signature so that callers pass a ptr-to-ptr so that they will
see that deletion.

Signed-off-by: Mark Stapp <mjs@cisco.com>
(cherry picked from commit 3eb7d1641166872591554519607483f6d77657f5)

8 months agozebra: Ensure non-equal id's are not same nhg's 16561/head
Donald Sharp [Sat, 10 Aug 2024 23:43:08 +0000 (19:43 -0400)]
zebra: Ensure non-equal id's are not same nhg's

The function zebra_nhg_hash_equal is only used
as a hash function for storage of NHG's and retrieval.
If you have say two nhg's:

31 (25/26)
32 (25/26)

This function would return them as being equal.  Which
of course leads to the problem when you attempt to
hash_release 32 but release 31 from the hash.  Then later
when you attempt to do hash comparisons 32 has actually
been freed leaving to use after free situations and shit
goes down hill fast.

This hash is only used as part of the hash comparison
function for nexthop group storage.  Since this is so
let's always return the 31/32 nhg's are not equal at all.

We possibly have a different problem where we are creating
31 and 32 ( when 31 should have just been used instead of 32 )
but we need to prevent any type of hash release problem at all.
This supercedes any other issue( that should be tracked down
on it's own ).  Since you can have use after free situation
that leads to a crash -vs- some possible nexthop group duplication
which is very minor in comparison.

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

8 months agoMerge pull request #16553 from FRRouting/mergify/bp/stable/10.0/pr-16529
Donald Sharp [Sat, 10 Aug 2024 23:49:53 +0000 (19:49 -0400)]
Merge pull request #16553 from FRRouting/mergify/bp/stable/10.0/pr-16529

mgmtd: don't add implicit state data when reading config from file (backport #16529)

8 months agomgmtd: don't add implicit state data when reading config from file 16553/head
Igor Ryzhov [Wed, 7 Aug 2024 21:40:51 +0000 (00:40 +0300)]
mgmtd: don't add implicit state data when reading config from file

When mgmt reads configuration from file, it shouldn't add implicit state
data to the candidate datastore. Configuration datastores like candidate
should never store state, otherwise they fail validation.

Fixes #15814

Signed-off-by: Igor Ryzhov <idryzhov@gmail.com>
(cherry picked from commit 61e8d5e0b9f0ccb7647a04974f7134ede67fedd8)

8 months agoMerge pull request #16541 from FRRouting/mergify/bp/stable/10.0/pr-16531
Donald Sharp [Fri, 9 Aug 2024 00:40:34 +0000 (20:40 -0400)]
Merge pull request #16541 from FRRouting/mergify/bp/stable/10.0/pr-16531

ripd: fix show run output for distribute-list (backport #16531)

8 months agoripd: fix show run output for distribute-list 16541/head
Igor Ryzhov [Wed, 7 Aug 2024 22:25:02 +0000 (01:25 +0300)]
ripd: fix show run output for distribute-list

CLI show callbacks should be defined in frr_ripd_cli_info instead of
frr_ripd_info, because only the former is loaded by mgmtd and only its
callbacks are getting called for config output.

Signed-off-by: Igor Ryzhov <idryzhov@gmail.com>
(cherry picked from commit 25d94ec3eedca978ce7c37359105b0518dcf0f5f)

8 months agoMerge pull request #16537 from FRRouting/mergify/bp/stable/10.0/pr-16530
Donald Sharp [Thu, 8 Aug 2024 16:19:00 +0000 (12:19 -0400)]
Merge pull request #16537 from FRRouting/mergify/bp/stable/10.0/pr-16530

lib: fix crash on distribute-list delete (backport #16530)

8 months agolib: fix crash on distribute-list delete 16537/head
Igor Ryzhov [Wed, 7 Aug 2024 22:17:11 +0000 (01:17 +0300)]
lib: fix crash on distribute-list delete

The destroy callback must be executed only once on APPLY stage.

Fixes #16528

Signed-off-by: Igor Ryzhov <idryzhov@gmail.com>
(cherry picked from commit 2b12d62e38bf41648b2703b5a5c48e47eb01edc7)

8 months agoMerge pull request #16503 from FRRouting/mergify/bp/stable/10.0/pr-16497
Donald Sharp [Wed, 31 Jul 2024 16:33:58 +0000 (12:33 -0400)]
Merge pull request #16503 from FRRouting/mergify/bp/stable/10.0/pr-16497

bgpd: Check the actual remaining stream length before taking TLV value (backport #16497)

8 months agobgpd: Check the actual remaining stream length before taking TLV value 16503/head
Donatas Abraitis [Wed, 31 Jul 2024 05:35:14 +0000 (08:35 +0300)]
bgpd: Check the actual remaining stream length before taking TLV value

```
    0 0xb50b9f898028 in __sanitizer_print_stack_trace (/home/ubuntu/frr-public/frr_public_private-libfuzzer/bgpd/.libs/bgpd+0x368028) (BuildId: 3292703ed7958b20076550c967f879db8dc27ca7)
    1 0xb50b9f7ed8e4 in fuzzer::PrintStackTrace() (/home/ubuntu/frr-public/frr_public_private-libfuzzer/bgpd/.libs/bgpd+0x2bd8e4) (BuildId: 3292703ed7958b20076550c967f879db8dc27ca7)
    2 0xb50b9f7d4d9c in fuzzer::Fuzzer::CrashCallback() (/home/ubuntu/frr-public/frr_public_private-libfuzzer/bgpd/.libs/bgpd+0x2a4d9c) (BuildId: 3292703ed7958b20076550c967f879db8dc27ca7)
    3 0xe0d12d7469cc  (linux-vdso.so.1+0x9cc) (BuildId: 1a77697e9d723fe22246cfd7641b140c427b7e11)
    4 0xe0d12c88f1fc in __pthread_kill_implementation nptl/pthread_kill.c:43:17
    5 0xe0d12c84a678 in gsignal signal/../sysdeps/posix/raise.c:26:13
    6 0xe0d12c83712c in abort stdlib/abort.c:79:7
    7 0xe0d12d214724 in _zlog_assert_failed /home/ubuntu/frr-public/frr_public_private-libfuzzer/lib/zlog.c:789:2
    8 0xe0d12d1285e4 in stream_get /home/ubuntu/frr-public/frr_public_private-libfuzzer/lib/stream.c:324:3
    9 0xb50b9f8e47c4 in bgp_attr_encap /home/ubuntu/frr-public/frr_public_private-libfuzzer/bgpd/bgp_attr.c:2758:3
    10 0xb50b9f8dcd38 in bgp_attr_parse /home/ubuntu/frr-public/frr_public_private-libfuzzer/bgpd/bgp_attr.c:3783:10
    11 0xb50b9faf74b4 in bgp_update_receive /home/ubuntu/frr-public/frr_public_private-libfuzzer/bgpd/bgp_packet.c:2383:20
    12 0xb50b9faf1dcc in bgp_process_packet /home/ubuntu/frr-public/frr_public_private-libfuzzer/bgpd/bgp_packet.c:4075:11
    13 0xb50b9f8c90d0 in LLVMFuzzerTestOneInput /home/ubuntu/frr-public/frr_public_private-libfuzzer/bgpd/bgp_main.c:582:3
```

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

9 months agoMerge pull request #16477 from FRRouting/mergify/bp/stable/10.0/pr-16472
Donald Sharp [Fri, 26 Jul 2024 11:33:36 +0000 (07:33 -0400)]
Merge pull request #16477 from FRRouting/mergify/bp/stable/10.0/pr-16472

pimd: Fix msdp setting of sa->rp (backport #16472)

9 months agoMerge pull request #16380 from FRRouting/mergify/bp/stable/10.0/pr-16350
Jafar Al-Gharaibeh [Thu, 25 Jul 2024 20:59:40 +0000 (16:59 -0400)]
Merge pull request #16380 from FRRouting/mergify/bp/stable/10.0/pr-16350

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

9 months agopimd: Fix msdp setting of sa->rp 16477/head
Donald Sharp [Thu, 25 Jul 2024 11:50:32 +0000 (07:50 -0400)]
pimd: Fix msdp setting of sa->rp

The code is clearly incorrect.  After consultation with
the original author this is the decided change.

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

9 months agoMerge pull request #16459 from FRRouting/mergify/bp/stable/10.0/pr-16451
Donatas Abraitis [Thu, 25 Jul 2024 10:25:06 +0000 (13:25 +0300)]
Merge pull request #16459 from FRRouting/mergify/bp/stable/10.0/pr-16451

lib: mgmtd: fix too early daemon detach of mgmtd (backport #16451)

9 months agolib: mgmtd: fix too early daemon detach of mgmtd 16459/head
Christian Hopps [Tue, 23 Jul 2024 21:42:07 +0000 (17:42 -0400)]
lib: mgmtd: fix too early daemon detach of mgmtd

Correct FRR startup counts on a daemon's vty socket to be open when the
parent process exits. The parent process waits for `frr_check_detach()`
to be called by the child before exiting. The problem is when the
`FRR_MANUAL_VTY_START` flag is set the vty socket was not opened but
`frr_check_detach()` was called anyway.

Instead add a bool option for `frr_check_detach()` to be called when the
socket is opened with `frr_vty_serv_start()`, and do so when "manually"
calling said function (i.e., when FRR_MANUAL_VTY_START is set).

The `FRR_MANUAL_VTY_START` flag is only set by mgmtd. The reason we
wait to open the vty socket is so that mgmtd can parse the various
daemon specific config files it has taken over, after the event loop has
started, but before we receive any possible new config from `vtysh`.

fixes #16362

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

9 months agoMerge pull request #16454 from FRRouting/mergify/bp/stable/10.0/pr-16428
Donald Sharp [Wed, 24 Jul 2024 14:20:45 +0000 (10:20 -0400)]
Merge pull request #16454 from FRRouting/mergify/bp/stable/10.0/pr-16428

yang: Added missed prefix to the frr-deviations-ietf-routing yang file (backport #16428)

9 months agoyang: Added missed prefix to the yang file 16454/head
Y Bharath [Mon, 22 Jul 2024 11:17:54 +0000 (16:47 +0530)]
yang: Added missed prefix to the yang file

Corrected warning by including the module

Signed-off-by: y-bharath14 <y.bharath@samsung.com>
(cherry picked from commit ed832b70ec0ea7ad0cf22a844de2151592b5b0e8)

9 months agoMerge pull request #16444 from FRRouting/mergify/bp/stable/10.0/pr-16376
Russ White [Tue, 23 Jul 2024 21:52:48 +0000 (17:52 -0400)]
Merge pull request #16444 from FRRouting/mergify/bp/stable/10.0/pr-16376

ospfd: fix internal ldp-sync state flags when feature is disabled (backport #16376)

9 months agoospfd: fix internal ldp-sync state flags when feature is disabled 16444/head
Christian Breunig [Sat, 13 Jul 2024 06:43:36 +0000 (08:43 +0200)]
ospfd: fix internal ldp-sync state flags when feature is disabled

When enabling "mpls ldp-sync" under "router ospf" ospfd configures
SET_FLAG(ldp_sync_info->flags, LDP_SYNC_FLAG_IF_CONFIG) so internally knowing
that the ldp-sync feature is enabled. However the flag is not cleared when
turning of the feature using "nompls ldp-sync"!

https://github.com/FRRouting/frr/issues/16375

Signed-off-by: Christian Breunig <christian@breunig.cc>
(cherry picked from commit 5a70378a47f541b0354fbb96770dd0a65ec552b8)

9 months agoMerge pull request #16431 from FRRouting/mergify/bp/stable/10.0/pr-16429
Donald Sharp [Tue, 23 Jul 2024 14:45:25 +0000 (10:45 -0400)]
Merge pull request #16431 from FRRouting/mergify/bp/stable/10.0/pr-16429

lib: move non-error from __log_err to __dbg (backport #16429)

9 months agoMerge pull request #16434 from FRRouting/mergify/bp/stable/10.0/pr-16309
Donald Sharp [Tue, 23 Jul 2024 14:44:58 +0000 (10:44 -0400)]
Merge pull request #16434 from FRRouting/mergify/bp/stable/10.0/pr-16309

pimd: fix crash on non-existent interface (backport #16309)

9 months agopimd: fix crash on non-existent interface 16434/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 agolib: move non-error from __log_err to __dbg 16431/head
Christian Hopps [Mon, 22 Jul 2024 11:52:10 +0000 (07:52 -0400)]
lib: move non-error from __log_err to __dbg

Additionally, print `errmsg_if_any` in successful debug messages
if non-NULL.

fixes #16386 #16043

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

9 months agoMerge pull request #16396 from FRRouting/mergify/bp/stable/10.0/pr-16365
Donatas Abraitis [Sat, 20 Jul 2024 08:45:54 +0000 (01:45 -0700)]
Merge pull request #16396 from FRRouting/mergify/bp/stable/10.0/pr-16365

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

9 months agoisisd: fix crash when calculating the neighbor spanning tree based on the fragmented LSP 16396/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 #16388 from FRRouting/mergify/bp/stable/10.0/pr-16373
Jafar Al-Gharaibeh [Tue, 16 Jul 2024 13:56:22 +0000 (09:56 -0400)]
Merge pull request #16388 from FRRouting/mergify/bp/stable/10.0/pr-16373

staticd: fix missing static routes (backport #16373)

9 months agozebra: fix missing static routes 16388/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 agozebra: Fix to avoid two Vrfs with same table ids 16380/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 agoMerge pull request #16329 from FRRouting/mergify/bp/stable/10.0/pr-16303
Donald Sharp [Wed, 3 Jul 2024 13:37:36 +0000 (09:37 -0400)]
Merge pull request #16329 from FRRouting/mergify/bp/stable/10.0/pr-16303

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

9 months agoMerge pull request #16336 from FRRouting/mergify/bp/stable/10.0/pr-16226
Donatas Abraitis [Wed, 3 Jul 2024 09:57:21 +0000 (11:57 +0200)]
Merge pull request #16336 from FRRouting/mergify/bp/stable/10.0/pr-16226

ldpd: fix wrong gtsm count (backport #16226)

9 months agoMerge pull request #16313 from FRRouting/mergify/bp/stable/10.0/pr-16305
Jafar Al-Gharaibeh [Tue, 2 Jul 2024 20:56:19 +0000 (16:56 -0400)]
Merge pull request #16313 from FRRouting/mergify/bp/stable/10.0/pr-16305

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

9 months agoMerge pull request #16327 from FRRouting/mergify/bp/stable/10.0/pr-15716
Jafar Al-Gharaibeh [Tue, 2 Jul 2024 20:55:29 +0000 (16:55 -0400)]
Merge pull request #16327 from FRRouting/mergify/bp/stable/10.0/pr-15716

isisd: Fix memory leaks when the transition of neighbor state from non-UP to DOWN (backport #15716)

9 months agoldpd: fix wrong gtsm count 16336/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 16329/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 #16319 from FRRouting/mergify/bp/stable/10.0/pr-16233
Russ White [Tue, 2 Jul 2024 11:59:41 +0000 (07:59 -0400)]
Merge pull request #16319 from FRRouting/mergify/bp/stable/10.0/pr-16233

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

9 months agoisisd: Fix memory leaks when the transition of neighbor state from non-UP to DOWN 16327/head
zhou-run [Tue, 9 Apr 2024 13:04:39 +0000 (21:04 +0800)]
isisd: Fix memory leaks when the transition of neighbor state from non-UP to DOWN

When receiving a hello packet, if the neighbor state transitions directly from a non-ISIS_ADJ_UP state (such as ISIS_ADJ_INITIALIZING) to ISIS_ADJ_DOWN state, the neighbor entry cannot be deleted. If the neighbor is removed or the neighbor's System ID changes, it may result in memory leakage in the neighbor entry.

Test Scenario:
LAN link between Router A and Router B is established. Router A does not configure neighbor authentication, while Router B is configured with neighbor authentication. When the neighbor entry on Router B ages out, the neighbor state on Router A transitions to INIT. If Router B is then removed, the neighbor state on Router A transitions to DOWN and persists.

Signed-off-by: zhou-run <166502045+zhou-run@users.noreply.github.com>
fix frrbot styling issues found.

fix frrbot styling issues found.

Signed-off-by: zhou-run <166502045+zhou-run@users.noreply.github.com>
(cherry picked from commit 5009f7539ad6bf496158499917dcf3f7ab760753)

9 months agoripd: Change the start value of sequence 1 to 0 16319/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 16313/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)

10 months agoMerge pull request #16283 from FRRouting/mergify/bp/stable/10.0/pr-15838
Russ White [Tue, 25 Jun 2024 11:31:50 +0000 (07:31 -0400)]
Merge pull request #16283 from FRRouting/mergify/bp/stable/10.0/pr-15838

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

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

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

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

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

10 months agoMerge pull request #16282 from FRRouting/mergify/bp/stable/10.0/pr-16213
Russ White [Tue, 25 Jun 2024 11:29:54 +0000 (07:29 -0400)]
Merge pull request #16282 from FRRouting/mergify/bp/stable/10.0/pr-16213

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

10 months agobgpd: Check if we have real stream data for tunnel encapsulation sub-tlvs 16292/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 16290/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 #16279 from FRRouting/mergify/bp/stable/10.0/pr-16211
Donatas Abraitis [Tue, 25 Jun 2024 10:48:05 +0000 (13:48 +0300)]
Merge pull request #16279 from FRRouting/mergify/bp/stable/10.0/pr-16211

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

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

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

10 months agoMerge pull request #16268 from louis-6wind/show-isis-database-crash-bp
Russ White [Mon, 24 Jun 2024 21:18:26 +0000 (17:18 -0400)]
Merge pull request #16268 from louis-6wind/show-isis-database-crash-bp

isisd: fix crash when displaying asla in json

10 months agotests: improve tests for aspath exclude and bgp access list 16283/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 agobgpd: Check if we have really enough data before doing memcpy for FQDN capability 16282/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 16279/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 16275/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)