summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Stapp <mstapp@nvidia.com>2021-10-05 11:49:20 -0400
committerMark Stapp <mstapp@nvidia.com>2021-10-08 09:11:51 -0400
commitbb2ca6927f98b53e9d860697ed82477eddbebe5c (patch)
tree78287df4b0fc813637a98ce407b9932ff0781608
parent01236d7aa7dab0891fa25012f87bc1fe3bbcfe9b (diff)
bgpd: BGP-LU use implicit-null in some cases
In some cases where bgp is at the mpls edge, where it has a BGP-LU peer downstream but an IP peer upstream, it can advertise the IMPLICIT_NULL label instead of a per-prefix label. Signed-off-by: Mark Stapp <mstapp@nvidia.com>
-rw-r--r--bgpd/bgp_label.c4
-rw-r--r--bgpd/bgp_route.c28
2 files changed, 27 insertions, 5 deletions
diff --git a/bgpd/bgp_label.c b/bgpd/bgp_label.c
index 3c8f2f3668..fa2a445165 100644
--- a/bgpd/bgp_label.c
+++ b/bgpd/bgp_label.c
@@ -244,6 +244,10 @@ void bgp_reg_dereg_for_label(struct bgp_dest *dest, struct bgp_path_info *pi,
p = bgp_dest_get_prefix(dest);
+ if (BGP_DEBUG(labelpool, LABELPOOL))
+ zlog_debug("%s: %pFX: %s ", __func__, p,
+ (reg ? "reg" : "dereg"));
+
if (reg) {
assert(pi);
/*
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index fc97178450..f278cef77c 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -2712,6 +2712,28 @@ static void bgp_process_evpn_route_injection(struct bgp *bgp, afi_t afi,
}
/*
+ * Utility to determine whether a particular path_info should use
+ * the IMPLICIT_NULL label. This is pretty specialized: it's only called
+ * in a path where we basically _know_ this is a BGP-LU route.
+ */
+static bool bgp_lu_need_imp_null(const struct bgp_path_info *new_select)
+{
+ /* Certain types get imp null; so do paths where the nexthop is
+ * not labeled.
+ */
+ if (new_select->sub_type == BGP_ROUTE_STATIC
+ || new_select->sub_type == BGP_ROUTE_AGGREGATE
+ || new_select->sub_type == BGP_ROUTE_REDISTRIBUTE)
+ return true;
+ else if (new_select->extra == NULL ||
+ !bgp_is_valid_label(&new_select->extra->label[0]))
+ /* TODO -- should be configurable? */
+ return true;
+ else
+ return false;
+}
+
+/*
* old_select = The old best path
* new_select = the new best path
*
@@ -2802,11 +2824,7 @@ static void bgp_process_main_one(struct bgp *bgp, struct bgp_dest *dest,
* implicit-null for local routes, aggregate
* and redistributed routes
*/
- if (new_select->sub_type == BGP_ROUTE_STATIC
- || new_select->sub_type
- == BGP_ROUTE_AGGREGATE
- || new_select->sub_type
- == BGP_ROUTE_REDISTRIBUTE) {
+ if (bgp_lu_need_imp_null(new_select)) {
if (CHECK_FLAG(
dest->flags,
BGP_NODE_REGISTERED_FOR_LABEL)