]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: fix mpls command
authoranlan_cs <anlan_cs@tom.com>
Thu, 16 May 2024 08:44:45 +0000 (16:44 +0800)
committerMergify <37929162+mergify[bot]@users.noreply.github.com>
Sat, 18 May 2024 13:13:10 +0000 (13:13 +0000)
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 <anlan_cs@tom.com>
(cherry picked from commit 05ad3ccb034c174d2e853e88b826ca0db1e77f45)

zebra/zebra_mpls.c
zebra/zebra_mpls_vty.c

index eac4fcc8e0605d4eb4f8fa4d42f6ffc8d261a5c0..62350032480e4d7e5b628d7148d783ef1fd53e8a 100644 (file)
@@ -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);
                }
        }
 
index e64e7009b4d2422692066af6c9207bb396d76dbe..3b2d76c503e396d62cff3000418c75b1cbacd0d7 100644 (file)
@@ -246,7 +246,7 @@ DEFUN (mpls_label_bind,
 
 DEFUN (no_mpls_label_bind,
        no_mpls_label_bind_cmd,
-       "no mpls label bind <A.B.C.D/M|X:X::X:X/M> [<(16-1048575)|implicit-null>]",
+       "no mpls label bind <A.B.C.D/M|X:X::X:X/M> [<(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);
 }