Commit Graph

7516 Commits

Author SHA1 Message Date
Donald Sharp
b56758dae8 bgpd: Testing for valid pointer is done by for loop
No need to test for valid pointer as that the for loop will
do so as well.  This reduces indentation.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-03-02 21:05:46 -05:00
Donatas Abraitis
df98e88368
Merge pull request #15368 from louis-6wind/fix-6pe
bgpd: fix 6vpe nexthop
2024-02-28 11:34:43 +02:00
Farid Mihoub
3104d482e9 bmp: fix vty_out for monitor afi loc-rib
"show run" displays BMP monitor AFI in upper case.

> bmp targets bmp1
>  bmp monitor IPv4 unicast loc-rib

Display it in lower case.

> bmp targets bmp1
>  bmp monitor ipv4 unicast loc-rib

Signed-off-by: Farid Mihoub <farid.mihoub@6wind.com>
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-02-27 19:12:19 +01:00
Russ White
0f3923d821
Merge pull request #13721 from pguibert6WIND/route_target_wrong_display
bgpd: fix route-target display with as dotted format
2024-02-27 12:01:45 -05:00
Russ White
c4f9b874b7
Merge pull request #14810 from dmytroshytyi-6WIND/srv6_bgp_sid_reachability
SRv6 BGP SID reachability
2024-02-27 10:32:14 -05:00
Russ White
879ca714ed
Merge pull request #15273 from opensourcerouting/feature/paths_limit_capability
bgpd: Implement Paths-Limit capability
2024-02-27 10:24:05 -05:00
Philippe Guibert
7c1480fd2f bgpd: fix route-target display with as dotted format
The following command results in a wrong route-target
display:
> # show running-config
> [..]
> route-map rmap permit 1
>  set extcommunity rt 1.45:55
> exit
> router bgp 1.45 as-notation plain
> neighbor 192.0.2.1 remote-as 65500
> address-family ipv4 unicast
> network 192.0.2.2/32 route-map rmap
>

Observed output:

> # show bgp ipv4 192.0.2.2/32
> [..]
>     Extended Community: RT:1.0.0.45:55
>

The decoding of the passed cli string assumes this is an
IP address, whereas it is an AS number in dotted format.
Consequently, the vty output will use the ip address encoding.

Count the number of dots in the extended community format.
If a single dot number is detected, the AS format is passed,
and used by the vty output.

After fix:

>
> # show bgp ipv4 192.0.2.2/32
> [..]
>    Extended Community: RT:65581:55
>

For remind, AS 65581 and AS 1.45 are a unique AS number.

> show bgp neighbor
> BGP neighbor is 192.0.2.1, remote AS 65500, local AS 65581, external link
> [..]

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2024-02-27 14:28:22 +01:00
Francois Dumontet
100ef15262 bgpd: fix no bgp as-path access-list issue
router bgp 65001
 no bgp ebgp-requires-policy
 neighbor 192.168.1.2 remote-as external
 neighbor 192.168.1.2 timers 3 10
 address-family ipv4 unicast
  neighbor 192.168.1.2 route-map r2 in
 exit-address-family
!
ip prefix-list p1 seq 5 permit 172.16.255.31/32
!
route-map r2 permit 10
 match ip address prefix-list p1
 set as-path exclude 65003
route-map r2 permit 20
 set as-path exclude all
!

we make the following commands

bgp as-path access-list FIRST permit ^65
bgp as-path access-list SECOND permit 2
 route-map r2 permit 6
  set as-path exclude as-path-access-list SECOND

and then

no bgp as-path access-list SECOND permit 2
clear bgp *

we have the following crash in bgp

               Stack trace of thread 536083:
                #0  0x00007f87f8aacfe1 raise (libpthread.so.0 + 0x12fe1)
                #1  0x00007f87f8cf6870 core_handler (libfrr.so.0 +
		    0xf6870)
                #2  0x00007f87f8aad140 __restore_rt (libpthread.so.0 +
		    0x13140)
                #3  0x00007f87f89a5122 __GI___regexec (libc.so.6 +
		    0xdf122)
                #4  0x000055d7f198b4a7 aspath_filter_exclude_acl (bgpd +
		    0x2054a7)
                #5  0x000055d7f1902187 route_set_aspath_exclude (bgpd +
		    0x17c187)
                #6  0x00007f87f8ce54b0 route_map_apply_ext (libfrr.so.0
		    + 0xe54b0)
                #7  0x000055d7f18da925 bgp_input_modifier (bgpd +
		    0x154925)
                #8  0x000055d7f18e0647 bgp_update (bgpd + 0x15a647)
                #9  0x000055d7f18e4772 bgp_nlri_parse_ip (bgpd +
		    0x15e772)
                #10 0x000055d7f18c38ae bgp_nlri_parse (bgpd + 0x13d8ae)
                #11 0x000055d7f18c6b7a bgp_update_receive (bgpd +
		    0x140b7a)
                #12 0x000055d7f18c8ff3 bgp_process_packet (bgpd +
		    0x142ff3)
                #13 0x00007f87f8d0dce0 thread_call (libfrr.so.0 +
		    0x10dce0)
                #14 0x00007f87f8cacb28 frr_run (libfrr.so.0 + 0xacb28)
                #15 0x000055d7f18435da main (bgpd + 0xbd5da)
                #16 0x00007f87f88e9d0a __libc_start_main (libc.so.6 +
		    0x23d0a)
                #17 0x000055d7f18415fa _start (bgpd + 0xbb5fa)

analysis

crash is due to the fact that there were always a pointer from
as-path exclude to deleted as-path access list.

fix
we add a backpointer mechanism to manage the dependency beetween
as-path access-list  and aspath exclude.

Signed-off-by: Francois Dumontet <francois.dumontet@6wind.com>
2024-02-26 14:58:54 +01:00
Louis Scalbert
0325116a27 bgpd: fix 6vpe nexthop
6vPE enables the announcement of IPv6 VPN prefixes through an IPv4 BGP
session. In this scenario, the next hop addresses for these prefixes are
represented in an IPv4-mapped IPv6 format, noted as ::ffff:[IPv4]. This
format indicates to the peer that it should route these IPv6 addresses
using information from the IPv4 nexthop. For example:

> Path Attribute - MP_REACH_NLRI
> [...]
>     Address family identifier (AFI): IPv6 (2)
>     Subsequent address family identifier (SAFI): Labeled VPN Unicast (128)
>     Next hop:  RD=0:0 IPv6=::ffff:192.0.2.5 RD=0:0 Link-local=fe80::501d:42ff:feef:b021
>     Number of Subnetwork points of attachment (SNPA): 0

This rule is set out in RFC4798:

> The IPv4 address of the egress 6PE router MUST be encoded as an
> IPv4-mapped IPv6 address in the BGP Next Hop field.

However, in some situations, bgpd sends a standard nexthop IPv6 address
instead of an IPv4-mapped IPv6 address because the outgoing interface for
the BGP session has a valid IPv6 address. This is problematic because
the peer router may not be able to route the nexthop IPv6 address (ie.
if the outgoing interface has not IPv6).

Fix the issue by always sending a IPv4-mapped IPv6 address as nexthop
when the BGP session is on IPv4 and address family IPv6.

Link: https://datatracker.ietf.org/doc/html/rfc4798#section-2
Fixes: 92d6f76 ("lib,zebra,bgpd: Fix for nexthop as IPv4 mapped IPv6 address")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-02-26 10:17:08 +01:00
Igor Ryzhov
83a3b0f10f bgpd, yang: fix missing mandatory/default statements on some leafs
The code expects these leafs to always exist. If they are not set, the
daemon would crash. CLI always sets them, but we should properly mark
them as mandatory/default to prevent them from being missed when using
the API.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-26 01:03:27 +02:00
Igor Ryzhov
0b905f7404 lib: fix nb callbacks for containers inside choice case
Containers inside a choice's case must be treated as presence containers
as they can be explicitly created and deleted. They must have `create`
and `destroy` callbacks, otherwise the internal data they represent may
never be deleted.

The issue can be reproduced with the following steps:
- create an access-list with destination-network params
  ```
  # access-list test seq 1 permit ip any 10.10.10.0 0.0.0.255
  ```
- delete the `destination-network` container
  ```
  # mgmt delete-config /frr-filter:lib/access-list[name='test'][type='ipv4']/entry[sequence='1']/destination-network
  # mgmt commit apply
  MGMTD: No changes found to be committed!
  ```

As the `destination-network` container is non-presence, and all its
leafs are mandatory, mgmtd doesn't see any changes to be commited and
simply updates its YANG data tree without passing any updates to backend
daemons.

This commit fixes the issue by requiring `create` and `destroy`
callbacks for containers inside choice's cases.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-02-24 01:39:18 +02:00
Louis Scalbert
58c1206112 bgpd: move mp_nexthop_prefer_global boolean attribute to nh_flags
Move mp_nexthop_prefer_global boolean attribute to nh_flags. It does
not currently save memory because of the packing.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-02-22 18:20:34 +01:00
Russ White
ab40199f00
Merge pull request #15351 from louis-6wind/fix-leak-vrf-interface
bgpd: update route leak after vrf interface changes
2024-02-20 10:14:20 -05:00
Donald Sharp
863e6ddf11 bgpd: Fix value stored to group never being read
SA Reports:

bgpd/bgp_rpki.c:1085:24: warning: Value stored to 'group' during its initialization is never read [deadcode.DeadStores]
        struct rtr_mgr_group *group = get_connected_group(rpki_vrf);
                              ^~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-02-15 23:28:18 -05:00
Louis Scalbert
94d12dc490 bgpd: update route leak when vrf appears
If the VRF is not yet created and a BGP instance is created for the
VRF, dependent leaked routes are inactive, which is normal. However,
when the VRF interface appears, they remains inactive.

Update route leak when a VRF interface appears. Note that routes to a
deleted VRF are already removed by zebra.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-02-14 16:39:51 +01:00
Louis Scalbert
b45c5cd959 bgpd: update route leak when vrf state changes
Locally leaked routes remain active after the nexthop VRF interface goes
down.

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

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-02-14 16:39:51 +01:00
Donatas Abraitis
72f0e06824 bgpd: Implement Paths-Limit capability
https://datatracker.ietf.org/doc/html/draft-abraitis-idr-addpath-paths-limit

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-02-13 17:07:15 +02:00
Donatas Abraitis
13c5d0e708 bgpd: Do not send dynamic capability if both peers do not have it exchanged
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-02-13 17:06:04 +02:00
Russ White
17a0a625f0
Merge pull request #15284 from opensourcerouting/feature/bgpd_announce_rpki_state_knob
bgpd: Add neighbor X send-community extended rpki command
2024-02-13 09:35:10 -05:00
Donatas Abraitis
26faf341ef
Merge pull request #15352 from louis-6wind/fix-leak-recursive
bgpd: fix route recursion on leaked routes
2024-02-12 21:42:03 +02:00
Donald Sharp
9800590ccc
Merge pull request #15346 from opensourcerouting/fix/memory_optimizations
Some more memory optimizations
2024-02-11 21:33:44 -05:00
Louis Scalbert
59a544c39b 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>
2024-02-09 18:25:01 +01:00
Alexander Skorichenko
f4da4398f4 bgpd: fix minttl copying during peer reset
Include gtsm_hops (minttl) field when copying peer structure,
so that a new connection could set a proper value.

Signed-off-by: Alexander Skorichenko <askorichenko@netgate.com>
2024-02-09 16:58:52 +01:00
Donatas Abraitis
4dccc31884 bgpd: Optimize memory for peer_connection struct
```
struct peer_connection {
	struct peer *              peer;                 /*     0     8 */
	enum bgp_fsm_status        status;               /*     8     4 */
	enum bgp_fsm_status        ostatus;              /*    12     4 */
	int                        fd;                   /*    16     4 */
	uint32_t                   thread_flags;         /*    20     4 */
	pthread_mutex_t            io_mtx;               /*    24    40 */
	/* --- cacheline 1 boundary (64 bytes) --- */
	struct stream_fifo *       ibuf;                 /*    64     8 */
	struct stream_fifo *       obuf;                 /*    72     8 */
	struct ringbuf *           ibuf_work;            /*    80     8 */
	struct event *             t_read;               /*    88     8 */
	struct event *             t_write;              /*    96     8 */
	struct event *             t_connect;            /*   104     8 */
	struct event *             t_delayopen;          /*   112     8 */
	struct event *             t_start;              /*   120     8 */
	/* --- cacheline 2 boundary (128 bytes) --- */
	struct event *             t_holdtime;           /*   128     8 */
	struct event *             t_connect_check_r;    /*   136     8 */
	struct event *             t_connect_check_w;    /*   144     8 */
	struct event *             t_gr_restart;         /*   152     8 */
	struct event *             t_gr_stale;           /*   160     8 */
	struct event *             t_generate_updgrp_packets; /*   168     8 */
	struct event *             t_pmax_restart;       /*   176     8 */
	struct event *             t_routeadv;           /*   184     8 */
	/* --- cacheline 3 boundary (192 bytes) --- */
	struct event *             t_process_packet;     /*   192     8 */
	struct event *             t_process_packet_error; /*   200     8 */
	union sockunion            su;                   /*   208   128 */

	/* size: 336, cachelines: 6, members: 25 */
	/* last cacheline: 16 bytes */
};   /* saved 8 bytes! */
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-02-09 17:29:35 +02:00
Donatas Abraitis
c6e5b8030f bgpd: Optimize memory for bgp_nexthop_cache struct
```
struct bgp_nexthop_cache {
	afi_t                      afi;                  /*     0     4 */
	ifindex_t                  ifindex_ipv6_ll;      /*     4     4 */
	struct bgp_nexthop_cache_item entry;             /*     8    32 */
	uint32_t                   metric;               /*    40     4 */
	uint8_t                    nexthop_num;          /*    44     1 */
	_Bool                      is_evpn_gwip_nexthop; /*    45     1 */
	uint16_t                   change_flags;         /*    46     2 */
	struct nexthop *           nexthop;              /*    48     8 */
	time_t                     last_update;          /*    56     8 */
	/* --- cacheline 1 boundary (64 bytes) --- */
	uint16_t                   flags;                /*    64     2 */

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

	uint32_t                   srte_color;           /*    68     4 */
	struct bgp_nexthop_cache_head * tree;            /*    72     8 */
	struct prefix              prefix __attribute__((__aligned__(8))); /*    80    56 */
	/* --- cacheline 2 boundary (128 bytes) was 8 bytes ago --- */
	void *                     nht_info;             /*   136     8 */
	struct path_list           paths;                /*   144     8 */
	unsigned int               path_count;           /*   152     4 */

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

	struct bgp *               bgp;                  /*   160     8 */

	/* size: 168, cachelines: 3, members: 17 */
	/* sum members: 162, holes: 2, sum holes: 6 */
	/* forced alignments: 1 */
	/* last cacheline: 40 bytes */
} __attribute__((__aligned__(8)));   /* saved 16 bytes! */
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-02-09 17:25:05 +02:00
Donatas Abraitis
d13abf1180 bgpd: Optimize memory for ecommunity struct
```
struct ecommunity {
	long unsigned int          refcnt;               /*     0     8 */
	uint8_t                    unit_size;            /*     8     1 */
	_Bool                      disable_ieee_floating; /*     9     1 */

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

	uint32_t                   size;                 /*    12     4 */
	uint8_t *                  val;                  /*    16     8 */
	char *                     str;                  /*    24     8 */

	/* size: 32, cachelines: 1, members: 6 */
	/* sum members: 30, holes: 1, sum holes: 2 */
	/* last cacheline: 32 bytes */
};   /* saved 8 bytes! */
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-02-09 17:21:23 +02:00
Donatas Abraitis
1fce318efc bgpd: Optimize memory for bgp_adj_out struct
```
struct bgp_adj_out {
	struct rb_entry            adj_entry;            /*     0    32 */

	/* XXX last struct has 4 bytes of padding */

	struct update_subgroup *   subgroup;             /*    32     8 */
	struct {
		struct bgp_adj_out * tqe_next;           /*    40     8 */
		struct bgp_adj_out * * tqe_prev;         /*    48     8 */
	} subgrp_adj_train;                              /*    40    16 */
	struct bgp_dest *          dest;                 /*    56     8 */
	/* --- cacheline 1 boundary (64 bytes) --- */
	uint32_t                   addpath_tx_id;        /*    64     4 */
	uint32_t                   attr_hash;            /*    68     4 */
	struct attr *              attr;                 /*    72     8 */
	struct bgp_advertise *     adv;                  /*    80     8 */

	/* size: 88, cachelines: 2, members: 8 */
	/* paddings: 1, sum paddings: 4 */
	/* last cacheline: 24 bytes */
};   /* saved 8 bytes! */
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-02-09 17:18:22 +02:00
Donald Sharp
afa07a7f3a
Merge pull request #15255 from louis-6wind/bgp-leak-interface
bgpd: fix interface of routes leaked from another VRF
2024-02-08 11:18:58 -05:00
Philippe Guibert
ec6e09c271 bgpd: fix flushing ipv6 flowspec entries when peering stops
When a BGP flowspec peering stops, the BGP RIB entries for IPv6
flowspec entries are removed, but not the ZEBRA RIB IPv6 entries.

Actually, when calling bgp_zebra_withdraw() function call, only
the AFI_IP parameter is passed to the bgp_pbr_update_entry() function
in charge of the Flowspec add/delete in zebra. Fix this by passing
the AFI parameter to the bgp_zebra_withdraw() function.

Note that using topotest does not show up the problem as the
flowspec driver code is not present and was refused. Without that,
routes are not installed, and can not be uninstalled.

Fixes: 529efa2346 ("bgpd: allow flowspec entries to be announced to zebra")
Link: https://github.com/FRRouting/frr/pull/2025

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2024-02-07 23:01:25 +01:00
Donatas Abraitis
4d7975ee59 bgpd: Add neighbor X send-community extended rpki command
By default, iBGP and eBGP-OAD peers exchange RPKI extended community by default.

Add a command to disable sending RPKI extended community if needed.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-02-07 22:35:21 +02:00
Donald Sharp
7fe05d6185
Merge pull request #15314 from opensourcerouting/fix/remove_bgp_evpn_attr_get_df_pref
bgpd: A couple random EVPN findings
2024-02-07 07:44:07 -05:00
Donald Sharp
1bc2fa3584
Merge pull request #15305 from louis-6wind/label-dead-code
bgpd: remove dead label code in bgp_update
2024-02-06 14:50:56 -05:00
Donald Sharp
a791deff91
Merge pull request #15311 from louis-6wind/fix-show-srv6-sid
bgpd: fix displaying srv6 sid
2024-02-06 11:40:14 -05:00
Louis Scalbert
0603626184 bgpd: remove dead label code in bgp_update
No need to init new_attr. It is not used until it is overridden.

> new_attr = *attr;

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-02-06 13:30:14 +01:00
Donatas Abraitis
bd7bad9121 bgpd: Drop unused function bgp_evpn_attr_get_df_pref()
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-02-06 14:02:51 +02:00
Louis Scalbert
e2138a634d bgpd: fix displaying srv6 sid
98efa5bc6b ("bgpd: bgp_path_info_extra memory optimization") has removed
SID info from the extra structure.

Do not test for extra presence.

Fixes: 98efa5bc6b ("bgpd: bgp_path_info_extra memory optimization")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-02-06 11:21:21 +01:00
Donatas Abraitis
c8acc6709c bgpd: Send dynamic capability when on/off FQDN capability
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-02-05 12:23:53 +02:00
Donatas Abraitis
04e2401d20 bgpd: Do not reset the session if turning on/off FQDN capability
Allow BGP dynamic capabilities handle this gracefully.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-02-05 10:43:50 +02:00
Donatas Abraitis
3e99dcc626 bgpd: Send FQDN capability via dynamic capability if enabled
Since we have a knob to disable sending FQDN capability, it MUST be checked
before sending it using dynamic capabilities.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-02-05 08:22:46 +02:00
Donald Sharp
5bc104120b bgpd: Prevent rpki from hooking multiple times into rcu code
As far as I can tell, the rpki code creates a pthread that
is used to handle the i/o associated with talking to the
remote rpki server.  The problem that we are having is that
the rpki code in FRR wants to behave like FRR code and use
the zlog_XXX functions.  These functions all depend on
the RCU code.  Which is a bit picky( and rightly so!!! )
about being started up properly and shut down properly.

This commit is fixing the problem of shutdown.  From
playing with the rpki code, I was able to experimentally
determine that the rpki_create_socket callback function
can be called multiple times per pthread.  Additionally
I was able to clearly see multiple *different* pthreads
actually be created.  This leaves the possiblity
that each time it is called it might be hooking into the
RCU code.  Which makes the rcu code unhappy on shutdown.

Let's address the issue by checking to see if this pthread
has already hooked into the RCU code or not.  If so
then don't do this again.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-02-03 23:10:19 -05:00
Donald Sharp
3a6c3129dd
Merge pull request #15265 from louis-6wind/fix-rpki-logs
bgpd,lib: fix logging from rpki_create_socket()
2024-02-03 08:40:27 -05:00
Donatas Abraitis
8629700bc8
Merge pull request #15192 from fdumontet6WIND/capa_nego
bgpd: add [no]neighbor capability fqdn
2024-02-03 12:19:53 +02:00
Francois Dumontet
e146ea53ef bgpd: add [no]neighbor capability fqdn command
cisco routers are not dealing fairly whith unsupported capabilities.
When a cisco router receive an unsupported capabilities it reset the
negociation without notifying the unmatching capability as described in
RFC2842.
Cisco suggest the use of
neighbor x.x.x.x capability fqdn
to avoid the use of fqdn in open message.

this new command is to remove the use of fqdn capability in the
open message with the peer "x.x.x.x".

Link: https://www.cisco.com/c/en/us/support/docs/ip/border-gateway-protocol-bgp/116189-problemsolution-technology-00.pdf

Signed-off-by: Francois Dumontet <francois.dumontet@6wind.com>
2024-02-02 11:31:47 +01:00
Louis Scalbert
fdaf08bb46 bgpd: fix logging from rpki_create_socket()
Fix the following crash when logging from rpki_create_socket():

> #0  raise (sig=<optimized out>) at ../sysdeps/unix/sysv/linux/raise.c:50
> #1  0x00007f6e21723798 in core_handler (signo=6, siginfo=0x7f6e1e502ef0, context=0x7f6e1e502dc0) at lib/sigevent.c:248
> #2  <signal handler called>
> #3  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
> #4  0x00007f6e2144e537 in __GI_abort () at abort.c:79
> #5  0x00007f6e2176348e in _zlog_assert_failed (xref=0x7f6e2180c920 <_xref.16>, extra=0x0) at lib/zlog.c:670
> #6  0x00007f6e216b1eda in rcu_read_lock () at lib/frrcu.c:294
> #7  0x00007f6e21762da8 in vzlog_notls (xref=0x0, prio=2, fmt=0x7f6e217afe50 "%s:%d: %s(): assertion (%s) failed", ap=0x7f6e1e504248) at lib/zlog.c:425
> #8  0x00007f6e217632fb in vzlogx (xref=0x0, prio=2, fmt=0x7f6e217afe50 "%s:%d: %s(): assertion (%s) failed", ap=0x7f6e1e504248) at lib/zlog.c:627
> #9  0x00007f6e217621f5 in zlog (prio=2, fmt=0x7f6e217afe50 "%s:%d: %s(): assertion (%s) failed") at lib/zlog.h:73
> #10 0x00007f6e21763596 in _zlog_assert_failed (xref=0x7f6e2180c920 <_xref.16>, extra=0x0) at lib/zlog.c:687
> #11 0x00007f6e216b1eda in rcu_read_lock () at lib/frrcu.c:294
> #12 0x00007f6e21762da8 in vzlog_notls (xref=0x7f6e21a50040 <_xref.68>, prio=4, fmt=0x7f6e21a4999f "getaddrinfo: debug", ap=0x7f6e1e504878) at lib/zlog.c:425
> #13 0x00007f6e217632fb in vzlogx (xref=0x7f6e21a50040 <_xref.68>, prio=4, fmt=0x7f6e21a4999f "getaddrinfo: debug", ap=0x7f6e1e504878) at lib/zlog.c:627
> #14 0x00007f6e21a3f774 in zlog_ref (xref=0x7f6e21a50040 <_xref.68>, fmt=0x7f6e21a4999f "getaddrinfo: debug") at ./lib/zlog.h:84
> #15 0x00007f6e21a451b2 in rpki_create_socket (_cache=0x55729149cc30) at bgpd/bgp_rpki.c:1337
> #16 0x00007f6e2120e7b7 in tr_tcp_open (tr_socket=0x5572914d1520) at rtrlib/rtrlib/transport/tcp/tcp_transport.c:111
> #17 0x00007f6e2120e212 in tr_open (socket=0x5572914b5e00) at rtrlib/rtrlib/transport/transport.c:16
> #18 0x00007f6e2120faa2 in rtr_fsm_start (rtr_socket=0x557290e17180) at rtrlib/rtrlib/rtr/rtr.c:130
> #19 0x00007f6e218b7ea7 in start_thread (arg=<optimized out>) at pthread_create.c:477
> #20 0x00007f6e21527a2f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

rpki_create_socket() is a hook function called from the rtrlib library.
The issue arises because rtrlib initiates its own separate pthread in which
it runs the hook, which does not establish an FRR RCU context. Consequently,
this leads to failures in the logging mechanism that relies on RCU.

Initialize a new FRR pthread context from the rtrlib pthread with a
valid RCU context to allow logging from the rpki_create_socket() and
dependent functions.

Link: https://github.com/FRRouting/frr/issues/15260
Fixes: a951752d4a ("bgpd: create cache server socket in vrf")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2024-02-02 10:35:10 +01:00
Donald Sharp
a4f222292b
Merge pull request #15275 from opensourcerouting/fix/one_more_memory_optimization_attr_struct
bgpd: One more attr struct memory optimization
2024-02-01 20:46:09 -05:00
Donald Sharp
9d8fd14b56
Merge pull request #15276 from mjstapp/port_registry
*: create a single registry of daemons' default port values
2024-02-01 16:07:11 -05:00
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
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