Commit Graph

557 Commits

Author SHA1 Message Date
Stephen Worley
742341e144 bgpd: add mpath label stack helper functions for dvni
Add some bgp_path_info helper functions for getting the correct l3vni
label, getting the vni from the label stack, and determinging if
the mpath is D-VNI based.

Signed-off-by: Stephen Worley <sworley@nvidia.com>
2023-02-13 18:12:05 -05:00
Stephen Worley
31e1a1033d bgpd: send L3VNI as route labels to zebra
Add functionality to always send the L3VNI to zebra as a label
on the route. It will be zebra's job to determine how to use it (i.e.
via Single Vxlan Device or not).

The l3VNI according to rfc should always be the second for a type2 route
and be the only one available for a type5. Hence, we can just grab the
last label in the stack here and add it onto the route.

Signed-off-by: Stephen Worley <sworley@nvidia.com>
2023-02-13 18:12:05 -05:00
David Lamparter
acddc0ed3c *: auto-convert to SPDX License IDs
Done with a combination of regex'ing and banging my head against a wall.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-02-09 14:09:11 +01:00
Donatas Abraitis
cfd01fc0ac Revert "bgpd: optimal router reflection cli and fsm changes"
This reverts commit 70cd87ca02.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2023-01-17 18:15:28 +02:00
Donald Sharp
2bb8b49ce1 Revert "Merge pull request #11127 from louis-6wind/bgp-leak"
This reverts commit 16aa1809e7, reversing
changes made to f616e71608.
2023-01-13 08:13:52 -05:00
Russ White
16aa1809e7
Merge pull request #11127 from louis-6wind/bgp-leak
bgpd: multiple fixes for route leaking
2022-12-27 14:51:28 -05:00
Donatas Abraitis
8431489f74
Merge pull request #12551 from proelbtn/fix-install-srv6-local-routes
bgpd: Fix announce SRv6 locally-generated routes to Zebra
2022-12-23 14:51:46 +02:00
anlan_cs
4d67f4fc5f bgpd: fix one wrong debug log for evpn
Take it into consideration for one debug log:
EVPN MAC-IP routes with a L3 NHG id, has no nexthops.

Not "delete", but "add".

Before:
```
Tx route delete VRF 21 192.168.30.253/32 metric 0 tag 0 count 0 nhg 72580649
```

After:
```
Tx route add VRF 21 192.168.30.253/32 metric 0 tag 0 count 0 nhg 72580649
```

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-12-21 11:22:55 +08:00
Ryoga Saito
db65643931 bgpd: Fix handling of SRv6 local routes
Current bgpd can't annouce SRv6 locally-generated routes to Zebra
correctly because MPLS label of locally-generated routes is not valid
but sid_info->transposition_len is set to non-zero value. This commit
fixes such kind of issues.

Signed-off-by: Ryoga Saito <ryoga.saito@linecorp.com>
2022-12-20 20:07:40 +09:00
Louis Scalbert
5f6c0ba6d2 bgpd: resend routes deleted by kernel after interface addresses deletion
When the last IPv4 address of an interface is deleted, Linux removes all
routes includes BGP ones using this interface without any Netlink
advertisement. bgpd keeps them in RIB as valid (e.g. installed in FIB).

The previous patch invalidates the associated nexthop groups in zebra
but bgpd is not notified of the event.

> 2022/05/09 17:37:52.925 ZEBRA: [TQKA8-0276P] Not Notifying Owner: connected about prefix 29.0.0.0/24(40) 3 vrf: 7

Look for the bgp_path_info that are unsynchronized with the kernel and
flag them for refresh in their attributes. A VPN route leaking update is
calles and the refresh flag triggers a route refresh to zebra and then a
kernel FIB installation.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-12-16 15:07:49 +01:00
Louis Scalbert
667a4e92da bgpd: move mp_nexthop_prefer_global boolean attribute to nh_flag
Previous commits have introduced a new 8 bits nh_flag in the attr
struct that has increased the memory footprint.

Move the mp_nexthop_prefer_global boolean in the attr structure that
takes 8 bits to the new nh_flag in order to go back to the previous
memory utilization.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-12-16 15:07:00 +01:00
Louis Scalbert
86a1c29632 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>
2022-12-16 14:52:47 +01:00
Louis Scalbert
6030b8b40d bgpd: update route leaking when a VRF loopback is received
At bgpd startup, VRF instances are sent from zebra before the
interfaces. When importing a l3vpn prefix from another local VRF
instance, the interfaces are not known yet. The prefix nexthop interface
cannot be set to the loopback or the VRF interface, which causes setting
invalid routes in zebra.

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

At a VRF interface deletion, zebra voluntarily sends a
ZEBRA_INTERFACE_ADD message to move it to VRF_DEFAULT. Do not update if
such a message is received. VRF destruction will destroy all the related
routes without adding codes.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2022-12-16 14:52:47 +01:00
Donatas Abraitis
073801481b bgpd: inet_ntop() adjustments
Use %pI4/%pI6 where possible, otherwise at least atjust stack buffer sizes
for inet_ntop() calls.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-11-29 17:36:13 +02:00
Donatas Abraitis
382c3b08b6 bgpd: Warn user only if the LL is not seriously available
LL address is assigned, but we get a warning, that it's not:

Interface: enp3s0 does not have a v6 LL address associated with it, waiting until one is created for it

```
donatas-pc# sh int enp3s0
Interface enp3s0 is up, line protocol is up
  Link ups:       0    last: (never)
  Link downs:     0    last: (never)
  vrf: default
  index 2 metric 0 mtu 1500 speed 100
  flags: <UP,BROADCAST,RUNNING,MULTICAST>
  v4 Multicast forwarding is on
  v6 Multicast forwarding is on
  Type: Ethernet
  HWaddr: 18:c0:4d:96:fa:3f
  inet 192.168.10.17/24
  inet6 2a02:4780:abc:0:e776:6220:1e21:44b1/64
  inet6 fe80::ca5d:fd0d:cd8:1bb7/64
```

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-11-18 10:36:24 +02:00
Carmine Scarpitta
a1d5e05fb3 bgpd: Do not set chunk pointer to NULL after free
`srv6_locator_chunk_free()` takes care of freeing the memory allocated
for a `struct srv6_locator_chunk` and setting the
`struct srv6_locator_chunk` pointer to NULL.

It is not necessary to explicitly set the pointer to NULL after invoking
`srv6_locator_chunk_free()`.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2022-10-29 17:23:59 +02:00
Carmine Scarpitta
6946731314 lib, bgpd: Enhance srv6_locator_chunk_free() API
A programmer can use the `srv6_locator_chunk_free()` function to free
the memory allocated for a `struct srv6_locator_chunk`.

The programmer invokes `srv6_locator_chunk_free()` by passing a single
pointer to the `struct srv6_locator_chunk` to be freed.
`srv6_locator_chunk_free()` uses `XFREE()` to free the memory.
It is the responsibility of the programmer to set the
`struct srv6_locator_chunk` pointer to NULL after freeing memory with
`srv6_locator_chunk_free()`.

This commit modifies the `srv6_locator_chunk_free()` function to take a
double pointer instead of a single pointer. In this way, setting the
`struct srv6_locator_chunk` pointer to NULL is no longer the
programmer's responsibility but is the responsibility of
`srv6_locator_chunk_free()`. This prevents programmers from making
mistakes such as forgetting to set the pointer to NULL after invoking
`srv6_locator_chunk_free()`.

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2022-10-29 17:04:35 +02:00
Carmine Scarpitta
527588aa78 bgpd: add support for per-VRF SRv6 SID
In the current implementation of bgpd, SRv6 SIDs can be configured only
under the address-family. This enables bgpd to leak IPv6 routes using
an SRv6 End.DT6 behavior and IPv4 routes using an SRv6 End.DT4
behavior. It is not possible to leak both IPv6 and IPv4 routes using a
single SRv6 SID.

This commit adds a new CLI command
"sid vpn per-vrf export <sid_idx|auto>" that enables bgpd to leak both
IPv6 and IPv4 routes using a single SRv6 SID (End.DT46 behavior).

Signed-off-by: Carmine Scarpitta <carmine.scarpitta@uniroma2.it>
2022-10-18 16:08:23 +02:00
Russ White
984eb32b58
Merge pull request #11159 from maduri111/bgpd-orr
bgpd: optimal route reflection
2022-10-12 09:30:36 -04:00
Russ White
b6aa61ba3c
Merge pull request #11981 from proelbtn/add-support-to-change-function-length
bgpd: Add support to change Segment Routing function length
2022-10-12 08:44:29 -04:00
Madhuri Kuruganti
70cd87ca02 bgpd: optimal router reflection cli and fsm changes
Signed-off-by: Madhuri Kuruganti <maduri111@gmail.com>
2022-10-12 13:43:55 +05:30
Ryoga Saito
bee2e7d08f bgpd: save srv6_locator_chunk in vpn_policy
In order to send correct SRv6 L3VPN advertisement, we need to save
srv6_locator_chunk in vpn_policy. With this information, we can
construct correct SRv6 L3VPN advertisement packets.

Signed-off-by: Ryoga Saito <ryoga.saito@linecorp.com>
2022-10-07 18:26:48 +09:00
Donatas Abraitis
b022cf7352
Merge pull request #11838 from Pdoijode/v6-gua-nh-bgp-update
bgpd: BGP does not update next-hop when global V6 address is configured
2022-10-06 10:04:37 +03:00
Pdoijode
bc6d1b151f bgpd: BGP does not update next-hop when global V6 address is configured
When primary global v6 unicast address is configured on an
unnumbered interface, BGP does not re-advertise updates out
with the new global v6 address as the nexthop

Signed-off-by: Pdoijode <pdoijode@nvidia.com>
2022-09-29 15:28:38 -07: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
253b7158ee bgpd: Remove redundant test against ifp for DEBUG messages
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-08-30 11:35:05 +03: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
Trey Aspelund
7226bc40d6 bgpd: ignore NEXT_HOP for MP_REACH_NLRI
RFC 4760 states we SHOULD ignore the NEXT_HOP attribute for BGP Update
messages carrying only MP_REACH_NLRI attributes. Thus we should use the
Network Address of Next Hop field of the MP_REACH_NLRI as the nexthop.

Instead of always looking for BGP_ATTR_NEXT_HOP, this commit ensures:
1) we set mp_nexthop_len to BGP_ATTR_NHLEN_IPV4 for v4 bgp_static routes
2) we check mp_nexthop_len when choosing the nexthop to use for nht
3) we check mp_nexthop_len when choosing the nexthop to send to zebra
4) we check mp_nexthop_len when picking the nexthop to shown by vtysh

Reported-by: Binon Gorbutt <binon@aervivo.com>
Signed-off-by: Trey Aspelund <taspelund@nvidia.com>
2022-08-04 20:36:49 +00:00
Donald Sharp
7b6cee8975 bgpd: use pI4
The bgp_path_info_to_ipv6_nexthop will correctly set
the nexthop value. There is no need to test this to
display something that won't be used in debug

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-07-29 18:31:58 -04:00
Donald Sharp
62bf6b4200 bgpd: Fixup pbr rule changes that were missed
In commit: d70a31a3ef

the Zapi ZEBRA_RULE_ADD message was modified but
the bgp version was not updated appropriately and
when zebra received the message it did not properly
read it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-07-26 12:41:11 -04:00
Xiao Liang
5609e70fb8 lib, zebra, bgpd: Move route EVPN flag to nexthop
Multipath route may have mixed nexthops of EVPN and IP unicast. Move
EVPN flag to nexthop to support such cases.

Signed-off-by: Xiao Liang <shaw.leon@gmail.com>
2022-06-10 17:12:48 +08:00
Donatas Abraitis
67f67ba481 bgpd: Drop label_ntop/label_pton functions
Start using mpls_lse_encode/mpls_lse_decode, that is endian-aware, because
we always use host-byte order, should use network-byte.

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-06-01 16:45:22 +03:00
Donatas Abraitis
6006b807b1 *: Properly use memset() when zeroing
Wrong: memset(&a, 0, sizeof(struct ...));
    Good:  memset(&a, 0, sizeof(a));

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2022-05-11 14:08:47 +03:00
Nobuhiro MIKI
1c21a23453 bgpd: refactor type of srv6_locator_chunks list
Since additional information such as block_bits_length is needed to
generate SIDs properly, the type of elements in srv6_locator_chunks
list is extended from "struct prefix_ipv6 *" to
"struct srv6_locator_chunk *". Even in terms of variable name,
"struct srv6_locator_chunk *" is appropriate.

Signed-off-by: Nobuhiro MIKI <nmiki@yahoo-corp.jp>
2022-04-06 13:40:14 +09:00
Donald Sharp
75ba864c81 bgpd: Warn user when an interface has no v6 LL address associated with it
When BGP detects that a peering is using a global address but no v6 LL
address has been created for the interface that the global address is
on warn the user that something is amiss and they need to fix it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-03-07 08:00:26 -05:00
Russ White
d2dfd26697
Merge pull request #10636 from ton31337/fix/use_get_set_for_communities
bgpd: Reuse get/set helpers for attr->community
2022-02-28 09:52:50 -05:00
Ryoga Saito
ea7cd161b2 bgpd: change the treatment for SRv6 routes
This patch adds transpostion_offset and transposition_len to bgp_sid_info,
and transposes SID only at bgp_zebra_announce.

Signed-off-by: Ryoga Saito <ryoga.saito@linecorp.com>
2022-02-25 15:34:28 +00:00
Donatas Abraitis
9a706b42fb bgpd: Reuse get/set helpers for attr->community
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-02-25 10:02:30 +02: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
Donatas Abraitis
1bcf3a96de bgpd: Use get/set helpers for attr->lcommunity
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2022-02-10 11:04:03 +02:00
Iqra Siddiqui
3756b9aceb bgpd: Fixing dead code
Description:
-Removing break statements which will never be executed.
-Adding missing 'cmd' variable.

Co-authored-by: Kantesh Mundaragi <kmundaragi@vmware.com>
Signed-off-by: Iqra Siddiqui <imujeebsiddi@vmware.com>
2022-01-31 21:50:50 -08:00
Russ White
05786ac774
Merge pull request #9644 from opensourcerouting/ospf-opaque-attrs
OSPF opaque route attributes
2022-01-18 09:08:38 -05:00
Donald Sharp
be785e356a bgpd, tests: Add code to handle failed installations
Currently the Wait for Install code ( bgp_suppress_fib ) does
not properly handle two states from zebra:  ROUTE_INSTALL_FAILED
and BETTER_ADMIN_DISTANCE_WON.  Pre this change the WFI code
would just never notify our peers about a route install failure
but more is needed.  In the ROUTE_INSTALL_FAILED and the
BETTER_ADMIN_DISTANCE_WON we need to notify our peers with
a withdrawal about the route, else we will continue to
draw traffic to us when we cannot legally do so.

Why is this needed?  In either case imagine that we've already
received a bgp route, installed it and sent to our peers.
In the Better admin distance won case, say a static route is installed
at this point in time we must stop advertising the route through
us since we are not installed.  As such a withdrawal must be sent.

In the ROUTE_INSTALL_FAILED case, the code was not properly handling
the situation where we have Route A, it was successfully installed
and then we received a update to Route A that was attempted to be
installed but failed.  In this case we also need to send a withdrawal

Finally update the bgp_suppress_fib topotest to test both of these
situations.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-12-17 13:28:56 -05:00
Russ White
f1f6716d4a
Merge pull request #9610 from iqras23/best_path
bgpd: VRF-Lite fix best path selection
2021-11-30 16:14:34 -05:00
Renato Westphal
959331a339 lib: do not include bgpd headers in route_opaque.h
Duplicate a couple of definitions in order to remove the bgpd
includes from this libfrr header. This is necessary to fix some
name collisions like PREFIX_LIST_IN being defined differently on
multiple daemons (as soon as other daemons start including
route_opaque.h).

Including daemon headers on libfrr headers is a bad practice and
should be avoided whenever possible.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2021-11-23 14:24:07 -03:00
Igor Ryzhov
096f7609f9 *: cleanup ifp->vrf_id
Since f60a1188 we store a pointer to the VRF in the interface structure.
There's no need anymore to store a separate vrf_id field.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-11-22 20:47:23 +03:00
Iqra Siddiqui
ad1844f7bd bgpd: Few code optimisations
Description:
Added a macro which optimises some part of the code.

Co-authored-by: Santosh P K <sapk@vmware.com>
Co-authored-by: Kantesh Mundaragi <kmundaragi@vmware.com>
Signed-off-by: Iqra Siddiqui <imujeebsiddi@vmware.com>
2021-11-19 07:33:22 +05:30
Igor Ryzhov
608c887069 *: unify if_is_loopback/if_is_loopback_or_vrf
We should always treat the VRF interface as a loopback. Currently, this
is not the case, because in some old pre-VRF code we use if_is_loopback
instead of if_is_loopback_or_vrf. To avoid any future problems, the
proposal is to rename if_is_loopback_or_vrf to if_is_loopback and use it
everywhere. if_is_loopback is renamed to if_is_loopback_exact in case
it's ever needed, but currently it's not used anywhere.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-11-16 18:07:11 +03:00
Russ White
f727c6ae8a
Merge pull request #9837 from idryzhov/cleanup-if-by-name-vrf-all
*: fix usage of if_lookup_by_name_all_vrf
2021-10-27 15:29:39 -04:00
Russ White
a2b52cbeb4
Merge pull request #9854 from opensourcerouting/zapi-call-table
*: convert zclient callbacks to table
2021-10-26 11:33:44 -04:00
Donald Sharp
d9654571f9
Merge pull request #9316 from ton31337/fix/send_best_path_reason_for_zebra
bgpd: Send BGP best path reason to Zebra
2021-10-25 11:09:20 -04:00
David Lamparter
a243d1db93 *: convert zclient callbacks to table
This removes a giant `switch { }` block from lib/zclient.c and
harmonizes all zclient callback function types to be the same (some had
a subset of the args, some had a void return, now they all have
ZAPI_CALLBACK_ARGS and int return.)

Apart from getting rid of the giant switch, this is a minor security
benefit since the function pointers are now in a `const` array, so they
can't be overwritten by e.g. heap overflows for code execution anymore.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2021-10-20 13:28:46 +02:00
Anuradha Karuppiah
a383bfc7c9 bgpd: lttng tracepoint for local events received from zebra
TPs -
=====
root@ibm-2410a1-01:mgmt:~# lttng list --userspace |grep frr_bgp:evpn.*recv
      frr_bgp:evpn_local_l3vni_del_zrecv (loglevel: TRACE_INFO (6)) (type: tracepoint)
      frr_bgp:evpn_local_l3vni_add_zrecv (loglevel: TRACE_INFO (6)) (type: tracepoint)
      frr_bgp:evpn_local_macip_del_zrecv (loglevel: TRACE_INFO (6)) (type: tracepoint)
      frr_bgp:evpn_local_macip_add_zrecv (loglevel: TRACE_INFO (6)) (type: tracepoint)
      frr_bgp:evpn_local_vni_del_zrecv (loglevel: TRACE_INFO (6)) (type: tracepoint)
      frr_bgp:evpn_local_vni_add_zrecv (loglevel: TRACE_INFO (6)) (type: tracepoint)
      frr_bgp:evpn_mh_local_es_evi_del_zrecv (loglevel: TRACE_INFO (6)) (type: tracepoint)
      frr_bgp:evpn_mh_local_es_evi_add_zrecv (loglevel: TRACE_INFO (6)) (type: tracepoint)
      frr_bgp:evpn_mh_local_es_del_zrecv (loglevel: TRACE_INFO (6)) (type: tracepoint)
      frr_bgp:evpn_mh_local_es_add_zrecv (loglevel: TRACE_INFO (6)) (type: tracepoint)
root@ibm-2410a1-01:mgmt:~#

Sample output -
===============
1. ES
frr_bgp:evpn_mh_local_es_add_zrecv {'esi': '03:44:38:39:ff:ff:01:00:00:01', 'vtep': '27.0.0.15', 'active': 0, 'bypass': 0, 'df_pref': 50000}
frr_bgp:evpn_mh_local_es_del_zrecv {'esi': '03:44:38:39:ff:ff:01:00:00:01'}

2. ES-EVI
frr_bgp:evpn_mh_local_es_evi_add_zrecv {'esi': '03:44:38:39:ff:ff:01:00:00:01', 'vni': 1004}
frr_bgp:evpn_mh_local_es_evi_del_zrecv {'esi': '03:44:38:39:ff:ff:01:00:00:01', 'vni': 1001}

3. L2-VNI
frr_bgp:evpn_local_vni_add_zrecv {'vni': 1004, 'vtep': '27.0.0.15', 'mc_grp': '239.1.1.104', 'vrf': 97}

4. L3-VNI
frr_bgp:evpn_local_l3vni_add_zrecv {'vni': 4001, 'vrf': 87, 'svi_rmac': '24:8a:07:cc:aa:5f', 'vrr_rmac': '24:8a:07:cc:aa:5f', 'vtep': '27.0.0.15', 'filter': 0, 'svi_ifindex': 95, 'anycast_mac': 'n'
frr_bgp:evpn_local_l3vni_del_zrecv {'vni': 4003, 'vrf': 107}

5. MAC-IP
frr_bgp:evpn_local_macip_add_zrecv {'vni': 1003, 'mac': '00:02:00:00:00:04', 'ip': 'fe80::202:ff:fe00:4', 'flags': 4, 'seq': 0, 'esi': '03:44:38:39:ff:ff:01:00:00:02'}
frr_bgp:evpn_local_macip_del_zrecv {'vni': 1000, 'mac': '00:02:00:00:00:04', 'ip': '2001:fee1::4', 'state': 1}

Signed-off-by: Anuradha Karuppiah <anuradhak@nvidia.com>
2021-10-15 10:37:02 -07:00
Igor Ryzhov
de4f1a66fb bgpd: don't use if_lookup_by_name_all_vrf
if_lookup_by_name_all_vrf doesn't work correctly with netns VRF backend
as the same index may be used in multiple netns simultaneously.

Use the appropriate VRF when looking for the interface.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-10-15 03:42:52 +03:00
Donatas Abraitis
1d7260a1b5 bgpd: Send BGP best path reason to Zebra
```
exit1-debian-9# show ip route 172.16.16.1/32
Routing entry for 172.16.16.1/32
  Known via "bgp", distance 20, metric 0, best
  Last update 00:00:28 ago
  * 192.168.0.2, via eth1, weight 1
    AS-Path          : 65003
    Communities      : first 65001:2 65001:3
    Large-Communities: 65001:1:1 65001:1:2 65001:1:3
    Selection reason : First path received
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-10-14 16:52:47 +03:00
David Lamparter
c5726f0314
Merge pull request #9676 from donaldsharp/import_register 2021-10-13 22:28:03 +02:00
Donald Sharp
f3d20a2aa5 bgpd: When removing v6 address being used as a nexthop ensure peer is reset
With v6 interface based peering, we send the global as well as the LL address
as nexthops to the peer.  When either of these were removed on the interface
we were not necessarily resetting the connection.  Leaving bgp in a state
where the peer had reachability for addresses that are no longer in use.

Modify the code that when we receive an interface address deletion
event.  Check to see that we are using the v6 address as nexthops
for that peer and if so, tell it to reset.

I initially struggled with a hard reset of the peer or a clear but
choose to follow other places in the code that we noticed address
changes that resulted in hard resets.

Ticket: #2799568
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-10-04 08:03:38 -04:00
Donald Sharp
3d174ce08d *: Remove the ZEBRA_IMPORT_ROUTE_XXX zapi messages
These are no longer really needed.  The client just needs
to call nexthop resolution instead.

So let's remove the zapi types.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-09-27 12:38:08 -04:00
Quentin Young
83caa5e5c1
Merge pull request #9638 from proelbtn/fix-multipath-srv6-sid 2021-09-24 14:58:12 -04:00
Ryoga Saito
cd18af00c8 bgpd: fix mpls nexthop announce to zebra
currently, has_valid_label is only used to check need to print debug,
but if route has normal nexthops and mpls nexthops, label information
will be printed even for normal nexthops.

Signed-off-by: Ryoga Saito <ryoga.saito@linecorp.com>
2021-09-22 04:58:59 +00:00
Ryoga Saito
09e06fcfac bgpd: fix annouce for multipath SRv6 SID routes
In current implementation, only last path in mpinfo is treated as seg6
nexthop, but all paths should be treated as seg6 nexthop.

Signed-off-by: Ryoga Saito <ryoga.saito@linecorp.com>
2021-09-21 17:07:47 +00:00
Russ White
2075387e77
Merge pull request #9546 from proelbtn/add-support-for-perfix-sid-type-5
Add support for Prefix-SID (Type 5)
2021-09-21 11:36:53 -04:00
Ryoga Saito
16f3db2d8c bgpd: add sid struct info to bgp_path_info_extra
add SID structure information to bgp_path_info_extra to use structure
data in other places.

Signed-off-by: Ryoga Saito <contact@proelbtn.com>
2021-09-14 16:54:31 +00:00
Igor Ryzhov
b8c01bba53
Merge pull request #9486 from slankdev/slankdev-srv6-no-cli-1
CLI to delete SRv6 locator
2021-09-14 19:04:03 +03:00
Hiroki Shirokura
0249b8b612 bgpd: add no-cli for srv6 on bgpd-side
(1) Implement zapi wrapper func to release srv6-locator-chunk

(2) Implement no locator NAME command
router bgp 1
 segment-routing srv6
  no locator loc1

(3) Implement no segment-routing srv6 command
router bgp 1
 no segment-routing srv6

Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-09-13 22:38:25 +00:00
Hiroki Shirokura
d79ff732cd bgpd: handle srv6 locator notification and update vpn-rib
Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-09-07 12:54:39 +00:00
Kantesh Mundaragi
0789eb69e5 bgpd: VRF-Lite fix nexthop type
Description:
Change is intended for fixing the following issues related to vrf route leaking:

Routes with special nexthops i.e. blackhole/sink routes when imported,
are not programmed into the FIB and corresponding nexthop is set as 'inactive',
nexthop interface as 'unknown'.

While importing/leaking routes between VRFs, in case of special nexthop(ipv4/ipv6)
once bgp announces route(s) to zebra, nexthop type is incorrectly set as
NEXTHOP_TYPE_IPV6_IFINDEX/NEXTHOP_TYPE_IFINDEX
i.e. directly connected even though we are not able to resolve through an interface.
This leads to nexthop_active_check marking nexthop !NEXTHOP_FLAG_ACTIVE.
Unable to find the active nexthop(s), route is not programmed into the FIB.

Whenever BGP leaks routes, set the correct nexthop type, so that route gets resolved
and correctly programmed into the FIB, in the imported vrf.

Co-authored-by: Kantesh Mundaragi <kmundaragi@vmware.com>
Signed-off-by: Iqra Siddiqui <imujeebsiddi@vmware.com>
2021-09-07 01:50:06 -07:00
Igor Ryzhov
2ebb354c41 bgpd: fix update-source for ipv6
There's no IPv6 LL address on loopback/vrf interfaces. So if the user
configures update-source, the session is never going to be established.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-08-26 13:07:55 +03:00
Philippe Guibert
bbf32574e2 bgpd: fix uninitialised segs6 buffer
Below dump may be observed when receiving bgp ipv6 updates.

2021/08/25 16:52:32 BGP: [V15FP-4CPVK] Tx route add VRF 0 4004::1/128 metric 0 tag 0 count 1 nhg 0
2021/08/25 16:52:32 BGP: [JQXM8-V0CKB]   nhop [1]: 2003::4 if 0 VRF 0 wt 0  P8�o�

Fix it.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-08-25 16:57:18 +02:00
Donald Sharp
957f74c302 bgpd: Store distance received from a redistribute statement
When bgp receives the admin distance from a redistribution statement
let's store that distance for later usage.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-08-07 20:27:45 -04:00
Philippe Guibert
7afeaffa12 bgpd: flowspec redirect vrf uses vrf table instead of allocated table id
Until now, when bgp flowspec entry action was to redirect to a vrf, a
default route was installed in a specific table. that route was a vrf
route leak one. The process can be simplified, as vrf-lite already
has a table identifier. Actually, because policy routing is used to
redirect traffic to a defined table (with ip rule command), use
the table identifier of the VRF.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-08-01 14:38:13 +02:00
Jafar Al-Gharaibeh
213d980ff9
Merge pull request #9007 from donaldsharp/pbr_stuff
add ability to match on proto to pbr
2021-07-27 15:09:29 -05:00
Philippe Guibert
abe6805421 bgpd: associate correct nexthop when using peer link-local
When setting bgp configuration using peers referencing link local
ipv6 addresses, the bgp should be able to handle incoming bgp
connections, and find out the appropriate interface where the
connection comes from.

ipv6 link local sessions work by using bgp unnumbered interfaces
config, but it does not work if we have a shared media with
multiple potential link local ipv6 addresses on the network.

The fix consists in finding out the appropriate interface, when
the local configuration references a link local ipv6 addresses,
and the source address used references an interface. below
configuration illustrates what can be done then:

neighbor fe80::4113:5bba:2b61:b20c remote-as 55
neighbor fe80::4113:5bba:2b61:b20c update-source eth0

note: this change does not solve the ability for such config to
create an outgoing connection to remote peer (as the link local
ipv6 address config does not indicate which interface to use).

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2021-07-12 09:23:22 +02:00
Donald Sharp
f56697eff3 bgpd, pbrd, zebra: Encode/decode the ip proto from daemons to zebra
Ensure that we properly encode/decode the ip protocol from daemons
to zebra.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-07-08 11:12:47 -04:00
Donald Sharp
dac42f2ef5 bgpd: Ensure v6 LL address is available before establishing peering
There are startup situations where we will attempt to connect to a remote
peer before bgp has received the v6 LL address.  If we do not have this address
we must not allow the connection to come up until we have one available to use
in those situations where we must have a v6 LL address.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-06-30 10:33:21 -04:00
Donald Sharp
b2c42dda96
Merge pull request #8853 from ton31337/fix/bgp_dest_lock_unlock
bgpd: Make sure we don't miss to unlock for bgp_dest before returning
2021-06-23 07:59:32 -04:00
Donatas Abraitis
e71ad4b64e bgpd: Make sure we don't miss to unlock for bgp_dest before returning
bgp_node_lookup() increases `lock` which is not decreased on return.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-06-22 23:14:47 +03:00
Ameya Dharkar
9daa5d471a bgpd, zebra: Add svi_interface to zebra VNI and bgp EVPN structures
SVI ifindex for L2VNI is required in BGP to perform EVPN type-5 to type-2
recusrsive resolution using gateway IP overlay index.

Program this svi_ifindex in struct zebra_vni_t as well as in struct bgpevpn

Changes include:
1. Add svi_if field to struct zebra_evpn_t
2. Add svi_ifindex field to struct bgpevpn
3. When SVI (bridge or VLAN) is bound to a VxLAN interface, store it in the
zebra_evpn_t structure.
4. Add this SVI ifindex to ZEBRA_VNI_ADD
5. Store svi_ifindex in struct bgpevpn

Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
2021-06-07 17:58:23 -07:00
Ameya Dharkar
a2299abae8 bgpd: Import received EVPN RT-5 prefix with gateway IP in BGP VRF
The IP/IPv6 prefix carried with EVPN RT-5 is imported in the BGP vrf according
to the attached route targets.
If the prefix carries a gateway IP overlay index, this gateway IP should be
installed as the nexthop of the route imported in the BGP vrf.
This route in vrf will be marked as VALID only if the nexthop is resolved in the
SVI network.
To receive runtime reachability information for the nexthop, register it with
the nexthop tracking module.
Send this route to zebra after processing.

Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
2021-06-07 17:58:22 -07:00
Donald Sharp
feb1723846 bgpd: Convert to using peer_established(peer) function
We are inconsistently using peer_establiahed(peer) with
sometimes using `peer->status == Established`.  Just Convert
over to using the function for consistency.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-06-07 10:48:36 -04:00
Hiroki Shirokura
c60c1ade86 *: delete ZEBRA_FLAG_SEG6*_ROUTE and add ZAPI_NEXTHOP_FLAG_SEG6*
https://github.com/FRRouting/frr/pull/5865#discussion_r597670225

As this comment says. ZEBRA_FLAG_XXX should not have been used.
To communicate SRv6 Route Information. A simple Nexthop Flag would
have been sufficient for SRv6 information. And I fixed the whole
thing that way.

Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:48 -04:00
Hiroki Shirokura
0548592691 *: eliminate redundant info from srv6 locator zapi
Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:48 -04:00
Hiroki Shirokura
1bda3e627d *: use one line init instead of memset and format it
Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:48 -04:00
Hiroki Shirokura
3a0220e46a bgpd: use zapi_srv6_locator_chunk_decode
Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:48 -04:00
Hiroki Shirokura
7de4c88525 *: fix code format accourding to checkpatch
Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:48 -04:00
Hiroki Shirokura
53a4de82ec bgpd: install vpn's transit route using H.Encaps (step4)
This commit make bgpd to support install H.Encaps(seg6 mode segs) routes
when VPN-prefix has Prefix-sid.

Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:48 -04:00
Hiroki Shirokura
a0281b2eab bgpd: cli for srv6-locator assignment (step4)
This commit add command to speficy SRv6 locator for BGP SRv6-VPN.
CLI example is follow. CLI block of "segment-routing" is already
implemented by previous commits and it's managed by zebra.

Zebra manage just the ownership of locator's prefix.
Zlient can request to get srv6-locator's prefix chunk using
srv6_manager_get_locator_chunk() which is usuful func to
execute ZEBRA_SRV6_MANAGER_GET_LOCATOR_CHUNK api. This request
is wokring as async, And zebra calls same api to Zclients when
zebra allocate locator prefix chunk.

And then, finally zclient(bgpd) catch the information via
process_srv6_lcoator_chunk callback function.

router bgp 1
 segment-routing srv6
  locator loc1
 !
!
segment-routing
 srv6
  locators
   locator loc1
    prefix 2001:db8:1:1::/64
   !
  !
 !
!

[POINT_OF_REVIEW]
In current implementation, user can just configure srv6 locator
but user can't de-configure srv6 locator.

Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
2021-06-02 10:24:48 -04:00
Mark Stapp
2d3eb91699
Merge pull request #8498 from ton31337/feature/opaque_data_void_zebra
Zebra OPAQUE data from other daemons stuff
2021-05-24 07:48:02 -04:00
Igor Ryzhov
6bfcd0f14a bgpd: fix zebra bfd registration
If there's no default router configured at the moment when bgpd is
connected to zebra, bgpd is not registered as a BFD client.

We should do the registration regardless of the config existence.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-05-18 23:31:52 +03:00
Donatas Abraitis
94effaf032 zebra: Send more OPAQUE data from BGP
This includes community and large-community data.

```
exit1-debian-9# show ip route 172.16.16.1/32
Routing entry for 172.16.16.1/32
  Known via "bgp", distance 20, metric 0, best
  Last update 00:00:23 ago
  * 192.168.0.2, via eth1, weight 1
    AS-Path          : 65030
    Communities      : 65001:1 65001:2 65001:3 65001:4 65001:5 65001:6
    Large-Communities: 65001:123:1 65001:123:2
```

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-05-14 22:12:33 +03:00
Russ White
a63273a5b4
Merge pull request #8556 from donaldsharp/bgp_pbr_weird
Bgp flowspec cleanups
2021-05-13 23:14:34 -04:00
Donald Sharp
cc42c4f00c bgpd: use __func__ instead of __PRETTY_FUNCTION__
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-05-12 12:00:23 -04:00
Donald Sharp
70492deafc bgpd: Remove usage of prefix2str and use builtin in bgp_zebra.c
Convert over from prefix2str explicit call and use the builtin
%pFX we have now.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2021-05-12 07:33:08 -04:00
Igor Ryzhov
6cc0114b6e bgpd: deregister bgp instance from zebra when vrf is deleted
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-05-10 01:22:34 +03:00
Igor Ryzhov
d9083050c8 Revert "bgpd: vrf route leaking, fix vrf redistribute"
This reverts commit 6b2433c63f.
2021-05-09 22:28:36 +03:00
Quentin Young
bbad027684 lib, bgpd, zebra: RA interval is unsigned
Use unsigned value for all RA requests to Zebra

- encoding signed int as unsigned is bad practice
- RA interval is never, and should never be, negative

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2021-04-28 11:43:50 -04:00
Abhinay Ramesh
6b2433c63f bgpd: vrf route leaking, fix vrf redistribute
Description:
After FRR restart, routes are not getting redistributed;
when routes added first and then 'redistribute static' cmd is issued.

During the frr restart, vrf_id will be unknown,
so irrespective of redistribution, we set the redistribute vrf bitmap.
Later, when we add a route and then issue 'redistribute' cmd,
we check the redistribute vrf bitmap and return CMD_WARNING;
zebra_redistribute_add also checks the redistribute vrf bitmap and returns.

Instead of checking the redistribute vrf bitmap, always set it anyways.

Co-authored-by: Santosh P K <sapk@vmware.com>
Co-authored-by: Kantesh Mundaragi <kmundaragi@vmware.com>
Signed-off-by: Abhinay Ramesh <rabhinay@vmware.com>
2021-04-07 06:09:42 +00:00
Russ White
40bf85a391
Merge pull request #8056 from jmmikkel/peertype
bgpd: Add "bgp bestpath peer-type multipath-relax"
2021-03-30 10:26:57 -04:00