Commit Graph

824 Commits

Author SHA1 Message Date
Russ White
bd751c0700
Merge pull request #10987 from opensourcerouting/fix/bgp_conditional_advertisements_rmap_change_peer_groups
bgpd: Do not forget to update conditional advertisements rmaps for peer-groups
2022-04-13 15:00:14 -04: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
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
9118301e48 bgpd: Do not forget to update conditional advertisements rmaps for peer-groups
When the peer is configured for the first time:
```
neighbor P1 peer-group
neighbor P1 remote-as external
neighbor P1 advertise-map ADV exist-map EXIST
neighbor 10.10.10.1 peer-group P1
```

Conditional advertisements route-maps are not updated and cond. advertisements
do not work until FRR restarted. BGP sessions clear does not help.

Or even changing peer-group for a peer, causes this bug to kick in.

```
no neighbor 10.10.10.1
neighbor 10.10.10.1 peer-group P2
```

With this fix, cond. advertisements start working immediatelly.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-04-08 22:43:01 +03:00
Donald Sharp
f75b916348 bgpd, vtysh: Fix spelliing of explicitely
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-02 07:25:18 -04: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
Donald Sharp
6240377270 bgpd: Do not fail when going from GR mode to GR
If you enter:

router bgp 325
  bgp graceful-restart
  bgp graceful-restart
!

The second command entered will fail.  This is not
something that should be failing as that it's a no-op.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-03-10 09:33:57 -05: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
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
Donald Sharp
b17826b715 bgp: Add a 15 minute warning to missing policy
Add a 15 minute warning to the logging system when
bgp policy is not setup properly.  Operators keep asking
about the missing policy( on upgrade typically ).  Let's
try to give them a bit more of a hint when something is
going wrong as that they are clearly missing the other
various places FRR tells them about it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-15 12:40:38 -05:00
Donatas Abraitis
7a90d91586
Merge pull request #10408 from idryzhov/no-opaque-by-default
*: do not send opaque data to zebra by default
2022-01-28 12:54:16 +02:00
Donatas Abraitis
6766acddbf
Merge pull request #9880 from louis-oui/maximum-prefix-out
bgpd: fixes maximum prefix out
2022-01-27 08:49:31 +02:00
Louis Scalbert
80444d30ce bgpd: fix peer-group with maximum-prefix-out
When setting maximum-prefix-out on peer-group, the applied value on
member is 0.

Fix usage of maximum-prefix-out on peer-group.

The peer_maximum_prefix_out_(un)set functions are derived from
peer_maximum_prefix_(un)set.

Fixes: fde246e835 ("bgpd: Add an option to limit outgoing prefixes")
Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-01-26 16:49:31 +01:00
Igor Ryzhov
870791a3b5 *: do not send opaque data to zebra by default
Opaque data takes up a lot of memory when there are a lot of routes on
the box. Given that this is just a cosmetic info, I propose to disable
it by default to not shock people who start using FRR for the first time
or upgrades from an old version.

Fixes #10101.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2022-01-24 22:18:46 +03:00
Louis Scalbert
d0bf49ecd5 bgpd: apply maximum-prefix-out without clearing the neighbor
Abstract:
- The command "neighbor PEER maximum-prefix-out NUMBER" cannot be applied
  without clearing the BGP neighbor.
- Apply the maximum-prefix-out value as soon as it is modified without
  clearing the neighbor.

subgroup_update_packet() and subgroup_withdraw_packet() respectively
manages the announcement and withdrawal BGP message to the peer.
subgrp->scount counter counts the number of sent prefixes.

Before the patch, the maximum out prefix limitation was applied in
subgroup_update_packet() in order that subgrp->scount never exceeds the
limit. Setting a limit inferior to the effective number of sent prefix
did not result in sending any withdrawal message to reduce the number of
sent prefixes. Without clearing the BGP neighbor, the limitation only
applied to the announcement of new prefixes when the limitation was
over.

With the patch, the limitation is checked in subgroup_announce_check().
The function is intended to say whether a prefix has to be announced in
regards to the prefix-list, route-map... Now when a maximum-prefix-out
value is changed/removed, the neighbor AFI/SAFI table is re-parsed in
the same way as for the application of route-map, prefix-lists...

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-01-20 18:19:37 +01:00
David Schweizer
3cb14f2605
bgpd: Reset message statistics with clear command
Signed-off-by: David Schweizer <dschweizer@opensourcerouting.org>
2022-01-19 14:24:18 +01:00
Donald Sharp
cce7c33396
Merge pull request #10335 from ton31337/fix/reduce_nesting_show_neighbor_bgp
bgpd: Reduce nesting for bgp_show_peer()
2022-01-14 08:11:48 -05:00
Donatas Abraitis
107115632a bgpd: Reduce nesting for bgp_show_peer()
It's hard to read sometimes or even add something more.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-01-13 17:23:03 +02:00
Donatas Abraitis
df8d723c5f *: Add FOREACH_AFI_SAFI_NSF(afi, safi) macro to reduce nesting
Used for graceful-restart mostly.

Especially for bgp_show_neighbor_graceful_restart_capability_per_afi_safi()

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-01-13 14:29:54 +02:00
Donatas Abraitis
ed284e2338 bgpd: Make sure we are playing with non-NULL for bgp shutdown message
```
*** CID 1510738:  Null pointer dereferences  (FORWARD_NULL)
/bgpd/bgp_vty.c: 4243 in bgp_shutdown_msg_magic()
4237            if (msgstr && strlen(msgstr) > BGP_ADMIN_SHUTDOWN_MSG_LEN) {
4238                    vty_out(vty, "%% Shutdown message size exceeded %d\n",
4239                            BGP_ADMIN_SHUTDOWN_MSG_LEN);
4240                    return CMD_WARNING_CONFIG_FAILED;
4241            }
4242
>>>     CID 1510738:  Null pointer dereferences  (FORWARD_NULL)
>>>     Passing null pointer "msgstr" to "bgp_shutdown_enable", which dereferences it.
4243            bgp_shutdown_enable(bgp, msgstr);
4244            XFREE(MTYPE_TMP, msgstr);
4245
4246            return CMD_SUCCESS;
4247     }
4248
```

```
*** CID 1510737:  Null pointer dereferences  (REVERSE_INULL)
/bgpd/bgpd.c: 4344 in bgp_shutdown_enable()
4338                    /* continue, if peer is already in administrative shutdown. */
4339                    if (CHECK_FLAG(peer->flags, PEER_FLAG_SHUTDOWN))
4340                            continue;
4341
4342                    /* send a RFC 4486 notification message if necessary */
4343                    if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status)) {
>>>     CID 1510737:  Null pointer dereferences  (REVERSE_INULL)
>>>     Null-checking "msg" suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
4344                            if (msg)
4345                                    bgp_notify_send_with_data(
4346                                            peer, BGP_NOTIFY_CEASE,
4347                                            BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN, data,
4348                                            datalen + 1);
4349                            else
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-01-11 17:07:19 +02:00
Donatas Abraitis
202a171144 bgpd: Use correct encoding before printing shutdown msg
Using `bgp shutdown message MSG...`.

Length should be decoded from the first byte, but it's decoded from the data
instead.

Before:

```
%NOTIFICATION: sent to neighbor 192.168.0.2 6/2 (Cease/Administratively Shutdown) 70 bytes 5b 54 49 43 4b 45 54 2d 31 2d 31 34 33 38 33 36 37 33 39 30 5d 20 73
```

After:

```
%NOTIFICATION: sent to neighbor 192.168.0.2 6/2 (Cease/Administratively Shutdown) "[TICKET-1-1438367390] software upgrade; Expected downtime for 2 hours;"
```

On receiving side:

```
"[TICKET-1-1438367390] software upgrade; Expected downtime for 2 hours;"
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-01-07 22:35:38 +02:00
Donatas Abraitis
9f33eea39a bgpd: Increase administrative shutdown message size to 255
Extended BGP Administrative Shutdown Communication (rfc9003):

Basically, shutdown message size is increased to 255 from 128.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-01-07 22:35:38 +02:00
Donatas Abraitis
1479ed2fb3 bgpd: Implement LLGR helper mode
Tested between GoBGP and FRR (this commit).

```
┌───────────┐             ┌────────────┐
│           │             │            │
│ GoBGPD    │             │ FRRouting  │
│ (restart) │             │            │
│           │             │            │
└──────┬────┘             └───────┬────┘
       │                          │
       │                          │
       │                          │
       │     ┌───────────┐        │
       │     │           │        │
       │     │           │        │
       └─────┤ FRRouting ├────────┘
             │ (helper)  │
             │           │
             └───────────┘

// GoBGPD
% cat /etc/gobgp/config.toml
[global.config]
    as = 65002
    router-id = "2.2.2.2"
    port = 179

[[neighbors]]
    [neighbors.config]
        peer-as = 65001
        neighbor-address = "2a02🔤:123"
    [neighbors.graceful-restart.config]
        enabled = true
        restart-time = 3
        long-lived-enabled = true
    [[neighbors.afi-safis]]
        [neighbors.afi-safis.config]
            afi-safi-name = "ipv6-unicast"
        [neighbors.afi-safis.mp-graceful-restart.config]
            enabled = true
        [neighbors.afi-safis.long-lived-graceful-restart.config]
            enabled = true
            restart-time = 10
    [[neighbors.afi-safis]]
        [neighbors.afi-safis.config]
            afi-safi-name = "ipv4-unicast"
        [neighbors.afi-safis.mp-graceful-restart.config]
            enabled = true
        [neighbors.afi-safis.long-lived-graceful-restart.config]
            enabled = true
            restart-time = 20

% ./gobgp global rib add -a ipv6 2001:db8:4::/64
% ./gobgp global rib add -a ipv6 2001:db8:5::/64 community 65535:7
% ./gobgp global rib add -a ipv4 100.100.100.100/32
% ./gobgp global rib add -a ipv4 100.100.100.200/32 community 65535:7
```

1. When killing GoBGPD, graceful restart timer starts in FRR helper router;
2. When GR timer expires in helper router:
   a) LLGR_STALE community is attached to routes to be retained;
   b) Clear stale routes that have NO_LLGR community attached;
   c) Start LLGR timer per AFI/SAFI;
   d) Recompute bestpath and reannounce routes to peers;
   d) When LLGR timer expires, clear all routes on particular AFI/SAFI.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-12-28 16:07:59 +02:00
Donatas Abraitis
f5827f3689 bgpd: Drop if 0 blocks
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-12-23 14:41:11 +02:00
Donatas Abraitis
22472feef8 bgpd: No need to test if a thread is running for BGP_TIMER_OFF
Handles that inside the macro.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-12-21 10:57:07 +02:00
Russ White
5c24a442d9
Merge pull request #10105 from ton31337/feature/rfc9072
bgpd: Implement rfc9072
2021-11-29 10:46:58 -05:00
Donatas Abraitis
75eeda9323 bgpd: Convert vty_out to vty_json for JSON
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-25 17:51:12 +02:00
Donatas Abraitis
d08c0c8077 bgpd: Implement rfc9072
Related: https://datatracker.ietf.org/doc/html/rfc9072

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-11-22 15:34:46 +02:00
Russ White
208a07a8b8
Merge pull request #9972 from opensourcerouting/bfd-bgp-fixes
bfdd,bgpd: fix some integration bugs
2021-11-05 17:31:29 -04:00
Rafael Zalamena
7196f56eb3 bgpd: update BFD config on update-source change
Update BFD sessions when the update-source configuration is set so the
session follows the new configured source address.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2021-11-04 08:01:28 -03:00
Rafael Zalamena
4ba37eb691 bgpd: fix BFD configuration update on TTL change
When altering the TTL of a eBGP peer also update the BFD
configuration. This was only working when the configuration happened
after the peer connection had been established.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2021-11-04 08:01:28 -03:00
Donatas Abraitis
8606be8779 bgpd: Add Long-lived Graceful Restart capability (restarter)
Restart Router mode.

FRRouting (Restarter):
```
 bgp long-lived-graceful-restart stale-time 10
 bgp graceful-restart restart-time 1
```

Tested with GoBGP (Helper):
```
    long-lived-graceful-restart:	advertised and received
        Local:
	    ipv4-unicast, restart time 100000 sec
        Remote:
	    ipv4-unicast, restart time 10 sec, forward flag set
```

Logs:

```
{"Key":"192.168.10.123","Reason":"graceful-restart","State":"BGP_FSM_ESTABLISHED","Topic":"Peer","level":"info","msg":"Peer Down","time":"2021-10-25T17:48:36+03:00"}
{"Key":"192.168.10.123","State":"BGP_FSM_IDLE","Topic":"Peer","level":"warning","msg":"graceful restart timer expired","time":"2021-10-25T17:48:37+03:00"}
{"Family":65537,"Key":"192.168.10.123","Topic":"Peer","level":"info","msg":"start LLGR restart timer (10 sec) for ipv4-unicast","time":"2021-10-25T17:48:37+03:00"}
{"Family":65537,"Key":"192.168.10.123","Topic":"Peer","level":"info","msg":"LLGR restart timer (10 sec) for ipv4-unicast expired","time":"2021-10-25T17:48:47+03:00"}

% ./gobgp global rib
   Network              Next Hop             AS_PATH              Age        Attrs
S*>10.0.2.0/24          192.168.10.123       174                  00:12:08   [{Origin: ?} {Med: 0} {Communities: llgr-stale} {Extcomms: [174:1282304808]}]
```

Helper mode will be added with upcoming PRs.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-10-31 20:25:42 +02:00
Donald Sharp
6e26b2e21f bgpd: When issuing no ... ebgp-multihop always resets
When removing the command `no neighbor <X> ebgp-multihop <Y>`
the bgp code was always resetting the connection even if
the command would do nothing.

Fixes: #6464
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-10-24 15:09:30 -04:00
Donald Sharp
144908dc52
Merge pull request #9774 from idryzhov/bgp-show-crash
bgpd: fix crash when using "show bgp vrf all"
2021-10-08 12:38:08 -04:00
Igor Ryzhov
1c49e8138e bgpd: fix crash when using "show bgp vrf all"
Any command that uses `peer_lookup_in_view` crashes when "vrf all" is
used, because bgp is NULL in this case.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-10-08 11:42:13 +03:00
Donald Sharp
e1a32ec1c5 bgpd: bgp_announce_route should know if we should force the update or not
When calling bgp_announce_route allow it to properly set the flag
to force an update to go out or not.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-10-04 07:59:18 -04:00
Igor Ryzhov
b0a007df7a bgpd: fix access-list update callback
When a regular access-list is updated, we should update references to
regular access-lists, not as-path access-lists.

Fixes #9707.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-10-01 14:45:07 +03:00
Donatas Abraitis
7c0e43123d bgpd: Add disable-addpath-rx knob
The idea is to disable addpath-rx capability to avoid unnecessary additional
routes installed.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-09-03 15:05:02 +03:00
Donald Sharp
e7682ccd1b bgpd: Do not randomly generate a vrf id for -Z
When FRR added the -Z parameter the bgp daemon was setting
a vrf identifier based upon a number starting at 1.  This
caused issues when we upgraded the code to the outgoing
sockets to use vrf_bind always.

FRR should never just randomly select a vrf identifier.
Let's just use VRF_DEFAULT when we are in a -Z environment.
It's a safe bet.

Fixes: #9519
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-09-02 09:02:55 -04:00
Russ White
8811ce0beb
Merge pull request #9469 from ton31337/fix/extcommunity_bandwidth_floating_to_hex
bgpd: Use IEEE-754 Floating Point for storing extcommunity bandwidth
2021-09-01 12:56:45 -04:00
Donatas Abraitis
e5fbfe01ae
Merge pull request #9318 from Prerana-GB/ibgp_knob
bgp: BGP knob for faster convergence of bgp sessions
2021-09-01 10:45:27 +03:00
Donatas Abraitis
27aa23a43b bgpd: Add neighbor PEER link-bw-encoding-ieee
This is to avoid breaking changes between existing deployments of
extended community for bandwidth encoding. By default FRR uses uint32
to encode bandwidth, which is not as the draft requires (IEEE floating-point).

This switch enables the required encoding per-peer.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-08-30 14:21:49 +03:00
Prerana-GB
f852eb9833 bgpd: BGP knob to teardown session immediately when peer is unreachable
When BGP is notified by RIB that peer address is unreachable then BGP session must be brought
down immediately and not wait for the hold-timer expiry. Today single-hop EBGP already behaves
this way but need to change for iBGP and multi-hop EBGP sessions.

Signed-off-by: Prerana G.B <prerana@vmware.com>, Pushpasis Sarkar <spushpasis@vmware.com>
2021-08-24 12:23:38 +00:00
Takemasa Imada
b042667a3d bgpd: minimum-holdtime knob to prevent session establishment with BGP peer with low holdtime.
Signed-off-by: Takemasa Imada <takemasa.imada@gmail.com>
2021-08-15 06:08:08 +09:00
Donald Sharp
883da9f5ec
Merge pull request #9256 from idryzhov/dampening-revert
BGP per-peer dampening revert
2021-08-06 10:46:09 -04:00
Igor Ryzhov
1ca2fd1175 Revert "bgpd: convert global config to transactional cli"
This reverts commit ff8a8a7ac1.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-08-03 23:36:31 +03:00