summaryrefslogtreecommitdiffstats
path: root/bgpd
diff options
context:
space:
mode:
authorPhilippe Guibert <philippe.guibert@6wind.com>2023-04-19 16:40:50 +0200
committerPhilippe Guibert <philippe.guibert@6wind.com>2023-04-27 17:05:35 +0200
commitcf1c7e309e0b2af051c97b716afb59f6ea84ec75 (patch)
treeb9d4c998aceb5e6db595d6313d048cb8c4bac553 /bgpd
parentMerge pull request #13386 from donaldsharp/bgp_received_routes (diff)
downloadfrr-cf1c7e309e0b2af051c97b716afb59f6ea84ec75.tar.xz
frr-cf1c7e309e0b2af051c97b716afb59f6ea84ec75.zip
bgpd: configure explicit-null for local paths per address family
Until now, the bgp local paths were using the default null label defined. It was not possible to select the null label for the ipv4 or the ipv6 address families. This commit addresses this issues by adding two extra-parameters to the BGP labeled-unicast command. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/bgp_route.c11
-rw-r--r--bgpd/bgp_vty.c29
-rw-r--r--bgpd/bgpd.h6
3 files changed, 35 insertions, 11 deletions
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 2cea52532..b51396c8d 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -3087,10 +3087,13 @@ static bool bgp_lu_need_null_label(struct bgp *bgp,
need_null_label:
if (label == NULL)
return true;
- if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_LU_EXPLICIT_NULL))
- /* Disable PHP : explicit-null */
- *label = afi == AFI_IP ? MPLS_LABEL_IPV4_EXPLICIT_NULL
- : MPLS_LABEL_IPV6_EXPLICIT_NULL;
+ /* Disable PHP : explicit-null */
+ if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_LU_IPV4_EXPLICIT_NULL) &&
+ afi == AFI_IP)
+ *label = MPLS_LABEL_IPV4_EXPLICIT_NULL;
+ else if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_LU_IPV6_EXPLICIT_NULL) &&
+ afi == AFI_IP6)
+ *label = MPLS_LABEL_IPV6_EXPLICIT_NULL;
else
/* Enforced PHP popping: implicit-null */
*label = MPLS_LABEL_IMPLICIT_NULL;
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index de781d6b1..05ad4d97e 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -2821,17 +2821,27 @@ DEFUN(no_bgp_ebgp_requires_policy, no_bgp_ebgp_requires_policy_cmd,
}
DEFPY(bgp_lu_uses_explicit_null, bgp_lu_uses_explicit_null_cmd,
- "[no] bgp labeled-unicast explicit-null",
+ "[no] bgp labeled-unicast <explicit-null|ipv4-explicit-null|ipv6-explicit-null>$value",
NO_STR BGP_STR
"BGP Labeled-unicast options\n"
- "Use explicit-null label values for local prefixes\n")
+ "Use explicit-null label values for all local prefixes\n"
+ "Use the IPv4 explicit-null label value for IPv4 local prefixes\n"
+ "Use the IPv6 explicit-null label value for IPv6 local prefixes\n")
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
+ uint64_t label_mode;
+ if (strmatch(value, "ipv4-explicit-null"))
+ label_mode = BGP_FLAG_LU_IPV4_EXPLICIT_NULL;
+ else if (strmatch(value, "ipv6-explicit-null"))
+ label_mode = BGP_FLAG_LU_IPV6_EXPLICIT_NULL;
+ else
+ label_mode = BGP_FLAG_LU_IPV4_EXPLICIT_NULL |
+ BGP_FLAG_LU_IPV6_EXPLICIT_NULL;
if (no)
- UNSET_FLAG(bgp->flags, BGP_FLAG_LU_EXPLICIT_NULL);
+ UNSET_FLAG(bgp->flags, label_mode);
else
- SET_FLAG(bgp->flags, BGP_FLAG_LU_EXPLICIT_NULL);
+ SET_FLAG(bgp->flags, label_mode);
return CMD_SUCCESS;
}
@@ -18250,8 +18260,17 @@ int bgp_config_write(struct vty *vty)
? ""
: "no ");
- if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_LU_EXPLICIT_NULL))
+ if (!!CHECK_FLAG(bgp->flags, BGP_FLAG_LU_IPV4_EXPLICIT_NULL) &&
+ !!CHECK_FLAG(bgp->flags, BGP_FLAG_LU_IPV6_EXPLICIT_NULL))
vty_out(vty, " bgp labeled-unicast explicit-null\n");
+ else if (!!CHECK_FLAG(bgp->flags,
+ BGP_FLAG_LU_IPV4_EXPLICIT_NULL))
+ vty_out(vty,
+ " bgp labeled-unicast ipv4-explicit-null\n");
+ else if (!!CHECK_FLAG(bgp->flags,
+ BGP_FLAG_LU_IPV6_EXPLICIT_NULL))
+ vty_out(vty,
+ " bgp labeled-unicast ipv6-explicit-null\n");
/* draft-ietf-idr-deprecate-as-set-confed-set */
if (bgp->reject_as_sets)
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index b6491bf79..c3cb6ba91 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -500,8 +500,10 @@ struct bgp {
#define BGP_FLAG_HARD_ADMIN_RESET (1ULL << 31)
/* Evaluate the AIGP attribute during the best path selection process */
#define BGP_FLAG_COMPARE_AIGP (1ULL << 32)
-/* For BGP-LU, force local prefixes to use explicit-null label */
-#define BGP_FLAG_LU_EXPLICIT_NULL (1ULL << 33)
+/* For BGP-LU, force IPv4 local prefixes to use ipv4-explicit-null label */
+#define BGP_FLAG_LU_IPV4_EXPLICIT_NULL (1ULL << 33)
+/* For BGP-LU, force IPv6 local prefixes to use ipv6-explicit-null label */
+#define BGP_FLAG_LU_IPV6_EXPLICIT_NULL (1ULL << 34)
/* BGP default address-families.
* New peers inherit enabled afi/safis from bgp instance.