bgpd: clean up variable-shadowing compiler warnings

Clean up -Wshadow warnings in bgp.

Signed-off-by: Mark Stapp <mjs@cisco.com>
This commit is contained in:
Mark Stapp 2025-03-27 08:56:43 -04:00
parent aece400f10
commit 660cbf5651
23 changed files with 235 additions and 249 deletions

View file

@ -1444,11 +1444,11 @@ bgp_attr_malformed(struct bgp_attr_parser_args *args, uint8_t subcode,
uint8_t *notify_datap = (length > 0 ? args->startp : NULL);
if (bgp_debug_update(peer, NULL, NULL, 1)) {
char attr_str[BUFSIZ] = {0};
char str[BUFSIZ] = { 0 };
bgp_dump_attr(attr, attr_str, sizeof(attr_str));
bgp_dump_attr(attr, str, sizeof(str));
zlog_debug("%s: attributes: %s", __func__, attr_str);
zlog_debug("%s: attributes: %s", __func__, str);
}
/* Only relax error handling for eBGP peers */
@ -2043,11 +2043,11 @@ static int bgp_attr_aggregator(struct bgp_attr_parser_args *args)
peer->host, aspath_print(attr->aspath));
if (bgp_debug_update(peer, NULL, NULL, 1)) {
char attr_str[BUFSIZ] = {0};
char str[BUFSIZ] = { 0 };
bgp_dump_attr(attr, attr_str, sizeof(attr_str));
bgp_dump_attr(attr, str, sizeof(str));
zlog_debug("%s: attributes: %s", __func__, attr_str);
zlog_debug("%s: attributes: %s", __func__, str);
}
} else {
SET_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_AGGREGATOR));
@ -2094,11 +2094,11 @@ bgp_attr_as4_aggregator(struct bgp_attr_parser_args *args,
peer->host, aspath_print(attr->aspath));
if (bgp_debug_update(peer, NULL, NULL, 1)) {
char attr_str[BUFSIZ] = {0};
char str[BUFSIZ] = { 0 };
bgp_dump_attr(attr, attr_str, sizeof(attr_str));
bgp_dump_attr(attr, str, sizeof(str));
zlog_debug("%s: attributes: %s", __func__, attr_str);
zlog_debug("%s: attributes: %s", __func__, str);
}
} else {
SET_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_AS4_AGGREGATOR));

View file

@ -30,7 +30,7 @@
DEFINE_MTYPE_STATIC(BGPD, BFD_CONFIG, "BFD configuration data");
extern struct zclient *zclient;
extern struct zclient *bgp_zclient;
static void bfd_session_status_update(struct bfd_session_params *bsp,
const struct bfd_session_status *bss,
@ -651,7 +651,7 @@ DEFUN(no_neighbor_bfd_profile, no_neighbor_bfd_profile_cmd,
void bgp_bfd_init(struct event_loop *tm)
{
/* Initialize BFD client functions */
bfd_protocol_integration_init(zclient, tm);
bfd_protocol_integration_init(bgp_zclient, tm);
/* "neighbor bfd" commands. */
install_element(BGP_NODE, &neighbor_bfd_cmd);

View file

@ -1441,14 +1441,14 @@ static char *_ecommunity_ecom2str(struct ecommunity *ecom, int format, int filte
snprintf(encbuf, sizeof(encbuf), "FS:action %s",
action);
} else if (sub_type == ECOMMUNITY_TRAFFIC_RATE) {
union traffic_rate data;
union traffic_rate rate;
data.rate_byte[3] = *(pnt+2);
data.rate_byte[2] = *(pnt+3);
data.rate_byte[1] = *(pnt+4);
data.rate_byte[0] = *(pnt+5);
rate.rate_byte[3] = *(pnt + 2);
rate.rate_byte[2] = *(pnt + 3);
rate.rate_byte[1] = *(pnt + 4);
rate.rate_byte[0] = *(pnt + 5);
snprintf(encbuf, sizeof(encbuf), "FS:rate %f",
data.rate_float);
rate.rate_float);
} else if (sub_type == ECOMMUNITY_TRAFFIC_MARKING) {
snprintf(encbuf, sizeof(encbuf),
"FS:marking %u", *(pnt + 5));

View file

@ -905,7 +905,7 @@ static enum zclient_send_status bgp_zebra_send_remote_macip(
bool esi_valid;
/* Check socket. */
if (!zclient || zclient->sock < 0) {
if (!bgp_zclient || bgp_zclient->sock < 0) {
if (BGP_DEBUG(zebra, ZEBRA))
zlog_debug("%s: No zclient or zclient->sock exists",
__func__);
@ -923,7 +923,7 @@ static enum zclient_send_status bgp_zebra_send_remote_macip(
if (!esi)
esi = zero_esi;
s = zclient->obuf;
s = bgp_zclient->obuf;
stream_reset(s);
zclient_create_header(
@ -984,7 +984,7 @@ static enum zclient_send_status bgp_zebra_send_remote_macip(
frrtrace(5, frr_bgp, evpn_mac_ip_zsend, add, vpn, p, remote_vtep_ip,
esi);
return zclient_send_message(zclient);
return zclient_send_message(bgp_zclient);
}
/*
@ -998,7 +998,7 @@ bgp_zebra_send_remote_vtep(struct bgp *bgp, struct bgpevpn *vpn,
struct stream *s;
/* Check socket. */
if (!zclient || zclient->sock < 0) {
if (!bgp_zclient || bgp_zclient->sock < 0) {
if (BGP_DEBUG(zebra, ZEBRA))
zlog_debug("%s: No zclient or zclient->sock exists",
__func__);
@ -1014,7 +1014,7 @@ bgp_zebra_send_remote_vtep(struct bgp *bgp, struct bgpevpn *vpn,
return ZCLIENT_SEND_SUCCESS;
}
s = zclient->obuf;
s = bgp_zclient->obuf;
stream_reset(s);
zclient_create_header(
@ -1041,7 +1041,7 @@ bgp_zebra_send_remote_vtep(struct bgp *bgp, struct bgpevpn *vpn,
frrtrace(3, frr_bgp, evpn_bum_vtep_zsend, add, vpn, p);
return zclient_send_message(zclient);
return zclient_send_message(bgp_zclient);
}
/*

View file

@ -1387,7 +1387,7 @@ bgp_zebra_send_remote_es_vtep(struct bgp *bgp, struct bgp_evpn_es_vtep *es_vtep,
uint32_t flags = 0;
/* Check socket. */
if (!zclient || zclient->sock < 0) {
if (!bgp_zclient || bgp_zclient->sock < 0) {
if (BGP_DEBUG(zebra, ZEBRA))
zlog_debug("%s: No zclient or zclient->sock exists",
__func__);
@ -1405,7 +1405,7 @@ bgp_zebra_send_remote_es_vtep(struct bgp *bgp, struct bgp_evpn_es_vtep *es_vtep,
if (CHECK_FLAG(es_vtep->flags, BGP_EVPNES_VTEP_ESR))
SET_FLAG(flags, ZAPI_ES_VTEP_FLAG_ESR_RXED);
s = zclient->obuf;
s = bgp_zclient->obuf;
stream_reset(s);
zclient_create_header(s,
@ -1427,7 +1427,7 @@ bgp_zebra_send_remote_es_vtep(struct bgp *bgp, struct bgp_evpn_es_vtep *es_vtep,
frrtrace(3, frr_bgp, evpn_mh_vtep_zsend, add, es, es_vtep);
return zclient_send_message(zclient);
return zclient_send_message(bgp_zclient);
}
static enum zclient_send_status bgp_evpn_es_vtep_re_eval_active(
@ -2876,7 +2876,7 @@ static void bgp_evpn_l3nhg_zebra_add_v4_or_v6(struct bgp_evpn_es_vrf *es_vrf,
if (!api_nhg.nexthop_num)
return;
zclient_nhg_send(zclient, ZEBRA_NHG_ADD, &api_nhg);
zclient_nhg_send(bgp_zclient, ZEBRA_NHG_ADD, &api_nhg);
}
static bool bgp_evpn_l3nhg_zebra_ok(struct bgp_evpn_es_vrf *es_vrf)
@ -2885,7 +2885,7 @@ static bool bgp_evpn_l3nhg_zebra_ok(struct bgp_evpn_es_vrf *es_vrf)
return false;
/* Check socket. */
if (!zclient || zclient->sock < 0)
if (!bgp_zclient || bgp_zclient->sock < 0)
return false;
return true;
@ -2920,7 +2920,7 @@ static void bgp_evpn_l3nhg_zebra_del_v4_or_v6(struct bgp_evpn_es_vrf *es_vrf,
frrtrace(4, frr_bgp, evpn_mh_nhg_zsend, false, v4_nhg, api_nhg.id,
es_vrf);
zclient_nhg_send(zclient, ZEBRA_NHG_DEL, &api_nhg);
zclient_nhg_send(bgp_zclient, ZEBRA_NHG_DEL, &api_nhg);
}
static void bgp_evpn_l3nhg_zebra_del(struct bgp_evpn_es_vrf *es_vrf)
@ -4476,7 +4476,7 @@ static void bgp_evpn_nh_zebra_update_send(struct bgp_evpn_nh *nh, bool add)
struct bgp *bgp_vrf = nh->bgp_vrf;
/* Check socket. */
if (!zclient || zclient->sock < 0)
if (!bgp_zclient || bgp_zclient->sock < 0)
return;
/* Don't try to register if Zebra doesn't know of this instance. */
@ -4487,7 +4487,7 @@ static void bgp_evpn_nh_zebra_update_send(struct bgp_evpn_nh *nh, bool add)
return;
}
s = zclient->obuf;
s = bgp_zclient->obuf;
stream_reset(s);
zclient_create_header(
@ -4512,7 +4512,7 @@ static void bgp_evpn_nh_zebra_update_send(struct bgp_evpn_nh *nh, bool add)
frrtrace(2, frr_bgp, evpn_mh_nh_rmac_zsend, add, nh);
zclient_send_message(zclient);
zclient_send_message(bgp_zclient);
}
static void bgp_evpn_nh_zebra_update(struct bgp_evpn_nh *nh, bool add)

View file

@ -673,8 +673,6 @@ static inline bool bgp_evpn_is_path_local(struct bgp *bgp,
&& pi->sub_type == BGP_ROUTE_STATIC);
}
extern struct zclient *zclient;
extern void bgp_evpn_install_uninstall_default_route(struct bgp *bgp_vrf,
afi_t afi, safi_t safi,
bool add);

View file

@ -1462,22 +1462,22 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd,
output_count++;
if (use_json && json_array) {
const struct prefix *p =
const struct prefix *pfx =
bgp_dest_get_prefix(rm);
json_prefix_info = json_object_new_object();
json_object_string_addf(json_prefix_info,
"prefix", "%pFX", p);
"prefix", "%pFX", pfx);
json_object_int_add(json_prefix_info,
"prefixLen", p->prefixlen);
"prefixLen", pfx->prefixlen);
json_object_object_add(json_prefix_info,
"paths", json_array);
json_object_object_addf(json_nroute,
json_prefix_info,
"%pFX", p);
"%pFX", pfx);
json_array = NULL;
}
}

View file

@ -26,7 +26,7 @@
#include "bgpd/bgp_debug.h"
#include "bgpd/bgp_errors.h"
extern struct zclient *zclient;
extern struct zclient *bgp_zclient;
/* MPLS Labels hash routines. */
@ -157,7 +157,7 @@ int bgp_parse_fec_update(void)
afi_t afi;
safi_t safi;
s = zclient->ibuf;
s = bgp_zclient->ibuf;
memset(&p, 0, sizeof(p));
p.family = stream_getw(s);
@ -249,7 +249,7 @@ static void bgp_send_fec_register_label_msg(struct bgp_dest *dest, bool reg,
p = bgp_dest_get_prefix(dest);
/* Check socket. */
if (!zclient || zclient->sock < 0)
if (!bgp_zclient || bgp_zclient->sock < 0)
return;
if (BGP_DEBUG(labelpool, LABELPOOL))
@ -258,7 +258,7 @@ static void bgp_send_fec_register_label_msg(struct bgp_dest *dest, bool reg,
/* If the route node has a local_label assigned or the
* path node has an MPLS SR label index allowing zebra to
* derive the label, proceed with registration. */
s = zclient->obuf;
s = bgp_zclient->obuf;
stream_reset(s);
command = (reg) ? ZEBRA_FEC_REGISTER : ZEBRA_FEC_UNREGISTER;
zclient_create_header(s, command, VRF_DEFAULT);
@ -288,7 +288,7 @@ static void bgp_send_fec_register_label_msg(struct bgp_dest *dest, bool reg,
if (reg)
stream_putw_at(s, flags_pos, flags);
zclient_send_message(zclient);
zclient_send_message(bgp_zclient);
}
/**

View file

@ -46,7 +46,7 @@ DEFINE_MTYPE_STATIC(BGPD, MPLSVPN_NH_LABEL_BIND_CACHE,
/*
* Definitions and external declarations.
*/
extern struct zclient *zclient;
extern struct zclient *bgp_zclient;
extern int argv_find_and_parse_vpnvx(struct cmd_token **argv, int argc,
int *index, afi_t *afi)
@ -317,7 +317,7 @@ void vpn_leak_zebra_vrf_label_update(struct bgp *bgp, afi_t afi)
if (label == BGP_PREVENT_VRF_2_VRF_LEAK)
label = MPLS_LABEL_NONE;
zclient_send_vrf_label(zclient, bgp->vrf_id, afi, label, ZEBRA_LSP_BGP);
zclient_send_vrf_label(bgp_zclient, bgp->vrf_id, afi, label, ZEBRA_LSP_BGP);
bgp->vpn_policy[afi].tovpn_zebra_vrf_label_last_sent = label;
}
@ -344,7 +344,7 @@ void vpn_leak_zebra_vrf_label_withdraw(struct bgp *bgp, afi_t afi)
bgp->name_pretty, bgp->vrf_id);
}
zclient_send_vrf_label(zclient, bgp->vrf_id, afi, label, ZEBRA_LSP_BGP);
zclient_send_vrf_label(bgp_zclient, bgp->vrf_id, afi, label, ZEBRA_LSP_BGP);
bgp->vpn_policy[afi].tovpn_zebra_vrf_label_last_sent = label;
}
@ -401,7 +401,7 @@ void vpn_leak_zebra_vrf_sid_update_per_af(struct bgp *bgp, afi_t afi)
ctx.table = vrf->data.l.table_id;
act = afi == AFI_IP ? ZEBRA_SEG6_LOCAL_ACTION_END_DT4
: ZEBRA_SEG6_LOCAL_ACTION_END_DT6;
zclient_send_localsid(zclient, tovpn_sid, bgp->vrf_id, act, &ctx);
zclient_send_localsid(bgp_zclient, tovpn_sid, bgp->vrf_id, act, &ctx);
tovpn_sid_ls = XCALLOC(MTYPE_BGP_SRV6_SID, sizeof(struct in6_addr));
*tovpn_sid_ls = *tovpn_sid;
@ -457,7 +457,7 @@ void vpn_leak_zebra_vrf_sid_update_per_vrf(struct bgp *bgp)
}
ctx.table = vrf->data.l.table_id;
act = ZEBRA_SEG6_LOCAL_ACTION_END_DT46;
zclient_send_localsid(zclient, tovpn_sid, bgp->vrf_id, act, &ctx);
zclient_send_localsid(bgp_zclient, tovpn_sid, bgp->vrf_id, act, &ctx);
tovpn_sid_ls = XCALLOC(MTYPE_BGP_SRV6_SID, sizeof(struct in6_addr));
*tovpn_sid_ls = *tovpn_sid;
@ -519,7 +519,7 @@ void vpn_leak_zebra_vrf_sid_withdraw_per_af(struct bgp *bgp, afi_t afi)
bgp->vpn_policy[afi]
.tovpn_sid_locator->argument_bits_length;
}
zclient_send_localsid(zclient,
zclient_send_localsid(bgp_zclient,
bgp->vpn_policy[afi].tovpn_zebra_vrf_sid_last_sent,
bgp->vrf_id, ZEBRA_SEG6_LOCAL_ACTION_UNSPEC,
&seg6localctx);
@ -564,7 +564,7 @@ void vpn_leak_zebra_vrf_sid_withdraw_per_vrf(struct bgp *bgp)
seg6localctx.argument_len =
bgp->tovpn_sid_locator->argument_bits_length;
}
zclient_send_localsid(zclient, bgp->tovpn_zebra_vrf_sid_last_sent,
zclient_send_localsid(bgp_zclient, bgp->tovpn_zebra_vrf_sid_last_sent,
bgp->vrf_id, ZEBRA_SEG6_LOCAL_ACTION_UNSPEC,
&seg6localctx);
XFREE(MTYPE_BGP_SRV6_SID, bgp->tovpn_zebra_vrf_sid_last_sent);

View file

@ -1460,8 +1460,6 @@ static struct bgp_path_info *bgpL3vpnRte_lookup(struct variable *v, oid name[],
pi = bgp_lookup_route_next(l3vpn_bgp, dest, &prefix, policy,
&nexthop);
if (pi) {
uint8_t vrf_name_len =
strnlen((*l3vpn_bgp)->name, VRF_NAMSIZ);
const struct prefix *p = bgp_dest_get_prefix(*dest);
uint8_t oid_index;
bool v4 = (p->family == AF_INET);
@ -1469,6 +1467,8 @@ static struct bgp_path_info *bgpL3vpnRte_lookup(struct variable *v, oid name[],
: sizeof(struct in6_addr);
struct attr *attr = pi->attr;
vrf_name_len = strnlen((*l3vpn_bgp)->name, VRF_NAMSIZ);
/* copy the index parameters */
oid_copy_str(&name[namelen], (*l3vpn_bgp)->name,
vrf_name_len);

View file

@ -34,7 +34,7 @@
#include "bgpd/bgp_mplsvpn.h"
#include "bgpd/bgp_ecommunity.h"
extern struct zclient *zclient;
extern struct zclient *bgp_zclient;
static void register_zebra_rnh(struct bgp_nexthop_cache *bnc);
static void unregister_zebra_rnh(struct bgp_nexthop_cache *bnc);
@ -667,7 +667,7 @@ static void bgp_process_nexthop_update(struct bgp_nexthop_cache *bnc,
nexthop->vrf_id);
if (ifp)
zclient_send_interface_radv_req(
zclient, nexthop->vrf_id, ifp,
bgp_zclient, nexthop->vrf_id, ifp,
true,
BGP_UNNUM_DEFAULT_RA_INTERVAL);
}
@ -1131,11 +1131,11 @@ static bool make_prefix(int afi, struct bgp_path_info *pi, struct prefix *p,
*/
static void sendmsg_zebra_rnh(struct bgp_nexthop_cache *bnc, int command)
{
bool exact_match = false;
bool match_p = false;
bool resolve_via_default = false;
int ret;
if (!zclient)
if (!bgp_zclient)
return;
/* Don't try to register if Zebra doesn't know of this instance. */
@ -1155,7 +1155,7 @@ static void sendmsg_zebra_rnh(struct bgp_nexthop_cache *bnc, int command)
}
if (command == ZEBRA_NEXTHOP_REGISTER) {
if (CHECK_FLAG(bnc->flags, BGP_NEXTHOP_CONNECTED))
exact_match = true;
match_p = true;
if (CHECK_FLAG(bnc->flags, BGP_STATIC_ROUTE_EXACT_MATCH))
resolve_via_default = true;
}
@ -1165,8 +1165,8 @@ static void sendmsg_zebra_rnh(struct bgp_nexthop_cache *bnc, int command)
zserv_command_string(command), &bnc->prefix,
bnc->bgp->name_pretty);
ret = zclient_send_rnh(zclient, command, &bnc->prefix, SAFI_UNICAST,
exact_match, resolve_via_default,
ret = zclient_send_rnh(bgp_zclient, command, &bnc->prefix, SAFI_UNICAST,
match_p, resolve_via_default,
bnc->bgp->vrf_id);
if (ret == ZCLIENT_SEND_FAILURE) {
flog_warn(EC_BGP_ZEBRA_SEND,
@ -1593,7 +1593,7 @@ void bgp_nht_reg_enhe_cap_intfs(struct peer *peer)
if (!ifp)
continue;
zclient_send_interface_radv_req(zclient,
zclient_send_interface_radv_req(bgp_zclient,
nhop->vrf_id,
ifp, true,
BGP_UNNUM_DEFAULT_RA_INTERVAL);
@ -1643,7 +1643,7 @@ void bgp_nht_dereg_enhe_cap_intfs(struct peer *peer)
if (!ifp)
continue;
zclient_send_interface_radv_req(zclient, nhop->vrf_id, ifp, 0,
zclient_send_interface_radv_req(bgp_zclient, nhop->vrf_id, ifp, 0,
0);
}
}

View file

@ -3148,8 +3148,6 @@ static void bgp_dynamic_capability_paths_limit(uint8_t *pnt, int action,
SET_FLAG(peer->cap, PEER_CAP_PATHS_LIMIT_RCV);
while (data + CAPABILITY_CODE_PATHS_LIMIT_LEN <= end) {
afi_t afi;
safi_t safi;
iana_afi_t pkt_afi;
iana_safi_t pkt_safi;
uint16_t paths_limit = 0;
@ -3508,8 +3506,6 @@ static void bgp_dynamic_capability_llgr(uint8_t *pnt, int action,
SET_FLAG(peer->cap, PEER_CAP_LLGR_RCV);
while (data + BGP_CAP_LLGR_MIN_PACKET_LEN <= end) {
afi_t afi;
safi_t safi;
iana_afi_t pkt_afi;
iana_safi_t pkt_safi;
struct graceful_restart_af graf;
@ -3616,8 +3612,6 @@ static void bgp_dynamic_capability_graceful_restart(uint8_t *pnt, int action,
while (data + GRACEFUL_RESTART_CAPABILITY_PER_AFI_SAFI_SIZE <=
end) {
afi_t afi;
safi_t safi;
iana_afi_t pkt_afi;
iana_safi_t pkt_safi;
struct graceful_restart_af graf;

View file

@ -442,7 +442,7 @@ static bool bgp_pbr_extract(struct bgp_pbr_match_val list[],
struct bgp_pbr_range_port *range)
{
int i = 0;
bool exact_match = false;
bool match_p = false;
if (range)
memset(range, 0, sizeof(struct bgp_pbr_range_port));
@ -457,9 +457,9 @@ static bool bgp_pbr_extract(struct bgp_pbr_match_val list[],
OPERATOR_COMPARE_EQUAL_TO)) {
if (range)
range->min_port = list[i].value;
exact_match = true;
match_p = true;
}
if (exact_match && i > 0)
if (match_p && i > 0)
return false;
if (list[i].compare_operator ==
(OPERATOR_COMPARE_GREATER_THAN +

View file

@ -151,8 +151,6 @@ struct bgp_pbr_config {
bool pbr_interface_any_ipv6;
};
extern struct bgp_pbr_config *bgp_pbr_cfg;
struct bgp_pbr_rule {
uint32_t flags;
struct prefix src;

View file

@ -12034,8 +12034,6 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
/* Line 7 display Originator, Cluster-id */
if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)) ||
CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) {
char buf[BUFSIZ] = {0};
if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))) {
if (json_paths)
json_object_string_addf(json_path,
@ -12047,9 +12045,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn,
}
if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_CLUSTER_LIST))) {
struct cluster_list *cluster =
bgp_attr_get_cluster(attr);
int i;
struct cluster_list *cluster = bgp_attr_get_cluster(attr);
if (json_paths) {
json_cluster_list = json_object_new_object();
@ -13579,7 +13575,7 @@ DEFUN (show_ip_bgp_large_community_list,
afi_t afi = AFI_IP6;
safi_t safi = SAFI_UNICAST;
int idx = 0;
bool exact_match = 0;
bool match_p = 0;
struct bgp *bgp = NULL;
bool uj = use_json(argc, argv);
@ -13596,10 +13592,10 @@ DEFUN (show_ip_bgp_large_community_list,
const char *clist_number_or_name = argv[++idx]->arg;
if (++idx < argc && strmatch(argv[idx]->text, "exact-match"))
exact_match = 1;
match_p = 1;
return bgp_show_lcommunity_list(vty, bgp, clist_number_or_name,
exact_match, afi, safi, uj);
match_p, afi, safi, uj);
}
DEFUN (show_ip_bgp_large_community,
show_ip_bgp_large_community_cmd,
@ -13618,7 +13614,7 @@ DEFUN (show_ip_bgp_large_community,
afi_t afi = AFI_IP6;
safi_t safi = SAFI_UNICAST;
int idx = 0;
bool exact_match = 0;
bool match_p = false;
struct bgp *bgp = NULL;
bool uj = use_json(argc, argv);
uint16_t show_flags = 0;
@ -13636,10 +13632,10 @@ DEFUN (show_ip_bgp_large_community,
if (argv_find(argv, argc, "AA:BB:CC", &idx)) {
if (argv_find(argv, argc, "exact-match", &idx)) {
argc--;
exact_match = 1;
match_p = true;
}
return bgp_show_lcommunity(vty, bgp, argc, argv,
exact_match, afi, safi, uj);
match_p, afi, safi, uj);
} else
return bgp_show(vty, bgp, afi, safi,
bgp_show_type_lcommunity_all, NULL, show_flags,
@ -13910,7 +13906,7 @@ DEFPY(show_ip_bgp, show_ip_bgp_cmd,
void *output_arg = NULL;
struct bgp *bgp = NULL;
int idx = 0;
int exact_match = 0;
int match_p = 0;
char *community = NULL;
bool first = true;
uint16_t show_flags = 0;
@ -13975,7 +13971,7 @@ DEFPY(show_ip_bgp, show_ip_bgp_cmd,
community = maybecomm;
if (argv_find(argv, argc, "exact-match", &idx))
exact_match = 1;
match_p = 1;
if (!community)
sh_type = bgp_show_type_community_all;
@ -13986,7 +13982,7 @@ DEFPY(show_ip_bgp, show_ip_bgp_cmd,
struct community_list *list;
if (argv_find(argv, argc, "exact-match", &idx))
exact_match = 1;
match_p = 1;
list = community_list_lookup(bgp_clist, clist_number_or_name, 0,
COMMUNITY_LIST_MASTER);
@ -13996,7 +13992,7 @@ DEFPY(show_ip_bgp, show_ip_bgp_cmd,
return CMD_WARNING;
}
if (exact_match)
if (match_p)
sh_type = bgp_show_type_community_list_exact;
else
sh_type = bgp_show_type_community_list;
@ -14106,7 +14102,7 @@ DEFPY(show_ip_bgp, show_ip_bgp_cmd,
/* show bgp: AFI_IP6, show ip bgp: AFI_IP */
if (community)
return bgp_show_community(vty, bgp, community,
exact_match, afi, safi,
match_p, afi, safi,
show_flags);
else
return bgp_show(vty, bgp, afi, safi, sh_type,
@ -14151,7 +14147,7 @@ DEFPY(show_ip_bgp, show_ip_bgp_cmd,
if (community)
bgp_show_community(
vty, abgp, community,
exact_match, afi, safi,
match_p, afi, safi,
show_flags);
else
bgp_show(vty, abgp, afi, safi,
@ -14199,7 +14195,7 @@ DEFPY(show_ip_bgp, show_ip_bgp_cmd,
if (community)
bgp_show_community(
vty, abgp, community,
exact_match, afi, safi,
match_p, afi, safi,
show_flags);
else
bgp_show(vty, abgp, afi, safi,
@ -15469,15 +15465,15 @@ show_adj_route(struct vty *vty, struct peer *peer, struct bgp_table *table,
json_net =
json_object_new_object();
struct bgp_path_info bpi;
struct bgp_path_info pathi;
struct bgp_dest buildit = *dest;
struct bgp_dest *pass_in;
if (route_filtered ||
ret == RMAP_DENY) {
bpi.attr = &attr;
bpi.peer = peer;
buildit.info = &bpi;
pathi.attr = &attr;
pathi.peer = peer;
buildit.info = &pathi;
pass_in = &buildit;
} else

View file

@ -1355,7 +1355,7 @@ lib_route_map_entry_match_condition_rmap_match_condition_comm_list_finish(
{
struct routemap_hook_context *rhc;
const char *value;
bool exact_match = false;
bool match_p = false;
bool any = false;
char *argstr;
const char *condition;
@ -1367,13 +1367,13 @@ lib_route_map_entry_match_condition_rmap_match_condition_comm_list_finish(
value = yang_dnode_get_string(args->dnode, "comm-list-name");
if (yang_dnode_exists(args->dnode, "comm-list-name-exact-match"))
exact_match = yang_dnode_get_bool(
match_p = yang_dnode_get_bool(
args->dnode, "./comm-list-name-exact-match");
if (yang_dnode_exists(args->dnode, "comm-list-name-any"))
any = yang_dnode_get_bool(args->dnode, "comm-list-name-any");
if (exact_match) {
if (match_p) {
argstr = XMALLOC(MTYPE_ROUTE_MAP_COMPILED,
strlen(value) + strlen("exact-match") + 2);

View file

@ -967,10 +967,10 @@ static int update_group_show_walkcb(struct update_group *updgrp, void *arg)
if (ctx->uj) {
json_peers = json_object_new_array();
SUBGRP_FOREACH_PEER (subgrp, paf) {
json_object *peer =
json_object *jpeer =
json_object_new_string(
paf->peer->host);
json_object_array_add(json_peers, peer);
json_object_array_add(json_peers, jpeer);
}
json_object_object_add(json_subgrp, "peers",
json_peers);

View file

@ -11504,7 +11504,7 @@ DEFPY (show_bgp_vrfs,
json_vrfs = json_object_new_object();
for (ALL_LIST_ELEMENTS_RO(inst, node, bgp)) {
const char *name;
const char *bname;
/* Skip Views. */
if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW)
@ -11523,18 +11523,18 @@ DEFPY (show_bgp_vrfs,
json_vrf = json_object_new_object();
if (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) {
name = VRF_DEFAULT_NAME;
bname = VRF_DEFAULT_NAME;
type = "DFLT";
} else {
name = bgp->name;
bname = bgp->name;
type = "VRF";
}
show_bgp_vrfs_detail_common(vty, bgp, json_vrf, name, type,
show_bgp_vrfs_detail_common(vty, bgp, json_vrf, bname, type,
false);
if (uj)
json_object_object_add(json_vrfs, name, json_vrf);
json_object_object_add(json_vrfs, bname, json_vrf);
}
if (uj) {

View file

@ -56,8 +56,8 @@
#include "bgpd/bgp_lcommunity.h"
/* All information about zebra. */
struct zclient *zclient = NULL;
struct zclient *zclient_sync;
struct zclient *bgp_zclient = NULL;
struct zclient *bgp_zclient_sync;
static bool bgp_zebra_label_manager_connect(void);
/* hook to indicate vrf status change for SNMP */
@ -69,7 +69,7 @@ DEFINE_MTYPE_STATIC(BGPD, BGP_IF_INFO, "BGP interface context");
/* Can we install into zebra? */
static inline bool bgp_install_info_to_zebra(struct bgp *bgp)
{
if (zclient->sock <= 0)
if (bgp_zclient->sock <= 0)
return false;
if (!IS_BGP_INST_KNOWN_TO_ZEBRA(bgp)) {
@ -1010,15 +1010,15 @@ struct bgp *bgp_tm_bgp;
static void bgp_zebra_tm_connect(struct event *t)
{
struct zclient *zclient;
struct zclient *zc;
int delay = 10, ret = 0;
zclient = EVENT_ARG(t);
if (bgp_tm_status_connected && zclient->sock > 0)
zc = EVENT_ARG(t);
if (bgp_tm_status_connected && zc->sock > 0)
delay = 60;
else {
bgp_tm_status_connected = false;
ret = tm_table_manager_connect(zclient);
ret = tm_table_manager_connect(zc);
}
if (ret < 0) {
zlog_err("Error connecting to table manager!");
@ -1031,7 +1031,7 @@ static void bgp_zebra_tm_connect(struct event *t)
}
bgp_tm_status_connected = true;
if (!bgp_tm_chunk_obtained) {
if (bgp_zebra_get_table_range(zclient, bgp_tm_chunk_size,
if (bgp_zebra_get_table_range(zc, bgp_tm_chunk_size,
&bgp_tm_min,
&bgp_tm_max) >= 0) {
bgp_tm_chunk_obtained = true;
@ -1040,7 +1040,7 @@ static void bgp_zebra_tm_connect(struct event *t)
}
}
}
event_add_timer(bm->master, bgp_zebra_tm_connect, zclient, delay,
event_add_timer(bm->master, bgp_zebra_tm_connect, zc, delay,
&bgp_tm_thread_connect);
}
@ -1071,7 +1071,7 @@ void bgp_zebra_init_tm_connect(struct bgp *bgp)
bgp_tm_min = bgp_tm_max = 0;
bgp_tm_chunk_size = BGP_FLOWSPEC_TABLE_CHUNK;
bgp_tm_bgp = bgp;
event_add_timer(bm->master, bgp_zebra_tm_connect, zclient_sync, delay,
event_add_timer(bm->master, bgp_zebra_tm_connect, bgp_zclient_sync, delay,
&bgp_tm_thread_connect);
}
@ -1650,7 +1650,7 @@ bgp_zebra_announce_actual(struct bgp_dest *dest, struct bgp_path_info *info,
__func__, p, (allow_recursion ? "" : "NOT "));
}
return zclient_route_send(ZEBRA_ROUTE_ADD, zclient, &api);
return zclient_route_send(ZEBRA_ROUTE_ADD, bgp_zclient, &api);
}
@ -1747,7 +1747,7 @@ enum zclient_send_status bgp_zebra_withdraw_actual(struct bgp_dest *dest,
zlog_debug("Tx route delete %s (table id %u) %pFX",
bgp->name_pretty, api.tableid, &api.prefix);
return zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api);
return zclient_route_send(ZEBRA_ROUTE_DELETE, bgp_zclient, &api);
}
/*
@ -2071,19 +2071,19 @@ int bgp_redistribute_set(struct bgp *bgp, afi_t afi, int type,
.table_id = instance,
.vrf_id = bgp->vrf_id,
};
if (redist_lookup_table_direct(&zclient->mi_redist[afi][type], &table) !=
NULL)
if (redist_lookup_table_direct(&bgp_zclient->mi_redist[afi][type],
&table) != NULL)
return CMD_WARNING;
redist_add_table_direct(&zclient->mi_redist[afi][type], &table);
redist_add_table_direct(&bgp_zclient->mi_redist[afi][type], &table);
} else {
if (redist_check_instance(&zclient->mi_redist[afi][type], instance))
if (redist_check_instance(&bgp_zclient->mi_redist[afi][type], instance))
return CMD_WARNING;
redist_add_instance(&zclient->mi_redist[afi][type], instance);
redist_add_instance(&bgp_zclient->mi_redist[afi][type], instance);
}
} else {
if (vrf_bitmap_check(&zclient->redist[afi][type], bgp->vrf_id))
if (vrf_bitmap_check(&bgp_zclient->redist[afi][type], bgp->vrf_id))
return CMD_WARNING;
#ifdef ENABLE_BGP_VNC
@ -2093,7 +2093,7 @@ int bgp_redistribute_set(struct bgp *bgp, afi_t afi, int type,
}
#endif
vrf_bitmap_set(&zclient->redist[afi][type], bgp->vrf_id);
vrf_bitmap_set(&bgp_zclient->redist[afi][type], bgp->vrf_id);
}
/*
@ -2111,7 +2111,7 @@ int bgp_redistribute_set(struct bgp *bgp, afi_t afi, int type,
instance);
/* Send distribute add message to zebra. */
zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, zclient, afi, type,
zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, bgp_zclient, afi, type,
instance, bgp->vrf_id);
return CMD_SUCCESS;
@ -2132,9 +2132,9 @@ int bgp_redistribute_resend(struct bgp *bgp, afi_t afi, int type,
instance);
/* Send distribute add message to zebra. */
zebra_redistribute_send(ZEBRA_REDISTRIBUTE_DELETE, zclient, afi, type,
zebra_redistribute_send(ZEBRA_REDISTRIBUTE_DELETE, bgp_zclient, afi, type,
instance, bgp->vrf_id);
zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, zclient, afi, type,
zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, bgp_zclient, afi, type,
instance, bgp->vrf_id);
return 0;
@ -2214,21 +2214,21 @@ int bgp_redistribute_unreg(struct bgp *bgp, afi_t afi, int type,
.table_id = instance,
.vrf_id = bgp->vrf_id,
};
if (redist_lookup_table_direct(&zclient->mi_redist[afi][type], &table) ==
if (redist_lookup_table_direct(&bgp_zclient->mi_redist[afi][type], &table) ==
NULL)
return CMD_WARNING;
redist_del_table_direct(&zclient->mi_redist[afi][type], &table);
redist_del_table_direct(&bgp_zclient->mi_redist[afi][type], &table);
} else {
if (!redist_check_instance(&zclient->mi_redist[afi][type], instance))
if (!redist_check_instance(&bgp_zclient->mi_redist[afi][type], instance))
return CMD_WARNING;
redist_del_instance(&zclient->mi_redist[afi][type], instance);
redist_del_instance(&bgp_zclient->mi_redist[afi][type], instance);
}
} else {
if (!vrf_bitmap_check(&zclient->redist[afi][type], bgp->vrf_id))
if (!vrf_bitmap_check(&bgp_zclient->redist[afi][type], bgp->vrf_id))
return CMD_WARNING;
vrf_bitmap_unset(&zclient->redist[afi][type], bgp->vrf_id);
vrf_bitmap_unset(&bgp_zclient->redist[afi][type], bgp->vrf_id);
}
if (bgp_install_info_to_zebra(bgp)) {
@ -2237,7 +2237,7 @@ int bgp_redistribute_unreg(struct bgp *bgp, afi_t afi, int type,
zlog_debug("Tx redistribute del %s afi %d %s %d",
bgp->name_pretty, afi,
zebra_route_string(type), instance);
zebra_redistribute_send(ZEBRA_REDISTRIBUTE_DELETE, zclient, afi,
zebra_redistribute_send(ZEBRA_REDISTRIBUTE_DELETE, bgp_zclient, afi,
type, instance, bgp->vrf_id);
}
@ -2325,7 +2325,7 @@ void bgp_redistribute_redo(struct bgp *bgp)
void bgp_zclient_reset(void)
{
zclient_reset(zclient);
zclient_reset(bgp_zclient);
}
/* Register this instance with Zebra. Invoked upon connect (for
@ -2335,14 +2335,14 @@ void bgp_zclient_reset(void)
void bgp_zebra_instance_register(struct bgp *bgp)
{
/* Don't try to register if we're not connected to Zebra */
if (!zclient || zclient->sock < 0)
if (!bgp_zclient || bgp_zclient->sock < 0)
return;
if (BGP_DEBUG(zebra, ZEBRA))
zlog_debug("Registering %s", bgp->name_pretty);
/* Register for router-id, interfaces, redistributed routes. */
zclient_send_reg_requests(zclient, bgp->vrf_id);
zclient_send_reg_requests(bgp_zclient, bgp->vrf_id);
/* For EVPN instance, register to learn about VNIs, if appropriate. */
if (bgp->advertise_all_vni)
@ -2364,7 +2364,7 @@ void bgp_zebra_instance_register(struct bgp *bgp)
void bgp_zebra_instance_deregister(struct bgp *bgp)
{
/* Don't try to deregister if we're not connected to Zebra */
if (zclient->sock < 0)
if (bgp_zclient->sock < 0)
return;
if (BGP_DEBUG(zebra, ZEBRA))
@ -2375,7 +2375,7 @@ void bgp_zebra_instance_deregister(struct bgp *bgp)
bgp_zebra_advertise_all_vni(bgp, 0);
/* Deregister for router-id, interfaces, redistributed routes. */
zclient_send_dereg_requests(zclient, bgp->vrf_id);
zclient_send_dereg_requests(bgp_zclient, bgp->vrf_id);
}
void bgp_zebra_initiate_radv(struct bgp *bgp, struct peer *peer)
@ -2386,7 +2386,7 @@ void bgp_zebra_initiate_radv(struct bgp *bgp, struct peer *peer)
return;
/* Don't try to initiate if we're not connected to Zebra */
if (zclient->sock < 0)
if (bgp_zclient->sock < 0)
return;
if (BGP_DEBUG(zebra, ZEBRA))
@ -2398,7 +2398,7 @@ void bgp_zebra_initiate_radv(struct bgp *bgp, struct peer *peer)
* If we don't have an ifp pointer, call function to find the
* ifps for a numbered enhe peer to turn RAs on.
*/
peer->ifp ? zclient_send_interface_radv_req(zclient, bgp->vrf_id,
peer->ifp ? zclient_send_interface_radv_req(bgp_zclient, bgp->vrf_id,
peer->ifp, 1, ra_interval)
: bgp_nht_reg_enhe_cap_intfs(peer);
}
@ -2406,7 +2406,7 @@ void bgp_zebra_initiate_radv(struct bgp *bgp, struct peer *peer)
void bgp_zebra_terminate_radv(struct bgp *bgp, struct peer *peer)
{
/* Don't try to terminate if we're not connected to Zebra */
if (zclient->sock < 0)
if (bgp_zclient->sock < 0)
return;
if (BGP_DEBUG(zebra, ZEBRA))
@ -2418,7 +2418,7 @@ void bgp_zebra_terminate_radv(struct bgp *bgp, struct peer *peer)
* If we don't have an ifp pointer, call function to find the
* ifps for a numbered enhe peer to turn RAs off.
*/
peer->ifp ? zclient_send_interface_radv_req(zclient, bgp->vrf_id,
peer->ifp ? zclient_send_interface_radv_req(bgp_zclient, bgp->vrf_id,
peer->ifp, 0, 0)
: bgp_nht_dereg_enhe_cap_intfs(peer);
}
@ -2428,7 +2428,7 @@ int bgp_zebra_advertise_subnet(struct bgp *bgp, int advertise, vni_t vni)
struct stream *s = NULL;
/* Check socket. */
if (!zclient || zclient->sock < 0)
if (!bgp_zclient || bgp_zclient->sock < 0)
return 0;
/* Don't try to register if Zebra doesn't know of this instance. */
@ -2440,7 +2440,7 @@ int bgp_zebra_advertise_subnet(struct bgp *bgp, int advertise, vni_t vni)
return 0;
}
s = zclient->obuf;
s = bgp_zclient->obuf;
stream_reset(s);
zclient_create_header(s, ZEBRA_ADVERTISE_SUBNET, bgp->vrf_id);
@ -2448,7 +2448,7 @@ int bgp_zebra_advertise_subnet(struct bgp *bgp, int advertise, vni_t vni)
stream_put3(s, vni);
stream_putw_at(s, 0, stream_get_endp(s));
return zclient_send_message(zclient);
return zclient_send_message(bgp_zclient);
}
int bgp_zebra_advertise_svi_macip(struct bgp *bgp, int advertise, vni_t vni)
@ -2456,14 +2456,14 @@ int bgp_zebra_advertise_svi_macip(struct bgp *bgp, int advertise, vni_t vni)
struct stream *s = NULL;
/* Check socket. */
if (!zclient || zclient->sock < 0)
if (!bgp_zclient || bgp_zclient->sock < 0)
return 0;
/* Don't try to register if Zebra doesn't know of this instance. */
if (!IS_BGP_INST_KNOWN_TO_ZEBRA(bgp))
return 0;
s = zclient->obuf;
s = bgp_zclient->obuf;
stream_reset(s);
zclient_create_header(s, ZEBRA_ADVERTISE_SVI_MACIP, bgp->vrf_id);
@ -2471,7 +2471,7 @@ int bgp_zebra_advertise_svi_macip(struct bgp *bgp, int advertise, vni_t vni)
stream_putl(s, vni);
stream_putw_at(s, 0, stream_get_endp(s));
return zclient_send_message(zclient);
return zclient_send_message(bgp_zclient);
}
int bgp_zebra_advertise_gw_macip(struct bgp *bgp, int advertise, vni_t vni)
@ -2479,7 +2479,7 @@ int bgp_zebra_advertise_gw_macip(struct bgp *bgp, int advertise, vni_t vni)
struct stream *s = NULL;
/* Check socket. */
if (!zclient || zclient->sock < 0)
if (!bgp_zclient || bgp_zclient->sock < 0)
return 0;
/* Don't try to register if Zebra doesn't know of this instance. */
@ -2491,7 +2491,7 @@ int bgp_zebra_advertise_gw_macip(struct bgp *bgp, int advertise, vni_t vni)
return 0;
}
s = zclient->obuf;
s = bgp_zclient->obuf;
stream_reset(s);
zclient_create_header(s, ZEBRA_ADVERTISE_DEFAULT_GW, bgp->vrf_id);
@ -2499,7 +2499,7 @@ int bgp_zebra_advertise_gw_macip(struct bgp *bgp, int advertise, vni_t vni)
stream_putl(s, vni);
stream_putw_at(s, 0, stream_get_endp(s));
return zclient_send_message(zclient);
return zclient_send_message(bgp_zclient);
}
int bgp_zebra_vxlan_flood_control(struct bgp *bgp,
@ -2508,7 +2508,7 @@ int bgp_zebra_vxlan_flood_control(struct bgp *bgp,
struct stream *s;
/* Check socket. */
if (!zclient || zclient->sock < 0)
if (!bgp_zclient || bgp_zclient->sock < 0)
return 0;
/* Don't try to register if Zebra doesn't know of this instance. */
@ -2520,14 +2520,14 @@ int bgp_zebra_vxlan_flood_control(struct bgp *bgp,
return 0;
}
s = zclient->obuf;
s = bgp_zclient->obuf;
stream_reset(s);
zclient_create_header(s, ZEBRA_VXLAN_FLOOD_CONTROL, bgp->vrf_id);
stream_putc(s, flood_ctrl);
stream_putw_at(s, 0, stream_get_endp(s));
return zclient_send_message(zclient);
return zclient_send_message(bgp_zclient);
}
int bgp_zebra_advertise_all_vni(struct bgp *bgp, int advertise)
@ -2535,14 +2535,14 @@ int bgp_zebra_advertise_all_vni(struct bgp *bgp, int advertise)
struct stream *s;
/* Check socket. */
if (!zclient || zclient->sock < 0)
if (!bgp_zclient || bgp_zclient->sock < 0)
return 0;
/* Don't try to register if Zebra doesn't know of this instance. */
if (!IS_BGP_INST_KNOWN_TO_ZEBRA(bgp))
return 0;
s = zclient->obuf;
s = bgp_zclient->obuf;
stream_reset(s);
zclient_create_header(s, ZEBRA_ADVERTISE_ALL_VNI, bgp->vrf_id);
@ -2553,7 +2553,7 @@ int bgp_zebra_advertise_all_vni(struct bgp *bgp, int advertise)
stream_putc(s, bgp->vxlan_flood_ctrl);
stream_putw_at(s, 0, stream_get_endp(s));
return zclient_send_message(zclient);
return zclient_send_message(bgp_zclient);
}
int bgp_zebra_dup_addr_detection(struct bgp *bgp)
@ -2561,7 +2561,7 @@ int bgp_zebra_dup_addr_detection(struct bgp *bgp)
struct stream *s;
/* Check socket. */
if (!zclient || zclient->sock < 0)
if (!bgp_zclient || bgp_zclient->sock < 0)
return 0;
/* Don't try to register if Zebra doesn't know of this instance. */
@ -2578,7 +2578,7 @@ int bgp_zebra_dup_addr_detection(struct bgp *bgp)
"enable" : "disable",
bgp->evpn_info->dad_freeze_time);
s = zclient->obuf;
s = bgp_zclient->obuf;
stream_reset(s);
zclient_create_header(s, ZEBRA_DUPLICATE_ADDR_DETECTION,
bgp->vrf_id);
@ -2589,7 +2589,7 @@ int bgp_zebra_dup_addr_detection(struct bgp *bgp)
stream_putl(s, bgp->evpn_info->dad_freeze_time);
stream_putw_at(s, 0, stream_get_endp(s));
return zclient_send_message(zclient);
return zclient_send_message(bgp_zclient);
}
static int rule_notify_owner(ZAPI_CALLBACK_ARGS)
@ -3965,7 +3965,7 @@ void bgp_if_init(void)
static bool bgp_zebra_label_manager_ready(void)
{
return (zclient_sync->sock > 0);
return (bgp_zclient_sync->sock > 0);
}
static void bgp_start_label_manager(struct event *start)
@ -3979,29 +3979,29 @@ static void bgp_start_label_manager(struct event *start)
static bool bgp_zebra_label_manager_connect(void)
{
/* Connect to label manager. */
if (zclient_socket_connect(zclient_sync) < 0) {
if (zclient_socket_connect(bgp_zclient_sync) < 0) {
zlog_warn("%s: failed connecting synchronous zclient!",
__func__);
return false;
}
/* make socket non-blocking */
set_nonblocking(zclient_sync->sock);
set_nonblocking(bgp_zclient_sync->sock);
/* Send hello to notify zebra this is a synchronous client */
if (zclient_send_hello(zclient_sync) == ZCLIENT_SEND_FAILURE) {
if (zclient_send_hello(bgp_zclient_sync) == ZCLIENT_SEND_FAILURE) {
zlog_warn("%s: failed sending hello for synchronous zclient!",
__func__);
close(zclient_sync->sock);
zclient_sync->sock = -1;
close(bgp_zclient_sync->sock);
bgp_zclient_sync->sock = -1;
return false;
}
/* Connect to label manager */
if (lm_label_manager_connect(zclient_sync, 0) != 0) {
if (lm_label_manager_connect(bgp_zclient_sync, 0) != 0) {
zlog_warn("%s: failed connecting to label manager!", __func__);
if (zclient_sync->sock > 0) {
close(zclient_sync->sock);
zclient_sync->sock = -1;
if (bgp_zclient_sync->sock > 0) {
close(bgp_zclient_sync->sock);
bgp_zclient_sync->sock = -1;
}
return false;
}
@ -4030,22 +4030,22 @@ void bgp_zebra_init(struct event_loop *master, unsigned short instance)
hook_register_prio(if_unreal, 0, bgp_ifp_destroy);
/* Set default values. */
zclient = zclient_new(master, &zclient_options_default, bgp_handlers,
array_size(bgp_handlers));
zclient_init(zclient, ZEBRA_ROUTE_BGP, 0, &bgpd_privs);
zclient->zebra_buffer_write_ready = bgp_zebra_buffer_write_ready;
zclient->zebra_connected = bgp_zebra_connected;
zclient->zebra_capabilities = bgp_zebra_capabilities;
zclient->nexthop_update = bgp_nexthop_update;
zclient->instance = instance;
bgp_zclient = zclient_new(master, &zclient_options_default, bgp_handlers,
array_size(bgp_handlers));
zclient_init(bgp_zclient, ZEBRA_ROUTE_BGP, 0, &bgpd_privs);
bgp_zclient->zebra_buffer_write_ready = bgp_zebra_buffer_write_ready;
bgp_zclient->zebra_connected = bgp_zebra_connected;
bgp_zclient->zebra_capabilities = bgp_zebra_capabilities;
bgp_zclient->nexthop_update = bgp_nexthop_update;
bgp_zclient->instance = instance;
/* Initialize special zclient for synchronous message exchanges. */
zclient_sync = zclient_new(master, &zclient_options_sync, NULL, 0);
zclient_sync->sock = -1;
zclient_sync->redist_default = ZEBRA_ROUTE_BGP;
zclient_sync->instance = instance;
zclient_sync->session_id = 1;
zclient_sync->privs = &bgpd_privs;
bgp_zclient_sync = zclient_new(master, &zclient_options_sync, NULL, 0);
bgp_zclient_sync->sock = -1;
bgp_zclient_sync->redist_default = ZEBRA_ROUTE_BGP;
bgp_zclient_sync->instance = instance;
bgp_zclient_sync->session_id = 1;
bgp_zclient_sync->privs = &bgpd_privs;
if (!bgp_zebra_label_manager_ready())
event_add_timer(master, bgp_start_label_manager, NULL, 1,
@ -4054,17 +4054,17 @@ void bgp_zebra_init(struct event_loop *master, unsigned short instance)
void bgp_zebra_destroy(void)
{
if (zclient == NULL)
if (bgp_zclient == NULL)
return;
zclient_stop(zclient);
zclient_free(zclient);
zclient = NULL;
zclient_stop(bgp_zclient);
zclient_free(bgp_zclient);
bgp_zclient = NULL;
if (zclient_sync == NULL)
if (bgp_zclient_sync == NULL)
return;
zclient_stop(zclient_sync);
zclient_free(zclient_sync);
zclient_sync = NULL;
zclient_stop(bgp_zclient_sync);
zclient_free(bgp_zclient_sync);
bgp_zclient_sync = NULL;
}
int bgp_zebra_num_connects(void)
@ -4090,7 +4090,7 @@ void bgp_send_pbr_rule_action(struct bgp_pbr_action *pbra,
zlog_debug("%s: table %d fwmark %d %d", __func__,
pbra->table_id, pbra->fwmark, install);
}
s = zclient->obuf;
s = bgp_zclient->obuf;
stream_reset(s);
zclient_create_header(s,
@ -4099,7 +4099,7 @@ void bgp_send_pbr_rule_action(struct bgp_pbr_action *pbra,
bgp_encode_pbr_rule_action(s, pbra, pbr);
if ((zclient_send_message(zclient) != ZCLIENT_SEND_FAILURE)
if ((zclient_send_message(bgp_zclient) != ZCLIENT_SEND_FAILURE)
&& install) {
if (!pbr)
pbra->install_in_progress = true;
@ -4118,7 +4118,7 @@ void bgp_send_pbr_ipset_match(struct bgp_pbr_match *pbrim, bool install)
zlog_debug("%s: name %s type %d %d, ID %u", __func__,
pbrim->ipset_name, pbrim->type, install,
pbrim->unique);
s = zclient->obuf;
s = bgp_zclient->obuf;
stream_reset(s);
zclient_create_header(s,
@ -4131,7 +4131,7 @@ void bgp_send_pbr_ipset_match(struct bgp_pbr_match *pbrim, bool install)
bgp_encode_pbr_ipset_match(s, pbrim);
stream_putw_at(s, 0, stream_get_endp(s));
if ((zclient_send_message(zclient) != ZCLIENT_SEND_FAILURE) && install)
if ((zclient_send_message(bgp_zclient) != ZCLIENT_SEND_FAILURE) && install)
pbrim->install_in_progress = true;
}
@ -4146,7 +4146,7 @@ void bgp_send_pbr_ipset_entry_match(struct bgp_pbr_match_entry *pbrime,
zlog_debug("%s: name %s %d %d, ID %u", __func__,
pbrime->backpointer->ipset_name, pbrime->unique,
install, pbrime->unique);
s = zclient->obuf;
s = bgp_zclient->obuf;
stream_reset(s);
zclient_create_header(s,
@ -4159,7 +4159,7 @@ void bgp_send_pbr_ipset_entry_match(struct bgp_pbr_match_entry *pbrime,
bgp_encode_pbr_ipset_entry_match(s, pbrime);
stream_putw_at(s, 0, stream_get_endp(s));
if ((zclient_send_message(zclient) != ZCLIENT_SEND_FAILURE) && install)
if ((zclient_send_message(bgp_zclient) != ZCLIENT_SEND_FAILURE) && install)
pbrime->install_in_progress = true;
}
@ -4218,7 +4218,7 @@ void bgp_send_pbr_iptable(struct bgp_pbr_action *pba,
zlog_debug("%s: name %s type %d mark %d %d, ID %u", __func__,
pbm->ipset_name, pbm->type, pba->fwmark, install,
pbm->unique2);
s = zclient->obuf;
s = bgp_zclient->obuf;
stream_reset(s);
zclient_create_header(s,
@ -4232,7 +4232,7 @@ void bgp_send_pbr_iptable(struct bgp_pbr_action *pba,
if (nb_interface)
bgp_encode_pbr_interface_list(pba->bgp, s, pbm->family);
stream_putw_at(s, 0, stream_get_endp(s));
ret = zclient_send_message(zclient);
ret = zclient_send_message(bgp_zclient);
if (install) {
if (ret != ZCLIENT_SEND_FAILURE)
pba->refcnt++;
@ -4319,7 +4319,7 @@ void bgp_zebra_announce_default(struct bgp *bgp, struct nexthop *nh,
}
zclient_route_send(announce ? ZEBRA_ROUTE_ADD : ZEBRA_ROUTE_DELETE,
zclient, &api);
bgp_zclient, &api);
}
/* Send capabilities to RIB */
@ -4332,7 +4332,7 @@ int bgp_zebra_send_capabilities(struct bgp *bgp, bool disable)
zlog_debug("%s: Sending %sable for %s", __func__,
disable ? "dis" : "en", bgp->name_pretty);
if (zclient == NULL) {
if (bgp_zclient == NULL) {
if (BGP_DEBUG(zebra, ZEBRA))
zlog_debug("%s: %s zclient invalid", __func__,
bgp->name_pretty);
@ -4340,7 +4340,7 @@ int bgp_zebra_send_capabilities(struct bgp *bgp, bool disable)
}
/* Check if the client is connected */
if ((zclient->sock < 0) || (zclient->t_connect)) {
if ((bgp_zclient->sock < 0) || (bgp_zclient->t_connect)) {
if (BGP_DEBUG(zebra, ZEBRA))
zlog_debug("%s: %s client not connected", __func__,
bgp->name_pretty);
@ -4365,7 +4365,7 @@ int bgp_zebra_send_capabilities(struct bgp *bgp, bool disable)
api.vrf_id = bgp->vrf_id;
}
if (zclient_capabilities_send(ZEBRA_CLIENT_CAPABILITIES, zclient, &api)
if (zclient_capabilities_send(ZEBRA_CLIENT_CAPABILITIES, bgp_zclient, &api)
== ZCLIENT_SEND_FAILURE) {
zlog_err("%s(%d): Error sending GR capability to zebra",
bgp->name_pretty, bgp->vrf_id);
@ -4394,7 +4394,7 @@ int bgp_zebra_update(struct bgp *bgp, afi_t afi, safi_t safi,
bgp->name_pretty, afi, safi,
zserv_gr_client_cap_string(type));
if (zclient == NULL) {
if (bgp_zclient == NULL) {
if (BGP_DEBUG(zebra, ZEBRA))
zlog_debug("%s: %s zclient == NULL, invalid", __func__,
bgp->name_pretty);
@ -4402,7 +4402,7 @@ int bgp_zebra_update(struct bgp *bgp, afi_t afi, safi_t safi,
}
/* Check if the client is connected */
if ((zclient->sock < 0) || (zclient->t_connect)) {
if ((bgp_zclient->sock < 0) || (bgp_zclient->t_connect)) {
if (BGP_DEBUG(zebra, ZEBRA))
zlog_debug("%s: %s client not connected", __func__,
bgp->name_pretty);
@ -4414,7 +4414,7 @@ int bgp_zebra_update(struct bgp *bgp, afi_t afi, safi_t safi,
api.vrf_id = bgp->vrf_id;
api.cap = type;
if (zclient_capabilities_send(ZEBRA_CLIENT_CAPABILITIES, zclient, &api)
if (zclient_capabilities_send(ZEBRA_CLIENT_CAPABILITIES, bgp_zclient, &api)
== ZCLIENT_SEND_FAILURE) {
if (BGP_DEBUG(zebra, ZEBRA))
zlog_debug("%s: %s error sending capability", __func__,
@ -4434,14 +4434,14 @@ int bgp_zebra_stale_timer_update(struct bgp *bgp)
zlog_debug("%s: %s Timer Update to %u", __func__,
bgp->name_pretty, bgp->rib_stale_time);
if (zclient == NULL) {
if (bgp_zclient == NULL) {
if (BGP_DEBUG(zebra, ZEBRA))
zlog_debug("zclient invalid");
return BGP_GR_FAILURE;
}
/* Check if the client is connected */
if ((zclient->sock < 0) || (zclient->t_connect)) {
if ((bgp_zclient->sock < 0) || (bgp_zclient->t_connect)) {
if (BGP_DEBUG(zebra, ZEBRA))
zlog_debug("%s: %s client not connected", __func__,
bgp->name_pretty);
@ -4452,7 +4452,7 @@ int bgp_zebra_stale_timer_update(struct bgp *bgp)
api.cap = ZEBRA_CLIENT_RIB_STALE_TIME;
api.stale_removal_time = bgp->rib_stale_time;
api.vrf_id = bgp->vrf_id;
if (zclient_capabilities_send(ZEBRA_CLIENT_CAPABILITIES, zclient, &api)
if (zclient_capabilities_send(ZEBRA_CLIENT_CAPABILITIES, bgp_zclient, &api)
== ZCLIENT_SEND_FAILURE) {
if (BGP_DEBUG(zebra, ZEBRA))
zlog_debug("%s: %s error sending capability", __func__,
@ -4465,12 +4465,12 @@ int bgp_zebra_stale_timer_update(struct bgp *bgp)
int bgp_zebra_srv6_manager_get_locator_chunk(const char *name)
{
return srv6_manager_get_locator_chunk(zclient, name);
return srv6_manager_get_locator_chunk(bgp_zclient, name);
}
int bgp_zebra_srv6_manager_release_locator_chunk(const char *name)
{
return srv6_manager_release_locator_chunk(zclient, name);
return srv6_manager_release_locator_chunk(bgp_zclient, name);
}
/**
@ -4488,7 +4488,7 @@ int bgp_zebra_srv6_manager_get_locator(const char *name)
* Send the Get Locator request to the SRv6 Manager and return the
* result
*/
return srv6_manager_get_locator(zclient, name);
return srv6_manager_get_locator(bgp_zclient, name);
}
/**
@ -4520,7 +4520,7 @@ bool bgp_zebra_request_srv6_sid(const struct srv6_sid_ctx *ctx,
* Send the Get SRv6 SID request to the SRv6 Manager and check the
* result
*/
ret = srv6_manager_get_sid(zclient, ctx, sid_value, locator_name,
ret = srv6_manager_get_sid(bgp_zclient, ctx, sid_value, locator_name,
sid_func);
if (ret < 0) {
zlog_warn("%s: error getting SRv6 SID!", __func__);
@ -4549,7 +4549,7 @@ void bgp_zebra_release_srv6_sid(const struct srv6_sid_ctx *ctx)
* Send the Release SRv6 SID request to the SRv6 Manager and check the
* result
*/
ret = srv6_manager_release_sid(zclient, ctx);
ret = srv6_manager_release_sid(bgp_zclient, ctx);
if (ret < 0) {
zlog_warn("%s: error releasing SRv6 SID!", __func__);
return;
@ -4592,7 +4592,7 @@ void bgp_zebra_send_nexthop_label(int cmd, mpls_label_t label,
znh->labels[i] = out_labels[i];
}
/* vrf_id is DEFAULT_VRF */
zebra_send_mpls_labels(zclient, cmd, &zl);
zebra_send_mpls_labels(bgp_zclient, cmd, &zl);
}
bool bgp_zebra_request_label_range(uint32_t base, uint32_t chunk_size,
@ -4601,10 +4601,10 @@ bool bgp_zebra_request_label_range(uint32_t base, uint32_t chunk_size,
int ret;
uint32_t start, end;
if (!zclient_sync || !bgp_zebra_label_manager_ready())
if (!bgp_zclient_sync || !bgp_zebra_label_manager_ready())
return false;
ret = lm_get_label_chunk(zclient_sync, 0, base, chunk_size, &start,
ret = lm_get_label_chunk(bgp_zclient_sync, 0, base, chunk_size, &start,
&end);
if (ret < 0) {
zlog_warn("%s: error getting label range!", __func__);
@ -4633,10 +4633,10 @@ void bgp_zebra_release_label_range(uint32_t start, uint32_t end)
{
int ret;
if (!zclient_sync || !bgp_zebra_label_manager_ready())
if (!bgp_zclient_sync || !bgp_zebra_label_manager_ready())
return;
ret = lm_release_label_chunk(zclient_sync, start, end);
ret = lm_release_label_chunk(bgp_zclient_sync, start, end);
if (ret < 0)
zlog_warn("%s: error releasing label range!", __func__);
}

View file

@ -8,6 +8,9 @@
#include "vxlan.h"
/* The global zapi session handle */
extern struct zclient *bgp_zclient;
/* Macro to update bgp_original based on bpg_path_info */
#define BGP_ORIGINAL_UPDATE(_bgp_orig, _mpinfo, _bgp) \
((_mpinfo->extra && _mpinfo->extra->vrfleak && \

View file

@ -121,7 +121,7 @@ unsigned int bgp_suppress_fib_count;
static void bgp_if_finish(struct bgp *bgp);
static void peer_drop_dynamic_neighbor(struct peer *peer);
extern struct zclient *zclient;
extern struct zclient *bgp_zclient;
/* handle main socket creation or deletion */
static int bgp_check_main_socket(bool create, struct bgp *bgp)
@ -447,9 +447,9 @@ void bm_wait_for_fib_set(bool set)
send_msg = true;
}
if (send_msg && zclient)
if (send_msg && bgp_zclient)
zebra_route_notify_send(ZEBRA_ROUTE_NOTIFY_REQUEST,
zclient, set);
bgp_zclient, set);
/*
* If this is configed at a time when peers are already set
@ -507,9 +507,9 @@ void bgp_suppress_fib_pending_set(struct bgp *bgp, bool set)
if (BGP_DEBUG(zebra, ZEBRA))
zlog_debug("Sending ZEBRA_ROUTE_NOTIFY_REQUEST");
if (zclient)
if (bgp_zclient)
zebra_route_notify_send(ZEBRA_ROUTE_NOTIFY_REQUEST,
zclient, set);
bgp_zclient, set);
}
/*
@ -3928,16 +3928,16 @@ static void bgp_zclient_set_redist(afi_t afi, int type, unsigned short instance,
{
if (instance) {
if (set)
redist_add_instance(&zclient->mi_redist[afi][type],
redist_add_instance(&bgp_zclient->mi_redist[afi][type],
instance);
else
redist_del_instance(&zclient->mi_redist[afi][type],
redist_del_instance(&bgp_zclient->mi_redist[afi][type],
instance);
} else {
if (set)
vrf_bitmap_set(&zclient->redist[afi][type], vrf_id);
vrf_bitmap_set(&bgp_zclient->redist[afi][type], vrf_id);
else
vrf_bitmap_unset(&zclient->redist[afi][type], vrf_id);
vrf_bitmap_unset(&bgp_zclient->redist[afi][type], vrf_id);
}
}
@ -4289,8 +4289,7 @@ int bgp_delete(struct bgp *bgp)
FOREACH_AFI_SAFI (afi, safi) {
struct bgp_aggregate *aggregate = NULL;
for (struct bgp_dest *dest =
bgp_table_top(bgp->aggregate[afi][safi]);
for (dest = bgp_table_top(bgp->aggregate[afi][safi]);
dest; dest = bgp_route_next(dest)) {
aggregate = bgp_dest_get_bgp_aggregate_info(dest);
if (aggregate == NULL)

View file

@ -1352,11 +1352,11 @@ rfapiRouteInfo2NextHopEntry(struct rfapi_ip_prefix *rprefix,
bgp_attr_extcom_tunnel_type(bpi->attr, &tun_type);
if (tun_type == BGP_ENCAP_TYPE_MPLS) {
struct prefix p;
struct prefix pfx;
/* MPLS carries UN address in next hop */
rfapiNexthop2Prefix(bpi->attr, &p);
if (p.family != AF_UNSPEC) {
rfapiQprefix2Raddr(&p, &new->un_address);
rfapiNexthop2Prefix(bpi->attr, &pfx);
if (pfx.family != AF_UNSPEC) {
rfapiQprefix2Raddr(&pfx, &new->un_address);
have_vnc_tunnel_un = 1;
}
}
@ -1773,7 +1773,7 @@ struct rfapi_next_hop_entry *rfapiRouteNode2NextHopList(
* Add non-withdrawn routes from less-specific prefix
*/
if (parent) {
const struct prefix *p = agg_node_get_prefix(parent);
p = agg_node_get_prefix(parent);
rib_rn = rfd_rib_table ? agg_node_get(rfd_rib_table, p) : NULL;
rfapiQprefix2Rprefix(p, &rprefix);
@ -3224,7 +3224,7 @@ static void rfapiBgpInfoFilteredImportEncap(
__func__, rn);
#endif
for (m = RFAPI_MONITOR_ENCAP(rn); m; m = m->next) {
const struct prefix *p;
const struct prefix *pfx;
/*
* For each referenced bpi/route, copy the ENCAP route's
@ -3252,9 +3252,9 @@ static void rfapiBgpInfoFilteredImportEncap(
* list
* per prefix.
*/
p = agg_node_get_prefix(m->node);
pfx = agg_node_get_prefix(m->node);
referenced_vpn_prefix =
agg_node_get(referenced_vpn_table, p);
agg_node_get(referenced_vpn_table, pfx);
assert(referenced_vpn_prefix);
for (mnext = referenced_vpn_prefix->info; mnext;
mnext = mnext->next) {

View file

@ -338,13 +338,12 @@ static int process_unicast_route(struct bgp *bgp, /* in */
hattr = *attr;
if (rmap) {
struct bgp_path_info info;
struct bgp_path_info pinfo = {};
route_map_result_t ret;
memset(&info, 0, sizeof(info));
info.peer = peer;
info.attr = &hattr;
ret = route_map_apply(rmap, prefix, &info);
pinfo.peer = peer;
pinfo.attr = &hattr;
ret = route_map_apply(rmap, prefix, &pinfo);
if (ret == RMAP_DENYMATCH) {
bgp_attr_flush(&hattr);
vnc_zlog_debug_verbose(
@ -768,13 +767,12 @@ static void vnc_import_bgp_add_route_mode_plain(struct bgp *bgp,
hattr = *attr;
if (rmap) {
struct bgp_path_info info;
struct bgp_path_info pinfo = {};
route_map_result_t ret;
memset(&info, 0, sizeof(info));
info.peer = peer;
info.attr = &hattr;
ret = route_map_apply(rmap, prefix, &info);
pinfo.peer = peer;
pinfo.attr = &hattr;
ret = route_map_apply(rmap, prefix, &pinfo);
if (ret == RMAP_DENYMATCH) {
bgp_attr_flush(&hattr);
vnc_zlog_debug_verbose(