diff options
| author | Donatas Abraitis <donatas@opensourcerouting.org> | 2023-04-28 16:27:20 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-28 16:27:20 +0300 |
| commit | 8bc79f38555f142e5cbfcafc8a5af2549fc485ab (patch) | |
| tree | 08f37e16739444c69fa613ba00ade1225e4e120d | |
| parent | 0c41d0ffad0c6c1a9063dab96c2b7c28e8cdc8b8 (diff) | |
| parent | cf1c7e309e0b2af051c97b716afb59f6ea84ec75 (diff) | |
Merge pull request #13335 from pguibert6WIND/bgp_lu_explicit_per_afi
bgpd: configure explicit-null for local paths per address family
| -rw-r--r-- | bgpd/bgp_route.c | 11 | ||||
| -rw-r--r-- | bgpd/bgp_vty.c | 29 | ||||
| -rw-r--r-- | bgpd/bgpd.h | 6 | ||||
| -rw-r--r-- | doc/user/bgp.rst | 2 |
4 files changed, 36 insertions, 12 deletions
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 2cea525320..b51396c8d1 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 de781d6b1e..05ad4d97e5 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 b6491bf799..c3cb6ba91e 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. diff --git a/doc/user/bgp.rst b/doc/user/bgp.rst index 00502a9d76..e2cc121d95 100644 --- a/doc/user/bgp.rst +++ b/doc/user/bgp.rst @@ -2780,7 +2780,7 @@ Labeled unicast *bgpd* supports labeled information, as per :rfc:`3107`. -.. clicmd:: bgp labeled-unicast explicit-null +.. clicmd:: bgp labeled-unicast <explicit-null|ipv4-explicit-null|ipv6-explicit-null> By default, locally advertised prefixes use the `implicit-null` label to encode in the outgoing NLRI. The following command uses the `explicit-null` |
