Commit Graph

545 Commits

Author SHA1 Message Date
Russ White
a8ef436639
Merge pull request #12040 from opensourcerouting/fix/bgp_local_as_remote_as
bgpd: Allow using remote-as the same as local-as
2022-10-06 10:03:26 -04:00
Madhuri Kuruganti
e85e4a8d16 bgpd: conditional advertisement code cleanup
Signed-off-by: Madhuri Kuruganti <maduri111@gmail.com>
2022-10-06 12:43:05 +05:30
Donatas Abraitis
d6b0327c35 bgpd: Allow using remote-as the same as local-as
As an example, Arista EOS allows this behavior.

Configuration something like:

```
 neighbor PG peer-group
 neighbor PG remote-as 65001
 neighbor PG local-as 65001
 neighbor 192.168.10.124 peer-group PG
```

Or without peer-group.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-09-29 21:13:40 +03:00
Xiao Liang
a783cc05f0 bgpd: Handle route-refresh request received before EoR
See the BGP message sequence:

    R1                  R2
    |      updates      |
    |------------------>|
    |                   |
    |  refresh request  |
    x<------------------|
    |                   |
    |   updates cont.   |
    |------------------>|
    |                   |
    |    end-of-rib     |
    |------------------>|
    |                   |

When R1 and R2 establish BGP session, R1 begins to send initial updates.
If R2 sends a route-refresh request before EoR, it's silently ignored
by R1, and routes received earlier have no chance to be processed again.

RFC7313 says, "for a BGP speaker that supports the BGP Graceful Restart,
it MUST NOT send a BoRR for an <AFI, SAFI> to a neighbor before it sends
the EoR for the <AFI, SAFI> to the neighbor." But it doesn't forbid
route-refresh request to be sent before receiving EoR.

To handle this scenario, postpone response to refresh request until EoR
is sent.

Signed-off-by: Xiao Liang <shaw.leon@gmail.com>
2022-09-16 18:26:21 +08:00
Rafael Zalamena
340ed5f9e2
Merge pull request #11823 from pguibert6WIND/bgp_vpnv4_gre_ebgp
Bgp vpnv4 convey without transport label
2022-09-06 13:37:19 -03:00
Philippe Guibert
4cd690ae4d bgpd: add 'mpls bgp forwarding' to ease mpls vpn ebgp peering
RFC4364 describes peerings between multiple AS domains, to ease
the continuity of VPN services across multiple SPs. This commit
implements a sub-set of IETF option b) described in chapter 10 b.

The ASBR to ASBR approach is taken, with an EBGP peering between
the two routers. The EBGP peering must be directly connected to
the outgoing interface used. In those conditions, the next hop
is directly connected, and there is no need to have a transport
label to convey the VPN label. A new vty command is added on a
per interface basis:

This command if enabled, will permit to convey BGP VPN labels
without any transport labels (i.e. with implicit-null label).

restriction:
this command is used only for EBGP directly connected peerings.
Other use cases are not covered.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2022-09-05 22:26:33 +02:00
Donatas Abraitis
b6a3df6b48 bgpd: Drop useless comments for peer af flags
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-08-31 14:39:38 +03:00
Donatas Abraitis
da5e1a58e9 bgpd: Increase peer af_flags to uint64_t
Increasing in advance, as we already hitting the current limit.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-08-31 14:35:55 +03:00
Russ White
d72c279d08
Merge pull request #11833 from opensourcerouting/feature/bgp_neighbor_soo
bgpd: Add `neighbor soo` command
2022-08-30 11:17:53 -04:00
Donald Sharp
083ec940ab bgpd: Convert from bgp_clock() to monotime()
Let's convert to our actual library call instead
of using yet another abstraction that makes it fun
for people to switch daemons.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-08-24 08:23:40 -04:00
Donatas Abraitis
01da2d2691 bgpd: Add neighbor soo command
BGP SoO is a tag that is appended on BGP updates to allow a peer to mark
a particular peer as belonging to a particular site. In certain MPLS L3 VPN
configurations, the BGP AS-Path may not provide the granularity needed
prevent a loop in the control-plane. With this in mind, BGP SoO is designed
to fill this gap and prevent a routing loop that may occur.

If we configure for example, `neighbor soo 65000:1` at PEs, routes won't be
announced between CPEs if soo matches. This is especially needed when using
as-override or allowas-in.

Also, this is the automated way of the same behavior as configuring route-maps
for each peer like:

```
bgp extcommunity-list cpe permit soo 65000:1
!
route-map cpe permit 10
 set extcommunity soo 65000:1
...
route-map cpe deny 10
 match extcommunity cpe
route-map cpe permit 20
...
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-08-20 21:22:45 +03:00
Donatas Abraitis
0b1fb52c2a bgpd: Convert some int functions to void
The output is not checked, we can have void instead.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-08-12 13:26:38 +03:00
Donatas Abraitis
c41e93720a bgpd: Reset BGP sessions when changing the port
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-07-27 11:44:07 +03:00
Philippe Guibert
a486300b26 bgpd: implement retain route-target all behaviour
A new command is available under SAFI_MPLS_VPN:

With this command, the BGP vpnvx prefixes received are
not kept, if there are no VRF interested in importing
those vpn entries.

A soft refresh is performed if there is a change of
configuration: retain cmd, vrf import settings, or
route-map change.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2022-07-18 08:57:19 +02:00
Quentin Young
ecf2b628d9 bgpd: rename update_type enum values
These values were named WITHDRAW and UPDATE. Yeah, you guessed it, those
are already #define's elsewhere (bgp_debug.h). Hilarity ensues.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2022-07-01 15:22:04 +03:00
Donatas Abraitis
7dddd1f733 bgpd: Make sure peer-groups/unnumbered work too with BGP role
Just adding a support for peer-groups, because now it's not possible to
configure BGP role for peer-groups.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-06-28 18:32:11 +03:00
Lou Berger
613025ef10
Merge pull request #11093 from donaldsharp/allow_martians
Allow martians
2022-06-28 10:38:57 -04:00
Donatas Abraitis
83194f394b bgpd: Use uin64_t for peer->flags
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-06-27 17:22:54 +03:00
Donatas Abraitis
f646c17a43
Merge pull request #11426 from error2407/open_policy
bgpd: Add RFC9234 implementation
2022-06-27 09:57:29 +03:00
Donald Sharp
8666265e2e bgpd: Add bgp allow-martian-nexthop command
The command `debug bgp allow-martian` is not actually
a debug command it's a command that when entered allows
bgp to not reset a peering when a martian nexthop is
passed in the nlri.

Add the `bgp allow-martian-nexthop` command and allow it to be
used.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-24 07:45:46 -04:00
Eugene Bogomazov
8f2d6021f8 bgpd: Add patches for RFC9234 implementation
This commit fixes some issues that were noted by the reviewer

Signed-off-by: Eugene Bogomazov <eb@qrator.net>
2022-06-21 17:41:53 +03:00
Donatas Abraitis
0ebabd4107 bgpd: Increase peer->flags to uint64_t
We will hit the limit soon, let's increase this in advance.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-06-20 20:21:26 +03:00
Eugene Bogomazov
d864dd9eb1 bgpd: Add RFC9234 implementation
RFC9234 is a way to establish correct connection roles (Customer/
Provider, Peer or with RS) between bgp speakers. This patch:
- Add a new configuration/terminal option to set the appropriate local
role;
- Add a mechanism for checking used roles, implemented by exchanging
the corresponding capabilities in OPEN messages;
- Add strict mode to force other party to use this feature;
- Add basic support for a new transitive optional bgp attribute - OTC
(Only to Customer);
- Add logic for default setting OTC attribute and filtering routes with
this attribute by the edge speakers, if the appropriate conditions are
met;
- Add two test stands to check role negotiation and route filtering
during role usage.

Signed-off-by: Eugene Bogomazov <eb@qrator.net>
2022-06-17 13:14:46 +03:00
Donatas Abraitis
8dcad8e9fd bgpd: last_reset_cause_size can't be larger than 65k bytes
Reduce the scope, to avoid comparing uint16_t vs. size_t in a loop.

```
vty_out(vty,
	"  Message received that caused BGP to send a NOTIFICATION:\n    ");
	for (i = 1; i <= p->last_reset_cause_size;
	     i++) {
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-06-10 12:38:24 +03:00
Donatas Abraitis
aebe2e379f bgpd: Add Notification CEASE BFD Down message
Related: https://datatracker.ietf.org/doc/html/draft-ietf-idr-bfd-subcode

When BFD Down notification comes and BGP is configured to track on BFD events,
send BGP Cease/BFD Down notification to the peer.

If RFC 8538 is enabled (Notification support for Graceful-Restart), notification
should be encapsulated into Hard Reset message.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-06-02 16:06:57 +03:00
David Lamparter
bd9fb6f368 bgpd: implement SendHoldTimer
As described by
https://www.ietf.org/archive/id/draft-spaghetti-idr-bgp-sendholdtimer-04.html

Since this replicates the HoldTime check on the receiver that is already
part of the protocol, I do not believe it necessary to wait for IETF
progress on this draft.  It's just replicating an existing element of
the protocol at the other side of the session.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-05-19 12:14:40 +02:00
Pavel Shirshov
425bd64be8 bgpd: Allow bgp to control the DSCP session TOS value
Allow BGP to control the TOS DSCP value in the tcp header
via a new command at the bgp global level `bgp session-dscp <0-63>`

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Signed-off-by: Pavel Shirhov <pavelsh@microsoft.com>
2022-05-13 14:14:35 -04:00
Donald Sharp
aa53c036c0 bgpd: Change single value bitfield to a bool
The maxpaths same_clusterlen value was a uint16_t
with a single bit being used.  No other values are
being stored.  Let's remove the bitfield and simplify
to a bool.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-05-12 10:20:28 -04:00
Donatas Abraitis
1ae314be4f bgpd: Send Hard Reset Notification for BGP_NOTIFY_CEASE_ADMIN_RESET
`clear bgp neighbor` should send Hard Reset and graceful restart should be
activated. Let's make this adjustable.

https://datatracker.ietf.org/doc/html/rfc8538#section-5.1

   +-------+------------------------------------+----------------------+
   | Value |                Name                |  Suggested Behavior  |
   +-------+------------------------------------+----------------------+
   |   1   | Maximum Number of Prefixes Reached |      Hard Reset      |
   |   2   |      Administrative Shutdown       |      Hard Reset      |
   |   3   |         Peer De-configured         |      Hard Reset      |
   |   4   |        Administrative Reset        | Provide user control |
   |   5   |        Connection Rejected         |    Graceful Cease    |
   |   6   |     Other Configuration Change     |    Graceful Cease    |
   |   7   |  Connection Collision Resolution   |    Graceful Cease    |
   |   8   |          Out of Resources          |    Graceful Cease    |
   |   9   |             Hard Reset             |      Hard Reset      |
   +-------+------------------------------------+----------------------+

Enabled by default.

Co-authored-by: Biswajit Sadhu <biswajit.sadhu@gmail.com>
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-10 09:04:25 +03:00
Russ White
2cf70f4ee0
Merge pull request #11147 from opensourcerouting/feature/gr_n-bit_cli_knob
bgpd: Add CLI knob to enable graceful restart for BGP notifications
2022-05-09 19:35:14 -04:00
Donatas Abraitis
fd6b4f065a bgpd: Use uint64_t for bgp->flags
We will hit this soon because uint32_t will be not enough.

Two more flags gonna be added for rfc8538.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-06 22:12:41 +03:00
Donatas Abraitis
f2ca5c5b95 bgpd: Add CLI knob to enable graceful restart for BGP notifications
N-bit flag should be exchanged in BGP OPEN messages, not only when the
bgpd is restarted/started.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-05 12:35:03 +03:00
Donald Sharp
59ba003346
Merge pull request #11137 from opensourcerouting/if-name-len-fixes
*: standardize interface name maximum length
2022-05-04 07:44:26 -04:00
Rafael Zalamena
5bcc6b469c bgpd: fix interface name compare
We always want to compare the whole string, lets not use `strncmp` for
this case.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2022-05-02 11:33:48 -03:00
Donatas Abraitis
eea685b6d3 bgpd: Implement CEASE/Hard Reset notification
Also, add N-Bit (Notification) flag for Graceful Restart.

This is a preparation for RFC8538.

More information: https://datatracker.ietf.org/doc/html/rfc8538

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-02 09:43:40 +03:00
Donatas Abraitis
54394daa2d bgpd: Rename graceful restart constants for R-bit capabilities
Just to better understand what they mean.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-04-27 22:32:54 +03:00
Donatas Abraitis
9c2fd3fe44 bgpd: Convert vpn_policy_direction_t to enum
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-04-12 22:13:55 +03:00
Donatas Abraitis
d54f55f22d bgpd: Convert bgp_policy_type_e to enum
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-04-12 22:13:55 +03:00
Donatas Abraitis
3061acc235 bgpd: Convert bgp_peer_sort_t to enum
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-04-12 22:13:55 +03:00
Donatas Abraitis
f70c91dcef bgpd: Add %pBP printfrr() extension to print IP(hostname) for BGP peer
Replace existing bgp_peer_hostname() function.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-03-31 21:20:11 +03:00
Russ White
4037154240
Merge pull request #10838 from ton31337/feature/bgpd_callbacks_for_start_end_configurations
bgpd: Add BGP configuration start/end markers
2022-03-29 11:30:47 -04:00
Donatas Abraitis
a7d91a8c79 bgpd: Print hostname along with IP for most useful debug messages
Examples:

```
%ADJCHANGE: neighbor 192.168.0.1(exit1-debian-11) in vrf default Up
192.168.0.1(exit1-debian-11) graceful restart stalepath timer expired
192.168.0.1(exit1-debian-11) sending route-refresh (BoRR) for IPv4/unicast
192.168.0.1(exit1-debian-11) graceful restart timer started for 120 sec
192.168.0.1(exit1-debian-11) graceful restart stalepath timer started for 120 sec
192.168.0.1(exit1-debian-11) graceful restart timer stopped
%MAXPFXEXCEED: No. of IPv4 Unicast prefix received from 192.168.0.1(exit1-debian-11) 9 exceed, limit 1
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-03-22 21:59:58 +02:00
Donatas Abraitis
aa24a36a2d bgpd: Add BGP configuration start/end markers
Delay BGP configuration until we receive end-configuration hook to make sure
we don't send partial updates to peer which leads to broken Graceful-Restart.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-03-22 09:04:46 +02:00
Ryoga Saito
921c7e77b0 bgpd: update logic to allocate SRv6 locator
For the later patches, this patch changes the behavior of alloc_new sid
so that bgpd record not only SID for VRF, but also Locator of SID.

Signed-off-by: Ryoga Saito <ryoga.saito@linecorp.com>
2022-02-25 15:34:24 +00:00
Donald Sharp
cc9f21da22 *: Change thread->func to return void instead of int
The int return value is never used.  Modify the code
base to just return a void instead.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-23 19:56:04 -05:00
Sri Mohana Singamsetty
5daff9dcd0
Merge pull request #10590 from donaldsharp/bgp_error_codes
Bgp error codes
2022-02-16 08:44:20 -08:00
Donald Sharp
e4aa4745f2 bgpd: Renumber bgp_create_error_code enum values
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-15 16:38:32 -05:00
Donald Sharp
4b7e23e9f2 bgpd: Convert bgp error codes for cli input to an enum
Conversion of bgp error codes returned for cli input into
an enum and then properly handling all the error cases
in bgp_vty_return.

Because not all error codes returned were properly handled
in this function there existed configuration examples that
were accepted on the cli without an error message but not
saved.

Fixes: #10589
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-15 16:38:32 -05:00
Donald Sharp
b5d6f2d068 bgpd: Remove unused BGP_ERR_MAX #define
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-15 16:38:32 -05:00
Donald Sharp
8b4a0b6631 bgpd: Remove impossible invalid state
confederations are checking to see that the bgp pointer
is non-null.  But it's impossible to have a null pointer
in the cli and in all paths we have already deref'ed the bgp
pointer.  Let's remove that error code as that it is impossible
to happen.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-15 16:38:32 -05:00