Skip to content

Commit

Permalink
Merge pull request #12709 from donaldsharp/update_withdraw_always_work
Browse files Browse the repository at this point in the history
bgpd: bgp_update and bgp_withdraw never return failures
  • Loading branch information
ton31337 authored Jan 31, 2023
2 parents 65a7824 + 367b458 commit 9eca0bd
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 138 deletions.
44 changes: 21 additions & 23 deletions bgpd/bgp_evpn.c
Original file line number Diff line number Diff line change
Expand Up @@ -4429,7 +4429,7 @@ static int process_type2_route(struct peer *peer, afi_t afi, safi_t safi,
mpls_label_t label[BGP_MAX_LABELS] = {};
uint32_t num_labels = 0;
uint32_t eth_tag;
int ret;
int ret = 0;

/* Type-2 route should be either 33, 37 or 49 bytes or an
* additional 3 bytes if there is a second label (VNI):
Expand Down Expand Up @@ -4522,13 +4522,13 @@ static int process_type2_route(struct peer *peer, afi_t afi, safi_t safi,

/* Process the route. */
if (attr)
ret = bgp_update(peer, (struct prefix *)&p, addpath_id, attr,
afi, safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
&prd, &label[0], num_labels, 0, &evpn);
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
ret = bgp_withdraw(peer, (struct prefix *)&p, addpath_id, attr,
afi, safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
&prd, &label[0], num_labels, &evpn);
bgp_withdraw(peer, (struct prefix *)&p, addpath_id, attr, afi,
safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd,
&label[0], num_labels, &evpn);
goto done;

fail:
Expand All @@ -4553,7 +4553,6 @@ static int process_type3_route(struct peer *peer, afi_t afi, safi_t safi,
struct prefix_evpn p;
uint8_t ipaddr_len;
uint32_t eth_tag;
int ret;

/* Type-3 route should be either 17 or 29 bytes: RD (8), Eth Tag (4),
* IP len (1) and IP (4 or 16).
Expand Down Expand Up @@ -4614,14 +4613,14 @@ static int process_type3_route(struct peer *peer, afi_t afi, safi_t safi,

/* Process the route. */
if (attr)
ret = bgp_update(peer, (struct prefix *)&p, addpath_id, attr,
afi, safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
&prd, NULL, 0, 0, NULL);
bgp_update(peer, (struct prefix *)&p, addpath_id, attr, afi,
safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, NULL,
0, 0, NULL);
else
ret = bgp_withdraw(peer, (struct prefix *)&p, addpath_id, attr,
afi, safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
&prd, NULL, 0, NULL);
return ret;
bgp_withdraw(peer, (struct prefix *)&p, addpath_id, attr, afi,
safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd,
NULL, 0, NULL);
return 0;
}

/*
Expand All @@ -4637,7 +4636,6 @@ static int process_type5_route(struct peer *peer, afi_t afi, safi_t safi,
uint8_t ippfx_len;
uint32_t eth_tag;
mpls_label_t label; /* holds the VNI as in the packet */
int ret;
bool is_valid_update = true;

/* Type-5 route should be 34 or 58 bytes:
Expand Down Expand Up @@ -4749,9 +4747,9 @@ static int process_type5_route(struct peer *peer, afi_t afi, safi_t safi,

/* Process the route. */
if (attr && is_valid_update)
ret = bgp_update(peer, (struct prefix *)&p, addpath_id, attr,
afi, safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
&prd, &label, 1, 0, &evpn);
bgp_update(peer, (struct prefix *)&p, addpath_id, attr, afi,
safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd,
&label, 1, 0, &evpn);
else {
if (!is_valid_update) {
char attr_str[BUFSIZ] = {0};
Expand All @@ -4762,12 +4760,12 @@ static int process_type5_route(struct peer *peer, afi_t afi, safi_t safi,
peer->hostname, peer->bgp->vrf_id, &p,
attr_str);
}
ret = bgp_withdraw(peer, (struct prefix *)&p, addpath_id, attr,
afi, safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
&prd, &label, 1, &evpn);
bgp_withdraw(peer, (struct prefix *)&p, addpath_id, attr, afi,
safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd,
&label, 1, &evpn);
}

return ret;
return 0;
}

static void evpn_mpattr_encode_type5(struct stream *s, const struct prefix *p,
Expand Down
30 changes: 14 additions & 16 deletions bgpd/bgp_evpn_mh.c
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,6 @@ int bgp_evpn_type4_route_process(struct peer *peer, afi_t afi, safi_t safi,
struct attr *attr, uint8_t *pfx, int psize,
uint32_t addpath_id)
{
int ret;
esi_t esi;
uint8_t ipaddr_len;
struct in_addr vtep_ip;
Expand Down Expand Up @@ -750,15 +749,15 @@ int bgp_evpn_type4_route_process(struct peer *peer, afi_t afi, safi_t safi,
build_evpn_type4_prefix(&p, &esi, vtep_ip);
/* Process the route. */
if (attr) {
ret = bgp_update(peer, (struct prefix *)&p, addpath_id, attr,
afi, safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
&prd, NULL, 0, 0, NULL);
bgp_update(peer, (struct prefix *)&p, addpath_id, attr, afi,
safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, NULL,
0, 0, NULL);
} else {
ret = bgp_withdraw(peer, (struct prefix *)&p, addpath_id, attr,
afi, safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
&prd, NULL, 0, NULL);
bgp_withdraw(peer, (struct prefix *)&p, addpath_id, attr, afi,
safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd,
NULL, 0, NULL);
}
return ret;
return 0;
}

/* Check if a prefix belongs to the local ES */
Expand Down Expand Up @@ -1180,7 +1179,6 @@ int bgp_evpn_type1_route_process(struct peer *peer, afi_t afi, safi_t safi,
struct attr *attr, uint8_t *pfx, int psize,
uint32_t addpath_id)
{
int ret;
struct prefix_rd prd;
esi_t esi;
uint32_t eth_tag;
Expand Down Expand Up @@ -1219,15 +1217,15 @@ int bgp_evpn_type1_route_process(struct peer *peer, afi_t afi, safi_t safi,
build_evpn_type1_prefix(&p, eth_tag, &esi, vtep_ip);
/* Process the route. */
if (attr) {
ret = bgp_update(peer, (struct prefix *)&p, addpath_id, attr,
afi, safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
&prd, NULL, 0, 0, NULL);
bgp_update(peer, (struct prefix *)&p, addpath_id, attr, afi,
safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, NULL,
0, 0, NULL);
} else {
ret = bgp_withdraw(peer, (struct prefix *)&p, addpath_id, attr,
afi, safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
&prd, NULL, 0, NULL);
bgp_withdraw(peer, (struct prefix *)&p, addpath_id, attr, afi,
safi, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd,
NULL, 0, NULL);
}
return ret;
return 0;
}

void bgp_evpn_mh_config_ead_export_rt(struct bgp *bgp,
Expand Down
21 changes: 6 additions & 15 deletions bgpd/bgp_flowspec.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ int bgp_nlri_parse_flowspec(struct peer *peer, struct attr *attr,
safi_t safi;
int psize = 0;
struct prefix p;
int ret;
void *temp;

/* Start processing the NLRI - there may be multiple in the MP_REACH */
Expand Down Expand Up @@ -190,21 +189,13 @@ int bgp_nlri_parse_flowspec(struct peer *peer, struct attr *attr,
}
/* Process the route. */
if (!withdraw)
ret = bgp_update(peer, &p, 0, attr,
afi, safi,
ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
NULL, NULL, 0, 0, NULL);
bgp_update(peer, &p, 0, attr, afi, safi,
ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL,
NULL, 0, 0, NULL);
else
ret = bgp_withdraw(peer, &p, 0, attr,
afi, safi,
ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
NULL, NULL, 0, NULL);
if (ret) {
flog_err(EC_BGP_FLOWSPEC_INSTALLATION,
"Flowspec NLRI failed to be %s.",
attr ? "added" : "withdrawn");
return BGP_NLRI_PARSE_ERROR;
}
bgp_withdraw(peer, &p, 0, attr, afi, safi,
ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL,
NULL, 0, NULL);
}
return BGP_NLRI_PARSE_OK;
}
14 changes: 4 additions & 10 deletions bgpd/bgp_mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,16 +211,10 @@ static void bgp_process_mac_rescan_table(struct bgp *bgp, struct peer *peer,

memcpy(&evpn, bgp_attr_get_evpn_overlay(pi->attr),
sizeof(evpn));
int32_t ret = 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);

if (ret < 0)
bgp_dest_unlock_node(dest);
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);
}
}
}
Expand Down
Loading

0 comments on commit 9eca0bd

Please sign in to comment.