Skip to content

Commit

Permalink
Merge pull request #15693 from anlancs/fix/zebra-label-bind
Browse files Browse the repository at this point in the history
zebra: fix wrong check for mpls label
  • Loading branch information
donaldsharp authored Apr 9, 2024
2 parents 7f6cda3 + cbd1f32 commit 5d7b50d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
12 changes: 8 additions & 4 deletions zebra/zebra_mpls.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
}
}

Expand All @@ -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);
}

/*
Expand Down
5 changes: 3 additions & 2 deletions zebra/zebra_mpls.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,13 @@ int zebra_mpls_fec_unregister(struct zebra_vrf *zvrf, struct prefix *p,
* hash..
*/
struct zebra_fec *zebra_mpls_fec_for_label(struct zebra_vrf *zvrf,
mpls_label_t label);
struct prefix *p, mpls_label_t label);

/*
* 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);

/*
* Add static FEC to label binding. If there are clients registered for this
Expand Down
2 changes: 1 addition & 1 deletion zebra/zebra_mpls_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ static int zebra_mpls_bind(struct vty *vty, int add_cmd, const char *prefix,
vty_out(vty, "%% Invalid label\n");
return CMD_WARNING_CONFIG_FAILED;
}
if (zebra_mpls_label_already_bound(zvrf, label)) {
if (zebra_mpls_label_already_bound(zvrf, &p, label)) {
vty_out(vty,
"%% Label already bound to a FEC\n");
return CMD_WARNING_CONFIG_FAILED;
Expand Down

0 comments on commit 5d7b50d

Please sign in to comment.