-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bgpd: Add basic support of RFC 4684 - Routing Target (RT) Constrain #13476
Draft
Sohn123
wants to merge
40
commits into
FRRouting:master
Choose a base branch
from
WiMoVE-OSS:bgp-routing-target-constraints
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
e76d547
lib: Add route target constraint SAFI value from RFC 4684
Sohn123 06c87b2
yang: Add yang-model for bgp route target constraint family
Sohn123 d64000b
bgpd: Add configuration for bgp route target constraint SAFI
Sohn123 b5aeab3
bgpd: Add RTC capability to negotiated capabilities
Sohn123 d9b29ac
Add prefix for SAFI_RTC
Sohn123 96bd25a
bgpd: Add static route configuration for SAFI_RTC.
Sohn123 68f3757
bgpd: Add encoding for SAFI_RTC attribute.
Sohn123 28ffa9b
lib,bgpd: Add prefix_list to peer to safe filters for Route target co…
Sohn123 9e85d34
bgpd: Add parsing for SAFI_RTC
Sohn123 3c1deb7
bgpd: Implement filtering via Route target constrain prefix list.
Sohn123 89273f9
bgpd: Improve display of rtc_prefix in show command.
Sohn123 a64b210
bgpd: Put every peer that has Route target constrain configured in se…
Sohn123 c9d377d
bgpd: No declaration after label.
Sohn123 b073cf7
bgpd: Use const pointer and copy value.
Sohn123 389cef7
bgpd: Add prototypes.
Sohn123 8de224e
bgpd: Initialize ret.
Sohn123 ea5501c
bgpd: format bgpd code
Sohn123 1854ce0
lib: Format lib code
Sohn123 393d1fd
vtysh: Format vtysh code
Sohn123 6d77dcc
lib: Add configurable empty_action for plist
Sohn123 99bb2e9
bgpd: Extract RTC code into extra functions and extra file
Sohn123 cf3d201
bgpd: Generate rtc prefixes from vni route-targets
Sohn123 9ba1eb6
bgpd: Remove RTC testcode
Sohn123 330fa84
bgpd: Remove unneccesarry table initialization in bgp_rtc.c
Sohn123 b93cd5c
bgpd: Rename rtc command to rt-constraint
Sohn123 a23bfd9
lib: Remove debug logging statements
Sohn123 d4c4474
bgpd: Remove unused str2prefix_rtc function
Sohn123 1f65c62
bgpd: Replace // with /* in bgp_rtc.c
Sohn123 ae6ac26
bgpd: Remove debug statements.
Sohn123 d015879
bgpd: Add vty output if RTC configuration fails
Sohn123 648af91
bgpd: Remove afi/safi check for rtc filtering to make it applicable f…
Sohn123 bcb5fb8
bgpd: Remove dead assignments
Sohn123 369578d
bgpd: Introduce proper debug statements in bgp_rtc_filter
Sohn123 302b0e5
bgpd: Adapt write_network for SAFI_RTC
Sohn123 296c2d5
bgpd: Fix update group compare function to allow for deletion
Sohn123 446b388
bgpd: correctly delete prefix list on peer close
Sohn123 a70f67f
bgpd: mark path as valid for RTC
Sohn123 5426941
bgpd: Fix use after free of ecommunities
Sohn123 c82e970
bgpd: fix call of bgp_withdraw, and definition of bgp_show_table_rd
Sohn123 4438486
vtysh: move install_node statement for bgp_rtc_node
Sohn123 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
/* BGP routing information | ||
* Copyright (C) 1996, 97, 98, 99 Kunihiro Ishiguro | ||
* Copyright (C) 2016 Job Snijders <[email protected]> | ||
|
@@ -75,6 +74,7 @@ | |
#include "bgpd/bgp_flowspec.h" | ||
#include "bgpd/bgp_flowspec_util.h" | ||
#include "bgpd/bgp_pbr.h" | ||
#include "bgpd/bgp_rtc.h" | ||
|
||
#include "bgpd/bgp_route_clippy.c" | ||
|
||
|
@@ -2515,6 +2515,14 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi, | |
bgp_otc_egress(peer, attr)) | ||
return false; | ||
|
||
/* RTC-Filtering */ | ||
if (peer->afc[AFI_IP][SAFI_RTC]) { | ||
/* The update group should only have one peer */ | ||
onlypeer = SUBGRP_PFIRST(subgrp)->peer; | ||
if (bgp_rtc_filter(onlypeer, attr, p)) | ||
return false; | ||
} | ||
|
||
if (filter->advmap.update_type == UPDATE_TYPE_WITHDRAW && | ||
filter->advmap.aname && | ||
route_map_lookup_by_name(filter->advmap.aname)) { | ||
|
@@ -3549,6 +3557,7 @@ static void bgp_lu_handle_label_allocation(struct bgp *bgp, | |
CHECK_FLAG(dest->flags, BGP_NODE_LABEL_REQUESTED)) { | ||
bgp_unregister_for_label(dest); | ||
} | ||
|
||
} | ||
|
||
static struct interface * | ||
|
@@ -6634,6 +6643,11 @@ static void bgp_nexthop_reachability_check(afi_t afi, safi_t safi, | |
struct bgp *bgp, | ||
struct bgp *bgp_nexthop) | ||
{ | ||
if (safi == SAFI_RTC) { | ||
bgp_unlink_nexthop(bpi); | ||
|
||
bgp_path_info_set_flag(dest, bpi, BGP_PATH_VALID); | ||
} | ||
/* Nexthop reachability check. */ | ||
if (safi == SAFI_UNICAST || safi == SAFI_LABELED_UNICAST) { | ||
if (CHECK_FLAG(bgp->flags, BGP_FLAG_IMPORT_CHECK)) { | ||
|
@@ -6665,12 +6679,12 @@ static void bgp_nexthop_reachability_check(afi_t afi, safi_t safi, | |
} | ||
} | ||
|
||
static struct bgp_static *bgp_static_new(void) | ||
struct bgp_static *bgp_static_new(void) | ||
{ | ||
return XCALLOC(MTYPE_BGP_STATIC, sizeof(struct bgp_static)); | ||
} | ||
|
||
static void bgp_static_free(struct bgp_static *bgp_static) | ||
void bgp_static_free(struct bgp_static *bgp_static) | ||
{ | ||
XFREE(MTYPE_ROUTE_MAP_NAME, bgp_static->rmap.name); | ||
route_map_counter_decrement(bgp_static->rmap.map); | ||
|
@@ -12036,6 +12050,69 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t sa | |
return CMD_SUCCESS; | ||
} | ||
|
||
int bgp_show_table_rtc(struct vty *vty, struct bgp *bgp, safi_t safi, | ||
struct bgp_table *table, enum bgp_show_type type, | ||
void *output_arg, uint16_t show_flags); | ||
int bgp_show_table_rtc(struct vty *vty, struct bgp *bgp, safi_t safi, | ||
struct bgp_table *table, enum bgp_show_type type, | ||
void *output_arg, uint16_t show_flags) | ||
{ | ||
struct bgp_dest *dest, *next; | ||
unsigned long output_cum = 0; | ||
unsigned long total_cum = 0; | ||
struct bgp_table *itable; | ||
bool show_msg; | ||
bool use_json = !!CHECK_FLAG(show_flags, BGP_SHOW_OPT_JSON); | ||
|
||
show_msg = (!use_json && type == bgp_show_type_normal); | ||
|
||
for (dest = bgp_table_top(table); dest; dest = next) { | ||
struct prefix local_p = {}; | ||
const struct prefix *dest_p = bgp_dest_get_prefix(dest); | ||
local_p = *dest_p; | ||
|
||
next = bgp_route_next(dest); | ||
|
||
itable = bgp_dest_get_bgp_table_info(dest); | ||
if (itable != NULL) { | ||
|
||
struct bgp_path_info *pi = | ||
bgp_dest_get_bgp_path_info(dest); | ||
struct ecommunity *ecom = ecommunity_parse( | ||
local_p.u.prefix_rtc.route_target, 8, true); | ||
char *ecomstr = ecommunity_ecom2str( | ||
ecom, ECOMMUNITY_FORMAT_DISPLAY, 0); | ||
vty_out(vty, | ||
"Prefix: \n\tRoute Target: %s/%u\n\tOrigin-as: %u\n", | ||
ecomstr, local_p.prefixlen, | ||
local_p.u.prefix_rtc.origin_as); | ||
XFREE(MTYPE_ECOMMUNITY_STR, ecomstr); | ||
ecommunity_unintern(&ecom); | ||
route_vty_out_detail_header(vty, bgp, dest, &local_p, | ||
NULL, AFI_IP, safi, NULL, | ||
false); | ||
route_vty_out_detail(vty, bgp, dest, &local_p, pi, | ||
AFI_IP, safi, RPKI_NOT_BEING_USED, | ||
NULL); | ||
if (next == NULL) | ||
show_msg = false; | ||
} | ||
} | ||
if (show_msg) { | ||
if (output_cum == 0) | ||
vty_out(vty, "No BGP prefixes displayed, %ld exist\n", | ||
total_cum); | ||
else | ||
vty_out(vty, | ||
"\nDisplayed %ld routes and %ld total paths\n", | ||
output_cum, total_cum); | ||
} else { | ||
if (use_json && output_cum == 0) | ||
vty_out(vty, "{}\n"); | ||
} | ||
return CMD_SUCCESS; | ||
} | ||
|
||
int bgp_show_table_rd(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, | ||
struct bgp_table *table, struct prefix_rd *prd_match, | ||
enum bgp_show_type type, void *output_arg, | ||
|
@@ -12481,6 +12558,7 @@ const struct prefix_rd *bgp_rd_from_dest(const struct bgp_dest *dest, | |
case SAFI_UNICAST: | ||
case SAFI_MULTICAST: | ||
case SAFI_LABELED_UNICAST: | ||
case SAFI_RTC: | ||
case SAFI_FLOWSPEC: | ||
case SAFI_MAX: | ||
return NULL; | ||
|
@@ -16153,7 +16231,28 @@ void bgp_config_write_network(struct vty *vty, struct bgp *bgp, afi_t afi, | |
|
||
p = bgp_dest_get_prefix(dest); | ||
|
||
vty_out(vty, " network %pFX", p); | ||
if (safi == SAFI_RTC) { | ||
/* Only prefixes with a length of more than 48 have the | ||
* type and subtype field set. If those aren't set | ||
* ecommunity_ecom2str returns just UNK: */ | ||
if (p->prefixlen >= 48) { | ||
struct ecommunity *ecom = ecommunity_parse( | ||
(unsigned char *)&p->u.prefix_rtc | ||
.route_target, | ||
8, false); | ||
char *b = ecommunity_ecom2str( | ||
ecom, ECOMMUNITY_FORMAT_ROUTE_MAP, | ||
ECOMMUNITY_ROUTE_TARGET); | ||
vty_out(vty, " rt %s", b); | ||
ecommunity_unintern(&ecom); | ||
XFREE(MTYPE_ECOMMUNITY_STR, b); | ||
} else { | ||
vty_out(vty, " rt 0:0"); | ||
} | ||
vty_out(vty, "/%d", p->prefixlen); | ||
} else { | ||
vty_out(vty, " network %pFX", p); | ||
} | ||
|
||
if (bgp_static->label_index != BGP_INVALID_LABEL_INDEX) | ||
vty_out(vty, " label-index %u", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I always add a static RTC route regardless if the address family is configured for any peer. Is this problematic and if it is, is there a way to check if an address family is configured for at least one peer? I could also add a bgp option like
advertis-all-vni
that toggles the behavior of automatically generating RTC routes. Maybe even independent for l2vpn and l3vpn.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Sohn123, please separate both variables: advertisement versus populating.
I think RTC will be enabled if either L2VPN or L3VPN is enabled on neighbors.
So RTC will be sent in this case.
I know you implemented something for L2VPN, and not for L3VPN.
I would say RTC should be common for both cases: are there many cases where both L3VPN and L2VPN are used?
about #13476 (comment),
I understand, RTC routes will have to be modified when dealing with iBGP, so I think this is something that will be done in bgp_updgrp_packet.c most probably. There is something done like that for BGP LU with label replacement.
I think this is something that can be done separately.