Commit Graph

34898 Commits

Author SHA1 Message Date
Donald Sharp
62443d7f66
Merge pull request #15264 from opensourcerouting/fix/memory_optimization
bgpd: Optimize memory for rd_ip struct
2024-02-01 14:55:18 -05:00
Donald Sharp
0bdcf62b8c
Merge pull request #15270 from LabNConsulting/chopps/fix-rpm-pkg
redhat: add option to include mgmtd_testc test client
2024-02-01 14:51:58 -05:00
Russ White
398c70074b
Merge pull request #15266 from donaldsharp/packable
2 memory optimizations
2024-02-01 14:23:58 -05:00
Mark Stapp
72b31b96fc *: create a single registry of daemons' default port values
Create a single registry of default port values that daemons
are using. Most of these are vty ports, but there are some
others for features like ospfapi and zebra FPM.

Signed-off-by: Mark Stapp <mjs@labn.net>
2024-02-01 11:40:02 -05:00
Donatas Abraitis
0223b98c5c bgpd: One more attr struct memory optimization
```
struct attr {
	struct aspath *            aspath;               /*     0     8 */
	struct community *         community;            /*     8     8 */
	long unsigned int          refcnt;               /*    16     8 */
	_uint64_t                  flag;                 /*    24     8 */
	struct in_addr             nexthop;              /*    32     4 */
	uint32_t                   med;                  /*    36     4 */
	uint32_t                   local_pref;           /*    40     4 */
	ifindex_t                  nh_ifindex;           /*    44     4 */
	uint8_t                    nh_flags;             /*    48     1 */
	uint8_t                    origin;               /*    49     1 */
	uint8_t                    es_flags;             /*    50     1 */
	uint8_t                    router_flag;          /*    51     1 */
	uint8_t                    distance;             /*    52     1 */
	uint8_t                    df_alg;               /*    53     1 */
	uint16_t                   df_pref;              /*    54     2 */
	enum pta_type              pmsi_tnl_type;        /*    56     4 */
	uint32_t                   rmap_change_flags;    /*    60     4 */
	/* --- cacheline 1 boundary (64 bytes) --- */
	struct in6_addr            mp_nexthop_global;    /*    64    16 */
	struct in6_addr            mp_nexthop_local;     /*    80    16 */
	ifindex_t                  nh_lla_ifindex;       /*    96     4 */
	mpls_label_t               label;                /*   100     4 */
	struct ecommunity *        ecommunity;           /*   104     8 */
	struct ecommunity *        ipv6_ecommunity;      /*   112     8 */
	struct lcommunity *        lcommunity;           /*   120     8 */
	/* --- cacheline 2 boundary (128 bytes) --- */
	struct cluster_list *      cluster1;             /*   128     8 */
	struct transit *           transit;              /*   136     8 */
	struct in_addr             mp_nexthop_global_in; /*   144     4 */
	struct in_addr             aggregator_addr;      /*   148     4 */
	struct in_addr             originator_id;        /*   152     4 */
	uint32_t                   weight;               /*   156     4 */
	as_t                       aggregator_as;        /*   160     4 */
	uint8_t                    mp_nexthop_len;       /*   164     1 */
	uint8_t                    mp_nexthop_prefer_global; /*   165     1 */
	uint8_t                    sticky;               /*   166     1 */
	uint8_t                    default_gw;           /*   167     1 */
	route_tag_t                tag;                  /*   168     4 */
	uint32_t                   label_index;          /*   172     4 */
	struct bgp_attr_srv6_vpn * srv6_vpn;             /*   176     8 */
	struct bgp_attr_srv6_l3vpn * srv6_l3vpn;         /*   184     8 */
	/* --- cacheline 3 boundary (192 bytes) --- */
	struct bgp_attr_encap_subtlv * encap_subtlvs;    /*   192     8 */
	struct bgp_attr_encap_subtlv * vnc_subtlvs;      /*   200     8 */
	struct bgp_route_evpn      evpn_overlay;         /*   208    36 */
	uint32_t                   mm_seqnum;            /*   244     4 */
	uint32_t                   mm_sync_seqnum;       /*   248     4 */
	struct ethaddr             rmac;                 /*   252     6 */
	/* --- cacheline 4 boundary (256 bytes) was 2 bytes ago --- */
	uint16_t                   encap_tunneltype;     /*   258     2 */
	uint32_t                   rmap_table_id;        /*   260     4 */
	uint32_t                   link_bw;              /*   264     4 */
	esi_t                      esi;                  /*   268    10 */

	/* XXX 2 bytes hole, try to pack */

	uint32_t                   srte_color;           /*   280     4 */
	enum nexthop_types_t       nh_type;              /*   284     4 */
	enum blackhole_type        bh_type;              /*   288     4 */
	uint32_t                   otc;                  /*   292     4 */
	_uint64_t                  aigp_metric;          /*   296     8 */

	/* size: 304, cachelines: 5, members: 54 */
	/* sum members: 302, holes: 1, sum holes: 2 */
	/* last cacheline: 48 bytes */
};   /* saved 8 bytes! */
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-02-01 17:28:42 +02:00
Donald Sharp
bb1e1265aa bgpd: Save memory when using bgp_path_info_extra and vnc
Structure size of bgp_path_info_extra when compiled
with vnc is 184 bytes.  Reduce this size to 72 bytes
when compiled w/ vnc but not necessarily turned
on vnc.

With 2 full bgp feeds this saves aproximately 100mb
when compiling with vnc and not using vnc.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-02-01 07:54:35 -05:00
Donald Sharp
a8e8f1bc72 lib: Reduce size of hash_bucket by 8 bytes
pahole reports that the hash_bucket has 2 4 byte holes
in the data structure.  Let's reorganize this a bit
and save 8 bytes per hash_bucket instance.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-02-01 07:53:31 -05:00
Louis Scalbert
8af61c8a34 topotests: test leak from the default vrf
Add tests in bgp_vrf_route_leak_basic topotest to check that route
leaking from the default VRF results in an operational route.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-02-01 11:46:56 +01:00
Christian Hopps
7521918454 tests: add mgmtd backend notification test
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-02-01 05:37:59 -05:00
Louis Scalbert
eeb9f76588 topotests: test leak from unknown vrf
Add a test in bgp_vrf_route_leak_basic topotest to check that route
leaking from a non existing VRF results in an inactive route.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-02-01 11:12:43 +01:00
Louis Scalbert
b459f7937e 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>
2024-02-01 11:11:41 +01:00
Carmine Scarpitta
0fb22f3e9b topotests: update interface in SRv6 topotest
Previously, routes leaked from one VRF to another VRF were associated
with the original nexthop interface.

Due to this change, the `bgp_srv6l3vpn_route_leak` topotest always fails
because it still expects the nexthop interface.

This commit fixes the expected interface name in the
`bgp_srv6l3vpn_route_leak` topotest.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-02-01 10:21:43 +01:00
Louis Scalbert
60e73903d5 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>
2024-02-01 10:21:43 +01:00
Louis Scalbert
db7cf73a33 bgpd: fix interface on leaks from redistribute connected
In the target VRF's Routing Information Base (RIB), routes that are
leaked and originate from the 'redistribute connected' command have
their next-hop interface set as the interface from the source VRF.
This prevents the IP address of the connected interface from being
reachable from the target VRF.

> router bgp 5227 vrf r1-cust1
>  address-family ipv4 unicast
>   redistribute connected
>   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
>  address-family ipv4 unicast
>   network 192.0.2.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
> !
> vrf r1-cust1
>  ip route 192.0.2.0/24 r1-cust4 nexthop-vrf r1-cust4

Extract from the routing table:
> VRF r1-cust1:
> C>* 172.16.29.0/24 is directly connected, r1-eth4, 00:44:15
> S>* 192.0.2.0/24 [1/0] is directly connected, r1-cust4 (vrf r1-cust4), weight 1, 00:00:30
>
> VRF r1-cust4:
> B>* 172.16.29.0/24 [20/0] is directly connected, r1-eth4 (vrf r1-cust1), weight 1, 00:00:02

In r1-cust4 VRF, the nexthop interface of 172.16.29.0/24 is r1-eth4,
which is unknown in the context. The following ping does not work:

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

Fix the issue by setting nh_ifindex to the index of the VRF master
interface of the incoming BGP instance. The result is:

> VRF r1-cust4:
> C>* 192.0.2.0/24 is directly connected, r1-cust5, 00:27:40
> B>* 172.16.29.0/24 [20/0] is directly connected, r1-cust1 (vrf r1-cust1), weight 1, 00:00:08

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

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-02-01 10:21:43 +01:00
Louis Scalbert
067fbab4e4 bgpd: fix interface on leaks from network statement
Leaked routes from prefixes defined with 'network <prefix>' are inactive
because they have no valid nexthop interface.

> vrf r1-cust1
>  ip route 172.16.29.0/24 192.168.1.2
> router bgp 5227 vrf r1-cust1
>  no bgp network import-check
>  address-family ipv4 unicast
>   network 172.16.29.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 192.0.2/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>* 172.16.29.0/24 [1/0] via 192.168.1.2, r1-eth4, weight 1, 00:47:53
>
> VRF r1-cust4:
> B   172.16.29.0/24 [20/0] is directly connected, unknown (vrf r1-cust1) inactive, weight 1, 00:03:40

Routes imported through the "network" command, as opposed to those
redistributed from the routing table, do not associate with any specific
interface.

When leaking prefix from other VRFs, if the route was imported from the
network statement (ie. static sub-type), set nh_ifindex to the index of
the VRF master interface of the incoming BGP instance.

The result is:

> VRF r1-cust4:
> B>* 172.16.29.0/24 [20/0] is directly connected, r1-cust1 (vrf r1-cust1), weight 1, 00:00:08

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-02-01 10:21:43 +01:00
Igor Ryzhov
a2caf2b5e1
Merge pull request #15268 from LabNConsulting/chopps/quieter-code
lowercase and localize debug/err macros
2024-02-01 10:54:30 +02:00
Christian Hopps
cb56b004b5 redhat: add option to include mgmtd_testc test client
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-02-01 03:17:44 -05:00
Christian Hopps
e9fc85f421 mgmtd: convert MGMTD_FE_CLIENT_DBG() to debug_fe_client()
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-31 20:19:23 -05:00
Christian Hopps
21f3b4e5c5 mgmtd: convert MGMTD_BE_CLIENT_DBG() to debug_be_client()
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-31 20:19:23 -05:00
Christian Hopps
31b6d684e1 mgmtd: convert MGMT_FE_ADAPTER_DBG() to __dbg()
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-31 20:19:23 -05:00
Christian Hopps
fb8dc955b1 mgmtd: convert MGMT_BE_ADAPTER_DBG() to __dbg()
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-31 20:19:23 -05:00
Christian Hopps
ef305e8993 mgmtd: convert MGMT_DS_DBG() to __dbg()
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-31 20:19:23 -05:00
Christian Hopps
ecd13c615b mgmtd: convert MGMT_TXN_DBG() to __dbg()
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-31 20:18:55 -05:00
Donatas Abraitis
bd3b17d27d
Merge pull request #15258 from louis-6wind/fix-adj-in-attr
bgpd: fix attr comparaison bgp_adj_in_set
2024-01-31 15:06:40 +02:00
Igor Ryzhov
72949f5f94
Merge pull request #15251 from qlyoung/fix-doc-nbcli-numlist
doc: fix misformatted list in nbapi docs
2024-01-31 15:06:25 +02:00
Christian Hopps
25d3086d83
Merge pull request #15246 from idryzhov/mgmt-get-data-improvements
mgmt get-data improvements
2024-01-31 06:04:04 -05:00
Donatas Abraitis
0fd46e3f4e bgpd: Optimize memory for rd_ip struct
```
struct rd_ip {
	uint16_t                   type;                 /*     0     2 */
	uint16_t                   val;                  /*     2     2 */
	struct in_addr             ip;                   /*     4     4 */

	/* size: 8, cachelines: 1, members: 3 */
	/* last cacheline: 8 bytes */
};   /* saved 4 bytes! */
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-01-31 11:29:30 +02:00
Igor Ryzhov
3afea9ccda tests: add tests for mgmt get-data with-defaults parameter
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-31 02:20:13 +02:00
Igor Ryzhov
c19d0a5bf3 mgmtd: add our own format definitions for frontend messages
It allows people not familiar with libyang and FRR internals to use
mgmtd FE API by looking only at `mgmt_msg_native.h` header. We still use
the same values to avoid a lot of mapping code, and ensure that any
change doesn't slip unnoticed by using static asserts.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-31 02:20:13 +02:00
Igor Ryzhov
dda5de0340 mgmtd: fix printing an empty data tree
We don't need to create an actual tree to print an empty tree, libyang
handles NULL just fine. The actual problem is that `yang_dnode_new`
creates a tree by validating it, and the validation creates all implicit
default nodes. Therefore, when called with "with-default" flags, instead
of getting an empty tree, we get a tree with all top-level default set.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-31 02:20:13 +02:00
Igor Ryzhov
e13c590abe mgmtd: add ability to choose datastore to get data from
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-31 02:20:13 +02:00
Igor Ryzhov
4317c8ffa6 mgmtd: add support for with-defaults parameter to get-data
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-31 02:20:13 +02:00
Igor Ryzhov
e2caf64ef7 yang: add more ietf models
These models are needed to use LYD_PRINT_WD_ALL_TAG flag of libyang.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-31 02:20:13 +02:00
Igor Ryzhov
642078de8e
Merge pull request #15254 from LabNConsulting/chopps/notifications
Add YANG notifications
2024-01-31 02:18:20 +02:00
Igor Ryzhov
2a572bad91
Merge pull request #14764 from mjstapp/nb_gen_tool
tools, vtysh: add the cli write callback, unhide an NB show command
2024-01-30 23:02:18 +02:00
Igor Ryzhov
ecc88c52ba build: build: make mgmtd test client build conditional
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-01-30 15:41:26 -05:00
Christian Hopps
1e884ba12f mgmtd: backend subscriptions to notifications
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-30 15:41:26 -05:00
Russ White
61aa468a04
Merge pull request #15257 from opensourcerouting/fix/reinstall_aggregate_route_if_rmap
bgpd: Reinstall aggregated routes if using route-maps and it was changed
2024-01-30 15:08:08 -05:00
Christian Hopps
cb3242f697 tests: add YANG notification test
Signed-off-by: Christian Hopps <chopps@labn.net>
2024-01-30 14:54:47 -05:00
Quentin Young
5b4a3d3af9 doc: update [no] recommendation
Signed-off-by: Quentin Young <qlyoung@qlyoung.net>
2024-01-30 12:16:01 -05:00
Jafar Al-Gharaibeh
471e4b7bbe
Merge pull request #15163 from opensourcerouting/fix/pam_account
packaging: Require account validation with pam_unix.so if PAM enabled
2024-01-30 10:24:57 -06:00
Donald Sharp
d633a81dbf
Merge pull request #15250 from opensourcerouting/fix/memory_optimizations
bgpd: Some memory optimizations
2024-01-30 10:56:35 -05:00
Donald Sharp
71dd971aeb
Merge pull request #15252 from mjstapp/fix_bitfield_init
lib: init new bitfield word after realloc
2024-01-30 10:54:23 -05:00
Dmytro Shytyi
51014631f0 tests: an srv6 sid reachability use-case
Verify that SRv6 SID becomes unreachable and
further the IPv4 route in L3VPN becomes invalid.

Signed-off-by: Dmytro Shytyi <dmytro.shytyi@6wind.com>
2024-01-30 16:15:17 +01:00
Dmytro Shytyi
b3ac50287d bgpd: srv6 sid reachability verification
In the case of SRv6-VPN we track the reachability
to the SID. We check that the SID is available
in the BGP update and then we check the nexthop
reachability.

Fixes 7f8c7d9 ("bgpd: ignore nexthop validation for srv6-vpn")

Signed-off-by: Dmytro Shytyi <dmytro.shytyi@6wind.com>
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2024-01-30 16:15:17 +01:00
Dmytro Shytyi
26c747ed6c bgpd: extend make_prefix to form srv6-based prefix
Enable the SRv6 SID prefix generation in make_prefix()
function of bgp_nht.c.

Signed-off-by: Dmytro Shytyi <dmytro.shytyi@6wind.com>

fixup: bgpd: extend make_prefix to form srv6-based prefix
2024-01-30 16:15:13 +01:00
Dmytro Shytyi
f49fc7682f doc: bgp ipv4 l3vpn sid reachability
BGP IPv4 L3VPN with SRv6 SID reachability example
provided in the documentation

Signed-off-by: Dmytro Shytyi <dmytro.shytyi@6wind.com>
2024-01-30 16:13:13 +01:00
Louis Scalbert
5c0aab103d bgpd: fix attr comparaison bgp_adj_in_set
In bgp_adj_in_set(), attr has not yet been interned. adj->attr is always
different from attr. adj->attr is always uninterned and interned even if
attr and adj->attr are identical.

Fix the comparison.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-01-30 15:24:32 +01:00
Donatas Abraitis
9aed5777b7 tests: Check if attributes are reapplied for aggregate routes with route-maps
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-01-30 15:54:04 +02:00
Donatas Abraitis
ee1986f1b5 bgpd: Reinstall aggregated routes if using route-maps and it was changed
Without this change when we change the route-map, we never reinstall the route
if the route-map has changed.

We checked only some attributes like aspath, communities, large-communities,
extended-communities, but ignoring the rest of attributes.

With this change, let's check if the route-map has changed.

bgp_route_map_process_update() is triggered on route-map change, and we set
`changed` to true, which treats aggregated route as not the same as it was before.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-01-30 15:47:49 +02:00