Skip to content

Commit

Permalink
bgpd: fix label in adj-rib-out
Browse files Browse the repository at this point in the history
After modifying the "label vpn export value", the vpn label information
of the VRF is not updated to the peers.

For example, the 192.168.0.0/24 prefix is announced to the peer with a
label value of 222.

> router bgp 65500
> [..]
>  neighbor 192.0.2.2 remote-as 65501
>  address-family ipv4-vpn
>   neighbor 192.0.2.2 activate
>  exit-address-family
> exit
> router bgp 65500 vrf vrf2
>  address-family ipv4 unicast
>   network 192.168.0.0/24
>   label vpn export 222
>   rd vpn export 444:444
>   rt vpn both 53:100
>   export vpn
>   import vpn
>  exit-address-family

Changing the label with "label vpn export" does not update the label
value to the peer unless the BGP sessions is re-established.

No labels are stored are stored struct bgp_adj_out so that it is
impossible to compare the current value with the previous value
in adj-RIB-out.

Reference the bgp_labels pointer in struct bgp_adj_out and compare the
values when updating adj-RIB-out.

Signed-off-by: Philippe Guibert <[email protected]>
Signed-off-by: Louis Scalbert <[email protected]>
  • Loading branch information
pguibert6WIND authored and louis-6wind committed Feb 26, 2024
1 parent 5a4eb39 commit aa5f080
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
3 changes: 3 additions & 0 deletions bgpd/bgp_advertise.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ struct bgp_adj_out {
/* Advertised attribute. */
struct attr *attr;

/* VPN label information */
struct bgp_labels *labels;

/* Advertisement information. */
struct bgp_advertise *adv;
};
Expand Down
14 changes: 11 additions & 3 deletions bgpd/bgp_updgrp_adv.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ static inline struct bgp_adj_out *adj_lookup(struct bgp_dest *dest,

static void adj_free(struct bgp_adj_out *adj)
{
bgp_labels_unintern(&adj->labels);

TAILQ_REMOVE(&(adj->subgroup->adjq), adj, subgrp_adj_train);
SUBGRP_DECR_STAT(adj->subgroup, adj_count);

Expand Down Expand Up @@ -489,6 +491,8 @@ bgp_advertise_clean_subgroup(struct update_subgroup *subgrp,
/* Unlink myself from advertisement FIFO. */
bgp_adv_fifo_del(fhead, adv);

bgp_labels_unintern(&adj->labels);

/* Free memory. */
bgp_advertise_free(adj->adv);
adj->adv = NULL;
Expand Down Expand Up @@ -543,9 +547,11 @@ void bgp_adj_out_set_subgroup(struct bgp_dest *dest,
* the route wasn't changed actually.
* Do not suppress BGP UPDATES for route-refresh.
*/
if (CHECK_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_DUPLICATES)
&& !CHECK_FLAG(subgrp->sflags, SUBGRP_STATUS_FORCE_UPDATES)
&& adj->attr_hash == attr_hash) {
if (CHECK_FLAG(bgp->flags, BGP_FLAG_SUPPRESS_DUPLICATES) &&
!CHECK_FLAG(subgrp->sflags, SUBGRP_STATUS_FORCE_UPDATES) &&
adj->attr_hash == attr_hash &&
bgp_labels_cmp(path->extra ? path->extra->labels : NULL,
adj->labels)) {
if (BGP_DEBUG(update, UPDATE_OUT)) {
char attr_str[BUFSIZ] = {0};

Expand Down Expand Up @@ -587,6 +593,8 @@ void bgp_adj_out_set_subgroup(struct bgp_dest *dest,
adv->baa = bgp_advertise_attr_intern(subgrp->hash, attr);
adv->adj = adj;
adj->attr_hash = attr_hash;
if (path->extra)
adj->labels = bgp_labels_intern(path->extra->labels);

/* Add new advertisement to advertisement attribute list. */
bgp_advertise_add(adv->baa, adv);
Expand Down

0 comments on commit aa5f080

Please sign in to comment.