Commit Graph

8130 Commits

Author SHA1 Message Date
Donald Sharp
1baeb81632 bgpd: bgp_getsockname should use connection
Let's use the connection associated with the peer
instead.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-11-26 11:59:33 -05:00
Donald Sharp
72f716ef28 bgpd: Modify bgp_connect_in_progress_update_connection to use connection
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-11-26 11:59:27 -05:00
Donald Sharp
2771431938 bgpd: Modify bgp_udpatesockname to pass in a connection
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-11-26 11:59:19 -05:00
Donald Sharp
eacf923b00 bgpd: Fix pattern of usage in bgp_notify_config_change
if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->connection->status))
        peer_notify_config_change(peer->connection);
else
        bgp_session_reset_safe(peer, &nnode);

Let's add a bool return to peer_notify_config_change of whether or
not it should call the peer session reset.  This simplifies
the code a bunch.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-11-26 11:59:18 -05:00
Donald Sharp
ba0edb9545 bgpd: Add peer_notify_config_change() function
We have about a bajillion tests of if we can
notify the peer and then we send a config change
notification.  Let's just make a function that
does this.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-11-26 11:58:23 -05:00
Donald Sharp
2e5b4e32c4 bgpd: peer_notify_unconfig should be connection based
Convert this function to being connection based.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-11-26 11:49:34 -05:00
Russ White
842da0d00e
Merge pull request #17501 from opensourcerouting/fix/gr_peer-groups
bgpd: Fix Graceful-Restart for peer-groups
2024-11-26 10:35:19 -05:00
Philippe Guibert
c5d7815ccc bgpd: fix version attribute is an int, not a string
The json display of the version attribute is originally an
integer. It has changed, most probably mistakenly.

> {
>   "vrfId": 7,
>   "vrfName": "vrf1",
>   "tableVersion": 3,
>   "routerId": "192.0.2.1",
>   "defaultLocPrf": 100,
>   "localAS": 65500,
>   "routes": {
>     "172.31.0.1/32": {
>       "prefix": "172.31.0.1/32",
>       "version": "1",		<--- int or string ??

Let us fix it, by using the integer display instead.

Fixes: f9f2d188e3 ("bgpd: fix 'json detail' output structure")

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2024-11-26 11:01:57 +01:00
Donatas Abraitis
ee5893ff59 bgpd: Use gracefulRestart JSON field
Deprecate gracefulRestartCapability which is inconsistent with an existing
format if advertised and received are printed.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-25 10:44:52 +02:00
Donatas Abraitis
0a85b1ba04 bgpd: Fix graceful-restart for peer-groups
Slipped somehow that peer-groups with GR is just completely broken, but it was
working before.

Strikes again, that we MUST have more and more topotests.

Fixes: 15403f521a ("bgpd: Streamline GR config, act on change immediately")

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-24 21:57:19 +02:00
Donald Sharp
d745f4eae5
Merge pull request #17459 from opensourcerouting/fix/disable_rpki_community_by_default
bgpd: Disable sending ROV extended community by default
2024-11-23 09:13:06 -05:00
Donatas Abraitis
7fb4c03f5b bgpd: Do not reset peers on suppress-fib toggling
If the desired state is the same - do nothing instead of resetting once again.

Fixes: bdb5ae8bce ("bgpd: Make suppress-fib-pending clear peering")

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-22 10:30:37 +02:00
Donald Sharp
c1c6298dd3 bgpd: Allow bfd to work if peer known but interface address not yet
If bgp is coming up and bgp has not received the interface address yet
but bgp has knowledge about a bfd peering, allow it to set the peering
data appropriately.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-11-20 16:13:42 -05:00
Donald Sharp
2a94de8af2 bgpd: bgp_connect should return an enum connect_result
This function when it is run by bgp_start is expected
to return a `enum connect_result`.  But instead
the function returns a variety of values that are
not really being checked for.  Consolidate to a correct
choice.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-11-20 16:11:22 -05:00
Donatas Abraitis
8cc6359fdc bgpd: Disable sending ROV extended community by default
https://datatracker.ietf.org/doc/html/rfc8097 defines ROV extended community,
but https://datatracker.ietf.org/doc/draft-ietf-sidrops-avoid-rpki-state-in-bgp
is against sending it by default even for iBGP peers.

Let's do this practice and reverse it.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-19 16:25:12 +02:00
Donald Sharp
9b50371965
Merge pull request #17456 from opensourcerouting/fix/lua_unit_test
Lua casting
2024-11-19 09:24:40 -05:00
Donatas Abraitis
004d770ec4 bgpd: Optimize the way parsing communities if no community alias exists
If at least one community alias is configured, then let's do the work,
otherwise we don't need to spend time on splitting stuff and creating
a new string.

This should improve the performance.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-18 23:29:53 +02:00
Donatas Abraitis
3c609266f5 bgpd: Use int, not long long for route-map action in Lua script
This is an issue for big-endian architectures, that causes incorrect castings.

lua_tointegerp() uses int*, not long long*.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-18 17:25:09 +02:00
Donatas Abraitis
2dc7db9251 bgpd: Optimize the outbound path if RFC8212 is applied
If we have (default enabled) enabled `bgp ebgp-require-policy`, then first check
it before applying the route-maps.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-17 14:41:05 +02:00
Jafar Al-Gharaibeh
66b0a33e0c
Merge pull request #17427 from opensourcerouting/fix/more_details_for_ebgp_no_policy
bgpd: Add more details to ebgp requires policy warning
2024-11-16 19:32:54 -06:00
Jafar Al-Gharaibeh
7c46eb68d4
Merge pull request #17435 from opensourcerouting/fix/bgp_allow_0.0.0.0_if_multiple_nlris_exist
bgpd: Validate both nexthop information (NEXTHOP and NLRI)
2024-11-16 19:32:04 -06:00
Donatas Abraitis
c050972fec
Merge pull request #17432 from raja-rajasekar/rajasekarr/evpn_pop_items_bp
bgpd : backpressure - Fix to pop items off zebra_announce FIFO for few EVPN triggers
2024-11-16 12:51:20 +02:00
Donatas Abraitis
a0d2734e87 bgpd: Validate both nexthop information (NEXTHOP and NLRI)
If we receive an IPv6 prefix e.g.: 2001:db8:100::/64 with nextop: 0.0.0.0, and
mp_nexthop: fc00::2, we should not treat this with an invalid nexthop because
of 0.0.0.0. We MUST check for MP_REACH attribute also and decide later if we
have at least one a valid nexthop.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-15 16:40:56 +02:00
Rajasekar Raja
898852f269 bgpd : backpressure - Fix to pop items off zebra_announce FIFO for few EVPN triggers
In cases such as 'no advertise-all-vni' and L2 VNI DELETE, we need to
pop all the VPN routes present in the bgp_zebra_announce FIFO yet to
be processed regardless of VNI is configured or not.

NOTE: NO need to pop the VPN routes in two cases
 1) In free_vni_entry
   - Called by bgp_free()->bgp_evpn_cleanup().
   - Since bgp_delete is called before bgp_free and we pop all the dest
     pertaining to bgp under delete.
 2) evpn_delete_vni() when user configures "no vni" since the withdraw
    of all routes happen in normal cycle.

Fixes: a07df6f754
("bgpd : backpressure - Handle BGP-Zebra(EPVN) Install evt Creation")

Ticket :#4163611

Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>
2024-11-15 00:32:42 -08:00
Donatas Abraitis
f765bc4144 bgpd: Use tmp_as when parsing color extended community
as is not initialized and it's assigned only later.

CID: 1601739

Fixes: 937cf4d ("bgpd:support of color extended community color-only types")

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-15 08:16:10 +02:00
Donatas Abraitis
2b3d41493d Revert "bgpd: Fix color extended community parsing"
This reverts commit 8e771bda84.
2024-11-15 08:14:32 +02:00
Donatas Abraitis
53c858e70e bgpd: Add more details to ebgp requires policy warning
This will tell explicitly which peer does not have a filter applied.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-15 08:09:08 +02:00
Donald Sharp
345ab24504
Merge pull request #17429 from opensourcerouting/fix/unsupported_commands_bgpd
bgpd: Drop unsupported commands
2024-11-14 19:47:44 -05:00
Donatas Abraitis
afb6f66f2b bgpd: Depracate no_synchronization_cmd, no_auto_summary_cmd commands
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-14 16:15:23 +02:00
Mark Stapp
e2d9e19282
Merge pull request #17422 from opensourcerouting/fix/coverity_bgp_color
bgpd: Fix color extended community parsing
2024-11-14 08:27:47 -05:00
Donatas Abraitis
5cf9f6a79f bgpd: Reduce the nesting level for show_adj_route()
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-13 13:36:01 +02:00
Donatas Abraitis
98ca49e0ee bgpd: Show neighbor advertised paths including addpath
Without the patch only the best path is displayed.

With the patch, display all paths including addpaths, but only for non-JSON
output to avoid breaking existing output.

E.g.:

```
munet> r2 shi vtysh -c 'sh ip bgp nei 192.168.2.3 advertised-routes'
     Network          Next Hop            Metric LocPrf Weight Path
 *>  172.16.16.254/32 192.168.2.3              0             0 65003 ?
 *   172.16.16.254/32 192.168.2.4              0             0 65004 ?
 *>  192.168.2.0/24   192.168.2.3              0             0 65003 ?
 *   192.168.2.0/24   192.168.2.4              0             0 65004 ?
```

Before it was:

```
munet> r2 shi vtysh -c 'sh ip bgp nei 192.168.2.3 advertised-routes'
     Network          Next Hop            Metric LocPrf Weight Path
 *>  172.16.16.254/32 192.168.2.3              0             0 65003 ?
 *>  192.168.2.0/24   192.168.2.3              0             0 65003 ?
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-13 13:32:28 +02:00
Donatas Abraitis
8e771bda84 bgpd: Fix color extended community parsing
CID: 1601739

Fixes: 937cf4db17 ("bgpd:support of color extended community color-only types")

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-13 10:03:17 +02:00
Russ White
fe56a659b6
Merge pull request #17410 from opensourcerouting/fix/bgpd_ebgp_multihop_set_unset
BGP BFD session things
2024-11-12 11:02:22 -05:00
Russ White
9ce07a1313
Merge pull request #17374 from opensourcerouting/fix/rfc_9687
Add two RFCs for BGP to the list
2024-11-12 09:59:06 -05:00
Russ White
d18337f4bd
Merge pull request #17344 from opensourcerouting/fix/reset_bgp_session_only_if_bfd_is_properly_working
bgpd: Reset BGP session only if it was a real BFD DOWN event
2024-11-12 09:53:40 -05:00
Donatas Abraitis
fcabeeaf79 bgpd: Update source address for BFD session
If BFD is down, we should try to detect the source automatically from the given
interface.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-12 13:09:09 +02:00
Donatas Abraitis
29eafd32c5 bgpd: Do not try to uninstall BFD session if the peer is not established
Having something like:

```
 neighbor 192.168.1.222 ebgp-multihop 32
 neighbor 192.168.1.222 update-source 192.168.1.5
 neighbor 192.168.1.222 bfd
```

Won't work and the result is (empty):

```
$ show bfd peers
BFD Peers:
```

bgp_stop() is called in BGP FSM multiple times (even at startup) that
causes intermediate session interruption when update-source/ebgp-multihop
is triggered.

With this fix, the ordering does not matter and the BFD session's parameters
are updated correctly.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-11 16:49:22 +02:00
Donatas Abraitis
6e92e25518 bgpd: Do not use an existing peer pointer for ALL_LIST_ELEMENTS()
Use a separate `member` in this case.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-11 16:49:08 +02:00
Krishnasamy R
95c08e082c bgpd: fix resolvedPrefix in show nexthop json output
While populating  the nexthop info for "show bgp nexthop json", resolvedPrefix
is added in parent json object instead of json_nexthop object.
This results in displaying wrong resolvedPrefix for nexthops.
Fixing the same by adding resolvedPrefix to json_nexthop object, so that
the proper resolvedPrefix would be displayed for the respective nexthop

Signed-off-by: Krishnasamy R <krishnasamyr@nvidia.com>
2024-11-11 01:59:31 -08:00
Donatas Abraitis
1dcb4bb2d3
Merge pull request #17362 from raja-rajasekar/rajasekarr/src_proto_for_redist_cmd
bgpd: Fix for match source-protocol in route-map for redistribute cmd
2024-11-09 22:01:44 +02:00
Rajasekar Raja
68358c0f92 bgpd: Fix for match source-protocol in route-map for redistribute cmd
A redistribute cmd can have a route-map attached to it and adding the
match source-protocol to that route-map means BGP to filter which
protocol routes to accept among the bunch of routes zebra is sending.

Fixing this since this wasnt implemented earlier.

Ticket :#4119692

Signed-off-by: Donald Sharp <sharpd@nvidia.com>

Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com>
2024-11-09 08:36:42 -08:00
Donatas Abraitis
3a47d1f7cb
Merge pull request #17384 from donaldsharp/bgp_withdraw_and_unlikely
Bgp withdraw and unlikely
2024-11-08 09:20:19 +02:00
Donatas Abraitis
a85dce2c66
Merge pull request #17341 from zice312963205/zly_tcpmss
bgpd:support tcp-mss for neighbor group
2024-11-08 09:11:41 +02:00
Donatas Abraitis
af9a2cb875
Merge pull request #17231 from guoguojia2021/guozhongfeng_alibaba
bgpd:support of color extended community color-only types
2024-11-08 08:56:21 +02:00
Donald Sharp
bd03373c37 bgpd: Add unlikely for debugs in bgp_update()
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-11-07 11:57:34 -05:00
Donald Sharp
fc818fe6ad bgpd: Mark debugs as unlikely in bgp_withdraw
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-11-07 11:57:34 -05:00
Donald Sharp
ea4823964c bgpd: In bgp_withdraw attempt to avoid a if statement on every pass
We have this:

if ( (safi == SAFI_UNICAST) && ...)
    do stuff
if ( (safi == SAFI_MPLS_VPN) && ... )
    do stuff

this leads to having to test safi multiple times if safi is
SAFI_UNICAST.  Let's make it a else if as that we know that
the safi is going to not change.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-11-07 11:57:34 -05:00
Donald Sharp
16bb315957 bgpd: Pass in the prefix instead of looking it up again
In an attempt to make the code faster let's just pass
in the prefix instead of having to do a lookup a majillion
times again after we already have it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2024-11-07 11:57:34 -05:00
Donatas Abraitis
895d586a5f bgpd: Set LLGR stale routes for all the paths including addpath
Without this patch we set only the first path for the route (if multiple exist)
as LLGR stale and stop doing that for the rest of the paths, which is wrong.

Fixes: 1479ed2fb3 ("bgpd: Implement LLGR helper mode")

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2024-11-07 14:05:36 +02:00