]> git.proxmox.com Git - mirror_frr.git/log
mirror_frr.git
16 months agoMerge pull request #13483 from opensourcerouting/fix/backport_d8be1399720ca36485b6a22...
Donald Sharp [Tue, 9 May 2023 17:30:51 +0000 (13:30 -0400)]
Merge pull request #13483 from opensourcerouting/fix/backport_d8be1399720ca36485b6a2209b143679b01b83cb

zebra: Reduce creation and fix memory leak of frrscripting pointers

16 months agozebra: Reduce creation and fix memory leak of frrscripting pointers
Donald Sharp [Fri, 5 May 2023 15:05:12 +0000 (11:05 -0400)]
zebra: Reduce creation and fix memory leak of frrscripting pointers

There are two issues being addressed:

a) The ZEBRA_ON_RIB_PROCESS_HOOK_CALL script point
was creating a fs pointer per dplane ctx in
rib_process_dplane_results().

b) The fs pointer was not being deleted and directly
leaked.

For (a) Move the creation of the fs to outside
the do while loop.

For (b) At function end ensure that the pointer
is actually deleted.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
16 months agoMerge pull request #13442 from FRRouting/mergify/bp/stable/8.5/pr-13436
Donatas Abraitis [Fri, 5 May 2023 16:49:41 +0000 (19:49 +0300)]
Merge pull request #13442 from FRRouting/mergify/bp/stable/8.5/pr-13436

ospfd: Fix memory leaks w/ `show ip ospf int X json` commands (backport #13436)

16 months agoospfd: Fix memory leaks w/ `show ip ospf int X json` commands
Donald Sharp [Thu, 4 May 2023 16:53:42 +0000 (12:53 -0400)]
ospfd: Fix memory leaks w/ `show ip ospf int X json` commands

FRR has a memory leak in the case when int X does not
exist and a memory leak when int X does exist.  Fix
these

Fixes: #13434
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
(cherry picked from commit 74e21732db129f7287d5ab227e45f305c5dbf34e)

16 months agoMerge pull request #13420 from FRRouting/mergify/bp/stable/8.5/pr-13020
Jafar Al-Gharaibeh [Thu, 4 May 2023 14:01:03 +0000 (09:01 -0500)]
Merge pull request #13420 from FRRouting/mergify/bp/stable/8.5/pr-13020

pimd: PIM not sending register packets after changing from non DR to DR (backport #13020)

16 months agopimd: PIM not sending register packets after changing from non DR to DR
Sai Gomathi N [Fri, 17 Mar 2023 10:51:16 +0000 (03:51 -0700)]
pimd: PIM not sending register packets after changing from non DR to DR

When the router is non dr for an interface, it installs mroute to drop
the packets from directly connected source. This was done to avoid packets
coming to cpu as nocache hit. Later when it gets change from non-DR to DR,
these entries are not cleared. So the packets are still dropped.
This causes register packets not getting generated.
So cleaning up the mroute entries and channel oil without
upstream reference which was created to drop.

Co-authored-by: Saravanan K <saravanank@vmware.com>
Signed-off-by: Sai Gomathi N <nsaigomathi@vmware.com>
(cherry picked from commit 1c883aef96013753f5467ba5e5028dee0f0a82c5)

17 months agoMerge pull request #13371 from FRRouting/mergify/bp/stable/8.5/pr-13330
Donatas Abraitis [Mon, 24 Apr 2023 19:07:10 +0000 (22:07 +0300)]
Merge pull request #13371 from FRRouting/mergify/bp/stable/8.5/pr-13330

zebra: EVPN handle duplicate detected local mac delete event (backport #13330)

17 months agozebra:fix evpn dup detected local mac del event
Chirag Shah [Sat, 22 Oct 2022 23:00:14 +0000 (16:00 -0700)]
zebra:fix evpn dup detected local mac del event

The current local mac delete event send to flag with force
always which breaks the duplicate detected MACs where
it requires to be resynced from bgpd to earlier state.

Ticket:#3233019
Issue:3233019

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

17 months agozebra: evpn handle del event for dup detected mac
Chirag Shah [Wed, 1 Dec 2021 04:42:01 +0000 (20:42 -0800)]
zebra: evpn handle del event for dup detected mac

Upon receiving local mobility event for MAC + NEIGH,
both are detected as duplicate upon hitting DAD threshold.

Duplicated detected ( freezed) MAC + NEIGH are not known
to bgpd.

If locally learnt MAC + NEIGH are deleted in kernel,
the MAC is marked as AUTO after sending delete event
to bgpd.

Bgpd only reinstalls best route for MAC_IP route (NEIGH)
but not for MAC event.
This puts a situation where MAC is AUTO state and
associated neigh as remote.

Fix:
DUPLICATE + LOCAL MAC deletion, set MAC delete request
as reinstall from bgpd.

Ticket:#2873307
Reviewed By:
Testing Done:

Freeze MAC + two NEIGHs in local mobility event.
Delete MAC and NEIGH from kerenl.
bgp rsync remote mac route which puts MAC to remote state.

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

17 months agoFRR Release 8.5.1 frr-8.5.1
Jafar Al-Gharaibeh [Sat, 22 Apr 2023 18:03:13 +0000 (13:03 -0500)]
FRR Release 8.5.1

* Bug Fixes

bgpd
  - Fix crash due to community aliases size
  - Aggregate-address memory leak fix
  - Bmp fix peer-up ports byte order
  - Check 7 bytes for long-lived graceful-restart capability
  - Copy the password from the previous peer on peer_xfer_config()
  - Do not allow a `no router bgp xxx` when autoimport is happening
  - Do not allow l3vni changes when shutting down
  - Do not announce routes immediatelly on filter updates
  - Do not call bgp_soft_reconfig_in() twice in a row on policy change
  - Evpn-mh esi not active suppress ead-es route
  - Fix crash for `show bgp ... neighbor received-routes detail|prefix`
  - Fix debug output for route-map names when using a unsuppress-map
  - Fix ecommunity parsing for as4
  - Fix for ain->attr corruption during path update
  - Increase buffer size used for dumping bgp to mrt files
  - Limit flowspec to no attribute means a implicit withdrawal
  - Prevent null pointer deref when outputting data

lib
   - Adjust only `any` flag for prefix-list entries if destroying
   - Destroy `any` flag when creating a prefix-list entry with prefix
   - Fix clear route-map cmd using defpy
   - Fix link state memory leak
   - Include clippy generated commands for routemap.c
   - On bfd peer shutdown actually stop event

ospfd
   - Cleanup some memory leaks on shutdown in ospf_apiserver.c
   - Fix for vitual-link crash in signal handler
   - Fix ospf_lsa memory leak
   - Fix ospf_ti_lfa drop of an entire table
   - Fixing summary origination after range configuration
   - Free up q_space in early return path
   - Log adjacency changes with neighbor ip in addition to neighbor id

pbrd
   - Fix mismatching in match src-dst

pim6d
   - Fixing mroutes not created after disabling and enabling pimv6.

pimd
   - Fix use after free issue for ifp's moving vrfs
   - In_multicast needs host order
   - Process no-forward bsm packet

ripd
   - Fix malformed route-map
   - Fix memory leak for ripd's route-map

staticd
   - Tell bfd that we are shutting down

tools
   - Fix missing remote-as configuration when reload
   - Frr-reload fix list value not present
   - Make check flag really work for reload
   - Set correct directory of vtysh for frr-reload.py

zebrad
   - Add link_nsid to zebra interface
   - Cleanup ctx leak on shutdown and turn off event
   - Evpn mh sync mac install as inactive
   - Fix for heap-use-after-free in evpn
   - Fix race during shutdown
   - Install directly connected route after interface flap

Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
17 months agoMerge pull request #13344 from opensourcerouting/fix/backport_8cb4892c0669d916557d693...
Donald Sharp [Fri, 21 Apr 2023 11:10:36 +0000 (07:10 -0400)]
Merge pull request #13344 from opensourcerouting/fix/backport_8cb4892c0669d916557d693b878420faec8e6e2a

bgpd: [8.5] Fix lcom->str string length to correctly cover aliases

17 months agobgpd: Fix lcom->str string length to correctly cover aliases
Donald Sharp [Thu, 20 Apr 2023 20:27:20 +0000 (16:27 -0400)]
bgpd: Fix lcom->str string length to correctly cover aliases

If you have a very large number of large communities whose
string length happened to be greater than BUFSIZ FRR's bgpd
would crash.  This is because bgpd would write beyond
the end of the string.

Originally the code auto-calculated the string size appropriately
but commit ed0e57e3f079352714c3a3a8a5b0dddf4aadfe1d modified
the string length to be a hard coded BUFSIZ.  When a route-map
like this is added:

route-map LARGE-OUT permit 10
 set large-community 4635:0:0 4635:1:906 4635:1:2906 4635:1:4515 4635:1:4594 4635:1:4641 4635:1:4760 4635:1:7979 4635:1:9253 4635:1:9293 4635:1:9304 4635:1:9908 4635:1:13335 4635:1:16265 4635:1:17924 4635:1:18013 4635:1:20940 4635:1:22822 4635:1:24429 4635:1:24482 4635:1:32590 4635:1:32934 4635:1:36692 4635:1:38008 4635:1:38819 4635:1:41378 4635:1:45753 4635:1:46489 4635:1:49544 4635:1:51847 4635:1:54574 4635:1:54994 4635:1:55720 4635:1:56059 4635:1:57724 4635:1:65021 4635:1:134823 4635:1:136907 4635:1:146961 24115:0:24115 24115:1:906 24115:1:2906 24115:1:4515 24115:1:4594 24115:1:4641 24115:1:4760 24115:1:7979 24115:1:9253 24115:1:9293 24115:1:9304 24115:1:9908 24115:1:13335 24115:1:16265 24115:1:17924 24115:1:18013 24115:1:20940 24115:1:22822 24115:1:24429 24115:1:24482 24115:1:32590 24115:1:32934 24115:1:36692 24115:1:38008 24115:1:38819 24115:1:41378 24115:1:45753 24115:1:46489 24115:1:49544 24115:1:51847 24115:1:54574 24115:1:54994 24115:1:55720 24115:1:56059 24115:1:57724 24115:1:65021 24115:1:134823 24115:1:136907 24115:1:100000 24115:1:100001 24115:1:100002
exit

BGP would have issues and crash.

Modify the code to correctly determine the string length of the communities
and to also double check if the string has an alias and ensure that the
string is still sufficiently large enough.  If not auto size it again.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
17 months agoMerge pull request #13338 from FRRouting/mergify/bp/stable/8.5/pr-13329
Jafar Al-Gharaibeh [Thu, 20 Apr 2023 04:06:24 +0000 (23:06 -0500)]
Merge pull request #13338 from FRRouting/mergify/bp/stable/8.5/pr-13329

bgpd: Fix for ain->attr corruption during path update (backport #13329)

17 months agobgpd: Fix for ain->attr corruption during path update
Pooja Jagadeesh Doijode [Wed, 19 Apr 2023 01:40:06 +0000 (18:40 -0700)]
bgpd: Fix for ain->attr corruption during path update

1. Consider a established L2VPN EVPN BGP peer with soft-reconfiguartion
   inbound configured

2. When the interface of this directly connected BGP peer is shutdown,
   bgp_soft_reconfig_table_update() is called, which memsets the evpn buffer
   and calls bgp_update() with received attributes stored in ain table(ain->attr).
   In bgp_update(), evpn_overlay attribute in ain->attr (which is an interned
   attr) was modified by doing a memcpy

3. Above action causes 2 attributes in the attrhash (which were previously different)
   to match!

4. Later during fsm change event of the peer, bgp_adj_in_remove() is called
   to clean up the ain->attr. But, because 2 attrs in attrhash match, it causes
   BGP to assert in bgp_attr_unintern()

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

17 months agoMerge pull request #13317 from FRRouting/mergify/bp/stable/8.5/pr-13312
Donatas Abraitis [Sun, 16 Apr 2023 15:58:32 +0000 (18:58 +0300)]
Merge pull request #13317 from FRRouting/mergify/bp/stable/8.5/pr-13312

zebra: EVPN MH ES-peer Sync MAC installed as inactive (backport #13312)

17 months agoMerge pull request #13315 from FRRouting/mergify/bp/stable/8.5/pr-13302
Donatas Abraitis [Sun, 16 Apr 2023 15:58:22 +0000 (18:58 +0300)]
Merge pull request #13315 from FRRouting/mergify/bp/stable/8.5/pr-13302

tools: fix missing remote-as configuration when reload (backport #13302)

17 months agozebra: evpn mh sync mac install as inactive
Chirag Shah [Fri, 14 Apr 2023 19:57:23 +0000 (12:57 -0700)]
zebra: evpn mh sync mac install as inactive

EVPN MH ES reduendant VTEPs need to install
sync MAC as notify inactive and generate
ND:Proxy stamped extended community on Type-2
route.

Ticket:#3436621
Issue:3436621

Testing Done:

tor-11 originates type-2 MAC route:

tor-11# bridge -d fdb show | grep 00:65:00:00:00:01
00:65:00:00:00:01 dev hostbond1 vlan 1000 notify master bridge static

tor-12 receives sync MAC route:

Before fix:
----------
tor-12:/# bridge -d fdb show | grep 00:65:00:00:00:01
00:65:00:00:00:01 dev hostbond1 vlan 1000 notify master bridge static

After fix: inactive is set to MAC entry
----------
tor-12:/#bridge -d fdb show | grep 00:65:00:00:00:01
00:65:00:00:00:01 dev hostbond1 vlan 1000 notify inactive master bridge
static

Notice the difference in `inactive` post notify on tor-12
with the fix.

Signed-off-by: Trey Aspelund <taspelund@nvidia.com>
Signed-off-by: Chirag Shah <chirag@nvidia.com>
(cherry picked from commit 4a1f91a366bacc8178afcc3d2712e08a3ba3e1ba)

17 months agotools: Make check flag really work for reload
anlan_cs [Fri, 14 Apr 2023 22:41:41 +0000 (06:41 +0800)]
tools: Make check flag really work for reload

The check flag of `found_pg_cmd` is already there, but not used.
So, make it really work for reload.

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

17 months agotools: fix missing remote-as configuration when reload
anlan_cs [Fri, 14 Apr 2023 00:32:32 +0000 (08:32 +0800)]
tools: fix missing remote-as configuration when reload

From commit `411d1a2`, `bgp_delete_nbr_remote_as_line()` is added to
remove some specific bgp neighbors.  But, when reloading the following
configuration, it will wrongly remove some good ones:
`neighbor 66.66.66.6 remote-as internal`:

```
router bgp 66
 bgp router-id 172.16.204.6
 neighbor ANLAN peer-group
 neighbor ANLAN remote-as internal
 neighbor 66.66.66.6 remote-as internal <- LOST
 neighbor 66.66.66.60 peer-group ANLAN
```

The reason is that "66.66.66.6" is included in "66.66.66.60" literally,
then it is mistakenly thought to be a match.  Just fix it with
excat match.

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

17 months agoMerge pull request #13307 from FRRouting/mergify/bp/stable/8.5/pr-13297
Donald Sharp [Fri, 14 Apr 2023 14:30:13 +0000 (10:30 -0400)]
Merge pull request #13307 from FRRouting/mergify/bp/stable/8.5/pr-13297

ospf6d: missing ECMP NHs in certain topologies (backport #13297)

17 months agoMerge pull request #13305 from FRRouting/mergify/bp/stable/8.5/pr-13301
Donald Sharp [Fri, 14 Apr 2023 13:54:04 +0000 (09:54 -0400)]
Merge pull request #13305 from FRRouting/mergify/bp/stable/8.5/pr-13301

bgpd: Fix crash for `show bgp ... neighbor received-routes detail|PREFIX (backport #13301)

17 months agoospf6d: missing ECMP NHs in certain topologies
lynne [Wed, 23 Jun 2021 17:15:17 +0000 (13:15 -0400)]
ospf6d: missing ECMP NHs in certain topologies

When ospf6 is started up and SPF is run depending on which route is
selected as the parent route we could miss adding a NH.   If one
possible parent route has two equal cost paths and the second possible
parent route has only one depending on which one is selected first
determines if we have have one or two NHs.

In the network below when creating a route 2001:db8:3:4::/64 in R2.
When SPF is run there are two possible parent routes R3 and R4.

     2001:db8:1:2  +-----+   2001:db8:2:5
    +--------------+  2  +---------------+
    |          ::2 |     | ::2           |
    |              +-----+               |
    |                                    |
 ::1|                                    |
+-----+                                  |::5
|  1  |2001:db8:1:3+-----+2001:db8:3:5+-----+2001:db8:5:6+-----+
|     +------------+  3  +------------+  5  +------------+  6  |
+-----+ ::1    ::3 |     |::3     ::5 |     |::5      ::6|     |
 ::1|              +-----+            +-----+            +-----+
    |                 |::3
    |                 | 2001:db8:3:4
    |                 |
    |                 |::4
    | 2001:db8:1:4 +-----+
    +--------------+  4  |
               ::4 |     |
                   +-----+

The problem was if we first created the route to 2001:db8:3:4::/64 with R3
as the parent route all is fine.  The code was merging the NH from the parent
route and R3 has 2 NH, one pointing to R1 and one to R5.   But if route
2001:db8:3:4::/64 was first created with parent as R4, it has only one NH
pointing to R1, and then later a new vertex was created pointing to R3 the
code would only copy the nhs from the vertex not from the parent route.   The
vertex always has just one NH.   But the parent route could have more.  So
when we would bringup this setup one time we would see one NH for
2001:db8:3:4::/64 and the next time we would see two NHs.  The code has been
modified so that it behaves the same when the route is first created, or when
a vertex is created, it selects the NHs from the parent route.

Signed-off-by: Lynne Morrison <lynne@voltanet.io>
(cherry picked from commit 637e6f293b84c8c21d91224267a85ced30e9f8cf)

17 months agobgpd: Fix crash for `show bgp ... neighbor received-routes detail|PREFIX`
Donatas Abraitis [Thu, 13 Apr 2023 20:37:06 +0000 (23:37 +0300)]
bgpd: Fix crash for `show bgp ... neighbor received-routes detail|PREFIX`

BGP: Received signal 11 at 1681287514 (si_addr 0x8, PC 0x559ab42eb1d9); aborting...
BGP: /lib/libfrr.so.0(zlog_backtrace_sigsafe+0x71) [0x7f4356b19af1]
BGP: /lib/libfrr.so.0(zlog_signal+0xf9) [0x7f4356b19cf9]
BGP: /lib/libfrr.so.0(+0xf5af5) [0x7f4356b4baf5]
BGP: /lib/x86_64-linux-gnu/libpthread.so.0(+0x14420) [0x7f43568ab420]
BGP: /usr/lib/frr/bgpd(prefix_rd2str+0x29) [0x559ab42eb1d9]
BGP: /usr/lib/frr/bgpd(route_vty_out_detail_header+0x7ca) [0x559ab43061ba]
BGP: /usr/lib/frr/bgpd(+0x1771a6) [0x559ab430a1a6]
BGP: /usr/lib/frr/bgpd(+0x177f06) [0x559ab430af06]
BGP: /usr/lib/frr/bgpd(+0x178c8b) [0x559ab430bc8b]
BGP: /usr/lib/frr/bgpd(+0x179e7e) [0x559ab430ce7e]
BGP: /lib/libfrr.so.0(+0x9417e) [0x7f4356aea17e]
BGP: /lib/libfrr.so.0(cmd_execute_command+0x111) [0x7f4356aea321]
BGP: /lib/libfrr.so.0(cmd_execute+0xd0) [0x7f4356aea4c0]
BGP: /lib/libfrr.so.0(+0x10d5de) [0x7f4356b635de]
BGP: /lib/libfrr.so.0(+0x10d81d) [0x7f4356b6381d]
BGP: /lib/libfrr.so.0(+0x110b03) [0x7f4356b66b03]
BGP: /lib/libfrr.so.0(event_call+0x81) [0x7f4356b5df91]
BGP: /lib/libfrr.so.0(frr_run+0xe8) [0x7f4356b11b58]
BGP: /usr/lib/frr/bgpd(main+0x385) [0x559ab4281d55]
BGP: /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3) [0x7f43566c9083]
BGP: /usr/lib/frr/bgpd(_start+0x2e) [0x559ab428437e]
BGP: in thread vtysh_read scheduled from lib/vty.c:2833 vty_event()

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

17 months agoMerge pull request #13296 from FRRouting/mergify/bp/stable/8.5/pr-13097
Donald Sharp [Thu, 13 Apr 2023 14:39:57 +0000 (10:39 -0400)]
Merge pull request #13296 from FRRouting/mergify/bp/stable/8.5/pr-13097

pim6d: mroutes not created after disabling and enabling PIMv6. (backport #13097)

17 months agoMerge pull request #13295 from FRRouting/mergify/bp/stable/8.5/pr-13244
Donald Sharp [Thu, 13 Apr 2023 14:39:06 +0000 (10:39 -0400)]
Merge pull request #13295 from FRRouting/mergify/bp/stable/8.5/pr-13244

pimd: Process no-forward BSM packet (backport #13244)

17 months agopim6d: Fixing mroutes not created after disabling and enabling PIMv6.
Abhishek N R [Fri, 24 Mar 2023 04:55:06 +0000 (21:55 -0700)]
pim6d: Fixing mroutes not created after disabling and enabling PIMv6.

After doing "no ipv6 pim" and "ipv6 pim" on receiver interface in LHR,
mroutes were not created.

When we enable pim after disabling it, we refresh the membership on pim interface.
First we clear the membership on the interface, then we add it back.
For PIMv6 we were only clearing it, membership was not added back. So mroutes were not created.

Now added code to fetch all the local membership information into PIM.

Fixes: #12005, #12820
Signed-off-by: Abhishek N R <abnr@vmware.com>
(cherry picked from commit 00fed6ed3b412c24a3c9aff455065b39f8ec8f6b)

17 months agopimd: Process no-forward BSM packet
Sarita Patra [Mon, 10 Apr 2023 05:30:44 +0000 (22:30 -0700)]
pimd: Process no-forward BSM packet

Topology Used:
=============
Cisco---FRR4----FRR2

Initially PIM nbr is down between FRR4----FRR2 from FRR2 side
Cisco is sending BSR packet to FRR4.

Problem Statement:
=================
No shutdown the PIM neighbor on FRR2 towards FRR4.
FRR2, receives BSR packet immediately as the new neighbor
comes up. This BSR packet is having no-forward bit set.
FRR2 is not able to process the BSR packet, and drop the
BSR packet.

Root Cause:
==========
When PIMD comes up, we start BSM timer for 60 seconds.
Here, the value accept_nofwd_bsm is setting to false.

FRR2, when receives no-forward BSR packet, it is getting
accept_nofwd_bsm value as false.

So, it drops, the no-forward BSM packet.

Fix:
===
Set accept_nofwd_bsm as false after first BSM packet received.

Signed-off-by: Sarita Patra <saritap@vmware.com>
(cherry picked from commit 8b462d557905200d98c7a8965b3d223637c3c5dd)

17 months agoMerge pull request #13278 from FRRouting/mergify/bp/stable/8.5/pr-13269
Jafar Al-Gharaibeh [Wed, 12 Apr 2023 21:35:37 +0000 (16:35 -0500)]
Merge pull request #13278 from FRRouting/mergify/bp/stable/8.5/pr-13269

ospfd: Fix ospf_lsa memory leak (backport #13269)

17 months agoMerge pull request #13280 from FRRouting/mergify/bp/stable/8.5/pr-13193
Jafar Al-Gharaibeh [Wed, 12 Apr 2023 21:35:17 +0000 (16:35 -0500)]
Merge pull request #13280 from FRRouting/mergify/bp/stable/8.5/pr-13193

lib: link state leak fix (backport #13193)

17 months agoMerge pull request #13257 from FRRouting/mergify/bp/stable/8.5/pr-13226
Donald Sharp [Wed, 12 Apr 2023 18:24:11 +0000 (14:24 -0400)]
Merge pull request #13257 from FRRouting/mergify/bp/stable/8.5/pr-13226

ripd: Fix memory leak for ripd's route-map (backport #13226)

17 months agoMerge pull request #13274 from FRRouting/mergify/bp/stable/8.5/pr-13249
Donald Sharp [Wed, 12 Apr 2023 17:38:30 +0000 (13:38 -0400)]
Merge pull request #13274 from FRRouting/mergify/bp/stable/8.5/pr-13249

zebra: Mark connected route as installed after interface flap event (backport #13249)

17 months agolib: Fix link state memory leak
Keelan10 [Mon, 3 Apr 2023 07:41:04 +0000 (11:41 +0400)]
lib: Fix link state memory leak

Free link message data when a delete event is recorded.

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

17 months agoospfd: Fix ospf_lsa memory leak
Keelan10 [Wed, 12 Apr 2023 09:36:40 +0000 (13:36 +0400)]
ospfd: Fix ospf_lsa memory leak

Free translated LSA when LSA installation fails

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

17 months agozebra: Install directly connected route after interface flap
Pooja Jagadeesh Doijode [Mon, 10 Apr 2023 23:03:23 +0000 (16:03 -0700)]
zebra: Install directly connected route after interface flap

Issue:
After vlan flap, zebra was not marking the selected/best route as installed.

As a result, when a static route was configured with nexthop as directly
connected interface's(vlan) IP, the static route was not being installed
in the kernel since its nexthop was unresolved. The nexthop was marked
unresolved because zebra failed to mark the best route as installed after
interface flap.

This was happening because, in dplane_route_update_internal() if the old and
new context type, and nexthop group id are the same, then zebra doesn't send
down a route replace request to kernel. But, the installed (ROUTE_ENTRY_INSTALLED)
flag is set when zebra receives a response from kernel. Since the
request to kernel was being skipped for the route entry, installed flag
was not being set

Fix:
In dplane_route_update_internal() if the old and new context type, and
nexthop group id are the same, then before returning, installed flag will
be set on the route-entry if it's not set already.

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

17 months agoMerge pull request #13265 from mjstapp/fix_dplane_shut_race_8_5
Jafar Al-Gharaibeh [Wed, 12 Apr 2023 04:39:54 +0000 (23:39 -0500)]
Merge pull request #13265 from mjstapp/fix_dplane_shut_race_8_5

zebra: fix race during shutdown

17 months agoMerge pull request #13266 from FRRouting/mergify/bp/stable/8.5/pr-12959
Jafar Al-Gharaibeh [Wed, 12 Apr 2023 04:39:27 +0000 (23:39 -0500)]
Merge pull request #13266 from FRRouting/mergify/bp/stable/8.5/pr-12959

zebra: Add link_nsid to zebra interface (backport #12959)

17 months agozebra: Add link_nsid to zebra interface
Xiao Liang [Tue, 21 Feb 2023 06:00:36 +0000 (14:00 +0800)]
zebra: Add link_nsid to zebra interface

Create VRF and interfaces:

    ip netns add vrf1
    ip link add veth1 index 100 type veth
    ip link add link veth1 veth1.200 type vlan id 200
    ip link set veth1.200 netns vrf1
    ip -n vrf1 link add veth2 index 100 type veth

After reloading zebra, "show interface veth1.200" shows wrong parent
interface:

    test# show interface veth1.200
    Interface veth1.200 is down
      ...
      Parent interface: veth2

This is because veth1.200 and veth1 are in different netns, and veth2
happens to have the same ifindex as veth1, in the same netns of
veth1.200.
When looking for parent, link-ifindex 100 should be looked up within
link-netns, rather than that of the child interface.

Add link_nsid to zebra interface, so that the <link_nsid, link_ifindex>
pair can uniquely identify the link interface.

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

17 months agozebra: fix race during shutdown
Mark Stapp [Tue, 11 Apr 2023 19:58:13 +0000 (15:58 -0400)]
zebra: fix race during shutdown

During shutdown, the main pthread stops the dplane pthread
before exiting. Don't try to clean up any events scheduled
to the dplane pthread at that point - just let the thread
exit and clean up. This is the 8.5 version.

Signed-off-by: Mark Stapp <mjs@labn.net>
17 months agoMerge pull request #13255 from FRRouting/mergify/bp/stable/8.5/pr-13240
Russ White [Tue, 11 Apr 2023 13:53:42 +0000 (09:53 -0400)]
Merge pull request #13255 from FRRouting/mergify/bp/stable/8.5/pr-13240

bgpd: EVPN-MH ESI is not active suppress EAD-ES Type-1 route (backport #13240)

17 months agoMerge pull request #13251 from FRRouting/mergify/bp/stable/8.5/pr-13247
Donatas Abraitis [Tue, 11 Apr 2023 12:49:14 +0000 (15:49 +0300)]
Merge pull request #13251 from FRRouting/mergify/bp/stable/8.5/pr-13247

Evpn crashes and other ilk (backport #13247)

17 months agoripd: Fix memory leak for ripd's route-map
anlan_cs [Thu, 6 Apr 2023 13:17:05 +0000 (21:17 +0800)]
ripd: Fix memory leak for ripd's route-map

When cleaning `ripd`, it should free `ctx->name` of `struct if_rmap_ctx`,
not `ctx` itself.  Otherwise, it will lead to memory leak.

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

17 months agobgpd:evpn-mh esi not active suppress ead-es route
Chirag Shah [Sat, 8 Apr 2023 03:14:25 +0000 (20:14 -0700)]
bgpd:evpn-mh esi not active suppress ead-es route

update_type1_routes_for_evi() is called from
L3VNI/L2VNI up event, if ESI is not UP then
do not advertise EAD-ES Type-1 route.
Just like from multiple places EAD-ES route
origination checks for its oper status.

Ticket:#3413454
Issue:3413454

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

17 months agobgpd: Do not allow a `no router bgp XXX` when autoimport is happening
Donald Sharp [Mon, 10 Apr 2023 18:04:27 +0000 (14:04 -0400)]
bgpd: Do not allow a `no router bgp XXX` when autoimport is happening

When we have these sequence of events causing a crash in
evpn_type5_test_topo1:

(A) no router bgp vrf RED 100
   this schedules for deletion the vrf RED instance
(B) a l3vni change event from zebra
   this creates a bgp instance for VRF RED in some cases
   additionally it auto imports evpn routes into VRF RED
   Please note this is desired behavior to allow for the
   auto importation of evpn vrf routes
(C) no router bgp 100
   The code was allowing the deletion of the default
   instance and causing tests to crash.

Effectively the test in bgp_vty to allow/dissallow
the removal of the default instance was not correct
for the case when (B) happens.

Let's just not allow the command to succeed in this case as that
the test was wrong.

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

17 months agobgpd: Do not allow l3vni changes when shutting down
Donald Sharp [Mon, 10 Apr 2023 17:59:48 +0000 (13:59 -0400)]
bgpd: Do not allow l3vni changes when shutting down

When a `no router bgp XXX` is issued and the bgp instance
is in the process of shutting down, do not allow a l3vni
change coming up from zebra to do anything.  We can just
safely ignore it at this point in time.

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

17 months agobgpd: Use the actual pointer type instead of a void
Donald Sharp [Mon, 10 Apr 2023 18:02:18 +0000 (14:02 -0400)]
bgpd: Use the actual pointer type instead of a void

Let's cut to the chase, we know the pointer type and
it allows us to not to some gyrations.

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

17 months agoMerge pull request #13232 from FRRouting/mergify/bp/stable/8.5/pr-13222
Jafar Al-Gharaibeh [Fri, 7 Apr 2023 19:28:41 +0000 (14:28 -0500)]
Merge pull request #13232 from FRRouting/mergify/bp/stable/8.5/pr-13222

Limit scope (backport #13222)

17 months agobgpd: Treat withdraw variable as a bool
Donald Sharp [Wed, 5 Apr 2023 19:25:57 +0000 (15:25 -0400)]
bgpd: Treat withdraw variable as a bool

Used as a bool, treated as a bool.  Make it a bool

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

17 months agobgpd: Limit flowspec to no attribute means a implicit withdrawal
Donald Sharp [Wed, 5 Apr 2023 18:57:05 +0000 (14:57 -0400)]
bgpd: Limit flowspec to no attribute means a implicit withdrawal

All other parsing functions done from bgp_nlri_parse() assume
no attributes == an implicit withdrawal.  Let's move
bgp_nlri_parse_flowspec() into the same alignment.

Reported-by: Matteo Memelli <mmemelli@amazon.it>
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
(cherry picked from commit cfd04dcb3e689754a72507d086ba3b9709fc5ed8)

17 months agobgpd: Conform bgp_packet.h with coding standards
Donald Sharp [Wed, 5 Apr 2023 18:51:47 +0000 (14:51 -0400)]
bgpd: Conform bgp_packet.h with coding standards

FRR's standards state that function declarations should
have actual variable names for parameters passed in.
Let's make this so for bgp_packet.h

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

17 months agoMerge pull request #13190 from FRRouting/mergify/bp/stable/8.5/pr-13175
Donatas Abraitis [Wed, 5 Apr 2023 13:23:25 +0000 (16:23 +0300)]
Merge pull request #13190 from FRRouting/mergify/bp/stable/8.5/pr-13175

zebra: Cleanup ctx leak on shutdown and turn off event (backport #13175)

17 months agoMerge pull request #13211 from FRRouting/mergify/bp/stable/8.5/pr-13181
Donatas Abraitis [Wed, 5 Apr 2023 07:15:00 +0000 (10:15 +0300)]
Merge pull request #13211 from FRRouting/mergify/bp/stable/8.5/pr-13181

bgpd: fix ecommunity parsing for AS4 (backport #13181)

17 months agozebra: Cleanup ctx leak on shutdown and turn off event
Donald Sharp [Fri, 31 Mar 2023 13:08:23 +0000 (09:08 -0400)]
zebra: Cleanup ctx leak on shutdown and turn off event

two things:

On shutdown cleanup any events associated with the update walker.
Also do not allow new events to be created.

Fixes this mem-leak:

./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790:Direct leak of 8 byte(s) in 1 object(s) allocated from:
./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790-    #0 0x7f0dd0b08037 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790-    #1 0x7f0dd06c19f9 in qcalloc lib/memory.c:105
./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790-    #2 0x55b42fb605bc in rib_update_ctx_init zebra/zebra_rib.c:4383
./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790-    #3 0x55b42fb6088f in rib_update zebra/zebra_rib.c:4421
./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790-    #4 0x55b42fa00344 in netlink_link_change zebra/if_netlink.c:2221
./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790-    #5 0x55b42fa24622 in netlink_information_fetch zebra/kernel_netlink.c:399
./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790-    #6 0x55b42fa28c02 in netlink_parse_info zebra/kernel_netlink.c:1183
./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790-    #7 0x55b42fa24951 in kernel_read zebra/kernel_netlink.c:493
./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790-    #8 0x7f0dd0797f0c in event_call lib/event.c:1995
./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790-    #9 0x7f0dd0684fd9 in frr_run lib/libfrr.c:1185
./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790-    #10 0x55b42fa30caa in main zebra/main.c:465
./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790-    #11 0x7f0dd01b5d09 in __libc_start_main ../csu/libc-start.c:308
./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790-
./msdp_topo1.test_msdp_topo1/r2.zebra.asan.1117790-SUMMARY: AddressSanitizer: 8 byte(s) leaked in 1 allocation(s).

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
(cherry picked from commit 3cd0accb5051e900ab343d5fa7c59360c0c1a812)
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
17 months agoMerge pull request #13210 from FRRouting/mergify/bp/stable/8.5/pr-13192
Donatas Abraitis [Wed, 5 Apr 2023 05:38:27 +0000 (08:38 +0300)]
Merge pull request #13210 from FRRouting/mergify/bp/stable/8.5/pr-13192

ripd: Fix malformed route-map (backport #13192)

17 months agotests: add test to validate 4-byte ecomm parsing
Trey Aspelund [Mon, 3 Apr 2023 21:03:40 +0000 (21:03 +0000)]
tests: add test to validate 4-byte ecomm parsing

Signed-off-by: Trey Aspelund <taspelund@nvidia.com>
(cherry picked from commit f615e6dc409c214e66863e8c2ef94775edcac050)

17 months agobgpd: fix ecommunity parsing for AS4
Trey Aspelund [Fri, 31 Mar 2023 21:46:21 +0000 (17:46 -0400)]
bgpd: fix ecommunity parsing for AS4

The parser for extended communities was incorrectly disallowing an
operator from configuring "Route Origin" extended communities
(e.g. RD/RT/SoO) with a 4-byte value matching BGP_AS4_MAX (UINT32_MAX)
and allowed the user to overflow UINT32_MAX. This updates the parser to
read the value as a uint64_t so that we can do proper checks on the
upper bounds (> BGP_AS4_MAX || errno).

before:
```
TORC11(config-router-af)# neighbor uplink-1 soo 4294967296:65
TORC11(config-router-af)# do sh run | include soo
  neighbor uplink-1 soo 0:65
TORC11(config-router-af)# neighbor uplink-1 soo 4294967295:65
% Malformed SoO extended community
TORC11(config-router-af)#
```

after:
```
TORC11(config-router-af)# neighbor uplink-1 soo 4294967296:65
% Malformed SoO extended community
TORC11(config-router-af)# neighbor uplink-1 soo 4294967295:65
TORC11(config-router-af)# do sh run | include soo
  neighbor uplink-1 soo 4294967295:65
TORC11(config-router-af)#
```

Signed-off-by: Trey Aspelund <taspelund@nvidia.com>
(cherry picked from commit b571d79d6482217c599c53976cb8cf0ec77b847f)

17 months agoripd: Fix malformed route-map
anlan_cs [Sun, 2 Apr 2023 00:33:25 +0000 (08:33 +0800)]
ripd: Fix malformed route-map

Currently the process of the `route-map` configuration for `per-vrf-rip`
is wrong.

There are two problems:
1. `ctx->name` for `if_rmap_ctx`  is not initialized in `if_rmap_ctx_create()`.
2.  The global `if_rmap_ctx_list` is wrongly used for `per-vrf-rip`.

So, two changes for it:
1. Correctly initializes `ctx->name`.
2. Use specific `if_rmap_ctx` for `per-vrf-rip`, not global one.

Note, this related implementation for `route-map` is only for `ripd`.

Before:
```
anlan(config)# route rip vrf vrf1
anlan(config-router)# route-map aa in lan
anlan(config-router)# do show run
!
router rip
 route-map aa in lan
exit
!
```

After:
```
anlan(config)# route rip vrf vrf1
anlan(config-router)# route-map aa in lan
anlan(config-router)# do show run
!
router rip vrf vrf1
 route-map aa in lan
exit
!
```

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

17 months agoMerge pull request #13203 from FRRouting/mergify/bp/stable/8.5/pr-13198
Donatas Abraitis [Tue, 4 Apr 2023 12:27:36 +0000 (15:27 +0300)]
Merge pull request #13203 from FRRouting/mergify/bp/stable/8.5/pr-13198

bgpd: bmp fix peer-up ports byte order (backport #13198)

17 months agobgpd: bmp fix peer-up ports byte order
Maxence Younsi [Mon, 3 Apr 2023 15:19:32 +0000 (17:19 +0200)]
bgpd: bmp fix peer-up ports byte order

added htons to ports in the peer-up message to fix byte order

Signed-off-by: Maxence Younsi <mx.yns@outlook.fr>
(cherry picked from commit 9e681c84fa07d768d41fb8fba269c965c8c08a4b)

17 months agoMerge pull request #13180 from FRRouting/mergify/bp/stable/8.5/pr-13139
Donatas Abraitis [Sun, 2 Apr 2023 17:30:02 +0000 (20:30 +0300)]
Merge pull request #13180 from FRRouting/mergify/bp/stable/8.5/pr-13139

bgpd: trim long neighbor description with no whitespace (backport #13139)

17 months agoMerge pull request #13173 from FRRouting/mergify/bp/stable/8.5/pr-13155
Donatas Abraitis [Fri, 31 Mar 2023 20:46:44 +0000 (23:46 +0300)]
Merge pull request #13173 from FRRouting/mergify/bp/stable/8.5/pr-13155

tests: Check received routes count for labeled-unicast with addpath (backport #13155)

17 months agobgpd: Trim long neighbor description with no whitespace
rbarroetavena [Thu, 23 Mar 2023 19:19:48 +0000 (16:19 -0300)]
bgpd: Trim long neighbor description with no whitespace

Fix for missing neighbor description in "show bgp summary [wide]"
when its length exceeds 20[64] chars and it doesn't contain
withespaces.
Existing behavior remains if description contains whitespaces
before size limit.

Signed-off-by: rbarroetavena <rbarroetavena@gmail.com>
(cherry picked from commit 420ac3d24cd4f78f05826f7d58a794e0ffc5543f)

17 months agotests: Check received routes count for labeled-unicast with addpath
Donatas Abraitis [Thu, 30 Mar 2023 13:50:15 +0000 (16:50 +0300)]
tests: Check received routes count for labeled-unicast with addpath

Test failed time to time, let's try this way:

```
$ for x in $(seq 1 20); do cp test_bgp_labeled_unicast_addpath.py test_$x.py; done
$ sudo pytest -s -n 20
```

Ran 10 times using this pattern, no failure :shrug:

Before this change, we checked advertised routes, and at some point `=` was
missing from the output, but advertised correctly. Receiving router gets as
much routes as expected to receive.

I reversed checking received routes, not advertised.

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

17 months agoMerge pull request #13169 from FRRouting/mergify/bp/stable/8.5/pr-13148
Donald Sharp [Fri, 31 Mar 2023 11:46:54 +0000 (07:46 -0400)]
Merge pull request #13169 from FRRouting/mergify/bp/stable/8.5/pr-13148

bgpd : memory leak fix for aggregate-address on cleanup (backport #13148)

17 months agoMerge pull request #13168 from FRRouting/mergify/bp/stable/8.5/pr-13153
Donatas Abraitis [Fri, 31 Mar 2023 09:19:31 +0000 (12:19 +0300)]
Merge pull request #13168 from FRRouting/mergify/bp/stable/8.5/pr-13153

bgpd: increase buffer size used for dumping BGP to MRT files (backport #13153)

17 months agobgpd : aggregate-address memory leak fix
Samanvitha B Bhargav [Thu, 30 Mar 2023 05:35:44 +0000 (22:35 -0700)]
bgpd : aggregate-address memory leak fix

Memory leaks are observed in the cleanup code. When “no router bgp" is executed,
cleanup in that flow for aggregate-address command is not taken care.

fixes the below leak:
    --
    ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444:Direct leak of 152 byte(s) in 1 object(s) allocated from:
    ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444-    #0 0x7f163e911037 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
    ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444-    #1 0x7f163e4b9259 in qcalloc lib/memory.c:105
    ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444-    #2 0x562bf42ebbd5 in bgp_aggregate_new bgpd/bgp_route.c:7239
    ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444-    #3 0x562bf42f14e8 in bgp_aggregate_set bgpd/bgp_route.c:8421
    ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444-    #4 0x562bf42f1e55 in aggregate_addressv6_magic bgpd/bgp_route.c:8592
    ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444-    #5 0x562bf42be3f5 in aggregate_addressv6 bgpd/bgp_route_clippy.c:341
    ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444-    #6 0x7f163e3f1e1b in cmd_execute_command_real lib/command.c:988
    ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444-    #7 0x7f163e3f219c in cmd_execute_command lib/command.c:1048
    ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444-    #8 0x7f163e3f2df4 in cmd_execute lib/command.c:1215
    ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444-    #9 0x7f163e5a2d73 in vty_command lib/vty.c:544
    ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444-    #10 0x7f163e5a79c8 in vty_execute lib/vty.c:1307
    ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444-    #11 0x7f163e5ad299 in vtysh_read lib/vty.c:2216
    ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444-    #12 0x7f163e593f16 in event_call lib/event.c:1995
    ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444-    #13 0x7f163e47c839 in frr_run lib/libfrr.c:1185
    ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444-    #14 0x562bf414e58d in main bgpd/bgp_main.c:505
    ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444-    #15 0x7f163de66d09 in __libc_start_main ../csu/libc-start.c:308
    ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444-
    ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444:Direct leak of 152 byte(s) in 1 object(s) allocated from:
    ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444-    #0 0x7f163e911037 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
    ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444-    #1 0x7f163e4b9259 in qcalloc lib/memory.c:105
    ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444-    #2 0x562bf42ebbd5 in bgp_aggregate_new bgpd/bgp_route.c:7239
    ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444-    #3 0x562bf42f14e8 in bgp_aggregate_set bgpd/bgp_route.c:8421
    ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444-    #4 0x562bf42f1cde in aggregate_addressv4_magic bgpd/bgp_route.c:8543
    ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444-    #5 0x562bf42bd258 in aggregate_addressv4 bgpd/bgp_route_clippy.c:255
    ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444-    #6 0x7f163e3f1e1b in cmd_execute_command_real lib/command.c:988
    ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444-    #7 0x7f163e3f219c in cmd_execute_command lib/command.c:1048
    ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444-    #8 0x7f163e3f2df4 in cmd_execute lib/command.c:1215
    ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444-    #9 0x7f163e5a2d73 in vty_command lib/vty.c:544
    ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444-    #10 0x7f163e5a79c8 in vty_execute lib/vty.c:1307
    ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444-    #11 0x7f163e5ad299 in vtysh_read lib/vty.c:2216
    ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444-    #12 0x7f163e593f16 in event_call lib/event.c:1995
    ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444-    #13 0x7f163e47c839 in frr_run lib/libfrr.c:1185
    ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444-    #14 0x562bf414e58d in main bgpd/bgp_main.c:505
    ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444-    #15 0x7f163de66d09 in __libc_start_main ../csu/libc-start.c:308
    ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444-
    ./bgp_local_asn_dot.test_bgp_local_asn_dot_agg/r3.bgpd.asan.3410444-SUMMARY: AddressSanitizer: 304 byte(s) leaked in 2 allocation(s).

Signed-off-by: Samanvitha B Bhargav <bsamanvitha@vmware.com>
(cherry picked from commit 7a70d99038a67f693c40d4f1c03027a2b05bfaf8)
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
17 months agobgpd: increase buffer size used for dumping BGP to MRT files
jeclarke [Thu, 30 Mar 2023 13:23:48 +0000 (14:23 +0100)]
bgpd: increase buffer size used for dumping BGP to MRT files

Signed-off-by: James Clarke (jamclar2) <jamclar2@cisco.com>
(cherry picked from commit 461b6cd4d7f27624569f7a557f9abf91a85ab3cc)

17 months agoMerge pull request #13137 from FRRouting/mergify/bp/stable/8.5/pr-13124
Donatas Abraitis [Thu, 30 Mar 2023 09:38:16 +0000 (12:38 +0300)]
Merge pull request #13137 from FRRouting/mergify/bp/stable/8.5/pr-13124

bgpd: Do not announce routes immediatelly on prefix/distribute/filter changes (backport #13124)

17 months agobgpd: Do not call bgp_soft_reconfig_in() twice in a row on policy change
Donatas Abraitis [Wed, 29 Mar 2023 20:21:35 +0000 (23:21 +0300)]
bgpd: Do not call bgp_soft_reconfig_in() twice in a row on policy change

Just realized it was a stupid copy/paste.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
18 months agobgpd: Do not announce routes immediatelly on filter updates
Donatas Abraitis [Tue, 28 Mar 2023 13:18:47 +0000 (16:18 +0300)]
bgpd: Do not announce routes immediatelly on filter updates

If we set `bgp route-map delay-timer X`, we should ignore starting to announce
routes immediately, and wait for delay timer to expire (or ignore at all if set
to zero).

f1aa49293a4a8302b70989aaa9ceb715385c3a7e broke this because we always sent
route refresh and on receiving BoRR before sending back EoRR.

Let's get fix this.

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

18 months agoMerge pull request #13129 from FRRouting/mergify/bp/stable/8.5/pr-13118
Donatas Abraitis [Wed, 29 Mar 2023 07:31:18 +0000 (10:31 +0300)]
Merge pull request #13129 from FRRouting/mergify/bp/stable/8.5/pr-13118

bgpd: Copy the password from the previous peer on peer_xfer_config() (backport #13118)

18 months agoMerge pull request #13134 from FRRouting/mergify/bp/stable/8.5/pr-13120
Donatas Abraitis [Wed, 29 Mar 2023 07:05:51 +0000 (10:05 +0300)]
Merge pull request #13134 from FRRouting/mergify/bp/stable/8.5/pr-13120

ospfd: Fix for vitual-link crash in signal handler (backport #13120)

18 months agoMerge pull request #13126 from FRRouting/mergify/bp/stable/8.5/pr-13123
Donatas Abraitis [Wed, 29 Mar 2023 06:54:18 +0000 (09:54 +0300)]
Merge pull request #13126 from FRRouting/mergify/bp/stable/8.5/pr-13123

bgpd: Fix debug output for route-map names when using a unsuppress-map (backport #13123)

18 months agoospfd: Fix for vitual-link crash in signal handler
Pooja Jagadeesh Doijode [Mon, 27 Mar 2023 17:31:00 +0000 (10:31 -0700)]
ospfd: Fix for vitual-link crash in signal handler

Whenever OSPF virtual-link is created, a virtual interface is
associated with it. Name of the virtual interface is derived by
combining "VLINK" string with the value of vlink_count, which is a global
variable.

Problem:
Consider a scenario where 2 virtual links A and B are created in OSPF with
virtual interfaces VLINK0 and VLINK1 respectively. When virtual-link A is unconfigured
and reconfigured, new interface name derived for it will be VLINK1, which is already
associated with virtual-link B. Due to this, both virtual-links A and B will
point to the same interface, VLINK1.

During FRR restart when signal handler is called, OSPF goes through all the virtual
links and deletes the interface(oi) associated with it. During the deletion of interface
for virtual-link B,it accesses the interface which was deleted already(which was deleted
during deletion of virual-link A) and whose fields were set to NULL. This
leads to OSPF crash.

Fixed it by not decrementing vlink_count during unconfig/deletion for virtual-link.

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

18 months agobgpd: Copy the password from the previous peer on peer_xfer_config()
Donatas Abraitis [Mon, 27 Mar 2023 19:03:03 +0000 (22:03 +0300)]
bgpd: Copy the password from the previous peer on peer_xfer_config()

We copy the password only if an existing peer structure didn't have it.

But it might be the case when it exists, and we skip here.

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

18 months agobgpd: Fix debug output for route-map names when using a unsuppress-map
Donald Sharp [Tue, 28 Mar 2023 11:47:22 +0000 (07:47 -0400)]
bgpd: Fix debug output for route-map names when using a unsuppress-map

Log is printing this with this config:

2023-03-28 07:36:47.007 [DEBG] bgpd: [Q9J6Z-09HRR] 192.168.119.120 [Update:SEND] 1.2.3.33/32 is filtered by route-map '(null)'

Here's the config:

 address-family ipv4 unicast
  network 1.2.3.33/32
  network 1.2.3.34/32
  aggregate-address 1.2.3.0/24 summary-only
  redistribute table 33 route-map foo
  neighbor 192.168.119.120 route-map DENY in
  neighbor 192.168.119.120 unsuppress-map UNSUPPRESS

ip prefix-list UNSUPPRESS seq 5 permit 1.2.3.4/32
ip prefix-list UNSUPPRESS seq 10 permit 1.2.3.5/32
ip prefix-list UNSUPPRESS seq 15 permit 1.2.3.6/32

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

18 months agoMerge pull request #13112 from FRRouting/mergify/bp/stable/8.5/pr-13101
Jafar Al-Gharaibeh [Sun, 26 Mar 2023 16:03:37 +0000 (11:03 -0500)]
Merge pull request #13112 from FRRouting/mergify/bp/stable/8.5/pr-13101

tools: Set correct directory of vtysh for frr-reload.py (backport #13101)

18 months agotools: Set correct directory of vtysh for frr-reload.py
Donatas Abraitis [Thu, 23 Mar 2023 18:55:14 +0000 (20:55 +0200)]
tools: Set correct directory of vtysh for frr-reload.py

Before it was setting SDIR, which is /usr/lib/frr, but the vtysh binary is put
under bindir (which is /usr/local by default). And running `/usr/lib/frr/frr reload`
failed.

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

18 months agoMerge pull request #13105 from FRRouting/mergify/bp/stable/8.5/pr-13100
Donald Sharp [Sun, 26 Mar 2023 12:19:20 +0000 (08:19 -0400)]
Merge pull request #13105 from FRRouting/mergify/bp/stable/8.5/pr-13100

bgpd: Check 7 bytes for Long-lived Graceful-Restart capability (backport #13100)

18 months agoMerge pull request #13102 from FRRouting/mergify/bp/stable/8.5/pr-13088
Donald Sharp [Fri, 24 Mar 2023 16:00:06 +0000 (12:00 -0400)]
Merge pull request #13102 from FRRouting/mergify/bp/stable/8.5/pr-13088

pimd: Fix use after free issue for ifp's moving vrfs (backport #13088)

18 months agobgpd: Check 7 bytes for Long-lived Graceful-Restart capability
Donatas Abraitis [Fri, 24 Mar 2023 07:55:23 +0000 (09:55 +0200)]
bgpd: Check 7 bytes for Long-lived Graceful-Restart capability

It's not 4 bytes, it was assuming the same as Graceful-Restart tuples.

LLGR has more 3 bytes (Long-lived Stale Time).

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

18 months agoMerge pull request #13096 from FRRouting/mergify/bp/stable/8.5/pr-13065
Donald Sharp [Fri, 24 Mar 2023 13:16:00 +0000 (09:16 -0400)]
Merge pull request #13096 from FRRouting/mergify/bp/stable/8.5/pr-13065

ospfd: Fixing Summary origination after range configuration (backport #13065)

18 months agopimd: Fix use after free issue for ifp's moving vrfs
Donald Sharp [Wed, 22 Mar 2023 22:24:56 +0000 (18:24 -0400)]
pimd: Fix use after free issue for ifp's moving vrfs

We have this valgrind trace:

==1125== Invalid read of size 4
==1125==    at 0x170A7D: pim_if_delete (pim_iface.c:203)
==1125==    by 0x170C01: pim_if_terminate (pim_iface.c:80)
==1125==    by 0x174F34: pim_instance_terminate (pim_instance.c:68)
==1125==    by 0x17535B: pim_vrf_terminate (pim_instance.c:260)
==1125==    by 0x1941CF: pim_terminate (pimd.c:161)
==1125==    by 0x1B476D: pim_sigint (pim_signals.c:44)
==1125==    by 0x4910C22: frr_sigevent_process (sigevent.c:133)
==1125==    by 0x49220A4: thread_fetch (thread.c:1777)
==1125==    by 0x48DC8E2: frr_run (libfrr.c:1222)
==1125==    by 0x15E12A: main (pim_main.c:176)
==1125==  Address 0x6274d28 is 1,192 bytes inside a block of size 1,752 free'd
==1125==    at 0x48369AB: free (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==1125==    by 0x174FF1: pim_vrf_delete (pim_instance.c:181)
==1125==    by 0x4925480: vrf_delete (vrf.c:264)
==1125==    by 0x4925480: vrf_delete (vrf.c:238)
==1125==    by 0x49332C7: zclient_vrf_delete (zclient.c:2187)
==1125==    by 0x4934319: zclient_read (zclient.c:4003)
==1125==    by 0x492249C: thread_call (thread.c:2008)
==1125==    by 0x48DC8D7: frr_run (libfrr.c:1223)
==1125==    by 0x15E12A: main (pim_main.c:176)
==1125==  Block was alloc'd at
==1125==    at 0x4837B65: calloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==1125==    by 0x48E80AF: qcalloc (memory.c:116)
==1125==    by 0x1750DA: pim_instance_init (pim_instance.c:90)
==1125==    by 0x1750DA: pim_vrf_new (pim_instance.c:161)
==1125==    by 0x4924FDC: vrf_get (vrf.c:183)
==1125==    by 0x493334C: zclient_vrf_add (zclient.c:2157)
==1125==    by 0x4934319: zclient_read (zclient.c:4003)
==1125==    by 0x492249C: thread_call (thread.c:2008)
==1125==    by 0x48DC8D7: frr_run (libfrr.c:1223)
==1125==    by 0x15E12A: main (pim_main.c:176)

and you do this series of events:

a) Create a vrf, put an interface in it
b) Turn on pim on that interface and turn on pim in that vrf
c) Delete the vrf
d) Do anything with the interface, in this case shutdown the system

The move of the interface to a new vrf is leaving the pim_ifp->pim pointer pointing
at the old pim instance, which was just deleted, so the instance pointer was freed.

Let's clean up the pim pointer in the interface pointer as well.

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

18 months agoospfd: Fixing Summary origination after range configuration
rgirada [Mon, 20 Mar 2023 11:22:26 +0000 (11:22 +0000)]
ospfd: Fixing Summary origination after range configuration

Description:
After area range config, summary lsas are aggerated to configured
route but later it was being flushed instead of the actual summary
lsa. This was seen when prefix-id of the aggregated route is same
as one of the actual summary route.
Here, aggregated summary lsa need to be returned to set the flag
SUMMARY_APPROVE after originating aggregated summary lsa but its not.
Which is being cleaned up as part of unapproved summary cleanup.
Corrected this now.

Issue: #13028

Signed-off-by: Rajesh Girada <rgirada@vmware.com>
(cherry picked from commit c8c1a240ab9653d74b3af009f850e150909f784e)

18 months agoMerge pull request #13077 from FRRouting/mergify/bp/stable/8.5/pr-13073
Jafar Al-Gharaibeh [Wed, 22 Mar 2023 01:36:05 +0000 (20:36 -0500)]
Merge pull request #13077 from FRRouting/mergify/bp/stable/8.5/pr-13073

staticd: Tell bfd that we are shutting down (backport #13073)

18 months agostaticd: Tell bfd that we are shutting down
Donald Sharp [Tue, 21 Mar 2023 12:55:35 +0000 (08:55 -0400)]
staticd: Tell bfd that we are shutting down

Prevent a use after free and tell the bfd subsystem
we are shutting down in staticd.

./bfd_topo3.test_bfd_topo3/r4.staticd.asan.2264460:==2264460==ERROR: AddressSanitizer: heap-use-after-free on address 0x61f000004698 at pc 0x7f65d1eb11b2 bp 0x7ffdbface490 sp 0x7ffdbface488
./bfd_topo3.test_bfd_topo3/r4.staticd.asan.2264460-READ of size 4 at 0x61f000004698 thread T0
./bfd_topo3.test_bfd_topo3/r4.staticd.asan.2264460-    #0 0x7f65d1eb11b1 in zclient_bfd_command lib/bfd.c:307
./bfd_topo3.test_bfd_topo3/r4.staticd.asan.2264460-    #1 0x7f65d1eb20f5 in _bfd_sess_send lib/bfd.c:507
./bfd_topo3.test_bfd_topo3/r4.staticd.asan.2264460-    #2 0x7f65d20510aa in thread_call lib/thread.c:1989
./bfd_topo3.test_bfd_topo3/r4.staticd.asan.2264460-    #3 0x7f65d2051f0a in _thread_execute lib/thread.c:2081
./bfd_topo3.test_bfd_topo3/r4.staticd.asan.2264460-    #4 0x7f65d1eb271b in _bfd_sess_remove lib/bfd.c:544
./bfd_topo3.test_bfd_topo3/r4.staticd.asan.2264460-    #5 0x7f65d1eb278d in bfd_sess_free lib/bfd.c:553
./bfd_topo3.test_bfd_topo3/r4.staticd.asan.2264460-    #6 0x7f65d1eb5400 in bfd_protocol_integration_finish lib/bfd.c:1029
./bfd_topo3.test_bfd_topo3/r4.staticd.asan.2264460-    #7 0x7f65d1f42f77 in hook_call_frr_fini lib/libfrr.c:41
./bfd_topo3.test_bfd_topo3/r4.staticd.asan.2264460-    #8 0x7f65d1f494a1 in frr_fini lib/libfrr.c:1199
./bfd_topo3.test_bfd_topo3/r4.staticd.asan.2264460-    #9 0x563b7abefd76 in sigint staticd/static_main.c:70
./bfd_topo3.test_bfd_topo3/r4.staticd.asan.2264460-    #10 0x7f65d200ef91 in frr_sigevent_process lib/sigevent.c:115
./bfd_topo3.test_bfd_topo3/r4.staticd.asan.2264460-    #11 0x7f65d204fac6 in thread_fetch lib/thread.c:1758
./bfd_topo3.test_bfd_topo3/r4.staticd.asan.2264460-    #12 0x7f65d1f49377 in frr_run lib/libfrr.c:1184
./bfd_topo3.test_bfd_topo3/r4.staticd.asan.2264460-    #13 0x563b7abefed1 in main staticd/static_main.c:160
./bfd_topo3.test_bfd_topo3/r4.staticd.asan.2264460-    #14 0x7f65d1b92d09 in __libc_start_main ../csu/libc-start.c:308
./bfd_topo3.test_bfd_topo3/r4.staticd.asan.2264460-    #15 0x563b7abefa99 in _start (/usr/lib/frr/staticd+0x15a99)
./bfd_topo3.test_bfd_topo3/r4.staticd.asan.2264460-

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

18 months agoMerge pull request #13072 from FRRouting/mergify/bp/stable/8.5/pr-13062
Donatas Abraitis [Tue, 21 Mar 2023 13:31:18 +0000 (15:31 +0200)]
Merge pull request #13072 from FRRouting/mergify/bp/stable/8.5/pr-13062

zebra: Fix for heap-use-after-free in EVPN (backport #13062)

18 months agozebra: Fix for heap-use-after-free in EVPN
Pooja Jagadeesh Doijode [Mon, 20 Mar 2023 19:54:31 +0000 (12:54 -0700)]
zebra: Fix for heap-use-after-free in EVPN

Issue:
When a netns is deleted, since zebra doesn’t receive interface down/delete
notifications from kernel, it manually deletes the interface without removing
the association between zebra_l3vni and the interface that is being deleted
(i.e it deletes the interface without setting “zl3vni->vxlan_if” to NULL).

Later, during the deletion of netns, when zl3vni_rmac_uninstall() is called to
uninstall the remote RMAC from the kernel, zebra ends up accessing stale
“zl3vni->vxlan_if” pointer, which now points to freed memory.
This was causing heap use-after-free.

Fix:
Before zebra starts deleting the interfaces when it receives netns delete notification,
appropriate functions() are being called to remove the association between evpn structs
and interface and set “zl3vni->vxlan_if” to NULL. This ensures that when
zl3vni_rmac_uninstall() is called during netns deletion, it will bail because
“zl3vni->vxlan_if” is NULL.

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

18 months agoMerge pull request #13067 from FRRouting/mergify/bp/stable/8.5/pr-13064
Donald Sharp [Tue, 21 Mar 2023 10:59:44 +0000 (06:59 -0400)]
Merge pull request #13067 from FRRouting/mergify/bp/stable/8.5/pr-13064

lib: fix clear route-map command (backport #13064)

18 months agoMerge pull request #13069 from FRRouting/mergify/bp/stable/8.5/pr-13061
Donald Sharp [Tue, 21 Mar 2023 10:58:42 +0000 (06:58 -0400)]
Merge pull request #13069 from FRRouting/mergify/bp/stable/8.5/pr-13061

lib: on bfd peer shutdown actually stop event (backport #13061)

18 months agolib: Include clippy generated commands for routemap.c
Donatas Abraitis [Tue, 21 Mar 2023 08:34:38 +0000 (10:34 +0200)]
lib: Include clippy generated commands for routemap.c

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
18 months agolib: on bfd peer shutdown actually stop event
Donald Sharp [Mon, 20 Mar 2023 20:07:20 +0000 (16:07 -0400)]
lib: on bfd peer shutdown actually stop event

When deleting a bfd peer during shutdown, let's ensure
that any scheduled events are actually stopped.

==7759== Invalid read of size 4
==7759==    at 0x48BF700: _bfd_sess_valid (bfd.c:419)
==7759==    by 0x48BF700: _bfd_sess_send (bfd.c:470)
==7759==    by 0x492F79C: thread_call (thread.c:2008)
==7759==    by 0x48E9BD7: frr_run (libfrr.c:1223)
==7759==    by 0x1C739B: main (bgp_main.c:550)
==7759==  Address 0xfb687a4 is 4 bytes inside a block of size 272 free'd
==7759==    at 0x48369AB: free (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==7759==    by 0x48BFA5A: bfd_sess_free (bfd.c:535)
==7759==    by 0x2B7034: bgp_peer_remove_bfd (bgp_bfd.c:339)
==7759==    by 0x29FF8A: peer_free (bgpd.c:1160)
==7759==    by 0x29FF8A: peer_unlock_with_caller (bgpd.c:1192)
==7759==    by 0x2A0506: peer_delete (bgpd.c:2633)
==7759==    by 0x208190: bgp_stop (bgp_fsm.c:1639)
==7759==    by 0x20C082: bgp_event_update (bgp_fsm.c:2751)
==7759==    by 0x492F79C: thread_call (thread.c:2008)
==7759==    by 0x48E9BD7: frr_run (libfrr.c:1223)
==7759==    by 0x1C739B: main (bgp_main.c:550)
==7759==  Block was alloc'd at
==7759==    at 0x4837B65: calloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==7759==    by 0x48F53AF: qcalloc (memory.c:116)
==7759==    by 0x48BF98D: bfd_sess_new (bfd.c:397)
==7759==    by 0x2B76DC: bgp_peer_configure_bfd (bgp_bfd.c:298)
==7759==    by 0x2B76DC: bgp_peer_configure_bfd (bgp_bfd.c:279)
==7759==    by 0x29BA06: peer_group2peer_config_copy (bgpd.c:2803)
==7759==    by 0x2A3D96: peer_create_bind_dynamic_neighbor (bgpd.c:4107)
==7759==    by 0x2A4195: peer_lookup_dynamic_neighbor (bgpd.c:4239)
==7759==    by 0x21AB72: bgp_accept (bgp_network.c:422)
==7759==    by 0x492F79C: thread_call (thread.c:2008)
==7759==    by 0x48E9BD7: frr_run (libfrr.c:1223)
==7759==    by 0x1C739B: main (bgp_main.c:550)

tl;dr -> Effectively, in this test setup we have 300 dynamic bgp
sessions all of which are using bfd.  When a peer collision is detected
or we remove the peers, if an event has been scheduled but not actually
executed yet the event event was not actually being stopped, leaving
the bsp pointer on the thread->arg and causing a crash when it is
executed.

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

18 months agolib:fix clear route-map cmd using DEFPY
Sindhu Parvathi Gopinathan [Mon, 20 Mar 2023 12:15:03 +0000 (05:15 -0700)]
lib:fix clear route-map cmd using DEFPY

Due to the wrong input argv id, "argv[idx_word]->arg"
fetched in-correctly and it clears all the route-maps instead of
specific one.

Now correct argv id is passed to clear the given route-map counters.

Also, use RMAP_NAME which allows to show list of configured
route-maps in the system.

After Fix:-

Ticket:#3407773
Issue:3407773

Testing: UT done

Before:
TORC11# clear route-map counters
  <cr>
  WORD  route-map name

After:

TORC11# clear route-map counters
  <cr>
  RMAP_NAME  route-map name
     my-as

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

18 months agoMerge pull request #13058 from opensourcerouting/fix/bgp_null_deref_8.5
Donald Sharp [Mon, 20 Mar 2023 23:51:15 +0000 (19:51 -0400)]
Merge pull request #13058 from opensourcerouting/fix/bgp_null_deref_8.5

bgpd: Prevent Null pointer deref when outputting data

18 months agobgpd: Prevent Null pointer deref when outputting data
Donald Sharp [Fri, 17 Mar 2023 19:40:33 +0000 (15:40 -0400)]
bgpd: Prevent Null pointer deref when outputting data

Crash:

(gdb) bt
0  0x00007fee27de15cb in raise () from /lib/x86_64-linux-gnu/libpthread.so.0
1  0x00007fee280ecd9c in core_handler (signo=11, siginfo=0x7ffe56001bb0, context=<optimized out>) at lib/sigevent.c:264
2  <signal handler called>
3  0x0000555e321c41b2 in prefix_rd2str (prd=0x10, buf=buf@entry=0x7ffe56002080 "27.0.0.R\340\373\062\062^U", size=size@entry=28) at bgpd/bgp_rd.c:168
4  0x0000555e321c431a in printfrr_prd (buf=0x7ffe560021a0, ea=<optimized out>, ptr=<optimized out>) at bgpd/bgp_rd.c:224
5  0x00007fee2812069b in vbprintfrr (cb_in=cb_in@entry=0x7ffe56002330, fmt0=fmt0@entry=0x555e3229a3ad " RD: %pRD\n", ap=ap@entry=0x7ffe560023d8) at lib/printf/vfprintf.c:564
6  0x00007fee28122ef7 in vasnprintfrr (mt=mt@entry=0x7fee281cb5e0 <MTYPE_VTY_OUT_BUF>, out=out@entry=0x7ffe560023f0 " RD: : R\n", outsz=outsz@entry=1024, fmt=fmt@entry=0x555e3229a3ad " RD: %pRD\n", ap=ap@entry=0x7ffe560023d8) at lib/printf/glue.c:103
7  0x00007fee28103504 in vty_out (vty=vty@entry=0x555e33f82d10, format=format@entry=0x555e3229a3ad " RD: %pRD\n") at lib/vty.c:190
8  0x0000555e32185156 in bgp_evpn_es_show_entry_detail (vty=0x555e33f82d10, es=0x555e33c38420, json=<optimized out>) at bgpd/bgp_evpn_mh.c:2655
9  0x0000555e32188fe5 in bgp_evpn_es_show (vty=vty@entry=0x555e33f82d10, uj=false, detail=true) at bgpd/bgp_evpn_mh.c:2721
notice prd=0x10 in #3.  This is because in bgp_evpn_mh.c we are sending &es->es_base_frag->prd.

There is one spot in the code where during output the es->es_base_frag is checked for non nullness
Let's just make sure it's right in all the places.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
18 months agoMerge pull request #13052 from FRRouting/mergify/bp/stable/8.5/pr-13049
Donatas Abraitis [Mon, 20 Mar 2023 05:58:43 +0000 (07:58 +0200)]
Merge pull request #13052 from FRRouting/mergify/bp/stable/8.5/pr-13049

lib: IPv6 prefix-list entry handling with `any` (backport #13049)

18 months agolib: Destroy `any` flag when creating a prefix-list entry with prefix
Donatas Abraitis [Sun, 19 Mar 2023 20:46:56 +0000 (22:46 +0200)]
lib: Destroy `any` flag when creating a prefix-list entry with prefix

The same as 61c07b9d43529f69f48ca54f4f0213cff52b5d0a, but forgot to put IPv6
in place.

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

18 months agotests: Check if prefix-lists with IPv6 any works fine
Donatas Abraitis [Sun, 19 Mar 2023 20:46:35 +0000 (22:46 +0200)]
tests: Check if prefix-lists with IPv6 any works fine

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

18 months agoMerge pull request #13041 from FRRouting/mergify/bp/stable/8.5/pr-13038
Donald Sharp [Sun, 19 Mar 2023 22:39:02 +0000 (18:39 -0400)]
Merge pull request #13041 from FRRouting/mergify/bp/stable/8.5/pr-13038

18 months agoMerge pull request #13043 from FRRouting/mergify/bp/stable/8.5/pr-13026
Donatas Abraitis [Sun, 19 Mar 2023 20:58:04 +0000 (22:58 +0200)]
Merge pull request #13043 from FRRouting/mergify/bp/stable/8.5/pr-13026

pbrd:fix mismatching in match src-dst (backport #13026)

18 months agoMerge pull request #13045 from FRRouting/mergify/bp/stable/8.5/pr-13025
Donatas Abraitis [Sun, 19 Mar 2023 20:57:53 +0000 (22:57 +0200)]
Merge pull request #13045 from FRRouting/mergify/bp/stable/8.5/pr-13025

Ospf ti lfa leaks (backport #13025)