Merge pull request #12709 from donaldsharp/update_withdraw_always_work

bgpd: bgp_update and bgp_withdraw never return failures
This commit is contained in:
Donatas Abraitis 2023-01-31 08:50:06 +02:00 committed by GitHub
commit 9eca0bdc02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 89 additions and 138 deletions

View File

@ -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):
@ -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:
@ -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).
@ -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;
}
/*
@ -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:
@ -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};
@ -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,

View File

@ -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;
@ -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 */
@ -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;
@ -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,

View File

@ -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 */
@ -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;
}

View File

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

View File

@ -3957,11 +3957,11 @@ static bool bgp_accept_own(struct peer *peer, afi_t afi, safi_t safi,
return false;
}
int 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 bgp_route_evpn *evpn)
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 bgp_route_evpn *evpn)
{
int ret;
int aspath_loop_count = 0;
@ -4337,7 +4337,7 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
bgp_dest_unlock_node(dest);
bgp_attr_unintern(&attr_new);
return 0;
return;
}
/* Withdraw/Announce before we fully processed the withdraw */
@ -4551,7 +4551,7 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
ret = bgp_damp_update(pi, dest, afi, safi);
if (ret == BGP_DAMP_SUPPRESSED) {
bgp_dest_unlock_node(dest);
return 0;
return;
}
}
@ -4671,7 +4671,7 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
bgp_unlink_nexthop(pi);
bgp_path_info_delete(dest, pi);
}
return 0;
return;
} // End of implicit withdraw
/* Received Logging. */
@ -4834,7 +4834,7 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
bgp_path_info_delete(dest, new);
}
return 0;
return;
/* This BGP update is filtered. Log the reason then update BGP
entry. */
@ -4897,13 +4897,14 @@ filtered:
}
#endif
return 0;
return;
}
int bgp_withdraw(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, struct bgp_route_evpn *evpn)
void bgp_withdraw(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,
struct bgp_route_evpn *evpn)
{
struct bgp *bgp;
char pfx_buf[BGP_PRD_PATH_STRLEN];
@ -4948,7 +4949,7 @@ int bgp_withdraw(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
peer->host, pfx_buf);
}
bgp_dest_unlock_node(dest);
return 0;
return;
}
/* Lookup withdrawn route. */
@ -4990,7 +4991,7 @@ int bgp_withdraw(struct peer *peer, const struct prefix *p, uint32_t addpath_id,
/* Unlock bgp_node_get() lock. */
bgp_dest_unlock_node(dest);
return 0;
return;
}
void bgp_default_originate(struct peer *peer, afi_t afi, safi_t safi,
@ -5122,10 +5123,10 @@ static void bgp_soft_reconfig_table_flag(struct bgp_table *table, bool flag)
}
}
static int bgp_soft_reconfig_table_update(struct peer *peer,
struct bgp_dest *dest,
struct bgp_adj_in *ain, afi_t afi,
safi_t safi, struct prefix_rd *prd)
static void bgp_soft_reconfig_table_update(struct peer *peer,
struct bgp_dest *dest,
struct bgp_adj_in *ain, afi_t afi,
safi_t safi, struct prefix_rd *prd)
{
struct bgp_path_info *pi;
uint32_t num_labels = 0;
@ -5146,17 +5147,15 @@ static int bgp_soft_reconfig_table_update(struct peer *peer,
else
memset(&evpn, 0, sizeof(evpn));
return 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);
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);
}
static void bgp_soft_reconfig_table(struct peer *peer, afi_t afi, safi_t safi,
struct bgp_table *table,
struct prefix_rd *prd)
{
int ret;
struct bgp_dest *dest;
struct bgp_adj_in *ain;
@ -5168,13 +5167,8 @@ static void bgp_soft_reconfig_table(struct peer *peer, afi_t afi, safi_t safi,
if (ain->peer != peer)
continue;
ret = bgp_soft_reconfig_table_update(peer, dest, ain,
afi, safi, prd);
if (ret < 0) {
bgp_dest_unlock_node(dest);
return;
}
bgp_soft_reconfig_table_update(peer, dest, ain, afi,
safi, prd);
}
}
@ -5189,7 +5183,6 @@ static void bgp_soft_reconfig_table(struct peer *peer, afi_t afi, safi_t safi,
static void bgp_soft_reconfig_table_task(struct thread *thread)
{
uint32_t iter, max_iter;
int ret;
struct bgp_dest *dest;
struct bgp_adj_in *ain;
struct peer *peer;
@ -5222,27 +5215,10 @@ static void bgp_soft_reconfig_table_task(struct thread *thread)
if (ain->peer != peer)
continue;
ret = bgp_soft_reconfig_table_update(
bgp_soft_reconfig_table_update(
peer, dest, ain, table->afi,
table->safi, prd);
iter++;
if (ret < 0) {
bgp_dest_unlock_node(dest);
listnode_delete(
table->soft_reconfig_peers,
peer);
bgp_announce_route(peer, table->afi,
table->safi, false);
if (list_isempty(
table->soft_reconfig_peers)) {
list_delete(
&table->soft_reconfig_peers);
bgp_soft_reconfig_table_flag(
table, false);
return;
}
}
}
}
}
@ -5959,7 +5935,6 @@ int bgp_nlri_parse_ip(struct peer *peer, struct attr *attr,
uint8_t *lim;
struct prefix p;
int psize;
int ret;
afi_t afi;
safi_t safi;
bool addpath_capable;
@ -6072,23 +6047,18 @@ int bgp_nlri_parse_ip(struct peer *peer, struct attr *attr,
/* Normal process. */
if (attr)
ret = bgp_update(peer, &p, addpath_id, attr, afi, safi,
ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
NULL, NULL, 0, 0, NULL);
bgp_update(peer, &p, addpath_id, attr, afi, safi,
ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL,
NULL, 0, 0, NULL);
else
ret = bgp_withdraw(peer, &p, addpath_id, attr, afi,
safi, ZEBRA_ROUTE_BGP,
BGP_ROUTE_NORMAL, NULL, NULL, 0,
NULL);
bgp_withdraw(peer, &p, addpath_id, attr, afi, safi,
ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, NULL,
NULL, 0, NULL);
/* Do not send BGP notification twice when maximum-prefix count
* overflow. */
if (CHECK_FLAG(peer->sflags, PEER_STATUS_PREFIX_OVERFLOW))
return BGP_NLRI_PARSE_ERROR_PREFIX_OVERFLOW;
/* Address family configuration mismatch. */
if (ret < 0)
return BGP_NLRI_PARSE_ERROR_ADDRESS_FAMILY;
}
/* Packet length consistency check. */

View File

@ -750,17 +750,17 @@ extern int bgp_static_unset_safi(afi_t afi, safi_t safi, struct vty *,
const char *, const char *, const char *);
/* this is primarily for MPLS-VPN */
extern int 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 bgp_route_evpn *evpn);
extern int bgp_withdraw(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, struct bgp_route_evpn *evpn);
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 bgp_route_evpn *evpn);
extern void bgp_withdraw(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, struct bgp_route_evpn *evpn);
/* for bgp_nexthop and bgp_damp */
extern void bgp_process(struct bgp *, struct bgp_dest *, afi_t, safi_t);