Commit Graph

302 Commits

Author SHA1 Message Date
Donatas Abraitis
2dbe669bdf :* Convert prefix2str to %pFX
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-10-22 09:07:41 +03:00
Donald Sharp
cd7f9b1711
Merge pull request #7323 from ton31337/fix/inet_ntoa_to_pFX_master
bgpd: Convert inet_ntoa to %pI4
2020-10-20 09:10:24 -04:00
Donatas Abraitis
23d0a75356 bgpd: Convert inet_ntoa to %pI4/inet_ntop
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-10-18 11:22:30 +03:00
Donald Sharp
c10e14e96d *: Create/Use accessor functions for lock count
Create appropriate accessor functions for the rn->lock
data.  We should be accessing this data through accessor
functions since it is private data to the data structure.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-10-17 13:39:10 -04:00
Donatas Abraitis
0dc8647094
Merge pull request #7306 from donaldsharp/bgp_dest_print
Bgp dest print
2020-10-17 20:21:52 +03:00
Donald Sharp
752eed47ef bgpd: Use bgp_dest_get_prefix accessor function
Use the appropriate bgp_dest_get_prefix accessor function

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-10-17 08:52:35 -04:00
Donald Sharp
09319b4e0f bgpd: More bgp_node -> bgp_dest cleanup
Some more of the bgp_node usage snuck in from big commits in
the past month or so from feature work.  Do some work
to put it back to bgp_dest for incoming future work.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-10-17 08:52:35 -04:00
David Lamparter
56ca3b5b3a bgpd: add %pBD for printing struct bgp_dest *
`%pRN` is not appropriate anymore.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-10-17 08:52:35 -04:00
Pat Ruddy
f137734bb4 bgpd: replace bgp_evpn_route2str with prefix2str
Remove bgp_evpn_route2str and replace calls with prefix2str

Signed-off-by: Pat Ruddy <pat@voltanet.io>
2020-10-16 11:54:30 +01:00
Quentin Young
84f22ecc05 bgpd: fix ecom leak handling l3vni update
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-09-15 16:06:58 -07:00
Philippe Guibert
4371bf9110 bgpd: remove warnings related to line too longs in bgp code
remove warnings related to line too long in bgp code.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-08-21 13:37:08 +02:00
Philippe Guibert
34540b0d7f bgpd: fill in local ecommunity context with ecom unit length
because the same extended community can be used for storing ipv6 and
ipv4 et communities, the unit length must be stored. do not forget to
set the standard value in bgp evpn.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-08-21 13:37:08 +02:00
Rafael Zalamena
be8d09f125
Merge pull request #6924 from AnuradhaKaruppiah/mem-fixes
bgpd: fixes for problems found during EVPN fuzzing
2020-08-20 14:12:51 +00:00
Renato Westphal
4fe5bc8c62
Merge pull request #6943 from ton31337/fix/replace_sizeof_instead_of_constant_for_bgp_dump_attr
bgpd: Use sizeof() in bgp_dump_attr()
2020-08-19 07:36:13 -03:00
Donatas Abraitis
5022c8331d bgpd: Use sizeof() in bgp_dump_attr()
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-08-18 21:43:07 +03:00
Quentin Young
e121d83163 bgpd: fix bad heap reads in type-2 nlri parsing
Various forms of corrupt packets could trigger reads of garbage heap.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-08-15 08:24:59 -07:00
Anuradha Karuppiah
9c7edc03b8 bgpd: Type-2/MAC-IP SYNC route handling
SYNC routes are paths rxed from a local-ES peer. These routes result in
the installation of local dataplane entries i.e. with access port as
destination (vs. the remote-VTEP destination that results in the packet
being sent via the VxLAN overlay).

If a SYNC path is selected as the best path it is always turned around
into a local path which immediately lowers the status of the SYNC path
to non-best. However we need to keep track of the highest MM seq-number
and peer activity to continue advertising the local path. In order to
do that we need information from the "second-best" SYNC path to be
bubbled up to the local best path. This "SYNC" info is then consolidated
and sent to zebra which is responsible for the MM handling and local
path management.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-08-05 06:46:13 -07:00
Anuradha Karuppiah
c44ab6f1f3 bgpd: support for Ethernet Segments and Type-1/EAD routes
This is the base patch that brings in support for Type-1 routes.
It includes support for -
- Ethernet Segment (ES) management
- EAD route handling
- MAC-IP (Type-2) routes with a non-zero ESI i.e. Aliasing for
  active-active multihoming
- Initial infra for consistency checking. Consistency checking
  is a fundamental feature for active-active solutions like MLAG.
  We will try to levarage the info in the EAD-ES/EAD-EVI routes to
  detect inconsitencies in access config across VTEPs attached to
  the same Ethernet Segment.

Functionality Overview -
========================
1. Ethernet segments are created in zebra and associated with
access VLANs. zebra sends that info as ES and ES-EVI objects to BGP.
2. BGP advertises EAD-ES and EAD-EVI routes for the locally attached
ethernet segments.
3. Similarly BGP processes EAD-ES and EAD-EVI routes from peers
and translates them into ES-VTEP objects which are then sent to zebra
as remote ESs.
4. Each ES in zebra is associated with a list of active VTEPs which
is then translated into a L2-NHG (nexthop group). This is the ES
"Alias" entry
5. MAC-IP routes with a non-zero ESI use the alias entry created in
(4.) to forward traffic i.e. a MAC-ECMP is done to these remote-ES
destinations.

EAD route management (route table and key) -
============================================
1. Local EAD-ES routes
a. route-table: per-ES route-table
key: {RD=ES-RD, ESI, ET=0xffffffff, VTEP-IP)
b. route-table: per-VNI route-table
Not added
c. route-table: global route-table
key: {RD=ES-RD, ESI, ET=0xffffffff)

2. Remote EAD-ES routes
a. route-table: per-ES route-table
Not added
b. route-table: per-VNI route-table
key: {RD=ES-RD, ESI, ET=0xffffffff, VTEP-IP)
c. route-table: global route-table
key: {RD=ES-RD, ESI, ET=0xffffffff)

3. Local EAD-EVI routes
a. route-table: per-ES route-table
Not added
b. route-table: per-VNI route-table
key: {RD=0, ESI, ET=0, VTEP-IP)
c. route-table: global route-table
key: {RD=L2-VNI-RD, ESI, ET=0)

4. Remote EAD-EVI routes
a. route-table: per-ES route-table
Not added
b. route-table: per-VNI route-table
key: {RD=0, ESI, ET=0, VTEP-IP)
c. route-table: global route-table
key: {RD=L2-VNI-RD, ESI, ET=0)

Please refer to bgp_evpn_mh.h for info on how the data-structures are
organized.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-08-05 06:46:12 -07:00
Anuradha Karuppiah
0a50c24813 bgpd: attr changes for EAD routes
Add ESI as an inline attribute field along with the other EVPN
attributes. This may be re-worked when the rest of the EVPN
attributes find a new home.

Some cleanup has been done to get rid of stale/unused references
to ESI. And also to consolidate duplicate definitions of ES ID
types.

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-08-05 06:46:12 -07:00
Anuradha Karuppiah
185fb14a41 bgpd: pull the multihoming code out to a separate file
Re-org only; no other code changes. This is being done to make maintanence
of MH functionality (which will have more code added to it) easy.

The code moved here was originally committed via -
'commit 50f74cf131 ("*: support for evpn type-4 route")'

Signed-off-by: Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
2020-08-05 06:46:12 -07:00
Russ White
4267c07425
Merge pull request #6628 from adharkar/frr-master-evpn_rt
bgpd: Incorrect auto-RT formed when L3VNI is not configured
2020-07-05 16:07:10 -04:00
Donald Sharp
9bcb3eef54 bgp: rename bgp_node to bgp_dest
This is the bulk part extracted from "bgpd: Convert from `struct
bgp_node` to `struct bgp_dest`".  It should not result in any functional
change.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-06-23 17:32:52 +02:00
Ameya Dharkar
ebdc9e64c3 bgpd: Incorrect auto-RT formed when L3VNI is not configured
We use ASN:VNI format to calculate auto RT for L3VNI.
When L3VNI is not configured, if we delete the configured RT, incorrect auto-RT
value is generated as VRF VNI is 0.

Fix:
Do not configure auto-RT if L3VNI is not configured.

Trigger:
1. Delete L3VNI
2. Delete configured RT.

Before fix:

dev# sh bgp vrf vrf-blue vni
BGP VRF: vrf-blue
  Local-Ip: 10.100.0.1
  L3-VNI: 0
  Rmac: 00:00:00:00:00:00
  VNI Filter: none
  L2-VNI List:

  Export-RTs:
  RT:101:0
  Import-RTs:
  RT:101:0
  RD: 10.100.0.1:2

After fix:

dev# sh bgp vrf vrf-blue vni
BGP VRF: vrf-blue
  Local-Ip: 10.100.0.1
  L3-VNI: 0
  Rmac: 00:00:00:00:00:00
  VNI Filter: none
  L2-VNI List:

  Export-RTs:

  Import-RTs:

  RD: 10.100.0.1:2

Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
2020-06-22 16:38:48 -07:00
Russ White
eeec40ba69
Merge pull request #6375 from adharkar/frr-master-l3vni_label
bgpd: EVPN RT-2 advertised with 2 labels for prefix-routes-only config
2020-05-26 12:14:16 -04:00
Sri Mohana Singamsetty
06fba5cb4c
Merge pull request #6463 from vivek-cumulus/evpn_extend_nht
bgpd: Extend EVPN next hop tracking for additional EVPN routes
2020-05-26 08:18:29 -07:00
vivek
e11329ca4c bgpd: Extend EVPN next hop tracking for additional EVPN routes
Extend the next hop tracking for type-2 and type-3 EVPN routes also.

Updates: "bgpd: Add nexthop of received EVPN RT-5 for nexthop tracking"
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2020-05-25 23:00:49 -07:00
vivek
5f0c5ec85d bgpd: Minor tweaks to EVPN route-import debugs
Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2020-05-25 14:06:10 -07:00
Ameya Dharkar
10f70510b9 bgpd: EVPN RT-2 advertised with 2 labels for prefix-routes-only config
L3VNI is configured with "prefix-routes-only" flag. Even in this case,
intermittently, we observed that local EVPN MACIP routes are installed and
advertised with 2 labels and 2 export RTs.

This is a sequencing issue. Consider following case where L2VNI 200 and L3VNI
1000 are configured for tenant vrf vrf-blue.

Bug is observed for following sequence of events:
1. vrf-blue BGP instance is created.
2. L2VNI is created in bgp for vni 200. It is linked to the tenant vrf vrf-blue
in function bgpevpn_link_to_l3vni.
Following code sets "VNI_FLAG_USE_TWO_LABELS" flag for vni 200 as L3VNI is not
yet attached to vrf-blue BGP instance.

/* check if we are advertising two labels for this vpn */
if (!CHECK_FLAG(bgp_vrf->vrf_flags, BGP_VRF_L3VNI_PREFIX_ROUTES_ONLY))
	SET_FLAG(vpn->flags, VNI_FLAG_USE_TWO_LABELS);

2. Now L3VNI is attached to vrf-blue BGP instance. In this case, we set
BGP_VRF_L3VNI_PREFIX_ROUTES_ONLY flag for vrf-blue but we do not clear
VNI_FLAG_USE_TWO_LABELS flag set on the corresponding L2VNIs.

This fix resolves following 2 issues observed above.
1. When L2VNI is created in BGP, flag VNI_FLAG_USE_TWO_LABELS should not be set
for this VNI if BGP vrf is not attached to any L3VNI.
2. When L3VNI is attached to the BGP vrf, set "VNI_FLAG_USE_TWO_LABELS" flag
if "prefix-routes-only" is not for the vrf.

UT cases:
1. Flap "prefix-routes-only" config for a vrf.
2. Test following triggers for vrfs with and without "prefix-routes-only"
   - Flap L2VNI from kernel.
   - Flap L3VNI from kernel.

Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
2020-05-08 21:10:10 -07:00
Quentin Young
772270f3b6 *: sprintf -> snprintf
Replace sprintf with snprintf where straightforward to do so.

- sprintf's into local scope buffers of known size are replaced with the
  equivalent snprintf call
- snprintf's into local scope buffers of known size that use the buffer
  size expression now use sizeof(buffer)
- sprintf(buf + strlen(buf), ...) replaced with snprintf() into temp
  buffer followed by strlcat

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-04-20 19:14:33 -04:00
Donatas Abraitis
c4efd0f423 *: Do not cast to the same type
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-04-08 17:15:06 +03:00
vivek
feca4f1e67 bgpd: Ensure RMAC extended community is unique
The BGP Router MAC extended community should be unique and not occur
multiple times. In a VRF-to-VRF route-leak scenario where EVPN routes
from a source VRF are leaked into the target VRF and then injected
back into EVPN from the target VRF, the resulting route had more than
one RMAC. With this fix, the resulting route will have only the
target VRF's RMAC.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2020-03-30 20:12:32 -07:00
vivek
fab92da7ca bgpd: Allow generating EVPN type-5 routes with existing extended community
The EVPN advertise route-map may generate extended communities for an IPv4
or IPv6 route injected into EVPN as type-5. If so, allow for it and add
to it.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Don Slice <dslice@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-30 20:12:32 -07:00
vivek
b1875e656c bgpd: Additional options for generating link bandwidth
Implement the code to handle the other route-map options to generate
the link bandwidth, namely, to use the cumulative bandwidth or to
base this on the number of multipaths. In the latter case, a reference
bandwidth is internally chosen - the implementation uses a value of
1 Gbps.

These additional options mean that the prefix may need to be advertised
if there is a link bandwidth change, which is a new criteria. Define a
new path (change) flag to support this and implement the advertisement.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by:   Don Slice <dslice@cumulusnetworks.com>
2020-03-30 20:12:31 -07:00
vivek
1207a5bc9b bgpd: Ability to add/update unique extended communities
Certain extended communities cannot be repeated. An example is the
BGP link bandwidth extended community. Enhance the extended community
add function to ensure uniqueness, if requested.

Note: This commit does not change the lack of uniqueness for any of
the already-supported extended communities. Many of them such as the
BGP route target can obviously be present multiple times. Others like
the Router's MAC should most probably be present only once. The portions
of the code which add these may already be structured such that duplicates
do not arise.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
2020-03-30 20:12:31 -07:00
Donald Sharp
b54892e0ea bgpd: Convert users of rn->p to use accessor function
Add new function `bgp_node_get_prefix()` and modify
the bgp code base to use it.

This is prep work for the struct bgp_dest rework.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-26 16:25:16 -04:00
Donald Sharp
5f040085ba lib, bgpd: Another round of struct const prefix cleanup
Cleanup another set of functions that need to respect the
const'ness of a prefix.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-26 16:22:00 -04:00
Donald Sharp
5a1ae2c237 bgpd: Rework code to use const struct prefix
Future work needs the ability to specify a
const struct prefix value.  Iterate into
bgp a bit to get this started.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-24 07:51:41 -04:00
Donald Sharp
bd494ec5ed bgpd: More const struct prefix work
Modify more code to use `const struct prefix` throughout
bgp.  This is all prep work for adding an accessor function
for bgp_node to get the prefix and reduce all the places that
code needs to be touched when we get that work done.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-22 14:50:46 -04:00
vivek
e34291b86a bgpd: Allow EVPN advertise route-map to modify attributes
Ensure that the EVPN advertise route-map is applied on a copy of the
original path_info and associated attribute, so that if the route-map
has SET clauses, they can operate properly. This closely follows
the model already in use in other route-map application code.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Don Slice <dslice@cumulusnetworks.com>
Reviewed-by:   Donald Sharp <sharpd@cumulusnetworks.com>
2020-03-19 14:21:23 -07:00
Donatas Abraitis
15569c58f8 *: Replace __PRETTY_FUNCTION__/__FUNCTION__ to __func__
Just keep the code cool.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-05 20:23:23 +02:00
Kishore Aramalla
c6ec0c745a bgpd: RFC compliance wrt invalid RMAC, GWIP, ESI and VNI
A route where ESI, GW IP, MAC and Label are all zero at the same time SHOULD
be treat-as-withdraw.
Invalid MAC addresses are broadcast or multicast MAC addresses. The route
MUST be treat-as-withdraw in case of an invalid MAC address.

As FRR support Ethernet NVO Tunnels only.
Route will be withdrawn when ESI, GW IP and MAC are zero or Invalid MAC

Test cases:
1) ET-5 route with valid RMAC extended community
2) ET-5 route no RMAC extended community
3) ET-5 route with Multicast MAC in RMAC extended community
4) ET-5 route with Broadcast MAC in RMAC extended community

Signed-off-by: Kishore Aramalla <karamalla@vmware.com>
2020-02-11 12:36:50 -08:00
Ameya Dharkar
4e72ff729d bgpd: EVPN crash because of incorrect nexthop for IPv6 prefix
RCA:
When we install IPv6 prefix imported from EVPN RT-5 in vrf, nexthop of the IPv6
route should be IPv4 mapped IPv6 address. In function
install_evpn_route_entry_in_vrf, we generate a new attribute with IPv4 mapped
IPv6 nexthop, but we use parent->attr while creating the actual route.
Thus, Ipv4 nexthop is assigned to this route.
Because of this incorrect nexthop, we observed a crash in function
update_ipv6nh_for_route_install.

Fix:
Pass the new attribute with Ipv4 mapped Ipv6 nexthop to
bgp_create_evpn_bgp_path_info

Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
2020-02-06 13:51:46 -08:00
Philippe Guibert
d846e91701 bgpd: import evpn entries with nexthop self attribute
import epvn entries with nexthop self attribute.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-01-08 18:18:58 +01:00
Santosh P K
a3a850a17d bgpd: fix unaligned access to addpath id
uint8_t * cannot be cast to uint32_t * unless the
pointed-to address is aligned according to uint32_t's
alignment rules. And it usually is not.

Signed-off-by: Santosh P K <sapk@vmware.com>
2020-01-07 07:47:13 -08:00
Donald Sharp
4f63093247
Merge pull request #4765 from opensourcerouting/defaults-v2
lib/*: new config defaults system, v2
2019-12-06 14:07:42 -05:00
David Lamparter
5d5393b943 bgpd: use new defaults system (v2)
This moves all the DFLT_BGP_* stuff over to the new defaults mechanism.
bgp_timers_nondefault() added to get better file-scoping.

v2: moved everything into bgp_vty.c so that the core BGP code is
independent of the CLI-specific defaults.  This should make the future
northbound conversion easier.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-12-06 15:13:32 +01:00
Quentin Young
6f4f49b237 bgpd: remove bgp_attr_dup
yeah

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-12-05 11:05:32 -05:00
Sri Mohana Singamsetty
da579bf9ff
Merge pull request #5432 from chiragshah6/evpn_dev2
bgpd: Handle possible non-selection of local route
2019-12-02 17:17:26 -08:00
Chirag Shah
7ab604ab79 bgpd: Handle possible non-selection of local route
In rare situations, the local route in a VNI may not get selected as the
best route. One situation is during a race between bgp and zebra which
was addressed in a prior commit. This change addresses another situation
where due to a change of tunnel IP, it is possible that a received route
may be selected as the best route if the path selection needs to take
next hop IPs into consideration. This is a pretty convoluted scenario,
but the code should handle it and delete and withdraw the local route
as well as (re)install the received route.

Ticket: CM-24114
Reviewed By: CCR-9487
Testing Done:
1. Manual tests - note, problem is not readily reproducible
2. evpn-smoke - results documented in the ticket

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2019-11-25 21:41:14 -08:00
Chirag Shah
27727001d7 bgpd: adv pip update type-5 with correct rmac
when a pip is disabled or mac-vlan is not present
use anycast MAC as RMAC value.

Ticket:CM-26923
Reviewed By:CCR-9417
Testing Done:

Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2019-11-22 07:53:40 -08:00