Commit Graph

1161 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
Michal Ruprich
dcab90125f bgpd: show ip bgp neighbors graceful-restart typo
Noticed a typo in the definition of
show_ip_bgp_neighbors_graceful_restart function.

Signed-off-by: Michal Ruprich <mruprich@redhat.com>
2022-10-04 15:14:48 +02:00
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
Donatas Abraitis
c4f64ea94d bgpd: Use %pRD for prefix_rd2str()
Convert a bunch of prefix_rd2str() for json/vty stuff.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-09-22 13:12:11 +03: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
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
Donatas Abraitis
c29b1ce67c
Merge pull request #11855 from cscarpitta/fix-srv6-memleaks
*: Fix several memory leaks in SRv6 implementation
2022-08-29 14:35:24 +03:00
Donatas Abraitis
511211bf56 bgpd: Convert prefix2str to %pFX
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-08-25 14:35:27 +03: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
Carmine Scarpitta
f8e9c702a1 bgpd: Fix memory leak in SRv6 locator delete
Running `bgp_srv6l3vpn_to_bgp_vrf` and `bgp_srv6l3vpn_to_bgp_vrf2`
topotests with `--valgrind-memleaks` gives several memory leak errors.
This is due to the way SRv6 locators are removed/unset in bgpd: when
an SRv6 locator is deleted or unset, the memory allocated for the
locator prefix (`tovpn_sid_locator`) is not freed.

This patch adds a `for` loop that iterates over the list of BGP
instances. For each BGP instance using the SRv6 locator to be
removed/unset, we use `XFREE()` to properly free the memory allocated
for `tovpn_sid_locator` after the SRv6 locator is removed or unset.

The memory allocated for `tovpn_sid_locator` cannot be freed before
calling `vpn_leak_postchange_all()`. This is because
after deleting an SRv6 locator, we call `vpn_leak_postchange_all()`
to handle the SRv6 locator deletion and send a BGP Prefix SID withdraw
message. `tovpn_sid_locator` is required to properly build the BGP
Prefix SID withdraw message. After calling `vpn_leak_postchange_all()`
we can safely remove the `tovpn_sid_locator` and free the allocated
memory.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2022-08-24 14:22:04 +02:00
Carmine Scarpitta
bda15542f4 bgpd: Fix memory leak when an SRv6 SID is removed
Running `bgp_srv6l3vpn_to_bgp_vrf` and `bgp_srv6l3vpn_to_bgp_vrf2`
topotests with `--valgrind-memleaks` gives several memory leak errors.
This is due to the way SRv6 SIDs are removed in bgpd: when
an SRv6 locator is deleted/unset, all the SIDs allocated from that
locator are removed from the SRv6 functions list
(`bgp->srv6_functions`),but the memory allocated for the SIDs is not
freed.

This patch adds a call to `XFREE()` to properly free the allocated
memory when an SRv6 SID is removed.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2022-08-24 08:56:46 +02:00
Carmine Scarpitta
03852f673b bgpd: Fix memory leak in SRv6 locator delete/unset
Running `bgp_srv6l3vpn_to_bgp_vrf` and `bgp_srv6l3vpn_to_bgp_vrf2`
topotests with `--valgrind-memleaks` gives several memory leak errors.
This is due to the way SRv6 locators are deleted/unset in bgpd: when
an SRv6 locator is deleted/unset, all the chunks of the locator are
removed from the SRv6 locator chunks list (`bgp->srv6_locator_chunks`).
However, the memory allocated for the chunks is not freed.

This patch adds a call to the `srv6_locator_chunk_free()` function to
properly free the allocated memory when an SRv6 locator is removed or
unset.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2022-08-24 08:53:08 +02: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
Donald Sharp
f609bcd6a6 bgpd: Safi can be SAFI_MAX which would allow a write beyond alloced
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-07-28 18:01:09 -04:00
Donatas Abraitis
8ff746efcb
Merge pull request #11695 from donaldsharp/afi_max
bgpd: Ensure we are not using AFI_MAX
2022-07-28 18:32:24 +03:00
Donald Sharp
d880a643d7 bgpd: Ensure we are not using AFI_MAX
When using bgp_vty_afi_from_str it can
return AFI_MAX( but in practice never will with
our cli ).  In bgp_default_afi_safi_cmd the code
directly references:
	bgp->default_afi[afi][safi] = TRUE;

and if afi is AFI_MAX FRRR would be accessing
memory where it should not be.

Let's just provide some assurances for coverity
that this never happens.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-07-27 09:36:17 -04:00
Donatas Abraitis
a3aecc99d5 bgpd: Allow setting custom port for BGP unnumbered peers
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-07-27 11:36:15 +03:00
Donald Sharp
1af6e82b81 bgpd: Remove newlines from zlog, they are not allowed
commit: a486300b26
introduced newlines in zlog_XX messaging.  Not allowed.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-07-26 10:06:38 -04:00
Russ White
3bf3144517
Merge pull request #11523 from pguibert6WIND/bgp_no_retain
Bgp no retain
2022-07-26 08:50:59 -04:00
Donald Sharp
c3aaa89a44 bgpd: Convert thread_cancel to THREAD_OFF and use THREAD_ARG
Just convert all uses of thread_cancel to THREAD_OFF.  Additionally
use THREAD_ARG instead of t->arg to get the arguement.  Individual
files should never be accessing thread private data like this.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-07-21 08:30:49 -04:00
Donald Sharp
fa5806c318 bgpd: Remove various macros that overlap THREAD_OFF
Let's just use THREAD_OFF consistently in the code base
instead of each daemon having a special macro that needs to
be looked at and remembered what it does.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-07-21 08:27:36 -04:00
Donald Sharp
a6de2db239
Merge pull request #11646 from opensourcerouting/fix/memory_show
bgpd: Show extended communities memory consumption
2022-07-19 14:13:17 -04:00
Russ White
96575121cf
Merge pull request #11611 from fdumontet6WIND/FMJA/desc_mess
bgp:change in showing neighbor description
2022-07-19 08:38:53 -04:00
Donatas Abraitis
145f7619aa bgpd: Show extended communities memory consumption
Just fix the description because it's wrong.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-07-19 14:06:17 +03:00
Francois Dumontet
64541ffa8f bgp:change in showing neighbor description
currently "show bgp summary" and "sho bgp summary wide" commands
provide a description string until a whitespace is occuring this
respectively with size limits of 20 and 60 chars

now theses two commands are providing strings with all
characters until the last witespace before size limit

Signed-off-by: Francois Dumontet <francois.dumontet@6wind.com>
2022-07-18 14:12:23 +02:00
Donatas Abraitis
00e6edb97d bgpd: Add constants for some repetitive CLI strings
"Address Family\n"
"Address Family modifier\n"

Before:

```
donatas-laptop(config-router)# address-family ipv4
  <cr>
  flowspec         Address Family Modifier
  labeled-unicast  Address Family modifier
  multicast        Address Family modifier
  unicast          Address Family Modifier
  vpn              Address Family modifier
```

After:

```
donatas-laptop(config-router)# address-family
  ipv4   Address Family
  ipv6   Address Family
  l2vpn  Address Family
donatas-laptop(config-router)# address-family ipv4
  <cr>
  flowspec         Address Family modifier
  labeled-unicast  Address Family modifier
  multicast        Address Family modifier
  unicast          Address Family modifier
  vpn              Address Family modifier
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-07-18 10:12:57 +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
Russ White
9a4b3d5467
Merge pull request #11486 from taspelund/bgp_timer_always_on
bgpd: include 0 in configured hold/keepalive
2022-06-28 16:54:09 -04: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
Trey Aspelund
e93d5c298d bgpd: include 0 in configured hold/keepalive
The default keepalive/hold timers are always exposed via this commit:
```
commit 9b1b96233d (origin/bgp_timer_always_on)
Author: Trey Aspelund <taspelund@nvidia.com>
Date:   Mon Jun 27 23:20:33 2022 +0000

    bgpd: always display keepalive/hold intervals

    `show bgp neighbors <peer> [json]` was only displaying the configured
    keepalive and holdtime intervals when they differed from the default
    values.  Since default config is still config, let's make sure these
    values are always displayed.

    Signed-off-by: Trey Aspelund <taspelund@nvidia.com>
```

However it mistakenly changed the logic to only display the peer's
timers if the configured value was non-zero.  This updates the logic to
check PEER_FLAG_TIMER to determine if the values were configured,
given 0 is a valid value (to disable keepalives).

Signed-off-by: Trey Aspelund <taspelund@nvidia.com>
2022-06-28 14:58:51 +00:00
Lou Berger
613025ef10
Merge pull request #11093 from donaldsharp/allow_martians
Allow martians
2022-06-28 10:38:57 -04:00
Russ White
fe9a6ecc4a
Merge pull request #11483 from taspelund/bgp_timer_always_on
bgpd: always display keepalive/hold intervals
2022-06-28 07:00:30 -04:00
Trey Aspelund
9b1b96233d bgpd: always display keepalive/hold intervals
`show bgp neighbors <peer> [json]` was only displaying the configured
keepalive and holdtime intervals when they differed from the default
values.  Since default config is still config, let's make sure these
values are always displayed.

Signed-off-by: Trey Aspelund <taspelund@nvidia.com>
2022-06-27 23:37:21 +00: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
47e1288431 *: Replace sockunion2str => %pSU
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-06-21 13:34:56 +03:00
Donald Sharp
1e592331cb bgpd: Display useful values when using json for missing neighbor state
When a peer has not established connection yet, these values:
`hostLocal`, `portLocal`, `hostForeign`, `portForeign` might
not have any values and json output will not display anything
for them.  Modify the code to display some nominal values in
this situation so that parsers are not surprised.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-06-17 13:43:30 -04: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
Donald Sharp
be9778a3c1
Merge pull request #11395 from opensourcerouting/fix/autocompete_for_rmap_bgp
*: Use autocomplete for route-maps under commands that require it
2022-06-14 10:48:36 -04:00
Donatas Abraitis
70dd370f5a *: Use autocomplete for route-maps under commands that require it
For example:

```
donatas-laptop# show bgp ipv4 unicast neighbors 127.0.0.2 advertised-routes route-map ?
  RMAP_NAME  Name of the route map
       testas2 testas

donatas-laptop(config)# router bgp
donatas-laptop(config-router)# address-family ipv4
donatas-laptop(config-router-af)# redistribute connected route-map ?
  RMAP_NAME  Pointer to route-map entries
       testas2 testas

donatas-laptop(config-router-af)# network 192.168.0.0/23 route-map ?
  RMAP_NAME  Name of the route map
       testas2 testas
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-06-13 21:00:51 +03:00
Donatas Abraitis
be8d17335f bgpd: Show TTL value unconditionally for neighbors
If GTSM configured - show this value, otherwise TTL.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-06-10 16:55:02 +03:00
Donatas Abraitis
8cfa1e7846 bgpd: Simplify BGP community alias handling
Also, warn in CLI an operator if we are trying to overwrite an existing
community alias with an existing alias.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-26 20:15:35 +03:00
Donatas Abraitis
d13d137a1b bgpd: Fix memory leak for BGP community alias in CLI
Before:
```
root@spine1-debian-11:~/frr# vtysh -c 'show memory bgpd | include Large Community'
Large Community               :      100     40        4000      100      4000
Large Community value         :      100     12        2400      100      2400
root@spine1-debian-11:~/frr# for x in $(seq 1 100); do vtysh -c 'conf' -c 'bgp community alias 123:123:123 testas' > /dev/null; done
root@spine1-debian-11:~/frr# vtysh -c 'show memory bgpd | include Large Community'
Large Community               :      200     40        8000      200      8000
Large Community value         :      200     12        4800      200      4800
root@spine1-debian-11:~/frr# for x in $(seq 1 100); do vtysh -c 'conf' -c 'bgp community alias 123:123:123 testas' > /dev/null; done
root@spine1-debian-11:~/frr# vtysh -c 'show memory bgpd | include Large Community'
Large Community               :      300     40       12000      300     12000
Large Community value         :      300     12        7200      300      7200
root@spine1-debian-11:~/frr#
```

After:
```
root@spine1-debian-11:~/frr# vtysh -c 'show memory bgpd | include Large Community'
Large Community               :        0     40           0        1        56
Large Community display string:        0   8192           0        1      8200
Large Community value         :        0     12           0        1        24
root@spine1-debian-11:~/frr# for x in $(seq 1 100); do vtysh -c 'conf' -c 'bgp community alias 123:123:123 testas' > /dev/null; done
root@spine1-debian-11:~/frr# vtysh -c 'show memory bgpd | include Large Community'
Large Community               :        0     40           0        1        56
Large Community display string:        0   8192           0        1      8200
Large Community value         :        0     12           0        1        24
root@spine1-debian-11:~/frr#
```

After we call [l]community_str2com(), we should free the memory.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-26 15:31:35 +03:00
Sri Mohana Singamsetty
93480825fb
Merge pull request #11204 from anlancs/fix/bgpd-check-vnihash
bgpd: remove unnecessary check for evpn
2022-05-19 09:38:10 -07:00
anlan_cs
f33bf7c0eb bgpd: remove unnecessary check for evpn
Since `bgp->vnihash` is naturally non-NULL, remove check for this field.

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-05-15 01:32:14 -04:00