Skip to content

Commit

Permalink
bgpd: remove label arguments from bgp_update
Browse files Browse the repository at this point in the history
Set labels in attr before calling bgp_update and remove label arguments
from bgp_update.

Note that modified attr structures are not yet interned.

Signed-off-by: Louis Scalbert <[email protected]>
  • Loading branch information
louis-6wind committed Feb 1, 2024
1 parent c63007b commit 2a4a1b4
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 61 deletions.
22 changes: 14 additions & 8 deletions bgpd/bgp_evpn.c
Original file line number Diff line number Diff line change
Expand Up @@ -4689,11 +4689,14 @@ static int process_type2_route(struct peer *peer, afi_t afi, safi_t safi,
}

/* Process the route. */
if (attr)
if (attr) {
attr->num_labels = num_labels;
attr->label_tbl[0] = label[0];
bgp_set_valid_label(&attr->label_tbl[0]);
bgp_update(peer, (struct prefix *)&p, addpath_id, attr, afi,
safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd,
&label[0], num_labels, 0, &evpn);
else
0, &evpn);
} else
bgp_withdraw(peer, (struct prefix *)&p, addpath_id, afi, safi,
ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, &label[0],
num_labels, &evpn);
Expand Down Expand Up @@ -4782,8 +4785,8 @@ static int process_type3_route(struct peer *peer, afi_t afi, safi_t safi,
/* Process the route. */
if (attr)
bgp_update(peer, (struct prefix *)&p, addpath_id, attr, afi,
safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, NULL,
0, 0, NULL);
safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd,
0, NULL);
else
bgp_withdraw(peer, (struct prefix *)&p, addpath_id, afi, safi,
ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, NULL, 0,
Expand Down Expand Up @@ -4914,11 +4917,14 @@ static int process_type5_route(struct peer *peer, afi_t afi, safi_t safi,
}

/* Process the route. */
if (attr && is_valid_update)
if (attr && is_valid_update) {
attr->num_labels = 1;
attr->label_tbl[0] = label;
bgp_set_valid_label(&attr->label_tbl[0]);
bgp_update(peer, (struct prefix *)&p, addpath_id, attr, afi,
safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd,
&label, 1, 0, &evpn);
else {
0, &evpn);
} else {
if (!is_valid_update) {
char attr_str[BUFSIZ] = {0};

Expand Down
8 changes: 4 additions & 4 deletions bgpd/bgp_evpn_mh.c
Original file line number Diff line number Diff line change
Expand Up @@ -756,8 +756,8 @@ int bgp_evpn_type4_route_process(struct peer *peer, afi_t afi, safi_t safi,
/* Process the route. */
if (attr) {
bgp_update(peer, (struct prefix *)&p, addpath_id, attr, afi,
safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, NULL,
0, 0, NULL);
safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd,
0, NULL);
} else {
bgp_withdraw(peer, (struct prefix *)&p, addpath_id, afi, safi,
ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, NULL, 0,
Expand Down Expand Up @@ -1225,8 +1225,8 @@ int bgp_evpn_type1_route_process(struct peer *peer, afi_t afi, safi_t safi,
/* Process the route. */
if (attr) {
bgp_update(peer, (struct prefix *)&p, addpath_id, attr, afi,
safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, NULL,
0, 0, NULL);
safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd,
0, NULL);
} else {
bgp_withdraw(peer, (struct prefix *)&p, addpath_id, afi, safi,
ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, NULL, 0,
Expand Down
2 changes: 1 addition & 1 deletion bgpd/bgp_flowspec.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ int bgp_nlri_parse_flowspec(struct peer *peer, struct attr *attr,
if (!withdraw) {
bgp_update(peer, &p, 0, attr, afi, safi,
ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL,
NULL, 0, 0, NULL);
0, NULL);
} else {
bgp_withdraw(peer, &p, 0, afi, safi, ZEBRA_ROUTE_BGP,
BGP_ROUTE_NORMAL, NULL, NULL, 0, NULL);
Expand Down
5 changes: 4 additions & 1 deletion bgpd/bgp_label.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,9 +449,12 @@ int bgp_nlri_parse_label(struct peer *peer, struct attr *attr,
}

if (attr) {
attr->num_labels = 1;
attr->label_tbl[0] = label;
bgp_set_valid_label(&attr->label_tbl[0]);
bgp_update(peer, &p, addpath_id, attr, packet->afi,
safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
NULL, &label, 1, 0, NULL);
NULL, 0, NULL);
} else {
bgp_withdraw(peer, &p, addpath_id, packet->afi,
SAFI_UNICAST, ZEBRA_ROUTE_BGP,
Expand Down
12 changes: 3 additions & 9 deletions bgpd/bgp_mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,6 @@ static void bgp_process_mac_rescan_table(struct bgp *bgp, struct peer *peer,
const struct prefix *p = bgp_dest_get_prefix(dest);
struct prefix_evpn *pevpn = (struct prefix_evpn *)dest;
struct prefix_rd prd;
uint32_t num_labels = 0;
mpls_label_t *label_pnt = NULL;
struct bgp_route_evpn *evpn;

if (pevpn->family == AF_EVPN
Expand Down Expand Up @@ -169,10 +167,6 @@ static void bgp_process_mac_rescan_table(struct bgp *bgp, struct peer *peer,
&& !dest_affected)
continue;

num_labels = pi->attr->num_labels;
if (num_labels)
label_pnt = &pi->attr->label_tbl[0];

prd.family = AF_UNSPEC;
prd.prefixlen = 64;
memcpy(&prd.val, pdest_p->u.val, 8);
Expand All @@ -183,7 +177,7 @@ static void bgp_process_mac_rescan_table(struct bgp *bgp, struct peer *peer,

bgp_debug_rdpfxpath2str(
AFI_L2VPN, SAFI_EVPN, &prd,
p, label_pnt, num_labels,
p, &pi->attr->label_tbl[0], pi->attr->num_labels,
pi->addpath_rx_id ? 1 : 0,
pi->addpath_rx_id, NULL,
pfx_buf, sizeof(pfx_buf));
Expand All @@ -198,8 +192,8 @@ static void bgp_process_mac_rescan_table(struct bgp *bgp, struct peer *peer,
sizeof(evpn));
bgp_update(peer, p, pi->addpath_rx_id, pi->attr,
AFI_L2VPN, SAFI_EVPN, ZEBRA_ROUTE_BGP,
BGP_ROUTE_NORMAL, &prd, label_pnt,
num_labels, 1, evpn);
BGP_ROUTE_NORMAL, &prd,
1, evpn);
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion bgpd/bgp_mplsvpn.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,12 @@ int bgp_nlri_parse_vpn(struct peer *peer, struct attr *attr,
STREAM_GET(p.u.val, data, psize - VPN_PREFIXLEN_MIN_BYTES);

if (attr) {
attr->num_labels = 1;
attr->label_tbl[0] = label;
bgp_set_valid_label(&attr->label_tbl[0]);
bgp_update(peer, &p, addpath_id, attr, packet->afi,
SAFI_MPLS_VPN, ZEBRA_ROUTE_BGP,
BGP_ROUTE_NORMAL, &prd, &label, 1, 0, NULL);
BGP_ROUTE_NORMAL, &prd, 0, NULL);
} else {
bgp_withdraw(peer, &p, addpath_id, packet->afi,
SAFI_MPLS_VPN, ZEBRA_ROUTE_BGP,
Expand Down
14 changes: 4 additions & 10 deletions bgpd/bgp_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -4165,8 +4165,8 @@ static bool bgp_accept_own(struct peer *peer, afi_t afi, safi_t safi,

void bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
struct attr *attr, afi_t afi, safi_t safi, int type,
int sub_type, struct prefix_rd *prd, mpls_label_t *label,
uint32_t num_labels, int soft_reconfig,
int sub_type, struct prefix_rd *prd,
int soft_reconfig,
struct bgp_route_evpn *evpn)
{
int ret;
Expand Down Expand Up @@ -5286,18 +5286,12 @@ static void bgp_soft_reconfig_table_update(struct peer *peer,
safi_t safi, struct prefix_rd *prd)
{
struct bgp_path_info *pi;
uint32_t num_labels = 0;
mpls_label_t *label_pnt = NULL;
struct bgp_route_evpn evpn;

for (pi = bgp_dest_get_bgp_path_info(dest); pi; pi = pi->next)
if (pi->peer == peer)
break;

if (pi)
num_labels = pi->attr->num_labels;
if (num_labels)
label_pnt = &pi->attr->label_tbl[0];
if (pi)
memcpy(&evpn, bgp_attr_get_evpn_overlay(pi->attr),
sizeof(evpn));
Expand All @@ -5306,7 +5300,7 @@ static void bgp_soft_reconfig_table_update(struct peer *peer,

bgp_update(peer, bgp_dest_get_prefix(dest), ain->addpath_rx_id,
ain->attr, afi, safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, prd,
label_pnt, num_labels, 1, &evpn);
1, &evpn);
}

static void bgp_soft_reconfig_table(struct peer *peer, afi_t afi, safi_t safi,
Expand Down Expand Up @@ -6217,7 +6211,7 @@ int bgp_nlri_parse_ip(struct peer *peer, struct attr *attr,
if (attr)
bgp_update(peer, &p, addpath_id, attr, afi, safi,
ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL,
NULL, 0, 0, NULL);
0, NULL);
else
bgp_withdraw(peer, &p, addpath_id, afi, safi,
ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL,
Expand Down
4 changes: 2 additions & 2 deletions bgpd/bgp_route.h
Original file line number Diff line number Diff line change
Expand Up @@ -779,8 +779,8 @@ extern int bgp_static_set(struct vty *vty, bool negate, const char *ip_str,
extern void bgp_update(struct peer *peer, const struct prefix *p,
uint32_t addpath_id, struct attr *attr, afi_t afi,
safi_t safi, int type, int sub_type,
struct prefix_rd *prd, mpls_label_t *label,
uint32_t num_labels, int soft_reconfig,
struct prefix_rd *prd,
int soft_reconfig,
struct bgp_route_evpn *evpn);
extern void bgp_withdraw(struct peer *peer, const struct prefix *p,
uint32_t addpath_id, afi_t afi, safi_t safi, int type,
Expand Down
16 changes: 3 additions & 13 deletions bgpd/bgp_rpki.c
Original file line number Diff line number Diff line change
Expand Up @@ -655,21 +655,11 @@ static void revalidate_bgp_node(struct bgp_dest *bgp_dest, afi_t afi,
{
struct bgp_adj_in *ain;

for (ain = bgp_dest->adj_in; ain; ain = ain->next) {
struct bgp_path_info *path =
bgp_dest_get_bgp_path_info(bgp_dest);
mpls_label_t *label = NULL;
uint32_t num_labels = 0;

if (path) {
label = path->attr->label_tbl;
num_labels = path->attr->num_labels;
}
for (ain = bgp_dest->adj_in; ain; ain = ain->next)
(void)bgp_update(ain->peer, bgp_dest_get_prefix(bgp_dest),
ain->addpath_rx_id, ain->attr, afi, safi,
ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL, label,
num_labels, 1, NULL);
}
ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL,
1, NULL);
}

/*
Expand Down
16 changes: 4 additions & 12 deletions bgpd/rfapi/vnc_export_bgp.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ void vnc_direct_bgp_add_route_ce(struct bgp *bgp, struct agg_node *rn,
iattr, /* bgp_update copies this attr */
afi, SAFI_UNICAST, ZEBRA_ROUTE_VNC_DIRECT,
BGP_ROUTE_REDISTRIBUTE, NULL, /* RD not used for unicast */
NULL, 0, /* tag not used for unicast */
0, NULL); /* EVPN not used */
bgp_attr_unintern(&iattr);
}
Expand Down Expand Up @@ -1033,9 +1032,7 @@ void vnc_direct_bgp_add_nve(struct bgp *bgp, struct rfapi_descriptor *rfd)
ZEBRA_ROUTE_VNC_DIRECT,
BGP_ROUTE_REDISTRIBUTE, NULL,
/* RD not used for unicast */
NULL,
/* tag not used for unicast */
0, 0, NULL); /* EVPN not used */
0, NULL); /* EVPN not used */

bgp_attr_unintern(&iattr);
}
Expand Down Expand Up @@ -1246,8 +1243,7 @@ static void vnc_direct_add_rn_group_rd(struct bgp *bgp,
iattr, /* bgp_update copies it */
afi, SAFI_UNICAST, ZEBRA_ROUTE_VNC_DIRECT,
BGP_ROUTE_REDISTRIBUTE, NULL, /* RD not used for unicast */
NULL, /* tag not used for unicast */
0, 0, NULL); /* EVPN not used */
0, NULL); /* EVPN not used */

bgp_attr_unintern(&iattr);

Expand Down Expand Up @@ -1699,8 +1695,7 @@ void vnc_direct_bgp_rh_add_route(struct bgp *bgp, afi_t afi,
iattr, /* bgp_update copies this attr */
afi, SAFI_UNICAST, ZEBRA_ROUTE_VNC_DIRECT_RH,
BGP_ROUTE_REDISTRIBUTE, NULL, /* RD not used for unicast */
NULL, /* tag not used for unicast, EVPN neither */
0, 0, NULL); /* EVPN not used */
0, NULL); /* EVPN not used */
bgp_attr_unintern(&iattr);
}

Expand Down Expand Up @@ -1937,10 +1932,7 @@ void vnc_direct_bgp_rh_vpn_enable(struct bgp *bgp, afi_t afi)
ZEBRA_ROUTE_VNC_DIRECT_RH,
BGP_ROUTE_REDISTRIBUTE, NULL,
/* RD not used for unicast */
NULL,
/* tag not used for unicast,
or EVPN */
0, 0, NULL); /* EVPN not used */
0, NULL); /* EVPN not used */

bgp_attr_unintern(&iattr);
}
Expand Down

0 comments on commit 2a4a1b4

Please sign in to comment.