]> git.puffer.fish Git - mirror/frr.git/log
mirror/frr.git
20 months agolib, zebra: Fix EVPN nexthop config order 14187/head
Xiao Liang [Thu, 15 Dec 2022 09:04:32 +0000 (17:04 +0800)]
lib, zebra: Fix EVPN nexthop config order

Delay EVPN route addition to synchronize with rib_delete(), which now
uses early route queue.

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

20 months agoFRR Release 9.0.0 frr-9.0
Jafar Al-Gharaibeh [Tue, 8 Aug 2023 17:06:22 +0000 (12:06 -0500)]
FRR Release 9.0.0

- Major Highlights:
-   Introduce `mgmtd` daemon
-   Add BGP `neighbor path-attribute treat-as-withdraw` command
-   Add BGP ASN dot notation support (RFC 5396)
-   Add BGP Software Version capability
-   Allow BGP peering via 127.0.0.0/8
-   Deprecate BGP `internet` community - this is the Cisco-specific community, which is never been RFC-defined and confusing
-   Implement `match source-protocol` for BGP route maps
-   Implement BGP Node Target extended communities (draft-ietf-idr-node-target-ext-comm)
-   Implement Flex-Algo for SR-MPLS (RFC 9350)
-   Add support for IS-IS `advertise-passive-only`
-   Add IS-IS `affinity-map` support
-   Add the `graceful-restart hello-delay` OSPFv2/OSPFv3 command
-   Add the `ipv6 mld join` PIMv6 command
-   Add `allow-ecmp x` RIP/RIPng Command
-   Add BFD support for RIP
- For a full list of new features and bug fixes, please refer to:
-   https://frrouting.org/release/

Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
20 months agoMerge pull request #14132 from FRRouting/mergify/bp/stable/9.0/pr-14129 docker/9.0.0
Donatas Abraitis [Thu, 3 Aug 2023 19:30:29 +0000 (22:30 +0300)]
Merge pull request #14132 from FRRouting/mergify/bp/stable/9.0/pr-14129

bgpd: Fix for session reset issue caused by malformed core attributes  in update message (backport #14129)

20 months agobgpd: Fix session reset issue caused by malformed core attributes 14132/head
Samanvitha B Bhargav [Wed, 2 Aug 2023 06:10:35 +0000 (23:10 -0700)]
bgpd: Fix session reset issue caused by malformed core attributes

RCA:
On encountering any attribute error for core attributes in update message,
the error handling is set to 'treat as withdraw' and
further parsing of the remaining attributes is skipped.
But the stream pointer is not being correctly adjusted to
point to the next NLRI field skipping the rest of the attributes.
This leads to incorrect parsing of the NLRI field,
which causes BGP session to reset.

Fix:
The stream pointer offset is rightly adjusted to point to the NLRI field correctly
when the malformed attribute is encountered and remaining attribute parsing is skipped.

Signed-off-by: Samanvitha B Bhargav <bsamanvitha@vmware.com>
(cherry picked from commit 70ff940fd1cbf920958116c558150ca5d3200eb8)

20 months agoMerge pull request #14128 from FRRouting/mergify/bp/stable/9.0/pr-14125
Donatas Abraitis [Wed, 2 Aug 2023 08:56:42 +0000 (11:56 +0300)]
Merge pull request #14128 from FRRouting/mergify/bp/stable/9.0/pr-14125

lib: Do not use time_t as a special Lua encoder/decoder (backport #14125)

20 months agolib: Do not use time_t as a special Lua encoder/decoder 14128/head
Donatas Abraitis [Tue, 1 Aug 2023 11:08:25 +0000 (14:08 +0300)]
lib: Do not use time_t as a special Lua encoder/decoder

This is purely an integer (long long/long), and causes issues for 32-bit systems.

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

20 months agoMerge pull request #14122 from FRRouting/mergify/bp/stable/9.0/pr-14121
Donald Sharp [Tue, 1 Aug 2023 11:50:31 +0000 (07:50 -0400)]
Merge pull request #14122 from FRRouting/mergify/bp/stable/9.0/pr-14121

debian: Add missing protobuf dependency (backport #14121)

20 months agoMerge pull request #14123 from FRRouting/mergify/bp/stable/9.0/pr-14115
Donatas Abraitis [Tue, 1 Aug 2023 10:38:36 +0000 (13:38 +0300)]
Merge pull request #14123 from FRRouting/mergify/bp/stable/9.0/pr-14115

docker: Adjustments for Alpine 3.18 and buildx (backport #14115)

20 months agodocker: Install the apk packages regardless of the platform 14123/head
Donatas Abraitis [Mon, 31 Jul 2023 08:05:15 +0000 (11:05 +0300)]
docker: Install the apk packages regardless of the platform

It was hardcoded to x86_64, but we build Alpine images for more platforms, let's
be dynamical here.

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

20 months agodocker: Use openssl instead of libressl
Donatas Abraitis [Mon, 31 Jul 2023 08:04:30 +0000 (11:04 +0300)]
docker: Use openssl instead of libressl

libressl is dropped from Alpine 3.18 for s390x.

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

20 months agodebian: Add missing protobuf dependency 14122/head
Martin Winter [Mon, 31 Jul 2023 22:48:26 +0000 (00:48 +0200)]
debian: Add missing protobuf dependency

Signed-off-by: Martin Winter <mwinter@opensourcerouting.org>
(cherry picked from commit 62559e53acd849001e21535ffcd25923b709b2fc)

21 months agoFRR Release 9.0
Jafar Al-Gharaibeh [Wed, 26 Jul 2023 05:07:52 +0000 (00:07 -0500)]
FRR Release 9.0

- Major Highlights:
-   Introduce `mgmtd` daemon
-   Add BGP `neighbor path-attribute treat-as-withdraw` command
-   Add BGP ASN dot notation support (RFC 5396)
-   Add BGP Software Version capability
-   Allow BGP peering via 127.0.0.0/8
-   Deprecate BGP `internet` community - this is the Cisco-specific community, which is never been RFC-defined and confusing
-   Implement `match source-protocol` for BGP route maps
-   Implement BGP Node Target extended communities (draft-ietf-idr-node-target-ext-comm)
-   Implement Flex-Algo for SR-MPLS (RFC 9350)
-   Add support for IS-IS `advertise-passive-only`
-   Add IS-IS `affinity-map` support
-   Add the `graceful-restart hello-delay` OSPFv2/OSPFv3 command
-   Add the `ipv6 mld join` PIMv6 command
-   Add `allow-ecmp x` RIP/RIPng Command
-   Add BFD support for RIP
- For a full list of new features and bug fixes, please refer to:
-   https://frrouting.org/release/

Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
21 months agoMerge pull request #14090 from FRRouting/mergify/bp/dev/9.0/pr-14079
Donald Sharp [Tue, 25 Jul 2023 18:26:18 +0000 (14:26 -0400)]
Merge pull request #14090 from FRRouting/mergify/bp/dev/9.0/pr-14079

bgpd: The last_reset_cause in the peer structure is too large (backport #14079)

21 months agoMerge pull request #14091 from FRRouting/mergify/bp/dev/9.0/pr-14081
Donald Sharp [Tue, 25 Jul 2023 18:25:48 +0000 (14:25 -0400)]
Merge pull request #14091 from FRRouting/mergify/bp/dev/9.0/pr-14081

Bgp ringbuf cleanup (backport #14081)

21 months agobgpd: Reduce size of ibuf_work ringbuf 14091/head
Donald Sharp [Mon, 24 Jul 2023 14:33:21 +0000 (10:33 -0400)]
bgpd: Reduce size of ibuf_work ringbuf

The ringbuf is 650k in size.  This is obscenely large and
in practical experimentation FRR never even approaches
that size at all.  Let's reduce this to 1.5 max packet sizes.

If a BGP_MAX_PACKET_SIZE packet is ever received having a bit
of extra space ensures that we can read at least 1 packet.

This also will significantly reduce memory usage when the
operator has a lot of peers.

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

21 months agobgpd: With io limit allow parsing to continue even if memory is low
Donald Sharp [Mon, 24 Jul 2023 14:13:32 +0000 (10:13 -0400)]
bgpd: With io limit allow parsing to continue even if memory is low

Commit: a0b937de428e14e869b8541f0b7810113d619c2e

Introduced the idea of a input Q packet limit.  Say you read in
635000 bytes of data and the input Q is already at it's limit
(currently 1000) then when bgp_process_reads runs it will
assert because there is less then a BGP_MAX_PACKET_SIZE in ibuf_work.

Don't assert as that it's irrelevant.  Even if we can't read a full packet
in let's let the whole system keep working as that as the input Q length
comes down we will start pulling down the ibuf_work and it will be ok.

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

21 months agobgpd: The last_reset_cause in the peer structure is too large 14090/head
Donald Sharp [Mon, 24 Jul 2023 00:30:47 +0000 (20:30 -0400)]
bgpd: The last_reset_cause in the peer structure is too large

The last_reset_cause is a plain old BGP_MAX_PACKET_SIZE buffer
that is really enlarging the peer data structure.  Let's just
copy the stream that failed and only allocate how ever much
the packet size actually was.  While it's likely that we have
a reset reason, the packet typically is not going to be 65k
in size.  Let's save space.

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

21 months agoMerge pull request #14077 from FRRouting/mergify/bp/dev/9.0/pr-14075
Donatas Abraitis [Sat, 22 Jul 2023 07:29:42 +0000 (10:29 +0300)]
Merge pull request #14077 from FRRouting/mergify/bp/dev/9.0/pr-14075

Remove unused memory allocations associated with bgp (backport #14075)

21 months agobgpd: Replace peer->ibuf_scratch 14077/head
Donald Sharp [Fri, 21 Jul 2023 17:10:03 +0000 (13:10 -0400)]
bgpd: Replace peer->ibuf_scratch

The peer->ibuf_scratch was allocating 65535 * 10 bytes
for scratch space to hold data incoming from a read
from a peer.  When you have 4k peers this is 262,1400,000
or 262 mb of data.  Which is crazy large.  Especially
since the i/o pthread is reading per peer without
any chance of having the data interfere with other reads.

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

21 months agobgpd: Remove withdraw_low from system, it is never used
Donald Sharp [Fri, 21 Jul 2023 16:46:31 +0000 (12:46 -0400)]
bgpd: Remove withdraw_low from system, it is never used

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

21 months agobgpd: Remove peer->sync array
Donald Sharp [Fri, 21 Jul 2023 16:41:35 +0000 (12:41 -0400)]
bgpd: Remove peer->sync array

It is never used.

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

21 months agobgpd: Remove peer->obuf_work
Donald Sharp [Fri, 21 Jul 2023 16:23:23 +0000 (12:23 -0400)]
bgpd: Remove peer->obuf_work

This is never used.  Free up another 65k of stream data
never used per peer.

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

21 months agobgpd: Remove peer->scratch
Donald Sharp [Fri, 21 Jul 2023 16:14:59 +0000 (12:14 -0400)]
bgpd: Remove peer->scratch

This was only ever being allocated and de-allocated.
Let's save 65k per peer

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

21 months agoMerge pull request #14068 from opensourcerouting/fix/backport_libyang_to_9.0
Donald Sharp [Fri, 21 Jul 2023 12:59:24 +0000 (08:59 -0400)]
Merge pull request #14068 from opensourcerouting/fix/backport_libyang_to_9.0

Switch to libyang 2.1.80

21 months agodocker: Use libyang 2.1.80 for Alpine builds 14068/head
Donatas Abraitis [Thu, 20 Jul 2023 20:16:38 +0000 (23:16 +0300)]
docker: Use libyang 2.1.80 for Alpine builds

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
21 months agodocker: Move Alpine dependency packages to APKBUILD file
Donatas Abraitis [Thu, 20 Jul 2023 19:39:14 +0000 (22:39 +0300)]
docker: Move Alpine dependency packages to APKBUILD file

Do not mix APKBUILD and Dockerfile when installing dependencies.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
21 months agodocker: Install protobuf-c-devel for ubi8-minimal
Donatas Abraitis [Thu, 20 Jul 2023 19:33:10 +0000 (22:33 +0300)]
docker: Install protobuf-c-devel for ubi8-minimal

configure: error: in `/src':
configure: error: protobuf requested but protoc-c not found.  Install protobuf-c.
See `config.log' for more details

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
21 months agodocker: Use Alpine Linux 3.18
Donatas Abraitis [Thu, 20 Jul 2023 19:11:03 +0000 (22:11 +0300)]
docker: Use Alpine Linux 3.18

It has the newer libyang version 2.1.55, while 3.17 has 2.1.30.

3.19 will have 2.1.80.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
21 months agodocker: Use libyang 2.1.80
Donatas Abraitis [Thu, 20 Jul 2023 19:10:19 +0000 (22:10 +0300)]
docker: Use libyang 2.1.80

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
21 months agoredhat: Require libyang 2.1.80
Donatas Abraitis [Thu, 20 Jul 2023 18:54:22 +0000 (21:54 +0300)]
redhat: Require libyang 2.1.80

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
21 months agodebian: Require libyang 2.1.80
Donatas Abraitis [Thu, 20 Jul 2023 18:52:26 +0000 (21:52 +0300)]
debian: Require libyang 2.1.80

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
21 months agosnapcraft: Use libyang 2.1.80
Donatas Abraitis [Thu, 20 Jul 2023 18:46:38 +0000 (21:46 +0300)]
snapcraft: Use libyang 2.1.80

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
21 months agoMerge pull request #14063 from FRRouting/mergify/bp/dev/9.0/pr-14006
Donald Sharp [Thu, 20 Jul 2023 16:38:44 +0000 (12:38 -0400)]
Merge pull request #14063 from FRRouting/mergify/bp/dev/9.0/pr-14006

pim6d: Fixing core while running MLD conformance test. (backport #14006)

21 months agopim6d: Fixing core while running MLD conformance test. 14063/head
Abhishek N R [Thu, 13 Jul 2023 09:54:27 +0000 (02:54 -0700)]
pim6d: Fixing core while running MLD conformance test.

While running MLD conformance test 9.2 core is getting generated.

Test setps:
1. ANVL: Listen (for upto <GeneralQueryRecvWaitTime> seconds) on <AIface-0>.
2. DUT: Send MLD General Query Message.
3. ANVL: Send MLD Report Message to <DIface-0> containing:
• IPv6 Source Address field set to link-local IPv6 Address of HOST-1
• IPv6 Destination Address field set to <McastAddrGroup>
• MLD Multicast Address field set to <McastAddrGroup>.
4. ANVL: Wait for <ProcessTime> seconds for DUT to process and add <Mcas- tAddrGroup> to its Multicast Address list.
5. ANVL: Send MLD General Query Message to <DIface-0> containing:
• IPv6 Source Address field set to link-local IPv6 Address of RTR-1 which is numerically less than the link-local IPv6 unicast address of <DIface-0>
• IPv6 Destination Address field set to link-scope all-nodes multicast address.
6. ANVL: Send MLD Multicast-Address-Specific Query Message to <DIface-0> containing:
• IPv6 Source Address field set to link-local IPv6 Address of RTR-1
• IPv6 Destination Address field set to <McastAddrGroup>
• MLD Multicast Address field set to <McastAddrGroup>
• MLD Maximum Response Delay field value set to 0.
7. ANVL: Verify that the Maximum Response Delay timer for <McastAd- drGroup> is set to zero.

While running above test, when group specific query is received we start gm_t_sg_expire timer.
Once this timer expires, we clear the corresponding entry.
During this sg->state was still set to JOIN. This happened because receiver went down without sending leave.

Added a condition to update the sg->state before starting the timer.
If receiver goes down without sending leave we will update sg->state to GM_SG_JOIN_EXPIRING or GM_SG_NOPRUNE_EXPIRING based on previous state.
If we receive a join then sg->state will be refreshed and will be updated to JOIN state.

Fixes: #13387
Signed-off-by: Abhishek N R <abnr@vmware.com>
(cherry picked from commit e9484001ee2a1030228de39c997e19f90e32516b)

21 months agoMerge pull request #14047 from FRRouting/mergify/bp/dev/9.0/pr-13918
Donatas Abraitis [Wed, 19 Jul 2023 11:09:01 +0000 (14:09 +0300)]
Merge pull request #14047 from FRRouting/mergify/bp/dev/9.0/pr-13918

bgpd: fix bgp evpn cli memory leaks. (backport #13918)

21 months agoMerge pull request #14045 from FRRouting/mergify/bp/dev/9.0/pr-14041
Donald Sharp [Tue, 18 Jul 2023 19:07:57 +0000 (15:07 -0400)]
Merge pull request #14045 from FRRouting/mergify/bp/dev/9.0/pr-14041

bgpd: Do not try to redistribute routes if we are shutting down (backport #14041)

21 months agobgpd: fix bgp evpn cli memory leaks. 14047/head
Abhinay Ramesh [Mon, 3 Jul 2023 09:40:11 +0000 (09:40 +0000)]
bgpd: fix bgp evpn cli memory leaks.

problem:
In CLI config codeflow there are memory leaks in failure scenario

Fix:
Code changes are done to free ecommunity

Signed-off-by: Abhinay Ramesh <rabhinay@vmware.com>
(cherry picked from commit 56b895c17242a608731b6b03a4909f258805caee)

21 months agobgpd: Do not try to redistribute routes if we are shutting down 14045/head
Donatas Abraitis [Tue, 18 Jul 2023 10:14:08 +0000 (13:14 +0300)]
bgpd: Do not try to redistribute routes if we are shutting down

When switching `router bgp`, `no router bgp` and doing redistributions, we should
ignore this action, otherwise memory leak happens:

```
Indirect leak of 400 byte(s) in 2 object(s) allocated from:
    0 0x7f81b36b3a06 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:153
    1 0x7f81b327bd2e in qcalloc lib/memory.c:105
    2 0x55f301d28628 in bgp_node_create bgpd/bgp_table.c:92
    3 0x7f81b3309d0b in route_node_new lib/table.c:52
    4 0x7f81b3309d0b in route_node_set lib/table.c:61
    5 0x7f81b330be0a in route_node_get lib/table.c:319
    6 0x55f301ce89df in bgp_redistribute_add bgpd/bgp_route.c:8907
    7 0x55f301dac182 in zebra_read_route bgpd/bgp_zebra.c:593
    8 0x7f81b334dcd7 in zclient_read lib/zclient.c:4179
    9 0x7f81b331d702 in event_call lib/event.c:1995
    10 0x7f81b325d597 in frr_run lib/libfrr.c:1213
    11 0x55f301b94b12 in main bgpd/bgp_main.c:505
    12 0x7f81b2b57082 in __libc_start_main ../csu/libc-start.c:308
```

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

21 months agoMerge pull request #14039 from FRRouting/mergify/bp/dev/9.0/pr-14033
Donatas Abraitis [Tue, 18 Jul 2023 12:22:22 +0000 (15:22 +0300)]
Merge pull request #14039 from FRRouting/mergify/bp/dev/9.0/pr-14033

Zebra same route (backport #14033)

21 months agozebra: Further handle route replace semantics 14039/head
Donald Sharp [Mon, 17 Jul 2023 14:00:32 +0000 (10:00 -0400)]
zebra: Further handle route replace semantics

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

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

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

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

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

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

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

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

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

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

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

bgpd: Prevent use after free (backport #14017)

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

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

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

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

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

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

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

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

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

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

fixes #13920

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

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

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

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

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

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

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

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

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

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

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

# Conflicts:
# .clang-format

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

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

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

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

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

bgpd: free bgp vpn policy

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Two minor changes for kernel routes:

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

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

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

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

ospf6d: unlock lsa (backport #13892)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Add an actual event pointer and just track it appropriately.

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

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

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

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

ospf6d: Stop crash in ospf6_write (backport #13897)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

eliminates tons of copy and paste code.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

staticd: remove unused YANG module (backport #13839)

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

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

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

backport of #13795

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

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

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

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

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

New requirements:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

mgmtd cleanup/simplify some code (backport #13766)

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

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

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

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

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

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

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

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

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

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