]> git.puffer.fish Git - mirror/frr.git/log
mirror/frr.git
10 months agoFRR Release 8.5.5 rc/8.5 docker/8.5.5 frr-8.5.5
Jafar Al-Gharaibeh [Thu, 6 Jun 2024 15:47:50 +0000 (10:47 -0500)]
FRR Release 8.5.5

Changelog:

bgpd
    "default-originate" shouldn't withdraw non-default routes
    Ensure community data is freed in some cases.
    Ensure that the correct aspath is free'd
    Fix error handling when receiving bgp prefix sid attribute
    Fix format overflow for graceful-restart debug logs
    Fix null argument warning
    Include unsuppress-map as a valid outgoing policy
    Make `suppress-fib-pending` clear peering
    Prevent from one more cve triggering this place

doc
    Add param range for graceful-restart helper supported-grace-time

isisd
    Fix heap-after-free with prefix sid
    Need to link directly against libyang

lib
    Check for not being a blackhole route
    Do not convert evpn prefixes into ipv4/ipv6 if not needed

nhrpd
    Fix nhrp_peer leak
    Fix race condition
    Fix core dump on shutdown

ospf6d
    Ospfv3 route change comparision fixed for asbr-only change
    Prevent heap-buffer-overflow with unknown type

ospfd
    Correct opaque lsa extended parser
    Fix ospf dead-interval minimal hello-multiplier param range
    Fix the bug where ip_ospf_dead-interval_minimal_hello-multiplier did not reset hello timer
    Protect call to get_edge() in ospf_te.c
    Solved crash in ri parsing with ospf te

pbrd
    Fix pbr handling for last rule deletion

pimd
    Fix crash unconfiguring rp keepalive timer
    Fix crash when configuring ssmpingd
    Fix dr-priority range
    Fix null register before aging out reg-stop
    Fix order of operations for evaluating join
    Re-evaluated s,g oils upon rp changes and for empty sg upstream oils
    Fix crash when mixing ssm/any-source joins

tests
    Check for 0.0.0.0/1 in bgp_default_route

vtysh
    Show `ip ospf network ...` even if it's not the same as the interface type

zebra
    Deny the routes if ip protocol cli refers to an undefined rmap
    Fix crash if macvlan link in another netns
    Fix nhg out of sync between zebra and kernel
    Re-install dependent nhgs on interface up
    Re-install nhg on interface up
    The dplane_fpm_nl return path leaks memory

Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
10 months agoMerge pull request #16173 from Jafaral/nhrp-8.5
Donald Sharp [Thu, 6 Jun 2024 15:02:18 +0000 (11:02 -0400)]
Merge pull request #16173 from Jafaral/nhrp-8.5

[8.5] nhrp: backport fixes #16141 and #16166

10 months agonhrpd: Fix nhrp_peer leak 16173/head
Keelan10 [Wed, 5 Jun 2024 10:34:18 +0000 (13:34 +0300)]
nhrpd: Fix nhrp_peer leak

- Addressed memory leak by removing `&c->peer_notifier` from the notifier list on termination. Retaining it caused the notifier list to stay active, preventing the deletion of `c->cur.peer`
  thereby causing a memory leak.

- Reordered termination steps to call `vrf_terminate` before `nhrp_vc_terminate`, preventing a heap-use-after-free issue when `nhrp_vc_notify_del` is invoked in `nhrp_peer_check_delete`.

- Added an if statement to avoid passing NULL as hash to `hash_release`, which leads to a SIGSEGV.

The ASan leak log for reference:

```
***********************************************************************************
Address Sanitizer Error detected in nhrp_topo.test_nhrp_topo/r1.asan.nhrpd.20265

=================================================================
==20265==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 112 byte(s) in 1 object(s) allocated from:
    #0 0x7f80270c9b40 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb40)
    #1 0x7f8026ac1eb8 in qmalloc lib/memory.c:100
    #2 0x560fd648f0a6 in nhrp_peer_create nhrpd/nhrp_peer.c:175
    #3 0x7f8026a88d3f in hash_get lib/hash.c:147
    #4 0x560fd6490a5d in nhrp_peer_get nhrpd/nhrp_peer.c:228
    #5 0x560fd648a51a in nhrp_nhs_resolve_cb nhrpd/nhrp_nhs.c:297
    #6 0x7f80266b000f in resolver_cb_literal lib/resolver.c:234
    #7 0x7f8026b62e0e in event_call lib/event.c:1969
    #8 0x7f8026aa5437 in frr_run lib/libfrr.c:1213
    #9 0x560fd6488b4f in main nhrpd/nhrp_main.c:166
    #10 0x7f8025eb2c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

SUMMARY: AddressSanitizer: 112 byte(s) leaked in 1 allocation(s).
***********************************************************************************

***********************************************************************************
Address Sanitizer Error detected in nhrp_topo.test_nhrp_topo/r2.asan.nhrpd.20400

=================================================================
==20400==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 112 byte(s) in 1 object(s) allocated from:
    #0 0x7fb6e3ca5b40 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb40)
    #1 0x7fb6e369deb8 in qmalloc lib/memory.c:100
    #2 0x562652de40a6 in nhrp_peer_create nhrpd/nhrp_peer.c:175
    #3 0x7fb6e3664d3f in hash_get lib/hash.c:147
    #4 0x562652de5a5d in nhrp_peer_get nhrpd/nhrp_peer.c:228
    #5 0x562652de1e8e in nhrp_packet_recvraw nhrpd/nhrp_packet.c:325
    #6 0x7fb6e373ee0e in event_call lib/event.c:1969
    #7 0x7fb6e3681437 in frr_run lib/libfrr.c:1213
    #8 0x562652dddb4f in main nhrpd/nhrp_main.c:166
    #9 0x7fb6e2a8ec86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

SUMMARY: AddressSanitizer: 112 byte(s) leaked in 1 allocation(s).
***********************************************************************************
```

Signed-off-by: Keelan Cannoo <keelan.cannoo@icloud.com>
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
10 months agonhrpd: core dump on shutdown backport fix
Dave LeRoy [Fri, 31 May 2024 17:05:10 +0000 (10:05 -0700)]
nhrpd: core dump on shutdown backport fix

This fixes a merge conflict encountered when backporting PR 15879

Signed-off-by: Dave LeRoy <dleroy@labn.net>
10 months agoMerge pull request #16147 from FRRouting/mergify/bp/stable/8.5/pr-14429
Donatas Abraitis [Mon, 3 Jun 2024 05:22:59 +0000 (08:22 +0300)]
Merge pull request #16147 from FRRouting/mergify/bp/stable/8.5/pr-14429

ospf6d: fix uninitialized warnings (backport #14429)

10 months agoospf6d: fix uninitialized warnings 16147/head
David Lamparter [Sat, 16 Sep 2023 12:17:24 +0000 (14:17 +0200)]
ospf6d: fix uninitialized warnings

GCC 13.2.0 complains:

```
ospf6d/ospf6_intra.c:139:25: error: ‘json_arr’ may be used uninitialized [-Werror=maybe-uninitialized]
ospf6d/ospf6_intra.c:485:20: error: ‘json_arr’ may be used uninitialized [-Werror=maybe-uninitialized]
```

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
(cherry picked from commit 55bbef1356418168833fba98d3e7d4691f8f1408)

10 months agoMerge pull request #16137 from FRRouting/mergify/bp/stable/8.5/pr-16111
Donald Sharp [Sat, 1 Jun 2024 14:04:10 +0000 (10:04 -0400)]
Merge pull request #16137 from FRRouting/mergify/bp/stable/8.5/pr-16111

ospf6d: Prevent heap-buffer-overflow with unknown type (backport #16111)

10 months agoMerge pull request #16130 from FRRouting/mergify/bp/stable/8.5/pr-16115
Jafar Al-Gharaibeh [Sat, 1 Jun 2024 03:48:09 +0000 (22:48 -0500)]
Merge pull request #16130 from FRRouting/mergify/bp/stable/8.5/pr-16115

pimd: fix crash when mixing ssm/any-source joins (backport #16115)

10 months agoospf6d: Prevent heap-buffer-overflow with unknown type 16137/head
Iggy Frankovic [Thu, 30 May 2024 11:59:54 +0000 (07:59 -0400)]
ospf6d: Prevent heap-buffer-overflow with unknown type

When parsing a osf6 grace lsa field and we receive an
unknown tlv type, ospf6d was not incrementing the pointer
to get beyond the tlv.  Leaving a situation where ospf6d
would parse the packet incorrectly.

Signed-off-by: Iggy Frankovic <iggy07@gmail.com>
(cherry picked from commit 826f2510e67711045e52cf4b5e3ddef514ed556e)

10 months agopimd: fix crash when mixing ssm/any-source joins 16130/head
Jafar Al-Gharaibeh [Thu, 30 May 2024 17:46:47 +0000 (12:46 -0500)]
pimd: fix crash when mixing ssm/any-source joins

There is no reason to call `igmp_anysource_forward_stop()` inside a call to
`igmp_get_source_by_addr()`; not only it is not expected for a "get" function
to perform such an action, but also the decision to start/stop forwarding is
already handled correctly by pim outside `igmp_get_source_by_addr()`.
That call was left there from the days pim was initially imported into the sources.

The problem/crash was happening because `igmp_find_source_by_addr()` would fail to
find the group/source combo when mixing `(*, G)` and `(S, G)`. When having an existing
flow `(*, G)`, and a new `(S, G)` igmp is received, a new entry is correctly created.
`igmp_anysource_forward_stop(group)` always stops and eventually frees `(*, G)`, even
when the new igmp is `(S, G)`, leaving a bad state. I.e, the new entry for `(S, G)`
causes `(*, G)` to be deleted.

Tested the fix with multiple receivers on the same interface with several ssm and
any source senders and receivers with various combination of start/stop orders and
they all worked correctly.

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

10 months agoMerge pull request #16114 from FRRouting/mergify/bp/stable/8.5/pr-13783
Donatas Abraitis [Fri, 31 May 2024 13:11:24 +0000 (16:11 +0300)]
Merge pull request #16114 from FRRouting/mergify/bp/stable/8.5/pr-13783

GCC13 nits (backport #13783)

10 months agobgpd: Use enum bgp_create_error_code as argument in header 16114/head
Donatas Abraitis [Tue, 13 Jun 2023 13:08:24 +0000 (16:08 +0300)]
bgpd: Use enum bgp_create_error_code as argument in header

```
bgpd/bgp_vty.c:865:5: warning: conflicting types for ‘bgp_vty_return’ due to enum/integer mismatch; have ‘int(struct vty *, enum bgp_create_error_code)’ [-Wenum-int-mismatch]
  865 | int bgp_vty_return(struct vty *vty, enum bgp_create_error_code ret)
      |     ^~~~~~~~~~~~~~
In file included from ./bgpd/bgp_mplsvpn.h:15,
                 from bgpd/bgp_vty.c:48:
./bgpd/bgp_vty.h:148:12: note: previous declaration of ‘bgp_vty_return’ with type ‘int(struct vty *, int)’
  148 | extern int bgp_vty_return(struct vty *vty, int ret);
      |            ^~~~~~~~~~~~~~
```

Fixing stuff regarding GCC13.

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

10 months agobgpd: Use enum bgp_fsm_state_progress for bgp_stop()
Donatas Abraitis [Tue, 13 Jun 2023 13:01:40 +0000 (16:01 +0300)]
bgpd: Use enum bgp_fsm_state_progress for bgp_stop()

```
bgpd/bgp_fsm.c:1360:29: warning: conflicting types for ‘bgp_stop’ due to enum/integer mismatch; have ‘enum bgp_fsm_state_progress(struct peer *)’ [-Wenum-int-mismatch]
 1360 | enum bgp_fsm_state_progress bgp_stop(struct peer *peer)
      |                             ^~~~~~~~
In file included from bgpd/bgp_fsm.c:29:
./bgpd/bgp_fsm.h:111:12: note: previous declaration of ‘bgp_stop’ with type ‘int(struct peer *)’
  111 | extern int bgp_stop(struct peer *peer);
      |            ^~~~~~~~
```

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

11 months agoMerge pull request #16107 from FRRouting/mergify/bp/stable/8.5/pr-16098
Jafar Al-Gharaibeh [Wed, 29 May 2024 15:56:33 +0000 (10:56 -0500)]
Merge pull request #16107 from FRRouting/mergify/bp/stable/8.5/pr-16098

ospf6d: OSPFv3 route change comparision fixed for ASBR-only change (backport #16098)

11 months agoospf6d: OSPFv3 route change comparision fixed for ASBR-only change 16107/head
Acee [Tue, 28 May 2024 14:02:27 +0000 (10:02 -0400)]
ospf6d: OSPFv3 route change comparision fixed for ASBR-only change

When a router route already exists in the area border routers table
as an ABR and it solely changes its ABR or ASBR status, the change
was missed and border route is not updated. This fixes the comparison
for the router_bits in the ospf6_path structure.

This fixes issue https://github.com/FRRouting/frr/issues/16053 although
the actual problem is not the computing router (r2) and not the OSPFv3
redistribution (r3).

Signed-off-by: Acee <aceelindem@gmail.com>
(cherry picked from commit 772688d2d3c03d8eeeb711c2fe3735c9e0885498)

11 months agoMerge pull request #16096 from opensourcerouting/fix/backport_pr_15674_8.5
Donald Sharp [Wed, 29 May 2024 11:34:11 +0000 (07:34 -0400)]
Merge pull request #16096 from opensourcerouting/fix/backport_pr_15674_8.5

ospfd: Solved crash in RI parsing with OSPF TE (backport #15674)

11 months agoMerge pull request #15873 from opensourcerouting/fix/1ce626aea6f1f274da92478a8e487c22...
Donald Sharp [Wed, 29 May 2024 11:33:42 +0000 (07:33 -0400)]
Merge pull request #15873 from opensourcerouting/fix/1ce626aea6f1f274da92478a8e487c229b08f9ce_8.5

vtysh: Show `ip ospf network ...` even if it's not the same as the interface type

11 months agoospfd: Solved crash in RI parsing with OSPF TE 16096/head
Olivier Dugeon [Wed, 3 Apr 2024 14:28:23 +0000 (16:28 +0200)]
ospfd: Solved crash in RI parsing with OSPF TE

Iggy Frankovic discovered another ospfd crash when performing fuzzing of OSPF
LSA packets. The crash occurs in ospf_te_parse_ri() function when attemping to
read Segment Routing subTLVs. The original code doesn't check if the size of
the SR subTLVs have the correct length. In presence of erronous LSA, this will
cause a buffer overflow and ospfd crash.

This patch introduces new verification of the subTLVs size for Router
Information TLV.

Co-authored-by: Iggy Frankovic <iggyfran@amazon.com>
Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
11 months agoospfd: Correct Opaque LSA Extended parser
Olivier Dugeon [Fri, 5 Apr 2024 10:57:11 +0000 (12:57 +0200)]
ospfd: Correct Opaque LSA Extended parser

Iggy Frankovic discovered another ospfd crash when performing fuzzing of OSPF
LSA packets. The crash occurs in ospf_te_parse_ext_link() function when
attemping to read Segment Routing Adjacency SID subTLVs. The original code
doesn't check if the size of the Extended Link TLVs and subTLVs have the correct
length. In presence of erronous LSA, this will cause a buffer overflow and ospfd
crashes.

This patch introduces new verification of the subTLVs size for Extended Link
TLVs and subTLVs. Similar check has been also introduced for the Extended
Prefix TLV.

Co-authored-by: Iggy Frankovic <iggyfran@amazon.com>
Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
11 months agoospfd: protect call to get_edge() in ospf_te.c
Olivier Dugeon [Tue, 16 Apr 2024 14:42:06 +0000 (16:42 +0200)]
ospfd: protect call to get_edge() in ospf_te.c

During fuzzing, Iggy Frankovic discovered that get_edge() function in ospf_te.c
could return null pointer, in particular when the link_id or advertised router
IP addresses are fuzzed. As the null pointer returned by get_edge() function is
not handlei by calling functions, this could cause ospfd crash.

This patch introduces new verification of returned pointer by get_edge()
function and stop the processing in case of null pointer. In addition, link ID
and advertiser router ID are validated before calling ls_find_edge_by_key() to
avoid the creation of a new edge with an invalid key.

CVE-2024-34088

Co-authored-by: Iggy Frankovic <iggyfran@amazon.com>
Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com>
11 months agoMerge pull request #16080 from FRRouting/mergify/bp/stable/8.5/pr-16021
Donald Sharp [Fri, 24 May 2024 14:28:50 +0000 (10:28 -0400)]
Merge pull request #16080 from FRRouting/mergify/bp/stable/8.5/pr-16021

isisd: fix heap-after-free with prefix sid (backport #16021)

11 months agoisisd: fix heap-after-free with prefix sid 16080/head
Louis Scalbert [Thu, 16 May 2024 14:44:03 +0000 (16:44 +0200)]
isisd: fix heap-after-free with prefix sid

> ==2334217==ERROR: AddressSanitizer: heap-use-after-free on address 0x61000001d0a0 at pc 0x563828c8de6f bp 0x7fffbdaee560 sp 0x7fffbdaee558
> READ of size 1 at 0x61000001d0a0 thread T0
>     #0 0x563828c8de6e in prefix_sid_cmp isisd/isis_spf.c:187
>     #1 0x7f84b8204f71 in hash_get lib/hash.c:142
>     #2 0x7f84b82055ec in hash_lookup lib/hash.c:184
>     #3 0x563828c8e185 in isis_spf_prefix_sid_lookup isisd/isis_spf.c:209
>     #4 0x563828c90642 in isis_spf_add2tent isisd/isis_spf.c:598
>     #5 0x563828c91cd0 in process_N isisd/isis_spf.c:824
>     #6 0x563828c93852 in isis_spf_process_lsp isisd/isis_spf.c:1041
>     #7 0x563828c98dde in isis_spf_loop isisd/isis_spf.c:1821
>     #8 0x563828c998de in isis_run_spf isisd/isis_spf.c:1983
>     #9 0x563828c99c7b in isis_run_spf_with_protection isisd/isis_spf.c:2009
>     #10 0x563828c9a60d in isis_run_spf_cb isisd/isis_spf.c:2090
>     #11 0x7f84b835c72d in event_call lib/event.c:2011
>     #12 0x7f84b8236d93 in frr_run lib/libfrr.c:1217
>     #13 0x563828c21918 in main isisd/isis_main.c:346
>     #14 0x7f84b7e4fd09 in __libc_start_main ../csu/libc-start.c:308
>     #15 0x563828c20df9 in _start (/usr/lib/frr/isisd+0xf5df9)
>
> 0x61000001d0a0 is located 96 bytes inside of 184-byte region [0x61000001d040,0x61000001d0f8)
> freed by thread T0 here:
>     #0 0x7f84b88a9b6f in __interceptor_free ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:123
>     #1 0x7f84b8263bae in qfree lib/memory.c:130
>     #2 0x563828c8e433 in isis_vertex_del isisd/isis_spf.c:249
>     #3 0x563828c91c95 in process_N isisd/isis_spf.c:811
>     #4 0x563828c93852 in isis_spf_process_lsp isisd/isis_spf.c:1041
>     #5 0x563828c98dde in isis_spf_loop isisd/isis_spf.c:1821
>     #6 0x563828c998de in isis_run_spf isisd/isis_spf.c:1983
>     #7 0x563828c99c7b in isis_run_spf_with_protection isisd/isis_spf.c:2009
>     #8 0x563828c9a60d in isis_run_spf_cb isisd/isis_spf.c:2090
>     #9 0x7f84b835c72d in event_call lib/event.c:2011
>     #10 0x7f84b8236d93 in frr_run lib/libfrr.c:1217
>     #11 0x563828c21918 in main isisd/isis_main.c:346
>     #12 0x7f84b7e4fd09 in __libc_start_main ../csu/libc-start.c:308
>
> previously allocated by thread T0 here:
>     #0 0x7f84b88aa037 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
>     #1 0x7f84b8263a6c in qcalloc lib/memory.c:105
>     #2 0x563828c8e262 in isis_vertex_new isisd/isis_spf.c:225
>     #3 0x563828c904db in isis_spf_add2tent isisd/isis_spf.c:588
>     #4 0x563828c91cd0 in process_N isisd/isis_spf.c:824
>     #5 0x563828c93852 in isis_spf_process_lsp isisd/isis_spf.c:1041
>     #6 0x563828c98dde in isis_spf_loop isisd/isis_spf.c:1821
>     #7 0x563828c998de in isis_run_spf isisd/isis_spf.c:1983
>     #8 0x563828c99c7b in isis_run_spf_with_protection isisd/isis_spf.c:2009
>     #9 0x563828c9a60d in isis_run_spf_cb isisd/isis_spf.c:2090
>     #10 0x7f84b835c72d in event_call lib/event.c:2011
>     #11 0x7f84b8236d93 in frr_run lib/libfrr.c:1217
>     #12 0x563828c21918 in main isisd/isis_main.c:346
>     #13 0x7f84b7e4fd09 in __libc_start_main ../csu/libc-start.c:308
>
> SUMMARY: AddressSanitizer: heap-use-after-free isisd/isis_spf.c:187 in prefix_sid_cmp
> Shadow bytes around the buggy address:
>   0x0c207fffb9c0: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
>   0x0c207fffb9d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 fa
>   0x0c207fffb9e0: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
>   0x0c207fffb9f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 fa
>   0x0c207fffba00: fa fa fa fa fa fa fa fa fd fd fd fd fd fd fd fd
> =>0x0c207fffba10: fd fd fd fd[fd]fd fd fd fd fd fd fd fd fd fd fa
>   0x0c207fffba20: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
>   0x0c207fffba30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 fa
>   0x0c207fffba40: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
>   0x0c207fffba50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 fa
>   0x0c207fffba60: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
> Shadow byte legend (one shadow byte represents 8 application bytes):
>   Addressable:           00
>   Partially addressable: 01 02 03 04 05 06 07
>   Heap left redzone:       fa
>   Freed heap region:       fd
>   Stack left redzone:      f1
>   Stack mid redzone:       f2
>   Stack right redzone:     f3
>   Stack after return:      f5
>   Stack use after scope:   f8
>   Global redzone:          f9
>   Global init order:       f6
>   Poisoned by user:        f7
>   Container overflow:      fc
>   Array cookie:            ac
>   Intra object redzone:    bb
>   ASan internal:           fe
>   Left alloca redzone:     ca
>   Right alloca redzone:    cb
>   Shadow gap:              cc
> ==2334217==ABORTING

Fixes: 2f7cc7bcd3 ("isisd: detect Prefix-SID collisions and handle them appropriately")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
(cherry picked from commit e697de58431474cdb06eff79bcbc70de4215e222)

11 months agoMerge pull request #16063 from FRRouting/mergify/bp/stable/8.5/pr-16032
Donald Sharp [Tue, 21 May 2024 18:45:38 +0000 (14:45 -0400)]
Merge pull request #16063 from FRRouting/mergify/bp/stable/8.5/pr-16032

zebra: Deny the routes if ip protocol CLI refers to an undefined rmap (backport #16032)

11 months agozebra: Deny the routes if ip protocol CLI refers to an undefined rmap 16063/head
Pooja Jagadeesh Doijode [Thu, 16 May 2024 23:36:18 +0000 (16:36 -0700)]
zebra: Deny the routes if ip protocol CLI refers to an undefined rmap

Currently zebra does not deny the routes if `ip protocol <proto> route-map
FOO`
commmand is configured with reference to an undefined route-map (FOO in
this case).
However, on FRR restart, in zebra_route_map_check() routes get denied
if route-map name is available but the route-map is not defined. This
change was introduced in fd303a4ba14c762550db972317e1e88528768005.

Fix:
When `ip protocol <proto> route-map FOO` CLI is configured with reference to an
undefined route-map FOO, let the processing in ip_protocol_rm_add() and
ip_protocol_rm_del() go through so that zebra can deny the routes instead
of simply returning. This will result in consistent behavior.

Testing Done:

Before fix:
```
spine-1# configure
spine-1(config)# ip protocol bgp route-map rmap7

root@spine-1:mgmt:/var/home/cumulus# vtysh -c "show run" | grep rmap7
ip protocol bgp route-map rmap7
root@spine-1:mgmt:/var/home/cumulus#

spine-1(config)# do show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, A - Babel, D - SHARP, F - PBR, f - OpenFabric,
       Z - FRR,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

C>* 27.0.0.1/32 is directly connected, lo, 02:27:45
B>* 27.0.0.3/32 [20/0] via fe80::202:ff:fe00:21, downlink_1, weight 1, 02:27:35
B>* 27.0.0.4/32 [20/0] via fe80::202:ff:fe00:29, downlink_2, weight 1, 02:27:40
B>* 27.0.0.5/32 [20/0] via fe80::202:ff:fe00:31, downlink_3, weight 1, 02:27:40
B>* 27.0.0.6/32 [20/0] via fe80::202:ff:fe00:39, downlink_4, weight 1, 02:27:40
```

After fix:
```
spine-1(config)# ip protocol bgp route-map route-map67
spine-1(config)# do show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, A - Babel, D - SHARP, F - PBR, f - OpenFabric,
       Z - FRR,
       > - selected route, * - FIB route, q - queued, r - rejected, b - backup
       t - trapped, o - offload failure

C>* 27.0.0.1/32 is directly connected, lo, 00:35:03
B   27.0.0.3/32 [20/0] via fe80::202:ff:fe00:21, downlink_1 inactive, weight 1, 00:34:58
B   27.0.0.4/32 [20/0] via fe80::202:ff:fe00:29, downlink_2 inactive, weight 1, 00:34:57
B   27.0.0.5/32 [20/0] via fe80::202:ff:fe00:31, downlink_3 inactive, weight 1, 00:34:57
B   27.0.0.6/32 [20/0] via fe80::202:ff:fe00:39, downlink_4 inactive, weight 1, 00:34:58
spine-1(config)#

root@spine-1:mgmt:/var/home/cumulus# ip route show
root@spine-1:mgmt:/var/home/cumulus#
```

Signed-off-by: Pooja Jagadeesh Doijode <pdoijode@nvidia.com>
(cherry picked from commit 705e8ef78f84dea3af5943a74571f968ad076c8d)

11 months agoMerge pull request #15990 from Jafaral/pim-fixes
Donatas Abraitis [Sat, 11 May 2024 11:55:49 +0000 (14:55 +0300)]
Merge pull request #15990 from Jafaral/pim-fixes

pimd: fixes split off from #15969 (backport #15975)

11 months agopimd: fix order of operations for evaluating join 15990/head
David Lamparter [Mon, 12 Dec 2022 16:50:59 +0000 (17:50 +0100)]
pimd: fix order of operations for evaluating join

join_desired looks at whether up->channel_oil is empty.  up->channel_oil
is updated from pim_forward_stop(), calling pim_channel_del_oif().  But
that was being called *after* updating join_desired, so join_desired saw
a non-empty OIL.  Pull up the pim_forward_stop() call to before updating
join_desired.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
(cherry picked from commit fdb1a6fed5a8e42447b5b9633ad9df0f3042d0a9)

11 months agopimd: fix null register before aging out reg-stop
David Lamparter [Mon, 17 Apr 2023 09:47:08 +0000 (11:47 +0200)]
pimd: fix null register before aging out reg-stop

It looks like the code was trying to do this with the null_register
parameter on pim_upstream_start_register_stop_timer(), but that didn't
quite work right.  Restructure a bit to get it right.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
(cherry picked from commit dce38da8061a7ac62c690dbb8a89cae7f9a758d6)

# Conflicts:
# pimd/pim_upstream.c

11 months agopimd: fix dr-priority range
David Lamparter [Fri, 14 Apr 2023 15:17:27 +0000 (17:17 +0200)]
pimd: fix dr-priority range

0 is a valid DR priority.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
(cherry picked from commit b564c1d890aef75067db22df09e608faf72b99f5)

11 months agoMerge pull request #15955 from FRRouting/mergify/bp/stable/8.5/pr-15846
Donatas Abraitis [Fri, 10 May 2024 11:00:51 +0000 (14:00 +0300)]
Merge pull request #15955 from FRRouting/mergify/bp/stable/8.5/pr-15846

ospfd: fix the bug where ip_ospf_dead-interval_minimal_hello-multiplier did not reset hello timer (backport #15846)

11 months agoospfd:fix the bug where ip_ospf_dead-interval_minimal_hello-multiplier did not reset... 15955/head
Bing Shui [Thu, 25 Apr 2024 16:02:26 +0000 (16:02 +0000)]
ospfd:fix the bug where ip_ospf_dead-interval_minimal_hello-multiplier did not reset hello timer

Signed-off-by: Bing Shui <652023330037@smail.nju.edu.cn>
(cherry picked from commit d733fe2c048cd75948d9f30ced77ed828e92ee18)

12 months agovtysh: Show `ip ospf network ...` even if it's not the same as the interface type 15873/head
Donatas Abraitis [Tue, 23 Apr 2024 14:13:46 +0000 (17:13 +0300)]
vtysh: Show `ip ospf network ...` even if it's not the same as the interface type

ospfv3 shows this unconditionally, and ospfv2 does not show `ip ospf network ...` if the type of the interface matches the specified network.

Fixes: https://github.com/FRRouting/frr/issues/15817
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
12 months agoMerge pull request #15859 from FRRouting/mergify/bp/stable/8.5/pr-15848
Donald Sharp [Mon, 29 Apr 2024 13:22:26 +0000 (09:22 -0400)]
Merge pull request #15859 from FRRouting/mergify/bp/stable/8.5/pr-15848

pimd: fix crash unconfiguring rp keepalive timer (backport #15848)

12 months agopimd: fix crash unconfiguring rp keepalive timer 15859/head
Vijayalaxmi Basavaraj [Mon, 22 Apr 2024 17:55:23 +0000 (10:55 -0700)]
pimd: fix crash unconfiguring rp keepalive timer

pimd crashs while unconfigure of rp ka timer as we are trying to access
a yand dnode(suppress timer) which does not exist at the moment.

User just configured rp keepalive timer and not suppress timer,
the yang dnode would not be present. Instead of directly accessing
yang_dnode_get_unit16, first check the yang node exist using
the xpath.

Ticket: #3874971

Testing:

Before:
------
tor-11(config)# no ip pim rp keep-alive-timer 3000
vtysh: error reading from pimd: Success (0)Warning: closing connection to pimd because of an I/O error!

Broadcast message from root@tor-11 (somewhere) (Mon Apr 22 17:29:12 2024):

cumulus-core: Running cl-support for core files "pimd.25467.1713806952.core"

After:
-----
tor-11(config)# no ip pim rp keep-alive-timer 3000
tor-11(config)#

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Signed-off-by: Vijayalaxmi Basavaraj <vbasavaraj@nvidia.com>
(cherry picked from commit 0c4b7c1f1f359c1d7647fea34f62378af8b640a5)

12 months agoMerge pull request #15418 from opensourcerouting/fix/backport_ee1c3c5518b1fb5b3989b80...
Donald Sharp [Thu, 25 Apr 2024 14:39:03 +0000 (10:39 -0400)]
Merge pull request #15418 from opensourcerouting/fix/backport_ee1c3c5518b1fb5b3989b80f8bd71ad2c2bc049a_8.5

lib: Do not convert EVPN prefixes into IPv4/IPv6 if not needed

12 months agoMerge pull request #15823 from FRRouting/mergify/bp/stable/8.5/pr-15815
Donald Sharp [Tue, 23 Apr 2024 16:53:40 +0000 (12:53 -0400)]
Merge pull request #15823 from FRRouting/mergify/bp/stable/8.5/pr-15815

lib, zebra: Check for not being a blackhole route (backport #15815)

12 months agolib, zebra: Check for not being a blackhole route 15823/head
Donald Sharp [Fri, 19 Apr 2024 16:13:32 +0000 (12:13 -0400)]
lib, zebra: Check for not being a blackhole route

In zebra_interface_nhg_reinstall zebra is checking that the
nhg is a singleton and not a blackhole nhg.  This was originally
done with checking that the nexthop is a NEXTHOP_TYPE_IFINDEX,
NEXTHOP_TYPE_IPV4_IFINDEX and NEXTHOP_TYPE_IPV6_IFINDEX.  This
was excluding NEXTHOP_TYPE_IPV4 and NEXTHOP_TYPE_IPV6.  These
were both possible to be received and maintained from the upper
level protocol for when a route is being recursively resolved.
If we have gotten to this point in zebra_interface_nhg_reinstall
the nexthop group has already been installed at least once
and we *know* that it is actually a valid nexthop.  What the
test is really trying to do is ensure that we are not reinstalling
a blackhole nexthop group( Which is not possible to even be
here by the way, but safety first! ).  So let's change
to test for that instead.

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

12 months agoMerge pull request #15659 from FRRouting/mergify/bp/stable/8.5/pr-15628
Donatas Abraitis [Fri, 5 Apr 2024 08:23:30 +0000 (11:23 +0300)]
Merge pull request #15659 from FRRouting/mergify/bp/stable/8.5/pr-15628

bgpd: Fix error handling when receiving BGP Prefix SID attribute (backport #15628)

12 months agobgpd: Prevent from one more CVE triggering this place 15659/head
Donatas Abraitis [Wed, 27 Mar 2024 17:08:38 +0000 (19:08 +0200)]
bgpd: Prevent from one more CVE triggering this place

If we receive an attribute that is handled by bgp_attr_malformed(), use
treat-as-withdraw behavior for unknown (or missing to add - if new) attributes.

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

12 months agobgpd: Fix error handling when receiving BGP Prefix SID attribute
Donatas Abraitis [Wed, 27 Mar 2024 16:42:56 +0000 (18:42 +0200)]
bgpd: Fix error handling when receiving BGP Prefix SID attribute

Without this patch, we always set the BGP Prefix SID attribute flag without
checking if it's malformed or not. RFC8669 says that this attribute MUST be discarded.

Also, this fixes the bgpd crash when a malformed Prefix SID attribute is received,
with malformed transitive flags and/or TLVs.

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

13 months agoMerge pull request #15568 from opensourcerouting/fix/backport_bgp_filter_fun_8.5
Russ White [Tue, 19 Mar 2024 14:36:56 +0000 (10:36 -0400)]
Merge pull request #15568 from opensourcerouting/fix/backport_bgp_filter_fun_8.5

BGP memory backports

13 months agobgpd: Ensure community data is freed in some cases. 15568/head
Donald Sharp [Sat, 2 Mar 2024 14:50:38 +0000 (09:50 -0500)]
bgpd: Ensure community data is freed in some cases.

Customer has this valgrind trace:

Direct leak of 2829120 byte(s) in 70728 object(s) allocated from:
  0 in community_new ../bgpd/bgp_community.c:39
  1 in community_uniq_sort ../bgpd/bgp_community.c:170
  2 in route_set_community ../bgpd/bgp_routemap.c:2342
  3 in route_map_apply_ext ../lib/routemap.c:2673
  4 in subgroup_announce_check ../bgpd/bgp_route.c:2367
  5 in subgroup_process_announce_selected ../bgpd/bgp_route.c:2914
  6 in group_announce_route_walkcb ../bgpd/bgp_updgrp_adv.c:199
  7 in hash_walk ../lib/hash.c:285
  8 in update_group_af_walk ../bgpd/bgp_updgrp.c:2061
  9 in group_announce_route ../bgpd/bgp_updgrp_adv.c:1059
 10 in bgp_process_main_one ../bgpd/bgp_route.c:3221
 11 in bgp_process_wq ../bgpd/bgp_route.c:3221
 12 in work_queue_run ../lib/workqueue.c:282

The above leak detected by valgrind was from a screenshot so I copied it
by hand.  Any mistakes in line numbers are purely from my transcription.
Additionally this is against a slightly modified 8.5.1 version of FRR.
Code inspection of 8.5.1 -vs- latest master shows the same problem
exists.  Code should be able to be followed from there to here.

What is happening:

There is a route-map being applied that modifes the outgoing community
to a peer.  This is saved in the attr copy created in
subgroup_process_announce_selected.  This community pointer is not
interned.  So the community->refcount is still 0.  Normally when
a prefix is announced, the attr and the prefix are placed on a
adjency out structure where the attribute is interned.  This will
cause the community to be saved in the community hash list as well.
In a non-normal operation when the decision to send is aborted after
the route-map application, the attribute is just dropped and the
pointer to the community is just dropped too, leading to situations
where the memory is leaked.  The usage of bgp suppress-fib would
would be a case where the community is caused to be leaked.
Additionally the previous commit where an unsuppress-map is used
to modify the outgoing attribute but since unsuppress-map was
not considered part of outgoing policy the attribute would be dropped as
well.  This pointer drop also extends to any dynamically allocated
memory saved by the attribute pointer that was not interned yet as well.

So let's modify the return case where the decision is made to
not send the prefix to the peer to always just flush the attribute
to ensure memory is not leaked.

Fixes: #15459
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
13 months agobgpd: Include unsuppress-map as a valid outgoing policy
Donald Sharp [Sat, 2 Mar 2024 14:42:30 +0000 (09:42 -0500)]
bgpd: Include unsuppress-map as a valid outgoing policy

If unsuppress-map is setup for outgoing peers, consider that
policy is being applied as for RFC 8212.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
13 months agobgpd: Ensure that the correct aspath is free'd
Donald Sharp [Wed, 13 Mar 2024 14:26:58 +0000 (10:26 -0400)]
bgpd: Ensure that the correct aspath is free'd

Currently in subgroup_default_originate the attr.aspath
is set in bgp_attr_default_set, which hashs the aspath
and creates a refcount for it.  If this is a withdraw
the subgroup_announce_check and bgp_adj_out_set_subgroup
is called which will intern the attribute.  This will
cause the the attr.aspath to be set to a new value
finally at the bottom of the function it intentionally
uninterns the aspath which is not the one that was
created for this function.  This reduces the other
aspath's refcount by 1 and if a clear bgp * is issued
fast enough the aspath for that will be removed
and the system will crash.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
14 months agoMerge pull request #15445 from FRRouting/mergify/bp/stable/8.5/pr-15399
Russ White [Tue, 27 Feb 2024 19:16:59 +0000 (14:16 -0500)]
Merge pull request #15445 from FRRouting/mergify/bp/stable/8.5/pr-15399

zebra: fix crash when macvlan link-interface is in another netns (backport #15399)

14 months agozebra: fix crash if macvlan link in another netns 15445/head
Louis Scalbert [Tue, 20 Feb 2024 16:49:01 +0000 (17:49 +0100)]
zebra: fix crash if macvlan link in another netns

A macvlan interface can have its underlying link-interface in another
namespace (aka. netns). However, by default, zebra does not know the
interface from the other namespaces. It results in a crash the pointer
to the link interface is NULL.

> 6  0x0000559d77a329d3 in zebra_vxlan_macvlan_up (ifp=0x559d798b8e00) at /root/frr/zebra/zebra_vxlan.c:4676
> 4676 link_zif = link_ifp->info;
> (gdb) list
> 4671 struct interface *link_ifp, *link_if;
> 4672
> 4673 zif = ifp->info;
> 4674 assert(zif);
> 4675 link_ifp = zif->link;
> 4676 link_zif = link_ifp->info;
> 4677 assert(link_zif);
> 4678
> (gdb) p zif->link
> $2 = (struct interface *) 0x0
> (gdb) p zif->link_ifindex
> $3 = 15

Fix the crash by returning when the macvlan link-interface is in another
namespace. No need to go further because any vxlan under the macvlan
interface would not be accessible by zebra.

Link: https://github.com/FRRouting/frr/issues/15370
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
(cherry picked from commit 44e6e3868d7a1488447f2be446dbd7cb5a5559ce)

14 months agolib: Do not convert EVPN prefixes into IPv4/IPv6 if not needed 15418/head
Donatas Abraitis [Thu, 15 Feb 2024 10:07:43 +0000 (12:07 +0200)]
lib: Do not convert EVPN prefixes into IPv4/IPv6 if not needed

Convert only when this is really needed, e.g. `match ip address prefix-list ...`.

Otherwise, we can't have mixed match clauses, like:

```
match ip address prefix-list p1
match evpn route-type prefix
```

This won't work, because the prefix is already converted, and we can't extract
route type, vni, etc. from the original EVPN prefix.

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

14 months agoMerge pull request #15362 from FRRouting/mergify/bp/stable/8.5/pr-13413
Donatas Abraitis [Tue, 13 Feb 2024 15:11:06 +0000 (17:11 +0200)]
Merge pull request #15362 from FRRouting/mergify/bp/stable/8.5/pr-13413

zebra: re-install NHG on interface up (backport #13413)

14 months agoMerge pull request #15364 from FRRouting/mergify/bp/stable/8.5/pr-14080
Donatas Abraitis [Tue, 13 Feb 2024 15:10:53 +0000 (17:10 +0200)]
Merge pull request #15364 from FRRouting/mergify/bp/stable/8.5/pr-14080

zebra: fix nhg out of sync between zebra and kernel (backport #14080)

14 months agozebra: fix nhg out of sync between zebra and kernel 15364/head
anlan_cs [Mon, 24 Jul 2023 06:40:22 +0000 (14:40 +0800)]
zebra: fix nhg out of sync between zebra and kernel

PR#13413 introduces reinstall mechanism, but there is problem with the route
leak scenario.

With route leak configuration: ( `x1` and `x2` are binded to `vrf1` )
```
vrf vrf2
 ip route 75.75.75.75/32 77.75.1.75 nexthop-vrf vrf1
 ip route 75.75.75.75/32 77.75.2.75 nexthop-vrf vrf1
exit-vrf
```

Firstly, all are ok.  But after `x1` is set down and up ( The interval
between the down and up operations should be less than 180 seconds. ) ,
`x1` is lost from the nexthop group:
```
anlan# ip nexthop
id 121 group 122/123 proto zebra
id 122 via 77.75.1.75 dev x1 scope link proto zebra
id 123 via 77.75.2.75 dev x2 scope link proto zebra
anlan# ip route show table 2
75.75.75.75 nhid 121 proto 196 metric 20
        nexthop via 77.75.1.75 dev x1 weight 1
        nexthop via 77.75.2.75 dev x2 weight 1
anlan# ip link set dev x1 down
anlan# ip link set dev x1 up
anlan# ip route show table 2 <- Wrong, one nexthop lost from group
75.75.75.75 nhid 121 via 77.75.2.75 dev x2 proto 196 metric 20
anlan# ip nexthop
id 121 group 123 proto zebra
id 122 via 77.75.1.75 dev x1 scope link proto zebra
id 123 via 77.75.2.75 dev x2 scope link proto zebra
anlan# show ip route vrf vrf2 <- Still ok
VRF vrf2:
S>* 75.75.75.75/32 [1/0] via 77.75.1.75, x1 (vrf vrf1), weight 1, 00:00:05
  *                      via 77.75.2.75, x2 (vrf vrf1), weight 1, 00:00:05
```

From the impact on kernel:
The `nh->type` of `id 122` is *always* `NEXTHOP_TYPE_IPV4` in the route leak
case.  Then, `nexthop_is_ifindex_type()` introduced by commit `5bb877` always
returns `false`, so its dependents can't be reinstalled.  After `x1` is down,
there is only `id 123` in the group of `id 121`.  So, Finally `id 121` remains
unchanged after `x1` is up, i.e., `id 122` is not added to the group even it is
reinstalled itself.

From the impact on zebra:
The `show ip route vrf vrf2` is still ok because the `id`s are reused/reinstalled
successfully within 180 seconds after `x1` is down and up.  The group of `id 121`
is with old `NEXTHOP_GROUP_INSTALLED` flag, and it is still the group of `id 122`
and `id 123` as before.

In this way, kernel and zebra have become out of sync.

The `nh->type` of `id 122` should be adjusted to `NEXTHOP_TYPE_IPV4_IFINDEX`
after nexthop resolved.  This commit is for doing this to make that reinstall
mechanism work.

Signed-off-by: anlan_cs <anlan_cs@tom.com>
(cherry picked from commit 045df14427b36b20015f12019dd6730a571fb6d3)

14 months agozebra:re-install dependent nhgs on interface up 15362/head
Chirag Shah [Sat, 29 Apr 2023 02:09:55 +0000 (19:09 -0700)]
zebra:re-install dependent nhgs on interface up

Upon interface up associated singleton NHG's
dependent NHGs needs to be reinstalled as
kernel would have deleted if there is no route
referencing it.

Ticket:#3416477
Issue:3416477
Testing Done:
flap interfaces which are part of route NHG,
upon interfaces up event, NHGs are resynced
into dplane.

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

14 months agozebra: re-install nhg on interface up
Ashwini Reddy [Wed, 19 Apr 2023 18:35:25 +0000 (11:35 -0700)]
zebra: re-install nhg on interface up

Intermittently zebra and kernel are out of sync
when interface flaps and the add's/dels are in
same processing queue and zebra assumes no change in nexthop.
Hence we need to bring in a reinstall to kernel
of the nexthops and routes to sync their states.

Upon interface flap kernel would have deleted NHGs
associated to a interface (the one flapped),
zebra retains NHGs for 3 mins even though upper
layer protocol removes the nexthops (associated NHG).
As part of interface address add ,
re-add singleton NHGs associated to interface.

Ticket: #3173663
Issue: 3173663

Signed-off-by: Ashwini Reddy <ashred@nvidia.com>
Signed-off-by: Chirag Shah <chirag@nvidia.com>
(cherry picked from commit 5bb87732f62d8dc0d92cad264fce568e5cf12366)

14 months agoMerge pull request #15342 from FRRouting/mergify/bp/stable/8.5/pr-15327
Donald Sharp [Mon, 12 Feb 2024 02:34:52 +0000 (21:34 -0500)]
Merge pull request #15342 from FRRouting/mergify/bp/stable/8.5/pr-15327

pimd: re-evaluated S,G OILs upon RP changes and empty SG upstream oils (backport #15327)

14 months agoMerge pull request #15348 from FRRouting/mergify/bp/stable/8.5/pr-15316
Donatas Abraitis [Sat, 10 Feb 2024 07:25:45 +0000 (09:25 +0200)]
Merge pull request #15348 from FRRouting/mergify/bp/stable/8.5/pr-15316

nhrp: fix race condition in  null lladdr from zebra (backport #15316)

14 months agonhrp: fix race condition 15348/head
Lou Berger [Tue, 6 Feb 2024 23:14:07 +0000 (23:14 +0000)]
nhrp: fix race condition

where null lladdr recieved from zebra before nhrp next hop
is installed.

Signed-off-by: Lou Berger <lberger@labn.net>
(cherry picked from commit 5d9ebe61815814804fac39597578c57e6420a69c)

14 months agopimd: re-evaluated S,G OILs upon RP changes and for empty SG upstream oils 15342/head
Rajesh Varatharaj [Thu, 8 Feb 2024 02:58:39 +0000 (18:58 -0800)]
pimd: re-evaluated S,G OILs upon RP changes and for empty SG upstream oils

Topology:

TOR11 (FHR) --- LEAF-11---SPINE1 (RP)MSDP SPINE-2(RP)MSDP --- LEAF-12 -- TOR12 (LHR)
        |         |                    | |       |
|         -----------------------------------------------------(ECMP)   |
|         |                                 |               |
 -----------------------------------------------------------------------(ECMP)
Issue:
In some triggers, S,G upstream is preserved even with the PP timer expiry, resulting
in S,G with NULL OILS. This could be because we create a dummy S,G upstream and
dummy channel_oif for *,G, where RPF is UNKNOWN. As a result, PIM+VXLAN traffic is never
forwarded downstream to LHR.

Fix:
when the S,G stream is running, Determine if a reevaluation of the outgoing interface
 list (OIL) is required. S,G upstream should then inherit the OIL from *,G.

Testing:
- Evpn pim tests - TestEvpnPimSingleVtepOneMdt.test_02_broadcast_traffic_spt_zero
- pim-smoke

Ticket: #
Signed-off-by: Rajesh Varatharaj <rvaratharaj@nvidia.com>
(cherry picked from commit 071d43a052e04de52771b2f03461c407f0ced36f)

15 months agoMerge pull request #15219 from FRRouting/mergify/bp/stable/8.5/pr-15210
Donatas Abraitis [Sat, 27 Jan 2024 20:55:20 +0000 (22:55 +0200)]
Merge pull request #15219 from FRRouting/mergify/bp/stable/8.5/pr-15210

bgpd: Fix format overflow for graceful-restart debug logs (backport #15210)

15 months agobgpd: Fix format overflow for graceful-restart debug logs 15219/head
Donatas Abraitis [Wed, 24 Jan 2024 06:57:56 +0000 (08:57 +0200)]
bgpd: Fix format overflow for graceful-restart debug logs

Use enum instead of int, and make the compiler happy when using -format-overflow.

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

15 months agoMerge pull request #15231 from donaldsharp/null_argument_warning_8.5
Donatas Abraitis [Fri, 26 Jan 2024 07:40:28 +0000 (09:40 +0200)]
Merge pull request #15231 from donaldsharp/null_argument_warning_8.5

bgpd: fix NULL argument warning

15 months agoMerge pull request #15230 from FRRouting/mergify/bp/stable/8.5/pr-15206
Donald Sharp [Thu, 25 Jan 2024 14:35:44 +0000 (09:35 -0500)]
Merge pull request #15230 from FRRouting/mergify/bp/stable/8.5/pr-15206

pbrd: Fix PBR handling for last rule deletion (backport #15206)

15 months agobgpd: fix NULL argument warning 15231/head
David Lamparter [Thu, 16 Mar 2023 10:00:02 +0000 (11:00 +0100)]
bgpd: fix NULL argument warning

gcc 12.2.0 complains `error: ‘%s’ directive argument is null`, even
though all enum values are covered with a string.  Let's just go with a
`???` default.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
15 months agopbrd: Fix PBR handling for last rule deletion 15230/head
Rajesh Varatharaj [Tue, 23 Jan 2024 06:24:33 +0000 (22:24 -0800)]
pbrd: Fix PBR handling for last rule deletion

Issue:
Previously, the PBR common was updated for every rule update or deletion

example:
let say we have three rule 11, 12, 13 and if we are removing rule 12. in the current code
we are making the entire map "valid" to false.

pbr-map MAP1 seq 11
match src-ip 90.1.1.2/32
set nexthop 20.1.1.2 swp1

pbr-map MAP1 seq 12
match src-ip 90.1.1.3/32
set nexthop 20.1.1.2 swp1

pbr-map MAP1 seq 13
match src-ip 90.1.1.4/32
set nexthop 20.1.1.2 swp1

no pbr-map MAP1 seq 12 ==> turns whole map valid to false.

r1(config)# end
r1# show pbr map
  pbr-map MAP1 valid: no
    Seq: 11 rule: 310
        Installed: yes Reason: Valid
        SRC IP Match: 90.1.1.2/32
        nexthop 20.1.1.2 swp1
          Installed: yes Tableid: 10002
    Seq: 13 rule: 312
        Installed: yes Reason: Valid
        SRC IP Match: 90.1.1.4/32
        nexthop 20.1.1.2 swp1
          Installed: yes Tableid: 10004

Fix:
Now, the PBR common will only be updated when the last rule is being deleted.
This change ensures that we only send a delete request to Zebra once, and only
set the valid and installed flags to false when the last rule is deleted.
This optimizes the handling of PBR rules and reduces unnecessary interactions with Zebra

Testing: UT in MR notes

Ticket: #
Signed-off-by: Rajesh Varatharaj <rvaratharaj@nvidia.com>
(cherry picked from commit aa12c72c2a9cc1ea22145db28636e716bbd52ace)

15 months agoMerge pull request #15208 from FRRouting/mergify/bp/stable/8.5/pr-15197
Donald Sharp [Wed, 24 Jan 2024 13:29:27 +0000 (08:29 -0500)]
Merge pull request #15208 from FRRouting/mergify/bp/stable/8.5/pr-15197

pimd: fix crash when configuring ssmpingd (backport #15197)

15 months agopimd: fix crash when configuring ssmpingd 15208/head
Igor Ryzhov [Tue, 23 Jan 2024 00:32:22 +0000 (02:32 +0200)]
pimd: fix crash when configuring ssmpingd

Command: `ip ssmpingd 1.1.1.1`

Backtrace:
```
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
0x00007fd1d3b02859 in __GI_abort () at abort.c:79
0x00007fd1d3e323e1 in yang_dnode_xpath_get_canon (dnode=<optimized out>, xpath_fmt=<optimized out>, ap=<optimized out>) at lib/yang_wrappers.c:61
0x00007fd1d3e34f41 in yang_dnode_get_ipv4 (addr=addr@entry=0x7ffc368554d4, dnode=<optimized out>, xpath_fmt=xpath_fmt@entry=0x5556af8680d4 "./source-addr") at lib/yang_wrappers.c:826
0x00005556af8216d3 in routing_control_plane_protocols_control_plane_protocol_pim_address_family_ssm_pingd_source_ip_create (args=0x7ffc36855530) at pimd/pim_nb_config.c:925
0x00007fd1d3dec13f in nb_callback_create (nb_node=0x5556b197ea40, nb_node=0x5556b197ea40, errmsg_len=8192, errmsg=0x7ffc36855a90 "", resource=0x5556b18fa6f8, dnode=0x5556b1ad7a10, event=NB_EV_APPLY, context=0x5556b1ad75c0) at lib/northbound.c:1260
nb_callback_configuration (context=0x5556b1ad75c0, event=NB_EV_APPLY, change=<optimized out>, errmsg=0x7ffc36855a90 "", errmsg_len=8192) at lib/northbound.c:1648
0x00007fd1d3deca6c in nb_transaction_process (event=event@entry=NB_EV_APPLY, transaction=transaction@entry=0x5556b1ad75c0, errmsg=errmsg@entry=0x7ffc36855a90 "", errmsg_len=errmsg_len@entry=8192) at lib/northbound.c:1779
0x00007fd1d3decdd6 in nb_candidate_commit_apply (transaction=0x5556b1ad75c0, save_transaction=save_transaction@entry=true, transaction_id=transaction_id@entry=0x0, errmsg=errmsg@entry=0x7ffc36855a90 "", errmsg_len=errmsg_len@entry=8192) at lib/northbound.c:1129
0x00007fd1d3decf15 in nb_candidate_commit (context=..., candidate=<optimized out>, save_transaction=save_transaction@entry=true, comment=comment@entry=0x0, transaction_id=transaction_id@entry=0x0, errmsg=0x7ffc36855a90 "", errmsg_len=8192) at lib/northbound.c:1162
0x00007fd1d3ded4af in nb_cli_classic_commit (vty=vty@entry=0x5556b1ada2a0) at lib/northbound_cli.c:50
0x00007fd1d3df025f in nb_cli_apply_changes_internal (vty=vty@entry=0x5556b1ada2a0, xpath_base=xpath_base@entry=0x7ffc36859b50 ".", clear_pending=clear_pending@entry=false) at lib/northbound_cli.c:177
0x00007fd1d3df06ad in nb_cli_apply_changes (vty=vty@entry=0x5556b1ada2a0, xpath_base_fmt=xpath_base_fmt@entry=0x0) at lib/northbound_cli.c:233
0x00005556af80fdd5 in pim_process_ssmpingd_cmd (vty=0x5556b1ada2a0, operation=NB_OP_CREATE, src_str=0x5556b1ad9630 "1.1.1.1") at pimd/pim_cmd_common.c:3423
0x00007fd1d3da7b0e in cmd_execute_command_real (vline=vline@entry=0x5556b1ac9520, vty=vty@entry=0x5556b1ada2a0, cmd=cmd@entry=0x0, up_level=up_level@entry=0) at lib/command.c:982
0x00007fd1d3da7cb1 in cmd_execute_command (vline=vline@entry=0x5556b1ac9520, vty=vty@entry=0x5556b1ada2a0, cmd=0x0, vtysh=vtysh@entry=0) at lib/command.c:1040
0x00007fd1d3da7e50 in cmd_execute (vty=vty@entry=0x5556b1ada2a0, cmd=cmd@entry=0x5556b1ae0a30 "ip ssmpingd 1.1.1.1", matched=matched@entry=0x0, vtysh=vtysh@entry=0) at lib/command.c:1207
0x00007fd1d3e278be in vty_command (vty=vty@entry=0x5556b1ada2a0, buf=<optimized out>) at lib/vty.c:591
0x00007fd1d3e27afd in vty_execute (vty=0x5556b1ada2a0) at lib/vty.c:1354
0x00007fd1d3e2bb23 in vtysh_read (thread=<optimized out>) at lib/vty.c:2362
0x00007fd1d3e22254 in event_call (thread=thread@entry=0x7ffc3685cd80) at lib/event.c:2003
0x00007fd1d3dce9e8 in frr_run (master=0x5556b183c830) at lib/libfrr.c:1218
0x00005556af803653 in main (argc=6, argv=<optimized out>, envp=<optimized out>) at pimd/pim_main.c:162
```

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

15 months agoMerge pull request #15140 from FRRouting/mergify/bp/stable/8.5/pr-14664
Donald Sharp [Tue, 16 Jan 2024 15:43:04 +0000 (10:43 -0500)]
Merge pull request #15140 from FRRouting/mergify/bp/stable/8.5/pr-14664

isisd: staticd: need to link directly against libyang (backport #14664)

15 months agoisisd: staticd: need to link directly against libyang 15140/head
Christian Hopps [Fri, 27 Oct 2023 02:51:08 +0000 (22:51 -0400)]
isisd: staticd: need to link directly against libyang

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

16 months agoMerge pull request #15041 from FRRouting/mergify/bp/stable/8.5/pr-15032
Donald Sharp [Mon, 18 Dec 2023 20:03:48 +0000 (15:03 -0500)]
Merge pull request #15041 from FRRouting/mergify/bp/stable/8.5/pr-15032

bgpd: "default-originate" shouldn't withdraw non-default routes (backport #15032)

16 months agotests: Check for 0.0.0.0/1 in bgp_default_route 15041/head
Xiao Liang [Mon, 18 Dec 2023 06:57:22 +0000 (14:57 +0800)]
tests: Check for 0.0.0.0/1 in bgp_default_route

Ensure that 0.0.0.0/1 route can be advertised along with
default-originate.

Signed-off-by: Xiao Liang <shaw.leon@gmail.com>
(cherry picked from commit 4538247c995e551aed0c08c4bb20b187ce95f5f2)

16 months agobgpd: "default-originate" shouldn't withdraw non-default routes
Xiao Liang [Fri, 15 Dec 2023 10:27:39 +0000 (18:27 +0800)]
bgpd: "default-originate" shouldn't withdraw non-default routes

Prevent "default-originate" from withdrawing non-default routes like
0.0.0.0/1 by checking prefix length.

Signed-off-by: Xiao Liang <shaw.leon@gmail.com>
(cherry picked from commit 4d74ba929daa6e6b2fe15f9df6e61d5e4808b64c)

16 months agoMerge pull request #15021 from FRRouting/mergify/bp/stable/8.5/pr-15014
Donald Sharp [Thu, 14 Dec 2023 15:38:53 +0000 (10:38 -0500)]
Merge pull request #15021 from FRRouting/mergify/bp/stable/8.5/pr-15014

ospfd: fix some ospf cmds' param range (backport #15014)

16 months agoMerge pull request #15005 from opensourcerouting/fix/bdb5ae8bce94432eb5e581f04f48dc4a...
Donald Sharp [Thu, 14 Dec 2023 15:33:04 +0000 (10:33 -0500)]
Merge pull request #15005 from opensourcerouting/fix/bdb5ae8bce94432eb5e581f04f48dc4aa5db7ca4_8.5

bgpd: Make `suppress-fib-pending` clear peering

16 months agodoc: add param range for graceful-restart helper supported-grace-time 15021/head
Bing Shui [Wed, 13 Dec 2023 14:25:43 +0000 (22:25 +0800)]
doc: add param range for graceful-restart helper supported-grace-time

Signed-off-by: Bing Shui <652023330037@smail.nju.edu.cn>
(cherry picked from commit 588b6421433ec0ffbe0d5fbc9ba68126e78d2935)

16 months agoospfd: fix ospf dead-interval minimal hello-multiplier param range
Bing Shui [Wed, 13 Dec 2023 14:23:58 +0000 (22:23 +0800)]
ospfd: fix ospf dead-interval minimal hello-multiplier param range

Signed-off-by: Bing Shui <652023330037@smail.nju.edu.cn>
(cherry picked from commit a1793303c0e8a531812f4176b62ff2ebf9ef9539)

16 months agobgpd: Make `suppress-fib-pending` clear peering 15005/head
Donald Sharp [Mon, 11 Dec 2023 15:46:53 +0000 (10:46 -0500)]
bgpd: Make `suppress-fib-pending` clear peering

When a peer has come up and already started installing
routes into the rib and `suppress-fib-pending` is either
turned on or off.  BGP is left with some routes that
may need to be withdrawn from peers and routes that
it does not know the status of.  Clear the BGP peers
for the interesting parties and let's let us come
up to speed as needed.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
16 months agoMerge pull request #14990 from FRRouting/mergify/bp/stable/8.5/pr-14983
Donald Sharp [Tue, 12 Dec 2023 17:22:59 +0000 (12:22 -0500)]
Merge pull request #14990 from FRRouting/mergify/bp/stable/8.5/pr-14983

zebra: The dplane_fpm_nl return path leaks memory (backport #14983)

16 months agozebra: The dplane_fpm_nl return path leaks memory 14990/head
Donald Sharp [Mon, 11 Dec 2023 18:41:36 +0000 (13:41 -0500)]
zebra: The dplane_fpm_nl return path leaks memory

The route entry created when using a ctx to pass route
entry data backup to the master pthread in zebra is
being leaked.  Prevent this from happening.

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

16 months agoFRR Release 8.5.4 docker/8.5.4 frr-8.5.4
Donatas Abraitis [Fri, 1 Dec 2023 07:51:27 +0000 (09:51 +0200)]
FRR Release 8.5.4

bgpd
    Check mandatory attributes more carefully for the UPDATE message
    Do not suppress conditional advertisement updates if triggered
    Fix crash in SNMP BGP4V2-MIB bgpv2PeerErrorsTable()
    Handle MP_UNREACH_NLRI malformed packets with session reset
    Ignore handling NLRIs if we received the MP_UNREACH_NLRI attribute
    Initialise timebuf arrays to zeros for dampening reuse timer
    Initialise buffer in bgp_notify_admin_message() before using it
    Make sure dampening is enabled for the specified AFI/SAFI
    Use proper AFI when dumping information for dampening stuff
    Treat EOR as withdrawn to avoid unwanted handling of malformed attrs

eigrpd
    Use the correct memory pool on interface deletion

vtysh
    Fix show route map JSON output

ospfd
    Fix infinite loop when listing OSPF interfaces

pbrd
    Fix show pbr map detail json output

zebra
    Add encap type when building packet for FPM
    Display ptmStatus order in interface JSON
    Fix connected route deletion when multiple entry exists
    Fix FPM multipath encap addition
    Fix link update for veth interfaces
    Fix zebra crash when replacing nhe during shutdown
    Prevent null pointer dereference

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
17 months agoMerge pull request #14893 from FRRouting/mergify/bp/stable/8.5/pr-14856
Donald Sharp [Tue, 28 Nov 2023 14:18:00 +0000 (09:18 -0500)]
Merge pull request #14893 from FRRouting/mergify/bp/stable/8.5/pr-14856

lib: fix show route map JSON display (backport #14856)

17 months agodoc: remove duplicated show route-map 14893/head
Rafael Zalamena [Tue, 21 Nov 2023 18:02:44 +0000 (15:02 -0300)]
doc: remove duplicated show route-map

Remove zebra duplicated command documentation without description.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
(cherry picked from commit 1f2ab614031dd169f6fbb495849099c443124f46)

17 months agolib,vtysh: fix show route map JSON output
Rafael Zalamena [Mon, 20 Nov 2023 20:32:19 +0000 (17:32 -0300)]
lib,vtysh: fix show route map JSON output

Move the command from 'lib' to 'vtysh' so we can properly format the
JSON output in a correct manner.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
(cherry picked from commit 570fdc55fd65899cd4376193e833594af6bca093)

17 months agoMerge pull request #14873 from FRRouting/mergify/bp/stable/8.5/pr-14862
Donald Sharp [Fri, 24 Nov 2023 19:33:01 +0000 (14:33 -0500)]
Merge pull request #14873 from FRRouting/mergify/bp/stable/8.5/pr-14862

zebra: fix dplane_ctx_iptable use-after-free (backport #14862)

17 months agozebra: fix dplane_ctx_iptable use-after-free 14873/head
Louis Scalbert [Wed, 22 Nov 2023 17:21:25 +0000 (18:21 +0100)]
zebra: fix dplane_ctx_iptable use-after-free

Fix a crash because a use-after-free.

> =================================================================
> ==1249835==ERROR: AddressSanitizer: heap-use-after-free on address 0x604000074210 at pc 0x7fa1b42a652c bp 0x7ffc477a2aa0 sp 0x7ffc477a2a98
> READ of size 8 at 0x604000074210 thread T0
>     #0 0x7fa1b42a652b in list_delete_all_node git/frr/lib/linklist.c:299:20
>     #1 0x7fa1b42a683f in list_delete git/frr/lib/linklist.c:312:2
>     #2 0x5ee515 in dplane_ctx_free_internal git/frr/zebra/zebra_dplane.c:858:4
>     #3 0x5ee59c in dplane_ctx_free git/frr/zebra/zebra_dplane.c:884:2
>     #4 0x5ee544 in dplane_ctx_fini git/frr/zebra/zebra_dplane.c:905:2
>     #5 0x7045c0 in rib_process_dplane_results git/frr/zebra/zebra_rib.c:4928:4
>     #6 0x7fa1b4434fb2 in event_call git/frr/lib/event.c:1970:2
>     #7 0x7fa1b42a0ccf in frr_run git/frr/lib/libfrr.c:1213:3
>     #8 0x556808 in main git/frr/zebra/main.c:488:2
>     #9 0x7fa1b3d0bd09 in __libc_start_main csu/../csu/libc-start.c:308:16
>     #10 0x4453e9 in _start (/usr/lib/frr/zebra+0x4453e9)
>
> 0x604000074210 is located 0 bytes inside of 40-byte region [0x604000074210,0x604000074238)
> freed by thread T0 here:
>     #0 0x4bf1dd in free (/usr/lib/frr/zebra+0x4bf1dd)
>     #1 0x7fa1b42df0c0 in qfree git/frr/lib/memory.c:130:2
>     #2 0x7fa1b42a68ce in list_free_internal git/frr/lib/linklist.c:24:2
>     #3 0x7fa1b42a6870 in list_delete git/frr/lib/linklist.c:313:2
>     #4 0x5ee515 in dplane_ctx_free_internal git/frr/zebra/zebra_dplane.c:858:4
>     #5 0x5ee59c in dplane_ctx_free git/frr/zebra/zebra_dplane.c:884:2
>     #6 0x5ee544 in dplane_ctx_fini git/frr/zebra/zebra_dplane.c:905:2
>     #7 0x7045c0 in rib_process_dplane_results git/frr/zebra/zebra_rib.c:4928:4
>     #8 0x7fa1b4434fb2 in event_call git/frr/lib/event.c:1970:2
>     #9 0x7fa1b42a0ccf in frr_run git/frr/lib/libfrr.c:1213:3
>     #10 0x556808 in main git/frr/zebra/main.c:488:2
>     #11 0x7fa1b3d0bd09 in __libc_start_main csu/../csu/libc-start.c:308:16
>
> previously allocated by thread T0 here:
>     #0 0x4bf5d2 in calloc (/usr/lib/frr/zebra+0x4bf5d2)
>     #1 0x7fa1b42dee18 in qcalloc git/frr/lib/memory.c:105:27
>     #2 0x7fa1b42a3784 in list_new git/frr/lib/linklist.c:18:9
>     #3 0x6d165f in pbr_iptable_alloc_intern git/frr/zebra/zebra_pbr.c:1015:29
>     #4 0x7fa1b426ad1f in hash_get git/frr/lib/hash.c:147:13
>     #5 0x6d15f2 in zebra_pbr_add_iptable git/frr/zebra/zebra_pbr.c:1030:13
>     #6 0x5db2a3 in zread_iptable git/frr/zebra/zapi_msg.c:3759:3
>     #7 0x5e365d in zserv_handle_commands git/frr/zebra/zapi_msg.c:4039:3
>     #8 0x7e09fc in zserv_process_messages git/frr/zebra/zserv.c:520:3
>     #9 0x7fa1b4434fb2 in event_call git/frr/lib/event.c:1970:2
>     #10 0x7fa1b42a0ccf in frr_run git/frr/lib/libfrr.c:1213:3
>     #11 0x556808 in main git/frr/zebra/main.c:488:2
>     #12 0x7fa1b3d0bd09 in __libc_start_main csu/../csu/libc-start.c:308:16

Fixes: 1cc380679e ("zebra: Actually free all memory associated ctx->u.iptable.interface_name_list")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
(cherry picked from commit 45140bb9e1efd2e603377809e349b35087d24f7d)

17 months agoMerge pull request #14852 from donaldsharp/backport_itis
Donatas Abraitis [Wed, 22 Nov 2023 12:42:55 +0000 (14:42 +0200)]
Merge pull request #14852 from donaldsharp/backport_itis

Backport a couple of fixes to 8.5

17 months agoMerge pull request #14848 from FRRouting/mergify/bp/stable/8.5/pr-14835
Donald Sharp [Tue, 21 Nov 2023 20:00:34 +0000 (15:00 -0500)]
Merge pull request #14848 from FRRouting/mergify/bp/stable/8.5/pr-14835

zebra: Fix fpm multipath encap addition (backport #14835)

17 months agobgpd: Ignore handling NLRIs if we received MP_UNREACH_NLRI 14851/head 14852/head
Donatas Abraitis [Sun, 29 Oct 2023 20:44:45 +0000 (22:44 +0200)]
bgpd: Ignore handling NLRIs if we received MP_UNREACH_NLRI

If we receive MP_UNREACH_NLRI, we should stop handling remaining NLRIs if
no mandatory path attributes received.

In other words, if MP_UNREACH_NLRI received, the remaining NLRIs should be handled
as a new data, but without mandatory attributes, it's a malformed packet.

In normal case, this MUST not happen at all, but to avoid crashing bgpd, we MUST
handle that.

Reported-by: Iggy Frankovic <iggyfran@amazon.com>
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
17 months agobgpd: Treat EOR as withdrawn to avoid unwanted handling of malformed attrs
Donatas Abraitis [Fri, 27 Oct 2023 08:56:45 +0000 (11:56 +0300)]
bgpd: Treat EOR as withdrawn to avoid unwanted handling of malformed attrs

Treat-as-withdraw, otherwise if we just ignore it, we will pass it to be
processed as a normal UPDATE without mandatory attributes, that could lead
to harmful behavior. In this case, a crash for route-maps with the configuration
such as:

```
router bgp 65001
 no bgp ebgp-requires-policy
 neighbor 127.0.0.1 remote-as external
 neighbor 127.0.0.1 passive
 neighbor 127.0.0.1 ebgp-multihop
 neighbor 127.0.0.1 disable-connected-check
 neighbor 127.0.0.1 update-source 127.0.0.2
 neighbor 127.0.0.1 timers 3 90
 neighbor 127.0.0.1 timers connect 1
 !
 address-family ipv4 unicast
  neighbor 127.0.0.1 addpath-tx-all-paths
  neighbor 127.0.0.1 default-originate
  neighbor 127.0.0.1 route-map RM_IN in
 exit-address-family
exit
!
route-map RM_IN permit 10
 set as-path prepend 200
exit
```

Send a malformed optional transitive attribute:

```
import socket
import time

OPEN = (b"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
b"\xff\xff\x00\x62\x01\x04\xfd\xea\x00\x5a\x0a\x00\x00\x01\x45\x02"
b"\x06\x01\x04\x00\x01\x00\x01\x02\x02\x02\x00\x02\x02\x46\x00\x02"
b"\x06\x41\x04\x00\x00\xfd\xea\x02\x02\x06\x00\x02\x06\x45\x04\x00"
b"\x01\x01\x03\x02\x0e\x49\x0c\x0a\x64\x6f\x6e\x61\x74\x61\x73\x2d"
b"\x70\x63\x00\x02\x04\x40\x02\x00\x78\x02\x09\x47\x07\x00\x01\x01"
b"\x80\x00\x00\x00")

KEEPALIVE = (b"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
b"\xff\xff\xff\xff\xff\xff\x00\x13\x04")

UPDATE = bytearray.fromhex("ffffffffffffffffffffffffffffffff002b0200000003c0ff00010100eb00ac100b0b001ad908ac100b0b")

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('127.0.0.2', 179))
s.send(OPEN)
data = s.recv(1024)
s.send(KEEPALIVE)
data = s.recv(1024)
s.send(UPDATE)
data = s.recv(1024)
time.sleep(100)
s.close()
```

Reported-by: Iggy Frankovic <iggyfran@amazon.com>
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
17 months agozebra: Fix fpm multipath encap addition 14848/head
Donald Sharp [Fri, 17 Nov 2023 21:57:20 +0000 (16:57 -0500)]
zebra: Fix fpm multipath encap addition

The fpm code path in building a ecmp route for evpn has
a bug that caused it to not add the encap attribute to
the netlink message.  See #f0f7b285b99dbd971400d33feea007232c0bd4a9
for the single path case being fixed.

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

17 months agoMerge pull request #14754 from FRRouting/mergify/bp/stable/8.5/pr-14675
Donald Sharp [Wed, 8 Nov 2023 16:18:51 +0000 (11:18 -0500)]
Merge pull request #14754 from FRRouting/mergify/bp/stable/8.5/pr-14675

zebra: Add encap type when building packet for FPM (backport #14675)

17 months agozebra: Add encap type when building packet for FPM 14754/head
Donald Sharp [Sat, 28 Oct 2023 14:03:39 +0000 (10:03 -0400)]
zebra: Add encap type when building packet for FPM

Currently in the single nexthop case w/ evpn sending
down via the FPM the encap type is not being set
for the nexthop.

This looks like the result of some code reorg for the
nexthop happened but the fpm failed to be accounted for.
Let's just move the encap type encoding to where it
will happen.

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

17 months agoMerge pull request #14686 from FRRouting/mergify/bp/stable/8.5/pr-14681
Donald Sharp [Mon, 30 Oct 2023 19:38:08 +0000 (15:38 -0400)]
Merge pull request #14686 from FRRouting/mergify/bp/stable/8.5/pr-14681

zebra: display ptmStatus order in interface json (backport #14681)

17 months agozebra: display ptmStatus order in interface json 14686/head
Sindhu Parvathi Gopinathan [Wed, 24 Aug 2022 16:17:57 +0000 (09:17 -0700)]
zebra: display ptmStatus order in interface json

Display ptmStatus in correct order in show interface json
output.

Signed-off-by: Sindhu Parvathi Gopinathan's <sgopinathan@nvidia.com>
(cherry picked from commit aa6dab0369b9ab90291f5596f6b23a4c0b226ed0)

18 months agoMerge pull request #14679 from FRRouting/mergify/bp/stable/8.5/pr-14665
Donald Sharp [Sun, 29 Oct 2023 14:11:04 +0000 (10:11 -0400)]
Merge pull request #14679 from FRRouting/mergify/bp/stable/8.5/pr-14665

pbrd: fix show pbr map detail json (backport #14665)

18 months agodoc: fix pbr map detail json 14679/head
Chirag Shah [Fri, 27 Oct 2023 15:06:27 +0000 (08:06 -0700)]
doc: fix pbr map detail json

Fix the documentation for the pbr map command with
correct syntax.

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

18 months agopbrd: fix show pbr map detail json
Sindhu Parvathi Gopinathan [Mon, 23 Oct 2023 05:59:06 +0000 (22:59 -0700)]
pbrd: fix show pbr map detail json

'detail' and 'josn' keyword is given as an optional parameter
for cli arguments. Hence 'detail' keyword was consider as a
pbr 'name' for "show pbr map detail json" command.

Before Fix:

```
cumulus#
cumulus# show pbr map detail json
[
]
cumulus#
```

After Fix:
```
cumulus# show pbr map detail json
[
  {
    "name":"MAP1",
    "valid":false,
    "policies":[
      {
        "id":1,
        "sequenceNumber":10,
        "ruleNumber":309,
        "vrfUnchanged":false,
        "installed":false,
        "installedReason":"Invalid Src or Dst",
        "vrfName":"default"
      }
    ]
  }
]
cumulus#
```

Ticket:#3638600

Issue:3638600

Testing: UT done

Signed-off-by: Sindhu Parvathi Gopinathan's <sgopinathan@nvidia.com>
(cherry picked from commit d621c365a65f825adfbc00128360390d0b2bd5be)

18 months agoMerge pull request #14655 from FRRouting/mergify/bp/stable/8.5/pr-14645
Donald Sharp [Wed, 25 Oct 2023 19:35:10 +0000 (15:35 -0400)]
Merge pull request #14655 from FRRouting/mergify/bp/stable/8.5/pr-14645

bgpd: A couple more bgpd crashes on malformed attributes (backport #14645)

18 months agoMerge pull request #14650 from FRRouting/mergify/bp/stable/8.5/pr-14628
Donald Sharp [Wed, 25 Oct 2023 19:32:56 +0000 (15:32 -0400)]
Merge pull request #14650 from FRRouting/mergify/bp/stable/8.5/pr-14628

bgpd: Do not suppress conditional advertisement updates if triggered (backport #14628)

18 months agobgpd: Check mandatory attributes more carefully for UPDATE message 14655/head
Donatas Abraitis [Mon, 23 Oct 2023 20:34:10 +0000 (23:34 +0300)]
bgpd: Check mandatory attributes more carefully for UPDATE message

If we send a crafted BGP UPDATE message without mandatory attributes, we do
not check if the length of the path attributes is zero or not. We only check
if attr->flag is at least set or not. Imagine we send only unknown transit
attribute, then attr->flag is always 0. Also, this is true only if graceful-restart
capability is received.

A crash:

```
bgpd[7834]: [TJ23Y-GY0RH] 127.0.0.1 Unknown attribute is received (type 31, length 16)
bgpd[7834]: [PCFFM-WMARW] 127.0.0.1(donatas-pc) rcvd UPDATE wlen 0 attrlen 20 alen 17
BGP[7834]: Received signal 11 at 1698089639 (si_addr 0x0, PC 0x55eefd375b4a); aborting...
BGP[7834]: /usr/local/lib/libfrr.so.0(zlog_backtrace_sigsafe+0x6d) [0x7f3205ca939d]
BGP[7834]: /usr/local/lib/libfrr.so.0(zlog_signal+0xf3) [0x7f3205ca9593]
BGP[7834]: /usr/local/lib/libfrr.so.0(+0xf5181) [0x7f3205cdd181]
BGP[7834]: /lib/x86_64-linux-gnu/libpthread.so.0(+0x12980) [0x7f3204ff3980]
BGP[7834]: /usr/lib/frr/bgpd(+0x18ab4a) [0x55eefd375b4a]
BGP[7834]: /usr/local/lib/libfrr.so.0(route_map_apply_ext+0x310) [0x7f3205cd1290]
BGP[7834]: /usr/lib/frr/bgpd(+0x163610) [0x55eefd34e610]
BGP[7834]: /usr/lib/frr/bgpd(bgp_update+0x9a5) [0x55eefd35c1d5]
BGP[7834]: /usr/lib/frr/bgpd(bgp_nlri_parse_ip+0xb7) [0x55eefd35e867]
BGP[7834]: /usr/lib/frr/bgpd(+0x1555e6) [0x55eefd3405e6]
BGP[7834]: /usr/lib/frr/bgpd(bgp_process_packet+0x747) [0x55eefd345597]
BGP[7834]: /usr/local/lib/libfrr.so.0(event_call+0x83) [0x7f3205cef4a3]
BGP[7834]: /usr/local/lib/libfrr.so.0(frr_run+0xc0) [0x7f3205ca10a0]
BGP[7834]: /usr/lib/frr/bgpd(main+0x409) [0x55eefd2dc979]
```

Sending:

```
import socket
import time

OPEN = (b"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
b"\xff\xff\x00\x62\x01\x04\xfd\xea\x00\x5a\x0a\x00\x00\x01\x45\x02"
b"\x06\x01\x04\x00\x01\x00\x01\x02\x02\x02\x00\x02\x02\x46\x00\x02"
b"\x06\x41\x04\x00\x00\xfd\xea\x02\x02\x06\x00\x02\x06\x45\x04\x00"
b"\x01\x01\x03\x02\x0e\x49\x0c\x0a\x64\x6f\x6e\x61\x74\x61\x73\x2d"
b"\x70\x63\x00\x02\x04\x40\x02\x00\x78\x02\x09\x47\x07\x00\x01\x01"
b"\x80\x00\x00\x00")

KEEPALIVE = (b"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
b"\xff\xff\xff\xff\xff\xff\x00\x13\x04")

UPDATE = bytearray.fromhex("ffffffffffffffffffffffffffffffff003c0200000014ff1f001000040146464646460004464646464646664646f50d05800100010200ffff000000")

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('127.0.0.2', 179))
s.send(OPEN)
data = s.recv(1024)
s.send(KEEPALIVE)
data = s.recv(1024)
s.send(UPDATE)
data = s.recv(1024)
time.sleep(1000)
s.close()
```

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

18 months agobgpd: Handle MP_REACH_NLRI malformed packets with session reset
Donatas Abraitis [Fri, 20 Oct 2023 14:49:18 +0000 (17:49 +0300)]
bgpd: Handle MP_REACH_NLRI malformed packets with session reset

Avoid crashing bgpd.

```
(gdb)
bgp_mp_reach_parse (args=<optimized out>, mp_update=0x7fffffffe140) at bgpd/bgp_attr.c:2341
2341 stream_get(&attr->mp_nexthop_global, s, IPV6_MAX_BYTELEN);
(gdb)
stream_get (dst=0x7fffffffe1ac, s=0x7ffff0006e80, size=16) at lib/stream.c:320
320 {
(gdb)
321 STREAM_VERIFY_SANE(s);
(gdb)
323 if (STREAM_READABLE(s) < size) {
(gdb)
34   return __builtin___memcpy_chk (__dest, __src, __len, __bos0 (__dest));
(gdb)

Thread 1 "bgpd" received signal SIGSEGV, Segmentation fault.
0x00005555556e37be in route_set_aspath_prepend (rule=0x555555aac0d0, prefix=0x7fffffffe050,
    object=0x7fffffffdb00) at bgpd/bgp_routemap.c:2282
2282 if (path->attr->aspath->refcnt)
(gdb)
```

With the configuration:

```
 neighbor 127.0.0.1 remote-as external
 neighbor 127.0.0.1 passive
 neighbor 127.0.0.1 ebgp-multihop
 neighbor 127.0.0.1 disable-connected-check
 neighbor 127.0.0.1 update-source 127.0.0.2
 neighbor 127.0.0.1 timers 3 90
 neighbor 127.0.0.1 timers connect 1
 address-family ipv4 unicast
  redistribute connected
  neighbor 127.0.0.1 default-originate
  neighbor 127.0.0.1 route-map RM_IN in
 exit-address-family
!
route-map RM_IN permit 10
 set as-path prepend 200
exit
```

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

18 months agotests: Check if BGP conditional advertisement works fine with static routes 14650/head
Donatas Abraitis [Thu, 19 Oct 2023 17:25:23 +0000 (20:25 +0300)]
tests: Check if BGP conditional advertisement works fine with static routes

If we modify the prefix-list that is used to define the routes to be
advertised, all of them MUST be advertised.

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

18 months agobgpd: Do not suppress conditional advertisement updates if triggered
Donatas Abraitis [Fri, 20 Oct 2023 08:59:59 +0000 (11:59 +0300)]
bgpd: Do not suppress conditional advertisement updates if triggered

If we have a prefix-list with one entry, and after some time we append a prefix-list
with some more additional entries, conditional advertisement is triggered, and the
old entries are suppressed (because they look identical as sent before).

Hence, the old entries are sent as withdrawals and only new entries sent as updates.

Force re-sending all BGP updates for conditional advertisement. The same is done
for route-refresh, and/or soft clear operations.

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

18 months agoMerge pull request #14586 from FRRouting/mergify/bp/stable/8.5/pr-13340
Donald Sharp [Fri, 13 Oct 2023 15:52:34 +0000 (11:52 -0400)]
Merge pull request #14586 from FRRouting/mergify/bp/stable/8.5/pr-13340

zebra: Fix connected route deletion when multiple entry exists (backport #13340)