From: anlan_cs Date: Thu, 16 May 2024 08:44:45 +0000 (+0800) Subject: zebra: fix mpls command X-Git-Tag: docker/9.1.1~11^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=b3455922fea047d98d5ee3fea77a94a4a5ca2470;p=matthieu%2Ffrr.git zebra: fix mpls command Configured with "mpls label bind 1.1.1.1/32 explicit-null", the running configuration is: ``` ! mpls label bind 1.1.1.1/32 IPv4 Explicit Null ! ``` After this commit, the running configuration is: ``` ! mpls label bind 1.1.1.1/32 explicit-null ! ``` And add the support for the "no" form: ``` anlan(config)# mpls label bind 1.1.1.1/32 explicit-null anlan(config)# no mpls label bind 1.1.1.1/32 explicit-null ``` Signed-off-by: anlan_cs (cherry picked from commit 05ad3ccb034c174d2e853e88b826ca0db1e77f45) --- diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c index eac4fcc8e0..6235003248 100644 --- a/zebra/zebra_mpls.c +++ b/zebra/zebra_mpls.c @@ -2691,8 +2691,16 @@ int zebra_mpls_write_fec_config(struct vty *vty, struct zebra_vrf *zvrf) continue; write = 1; - vty_out(vty, "mpls label bind %pFX %s\n", &rn->p, - label2str(fec->label, 0, lstr, BUFSIZ)); + + if (fec->label == MPLS_LABEL_IPV4_EXPLICIT_NULL || + fec->label == MPLS_LABEL_IPV6_EXPLICIT_NULL) + strlcpy(lstr, "explicit-null", sizeof(lstr)); + else if (fec->label == MPLS_LABEL_IMPLICIT_NULL) + strlcpy(lstr, "implicit-null", sizeof(lstr)); + else + snprintf(lstr, sizeof(lstr), "%d", fec->label); + + vty_out(vty, "mpls label bind %pFX %s\n", &rn->p, lstr); } } diff --git a/zebra/zebra_mpls_vty.c b/zebra/zebra_mpls_vty.c index e64e7009b4..3b2d76c503 100644 --- a/zebra/zebra_mpls_vty.c +++ b/zebra/zebra_mpls_vty.c @@ -246,7 +246,7 @@ DEFUN (mpls_label_bind, DEFUN (no_mpls_label_bind, no_mpls_label_bind_cmd, - "no mpls label bind [<(16-1048575)|implicit-null>]", + "no mpls label bind [<(16-1048575)|implicit-null|explicit-null>]", NO_STR MPLS_STR "Label configuration\n" @@ -254,7 +254,8 @@ DEFUN (no_mpls_label_bind, "IPv4 prefix\n" "IPv6 prefix\n" "MPLS Label to bind\n" - "Use Implicit-Null Label\n") + "Use Implicit-Null Label\n" + "Use Explicit-Null Label\n") { return zebra_mpls_bind(vty, 0, argv[4]->arg, NULL); }