Commit Graph

30591 Commits

Author SHA1 Message Date
David Lamparter
7b78f6c87f
Merge pull request #12522 from donaldsharp/some_various_stuff 2022-12-16 15:30:37 +01:00
Louis Scalbert
ce82e90260 bgpd: fix attrhash_cmp() clang-format
Fix attrhash_cmp() clang-format

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-12-16 15:09:36 +01:00
Philippe Guibert
4a62ec1669 topotests: fix appropriate number of routes in bgp
The number of routes in BGP ce devices was wrong.
Change the expected values.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2022-12-16 15:07:58 +01:00
Louis Scalbert
767199c683 topotests: raise an error if pinging from vrf is not possible
Because of the issue described in the above link, pinging from vrf with
the command "ip vrf exec <vrf> ping -I <src> <addr>" may fail.

> root@topo:~# ip vrf exec vrf1 ping -c1 -I 192.168.2.1 192.168.1.1
> bind: Cannot assign requested address

Raise an error if pinging its own IP from a VRF fails. This test should
always work unless in the condition of this issue.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=203483
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-12-16 15:07:57 +01:00
Louis Scalbert
56748da55f topotests: add tests to bgp-vrf-route-leak-basic
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-12-16 15:07:56 +01:00
Louis Scalbert
a1d9f6f2f2 topotests: add VRF leak tests in bgp_l3vpn_to_bgp_vrf
Check that route leaking between VRF within a router works properly.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-12-16 15:07:55 +01:00
Louis Scalbert
90bdefa094 topotests: add retry in BGP RIB check
Add a retry option in the BGP RIB test.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-12-16 15:07:55 +01:00
Louis Scalbert
a7e794215c topotests: add ability to check that a prefix is not in BGP RIB
Add an "exist" key to check the existence of a prefix in the BGP RIB.
Useful to check that a prefix has not leaked by error.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-12-16 15:07:54 +01:00
Louis Scalbert
5f6c0ba6d2 bgpd: resend routes deleted by kernel after interface addresses deletion
When the last IPv4 address of an interface is deleted, Linux removes all
routes includes BGP ones using this interface without any Netlink
advertisement. bgpd keeps them in RIB as valid (e.g. installed in FIB).

The previous patch invalidates the associated nexthop groups in zebra
but bgpd is not notified of the event.

> 2022/05/09 17:37:52.925 ZEBRA: [TQKA8-0276P] Not Notifying Owner: connected about prefix 29.0.0.0/24(40) 3 vrf: 7

Look for the bgp_path_info that are unsynchronized with the kernel and
flag them for refresh in their attributes. A VPN route leaking update is
calles and the refresh flag triggers a route refresh to zebra and then a
kernel FIB installation.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-12-16 15:07:49 +01:00
Louis Scalbert
c6b38684bd zebra: delete kernel routes using an interface with no more IPv4 address
When the last IPv4 address of an interface is deleted, Linux removes
all routes using this interface without any Netlink advertisement.

Routes that have a IPv4 nexthop are correctly removed from the FRR RIB.
However, routes that only have an interface with no more IPv4 addresses
as a nexthop remains in the FRR RIB.

In this situation, among the routes that this particular interface
nexthop:
 - remove from the zebra kernel routes
 - reinstall the routes that have been added from FRR. It is useful when
   the nexthop is for example a VRF interface.

Add related test cases in the zebra_netlink topotest.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-12-16 15:07:46 +01:00
Louis Scalbert
667a4e92da bgpd: move mp_nexthop_prefer_global boolean attribute to nh_flag
Previous commits have introduced a new 8 bits nh_flag in the attr
struct that has increased the memory footprint.

Move the mp_nexthop_prefer_global boolean in the attr structure that
takes 8 bits to the new nh_flag in order to go back to the previous
memory utilization.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-12-16 15:07:00 +01:00
Louis Scalbert
86a1c29632 bgpd: fix route recursion on leaked routes
Leaked recursive routes are not resolved.

> VRF r1-cust1:
> B>  5.1.0.0/24 [200/98] via 99.0.0.1 (recursive), weight 1, 00:00:08
>  *                       via 192.168.1.2, r1-eth4, weight 1, 00:00:08
> B>* 99.0.0.1/32 [200/0] via 192.168.1.2, r1-eth4, weight 1, 00:00:08

> VRF r1-cust4:
> B   5.1.0.0/24 [20/98] via 99.0.0.1 (vrf r1-cust1) inactive, weight 1, 00:00:08
> B>* 99.0.0.1/32 [20/0] via 192.168.1.2, r1-eth4 (vrf r1-cust1), weight 1, 00:00:08

When announcing the routes to zebra, use the peer of the ultimate bgp
path info instead of the one of the first parent path info to determine
whether the route is recursive.

The result is:
> VRF r1-cust4:
> B>  5.1.0.0/24 [20/98] via 99.0.0.1 (vrf r1-cust1) (recursive), weight 1, 00:00:02
>   *                      via 192.168.1.2, r1-eth4 (vrf r1-cust1), weight 1, 00:00:02
> B>* 99.0.0.1/32 [20/0] via 192.168.1.2, r1-eth4 (vrf r1-cust1), weight 1, 00:00:02

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-12-16 14:52:47 +01:00
Louis Scalbert
36c61d5c8b topotests: update bgp_vrf_route_leak_basic
Update bgp_vrf_route_leak_basic to set up the VRF interfaces. Otherwise
the routes to the VRF interface are inactives.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-12-16 14:52:47 +01:00
Louis Scalbert
6030b8b40d bgpd: update route leaking when a VRF loopback is received
At bgpd startup, VRF instances are sent from zebra before the
interfaces. When importing a l3vpn prefix from another local VRF
instance, the interfaces are not known yet. The prefix nexthop interface
cannot be set to the loopback or the VRF interface, which causes setting
invalid routes in zebra.

Update route leaking when the loopback or a VRF interface is received
from zebra.

At a VRF interface deletion, zebra voluntarily sends a
ZEBRA_INTERFACE_ADD message to move it to VRF_DEFAULT. Do not update if
such a message is received. VRF destruction will destroy all the related
routes without adding codes.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-12-16 14:52:47 +01:00
Louis Scalbert
6b74c9fa66 topotests: update ospf_multi_vrf_bgp_route_leak
Leaked connected routes have now the following nexthop interfaces:
- lo for routes imported from the default VRF
- or the VRF interface for routes imported from the other VRFs.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-12-16 14:52:47 +01:00
Louis Scalbert
14aabc0156 bgpd: fix invalid nexthop interface on leaked routes
There is two cases where the nexthop interface is incorrect:

- Case 1: leaked routes from prefixes stated in 'network <prefix>' are
  inactive because they have no nexthop IP address or interface.
- Case 2: leaked routes from 'redistribute connected' contains the
  original nexthop interface.

======
Case 1
======
> router bgp 5227 vrf r1-cust1
>  bgp router-id 192.168.1.1
>  no bgp network import-check
> !
>  address-family ipv4 unicast
>   network 10.2.3.4/32
>   network 192.168.1.0/24
>   rd vpn export 10:1
>   rt vpn import 52:100
>   rt vpn export 52:101
>   export vpn
>   import vpn
>  exit-address-family
> exit
> !
> router bgp 5227 vrf r1-cust4
>  bgp router-id 192.168.1.1
> !
>  address-family ipv4 unicast
>   network 29.0.0.0/24
>   rd vpn export 10:1
>   rt vpn import 52:101
>   rt vpn export 52:100
>   export vpn
>   import vpn
>  exit-address-family
> exit

Extract from the routing table:

> VRF r1-cust1:
> S>* 192.0.0.0/24 [1/0] via 192.168.1.2, r1-eth4, weight 1, 00:47:53
> C>* 192.168.1.0/24 is directly connected, r1-eth4, 00:44:15
> B>* 29.0.0.0/24 [20/0] is directly connected, unknown (vrf r1-cust4), inactive, weight 1, 00:00:02
>
> VRF r1-cust4:
> B   10.2.3.4/32 [20/0] is directly connected, unknown (vrf r1-cust1) inactive, weight 1, 00:00:02
> C>* 29.0.0.0/24 is directly connected, r1-cust5, 00:27:40
> B   192.0.0.0/24 [20/0] is directly connected, unknown (vrf r1-cust1) inactive, weight 1, 00:03:40
> B   192.168.1.0/24 [20/0] is directly connected, unknown (vrf r1-cust1) inactive, weight 1, 00:00:02

======
Case 2
======

The previous is modified with the following settings:

> router bgp 5227 vrf r1-cust1
>  address-family ipv4 unicast
>   no network 192.168.1.0/24
>   redistribute connected
> !
> vrf r1-cust1
> ip route 29.0.0.0/24 r1-cust5 nexthop-vrf r1-cust5

Extract from the routing table:
> VRF r1-cust1:
> S>* 192.0.0.0/24 [1/0] via 192.168.1.2, r1-eth4, weight 1, 00:47:53
> C>* 192.168.1.0/24 is directly connected, r1-eth4, 00:44:15
> S>* 29.0.0.0/24 [1/0] is directly connected, r1-cust5 (vrf r1-cust5), weight 1, 00:00:30
>
> VRF r1-cust4:
> B   10.2.3.4/32 [20/0] is directly connected, unknown (vrf r1-cust1) inactive, weight 1, 00:00:02
> C>* 29.0.0.0/24 is directly connected, r1-cust5, 00:27:40
> B   192.0.0.0/24 [20/0] is directly connected, unknown (vrf r1-cust1) inactive, weight 1, 00:03:40
> B>* 192.168.1.0/24 [20/0] is directly connected, r1-eth4 (vrf r1-cust1), weight 1, 00:00:02

The nexthop interface is r1-eth4. It causes issue to traffic leaving
r1-cust4. The following ping to r1-eth4 local address 192.168.1.1 from
r1-cust5 local add does
not respond.

> # tcpdump -lnni r1-cust1 'icmp' &
> # ip vrf exec r1-cust4 ping -c1 192.168.1.1 -I 29.0.0.1
> PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
PING 192.168.1.1 (192.168.1.1) from 29.0.0.1 : 56(84) bytes of data.
18:49:20.635638 IP 29.0.0.1 > 192.168.1.1: ICMP echo request, id 15897, seq 1, length 64
18:49:27.113827 IP 29.0.0.1 > 29.0.0.1: ICMP host 192.168.1.1 unreachable, length 92

Fix description:

When leaking prefix from other VRFs, if the nexthop IP address is not
set in the bgp path info attribures, reset nh_ifindex to the index of
master interface of the incoming BGP instance.

The result is for case 1 and 2:

> VRF r1-cust1:
> S>* 192.0.0.0/24 [1/0] via 192.168.1.2, r1-eth4, weight 1, 00:47:53
> C>* 192.168.1.0/24 is directly connected, r1-eth4, 00:44:15
> B>* 29.0.0.0/24 [20/0] is directly connected, r1-cust4 (vrf r1-cust4), weight 1, 00:00:08
>
> VRF r1-cust4:
> B>* 10.2.3.4/32 [20/0] is directly connected, r1-cust1 (vrf r1-cust1), weight 1, 00:00:08
> C>* 29.0.0.0/24 is directly connected, r1-cust5, 00:27:40
> B>* 192.0.0.0/24 [20/0] is directly connected, r1-cust1 (vrf r1-cust1), weight 1, 00:00:08
> B>* 192.168.1.0/24 [20/0] is directly connected, r1-cust1 (vrf r1-cust1), weight 1, 00:00:08

> # tcpdump -lnni r1-cust1 'icmp' &
> # ping -c1 192.168.1.1 -I 29.0.0.1
> PING 192.168.1.1 (192.168.1.1) from 29.0.0.1 : 56(84) bytes of data.
> 18:48:32.506281 IP 29.0.0.1 > 192.168.1.1: ICMP echo request, id 15870, seq 1, length 64
> 64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.050 ms
> 18:48:32.506304 IP 192.168.1.1 > 29.0.0.1: ICMP echo reply, id 15870, seq 1, length 64

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>

 1, 00:47:53
4:15
vrf r1-cust4), inactive, weight 1, 00:00:02

vrf r1-cust1) inactive, weight 1, 00:00:02
40
(vrf r1-cust1) inactive, weight 1, 00:03:40
n (vrf r1-cust1) inactive, weight 1, 00:00:02

dress is not
the index of

 1, 00:47:53
4:15
(vrf r1-cust4), weight 1, 00:00:08

(vrf r1-cust1), weight 1, 00:00:08
40
 (vrf r1-cust1), weight 1, 00:00:08
t1 (vrf r1-cust1), weight 1, 00:00:08
2022-12-16 14:52:47 +01:00
Louis Scalbert
09e370e5ff lib: fix clang warning
Fix a CLANG warning

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-12-16 14:52:47 +01:00
Louis Scalbert
e7192e9d24 lib: add a function to get the VRF or loopback interface
Add a function to find the VRF or the loopback interface: the loopback
interface for the default VRF and the VRF master interface otherwise.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-12-16 14:52:47 +01:00
Louis Scalbert
acf31ef73b bgpd: fix prefix VRF leaking with 'network import-check' (5/5)
The following configuration creates an infinite routing leaking loop
because 'rt vpn both' parameters are the same in both VRFs.

> router bgp 5227 vrf r1-cust4
>    no bgp network import-check
>    bgp router-id 192.168.1.1
>    address-family ipv4 unicast
>      network 28.0.0.0/24
>      rd vpn export 10:12
>      rt vpn both 52:100
>      import vpn
>      export vpn
>    exit-address-family
> !
> router bgp 5227 vrf r1-cust5
>    no bgp network import-check
>    bgp router id 192.168.1.1
>    address-family ipv4 unicast
>      network 29.0.0.0/24
>      rd vpn export 10:13
>      rt vpn both 52:100
>      import vpn
>      export vpn
>    exit-address-family

The previous commit has added a routing leak update when a nexthop
update is received from zebra. It indirectly calls
bgp_find_or_add_nexthop() in which a static route triggers a nexthop
cache entry registration that triggers a nexthop update from zebra.

Do not register again the nexthop cache entry if the BGP_STATIC_ROUTE is
already set.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-12-16 14:52:47 +01:00
Louis Scalbert
1e24860bf7 bgpd: fix prefix VRF leaking with 'network import-check' (4/5)
If 'network import-check' is defined on the source BGP session, prefixes
that are stated in the network command cannot be leaked to the other
VRFs BGP table even if they are present in the origin VRF RIB if the
'rt import' statement is defined after the 'network <prefix>' ones.

When a prefix nexthop is updated, update the prefix route leaking. The
current state of nexthop validation is now stored in the attributes of
the bgp path info. Attributes are compared with the previous ones at
route leaking update so that a nexthop validation change now triggers
the update of destination VRF BGP table.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-12-16 14:52:47 +01:00
Louis Scalbert
d0a55f87e9 bgpd: fix prefix VRF leaking with 'network import-check' (3/5)
"if not XX else" statements are confusing.

Replace two "if not XX else" statements by "if XX else" to prepare next
commits. The patch is only cosmetic.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-12-16 14:52:47 +01:00
Louis Scalbert
1565c70984 bgpd: fix prefix VRF leaking with 'network import-check' (2/5)
Move setting of some variables backwards to prepare next commits.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-12-16 14:52:47 +01:00
Louis Scalbert
0f001a82a8 bgpd: fix prefix VRF leaking with 'network import-check' (1/5)
If 'network import-check' is defined on the source BGP session, prefixes
that are stated in the network command cannot be leaked to the other
VRFs BGP table even if they are present in the origin VRF RIB.

Always validate the nexthop of BGP static routes (i.e. defined with the
network statement) if 'network import-check' is defined on the source
BGP session and the prefix is present in source RIB.

It fixes the issue when the 'rt import' statement is defined after the
'network' ones.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-12-16 14:52:47 +01:00
Louis Scalbert
1c4c40696f bgpd: fix prefix VRF leaking with 'no network import-check'
Prefixes that are stated in the network command cannot be leaked to
the other VRFs BGP table whether or not they are present in the origin
VRF RIB.

Always validate the nexthop of BGP static routes (i.e. defined with the
network statement) if 'no network import-check' is defined on the source
BGP session.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2022-12-16 14:52:47 +01:00
Donald Sharp
233b1a3860 bgpd: Convert bgp_packet_mpattr_prefix to use an enum for safi's
The function bgp_packet_mpattr_prefix was using an if statement
to encode packets to the peer.  Change it to a switch and make
it handle all the cases and fail appropriately when something
has gone wrong.  Hopefully in the future when a new afi/safi
is added we can catch it by compilation breaking instead of
weird runtime errors

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-12-16 08:43:16 -05:00
Donald Sharp
722e8011e1 bgpd: make bgp_packet_mpattr_start more prescriptive when using enum's
This function was just using default: case statements for
the encoding of nlri's to a peer.  Lay out all the different
cases and make things fail hard when a dev escape is found.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-12-16 08:17:18 -05:00
Donald Sharp
4487f0bd2c bgpd: Convert bgp_packet_mpattr_prefix_size to use an enum
The function bgp_packet_mpattr_prefix_size had an if/else
body that allowed people to add encoding types to bgpd
such that we could build the wrong size packets.  This
was exposed recently in commit:
0a9705a1e0

Where it was discovered flowspec was causing bgp update
messages to exceed the maximum size and the peer to
drop the connection.  Let's be proscriptive about this
and hopefully make it so that things don't work when
someone adds a new safi to the system ( and they'll have
to update this function ).

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-12-16 07:58:54 -05:00
Donald Sharp
960ad09f93
Merge pull request #12528 from spoignant-proton/master
bgpd: Add support for flowspec prefixes in bgp_packet_mpattr_prefix_size
2022-12-16 07:50:43 -05:00
Donald Sharp
b5478f9536
Merge pull request #12532 from opensourcerouting/fix/do_not_forget_updating_docs
docs: Do not forget updating default version for readthedocs.org
2022-12-16 07:42:04 -05:00
Donald Sharp
16c150f27b lib, staticd: return values even after an assert
When compiling with -fsanitize=thread.  I started getting this error:

staticd/static_zebra.c: In function ‘static_zebra_nht_get_prefix’:
staticd/static_zebra.c:316:1: error: control reaches end of non-void function [-Werror=return-type]
  316 | }
      | ^

Just to make future efforts still work, let's just make the compiler happy.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-12-16 07:38:58 -05:00
Sarita Patra
a5a221bf34 pimd: Fix (S,G) debug issue
Signed-off-by: Sarita Patra <saritap@vmware.com>
2022-12-16 03:05:37 -08:00
Donatas Abraitis
59a5f54681 docs: Do not forget updating default version for readthedocs.org
docs.frrouting.org

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-12-16 09:58:41 +02:00
Donatas Abraitis
507621139b
Merge pull request #10576 from louis-6wind/fix-l3vpn-igmetric
bgpd: fix the IGP metric for best path selection on VPN import
2022-12-16 09:18:01 +02:00
Mark Stapp
2d6916ad70
Merge pull request #12530 from taspelund/remote_macip_memleak
bgpd: cleanup macip_path_list for remote macip
2022-12-15 16:48:16 -05:00
Trey Aspelund
889360dcfd bgpd: cleanup macip_path_list for remote macip
ASAN reported the following memleak:
```
Direct leak of 40 byte(s) in 1 object(s) allocated from:
    #0 0x4d4342 in calloc (/usr/lib/frr/bgpd+0x4d4342)
    #1 0xbc3d68 in qcalloc /home/sharpd/frr8/lib/memory.c:116:27
    #2 0xb869f7 in list_new /home/sharpd/frr8/lib/linklist.c:64:9
    #3 0x5a38bc in bgp_evpn_remote_ip_hash_alloc /home/sharpd/frr8/bgpd/bgp_evpn.c:6789:24
    #4 0xb358d3 in hash_get /home/sharpd/frr8/lib/hash.c:162:13
    #5 0x593d39 in bgp_evpn_remote_ip_hash_add /home/sharpd/frr8/bgpd/bgp_evpn.c:6881:7
    #6 0x59dbbd in install_evpn_route_entry_in_vni_common /home/sharpd/frr8/bgpd/bgp_evpn.c:3049:2
    #7 0x59cfe0 in install_evpn_route_entry_in_vni_ip /home/sharpd/frr8/bgpd/bgp_evpn.c:3126:8
    #8 0x59c6f0 in install_evpn_route_entry /home/sharpd/frr8/bgpd/bgp_evpn.c:3318:8
    #9 0x59bb52 in install_uninstall_route_in_vnis /home/sharpd/frr8/bgpd/bgp_evpn.c:3888:10
    #10 0x59b6d2 in bgp_evpn_install_uninstall_table /home/sharpd/frr8/bgpd/bgp_evpn.c:4019:5
    #11 0x578857 in install_uninstall_evpn_route /home/sharpd/frr8/bgpd/bgp_evpn.c:4051:9
    #12 0x58ada6 in bgp_evpn_import_route /home/sharpd/frr8/bgpd/bgp_evpn.c:6049:9
    #13 0x713794 in bgp_update /home/sharpd/frr8/bgpd/bgp_route.c:4842:3
    #14 0x583fa0 in process_type2_route /home/sharpd/frr8/bgpd/bgp_evpn.c:4518:9
    #15 0x5824ba in bgp_nlri_parse_evpn /home/sharpd/frr8/bgpd/bgp_evpn.c:5732:8
    #16 0x6ae6a2 in bgp_nlri_parse /home/sharpd/frr8/bgpd/bgp_packet.c:363:10
    #17 0x6be6fa in bgp_update_receive /home/sharpd/frr8/bgpd/bgp_packet.c:2020:15
    #18 0x6b7433 in bgp_process_packet /home/sharpd/frr8/bgpd/bgp_packet.c:2929:11
    #19 0xd00146 in thread_call /home/sharpd/frr8/lib/thread.c:2006:2
```

The list itself was not being cleaned up when the final list entry was
removed, so make sure we do that instead of leaking memory.

Signed-off-by: Trey Aspelund <taspelund@nvidia.com>
2022-12-15 18:52:16 +00:00
Donald Sharp
5a59e9b21f bgpd: If we don't find what we are looking for cleanup the json structure
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-12-15 11:15:33 -05:00
Donald Sharp
1fec35c3c7 lib: Fix free function
The list delete function on creation was set to srv6_locator_chunk_free
Which takes a double pointer and dereferences it to free the data.
When list_delete is called it calls the delete function like this:
                if (*list->del)
                        (*list->del)(node->data);

The data is not passed in by reference and as such we do not have
a double pointer.  Fortunately this list_delete is only really
called on shutdown when the locator was deleted and we do not
have a fun situation where we were suddenly freeing 'something'.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-12-15 11:15:33 -05:00
Donald Sharp
6354d63593 ospf6d: Fix auth_key string memory leak
When using auth keys in ospfv3, there are some memory
leaks when you change the key or remove the interface

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-12-15 11:15:33 -05:00
Donald Sharp
739bc9fd72 zebra: When freeing the early route queue, actually free it right
The early route queue has a series of `struct zebra_early_route *`
entries.  Zebra is treating this memory as just a `struct route entry`.
This is wrong.  Correct this to free the memory correctly.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-12-15 11:15:33 -05:00
Donald Sharp
074c80b705 lib, tests, zebra: Remove unused workqueue error function
The wq->spec.errorfunc is never used in the code.
It's been in the code base since 2005 and I also
do not remember ever seeing it being called.  No
workqueue process function ever returns error.
Since it's not used let's just remove it from the
code base.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-12-15 11:15:33 -05:00
Donald Sharp
9a5602b8ed tests: Limit run of config_timing when building with --enable-address-sanitizer
Building FRR with --enable-address-sanitizer and then running the
config_timing test makes the test run for over an hour on my machine.
The goal of this test is to ensure that the test runs 10000 routes
in/out in a reasonable amount of time.  We cannot test this with
address-sanitizer enabled.  So just make the test meaningless
from a timing perspective but keep it `alive` from a it might
catch some address sanitizer issue with 50 -vs- 10000 routes

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-12-15 11:15:33 -05:00
Donald Sharp
478c62e21d zebra: Fix nexthop group memory leak
Address Sanitizer found this:

=================================================================
==418623==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 128 byte(s) in 4 object(s) allocated from:
    #0 0x4bd732 in calloc (/usr/lib/frr/zebra+0x4bd732)
    #1 0x7feaeab8f798 in qcalloc /home/sharpd/frr8/lib/memory.c:116:27
    #2 0x7feaeaba40f4 in nexthop_group_new /home/sharpd/frr8/lib/nexthop_group.c:270:9
    #3 0x56859b in netlink_route_change_read_unicast /home/sharpd/frr8/zebra/rt_netlink.c:950:9
    #4 0x5651c2 in netlink_route_change /home/sharpd/frr8/zebra/rt_netlink.c:1204:2
    #5 0x54af15 in netlink_information_fetch /home/sharpd/frr8/zebra/kernel_netlink.c:407:10
    #6 0x53e7a3 in netlink_parse_info /home/sharpd/frr8/zebra/kernel_netlink.c:1184:12
    #7 0x548d46 in kernel_read /home/sharpd/frr8/zebra/kernel_netlink.c:501:2
    #8 0x7feaeacc87f6 in thread_call /home/sharpd/frr8/lib/thread.c:2006:2
    #9 0x7feaeab36503 in frr_run /home/sharpd/frr8/lib/libfrr.c:1198:3
    #10 0x550d38 in main /home/sharpd/frr8/zebra/main.c:476:2
    #11 0x7feaea492d09 in __libc_start_main csu/../csu/libc-start.c:308:16

Indirect leak of 576 byte(s) in 4 object(s) allocated from:
    #0 0x4bd732 in calloc (/usr/lib/frr/zebra+0x4bd732)
    #1 0x7feaeab8f798 in qcalloc /home/sharpd/frr8/lib/memory.c:116:27
    #2 0x7feaeab9b3f8 in nexthop_new /home/sharpd/frr8/lib/nexthop.c:373:7
    #3 0x56875e in netlink_route_change_read_unicast /home/sharpd/frr8/zebra/rt_netlink.c:960:15
    #4 0x5651c2 in netlink_route_change /home/sharpd/frr8/zebra/rt_netlink.c:1204:2
    #5 0x54af15 in netlink_information_fetch /home/sharpd/frr8/zebra/kernel_netlink.c:407:10
    #6 0x53e7a3 in netlink_parse_info /home/sharpd/frr8/zebra/kernel_netlink.c:1184:12
    #7 0x548d46 in kernel_read /home/sharpd/frr8/zebra/kernel_netlink.c:501:2
    #8 0x7feaeacc87f6 in thread_call /home/sharpd/frr8/lib/thread.c:2006:2
    #9 0x7feaeab36503 in frr_run /home/sharpd/frr8/lib/libfrr.c:1198:3
    #10 0x550d38 in main /home/sharpd/frr8/zebra/main.c:476:2
    #11 0x7feaea492d09 in __libc_start_main csu/../csu/libc-start.c:308:16

SUMMARY: AddressSanitizer: 704 byte(s) leaked in 8 allocation(s).

Fix this!

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-12-15 11:15:33 -05:00
Donald Sharp
6f83bbd614 lib: On shutdown, disable snmp from working
When shutting down ensure that any daemon operating with
snmp tells it to stop operating so no more data is sent.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-12-15 11:14:53 -05:00
Louis Scalbert
dbb03df84f tests: fix IGP metric best path selection in bgp_l3vpn_to_bgp_vrf
The L3VPN best path computation now takes into accound the IGP metric.

Adapt the bgp_l3vpn_to_bgp_vrf tests so that routes with the best IGP
metric are selected when needed.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-12-15 17:10:59 +01:00
Louis Scalbert
e577535f15 tests: add a bgp path selection topotest
Add a bgp path selection topotest to the IGP metric path selection.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-12-15 17:10:59 +01:00
Louis Scalbert
6f27419975 bgpd: display the IGP metric of the ultimate path in snmp
Display the IGP metric of the ultimate path in the SNMP OID
mplsL3VpnVrfRteInetCidrMetric1.

Fixes: da0c0ef70c ("bgpd: VRF-Lite fix best path selection")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-12-15 17:10:59 +01:00
Louis Scalbert
f0cde006f0 bgpd: display the IGP metric of the ultimate path in route details
Display IGP metric of the ultimate path in the command
"show bgp vrf X ipv(4|6)".

Fixes: da0c0ef70c ("bgpd: VRF-Lite fix best path selection")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-12-15 17:10:56 +01:00
Louis Scalbert
ac2f64d3ec bgpd: fix the IGP metric for best path selection on VPN import
Since the commit da0c0ef70c ("bgpd: VRF-Lite fix best path selection"),
the best path selection is made from the comparison of the attributes
of the original route i.e. the ultimate path.

The IGP metric is currently set on the child path instead of the
ultimate path (i.e. the parent path). On eBGP, the ultimate path is the
child path. However, for imported routes, the ultimate path is always
set to 0, which results in skipping the IGP metric comparison when
selecting the best path.

Set the IGP metric on the ultimate path when a BGP nexthop is added or
updated.

Fixes: da0c0ef70c ("bgpd: VRF-Lite fix best path selection")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-12-15 17:09:35 +01:00
Stephane Poignant
0a9705a1e0
bgpd: Add support for flowspec prefixes in bgp_packet_mpattr_prefix_size
Currently, bgp_packet_mpattr_prefix_size (bgpd/bgp_attr.c:3978) always returns zero for Flowspec prefixes.
This is because, for flowspec prefixes, the prefixlen attribute of the prefix struct is always set to 0, and the actual length is bytes is set inside the flowspec_prefix struct instead (see lib/prefix.h:293 and lib/prefix.h:178).
Because of this, with a large number of flowspec NLRIs, bgpd ends up building update messages that exceed the maximum size and cause the peer to drop the connection (bgpd/bgp_updgrp_packet.c:L719).
The proposed change allows the bgp_packet_mpattr_prefix_size to return correct result for flowspec prefixes.

Signed-off-by: Stephane Poignant <stephane.poignant@proton.ch>
2022-12-15 14:53:48 +01:00
Donald Sharp
2fcd46fe38 lib: Convert agentx_enabled to a bool
FRR is using this as a bool.  Let's just use a bool.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-12-15 07:31:55 -05:00