]> git.puffer.fish Git - mirror/frr.git/log
mirror/frr.git
19 months agoFRR Release 9.0.1 docker/9.0.1 frr-9.0.1
Jafar Al-Gharaibeh [Sat, 2 Sep 2023 04:17:37 +0000 (23:17 -0500)]
FRR Release 9.0.1

Bug Fixes:

bgpd
    Add peers back to peer hash when peer_xfer_conn fails
    Check the length of the rcv software version
    Do not explicitly print maxttl value for ebgp-multihop vty output
    Do not process nlris if the attribute length is zero
    Don't read the first byte of orf header if we are ahead of stream
    Evpn code was not properly unlocking rd_dest
    Fix `show bgp all rpki notfound`
    Make sure we have enough data to read two bytes when validating aigp
    Use treat-as-withdraw for tunnel encapsulation attribute

zebra
    Fix evpn nexthop config order

lib
    Allow unsetting walltime-warning and cpu-warning

ospfd
    Prevent use after free( and crash of ospf ) when no router ospf

pimd
    Prevent crash when receiving register message when the rp() is unknown
    When receiving a packet be more careful with length in pim_pim_packet

vtysh
    Print uniq lines when parsing `no service ...`

Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
19 months agoMerge pull request #14336 from FRRouting/mergify/bp/stable/9.0/pr-14294
Jafar Al-Gharaibeh [Sat, 2 Sep 2023 03:18:55 +0000 (22:18 -0500)]
Merge pull request #14336 from FRRouting/mergify/bp/stable/9.0/pr-14294

pimd: Prevent crash when receiving register message when the RP() is … (backport #14294)

19 months agoMerge pull request #14334 from FRRouting/mergify/bp/stable/9.0/pr-14327
Jafar Al-Gharaibeh [Fri, 1 Sep 2023 21:12:09 +0000 (16:12 -0500)]
Merge pull request #14334 from FRRouting/mergify/bp/stable/9.0/pr-14327

bgpd: Fix `show bgp all rpki notfound` (backport #14327)

19 months agoMerge pull request #14339 from opensourcerouting/fix/backport_ce1f5d3774935e1694fd140...
Jafar Al-Gharaibeh [Fri, 1 Sep 2023 21:10:13 +0000 (16:10 -0500)]
Merge pull request #14339 from opensourcerouting/fix/backport_ce1f5d3774935e1694fd140858f3c3cdecf64ba4_9.0

bgpd: Add peers back to peer hash when peer_xfer_conn fails

19 months agobgpd: Add peers back to peer hash when peer_xfer_conn fails 14339/head
Donald Sharp [Wed, 30 Aug 2023 11:25:06 +0000 (07:25 -0400)]
bgpd: Add peers back to peer hash when peer_xfer_conn fails

It was noticed that occassionally peering failed in a testbed
upon investigation it was found that the peer was not in the
peer hash and we saw these failure messages:

Aug 25 21:31:15 doca-hbn-service-bf3-s06-1-ipmi bgpd[3048]: %NOTIFICATION: sent to neighbor 2001:cafe:1ead:4::4 4/0 (Hold Timer Expired) 0 bytes
Aug 25 21:31:22 doca-hbn-service-bf3-s06-1-ipmi bgpd[3048]: [EC 100663299] Can't get remote address and port: Transport endpoint is not connected
Aug 25 21:31:22 doca-hbn-service-bf3-s06-1-ipmi bgpd[3048]: [EC 100663299] %bgp_getsockname() failed for  peer 2001:cafe:1ead:4::4 fd 27 (from_peer fd -1)
Aug 25 21:31:22 doca-hbn-service-bf3-s06-1-ipmi bgpd[3048]: [EC 33554464] %Neighbor failed in xfer_conn

root@doca-hbn-service-bf3-s06-1-ipmi:/var/log/hbn/frr# vtysh -c 'show bgp peerhash' | grep 2001:cafe:1ead:4::4
root@doca-hbn-service-bf3-s06-1-ipmi:/var/log/hbn/frr#

Upon looking at the code the peer_xfer_conn function can fail
and the bgp_establish code will then return before adding the
peer back to the peerhash.

This is only part of the failure.  The peer also appears to
be in a state where it is no longer initiating connection attempts
but that will be another commited fix when we figure that one out.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
19 months agopimd: Prevent crash when receiving register message when the RP() is unknown 14336/head
Donald Sharp [Tue, 29 Aug 2023 18:59:34 +0000 (14:59 -0400)]
pimd: Prevent crash when receiving register message when the RP() is unknown

When receiving a register message for a Group, that the group has no
associated RP specified.  Prevent a crash from happening.

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

19 months agobgpd: Fix `show bgp all rpki notfound` 14334/head
Ryo Nakano [Fri, 1 Sep 2023 02:44:03 +0000 (11:44 +0900)]
bgpd: Fix `show bgp all rpki notfound`

The command "show bgp all rpki notfound" includes not only RPKI
notfound routes but also RPKI valid and invalid routes in its results.

Fix the code to display only RPKI notfound routes.

Old output:
```
frr# show bgp all rpki notfound

For address family: IPv4 Unicast
BGP table version is 0, local router ID is 10.0.0.1, vrf id 0
Default local pref 100, local AS 64512
Status codes:  s suppressed, d damped, h history, * valid, > best, = multipath,
               i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes:  i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

    Network          Next Hop            Metric LocPrf Weight Path
N   x.x.x.0/18       a.a.a.a                       100      0 64513 i
V   y.y.y.0/19       a.a.a.a                       200      0 64513 i
I   z.z.z.0/16       a.a.a.a                        10      0 64513 i

Displayed  3 routes and 3 total paths
```

New output:
```
frr# show bgp all rpki notfound

For address family: IPv4 Unicast
BGP table version is 0, local router ID is 10.0.0.1, vrf id 0
Default local pref 100, local AS 64512
Status codes:  s suppressed, d damped, h history, * valid, > best, = multipath,
               i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop's vrf id, < announce-nh-self
Origin codes:  i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

    Network          Next Hop            Metric LocPrf Weight Path
N   x.x.x.0/18       a.a.a.a                       100      0 64513 i

Displayed  1 routes and 3 total paths
```

Signed-off-by: Ryo Nakano <ryo.z.nakano@gmail.com>
(cherry picked from commit 65d6b56a063006c38ee695e711be3b3e78fb1745)

19 months agoMerge pull request #14321 from opensourcerouting/fix/backport_530be6a4d089600f1028439...
Jafar Al-Gharaibeh [Thu, 31 Aug 2023 17:01:15 +0000 (12:01 -0500)]
Merge pull request #14321 from opensourcerouting/fix/backport_530be6a4d089600f1028439ddec420ef651b983b_9.0

ospfd: Prevent use after free( and crash of ospf ) when no router ospf [backport]

19 months agoMerge pull request #14324 from FRRouting/mergify/bp/stable/9.0/pr-14322
Donald Sharp [Thu, 31 Aug 2023 15:05:30 +0000 (11:05 -0400)]
Merge pull request #14324 from FRRouting/mergify/bp/stable/9.0/pr-14322

Revert "bgpd: Add peers back to peer hash when peer_xfer_conn fails" (backport #14322)

19 months agoRevert "bgpd: Add peers back to peer hash when peer_xfer_conn fails" 14324/head
Donatas Abraitis [Thu, 31 Aug 2023 14:33:57 +0000 (17:33 +0300)]
Revert "bgpd: Add peers back to peer hash when peer_xfer_conn fails"

peer is NULL, but we pass it to hash_get().

This reverts commit 6f8c927b03c454aa309b84cefccc4faa31e0c03f.

(cherry picked from commit bc81691247228ad14501b86afe63dff0daf96ab6)

19 months agoospfd: Prevent use after free( and crash of ospf ) when no router ospf 14321/head
Donald Sharp [Wed, 30 Aug 2023 14:33:29 +0000 (10:33 -0400)]
ospfd: Prevent use after free( and crash of ospf ) when no router ospf

Consider this config:

router ospf
  redistribute kernel

Then you issue:

no router ospf

ospf will crash with a use after free.

The problem is that the event's associated with the
ospf pointer were shut off then the ospf_external_delete
was called which rescheduled the event.  Let's just move
event deletion to the end of the no router ospf.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
19 months agoMerge pull request #14311 from FRRouting/mergify/bp/stable/9.0/pr-14302
Jafar Al-Gharaibeh [Thu, 31 Aug 2023 05:22:41 +0000 (00:22 -0500)]
Merge pull request #14311 from FRRouting/mergify/bp/stable/9.0/pr-14302

pimd: When receiving a packet be more careful with length in pim_pim_… (backport #14302)

19 months agoMerge pull request #14309 from FRRouting/mergify/bp/stable/9.0/pr-14301
Jafar Al-Gharaibeh [Thu, 31 Aug 2023 05:22:24 +0000 (00:22 -0500)]
Merge pull request #14309 from FRRouting/mergify/bp/stable/9.0/pr-14301

bgpd: Add peers back to peer hash when peer_xfer_conn fails (backport #14301)

19 months agopimd: When receiving a packet be more careful with length in pim_pim_packet 14311/head
Donald Sharp [Wed, 30 Aug 2023 12:54:33 +0000 (08:54 -0400)]
pimd: When receiving a packet be more careful with length in pim_pim_packet

a) If the length passed is the header length then it is possible that
assignment of data will happen without data actually existing.

b) Just move the assignment to after we ensure that the pim packet
received is the minimum possible length that can be received.

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

19 months agobgpd: Add peers back to peer hash when peer_xfer_conn fails 14309/head
Donald Sharp [Wed, 30 Aug 2023 11:25:06 +0000 (07:25 -0400)]
bgpd: Add peers back to peer hash when peer_xfer_conn fails

It was noticed that occassionally peering failed in a testbed
upon investigation it was found that the peer was not in the
peer hash and we saw these failure messages:

Aug 25 21:31:15 doca-hbn-service-bf3-s06-1-ipmi bgpd[3048]: %NOTIFICATION: sent to neighbor 2001:cafe:1ead:4::4 4/0 (Hold Timer Expired) 0 bytes
Aug 25 21:31:22 doca-hbn-service-bf3-s06-1-ipmi bgpd[3048]: [EC 100663299] Can't get remote address and port: Transport endpoint is not connected
Aug 25 21:31:22 doca-hbn-service-bf3-s06-1-ipmi bgpd[3048]: [EC 100663299] %bgp_getsockname() failed for  peer 2001:cafe:1ead:4::4 fd 27 (from_peer fd -1)
Aug 25 21:31:22 doca-hbn-service-bf3-s06-1-ipmi bgpd[3048]: [EC 33554464] %Neighbor failed in xfer_conn

root@doca-hbn-service-bf3-s06-1-ipmi:/var/log/hbn/frr# vtysh -c 'show bgp peerhash' | grep 2001:cafe:1ead:4::4
root@doca-hbn-service-bf3-s06-1-ipmi:/var/log/hbn/frr#

Upon looking at the code the peer_xfer_conn function can fail
and the bgp_establish code will then return before adding the
peer back to the peerhash.

This is only part of the failure.  The peer also appears to
be in a state where it is no longer initiating connection attempts
but that will be another commited fix when we figure that one out.

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

20 months agoMerge pull request #14297 from FRRouting/mergify/bp/stable/9.0/pr-14290
Donatas Abraitis [Wed, 30 Aug 2023 07:02:55 +0000 (10:02 +0300)]
Merge pull request #14297 from FRRouting/mergify/bp/stable/9.0/pr-14290

bgpd: Use treat-as-withdraw for tunnel encapsulation attribute (backport #14290)

20 months agoMerge pull request #14291 from FRRouting/mergify/bp/stable/9.0/pr-14243
Jafar Al-Gharaibeh [Wed, 30 Aug 2023 03:25:31 +0000 (22:25 -0500)]
Merge pull request #14291 from FRRouting/mergify/bp/stable/9.0/pr-14243

bgpd: Do not explicitly print MAXTTL value for ebgp-multihop vty output (backport #14243)

20 months agobgpd: Use treat-as-withdraw for tunnel encapsulation attribute 14297/head
Donatas Abraitis [Thu, 13 Jul 2023 19:32:03 +0000 (22:32 +0300)]
bgpd: Use treat-as-withdraw for tunnel encapsulation attribute

Before this path we used session reset method, which is discouraged by rfc7606.

Handle this as rfc requires.

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

20 months agobgpd: Do not explicitly print MAXTTL value for ebgp-multihop vty output 14291/head
Donatas Abraitis [Sun, 20 Aug 2023 21:01:42 +0000 (00:01 +0300)]
bgpd: Do not explicitly print MAXTTL value for ebgp-multihop vty output

1. Create /etc/frr/frr.conf
```
frr version 7.5
frr defaults traditional
hostname centos8.localdomain
no ip forwarding
no ipv6 forwarding
service integrated-vtysh-config
line vty
router bgp 4250001000
  neighbor 192.168.122.207 remote-as 65512
  neighbor 192.168.122.207 ebgp-multihop
```

2. Start FRR
`# systemctl start frr
`
3. Show running configuration. Note that FRR explicitly set and shows the default TTL (225)

```
Building configuration...

Current configuration:
!
frr version 7.5
frr defaults traditional
hostname centos8.localdomain
no ip forwarding
no ipv6 forwarding
service integrated-vtysh-config
!
router bgp 4250001000
 neighbor 192.168.122.207 remote-as 65512
 neighbor 192.168.122.207 ebgp-multihop 255
!
line vty
!
end
```
4. Copy initial frr.conf to frr.conf.new (no changes)
`# cp /etc/frr/frr.conf /root/frr.conf.new
`
5. Run frr-reload.sh:

```
$ /usr/lib/frr/frr-reload.py --test  /root/frr.conf.new
2023-08-20 20:15:48,050  INFO: Called via "Namespace(bindir='/usr/bin', confdir='/etc/frr', daemon='', debug=False, filename='/root/frr.conf.new', input=None, log_level='info', overwrite=False, pathspace=None, reload=False, rundir='/var/run/frr', stdout=False, test=True, vty_socket=None)"
2023-08-20 20:15:48,050  INFO: Loading Config object from file /root/frr.conf.new
2023-08-20 20:15:48,124  INFO: Loading Config object from vtysh show running

Lines To Delete
===============
router bgp 4250001000
 no neighbor 192.168.122.207 ebgp-multihop 255

Lines To Add
============
router bgp 4250001000
 neighbor 192.168.122.207 ebgp-multihop
```

Closes https://github.com/FRRouting/frr/issues/14242

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

20 months agoMerge pull request #14269 from FRRouting/mergify/bp/stable/9.0/pr-14260
Donald Sharp [Thu, 24 Aug 2023 18:54:03 +0000 (14:54 -0400)]
Merge pull request #14269 from FRRouting/mergify/bp/stable/9.0/pr-14260

bgpd: Do not process NLRIs if the attribute length is zero (backport #14260)

20 months agobgpd: Do not process NLRIs if the attribute length is zero 14269/head
Donatas Abraitis [Tue, 22 Aug 2023 19:52:04 +0000 (22:52 +0300)]
bgpd: Do not process NLRIs if the attribute length is zero

```
3  0x00007f423aa42476 in __GI_raise (sig=sig@entry=11) at ../sysdeps/posix/raise.c:26
4  0x00007f423aef9740 in core_handler (signo=11, siginfo=0x7fffc414deb0, context=<optimized out>) at lib/sigevent.c:246
5  <signal handler called>
6  0x0000564dea2fc71e in route_set_aspath_prepend (rule=0x564debd66d50, prefix=0x7fffc414ea30, object=0x7fffc414e400)
    at bgpd/bgp_routemap.c:2258
7  0x00007f423aeec7e0 in route_map_apply_ext (map=<optimized out>, prefix=prefix@entry=0x7fffc414ea30,
    match_object=match_object@entry=0x7fffc414e400, set_object=set_object@entry=0x7fffc414e400, pref=pref@entry=0x0) at lib/routemap.c:2690
8  0x0000564dea2d277e in bgp_input_modifier (peer=peer@entry=0x7f4238f59010, p=p@entry=0x7fffc414ea30, attr=attr@entry=0x7fffc414e770,
    afi=afi@entry=AFI_IP, safi=safi@entry=SAFI_UNICAST, rmap_name=rmap_name@entry=0x0, label=0x0, num_labels=0, dest=0x564debdd5130)
    at bgpd/bgp_route.c:1772
9  0x0000564dea2df762 in bgp_update (peer=peer@entry=0x7f4238f59010, p=p@entry=0x7fffc414ea30, addpath_id=addpath_id@entry=0,
    attr=0x7fffc414eb50, afi=afi@entry=AFI_IP, safi=<optimized out>, safi@entry=SAFI_UNICAST, type=9, sub_type=0, prd=0x0, label=0x0,
    num_labels=0, soft_reconfig=0, evpn=0x0) at bgpd/bgp_route.c:4374
10 0x0000564dea2e2047 in bgp_nlri_parse_ip (peer=0x7f4238f59010, attr=attr@entry=0x7fffc414eb50, packet=0x7fffc414eaf0)
    at bgpd/bgp_route.c:6249
11 0x0000564dea2c5a58 in bgp_nlri_parse (peer=peer@entry=0x7f4238f59010, attr=attr@entry=0x7fffc414eb50,
    packet=packet@entry=0x7fffc414eaf0, mp_withdraw=mp_withdraw@entry=false) at bgpd/bgp_packet.c:339
12 0x0000564dea2c5d66 in bgp_update_receive (peer=peer@entry=0x7f4238f59010, size=size@entry=109) at bgpd/bgp_packet.c:2024
13 0x0000564dea2c901d in bgp_process_packet (thread=<optimized out>) at bgpd/bgp_packet.c:2933
14 0x00007f423af0bf71 in event_call (thread=thread@entry=0x7fffc414ee40) at lib/event.c:1995
15 0x00007f423aebb198 in frr_run (master=0x564deb73c670) at lib/libfrr.c:1213
16 0x0000564dea261b83 in main (argc=<optimized out>, argv=<optimized out>) at bgpd/bgp_main.c:505
```

With the configuration:

```
frr version 9.1-dev-MyOwnFRRVersion
frr defaults traditional
hostname ip-172-31-13-140
log file /tmp/debug.log
log syslog
service integrated-vtysh-config
!
debug bgp keepalives
debug bgp neighbor-events
debug bgp updates in
debug bgp updates out
!
router bgp 100
 bgp router-id 9.9.9.9
 no bgp ebgp-requires-policy
 bgp bestpath aigp
 neighbor 172.31.2.47 remote-as 200
 !
 address-family ipv4 unicast
  neighbor 172.31.2.47 default-originate
  neighbor 172.31.2.47 route-map RM_IN in
 exit-address-family
exit
!
route-map RM_IN permit 10
 set as-path prepend 200
exit
!
```

The issue is that we try to process NLRIs even if the attribute length is 0.

Later bgp_update() will handle route-maps and a crash occurs because all the
attributes are NULL, including aspath, where we dereference.

According to the RFC 4271:

A value of 0 indicates that neither the Network Layer
         Reachability Information field nor the Path Attribute field is
         present in this UPDATE message.

But with a fuzzed UPDATE message this can be faked. I think it's reasonable
to skip processing NLRIs if both update_len and attribute_len are 0.

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

20 months agoMerge pull request #14267 from FRRouting/mergify/bp/stable/9.0/pr-14232
Donald Sharp [Thu, 24 Aug 2023 14:52:56 +0000 (10:52 -0400)]
Merge pull request #14267 from FRRouting/mergify/bp/stable/9.0/pr-14232

bgpd: Make sure we have enough data to read two bytes when validating AIGP (backport #14232)

20 months agobgpd: Make sure we have enough data to read two bytes when validating AIGP 14267/head
Donatas Abraitis [Fri, 18 Aug 2023 08:28:03 +0000 (11:28 +0300)]
bgpd: Make sure we have enough data to read two bytes when validating AIGP

Found when fuzzing:

```
==3470861==ERROR: AddressSanitizer: heap-buffer-overflow on address 0xffff77801ef7 at pc 0xaaaaba7b3dbc bp 0xffffcff0e760 sp 0xffffcff0df50
READ of size 2 at 0xffff77801ef7 thread T0
    0 0xaaaaba7b3db8 in __asan_memcpy (/home/ubuntu/frr_8_5_2/frr_8_5_2_fuzz_clang/bgpd/bgpd+0x363db8) (BuildId: cc710a2356e31c7f4e4a17595b54de82145a6e21)
    1 0xaaaaba81a8ac in ptr_get_be16 /home/ubuntu/frr_8_5_2/frr_8_5_2_fuzz_clang/./lib/stream.h:399:2
    2 0xaaaaba819f2c in bgp_attr_aigp_valid /home/ubuntu/frr_8_5_2/frr_8_5_2_fuzz_clang/bgpd/bgp_attr.c:504:3
    3 0xaaaaba808c20 in bgp_attr_aigp /home/ubuntu/frr_8_5_2/frr_8_5_2_fuzz_clang/bgpd/bgp_attr.c:3275:7
    4 0xaaaaba7ff4e0 in bgp_attr_parse /home/ubuntu/frr_8_5_2/frr_8_5_2_fuzz_clang/bgpd/bgp_attr.c:3678:10
```

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

20 months agoMerge pull request #14248 from FRRouting/mergify/bp/stable/9.0/pr-14245
Donald Sharp [Mon, 21 Aug 2023 17:19:22 +0000 (13:19 -0400)]
Merge pull request #14248 from FRRouting/mergify/bp/stable/9.0/pr-14245

bgpd: Don't read the first byte of ORF header if we are ahead of stream (backport #14245)

20 months agoMerge pull request #14250 from FRRouting/mergify/bp/stable/9.0/pr-14241
Donald Sharp [Mon, 21 Aug 2023 17:18:58 +0000 (13:18 -0400)]
Merge pull request #14250 from FRRouting/mergify/bp/stable/9.0/pr-14241

bgpd: Check the length of the rcv software version (backport #14241)

20 months agobgpd: Check the length of the rcv software version 14250/head
Donatas Abraitis [Sun, 20 Aug 2023 18:37:25 +0000 (21:37 +0300)]
bgpd: Check the length of the rcv software version

Make sure we don't exceed the maximum of BGP_MAX_SOFT_VERSION.

The Capability Length SHOULD be no greater than 64.

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

20 months agobgpd: Don't read the first byte of ORF header if we are ahead of stream 14248/head
Donatas Abraitis [Sun, 20 Aug 2023 19:15:27 +0000 (22:15 +0300)]
bgpd: Don't read the first byte of ORF header if we are ahead of stream

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

20 months agoMerge pull request #14210 from FRRouting/mergify/bp/stable/9.0/pr-14184
Donatas Abraitis [Wed, 16 Aug 2023 07:27:35 +0000 (10:27 +0300)]
Merge pull request #14210 from FRRouting/mergify/bp/stable/9.0/pr-14184

lib: Allow unsetting walltime-warning and cpu-warning (backport #14184)

20 months agovtysh: Print uniq lines when parsing `no service ...` 14210/head
Donatas Abraitis [Fri, 11 Aug 2023 15:21:12 +0000 (18:21 +0300)]
vtysh: Print uniq lines when parsing `no service ...`

Before this patch:

```
no service cputime-warning
no service cputime-warning
no ipv6 forwarding
no service cputime-warning
no service cputime-warning
no service cputime-warning
```

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

20 months agolib: Allow unsetting walltime-warning and cpu-warning
Donatas Abraitis [Fri, 11 Aug 2023 15:11:03 +0000 (18:11 +0300)]
lib: Allow unsetting walltime-warning and cpu-warning

With a negative form we get:

```
Internal CLI error [walltime_warning_str]
Internal CLI error [cputime_warning_str]
```

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

20 months agoMerge pull request #14192 from FRRouting/mergify/bp/stable/9.0/pr-14182
Donald Sharp [Sat, 12 Aug 2023 18:02:31 +0000 (14:02 -0400)]
Merge pull request #14192 from FRRouting/mergify/bp/stable/9.0/pr-14182

bgpd: evpn code was not properly unlocking rd_dest (backport #14182)

20 months agobgpd: evpn code was not properly unlocking rd_dest 14192/head
Donald Sharp [Fri, 11 Aug 2023 13:53:42 +0000 (09:53 -0400)]
bgpd: evpn code was not properly unlocking rd_dest

Found some code where bgp was not unlocking the dest
and rd_dest when walking the tree attempting to
find something to install.

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

20 months agoMerge pull request #14187 from FRRouting/mergify/bp/stable/9.0/pr-12524
Jafar Al-Gharaibeh [Fri, 11 Aug 2023 18:58:09 +0000 (13:58 -0500)]
Merge pull request #14187 from FRRouting/mergify/bp/stable/9.0/pr-12524

lib, zebra: Fix EVPN nexthop config order (backport #12524)

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)