summaryrefslogtreecommitdiff
path: root/zebra/zebra_mpls.c
diff options
context:
space:
mode:
authoranlan_cs <anlan_cs@tom.com>2024-04-05 15:03:15 +0800
committeranlan_cs <anlan_cs@tom.com>2024-04-06 09:01:39 +0800
commitcbd1f3239a9f44fcbc2dc7d41eee82e623de141f (patch)
tree71a74f8b527ad876778e2948ddcf03c8fd25e886 /zebra/zebra_mpls.c
parent30dcd79011c867c56fd7d5a1201cda0eb656167d (diff)
zebra: fix wrong check for mpls label
Add a parameter for `zebra_mpls_fec_for_label()`, as before if it is `NULL`, otherwise exclude what this parameter represents. Before: ``` anlan(config)# mpls label bind 1.1.1.2/32 88 anlan(config)# mpls label bind 1.1.1.2/32 88 % Label already bound to a FEC anlan(config)# mpls label bind 1.1.1.3/32 88 % Label already bound to a FEC ``` After: ``` anlan(config)# mpls label bind 1.1.1.2/32 88 anlan(config)# mpls label bind 1.1.1.2/32 88 anlan(config)# mpls label bind 1.1.1.3/32 88 % Label already bound to a FEC ``` Signed-off-by: anlan_cs <anlan_cs@tom.com>
Diffstat (limited to 'zebra/zebra_mpls.c')
-rw-r--r--zebra/zebra_mpls.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/zebra/zebra_mpls.c b/zebra/zebra_mpls.c
index cc2cf9b9ff..4cc85d461f 100644
--- a/zebra/zebra_mpls.c
+++ b/zebra/zebra_mpls.c
@@ -2476,7 +2476,7 @@ static int zebra_mpls_cleanup_zclient_labels(struct zserv *client)
* hash..
*/
struct zebra_fec *zebra_mpls_fec_for_label(struct zebra_vrf *zvrf,
- mpls_label_t label)
+ struct prefix *p, mpls_label_t label)
{
struct route_node *rn;
struct zebra_fec *fec;
@@ -2491,8 +2491,11 @@ struct zebra_fec *zebra_mpls_fec_for_label(struct zebra_vrf *zvrf,
if (!rn->info)
continue;
fec = rn->info;
- if (fec->label == label)
+ if (fec->label == label) {
+ if (p && prefix_same(p, &rn->p))
+ return NULL;
return fec;
+ }
}
}
@@ -2502,9 +2505,10 @@ struct zebra_fec *zebra_mpls_fec_for_label(struct zebra_vrf *zvrf,
/*
* Inform if specified label is currently bound to a FEC or not.
*/
-int zebra_mpls_label_already_bound(struct zebra_vrf *zvrf, mpls_label_t label)
+int zebra_mpls_label_already_bound(struct zebra_vrf *zvrf, struct prefix *p,
+ mpls_label_t label)
{
- return (zebra_mpls_fec_for_label(zvrf, label) ? 1 : 0);
+ return (zebra_mpls_fec_for_label(zvrf, p, label) ? 1 : 0);
}
/*