Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bgpd: move labels from extra to extra->labels and add them to adj-rib-in and adj-rib-out #15434

Merged
merged 18 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion bgpd/bgp_advertise.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ bool bgp_adj_out_lookup(struct peer *peer, struct bgp_dest *dest,


void bgp_adj_in_set(struct bgp_dest *dest, struct peer *peer, struct attr *attr,
uint32_t addpath_id)
uint32_t addpath_id, struct bgp_labels *labels)
{
struct bgp_adj_in *adj;

Expand All @@ -173,6 +173,10 @@ void bgp_adj_in_set(struct bgp_dest *dest, struct peer *peer, struct attr *attr,
bgp_attr_unintern(&adj->attr);
adj->attr = bgp_attr_intern(attr);
}
if (!bgp_labels_cmp(adj->labels, labels)) {
bgp_labels_unintern(&adj->labels);
adj->labels = bgp_labels_intern(labels);
}
return;
}
}
Expand All @@ -181,6 +185,7 @@ void bgp_adj_in_set(struct bgp_dest *dest, struct peer *peer, struct attr *attr,
adj->attr = bgp_attr_intern(attr);
adj->uptime = monotime(NULL);
adj->addpath_rx_id = addpath_id;
adj->labels = bgp_labels_intern(labels);
BGP_ADJ_IN_ADD(dest, adj);
peer->stat_pfx_adj_rib_in++;
bgp_dest_lock_node(dest);
Expand All @@ -189,6 +194,7 @@ void bgp_adj_in_set(struct bgp_dest *dest, struct peer *peer, struct attr *attr,
void bgp_adj_in_remove(struct bgp_dest **dest, struct bgp_adj_in *bai)
{
bgp_attr_unintern(&bai->attr);
bgp_labels_unintern(&bai->labels);
if (bai->peer)
bai->peer->stat_pfx_adj_rib_in--;
BGP_ADJ_IN_DEL(*dest, bai);
Expand Down
9 changes: 8 additions & 1 deletion 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 All @@ -95,6 +98,9 @@ struct bgp_adj_in {
/* Received attribute. */
struct attr *attr;

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

/* timestamp (monotime) */
time_t uptime;

Expand Down Expand Up @@ -135,7 +141,8 @@ struct bgp_synchronize {
extern bool bgp_adj_out_lookup(struct peer *peer, struct bgp_dest *dest,
uint32_t addpath_tx_id);
extern void bgp_adj_in_set(struct bgp_dest *dest, struct peer *peer,
struct attr *attr, uint32_t addpath_id);
struct attr *attr, uint32_t addpath_id,
struct bgp_labels *labels);
extern bool bgp_adj_in_unset(struct bgp_dest **dest, struct peer *peer,
uint32_t addpath_id);
extern void bgp_adj_in_remove(struct bgp_dest **dest, struct bgp_adj_in *bai);
Expand Down
6 changes: 3 additions & 3 deletions bgpd/bgp_attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -4158,7 +4158,7 @@ size_t bgp_packet_mpattr_start(struct stream *s, struct peer *peer, afi_t afi,
void bgp_packet_mpattr_prefix(struct stream *s, afi_t afi, safi_t safi,
const struct prefix *p,
const struct prefix_rd *prd, mpls_label_t *label,
uint32_t num_labels, bool addpath_capable,
uint8_t num_labels, bool addpath_capable,
uint32_t addpath_tx_id, struct attr *attr)
{
switch (safi) {
Expand Down Expand Up @@ -4434,7 +4434,7 @@ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer,
struct bpacket_attr_vec_arr *vecarr,
struct prefix *p, afi_t afi, safi_t safi,
struct peer *from, struct prefix_rd *prd,
mpls_label_t *label, uint32_t num_labels,
mpls_label_t *label, uint8_t num_labels,
bool addpath_capable, uint32_t addpath_tx_id,
struct bgp_path_info *bpi)
{
Expand Down Expand Up @@ -4963,7 +4963,7 @@ size_t bgp_packet_mpunreach_start(struct stream *s, afi_t afi, safi_t safi)
void bgp_packet_mpunreach_prefix(struct stream *s, const struct prefix *p,
afi_t afi, safi_t safi,
const struct prefix_rd *prd,
mpls_label_t *label, uint32_t num_labels,
mpls_label_t *label, uint8_t num_labels,
bool addpath_capable, uint32_t addpath_tx_id,
struct attr *attr)
{
Expand Down
6 changes: 3 additions & 3 deletions bgpd/bgp_attr.h
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ extern bgp_size_t bgp_packet_attribute(
struct bgp *bgp, struct peer *peer, struct stream *s, struct attr *attr,
struct bpacket_attr_vec_arr *vecarr, struct prefix *p, afi_t afi,
safi_t safi, struct peer *from, struct prefix_rd *prd,
mpls_label_t *label, uint32_t num_labels, bool addpath_capable,
mpls_label_t *label, uint8_t num_labels, bool addpath_capable,
uint32_t addpath_tx_id, struct bgp_path_info *bpi);
extern void bgp_dump_routes_attr(struct stream *s, struct bgp_path_info *bpi,
const struct prefix *p);
Expand Down Expand Up @@ -451,7 +451,7 @@ extern size_t bgp_packet_mpattr_start(struct stream *s, struct peer *peer,
extern void bgp_packet_mpattr_prefix(struct stream *s, afi_t afi, safi_t safi,
const struct prefix *p,
const struct prefix_rd *prd,
mpls_label_t *label, uint32_t num_labels,
mpls_label_t *label, uint8_t num_labels,
bool addpath_capable,
uint32_t addpath_tx_id, struct attr *);
extern size_t bgp_packet_mpattr_prefix_size(afi_t afi, safi_t safi,
Expand All @@ -462,7 +462,7 @@ extern size_t bgp_packet_mpunreach_start(struct stream *s, afi_t afi,
safi_t safi);
extern void bgp_packet_mpunreach_prefix(
struct stream *s, const struct prefix *p, afi_t afi, safi_t safi,
const struct prefix_rd *prd, mpls_label_t *label, uint32_t num_labels,
const struct prefix_rd *prd, mpls_label_t *label, uint8_t num_labels,
bool addpath_capable, uint32_t addpath_tx_id, struct attr *attr);
extern void bgp_packet_mpunreach_end(struct stream *s, size_t attrlen_pnt);

Expand Down
26 changes: 18 additions & 8 deletions bgpd/bgp_bmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "bgpd/bgp_vty.h"
#include "bgpd/bgp_trace.h"
#include "bgpd/bgp_network.h"
#include "bgpd/bgp_label.h"

static void bmp_close(struct bmp *bmp);
static struct bmp_bgp *bmp_bgp_find(struct bgp *bgp);
Expand Down Expand Up @@ -1046,6 +1047,7 @@ static void bmp_monitor(struct bmp *bmp, struct peer *peer, uint8_t flags,

static bool bmp_wrsync(struct bmp *bmp, struct pullwr *pullwr)
{
uint8_t bpi_num_labels;
afi_t afi;
safi_t safi;

Expand Down Expand Up @@ -1219,23 +1221,25 @@ static bool bmp_wrsync(struct bmp *bmp, struct pullwr *pullwr)
(safi == SAFI_MPLS_VPN))
prd = (struct prefix_rd *)bgp_dest_get_prefix(bmp->syncrdpos);

bpi_num_labels = bgp_path_info_num_labels(bpi);

if (bpi && CHECK_FLAG(bpi->flags, BGP_PATH_SELECTED) &&
CHECK_FLAG(bmp->targets->afimon[afi][safi], BMP_MON_LOC_RIB)) {
bmp_monitor(bmp, bpi->peer, 0, BMP_PEER_TYPE_LOC_RIB_INSTANCE,
bn_p, prd, bpi->attr, afi, safi,
bpi && bpi->extra ? bpi->extra->bgp_rib_uptime
: (time_t)(-1L),
bpi->extra ? bpi->extra->label : NULL,
bpi->extra ? bpi->extra->num_labels : 0);
bpi_num_labels ? bpi->extra->labels->label : NULL,
bpi_num_labels);
}

if (bpi && CHECK_FLAG(bpi->flags, BGP_PATH_VALID) &&
CHECK_FLAG(bmp->targets->afimon[afi][safi], BMP_MON_POSTPOLICY))
bmp_monitor(bmp, bpi->peer, BMP_PEER_FLAG_L,
BMP_PEER_TYPE_GLOBAL_INSTANCE, bn_p, prd, bpi->attr,
afi, safi, bpi->uptime,
bpi->extra ? bpi->extra->label : NULL,
bpi->extra ? bpi->extra->num_labels : 0);
bpi_num_labels ? bpi->extra->labels->label : NULL,
bpi_num_labels);

if (adjin)
/* TODO: set label here when adjin supports labels */
Expand Down Expand Up @@ -1292,6 +1296,7 @@ static bool bmp_wrqueue_locrib(struct bmp *bmp, struct pullwr *pullwr)
struct peer *peer;
struct bgp_dest *bn = NULL;
bool written = false;
uint8_t bpi_num_labels;

bqe = bmp_pull_locrib(bmp);
if (!bqe)
Expand Down Expand Up @@ -1351,12 +1356,14 @@ static bool bmp_wrqueue_locrib(struct bmp *bmp, struct pullwr *pullwr)
break;
}

bpi_num_labels = bgp_path_info_num_labels(bpi);

bmp_monitor(bmp, peer, 0, BMP_PEER_TYPE_LOC_RIB_INSTANCE, &bqe->p, prd,
bpi ? bpi->attr : NULL, afi, safi,
bpi && bpi->extra ? bpi->extra->bgp_rib_uptime
: (time_t)(-1L),
(bpi && bpi->extra) ? bpi->extra->label : NULL,
(bpi && bpi->extra) ? bpi->extra->num_labels : 0);
bpi_num_labels ? bpi->extra->labels->label : NULL,
bpi_num_labels);
written = true;

out:
Expand All @@ -1375,6 +1382,7 @@ static bool bmp_wrqueue(struct bmp *bmp, struct pullwr *pullwr)
struct peer *peer;
struct bgp_dest *bn = NULL;
bool written = false;
uint8_t bpi_num_labels;

bqe = bmp_pull(bmp);
if (!bqe)
Expand Down Expand Up @@ -1426,12 +1434,14 @@ static bool bmp_wrqueue(struct bmp *bmp, struct pullwr *pullwr)
break;
}

bpi_num_labels = bgp_path_info_num_labels(bpi);

bmp_monitor(bmp, peer, BMP_PEER_FLAG_L,
BMP_PEER_TYPE_GLOBAL_INSTANCE, &bqe->p, prd,
bpi ? bpi->attr : NULL, afi, safi,
bpi ? bpi->uptime : monotime(NULL),
(bpi && bpi->extra) ? bpi->extra->label : NULL,
(bpi && bpi->extra) ? bpi->extra->num_labels : 0);
bpi_num_labels ? bpi->extra->labels->label : NULL,
bpi_num_labels);
written = true;
}

Expand Down
2 changes: 1 addition & 1 deletion bgpd/bgp_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -2713,7 +2713,7 @@ bool bgp_debug_zebra(const struct prefix *p)
const char *bgp_debug_rdpfxpath2str(afi_t afi, safi_t safi,
const struct prefix_rd *prd,
union prefixconstptr pu,
mpls_label_t *label, uint32_t num_labels,
mpls_label_t *label, uint8_t num_labels,
int addpath_valid, uint32_t addpath_id,
struct bgp_route_evpn *overlay_index,
char *str, int size)
Expand Down
2 changes: 1 addition & 1 deletion bgpd/bgp_debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ extern bool bgp_debug_zebra(const struct prefix *p);

extern const char *bgp_debug_rdpfxpath2str(
afi_t afi, safi_t safi, const struct prefix_rd *prd,
union prefixconstptr pu, mpls_label_t *label, uint32_t num_labels,
union prefixconstptr pu, mpls_label_t *label, uint8_t num_labels,
int addpath_valid, uint32_t addpath_id,
struct bgp_route_evpn *overlay_index, char *str, int size);
const char *bgp_notify_admin_message(char *buf, size_t bufsz, uint8_t *data,
Expand Down
Loading
Loading