diff --git a/babeld/babel_interface.c b/babeld/babel_interface.c index c99dadd083..4653b96db4 100644 --- a/babeld/babel_interface.c +++ b/babeld/babel_interface.c @@ -755,8 +755,10 @@ babel_interface_close_all(void) } /* Disable babel redistribution */ for (type = 0; type < ZEBRA_ROUTE_MAX; type++) { - zclient_redistribute (ZEBRA_REDISTRIBUTE_DELETE, zclient, AFI_IP, type, 0, VRF_DEFAULT); - zclient_redistribute (ZEBRA_REDISTRIBUTE_DELETE, zclient, AFI_IP6, type, 0, VRF_DEFAULT); + zclient_redistribute(ZEBRA_REDISTRIBUTE_DELETE, babel_zclient, AFI_IP, type, 0, + VRF_DEFAULT); + zclient_redistribute(ZEBRA_REDISTRIBUTE_DELETE, babel_zclient, AFI_IP6, type, 0, + VRF_DEFAULT); } } @@ -974,6 +976,7 @@ DEFUN (show_babel_route, { struct route_stream *routes = NULL; struct xroute_stream *xroutes = NULL; + routes = route_stream(0); if(routes) { while(1) { diff --git a/babeld/babel_zebra.c b/babeld/babel_zebra.c index bead9f27ef..54f0f79aa0 100644 --- a/babeld/babel_zebra.c +++ b/babeld/babel_zebra.c @@ -19,7 +19,7 @@ void babelz_zebra_init(void); /* we must use a pointer because of zclient.c's functions (new, free). */ -struct zclient *zclient; +struct zclient *babel_zclient; /* Debug types */ static const struct { @@ -94,9 +94,10 @@ DEFUN (babel_redistribute_type, } if (!negate) - zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, afi, type, 0, VRF_DEFAULT); + zclient_redistribute(ZEBRA_REDISTRIBUTE_ADD, babel_zclient, afi, type, 0, VRF_DEFAULT); else { - zclient_redistribute (ZEBRA_REDISTRIBUTE_DELETE, zclient, afi, type, 0, VRF_DEFAULT); + zclient_redistribute(ZEBRA_REDISTRIBUTE_DELETE, babel_zclient, afi, type, 0, + VRF_DEFAULT); /* perhaps should we remove xroutes having the same type... */ } return CMD_SUCCESS; @@ -230,11 +231,11 @@ static zclient_handler *const babel_handlers[] = { void babelz_zebra_init(void) { - zclient = zclient_new(master, &zclient_options_default, babel_handlers, - array_size(babel_handlers)); - zclient_init(zclient, ZEBRA_ROUTE_BABEL, 0, &babeld_privs); + babel_zclient = zclient_new(master, &zclient_options_default, babel_handlers, + array_size(babel_handlers)); + zclient_init(babel_zclient, ZEBRA_ROUTE_BABEL, 0, &babeld_privs); - zclient->zebra_connected = babel_zebra_connected; + babel_zclient->zebra_connected = babel_zebra_connected; install_element(BABEL_NODE, &babel_redistribute_type_cmd); install_element(ENABLE_NODE, &debug_babel_cmd); @@ -248,6 +249,6 @@ void babelz_zebra_init(void) void babel_zebra_close_connexion(void) { - zclient_stop(zclient); - zclient_free(zclient); + zclient_stop(babel_zclient); + zclient_free(babel_zclient); } diff --git a/babeld/babel_zebra.h b/babeld/babel_zebra.h index 7f960d3961..0455bad7e1 100644 --- a/babeld/babel_zebra.h +++ b/babeld/babel_zebra.h @@ -8,7 +8,7 @@ Copyright 2011 by Matthieu Boutier and Juliusz Chroboczek #include "vty.h" -extern struct zclient *zclient; +extern struct zclient *babel_zclient; void babelz_zebra_init(void); void babel_zebra_close_connexion(void); diff --git a/babeld/babeld.c b/babeld/babeld.c index 9943f2e02e..a9ad97509a 100644 --- a/babeld/babeld.c +++ b/babeld/babeld.c @@ -108,8 +108,8 @@ babel_config_write (struct vty *vty) /* list redistributed protocols */ for (afi = AFI_IP; afi <= AFI_IP6; afi++) { for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { - if (i != zclient->redist_default && - vrf_bitmap_check(&zclient->redist[afi][i], VRF_DEFAULT)) { + if (i != babel_zclient->redist_default && + vrf_bitmap_check(&babel_zclient->redist[afi][i], VRF_DEFAULT)) { vty_out(vty, " redistribute %s %s\n", (afi == AFI_IP) ? "ipv4" : "ipv6", zebra_route_string(i)); diff --git a/babeld/kernel.c b/babeld/kernel.c index 4957b04e77..ec562a9e93 100644 --- a/babeld/kernel.c +++ b/babeld/kernel.c @@ -176,8 +176,7 @@ zebra_route(int add, int family, const unsigned char *pref, unsigned short plen, debugf(BABEL_DEBUG_ROUTE, "%s route (%s) to zebra", add ? "adding" : "removing", (family == AF_INET) ? "ipv4" : "ipv6"); - return zclient_route_send (add ? ZEBRA_ROUTE_ADD : ZEBRA_ROUTE_DELETE, - zclient, &api); + return zclient_route_send(add ? ZEBRA_ROUTE_ADD : ZEBRA_ROUTE_DELETE, babel_zclient, &api); } int diff --git a/babeld/route.h b/babeld/route.h index 89427b8415..ec050fd87b 100644 --- a/babeld/route.h +++ b/babeld/route.h @@ -38,7 +38,6 @@ struct babel_route { struct route_stream; -extern struct babel_route **routes; extern int kernel_metric; extern enum babel_diversity diversity_kind; extern int diversity_factor; diff --git a/bfdd/ptm_adapter.c b/bfdd/ptm_adapter.c index 74f2d39878..9728046fba 100644 --- a/bfdd/ptm_adapter.c +++ b/bfdd/ptm_adapter.c @@ -36,7 +36,7 @@ struct ptm_client { TAILQ_HEAD(pcqueue, ptm_client); static struct pcqueue pcqueue; -static struct zclient *zclient; +static struct zclient *bfd_zclient; /* @@ -209,7 +209,7 @@ int ptm_bfd_notify(struct bfd_session *bs, uint8_t notify_state) * * q(64), l(32), w(16), c(8) */ - msg = zclient->obuf; + msg = bfd_zclient->obuf; stream_reset(msg); /* TODO: VRF handling */ @@ -264,7 +264,7 @@ int ptm_bfd_notify(struct bfd_session *bs, uint8_t notify_state) /* Write packet size. */ stream_putw_at(msg, 0, stream_get_endp(msg)); - return zclient_send_message(zclient); + return zclient_send_message(bfd_zclient); } static void _ptm_msg_read_address(struct stream *msg, struct sockaddr_any *sa) @@ -600,7 +600,7 @@ stream_failure: static int bfdd_replay(ZAPI_CALLBACK_ARGS) { - struct stream *msg = zclient->ibuf; + struct stream *msg = bfd_zclient->ibuf; uint32_t rcmd; STREAM_GETL(msg, rcmd); @@ -653,7 +653,7 @@ static void bfdd_zebra_connected(struct zclient *zc) zclient_create_header(msg, ZEBRA_INTERFACE_ADD, VRF_DEFAULT); /* Send requests. */ - zclient_send_message(zclient); + zclient_send_message(zc); } static void bfdd_sessions_enable_interface(struct interface *ifp) @@ -837,32 +837,32 @@ void bfdd_zclient_init(struct zebra_privs_t *bfdd_priv) { hook_register_prio(if_real, 0, bfd_ifp_create); hook_register_prio(if_unreal, 0, bfd_ifp_destroy); - zclient = zclient_new(master, &zclient_options_default, bfd_handlers, - array_size(bfd_handlers)); - assert(zclient != NULL); - zclient_init(zclient, ZEBRA_ROUTE_BFD, 0, bfdd_priv); + bfd_zclient = zclient_new(master, &zclient_options_default, bfd_handlers, + array_size(bfd_handlers)); + assert(bfd_zclient != NULL); + zclient_init(bfd_zclient, ZEBRA_ROUTE_BFD, 0, bfdd_priv); /* Send replay request on zebra connect. */ - zclient->zebra_connected = bfdd_zebra_connected; + bfd_zclient->zebra_connected = bfdd_zebra_connected; } void bfdd_zclient_register(vrf_id_t vrf_id) { - if (!zclient || zclient->sock < 0) + if (!bfd_zclient || bfd_zclient->sock < 0) return; - zclient_send_reg_requests(zclient, vrf_id); + zclient_send_reg_requests(bfd_zclient, vrf_id); } void bfdd_zclient_unregister(vrf_id_t vrf_id) { - if (!zclient || zclient->sock < 0) + if (!bfd_zclient || bfd_zclient->sock < 0) return; - zclient_send_dereg_requests(zclient, vrf_id); + zclient_send_dereg_requests(bfd_zclient, vrf_id); } void bfdd_zclient_stop(void) { - zclient_stop(zclient); + zclient_stop(bfd_zclient); /* Clean-up and free ptm clients data memory. */ pc_free_all(); @@ -870,7 +870,7 @@ void bfdd_zclient_stop(void) void bfdd_zclient_terminate(void) { - zclient_free(zclient); + zclient_free(bfd_zclient); } diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c index 9f8f1f6c69..b4adf47eb0 100644 --- a/bgpd/bgp_attr.c +++ b/bgpd/bgp_attr.c @@ -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)); diff --git a/bgpd/bgp_bfd.c b/bgpd/bgp_bfd.c index 5437b67f34..cef1192c10 100644 --- a/bgpd/bgp_bfd.c +++ b/bgpd/bgp_bfd.c @@ -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); diff --git a/bgpd/bgp_ecommunity.c b/bgpd/bgp_ecommunity.c index dcdf2ba25d..95c78cc49d 100644 --- a/bgpd/bgp_ecommunity.c +++ b/bgpd/bgp_ecommunity.c @@ -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)); diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c index 90c196ac91..0ebef2ecfe 100644 --- a/bgpd/bgp_evpn.c +++ b/bgpd/bgp_evpn.c @@ -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); } /* diff --git a/bgpd/bgp_evpn_mh.c b/bgpd/bgp_evpn_mh.c index bffbda75f7..70040f83b9 100644 --- a/bgpd/bgp_evpn_mh.c +++ b/bgpd/bgp_evpn_mh.c @@ -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) diff --git a/bgpd/bgp_evpn_private.h b/bgpd/bgp_evpn_private.h index 568d3d45ee..51d32b5003 100644 --- a/bgpd/bgp_evpn_private.h +++ b/bgpd/bgp_evpn_private.h @@ -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); diff --git a/bgpd/bgp_evpn_vty.c b/bgpd/bgp_evpn_vty.c index 571cca22fd..bfd8fd7c22 100644 --- a/bgpd/bgp_evpn_vty.c +++ b/bgpd/bgp_evpn_vty.c @@ -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; } } diff --git a/bgpd/bgp_label.c b/bgpd/bgp_label.c index 8ed9584b0a..94f0659e44 100644 --- a/bgpd/bgp_label.c +++ b/bgpd/bgp_label.c @@ -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); } /** diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index 0260cc2c3b..038f38a49b 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -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); diff --git a/bgpd/bgp_mplsvpn_snmp.c b/bgpd/bgp_mplsvpn_snmp.c index 93d9f67245..4a696fdcbf 100644 --- a/bgpd/bgp_mplsvpn_snmp.c +++ b/bgpd/bgp_mplsvpn_snmp.c @@ -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); diff --git a/bgpd/bgp_nht.c b/bgpd/bgp_nht.c index 5220c728f1..330af64379 100644 --- a/bgpd/bgp_nht.c +++ b/bgpd/bgp_nht.c @@ -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); } } diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c index f3ee837498..b18ebf411c 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -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; diff --git a/bgpd/bgp_pbr.c b/bgpd/bgp_pbr.c index b85a8e2254..be4c4741fd 100644 --- a/bgpd/bgp_pbr.c +++ b/bgpd/bgp_pbr.c @@ -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 + diff --git a/bgpd/bgp_pbr.h b/bgpd/bgp_pbr.h index cb16c4dc2e..c8116506a7 100644 --- a/bgpd/bgp_pbr.h +++ b/bgpd/bgp_pbr.h @@ -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; diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 5dd474c4e7..bb87406048 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -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 diff --git a/bgpd/bgp_routemap_nb_config.c b/bgpd/bgp_routemap_nb_config.c index 5f5274c5e1..cf189a6aaf 100644 --- a/bgpd/bgp_routemap_nb_config.c +++ b/bgpd/bgp_routemap_nb_config.c @@ -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); diff --git a/bgpd/bgp_updgrp.c b/bgpd/bgp_updgrp.c index 04e6a83552..d880c7b399 100644 --- a/bgpd/bgp_updgrp.c +++ b/bgpd/bgp_updgrp.c @@ -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); diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 66a2fe7997..0b0ed79baf 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -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) { diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index b953da57ce..6a874d53b6 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -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__); } diff --git a/bgpd/bgp_zebra.h b/bgpd/bgp_zebra.h index 7e9d57cb85..fa5b9fc91b 100644 --- a/bgpd/bgp_zebra.h +++ b/bgpd/bgp_zebra.h @@ -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 && \ diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index e57b6dd824..31cd573aee 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -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); } /* @@ -3929,16 +3929,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); } } @@ -4290,8 +4290,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) diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c index 8f1184170d..0d5a18afbb 100644 --- a/bgpd/rfapi/rfapi_import.c +++ b/bgpd/rfapi/rfapi_import.c @@ -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) { diff --git a/bgpd/rfapi/vnc_import_bgp.c b/bgpd/rfapi/vnc_import_bgp.c index e688638ed7..612caed0cf 100644 --- a/bgpd/rfapi/vnc_import_bgp.c +++ b/bgpd/rfapi/vnc_import_bgp.c @@ -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( diff --git a/configure.ac b/configure.ac index f9f3286563..00a5620529 100644 --- a/configure.ac +++ b/configure.ac @@ -467,6 +467,7 @@ AC_C_FLAG([-Wbad-function-cast]) AC_C_FLAG([-Wwrite-strings]) AC_C_FLAG([-Wundef]) AC_C_FLAG([-Wimplicit-fallthrough]) +AC_C_FLAG([-Wshadow]) if test "$enable_gcc_ultra_verbose" = "yes" ; then AC_C_FLAG([-Wcast-qual]) AC_C_FLAG([-Wmissing-noreturn]) @@ -474,7 +475,6 @@ if test "$enable_gcc_ultra_verbose" = "yes" ; then AC_C_FLAG([-Wunreachable-code]) AC_C_FLAG([-Wpacked]) AC_C_FLAG([-Wpadded]) - AC_C_FLAG([-Wshadow]) else AC_C_FLAG([-Wno-unused-result]) fi diff --git a/eigrpd/eigrp_northbound.c b/eigrpd/eigrp_northbound.c index 90af47e9e2..de6da954cf 100644 --- a/eigrpd/eigrp_northbound.c +++ b/eigrpd/eigrp_northbound.c @@ -739,7 +739,7 @@ static int eigrpd_instance_redistribute_create(struct nb_cb_create_args *args) else vrfid = VRF_DEFAULT; - if (vrf_bitmap_check(&zclient->redist[AFI_IP][proto], vrfid)) + if (vrf_bitmap_check(&eigrp_zclient->redist[AFI_IP][proto], vrfid)) return NB_ERR_INCONSISTENCY; break; case NB_EV_PREPARE: diff --git a/eigrpd/eigrp_vty.c b/eigrpd/eigrp_vty.c index 1a81a338bb..2ad4a25422 100644 --- a/eigrpd/eigrp_vty.c +++ b/eigrpd/eigrp_vty.c @@ -280,14 +280,14 @@ DEFPY (show_ip_eigrp_neighbors, struct eigrp *eigrp; if (vrf && strncmp(vrf, "all", sizeof("all")) == 0) { - struct vrf *vrf; + struct vrf *tvrf; - RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { - eigrp = eigrp_lookup(vrf->vrf_id); + RB_FOREACH (tvrf, vrf_name_head, &vrfs_by_name) { + eigrp = eigrp_lookup(tvrf->vrf_id); if (!eigrp) continue; - vty_out(vty, "VRF %s:\n", vrf->name); + vty_out(vty, "VRF %s:\n", tvrf->name); eigrp_neighbors_helper(vty, eigrp, ifname, detail); } diff --git a/eigrpd/eigrp_zebra.c b/eigrpd/eigrp_zebra.c index 5b0c64ffd0..955a3203ac 100644 --- a/eigrpd/eigrp_zebra.c +++ b/eigrpd/eigrp_zebra.c @@ -46,7 +46,7 @@ static int eigrp_interface_address_delete(ZAPI_CALLBACK_ARGS); static int eigrp_zebra_read_route(ZAPI_CALLBACK_ARGS); /* Zebra structure to hold current status. */ -struct zclient *zclient = NULL; +struct zclient *eigrp_zclient = NULL; /* For registering threads. */ extern struct event_loop *master; @@ -98,17 +98,17 @@ static zclient_handler *const eigrp_handlers[] = { void eigrp_zebra_init(void) { - zclient = zclient_new(master, &zclient_options_default, eigrp_handlers, - array_size(eigrp_handlers)); + eigrp_zclient = zclient_new(master, &zclient_options_default, eigrp_handlers, + array_size(eigrp_handlers)); - zclient_init(zclient, ZEBRA_ROUTE_EIGRP, 0, &eigrpd_privs); - zclient->zebra_connected = eigrp_zebra_connected; + zclient_init(eigrp_zclient, ZEBRA_ROUTE_EIGRP, 0, &eigrpd_privs); + eigrp_zclient->zebra_connected = eigrp_zebra_connected; } void eigrp_zebra_stop(void) { - zclient_stop(zclient); - zclient_free(zclient); + zclient_stop(eigrp_zclient); + zclient_free(eigrp_zclient); } /* Zebra route add and delete treatment. */ @@ -192,7 +192,7 @@ void eigrp_zebra_route_add(struct eigrp *eigrp, struct prefix *p, struct listnode *node; int count = 0; - if (!zclient->redist[AFI_IP][ZEBRA_ROUTE_EIGRP]) + if (!eigrp_zclient->redist[AFI_IP][ZEBRA_ROUTE_EIGRP]) return; memset(&api, 0, sizeof(api)); @@ -226,14 +226,14 @@ void eigrp_zebra_route_add(struct eigrp *eigrp, struct prefix *p, zlog_debug("Zebra: Route add %pFX", p); } - zclient_route_send(ZEBRA_ROUTE_ADD, zclient, &api); + zclient_route_send(ZEBRA_ROUTE_ADD, eigrp_zclient, &api); } void eigrp_zebra_route_delete(struct eigrp *eigrp, struct prefix *p) { struct zapi_route api; - if (!zclient->redist[AFI_IP][ZEBRA_ROUTE_EIGRP]) + if (!eigrp_zclient->redist[AFI_IP][ZEBRA_ROUTE_EIGRP]) return; memset(&api, 0, sizeof(api)); @@ -241,7 +241,7 @@ void eigrp_zebra_route_delete(struct eigrp *eigrp, struct prefix *p) api.type = ZEBRA_ROUTE_EIGRP; api.safi = SAFI_UNICAST; memcpy(&api.prefix, p, sizeof(*p)); - zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api); + zclient_route_send(ZEBRA_ROUTE_DELETE, eigrp_zclient, &api); if (IS_DEBUG_EIGRP(zebra, ZEBRA_REDISTRIBUTE)) zlog_debug("Zebra: Route del %pFX", p); @@ -252,10 +252,8 @@ void eigrp_zebra_route_delete(struct eigrp *eigrp, struct prefix *p) static int eigrp_is_type_redistributed(int type, vrf_id_t vrf_id) { return ((DEFAULT_ROUTE_TYPE(type)) - ? vrf_bitmap_check( - &zclient->default_information[AFI_IP], vrf_id) - : vrf_bitmap_check(&zclient->redist[AFI_IP][type], - vrf_id)); + ? vrf_bitmap_check(&eigrp_zclient->default_information[AFI_IP], vrf_id) + : vrf_bitmap_check(&eigrp_zclient->redist[AFI_IP][type], vrf_id)); } int eigrp_redistribute_set(struct eigrp *eigrp, int type, @@ -280,7 +278,7 @@ int eigrp_redistribute_set(struct eigrp *eigrp, int type, eigrp->dmetric[type] = metric; - zclient_redistribute(ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP, type, 0, + zclient_redistribute(ZEBRA_REDISTRIBUTE_ADD, eigrp_zclient, AFI_IP, type, 0, eigrp->vrf_id); ++eigrp->redistribute; @@ -293,7 +291,7 @@ int eigrp_redistribute_unset(struct eigrp *eigrp, int type) if (eigrp_is_type_redistributed(type, eigrp->vrf_id)) { memset(&eigrp->dmetric[type], 0, sizeof(struct eigrp_metrics)); - zclient_redistribute(ZEBRA_REDISTRIBUTE_DELETE, zclient, AFI_IP, + zclient_redistribute(ZEBRA_REDISTRIBUTE_DELETE, eigrp_zclient, AFI_IP, type, 0, eigrp->vrf_id); --eigrp->redistribute; } diff --git a/eigrpd/eigrpd.c b/eigrpd/eigrpd.c index 543a54da13..bc7c60c501 100644 --- a/eigrpd/eigrpd.c +++ b/eigrpd/eigrpd.c @@ -52,7 +52,6 @@ static struct eigrp_master eigrp_master; struct eigrp_master *eigrp_om; -extern struct zclient *zclient; extern struct in_addr router_id_zebra; int eigrp_master_hash_cmp(const struct eigrp *a, const struct eigrp *b) diff --git a/eigrpd/eigrpd.h b/eigrpd/eigrpd.h index 15d2bb54ee..28b1dc9a11 100644 --- a/eigrpd/eigrpd.h +++ b/eigrpd/eigrpd.h @@ -52,7 +52,7 @@ struct eigrp_master { }; /* Extern variables. */ -extern struct zclient *zclient; +extern struct zclient *eigrp_zclient; extern struct event_loop *master; extern struct eigrp_master *eigrp_om; extern struct zebra_privs_t eigrpd_privs; diff --git a/isisd/isis_adjacency.c b/isisd/isis_adjacency.c index 078280acf5..39ed076fab 100644 --- a/isisd/isis_adjacency.c +++ b/isisd/isis_adjacency.c @@ -653,7 +653,6 @@ void isis_adj_print_json(struct isis_adjacency *adj, struct json_object *json, json_object_object_add(iface_json, "ipv6-link-local", ipv6_link_json); for (unsigned int i = 0; i < adj->ll_ipv6_count; i++) { - char buf[INET6_ADDRSTRLEN]; inet_ntop(AF_INET6, &adj->ll_ipv6_addrs[i], buf, sizeof(buf)); json_object_string_add(ipv6_link_json, "ipv6", @@ -666,7 +665,6 @@ void isis_adj_print_json(struct isis_adjacency *adj, struct json_object *json, ipv6_non_link_json); for (unsigned int i = 0; i < adj->global_ipv6_count; i++) { - char buf[INET6_ADDRSTRLEN]; inet_ntop(AF_INET6, &adj->global_ipv6_addrs[i], buf, sizeof(buf)); json_object_string_add(ipv6_non_link_json, diff --git a/isisd/isis_bfd.c b/isisd/isis_bfd.c index 5e24e35210..c003b8002d 100644 --- a/isisd/isis_bfd.c +++ b/isisd/isis_bfd.c @@ -211,7 +211,7 @@ static int bfd_handle_circuit_add_addr(struct isis_circuit *circuit) void isis_bfd_init(struct event_loop *tm) { - bfd_protocol_integration_init(zclient, tm); + bfd_protocol_integration_init(isis_zclient, tm); hook_register(isis_adj_state_change_hook, bfd_handle_adj_state_change); hook_register(isis_adj_ip_enabled_hook, bfd_handle_adj_ip_enabled); diff --git a/isisd/isis_flags.c b/isisd/isis_flags.c index a621b4b5ed..09f46fbb58 100644 --- a/isisd/isis_flags.c +++ b/isisd/isis_flags.c @@ -26,12 +26,14 @@ long int flags_get_index(struct flags *flags) { struct listnode *node; long int index; + const void *ptr; if (flags->free_idcs == NULL || flags->free_idcs->count == 0) { index = flags->maxindex++; } else { node = listhead(flags->free_idcs); - index = (long int)listgetdata(node); + ptr = listgetdata(node); + index = (long int)ptr; listnode_delete(flags->free_idcs, (void *)index); index--; } diff --git a/isisd/isis_ldp_sync.c b/isisd/isis_ldp_sync.c index 53676ffe36..99e9227ad5 100644 --- a/isisd/isis_ldp_sync.c +++ b/isisd/isis_ldp_sync.c @@ -40,10 +40,9 @@ #include "isisd/isis_errors.h" #include "isisd/isis_tx_queue.h" #include "isisd/isis_nb.h" +#include "isisd/isis_zebra.h" #include "isisd/isis_ldp_sync.h" -extern struct zclient *zclient; - /* * LDP-SYNC msg between IGP and LDP */ @@ -122,8 +121,8 @@ void isis_ldp_sync_state_req_msg(struct isis_circuit *circuit) request.proto = LDP_IGP_SYNC_IF_STATE_REQUEST; request.ifindex = ifp->ifindex; - zclient_send_opaque(zclient, LDP_IGP_SYNC_IF_STATE_REQUEST, - (uint8_t *)&request, sizeof(request)); + zclient_send_opaque(isis_zclient, LDP_IGP_SYNC_IF_STATE_REQUEST, + (uint8_t *)&request, sizeof(request)); } /* diff --git a/isisd/isis_lsp.c b/isisd/isis_lsp.c index 28b987df38..4952c689fc 100644 --- a/isisd/isis_lsp.c +++ b/isisd/isis_lsp.c @@ -1125,7 +1125,6 @@ static void lsp_build(struct isis_lsp *lsp, struct isis_area *area) struct isis_router_cap *rcap; #ifndef FABRICD struct isis_router_cap_fad *rcap_fad; - struct listnode *node; struct flex_algo *fa; #endif /* ifndef FABRICD */ diff --git a/isisd/isis_route.c b/isisd/isis_route.c index b907c962be..0a0c6341d6 100644 --- a/isisd/isis_route.c +++ b/isisd/isis_route.c @@ -240,7 +240,7 @@ isis_route_info_new(struct prefix *prefix, struct prefix_ipv6 *src_p, for (ALL_LIST_ELEMENTS_RO(adjacencies, node, vadj)) { struct isis_spf_adj *sadj = vadj->sadj; struct isis_adjacency *adj = sadj->adj; - struct isis_sr_psid_info *sr = &vadj->sr; + struct isis_sr_psid_info *vsr = &vadj->sr; struct mpls_label_stack *label_stack = vadj->label_stack; /* @@ -248,7 +248,7 @@ isis_route_info_new(struct prefix *prefix, struct prefix_ipv6 *src_p, * environment. */ if (CHECK_FLAG(im->options, F_ISIS_UNIT_TEST)) { - isis_route_add_dummy_nexthops(rinfo, sadj->id, sr, + isis_route_add_dummy_nexthops(rinfo, sadj->id, vsr, label_stack); if (!allow_ecmp) break; @@ -260,7 +260,7 @@ isis_route_info_new(struct prefix *prefix, struct prefix_ipv6 *src_p, ISIS_CIRCUIT_FLAPPED_AFTER_SPF)) SET_FLAG(rinfo->flag, ISIS_ROUTE_FLAG_ZEBRA_RESYNC); - adjinfo2nexthop(prefix->family, rinfo->nexthops, adj, sr, + adjinfo2nexthop(prefix->family, rinfo->nexthops, adj, vsr, label_stack); if (!allow_ecmp) break; diff --git a/isisd/isis_snmp.c b/isisd/isis_snmp.c index 83a06b6998..24320e9ed9 100644 --- a/isisd/isis_snmp.c +++ b/isisd/isis_snmp.c @@ -692,15 +692,15 @@ static int isis_circuit_snmp_id_free(struct isis_circuit *circuit) static struct isis_circuit *isis_snmp_circuit_next(struct isis_circuit *circuit) { uint32_t start; - uint32_t off; + uint32_t offset; start = 1; if (circuit != NULL) start = circuit->snmp_id + 1; - for (off = start; off < SNMP_CIRCUITS_MAX; off++) { - circuit = snmp_circuits[off]; + for (offset = start; offset < SNMP_CIRCUITS_MAX; offset++) { + circuit = snmp_circuits[offset]; if (circuit != NULL) return circuit; @@ -759,7 +759,7 @@ static int isis_snmp_get_level_match(int is_type, int level) static int isis_snmp_conv_exact(uint8_t *buf, size_t max_len, size_t *out_len, const oid *idx, size_t idx_len) { - size_t off; + size_t offset; size_t len; /* Oid representation: length followed by bytes */ @@ -774,11 +774,11 @@ static int isis_snmp_conv_exact(uint8_t *buf, size_t max_len, size_t *out_len, if (idx_len < len + 1) return 0; - for (off = 0; off < len; off++) { - if (idx[off + 1] > 0xff) + for (offset = 0; offset < len; offset++) { + if (idx[offset + 1] > 0xff) return 0; - buf[off] = (uint8_t)(idx[off + 1] & 0xff); + buf[offset] = (uint8_t)(idx[offset + 1] & 0xff); } *out_len = len; @@ -789,7 +789,7 @@ static int isis_snmp_conv_exact(uint8_t *buf, size_t max_len, size_t *out_len, static int isis_snmp_conv_next(uint8_t *buf, size_t max_len, size_t *out_len, int *try_exact, const oid *idx, size_t idx_len) { - size_t off; + size_t offset; size_t len; size_t cmp_len; @@ -809,15 +809,15 @@ static int isis_snmp_conv_next(uint8_t *buf, size_t max_len, size_t *out_len, if ((idx_len - 1) < cmp_len) cmp_len = idx_len - 1; - for (off = 0; off < cmp_len; off++) { - if (idx[off + 1] > 0xff) { - memset(buf + off, 0xff, len - off); + for (offset = 0; offset < cmp_len; offset++) { + if (idx[offset + 1] > 0xff) { + memset(buf + offset, 0xff, len - off); *out_len = len; *try_exact = 1; return 1; } - buf[off] = (uint8_t)(idx[off + 1] & 0xff); + buf[offset] = (uint8_t)(idx[offset + 1] & 0xff); } if (cmp_len < len) @@ -983,7 +983,7 @@ static int isis_snmp_circuit_lookup_exact(oid *oid_idx, size_t oid_idx_len, static int isis_snmp_circuit_lookup_next(oid *oid_idx, size_t oid_idx_len, struct isis_circuit **ret_circuit) { - oid off; + oid offset; oid start; struct isis_circuit *circuit; @@ -996,10 +996,10 @@ static int isis_snmp_circuit_lookup_next(oid *oid_idx, size_t oid_idx_len, start = oid_idx[0]; } - for (off = start; off < SNMP_CIRCUITS_MAX; ++off) { - circuit = snmp_circuits[off]; + for (offset = start; offset < SNMP_CIRCUITS_MAX; ++offset) { + circuit = snmp_circuits[offset]; - if (circuit != NULL && off > start) { + if (circuit != NULL && offset > start) { if (ret_circuit != NULL) *ret_circuit = circuit; @@ -1052,7 +1052,7 @@ static int isis_snmp_circuit_level_lookup_next( oid *oid_idx, size_t oid_idx_len, int check_match, struct isis_circuit **ret_circuit, int *ret_level) { - oid off; + oid offset; oid start; struct isis_circuit *circuit = NULL; int level; @@ -1066,13 +1066,13 @@ static int isis_snmp_circuit_level_lookup_next( start = oid_idx[0]; } - for (off = start; off < SNMP_CIRCUITS_MAX; off++) { - circuit = snmp_circuits[off]; + for (offset = start; offset < SNMP_CIRCUITS_MAX; offset++) { + circuit = snmp_circuits[offset]; if (circuit == NULL) continue; - if (off > start || oid_idx_len < 2) { + if (offset > start || oid_idx_len < 2) { /* Found and can use level 1 */ level = IS_LEVEL_1; break; @@ -1504,7 +1504,7 @@ static uint8_t *isis_snmp_find_man_area(struct variable *v, oid *name, struct iso_address *area_addr = NULL; oid *oid_idx; size_t oid_idx_len; - size_t off = 0; + size_t offset = 0; *write_method = NULL; @@ -1539,8 +1539,8 @@ static uint8_t *isis_snmp_find_man_area(struct variable *v, oid *name, /* Append index */ name[v->namelen] = area_addr->addr_len; - for (off = 0; off < area_addr->addr_len; off++) - name[v->namelen + 1 + off] = area_addr->area_addr[off]; + for (offset = 0; offset < area_addr->addr_len; offset++) + name[v->namelen + 1 + offset] = area_addr->area_addr[offset]; *length = v->namelen + 1 + area_addr->addr_len; } @@ -1628,7 +1628,7 @@ static uint8_t *isis_snmp_find_router(struct variable *v, oid *name, struct isis_dynhn *dyn = NULL; oid *oid_idx; size_t oid_idx_len; - size_t off = 0; + size_t offset = 0; struct isis *isis = isis_lookup_by_vrfid(VRF_DEFAULT); if (isis == NULL) @@ -1729,8 +1729,8 @@ static uint8_t *isis_snmp_find_router(struct variable *v, oid *name, /* Append index */ name[v->namelen] = ISIS_SYS_ID_LEN; - for (off = 0; off < ISIS_SYS_ID_LEN; off++) - name[v->namelen + 1 + off] = dyn->id[off]; + for (offset = 0; offset < ISIS_SYS_ID_LEN; offset++) + name[v->namelen + 1 + off] = dyn->id[offset]; name[v->namelen + 1 + ISIS_SYS_ID_LEN] = (oid)dyn->level; @@ -2803,8 +2803,8 @@ static int isis_snmp_init(struct event_loop *tm) struct isis_func_to_prefix *h2f = isis_func_to_prefix_arr; struct variable *v; - for (size_t off = 0; off < isis_var_count; off++) { - v = &isis_var_arr[off]; + for (size_t offset = 0; offset < isis_var_count; offset++) { + v = &isis_var_arr[offset]; if (v->findVar != h2f->ihtp_func) { /* Next table */ @@ -2858,7 +2858,7 @@ static int isis_snmp_db_overload_update(const struct isis_area *area) { netsnmp_variable_list *notification_vars; long val; - uint32_t off; + uint32_t offset; if (!isis_snmp_trap_throttle(ISIS_TRAP_DB_OVERLOAD)) return 0; @@ -2880,8 +2880,8 @@ static int isis_snmp_db_overload_update(const struct isis_area *area) (uint8_t *)&val, sizeof(val)); /* Patch sys_level_state with proper index */ - off = array_size(isis_snmp_trap_data_var_sys_level_state) - 1; - isis_snmp_trap_data_var_sys_level_state[off] = val; + offset = array_size(isis_snmp_trap_data_var_sys_level_state) - 1; + isis_snmp_trap_data_var_sys_level_state[offset] = val; /* Prepare data */ if (area->overload_bit) diff --git a/isisd/isis_spf.c b/isisd/isis_spf.c index 9c32a8447c..5960fef755 100644 --- a/isisd/isis_spf.c +++ b/isisd/isis_spf.c @@ -1195,7 +1195,7 @@ end: && !spftree->area->attached_bit_rcv_ignore && (spftree->area->is_type & IS_LEVEL_1) && !isis_level2_adj_up(spftree->area)) { - struct prefix_pair ip_info = { {0} }; + memset(&ip_info, 0, sizeof(ip_info)); if (IS_DEBUG_RTE_EVENTS) zlog_debug("ISIS-Spf (%pLS): add default %s route", lsp->hdr.lsp_id, diff --git a/isisd/isis_sr.c b/isisd/isis_sr.c index 95ea36c3a8..fd6a44504c 100644 --- a/isisd/isis_sr.c +++ b/isisd/isis_sr.c @@ -749,11 +749,11 @@ void sr_adj_sid_add_single(struct isis_adjacency *adj, int family, bool backup, sra->backup_nexthops = list_new(); for (ALL_LIST_ELEMENTS_RO(nexthops, node, vadj)) { - struct isis_adjacency *adj = vadj->sadj->adj; + struct isis_adjacency *tadj = vadj->sadj->adj; struct mpls_label_stack *label_stack; label_stack = vadj->label_stack; - adjinfo2nexthop(family, sra->backup_nexthops, adj, NULL, + adjinfo2nexthop(family, sra->backup_nexthops, tadj, NULL, label_stack); } } diff --git a/isisd/isis_te.c b/isisd/isis_te.c index 32492ae0c0..cf92ae46e9 100644 --- a/isisd/isis_te.c +++ b/isisd/isis_te.c @@ -704,15 +704,15 @@ static int isis_te_export(uint8_t type, void *link_state) switch (type) { case LS_MSG_TYPE_NODE: ls_vertex2msg(&msg, (struct ls_vertex *)link_state); - rc = ls_send_msg(zclient, &msg, NULL); + rc = ls_send_msg(isis_zclient, &msg, NULL); break; case LS_MSG_TYPE_ATTRIBUTES: ls_edge2msg(&msg, (struct ls_edge *)link_state); - rc = ls_send_msg(zclient, &msg, NULL); + rc = ls_send_msg(isis_zclient, &msg, NULL); break; case LS_MSG_TYPE_PREFIX: ls_subnet2msg(&msg, (struct ls_subnet *)link_state); - rc = ls_send_msg(zclient, &msg, NULL); + rc = ls_send_msg(isis_zclient, &msg, NULL); break; default: rc = -1; @@ -1494,7 +1494,7 @@ static void isis_te_parse_lsp(struct mpls_te_area *mta, struct isis_lsp *lsp) /* Clean remaining Orphan Edges or Subnets */ if (IS_EXPORT_TE(mta)) - ls_vertex_clean(ted, vertex, zclient); + ls_vertex_clean(ted, vertex, isis_zclient); else ls_vertex_clean(ted, vertex, NULL); } @@ -1653,7 +1653,7 @@ int isis_te_sync_ted(struct zapi_opaque_reg_info dst) if (IS_MPLS_TE(mta) && IS_EXPORT_TE(mta)) { te_debug(" |- Export TED from area %s", area->area_tag); - rc = ls_sync_ted(mta->ted, zclient, &dst); + rc = ls_sync_ted(mta->ted, isis_zclient, &dst); if (rc != 0) return rc; } diff --git a/isisd/isis_tlvs.c b/isisd/isis_tlvs.c index 8c97dcda2f..aa9d5e683b 100644 --- a/isisd/isis_tlvs.c +++ b/isisd/isis_tlvs.c @@ -518,7 +518,7 @@ static void format_item_asla_subtlvs(struct isis_asla_subtlvs *asla, asla->max_rsv_bw); if (IS_SUBTLV(asla, EXT_UNRSV_BW)) { sbuf_push(buf, indent + 2, "Unreserved Bandwidth:\n"); - for (int j = 0; j < MAX_CLASS_TYPE; j += 2) { + for (j = 0; j < MAX_CLASS_TYPE; j += 2) { sbuf_push( buf, indent + 2, "[%d]: %g (Bytes/sec),\t[%d]: %g (Bytes/sec)\n", @@ -3209,7 +3209,7 @@ static struct isis_item *copy_item_lsp_entry(struct isis_item *i) } static void format_item_lsp_entry(uint16_t mtid, struct isis_item *i, - struct sbuf *buf, struct json_object *json, + struct sbuf *sbuf, struct json_object *json, int indent) { struct isis_lsp_entry *e = (struct isis_lsp_entry *)i; @@ -3229,10 +3229,9 @@ static void format_item_lsp_entry(uint16_t mtid, struct isis_item *i, json_object_string_add(lsp_json, "chksum", buf); json_object_int_add(lsp_json, "lifetime", e->checksum); } else - sbuf_push( - buf, indent, - "LSP Entry: %s, seq 0x%08x, cksum 0x%04hx, lifetime %hus\n", - sys_id, e->seqno, e->checksum, e->rem_lifetime); + sbuf_push(sbuf, indent, + "LSP Entry: %s, seq 0x%08x, cksum 0x%04hx, lifetime %hus\n", + sys_id, e->seqno, e->checksum, e->rem_lifetime); } static void free_item_lsp_entry(struct isis_item *i) @@ -3553,7 +3552,7 @@ static void copy_tlv_protocols_supported(struct isis_protocols_supported *src, } static void format_tlv_protocols_supported(struct isis_protocols_supported *p, - struct sbuf *buf, + struct sbuf *sbuf, struct json_object *json, int indent) { if (!p || !p->count || !p->protocols) @@ -3572,12 +3571,12 @@ static void format_tlv_protocols_supported(struct isis_protocols_supported *p, nlpid2str(p->protocols[i])); } } else { - sbuf_push(buf, indent, "Protocols Supported: "); + sbuf_push(sbuf, indent, "Protocols Supported: "); for (uint8_t i = 0; i < p->count; i++) { - sbuf_push(buf, 0, "%s%s", nlpid2str(p->protocols[i]), + sbuf_push(sbuf, 0, "%s%s", nlpid2str(p->protocols[i]), (i + 1 < p->count) ? ", " : ""); } - sbuf_push(buf, 0, "\n"); + sbuf_push(sbuf, 0, "\n"); } } @@ -5275,9 +5274,9 @@ static int pack_tlv_router_cap(const struct isis_router_cap *router_cap, /* Flex Algo Definitions */ for (int i = 0; i < SR_ALGORITHM_COUNT; i++) { struct isis_router_cap_fad *fad; - size_t subtlv_len; struct admin_group *ag; uint32_t admin_group_length; + size_t j; fad = router_cap->fads[i]; if (!fad) @@ -5315,8 +5314,8 @@ static int pack_tlv_router_cap(const struct isis_router_cap *router_cap, if (admin_group_length) { stream_putc(s, ISIS_SUBTLV_FAD_SUBSUBTLV_EXCAG); stream_putc(s, sizeof(uint32_t) * admin_group_length); - for (size_t i = 0; i < admin_group_length; i++) - stream_putl(s, admin_group_get_offset(ag, i)); + for (j = 0; j < admin_group_length; j++) + stream_putl(s, admin_group_get_offset(ag, j)); } ag = &fad->fad.admin_group_include_any; @@ -5324,8 +5323,8 @@ static int pack_tlv_router_cap(const struct isis_router_cap *router_cap, if (admin_group_length) { stream_putc(s, ISIS_SUBTLV_FAD_SUBSUBTLV_INCANYAG); stream_putc(s, sizeof(uint32_t) * admin_group_length); - for (size_t i = 0; i < admin_group_length; i++) - stream_putl(s, admin_group_get_offset(ag, i)); + for (j = 0; j < admin_group_length; j++) + stream_putl(s, admin_group_get_offset(ag, j)); } ag = &fad->fad.admin_group_include_all; @@ -5333,8 +5332,8 @@ static int pack_tlv_router_cap(const struct isis_router_cap *router_cap, if (admin_group_length) { stream_putc(s, ISIS_SUBTLV_FAD_SUBSUBTLV_INCALLAG); stream_putc(s, sizeof(uint32_t) * admin_group_length); - for (size_t i = 0; i < admin_group_length; i++) - stream_putl(s, admin_group_get_offset(ag, i)); + for (j = 0; j < admin_group_length; j++) + stream_putl(s, admin_group_get_offset(ag, j)); } if (fad->fad.flags != 0) { diff --git a/isisd/isis_zebra.c b/isisd/isis_zebra.c index c2670143f2..cb729501cc 100644 --- a/isisd/isis_zebra.c +++ b/isisd/isis_zebra.c @@ -45,7 +45,7 @@ #include "isisd/isis_sr.h" #include "isisd/isis_ldp_sync.h" -struct zclient *zclient; +struct zclient *isis_zclient; static struct zclient *zclient_sync; /* Router-id update message from zebra. */ @@ -254,7 +254,7 @@ void isis_zebra_route_add_route(struct isis *isis, struct prefix *prefix, struct zapi_route api; int count = 0; - if (zclient->sock < 0) + if (isis_zclient->sock < 0) return; /* Uninstall the route if it doesn't have any valid nexthop. */ @@ -295,7 +295,7 @@ void isis_zebra_route_add_route(struct isis *isis, struct prefix *prefix, return; api.nexthop_num = count; - zclient_route_send(ZEBRA_ROUTE_ADD, zclient, &api); + zclient_route_send(ZEBRA_ROUTE_ADD, isis_zclient, &api); } void isis_zebra_route_del_route(struct isis *isis, @@ -305,7 +305,7 @@ void isis_zebra_route_del_route(struct isis *isis, { struct zapi_route api; - if (zclient->sock < 0) + if (isis_zclient->sock < 0) return; if (!CHECK_FLAG(route_info->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED)) @@ -321,7 +321,7 @@ void isis_zebra_route_del_route(struct isis *isis, SET_FLAG(api.message, ZAPI_MESSAGE_SRCPFX); } - zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api); + zclient_route_send(ZEBRA_ROUTE_DELETE, isis_zclient, &api); } /** @@ -388,7 +388,7 @@ void isis_zebra_prefix_sid_install(struct isis_area *area, } /* Send message to zebra. */ - (void)zebra_send_mpls_labels(zclient, ZEBRA_MPLS_LABELS_REPLACE, &zl); + (void)zebra_send_mpls_labels(isis_zclient, ZEBRA_MPLS_LABELS_REPLACE, &zl); } /** @@ -415,7 +415,7 @@ void isis_zebra_prefix_sid_uninstall(struct isis_area *area, zl.local_label = psid->label; /* Send message to zebra. */ - (void)zebra_send_mpls_labels(zclient, ZEBRA_MPLS_LABELS_DELETE, &zl); + (void)zebra_send_mpls_labels(isis_zclient, ZEBRA_MPLS_LABELS_DELETE, &zl); } /** @@ -471,7 +471,7 @@ void isis_zebra_send_adjacency_sid(int cmd, const struct sr_adjacency *sra) } } - (void)zebra_send_mpls_labels(zclient, cmd, &zl); + (void)zebra_send_mpls_labels(isis_zclient, cmd, &zl); } static int isis_zebra_read(ZAPI_CALLBACK_ARGS) @@ -523,9 +523,9 @@ void isis_zebra_redistribute_set(afi_t afi, int type, vrf_id_t vrf_id, { if (type == DEFAULT_ROUTE) zclient_redistribute_default(ZEBRA_REDISTRIBUTE_DEFAULT_ADD, - zclient, afi, vrf_id); + isis_zclient, afi, vrf_id); else - zclient_redistribute(ZEBRA_REDISTRIBUTE_ADD, zclient, afi, type, + zclient_redistribute(ZEBRA_REDISTRIBUTE_ADD, isis_zclient, afi, type, tableid, vrf_id); } @@ -534,9 +534,9 @@ void isis_zebra_redistribute_unset(afi_t afi, int type, vrf_id_t vrf_id, { if (type == DEFAULT_ROUTE) zclient_redistribute_default(ZEBRA_REDISTRIBUTE_DEFAULT_DELETE, - zclient, afi, vrf_id); + isis_zclient, afi, vrf_id); else - zclient_redistribute(ZEBRA_REDISTRIBUTE_DELETE, zclient, afi, + zclient_redistribute(ZEBRA_REDISTRIBUTE_DELETE, isis_zclient, afi, type, tableid, vrf_id); } @@ -549,7 +549,7 @@ int isis_zebra_rlfa_register(struct isis_spftree *spftree, struct rlfa *rlfa) struct zapi_rlfa_request zr = {}; int ret; - if (!zclient) + if (!isis_zclient) return 0; zr.igp.vrf_id = area->isis->vrf_id; @@ -565,7 +565,7 @@ int isis_zebra_rlfa_register(struct isis_spftree *spftree, struct rlfa *rlfa) zlog_debug("ISIS-LFA: registering RLFA %pFX@%pI4 with LDP", &rlfa->prefix, &rlfa->pq_address); - ret = zclient_send_opaque_unicast(zclient, LDP_RLFA_REGISTER, + ret = zclient_send_opaque_unicast(isis_zclient, LDP_RLFA_REGISTER, ZEBRA_ROUTE_LDP, 0, 0, (const uint8_t *)&zr, sizeof(zr)); if (ret == ZCLIENT_SEND_FAILURE) { @@ -585,8 +585,8 @@ void isis_zebra_rlfa_unregister_all(struct isis_spftree *spftree) struct zapi_rlfa_igp igp = {}; int ret; - if (!zclient || spftree->type != SPF_TYPE_FORWARD - || CHECK_FLAG(spftree->flags, F_SPFTREE_NO_ADJACENCIES)) + if (!isis_zclient || spftree->type != SPF_TYPE_FORWARD || + CHECK_FLAG(spftree->flags, F_SPFTREE_NO_ADJACENCIES)) return; if (IS_DEBUG_LFA) @@ -599,7 +599,7 @@ void isis_zebra_rlfa_unregister_all(struct isis_spftree *spftree) igp.isis.spf.level = spftree->level; igp.isis.spf.run_id = spftree->runcount; - ret = zclient_send_opaque_unicast(zclient, LDP_RLFA_UNREGISTER_ALL, + ret = zclient_send_opaque_unicast(isis_zclient, LDP_RLFA_UNREGISTER_ALL, ZEBRA_ROUTE_LDP, 0, 0, (const uint8_t *)&igp, sizeof(igp)); if (ret == ZCLIENT_SEND_FAILURE) @@ -774,27 +774,27 @@ int isis_zebra_label_manager_connect(void) void isis_zebra_vrf_register(struct isis *isis) { - if (!zclient || zclient->sock < 0 || !isis) + if (!isis_zclient || isis_zclient->sock < 0 || !isis) return; if (isis->vrf_id != VRF_UNKNOWN) { if (IS_DEBUG_EVENTS) zlog_debug("%s: Register VRF %s id %u", __func__, isis->name, isis->vrf_id); - zclient_send_reg_requests(zclient, isis->vrf_id); + zclient_send_reg_requests(isis_zclient, isis->vrf_id); } } void isis_zebra_vrf_deregister(struct isis *isis) { - if (!zclient || zclient->sock < 0 || !isis) + if (!isis_zclient || isis_zclient->sock < 0 || !isis) return; if (isis->vrf_id != VRF_UNKNOWN) { if (IS_DEBUG_EVENTS) zlog_debug("%s: Deregister VRF %s id %u", __func__, isis->name, isis->vrf_id); - zclient_send_dereg_requests(zclient, isis->vrf_id); + zclient_send_dereg_requests(isis_zclient, isis->vrf_id); } } @@ -820,9 +820,9 @@ int isis_zebra_ls_register(bool up) int rc; if (up) - rc = ls_register(zclient, true); + rc = ls_register(isis_zclient, true); else - rc = ls_unregister(zclient, true); + rc = ls_unregister(isis_zclient, true); return rc; } @@ -934,7 +934,7 @@ static void isis_zebra_send_localsid(int cmd, const struct in6_addr *sid, memcpy(&api.prefix, &p, sizeof(p)); if (cmd == ZEBRA_ROUTE_DELETE) - return (void)zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, + return (void)zclient_route_send(ZEBRA_ROUTE_DELETE, isis_zclient, &api); SET_FLAG(api.flags, ZEBRA_FLAG_ALLOW_RECURSION); @@ -952,7 +952,7 @@ static void isis_zebra_send_localsid(int cmd, const struct in6_addr *sid, api.nexthop_num = 1; - zclient_route_send(ZEBRA_ROUTE_ADD, zclient, &api); + zclient_route_send(ZEBRA_ROUTE_ADD, isis_zclient, &api); } /** @@ -1372,7 +1372,7 @@ static int isis_zebra_process_srv6_locator_delete(ZAPI_CALLBACK_ARGS) */ int isis_zebra_srv6_manager_get_locator_chunk(const char *name) { - return srv6_manager_get_locator_chunk(zclient, name); + return srv6_manager_get_locator_chunk(isis_zclient, name); } @@ -1385,7 +1385,7 @@ int isis_zebra_srv6_manager_get_locator_chunk(const char *name) */ int isis_zebra_srv6_manager_release_locator_chunk(const char *name) { - return srv6_manager_release_locator_chunk(zclient, name); + return srv6_manager_release_locator_chunk(isis_zclient, name); } /** @@ -1403,7 +1403,7 @@ int isis_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(isis_zclient, name); } /** @@ -1434,7 +1434,7 @@ bool isis_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, NULL); + ret = srv6_manager_get_sid(isis_zclient, ctx, sid_value, locator_name, NULL); if (ret < 0) { zlog_warn("%s: error getting SRv6 SID!", __func__); return false; @@ -1462,7 +1462,7 @@ void isis_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(isis_zclient, ctx); if (ret < 0) { zlog_warn("%s: error releasing SRv6 SID!", __func__); return; @@ -1631,16 +1631,16 @@ static zclient_handler *const isis_handlers[] = { [ZEBRA_SRV6_SID_NOTIFY] = isis_zebra_srv6_sid_notify, }; -void isis_zebra_init(struct event_loop *master, int instance) +void isis_zebra_init(struct event_loop *mst, int instance) { /* Initialize asynchronous zclient. */ - zclient = zclient_new(master, &zclient_options_default, isis_handlers, + isis_zclient = zclient_new(mst, &zclient_options_default, isis_handlers, array_size(isis_handlers)); - zclient_init(zclient, PROTO_TYPE, 0, &isisd_privs); - zclient->zebra_connected = isis_zebra_connected; + zclient_init(isis_zclient, PROTO_TYPE, 0, &isisd_privs); + isis_zclient->zebra_connected = isis_zebra_connected; /* Initialize special zclient for synchronous message exchanges. */ - zclient_sync = zclient_new(master, &zclient_options_sync, NULL, 0); + zclient_sync = zclient_new(mst, &zclient_options_sync, NULL, 0); zclient_sync->sock = -1; zclient_sync->redist_default = ZEBRA_ROUTE_ISIS; zclient_sync->instance = instance; @@ -1654,11 +1654,11 @@ void isis_zebra_init(struct event_loop *master, int instance) void isis_zebra_stop(void) { - zclient_unregister_opaque(zclient, LDP_RLFA_LABELS); - zclient_unregister_opaque(zclient, LDP_IGP_SYNC_IF_STATE_UPDATE); - zclient_unregister_opaque(zclient, LDP_IGP_SYNC_ANNOUNCE_UPDATE); + zclient_unregister_opaque(isis_zclient, LDP_RLFA_LABELS); + zclient_unregister_opaque(isis_zclient, LDP_IGP_SYNC_IF_STATE_UPDATE); + zclient_unregister_opaque(isis_zclient, LDP_IGP_SYNC_ANNOUNCE_UPDATE); zclient_stop(zclient_sync); zclient_free(zclient_sync); - zclient_stop(zclient); - zclient_free(zclient); + zclient_stop(isis_zclient); + zclient_free(isis_zclient); } diff --git a/isisd/isis_zebra.h b/isisd/isis_zebra.h index 79da16efac..83a71b7dc9 100644 --- a/isisd/isis_zebra.h +++ b/isisd/isis_zebra.h @@ -11,7 +11,7 @@ #include "isisd.h" -extern struct zclient *zclient; +extern struct zclient *isis_zclient; struct label_chunk { uint32_t start; diff --git a/isisd/isisd.c b/isisd/isisd.c index a0faf31221..2260ba664f 100644 --- a/isisd/isisd.c +++ b/isisd/isisd.c @@ -187,12 +187,12 @@ struct isis *isis_lookup_by_sysid(const uint8_t *sysid) return NULL; } -void isis_master_init(struct event_loop *master) +void isis_master_init(struct event_loop *mst) { memset(&isis_master, 0, sizeof(isis_master)); im = &isis_master; im->isis = list_new(); - im->master = master; + im->master = mst; } void isis_master_terminate(void) @@ -694,24 +694,24 @@ static void isis_set_redist_vrf_bitmaps(struct isis *isis, bool set) if (type == DEFAULT_ROUTE) { if (set) vrf_bitmap_set( - &zclient->default_information + &isis_zclient->default_information [afi], isis->vrf_id); else vrf_bitmap_unset( - &zclient->default_information + &isis_zclient->default_information [afi], isis->vrf_id); } else { if (set) vrf_bitmap_set( - &zclient->redist + &isis_zclient->redist [afi] [type], isis->vrf_id); else vrf_bitmap_unset( - &zclient->redist + &isis_zclient->redist [afi] [type], isis->vrf_id); diff --git a/ldpd/lde.c b/ldpd/lde.c index 876dd41630..b0f9e5191f 100644 --- a/ldpd/lde.c +++ b/ldpd/lde.c @@ -538,8 +538,8 @@ static void lde_dispatch_parent(struct event *thread) sizeof(struct ldpd_init)) fatalx("INIT imsg with wrong len"); - memcpy(&init, imsg.data, sizeof(init)); - lde_init(&init); + memcpy(&ldp_init, imsg.data, sizeof(ldp_init)); + lde_init(&ldp_init); break; case IMSG_AGENTX_ENABLED: ldp_agentx_enabled(); diff --git a/ldpd/ldp_snmp.c b/ldpd/ldp_snmp.c index ed391ac600..2e7933f95c 100644 --- a/ldpd/ldp_snmp.c +++ b/ldpd/ldp_snmp.c @@ -620,10 +620,10 @@ static uint8_t *ldpHelloAdjacencyTable(struct variable *v, oid name[], size_t *l memcpy(name, v->name, v->namelen * sizeof(oid)); /* Append index */ - struct in_addr entityLdpId = {.s_addr = 0}; + entityLdpId.s_addr = 0; entityLdpId.s_addr = ldp_rtr_id_get(leconf); - struct in_addr peerLdpId = ctl_adj->id; + peerLdpId = ctl_adj->id; oid_copy_in_addr(name + v->namelen, &entityLdpId); name[v->namelen + 4] = 0; diff --git a/ldpd/ldp_vty_exec.c b/ldpd/ldp_vty_exec.c index f3bcd1b254..20b60bd373 100644 --- a/ldpd/ldp_vty_exec.c +++ b/ldpd/ldp_vty_exec.c @@ -1954,10 +1954,9 @@ ldp_vty_show_interface(struct vty *vty, const char *af_str, const char *json) return (ldp_vty_dispatch(vty, &ibuf, SHOW_IFACE, ¶ms)); } -int -ldp_vty_show_capabilities(struct vty *vty, const char *json) +int ldp_vty_show_capabilities(struct vty *vty, const char *use_json) { - if (json) { + if (use_json) { json_object *json; json_object *json_array; json_object *json_cap; diff --git a/ldpd/ldp_zebra.c b/ldpd/ldp_zebra.c index df682a1347..cf7ebdff41 100644 --- a/ldpd/ldp_zebra.c +++ b/ldpd/ldp_zebra.c @@ -38,7 +38,7 @@ static int ldp_sync_zebra_send_announce(void); static int ldp_zebra_opaque_msg_handler(ZAPI_CALLBACK_ARGS); static void ldp_sync_zebra_init(void); -static struct zclient *zclient; +static struct zclient *ldp_zclient; extern struct zclient *zclient_sync; static bool zebra_registered = false; @@ -100,23 +100,23 @@ pw2zpw(struct l2vpn_pw *pw, struct zapi_pw *zpw) static void ldp_zebra_opaque_register(void) { - zclient_register_opaque(zclient, LDP_IGP_SYNC_IF_STATE_REQUEST); - zclient_register_opaque(zclient, LDP_RLFA_REGISTER); - zclient_register_opaque(zclient, LDP_RLFA_UNREGISTER_ALL); + zclient_register_opaque(ldp_zclient, LDP_IGP_SYNC_IF_STATE_REQUEST); + zclient_register_opaque(ldp_zclient, LDP_RLFA_REGISTER); + zclient_register_opaque(ldp_zclient, LDP_RLFA_UNREGISTER_ALL); } static void ldp_zebra_opaque_unregister(void) { - zclient_unregister_opaque(zclient, LDP_IGP_SYNC_IF_STATE_REQUEST); - zclient_unregister_opaque(zclient, LDP_RLFA_REGISTER); - zclient_unregister_opaque(zclient, LDP_RLFA_UNREGISTER_ALL); + zclient_unregister_opaque(ldp_zclient, LDP_IGP_SYNC_IF_STATE_REQUEST); + zclient_unregister_opaque(ldp_zclient, LDP_RLFA_REGISTER); + zclient_unregister_opaque(ldp_zclient, LDP_RLFA_UNREGISTER_ALL); } int ldp_sync_zebra_send_state_update(struct ldp_igp_sync_if_state *state) { - if (zclient_send_opaque(zclient, LDP_IGP_SYNC_IF_STATE_UPDATE, + if (zclient_send_opaque(ldp_zclient, LDP_IGP_SYNC_IF_STATE_UPDATE, (const uint8_t *)state, sizeof(*state)) == ZCLIENT_SEND_FAILURE) return -1; @@ -130,9 +130,9 @@ ldp_sync_zebra_send_announce(void) struct ldp_igp_sync_announce announce; announce.proto = ZEBRA_ROUTE_LDP; - if (zclient_send_opaque(zclient, LDP_IGP_SYNC_ANNOUNCE_UPDATE, - (const uint8_t *)&announce, sizeof(announce)) - == ZCLIENT_SEND_FAILURE) + if (zclient_send_opaque(ldp_zclient, LDP_IGP_SYNC_ANNOUNCE_UPDATE, + (const uint8_t *)&announce, + sizeof(announce)) == ZCLIENT_SEND_FAILURE) return -1; else return 0; @@ -142,7 +142,7 @@ int ldp_zebra_send_rlfa_labels(struct zapi_rlfa_response *rlfa_labels) { int ret; - ret = zclient_send_opaque(zclient, LDP_RLFA_LABELS, + ret = zclient_send_opaque(ldp_zclient, LDP_RLFA_LABELS, (const uint8_t *)rlfa_labels, sizeof(*rlfa_labels)); if (ret == ZCLIENT_SEND_FAILURE) { @@ -271,7 +271,7 @@ ldp_zebra_send_mpls_labels(int cmd, struct kroute *kr) znh->label_num = 1; znh->labels[0] = kr->remote_label; - if (zebra_send_mpls_labels(zclient, cmd, &zl) == ZCLIENT_SEND_FAILURE) + if (zebra_send_mpls_labels(ldp_zclient, cmd, &zl) == ZCLIENT_SEND_FAILURE) return -1; return 0; @@ -295,7 +295,7 @@ kmpw_add(struct zapi_pw *zpw) debug_zebra_out("pseudowire %s nexthop %s (add)", zpw->ifname, log_addr(zpw->af, (union ldpd_addr *)&zpw->nexthop)); - return zebra_send_pw(zclient, ZEBRA_PW_ADD, zpw) == ZCLIENT_SEND_FAILURE; + return zebra_send_pw(ldp_zclient, ZEBRA_PW_ADD, zpw) == ZCLIENT_SEND_FAILURE; } int @@ -304,7 +304,7 @@ kmpw_del(struct zapi_pw *zpw) debug_zebra_out("pseudowire %s nexthop %s (del)", zpw->ifname, log_addr(zpw->af, (union ldpd_addr *)&zpw->nexthop)); - return zebra_send_pw(zclient, ZEBRA_PW_DELETE, zpw) == ZCLIENT_SEND_FAILURE; + return zebra_send_pw(ldp_zclient, ZEBRA_PW_DELETE, zpw) == ZCLIENT_SEND_FAILURE; } int @@ -314,7 +314,7 @@ kmpw_set(struct zapi_pw *zpw) zpw->ifname, log_addr(zpw->af, (union ldpd_addr *)&zpw->nexthop), zpw->local_label, zpw->remote_label); - return zebra_send_pw(zclient, ZEBRA_PW_SET, zpw) == ZCLIENT_SEND_FAILURE; + return zebra_send_pw(ldp_zclient, ZEBRA_PW_SET, zpw) == ZCLIENT_SEND_FAILURE; } int @@ -323,7 +323,7 @@ kmpw_unset(struct zapi_pw *zpw) debug_zebra_out("pseudowire %s nexthop %s (unset)", zpw->ifname, log_addr(zpw->af, (union ldpd_addr *)&zpw->nexthop)); - return zebra_send_pw(zclient, ZEBRA_PW_UNSET, zpw) == ZCLIENT_SEND_FAILURE; + return zebra_send_pw(ldp_zclient, ZEBRA_PW_UNSET, zpw) == ZCLIENT_SEND_FAILURE; } void @@ -620,18 +620,18 @@ void ldp_zebra_regdereg_zebra_info(bool want_register) want_register ? "Register" : "De-register"); if (want_register) { - zclient_send_reg_requests(zclient, VRF_DEFAULT); - zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP, + zclient_send_reg_requests(ldp_zclient, VRF_DEFAULT); + zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, ldp_zclient, AFI_IP, ZEBRA_ROUTE_ALL, 0, VRF_DEFAULT); - zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, zclient, + zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, ldp_zclient, AFI_IP6, ZEBRA_ROUTE_ALL, 0, VRF_DEFAULT); } else { - zclient_send_dereg_requests(zclient, VRF_DEFAULT); - zebra_redistribute_send(ZEBRA_REDISTRIBUTE_DELETE, zclient, + zclient_send_dereg_requests(ldp_zclient, VRF_DEFAULT); + zebra_redistribute_send(ZEBRA_REDISTRIBUTE_DELETE, ldp_zclient, AFI_IP, ZEBRA_ROUTE_ALL, 0, VRF_DEFAULT); - zebra_redistribute_send(ZEBRA_REDISTRIBUTE_DELETE, zclient, + zebra_redistribute_send(ZEBRA_REDISTRIBUTE_DELETE, ldp_zclient, AFI_IP6, ZEBRA_ROUTE_ALL, 0, VRF_DEFAULT); } @@ -678,7 +678,7 @@ static zclient_handler *const ldp_handlers[] = { [ZEBRA_OPAQUE_MESSAGE] = ldp_zebra_opaque_msg_handler, }; -void ldp_zebra_init(struct event_loop *master) +void ldp_zebra_init(struct event_loop *mst) { hook_register_prio(if_real, 0, ldp_ifp_create); hook_register_prio(if_up, 0, ldp_ifp_up); @@ -686,12 +686,12 @@ void ldp_zebra_init(struct event_loop *master) hook_register_prio(if_unreal, 0, ldp_ifp_destroy); /* Set default values. */ - zclient = zclient_new(master, &zclient_options_default, ldp_handlers, - array_size(ldp_handlers)); - zclient_init(zclient, ZEBRA_ROUTE_LDP, 0, &ldpd_privs); + ldp_zclient = zclient_new(mst, &zclient_options_default, ldp_handlers, + array_size(ldp_handlers)); + zclient_init(ldp_zclient, ZEBRA_ROUTE_LDP, 0, &ldpd_privs); /* set callbacks */ - zclient->zebra_connected = ldp_zebra_connected; + ldp_zclient->zebra_connected = ldp_zebra_connected; /* Access list initialize. */ access_list_add_hook(ldp_zebra_filter_update); @@ -702,9 +702,9 @@ void ldp_zebra_destroy(void) { ldp_zebra_opaque_unregister(); - zclient_stop(zclient); - zclient_free(zclient); - zclient = NULL; + zclient_stop(ldp_zclient); + zclient_free(ldp_zclient); + ldp_zclient = NULL; if (zclient_sync == NULL) return; diff --git a/ldpd/ldpd.c b/ldpd/ldpd.c index 4d38fdcd02..e4e1dc6fec 100644 --- a/ldpd/ldpd.c +++ b/ldpd/ldpd.c @@ -74,7 +74,7 @@ DEFINE_QOBJ_TYPE(ldpd_conf); const char *log_procname; struct ldpd_global global; -struct ldpd_init init; +struct ldpd_init ldp_init; struct ldpd_conf *ldpd_conf, *vty_conf; static struct imsgev *iev_ldpe, *iev_ldpe_sync; @@ -272,8 +272,8 @@ main(int argc, char *argv[]) "%s/" LDPD_SOCK_NAME, optarg); break; case 'n': - init.instance = atoi(optarg); - if (init.instance < 1) + ldp_init.instance = atoi(optarg); + if (ldp_init.instance < 1) exit(0); break; case 'L': @@ -291,11 +291,11 @@ main(int argc, char *argv[]) snprintf(ctl_sock_path, sizeof(ctl_sock_path), "%s/" LDPD_SOCK_NAME, frr_runstatedir); - strlcpy(init.user, ldpd_privs.user, sizeof(init.user)); - strlcpy(init.group, ldpd_privs.group, sizeof(init.group)); - strlcpy(init.ctl_sock_path, ctl_sock_path, sizeof(init.ctl_sock_path)); - strlcpy(init.zclient_serv_path, frr_zclientpath, - sizeof(init.zclient_serv_path)); + strlcpy(ldp_init.user, ldpd_privs.user, sizeof(ldp_init.user)); + strlcpy(ldp_init.group, ldpd_privs.group, sizeof(ldp_init.group)); + strlcpy(ldp_init.ctl_sock_path, ctl_sock_path, sizeof(ldp_init.ctl_sock_path)); + strlcpy(ldp_init.zclient_serv_path, frr_zclientpath, + sizeof(ldp_init.zclient_serv_path)); argc -= optind; if (argc > 0 || (lflag && eflag)) @@ -428,7 +428,7 @@ main(int argc, char *argv[]) fatal("could not establish imsg links"); main_imsg_compose_both(IMSG_DEBUG_UPDATE, &ldp_debug, sizeof(ldp_debug)); - main_imsg_compose_both(IMSG_INIT, &init, sizeof(init)); + main_imsg_compose_both(IMSG_INIT, &ldp_init, sizeof(ldp_init)); main_imsg_send_config(ldpd_conf); if (CHECK_FLAG(ldpd_conf->ipv4.flags, F_LDPD_AF_ENABLED)) diff --git a/ldpd/ldpd.h b/ldpd/ldpd.h index ad831a6ea3..700c388724 100644 --- a/ldpd/ldpd.h +++ b/ldpd/ldpd.h @@ -739,7 +739,7 @@ struct ctl_ldp_sync { extern struct ldpd_conf *ldpd_conf, *vty_conf; extern struct ldpd_global global; -extern struct ldpd_init init; +extern struct ldpd_init ldp_init; /* parse.y */ struct ldpd_conf *parse_config(char *); diff --git a/ldpd/ldpe.c b/ldpd/ldpe.c index 0a3a03bc38..50875e644d 100644 --- a/ldpd/ldpe.c +++ b/ldpd/ldpe.c @@ -373,8 +373,8 @@ static void ldpe_dispatch_main(struct event *thread) if (imsg.hdr.len != IMSG_HEADER_SIZE + sizeof(struct ldpd_init)) fatalx("INIT imsg with wrong len"); - memcpy(&init, imsg.data, sizeof(init)); - ldpe_init(&init); + memcpy(&ldp_init, imsg.data, sizeof(ldp_init)); + ldpe_init(&ldp_init); break; case IMSG_AGENTX_ENABLED: ldp_agentx_enabled(); diff --git a/lib/darr.h b/lib/darr.h index 4638b904d1..76743cc946 100644 --- a/lib/darr.h +++ b/lib/darr.h @@ -511,11 +511,11 @@ void *__darr_resize(void *a, uint count, size_t esize, struct memtype *mt); */ #define darr_pop(A) \ ({ \ - uint __len = _darr_len(A); \ - assert(__len); \ - darr_remove(A, __len - 1); \ + uint __poplen = _darr_len(A); \ + assert(__poplen); \ + darr_remove(A, __poplen - 1); \ /* count on fact that we don't resize */ \ - (A)[__len - 1]; \ + (A)[__poplen - 1]; \ }) /** diff --git a/lib/elf_py.c b/lib/elf_py.c index 14012a2173..7609ea59c1 100644 --- a/lib/elf_py.c +++ b/lib/elf_py.c @@ -518,12 +518,12 @@ static void elfsect_add_relocations(struct elfsect *w, Elf_Scn *rel, relw->es = w; if (relhdr->sh_type == SHT_REL) { - GElf_Rel _rel, *rel; + GElf_Rel _rel, *erel; - rel = gelf_getrel(reldata, i, &_rel); + erel = gelf_getrel(reldata, i, &_rel); relw->rela = &relw->_rela; - relw->rela->r_offset = rel->r_offset; - relw->rela->r_info = rel->r_info; + relw->rela->r_offset = erel->r_offset; + relw->rela->r_info = erel->r_info; relw->rela->r_addend = 0; relw->relative = true; } else @@ -581,14 +581,14 @@ static PyObject *elfsect_wrap(struct elffile *ef, Elf_Scn *scn, size_t idx, elfrelocs_init(&w->relocs); for (i = 0; i < ef->ehdr->e_shnum; i++) { - Elf_Scn *scn = elf_getscn(ef->elf, i); - GElf_Shdr _shdr, *shdr = gelf_getshdr(scn, &_shdr); + Elf_Scn *escn = elf_getscn(ef->elf, i); + GElf_Shdr _shdr, *shdr = gelf_getshdr(escn, &_shdr); if (shdr->sh_type != SHT_RELA && shdr->sh_type != SHT_REL) continue; if (shdr->sh_info && shdr->sh_info != idx) continue; - elfsect_add_relocations(w, scn, shdr); + elfsect_add_relocations(w, escn, shdr); } return (PyObject *)w; diff --git a/lib/frr_pthread.h b/lib/frr_pthread.h index bb751b7071..368ada36ad 100644 --- a/lib/frr_pthread.h +++ b/lib/frr_pthread.h @@ -233,11 +233,13 @@ int frr_pthread_non_controlled_startup(pthread_t thread, const char *name, unused, cleanup(_frr_mtx_unlock))) = _frr_mtx_lock(mutex), \ /* end */ -#define frr_with_mutex(...) \ - for (pthread_mutex_t MACRO_REPEAT(_frr_with_mutex, ##__VA_ARGS__) \ - *_once = NULL; _once == NULL; _once = (void *)1) \ +#define _frr_with_mutex_once(_once, ...) \ + for (pthread_mutex_t MACRO_REPEAT(_frr_with_mutex, ##__VA_ARGS__)*_once = NULL; \ + _once == NULL; _once = (void *)1) \ /* end */ +#define frr_with_mutex(...) _frr_with_mutex_once(NAMECTR(_once_), __VA_ARGS__) + /* variant 2: * (more suitable for long blocks, no extra indentation) * diff --git a/lib/libfrr.c b/lib/libfrr.c index 8a37b51c47..d40624a102 100644 --- a/lib/libfrr.c +++ b/lib/libfrr.c @@ -1192,9 +1192,10 @@ void frr_detach(void) frr_check_detach(); } -void frr_run(struct event_loop *master) +void frr_run(struct event_loop *loop) { char instanceinfo[64] = ""; + struct event thread; if (!(di->flags & FRR_MANUAL_VTY_START)) frr_vty_serv_start(false); @@ -1212,7 +1213,7 @@ void frr_run(struct event_loop *master) vty_stdio(frr_terminal_close); if (daemon_ctl_sock != -1) { set_nonblocking(daemon_ctl_sock); - event_add_read(master, frr_daemon_ctl, NULL, + event_add_read(loop, frr_daemon_ctl, NULL, daemon_ctl_sock, &daemon_ctl_thread); } } else if (di->daemon_mode) { @@ -1242,8 +1243,7 @@ void frr_run(struct event_loop *master) /* end fixed stderr startup logging */ zlog_startup_end(); - struct event thread; - while (event_fetch(master, &thread)) + while (event_fetch(loop, &thread)) event_call(&thread); } diff --git a/lib/link_state.c b/lib/link_state.c index 3d96c75f6d..27cc2558f5 100644 --- a/lib/link_state.c +++ b/lib/link_state.c @@ -2555,9 +2555,9 @@ static void ls_show_edge_json(struct ls_edge *edge, struct json_object *json) if (CHECK_FLAG(attr->flags, LS_ATTR_UNRSV_BW)) { jbw = json_object_new_array(); json_object_object_add(jte, "unreserved-bandwidth", jbw); - for (int i = 0; i < MAX_CLASS_TYPE; i++) { + for (i = 0; i < MAX_CLASS_TYPE; i++) { jobj = json_object_new_object(); - snprintfrr(buf, 13, "class-type-%u", i); + snprintfrr(buf, 13, "class-type-%u", (unsigned int)i); json_object_double_add(jobj, buf, attr->standard.unrsv_bw[i]); json_object_array_add(jbw, jobj); @@ -2599,7 +2599,7 @@ static void ls_show_edge_json(struct ls_edge *edge, struct json_object *json) if (CHECK_FLAG(attr->flags, LS_ATTR_SRLG)) { jsrlg = json_object_new_array(); json_object_object_add(jte, "srlgs", jsrlg); - for (int i = 1; i < attr->srlg_len; i++) { + for (i = 1; i < attr->srlg_len; i++) { jobj = json_object_new_object(); json_object_int_add(jobj, "srlg", attr->srlgs[i]); json_object_array_add(jsrlg, jobj); diff --git a/lib/linklist.h b/lib/linklist.h index f922891df9..d86db36f55 100644 --- a/lib/linklist.h +++ b/lib/linklist.h @@ -67,7 +67,11 @@ struct list { #define listcount(X) ((X)->count) #define list_isempty(X) ((X)->head == NULL && (X)->tail == NULL) /* return X->data only if X and X->data are not NULL */ -#define listgetdata(X) (assert(X), assert((X)->data != NULL), (X)->data) +static inline void *listgetdata(const struct listnode *X) +{ + assert((X != NULL) && ((X)->data != NULL)); + return X->data; +} /* App is going to manage listnode memory */ #define listset_app_node_mem(X) ((X)->flags |= LINKLIST_FLAG_NODE_MEM_BY_APP) #define listnode_init(X, val) ((X)->data = (val)) diff --git a/lib/northbound_oper.c b/lib/northbound_oper.c index 626c37082e..d9ad9b1701 100644 --- a/lib/northbound_oper.c +++ b/lib/northbound_oper.c @@ -157,7 +157,8 @@ nb_op_create_yield_state(const char *xpath, struct yang_translator *translator, /* remove trailing '/'s */ while (darr_len(ys->xpath) > 1 && ys->xpath[darr_len(ys->xpath) - 2] == '/') { darr_setlen(ys->xpath, darr_len(ys->xpath) - 1); - *darr_last(ys->xpath) = 0; + if (darr_last(ys->xpath)) + *darr_last(ys->xpath) = 0; } ys->xpath_orig = darr_strdup(xpath); ys->translator = translator; diff --git a/lib/printf/vfprintf.c b/lib/printf/vfprintf.c index 3f6700c838..12c4dad683 100644 --- a/lib/printf/vfprintf.c +++ b/lib/printf/vfprintf.c @@ -556,23 +556,23 @@ reswitch: switch (ch) { case 'G': if (flags & LONGDBL) { long double arg = GETARG(long double); - char fmt[6] = "%.*L"; - fmt[4] = ch; - fmt[5] = '\0'; + char lfmt[6] = "%.*L"; + lfmt[4] = ch; + lfmt[5] = '\0'; #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wformat-nonliteral" - snprintf(buf, sizeof(buf), fmt, prec, arg); + snprintf(buf, sizeof(buf), lfmt, prec, arg); #pragma GCC diagnostic pop } else { double arg = GETARG(double); - char fmt[5] = "%.*"; - fmt[3] = ch; - fmt[4] = '\0'; + char lfmt[5] = "%.*"; + lfmt[3] = ch; + lfmt[4] = '\0'; #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wformat-nonliteral" - snprintf(buf, sizeof(buf), fmt, prec, arg); + snprintf(buf, sizeof(buf), lfmt, prec, arg); #pragma GCC diagnostic pop } cp = buf; diff --git a/lib/zclient.c b/lib/zclient.c index 3e68e962aa..031f454385 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -3014,7 +3014,7 @@ size_t zebra_interface_link_params_write(struct stream *s, size_t w, nb_ext_adm_grp; struct if_link_params *iflp; int i; - + size_t j; if (s == NULL || ifp == NULL) return 0; @@ -3045,8 +3045,8 @@ size_t zebra_interface_link_params_write(struct stream *s, /* Extended Administrative Group */ nb_ext_adm_grp = admin_group_nb_words(&iflp->ext_admin_grp); w += stream_putc(s, nb_ext_adm_grp); - for (size_t i = 0; i < nb_ext_adm_grp; i++) - stream_putl(s, admin_group_get_offset(&iflp->ext_admin_grp, i)); + for (j = 0; j < nb_ext_adm_grp; j++) + stream_putl(s, admin_group_get_offset(&iflp->ext_admin_grp, j)); w += stream_putl(s, iflp->rmt_as); w += stream_put_in_addr(s, &iflp->rmt_ip); diff --git a/mgmtd/mgmt_ds.c b/mgmtd/mgmt_ds.c index dabae4afd1..a50ba015a3 100644 --- a/mgmtd/mgmt_ds.c +++ b/mgmtd/mgmt_ds.c @@ -151,9 +151,9 @@ void mgmt_ds_reset_candidate(void) } -int mgmt_ds_init(struct mgmt_master *mm) +int mgmt_ds_init(struct mgmt_master *m) { - if (mgmt_ds_mm || mm->running_ds || mm->candidate_ds || mm->oper_ds) + if (mgmt_ds_mm || m->running_ds || m->candidate_ds || m->oper_ds) assert(!"MGMTD: Call ds_init only once!"); /* Use Running DS from NB module??? */ @@ -178,10 +178,10 @@ int mgmt_ds_init(struct mgmt_master *mm) oper.config_ds = false; oper.ds_id = MGMTD_DS_OPERATIONAL; - mm->running_ds = &running; - mm->candidate_ds = &candidate; - mm->oper_ds = &oper; - mgmt_ds_mm = mm; + m->running_ds = &running; + m->candidate_ds = &candidate; + m->oper_ds = &oper; + mgmt_ds_mm = m; return 0; } @@ -195,16 +195,15 @@ void mgmt_ds_destroy(void) oper.root.dnode_root = NULL; } -struct mgmt_ds_ctx *mgmt_ds_get_ctx_by_id(struct mgmt_master *mm, - Mgmtd__DatastoreId ds_id) +struct mgmt_ds_ctx *mgmt_ds_get_ctx_by_id(struct mgmt_master *m, Mgmtd__DatastoreId ds_id) { switch (ds_id) { case MGMTD_DS_CANDIDATE: - return (mm->candidate_ds); + return (m->candidate_ds); case MGMTD_DS_RUNNING: - return (mm->running_ds); + return (m->running_ds); case MGMTD_DS_OPERATIONAL: - return (mm->oper_ds); + return (m->oper_ds); case MGMTD_DS_NONE: case MGMTD__DATASTORE_ID__STARTUP_DS: case _MGMTD__DATASTORE_ID_IS_INT_SIZE: diff --git a/mgmtd/mgmt_fe_adapter.c b/mgmtd/mgmt_fe_adapter.c index 8d59198803..ff3165f369 100644 --- a/mgmtd/mgmt_fe_adapter.c +++ b/mgmtd/mgmt_fe_adapter.c @@ -1442,7 +1442,6 @@ static void fe_adapter_handle_get_data(struct mgmt_fe_session_ctx *session, /* Check for yang-library shortcut */ if (nb_oper_is_yang_lib_query(msg->xpath)) { struct lyd_node *ylib = NULL; - LY_ERR err; err = ly_ctx_get_yanglib_data(ly_native_ctx, &ylib, "%u", ly_ctx_get_change_count( diff --git a/mgmtd/mgmt_txn.c b/mgmtd/mgmt_txn.c index 483dfab8e8..9e06ce9f5f 100644 --- a/mgmtd/mgmt_txn.c +++ b/mgmtd/mgmt_txn.c @@ -1993,17 +1993,17 @@ static void mgmt_txn_register_event(struct mgmt_txn_ctx *txn, } } -int mgmt_txn_init(struct mgmt_master *mm, struct event_loop *tm) +int mgmt_txn_init(struct mgmt_master *m, struct event_loop *loop) { if (mgmt_txn_mm || mgmt_txn_tm) assert(!"MGMTD TXN: Call txn_init() only once"); - mgmt_txn_mm = mm; - mgmt_txn_tm = tm; - mgmt_txns_init(&mm->txn_list); + mgmt_txn_mm = m; + mgmt_txn_tm = loop; + mgmt_txns_init(&m->txn_list); mgmt_txn_hash_init(); - assert(!mm->cfg_txn); - mm->cfg_txn = NULL; + assert(!m->cfg_txn); + m->cfg_txn = NULL; return 0; } diff --git a/nhrpd/nhrp_route.c b/nhrpd/nhrp_route.c index 7adc4a6399..2e4c7b1eec 100644 --- a/nhrpd/nhrp_route.c +++ b/nhrpd/nhrp_route.c @@ -16,7 +16,7 @@ DEFINE_MTYPE_STATIC(NHRPD, NHRP_ROUTE, "NHRP routing entry"); -static struct zclient *zclient; +static struct zclient *nhrp_zclient; static struct route_table *zebra_rib[AFI_MAX]; struct route_info { @@ -95,7 +95,7 @@ void nhrp_route_announce(int add, enum nhrp_cache_type type, struct zapi_route api; struct zapi_nexthop *api_nh; - if (zclient->sock < 0) + if (nhrp_zclient->sock < 0) return; memset(&api, 0, sizeof(api)); @@ -196,7 +196,7 @@ void nhrp_route_announce(int add, enum nhrp_cache_type type, api.metric, api.nexthop_num, ifp ? ifp->name : "none"); } - zclient_route_send(add ? ZEBRA_ROUTE_ADD : ZEBRA_ROUTE_DELETE, zclient, + zclient_route_send(add ? ZEBRA_ROUTE_ADD : ZEBRA_ROUTE_DELETE, nhrp_zclient, &api); } @@ -374,10 +374,10 @@ void nhrp_zebra_init(void) zebra_rib[AFI_IP] = route_table_init(); zebra_rib[AFI_IP6] = route_table_init(); - zclient = zclient_new(master, &zclient_options_default, nhrp_handlers, - array_size(nhrp_handlers)); - zclient->zebra_connected = nhrp_zebra_connected; - zclient_init(zclient, ZEBRA_ROUTE_NHRP, 0, &nhrpd_privs); + nhrp_zclient = zclient_new(master, &zclient_options_default, nhrp_handlers, + array_size(nhrp_handlers)); + nhrp_zclient->zebra_connected = nhrp_zebra_connected; + zclient_init(nhrp_zclient, ZEBRA_ROUTE_NHRP, 0, &nhrpd_privs); } static void nhrp_table_node_cleanup(struct route_table *table, @@ -393,18 +393,18 @@ void nhrp_send_zebra_configure_arp(struct interface *ifp, int family) { struct stream *s; - if (!zclient || zclient->sock < 0) { + if (!nhrp_zclient || nhrp_zclient->sock < 0) { debugf(NHRP_DEBUG_COMMON, "%s() : zclient not ready", __func__); return; } - s = zclient->obuf; + s = nhrp_zclient->obuf; stream_reset(s); zclient_create_header(s, ZEBRA_CONFIGURE_ARP, ifp->vrf->vrf_id); stream_putc(s, family); stream_putl(s, ifp->ifindex); stream_putw_at(s, 0, stream_get_endp(s)); - zclient_send_message(zclient); + zclient_send_message(nhrp_zclient); } void nhrp_send_zebra_gre_source_set(struct interface *ifp, @@ -413,7 +413,7 @@ void nhrp_send_zebra_gre_source_set(struct interface *ifp, { struct stream *s; - if (!zclient || zclient->sock < 0) { + if (!nhrp_zclient || nhrp_zclient->sock < 0) { zlog_err("%s : zclient not ready", __func__); return; } @@ -421,7 +421,7 @@ void nhrp_send_zebra_gre_source_set(struct interface *ifp, /* silently ignore */ return; } - s = zclient->obuf; + s = nhrp_zclient->obuf; stream_reset(s); zclient_create_header(s, ZEBRA_GRE_SOURCE_SET, ifp->vrf->vrf_id); stream_putl(s, ifp->ifindex); @@ -429,7 +429,7 @@ void nhrp_send_zebra_gre_source_set(struct interface *ifp, stream_putl(s, link_vrf_id); stream_putl(s, 0); /* mtu provisioning */ stream_putw_at(s, 0, stream_get_endp(s)); - zclient_send_message(zclient); + zclient_send_message(nhrp_zclient); } void nhrp_send_zebra_nbr(union sockunion *in, @@ -438,9 +438,9 @@ void nhrp_send_zebra_nbr(union sockunion *in, { struct stream *s; - if (!zclient || zclient->sock < 0) + if (!nhrp_zclient || nhrp_zclient->sock < 0) return; - s = zclient->obuf; + s = nhrp_zclient->obuf; stream_reset(s); zclient_neigh_ip_encode(s, out ? ZEBRA_NEIGH_IP_ADD : ZEBRA_NEIGH_IP_DEL, in, out, ifp, @@ -448,26 +448,26 @@ void nhrp_send_zebra_nbr(union sockunion *in, : ZEBRA_NEIGH_STATE_FAILED, 0); stream_putw_at(s, 0, stream_get_endp(s)); - zclient_send_message(zclient); + zclient_send_message(nhrp_zclient); } int nhrp_send_zebra_gre_request(struct interface *ifp) { - return zclient_send_zebra_gre_request(zclient, ifp); + return zclient_send_zebra_gre_request(nhrp_zclient, ifp); } void nhrp_interface_update_arp(struct interface *ifp, bool arp_enable) { - zclient_interface_set_arp(zclient, ifp, arp_enable); + zclient_interface_set_arp(nhrp_zclient, ifp, arp_enable); } void nhrp_zebra_terminate(void) { - zclient_register_neigh(zclient, VRF_DEFAULT, AFI_IP, false); - zclient_register_neigh(zclient, VRF_DEFAULT, AFI_IP6, false); - zclient_stop(zclient); - zclient_free(zclient); + zclient_register_neigh(nhrp_zclient, VRF_DEFAULT, AFI_IP, false); + zclient_register_neigh(nhrp_zclient, VRF_DEFAULT, AFI_IP6, false); + zclient_stop(nhrp_zclient); + zclient_free(nhrp_zclient); zebra_rib[AFI_IP]->cleanup = nhrp_table_node_cleanup; zebra_rib[AFI_IP6]->cleanup = nhrp_table_node_cleanup; diff --git a/ospf6d/ospf6_abr.c b/ospf6d/ospf6_abr.c index 343dfefcec..2cb63d8a29 100644 --- a/ospf6d/ospf6_abr.c +++ b/ospf6d/ospf6_abr.c @@ -515,8 +515,6 @@ int ospf6_abr_originate_summary_to_area(struct ospf6_route *route, summary->path.origin.id = ADV_ROUTER_IN_PREFIX(&route->prefix); } else { - struct ospf6_lsa *old; - summary->path.origin.type = htons(OSPF6_LSTYPE_INTER_PREFIX); diff --git a/ospf6d/ospf6_area.h b/ospf6d/ospf6_area.h index 2ed69cc597..16049427ac 100644 --- a/ospf6d/ospf6_area.h +++ b/ospf6d/ospf6_area.h @@ -123,16 +123,16 @@ struct ospf6_area { #define OSPF6_CMD_AREA_GET(str, oa, ospf6) \ { \ - uint32_t area_id; \ - int format, ret; \ - ret = str2area_id(str, &area_id, &format); \ - if (ret) { \ + uint32_t _area_id; \ + int _format, _ret; \ + _ret = str2area_id(str, &_area_id, &_format); \ + if (_ret) { \ vty_out(vty, "Malformed Area-ID: %s\n", str); \ return CMD_WARNING; \ } \ - oa = ospf6_area_lookup(area_id, ospf6); \ + oa = ospf6_area_lookup(_area_id, ospf6); \ if (oa == NULL) \ - oa = ospf6_area_create(area_id, ospf6, format); \ + oa = ospf6_area_create(_area_id, ospf6, _format); \ } /* prototypes */ diff --git a/ospf6d/ospf6_asbr.c b/ospf6d/ospf6_asbr.c index 8fa85badbe..df2758b081 100644 --- a/ospf6d/ospf6_asbr.c +++ b/ospf6d/ospf6_asbr.c @@ -1899,7 +1899,7 @@ static void ospf6_redistribute_default_set(struct ospf6 *ospf6, int originate) break; case DEFAULT_ORIGINATE_ZEBRA: zclient_redistribute_default(ZEBRA_REDISTRIBUTE_DEFAULT_DELETE, - zclient, AFI_IP6, ospf6->vrf_id); + ospf6_zclient, AFI_IP6, ospf6->vrf_id); ospf6_asbr_redistribute_remove(DEFAULT_ROUTE, 0, (struct prefix *)&p, ospf6); @@ -1915,7 +1915,7 @@ static void ospf6_redistribute_default_set(struct ospf6 *ospf6, int originate) break; case DEFAULT_ORIGINATE_ZEBRA: zclient_redistribute_default(ZEBRA_REDISTRIBUTE_DEFAULT_ADD, - zclient, AFI_IP6, ospf6->vrf_id); + ospf6_zclient, AFI_IP6, ospf6->vrf_id); break; case DEFAULT_ORIGINATE_ALWAYS: diff --git a/ospf6d/ospf6_bfd.c b/ospf6d/ospf6_bfd.c index 6379f9d992..0b00558572 100644 --- a/ospf6d/ospf6_bfd.c +++ b/ospf6d/ospf6_bfd.c @@ -27,8 +27,6 @@ #include "ospf6_zebra.h" #include "ospf6_bfd.h" -extern struct zclient *zclient; - /* * ospf6_bfd_trigger_event - Neighbor is registered/deregistered with BFD when * neighbor state is changed to/from 2way. @@ -280,7 +278,7 @@ DEFUN (no_ipv6_ospf6_bfd, void ospf6_bfd_init(void) { - bfd_protocol_integration_init(zclient, master); + bfd_protocol_integration_init(ospf6_zclient, master); /* Install BFD command */ install_element(INTERFACE_NODE, &ipv6_ospf6_bfd_cmd); diff --git a/ospf6d/ospf6_main.c b/ospf6d/ospf6_main.c index 8320f11f6c..e94f2a1c47 100644 --- a/ospf6d/ospf6_main.c +++ b/ospf6d/ospf6_main.c @@ -104,9 +104,9 @@ static void __attribute__((noreturn)) ospf6_exit(int status) vrf_terminate(); - if (zclient) { - zclient_stop(zclient); - zclient_free(zclient); + if (ospf6_zclient) { + zclient_stop(ospf6_zclient); + zclient_free(ospf6_zclient); } ospf6_master_delete(); diff --git a/ospf6d/ospf6_snmp.c b/ospf6d/ospf6_snmp.c index 9ac8b6c1af..037ca9bc0b 100644 --- a/ospf6d/ospf6_snmp.c +++ b/ospf6d/ospf6_snmp.c @@ -1382,9 +1382,9 @@ static int ospf6TrapIfStateChange(struct ospf6_interface *oi, int next_state, } /* Register OSPFv3-MIB. */ -static int ospf6_snmp_init(struct event_loop *master) +static int ospf6_snmp_init(struct event_loop *mstr) { - smux_init(master); + smux_init(mstr); REGISTER_MIB("OSPFv3MIB", ospfv3_variables, variable, ospfv3_oid); return 0; } diff --git a/ospf6d/ospf6_top.c b/ospf6d/ospf6_top.c index ad487f3565..9755cc44cc 100644 --- a/ospf6d/ospf6_top.c +++ b/ospf6d/ospf6_top.c @@ -142,20 +142,20 @@ static void ospf6_set_redist_vrf_bitmaps(struct ospf6 *ospf6, bool set) "%s: setting redist vrf %d bitmap for type %d", __func__, ospf6->vrf_id, type); if (set) - vrf_bitmap_set(&zclient->redist[AFI_IP6][type], + vrf_bitmap_set(&ospf6_zclient->redist[AFI_IP6][type], ospf6->vrf_id); else - vrf_bitmap_unset(&zclient->redist[AFI_IP6][type], + vrf_bitmap_unset(&ospf6_zclient->redist[AFI_IP6][type], ospf6->vrf_id); } red_list = ospf6->redist[DEFAULT_ROUTE]; if (red_list) { if (set) - vrf_bitmap_set(&zclient->default_information[AFI_IP6], + vrf_bitmap_set(&ospf6_zclient->default_information[AFI_IP6], ospf6->vrf_id); else - vrf_bitmap_unset(&zclient->default_information[AFI_IP6], + vrf_bitmap_unset(&ospf6_zclient->default_information[AFI_IP6], ospf6->vrf_id); } } @@ -566,13 +566,13 @@ static void ospf6_disable(struct ospf6 *o) } } -void ospf6_master_init(struct event_loop *master) +void ospf6_master_init(struct event_loop *mst) { memset(&ospf6_master, 0, sizeof(ospf6_master)); om6 = &ospf6_master; om6->ospf6 = list_new(); - om6->master = master; + om6->master = mst; } void ospf6_master_delete(void) diff --git a/ospf6d/ospf6_top.h b/ospf6d/ospf6_top.h index 8288413c10..2b29eeae89 100644 --- a/ospf6d/ospf6_top.h +++ b/ospf6d/ospf6_top.h @@ -231,7 +231,6 @@ DECLARE_QOBJ_TYPE(ospf6); #define OSPF6_STUB_ROUTER 0x02 /* global pointer for OSPF top data structure */ -extern struct ospf6 *ospf6; extern struct ospf6_master *om6; /* prototypes */ diff --git a/ospf6d/ospf6_zebra.c b/ospf6d/ospf6_zebra.c index 466301309f..cfb9bc1c11 100644 --- a/ospf6d/ospf6_zebra.c +++ b/ospf6d/ospf6_zebra.c @@ -36,11 +36,11 @@ DEFINE_MTYPE_STATIC(OSPF6D, OSPF6_DISTANCE, "OSPF6 distance"); unsigned char conf_debug_ospf6_zebra = 0; /* information about zebra. */ -struct zclient *zclient = NULL; +struct zclient *ospf6_zclient = NULL; void ospf6_zebra_vrf_register(struct ospf6 *ospf6) { - if (!zclient || zclient->sock < 0 || !ospf6) + if (!ospf6_zclient || ospf6_zclient->sock < 0 || !ospf6) return; if (ospf6->vrf_id != VRF_UNKNOWN) { @@ -49,13 +49,13 @@ void ospf6_zebra_vrf_register(struct ospf6 *ospf6) ospf6_vrf_id_to_name(ospf6->vrf_id), ospf6->vrf_id); } - zclient_send_reg_requests(zclient, ospf6->vrf_id); + zclient_send_reg_requests(ospf6_zclient, ospf6->vrf_id); } } void ospf6_zebra_vrf_deregister(struct ospf6 *ospf6) { - if (!zclient || zclient->sock < 0 || !ospf6) + if (!ospf6_zclient || ospf6_zclient->sock < 0 || !ospf6) return; if (ospf6->vrf_id != VRF_DEFAULT && ospf6->vrf_id != VRF_UNKNOWN) { @@ -67,7 +67,7 @@ void ospf6_zebra_vrf_deregister(struct ospf6 *ospf6) } /* Deregister for router-id, interfaces, * redistributed routes. */ - zclient_send_dereg_requests(zclient, ospf6->vrf_id); + zclient_send_dereg_requests(ospf6_zclient, ospf6->vrf_id); } } @@ -98,22 +98,22 @@ static int ospf6_router_id_update_zebra(ZAPI_CALLBACK_ARGS) /* redistribute function */ void ospf6_zebra_redistribute(int type, vrf_id_t vrf_id) { - if (vrf_bitmap_check(&zclient->redist[AFI_IP6][type], vrf_id)) + if (vrf_bitmap_check(&ospf6_zclient->redist[AFI_IP6][type], vrf_id)) return; - vrf_bitmap_set(&zclient->redist[AFI_IP6][type], vrf_id); + vrf_bitmap_set(&ospf6_zclient->redist[AFI_IP6][type], vrf_id); - if (zclient->sock > 0) - zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, zclient, + if (ospf6_zclient->sock > 0) + zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, ospf6_zclient, AFI_IP6, type, 0, vrf_id); } void ospf6_zebra_no_redistribute(int type, vrf_id_t vrf_id) { - if (!vrf_bitmap_check(&zclient->redist[AFI_IP6][type], vrf_id)) + if (!vrf_bitmap_check(&ospf6_zclient->redist[AFI_IP6][type], vrf_id)) return; - vrf_bitmap_unset(&zclient->redist[AFI_IP6][type], vrf_id); - if (zclient->sock > 0) - zebra_redistribute_send(ZEBRA_REDISTRIBUTE_DELETE, zclient, + vrf_bitmap_unset(&ospf6_zclient->redist[AFI_IP6][type], vrf_id); + if (ospf6_zclient->sock > 0) + zebra_redistribute_send(ZEBRA_REDISTRIBUTE_DELETE, ospf6_zclient, AFI_IP6, type, 0, vrf_id); } @@ -122,7 +122,7 @@ void ospf6_zebra_import_default_route(struct ospf6 *ospf6, bool unreg) struct prefix prefix = {}; int command; - if (zclient->sock < 0) { + if (ospf6_zclient->sock < 0) { if (IS_OSPF6_DEBUG_ZEBRA(SEND)) zlog_debug(" Not connected to Zebra"); return; @@ -141,7 +141,7 @@ void ospf6_zebra_import_default_route(struct ospf6 *ospf6, bool unreg) zserv_command_string(command), &prefix, ospf6->vrf_id); - if (zclient_send_rnh(zclient, command, &prefix, SAFI_UNICAST, false, + if (zclient_send_rnh(ospf6_zclient, command, &prefix, SAFI_UNICAST, false, true, ospf6->vrf_id) == ZCLIENT_SEND_FAILURE) flog_err(EC_LIB_ZAPI_SOCKET, "%s: zclient_send_rnh() failed", @@ -216,7 +216,7 @@ static int ospf6_zebra_gr_update(struct ospf6 *ospf6, int command, { struct zapi_cap api; - if (!zclient || zclient->sock < 0 || !ospf6) + if (!ospf6_zclient || ospf6_zclient->sock < 0 || !ospf6) return 1; memset(&api, 0, sizeof(api)); @@ -224,7 +224,7 @@ static int ospf6_zebra_gr_update(struct ospf6 *ospf6, int command, api.stale_removal_time = stale_time; api.vrf_id = ospf6->vrf_id; - (void)zclient_capabilities_send(ZEBRA_CLIENT_CAPABILITIES, zclient, + (void)zclient_capabilities_send(ZEBRA_CLIENT_CAPABILITIES, ospf6_zclient, &api); return 0; @@ -313,7 +313,7 @@ DEFUN(show_zebra, json_object *json_zebra; json_object *json_array; - if (zclient == NULL) { + if (ospf6_zclient == NULL) { vty_out(vty, "Not connected to zebra\n"); return CMD_SUCCESS; } @@ -323,13 +323,13 @@ DEFUN(show_zebra, json_zebra = json_object_new_object(); json_array = json_object_new_array(); - json_object_int_add(json_zebra, "fail", zclient->fail); + json_object_int_add(json_zebra, "fail", ospf6_zclient->fail); json_object_int_add( json_zebra, "redistributeDefault", - vrf_bitmap_check(&zclient->default_information[AFI_IP6], + vrf_bitmap_check(&ospf6_zclient->default_information[AFI_IP6], VRF_DEFAULT)); for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { - if (vrf_bitmap_check(&zclient->redist[AFI_IP6][i], + if (vrf_bitmap_check(&ospf6_zclient->redist[AFI_IP6][i], VRF_DEFAULT)) json_object_array_add( json_array, @@ -342,13 +342,13 @@ DEFUN(show_zebra, vty_json(vty, json); } else { vty_out(vty, "Zebra Information\n"); - vty_out(vty, " fail: %d\n", zclient->fail); + vty_out(vty, " fail: %d\n", ospf6_zclient->fail); vty_out(vty, " redistribute default: %d\n", - vrf_bitmap_check(&zclient->default_information[AFI_IP6], + vrf_bitmap_check(&ospf6_zclient->default_information[AFI_IP6], VRF_DEFAULT)); vty_out(vty, " redistribute:"); for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { - if (vrf_bitmap_check(&zclient->redist[AFI_IP6][i], + if (vrf_bitmap_check(&ospf6_zclient->redist[AFI_IP6][i], VRF_DEFAULT)) vty_out(vty, " %s", zebra_route_string(i)); } @@ -403,7 +403,7 @@ static void ospf6_zebra_route_update(int type, struct ospf6_route *request, zlog_debug("Zebra Send %s route: %pFX", (type == REM ? "remove" : "add"), &request->prefix); - if (zclient->sock < 0) { + if (ospf6_zclient->sock < 0) { if (IS_OSPF6_DEBUG_ZEBRA(SEND)) zlog_debug(" Not connected to Zebra"); return; @@ -487,9 +487,9 @@ static void ospf6_zebra_route_update(int type, struct ospf6_route *request, ospf6_zebra_append_opaque_attr(request, &api); if (type == REM) - ret = zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api); + ret = zclient_route_send(ZEBRA_ROUTE_DELETE, ospf6_zclient, &api); else - ret = zclient_route_send(ZEBRA_ROUTE_ADD, zclient, &api); + ret = zclient_route_send(ZEBRA_ROUTE_ADD, ospf6_zclient, &api); if (ret == ZCLIENT_SEND_FAILURE) flog_err(EC_LIB_ZAPI_SOCKET, @@ -552,7 +552,7 @@ void ospf6_zebra_add_discard(struct ospf6_route *request, struct ospf6 *ospf6) api.prefix = *dest; zapi_route_set_blackhole(&api, BLACKHOLE_NULL); - zclient_route_send(ZEBRA_ROUTE_ADD, zclient, &api); + zclient_route_send(ZEBRA_ROUTE_ADD, ospf6_zclient, &api); if (IS_OSPF6_DEBUG_ZEBRA(SEND)) zlog_debug("Zebra: Route add discard %pFX", dest); @@ -589,7 +589,7 @@ void ospf6_zebra_delete_discard(struct ospf6_route *request, api.prefix = *dest; zapi_route_set_blackhole(&api, BLACKHOLE_NULL); - zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api); + zclient_route_send(ZEBRA_ROUTE_DELETE, ospf6_zclient, &api); if (IS_OSPF6_DEBUG_ZEBRA(SEND)) zlog_debug("Zebra: Route delete discard %pFX", dest); @@ -758,14 +758,14 @@ static zclient_handler *const ospf6_handlers[] = { [ZEBRA_REDISTRIBUTE_ROUTE_DEL] = ospf6_zebra_read_route, }; -void ospf6_zebra_init(struct event_loop *master) +void ospf6_zebra_init(struct event_loop *mst) { /* Allocate zebra structure. */ - zclient = zclient_new(master, &zclient_options_default, ospf6_handlers, - array_size(ospf6_handlers)); - zclient_init(zclient, ZEBRA_ROUTE_OSPF6, 0, &ospf6d_privs); - zclient->zebra_connected = ospf6_zebra_connected; - zclient->nexthop_update = ospf6_zebra_import_check_update; + ospf6_zclient = zclient_new(mst, &zclient_options_default, ospf6_handlers, + array_size(ospf6_handlers)); + zclient_init(ospf6_zclient, ZEBRA_ROUTE_OSPF6, 0, &ospf6d_privs); + ospf6_zclient->zebra_connected = ospf6_zebra_connected; + ospf6_zclient->nexthop_update = ospf6_zebra_import_check_update; /* Install command element for zebra node. */ install_element(VIEW_NODE, &show_ospf6_zebra_cmd); diff --git a/ospf6d/ospf6_zebra.h b/ospf6d/ospf6_zebra.h index 7669b5e2c0..0ad86e8c9a 100644 --- a/ospf6d/ospf6_zebra.h +++ b/ospf6d/ospf6_zebra.h @@ -27,7 +27,7 @@ struct ospf6_distance { char *access_list; }; -extern struct zclient *zclient; +extern struct zclient *ospf6_zclient; struct ospf6; extern void ospf6_zebra_route_update_add(struct ospf6_route *request, @@ -38,7 +38,7 @@ extern void ospf6_zebra_route_update_remove(struct ospf6_route *request, extern void ospf6_zebra_redistribute(int, vrf_id_t vrf_id); extern void ospf6_zebra_no_redistribute(int, vrf_id_t vrf_id); #define ospf6_zebra_is_redistribute(type, vrf_id) \ - vrf_bitmap_check(&zclient->redist[AFI_IP6][type], vrf_id) + vrf_bitmap_check(&ospf6_zclient->redist[AFI_IP6][type], vrf_id) extern void ospf6_zebra_init(struct event_loop *tm); extern void ospf6_zebra_import_default_route(struct ospf6 *ospf6, bool unreg); extern void ospf6_zebra_add_discard(struct ospf6_route *request, diff --git a/ospf6d/ospf6d.c b/ospf6d/ospf6d.c index e4e0354fc9..ddb8a461d5 100644 --- a/ospf6d/ospf6d.c +++ b/ospf6d/ospf6d.c @@ -1408,13 +1408,13 @@ static void install_element_ospf6_debug_event(void) } /* Install ospf related commands. */ -void ospf6_init(struct event_loop *master) +void ospf6_init(struct event_loop *mst) { ospf6_top_init(); ospf6_area_init(); ospf6_interface_init(); ospf6_neighbor_init(); - ospf6_zebra_init(master); + ospf6_zebra_init(mst); ospf6_lsa_init(); ospf6_spf_init(); diff --git a/ospfclient/ospfclient.c b/ospfclient/ospfclient.c index 24ff08561d..315da6bb0a 100644 --- a/ospfclient/ospfclient.c +++ b/ospfclient/ospfclient.c @@ -54,7 +54,7 @@ struct zebra_privs_t ospfd_privs = {.user = NULL, struct event_loop *master; /* Global variables */ -struct ospf_apiclient *oclient; +struct ospf_apiclient *g_oclient; char **args; /* Our opaque LSAs have the following format. */ @@ -209,13 +209,13 @@ static void ready_callback(uint8_t lsa_type, uint8_t opaque_type, lsa_type, opaque_type, &addr); /* Schedule opaque LSA originate in 5 secs */ - event_add_timer(master, lsa_inject, oclient, 5, NULL); + event_add_timer(master, lsa_inject, g_oclient, 5, NULL); /* Schedule opaque LSA update with new value */ - event_add_timer(master, lsa_inject, oclient, 10, NULL); + event_add_timer(master, lsa_inject, g_oclient, 10, NULL); /* Schedule delete */ - event_add_timer(master, lsa_delete, oclient, 30, NULL); + event_add_timer(master, lsa_delete, g_oclient, 30, NULL); } static void new_if_callback(struct in_addr ifaddr, struct in_addr area_id) @@ -296,27 +296,27 @@ int main(int argc, char *argv[]) master = event_master_create(NULL); /* Open connection to OSPF daemon */ - oclient = ospf_apiclient_connect(args[1], ASYNCPORT); - if (!oclient) { + g_oclient = ospf_apiclient_connect(args[1], ASYNCPORT); + if (!g_oclient) { printf("Connecting to OSPF daemon on %s failed!\n", args[1]); exit(1); } /* Register callback functions. */ ospf_apiclient_register_callback( - oclient, ready_callback, new_if_callback, del_if_callback, + g_oclient, ready_callback, new_if_callback, del_if_callback, ism_change_callback, nsm_change_callback, lsa_update_callback, lsa_delete_callback); /* Register LSA type and opaque type. */ - ospf_apiclient_register_opaque_type(oclient, atoi(args[2]), + ospf_apiclient_register_opaque_type(g_oclient, atoi(args[2]), atoi(args[3])); /* Synchronize database with OSPF daemon. */ - ospf_apiclient_sync_lsdb(oclient); + ospf_apiclient_sync_lsdb(g_oclient); /* Schedule thread that handles asynchronous messages */ - event_add_read(master, lsa_read, oclient, oclient->fd_async, NULL); + event_add_read(master, lsa_read, g_oclient, g_oclient->fd_async, NULL); /* Now connection is established, run loop */ while (1) { diff --git a/ospfd/ospf_bfd.c b/ospfd/ospf_bfd.c index 7d4c7c06b8..ceab63540e 100644 --- a/ospfd/ospf_bfd.c +++ b/ospfd/ospf_bfd.c @@ -312,7 +312,7 @@ DEFUN (no_ip_ospf_bfd, void ospf_bfd_init(struct event_loop *tm) { - bfd_protocol_integration_init(zclient, tm); + bfd_protocol_integration_init(ospf_zclient, tm); /* Install BFD command */ install_element(INTERFACE_NODE, &ip_ospf_bfd_cmd); diff --git a/ospfd/ospf_flood.c b/ospfd/ospf_flood.c index bcb35315d8..6184d1352c 100644 --- a/ospfd/ospf_flood.c +++ b/ospfd/ospf_flood.c @@ -33,8 +33,6 @@ #include "ospfd/ospf_zebra.h" #include "ospfd/ospf_dump.h" -extern struct zclient *zclient; - /** @brief Function to refresh type-5 and type-7 DNA * LSAs when we receive an indication LSA. * @param Ospf instance. @@ -172,11 +170,11 @@ struct external_info *ospf_external_info_check(struct ospf *ospf, redist_on = is_default_prefix4(&p) ? vrf_bitmap_check( - &zclient->default_information[AFI_IP], + &ospf_zclient->default_information[AFI_IP], ospf->vrf_id) - : (zclient->mi_redist[AFI_IP][type].enabled || + : (ospf_zclient->mi_redist[AFI_IP][type].enabled || vrf_bitmap_check( - &zclient->redist[AFI_IP][type], + &ospf_zclient->redist[AFI_IP][type], ospf->vrf_id)); // Pending: check for MI above. if (redist_on) { diff --git a/ospfd/ospf_ldp_sync.c b/ospfd/ospf_ldp_sync.c index 496ae5b4bd..99f81f5663 100644 --- a/ospfd/ospf_ldp_sync.c +++ b/ospfd/ospf_ldp_sync.c @@ -28,8 +28,6 @@ #include "ospf_dump.h" #include "ospf_ism.h" -extern struct zclient *zclient; - /* * LDP-SYNC msg between IGP and LDP */ @@ -98,8 +96,8 @@ void ospf_ldp_sync_state_req_msg(struct interface *ifp) request.proto = LDP_IGP_SYNC_IF_STATE_REQUEST; request.ifindex = ifp->ifindex; - zclient_send_opaque(zclient, LDP_IGP_SYNC_IF_STATE_REQUEST, - (uint8_t *)&request, sizeof(request)); + zclient_send_opaque(ospf_zclient, LDP_IGP_SYNC_IF_STATE_REQUEST, + (uint8_t *)&request, sizeof(request)); } /* @@ -400,9 +398,9 @@ void ospf_ldp_sync_gbl_exit(struct ospf *ospf, bool remove) */ if (CHECK_FLAG(ospf->ldp_sync_cmd.flags, LDP_SYNC_FLAG_ENABLE)) { /* unregister with opaque client to recv LDP-IGP Sync msgs */ - zclient_unregister_opaque(zclient, + zclient_unregister_opaque(ospf_zclient, LDP_IGP_SYNC_IF_STATE_UPDATE); - zclient_unregister_opaque(zclient, + zclient_unregister_opaque(ospf_zclient, LDP_IGP_SYNC_ANNOUNCE_UPDATE); /* disable LDP globally */ @@ -754,8 +752,8 @@ DEFPY (ospf_mpls_ldp_sync, } /* register with opaque client to recv LDP-IGP Sync msgs */ - zclient_register_opaque(zclient, LDP_IGP_SYNC_IF_STATE_UPDATE); - zclient_register_opaque(zclient, LDP_IGP_SYNC_ANNOUNCE_UPDATE); + zclient_register_opaque(ospf_zclient, LDP_IGP_SYNC_IF_STATE_UPDATE); + zclient_register_opaque(ospf_zclient, LDP_IGP_SYNC_ANNOUNCE_UPDATE); if (!CHECK_FLAG(ospf->ldp_sync_cmd.flags, LDP_SYNC_FLAG_ENABLE)) { SET_FLAG(ospf->ldp_sync_cmd.flags, LDP_SYNC_FLAG_ENABLE); diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c index d35f0a1372..13bf947994 100644 --- a/ospfd/ospf_packet.c +++ b/ospfd/ospf_packet.c @@ -4055,11 +4055,11 @@ void ospf_ls_ack_send_direct(struct ospf_neighbor *nbr, struct ospf_lsa *lsa) * ignored. */ if (oi->type == OSPF_IFTYPE_POINTOMULTIPOINT && !oi->p2mp_non_broadcast) { - struct ospf_lsa_list_entry *ls_ack_list_entry; + struct ospf_lsa_list_entry *ack_list_entry; struct ospf_lsa *ack_queue_lsa; - frr_each (ospf_lsa_list, &oi->ls_ack_direct, ls_ack_list_entry) { - ack_queue_lsa = ls_ack_list_entry->lsa; + frr_each (ospf_lsa_list, &oi->ls_ack_direct, ack_list_entry) { + ack_queue_lsa = ack_list_entry->lsa; if ((lsa == ack_queue_lsa) || ((lsa->data->type == ack_queue_lsa->data->type) && (lsa->data->id.s_addr == diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c index b6f432b1bb..d187485b9f 100644 --- a/ospfd/ospf_te.c +++ b/ospfd/ospf_te.c @@ -1709,15 +1709,15 @@ static int ospf_te_export(uint8_t type, void *link_state) switch (type) { case LS_MSG_TYPE_NODE: ls_vertex2msg(&msg, (struct ls_vertex *)link_state); - rc = ls_send_msg(zclient, &msg, NULL); + rc = ls_send_msg(ospf_zclient, &msg, NULL); break; case LS_MSG_TYPE_ATTRIBUTES: ls_edge2msg(&msg, (struct ls_edge *)link_state); - rc = ls_send_msg(zclient, &msg, NULL); + rc = ls_send_msg(ospf_zclient, &msg, NULL); break; case LS_MSG_TYPE_PREFIX: ls_subnet2msg(&msg, (struct ls_subnet *)link_state); - rc = ls_send_msg(zclient, &msg, NULL); + rc = ls_send_msg(ospf_zclient, &msg, NULL); break; default: rc = -1; @@ -3113,7 +3113,7 @@ int ospf_te_sync_ted(struct zapi_opaque_reg_info dst) if (!OspfMplsTE.enabled || !OspfMplsTE.export) return rc; - rc = ls_sync_ted(OspfMplsTE.ted, zclient, &dst); + rc = ls_sync_ted(OspfMplsTE.ted, ospf_zclient, &dst); return rc; } @@ -4306,7 +4306,7 @@ DEFUN (ospf_mpls_te_export, VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); if (OspfMplsTE.enabled) { - if (ls_register(zclient, true) != 0) { + if (ls_register(ospf_zclient, true) != 0) { vty_out(vty, "Unable to register Link State\n"); return CMD_WARNING; } @@ -4330,7 +4330,7 @@ DEFUN (no_ospf_mpls_te_export, VTY_DECLVAR_INSTANCE_CONTEXT(ospf, ospf); if (OspfMplsTE.export) { - if (ls_unregister(zclient, true) != 0) { + if (ls_unregister(ospf_zclient, true) != 0) { vty_out(vty, "Unable to unregister Link State\n"); return CMD_WARNING; } diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 95e8b179d8..3263d0a5f8 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -12308,8 +12308,6 @@ static int config_write_interface_one(struct vty *vty, struct vrf *vrf) else vty_out(vty, " ip ospf"); - char buf[INET_ADDRSTRLEN]; - area_id2str(buf, sizeof(buf), ¶ms->if_area, params->if_area_id_fmt); vty_out(vty, " area %s", buf); diff --git a/ospfd/ospf_zebra.c b/ospfd/ospf_zebra.c index f45135f44f..cac8a5762f 100644 --- a/ospfd/ospf_zebra.c +++ b/ospfd/ospf_zebra.c @@ -45,7 +45,7 @@ DEFINE_MTYPE_STATIC(OSPFD, OSPF_REDISTRIBUTE, "OSPF Redistriute"); /* Zebra structure to hold current status. */ -struct zclient *zclient = NULL; +struct zclient *ospf_zclient; /* and for the Synchronous connection to the Label Manager */ struct zclient *zclient_sync; @@ -342,7 +342,7 @@ void ospf_zebra_add(struct ospf *ospf, struct prefix_ipv4 *p, if (CHECK_FLAG(ospf->config, OSPF_SEND_EXTRA_DATA_TO_ZEBRA)) ospf_zebra_append_opaque_attr(or, &api); - zclient_route_send(ZEBRA_ROUTE_ADD, zclient, &api); + zclient_route_send(ZEBRA_ROUTE_ADD, ospf_zclient, &api); } void ospf_zebra_delete(struct ospf *ospf, struct prefix_ipv4 *p, @@ -368,7 +368,7 @@ void ospf_zebra_delete(struct ospf *ospf, struct prefix_ipv4 *p, zlog_debug("Zebra: Route delete %pFX(%s)", p, ospf_vrf_id_to_name(ospf->vrf_id)); - zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api); + zclient_route_send(ZEBRA_ROUTE_DELETE, ospf_zclient, &api); } void ospf_zebra_add_discard(struct ospf *ospf, struct prefix_ipv4 *p) @@ -390,7 +390,7 @@ void ospf_zebra_add_discard(struct ospf *ospf, struct prefix_ipv4 *p) memcpy(&api.prefix, p, sizeof(*p)); zapi_route_set_blackhole(&api, BLACKHOLE_NULL); - zclient_route_send(ZEBRA_ROUTE_ADD, zclient, &api); + zclient_route_send(ZEBRA_ROUTE_ADD, ospf_zclient, &api); if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE)) zlog_debug("Zebra: Route add discard %pFX(%s)", p, @@ -416,7 +416,7 @@ void ospf_zebra_delete_discard(struct ospf *ospf, struct prefix_ipv4 *p) memcpy(&api.prefix, p, sizeof(*p)); zapi_route_set_blackhole(&api, BLACKHOLE_NULL); - zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api); + zclient_route_send(ZEBRA_ROUTE_DELETE, ospf_zclient, &api); if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE)) zlog_debug("Zebra: Route delete discard %pFX(%s)", p, @@ -695,7 +695,7 @@ void ospf_zebra_update_prefix_sid(const struct sr_prefix *srp) } /* Finally, send message to zebra. */ - (void)zebra_send_mpls_labels(zclient, ZEBRA_MPLS_LABELS_REPLACE, &zl); + (void)zebra_send_mpls_labels(ospf_zclient, ZEBRA_MPLS_LABELS_REPLACE, &zl); } /* Remove NHLFE for Prefix-SID */ @@ -722,7 +722,7 @@ void ospf_zebra_delete_prefix_sid(const struct sr_prefix *srp) } /* Send message to zebra. */ - (void)zebra_send_mpls_labels(zclient, ZEBRA_MPLS_LABELS_DELETE, &zl); + (void)zebra_send_mpls_labels(ospf_zclient, ZEBRA_MPLS_LABELS_DELETE, &zl); } /* Send MPLS Label entry to Zebra for installation or deletion */ @@ -746,7 +746,7 @@ void ospf_zebra_send_adjacency_sid(int cmd, struct sr_nhlfe nhlfe) znh->label_num = 1; znh->labels[0] = nhlfe.label_out; - (void)zebra_send_mpls_labels(zclient, cmd, &zl); + (void)zebra_send_mpls_labels(ospf_zclient, cmd, &zl); } struct ospf_redist *ospf_redist_lookup(struct ospf *ospf, uint8_t type, @@ -815,14 +815,14 @@ int ospf_is_type_redistributed(struct ospf *ospf, int type, { return (DEFAULT_ROUTE_TYPE(type) ? vrf_bitmap_check( - &zclient->default_information[AFI_IP], + &ospf_zclient->default_information[AFI_IP], ospf->vrf_id) : ((instance && redist_check_instance( - &zclient->mi_redist[AFI_IP][type], + &ospf_zclient->mi_redist[AFI_IP][type], instance)) || (!instance && - vrf_bitmap_check(&zclient->redist[AFI_IP][type], + vrf_bitmap_check(&ospf_zclient->redist[AFI_IP][type], ospf->vrf_id)))); } @@ -861,7 +861,7 @@ int ospf_redistribute_set(struct ospf *ospf, struct ospf_redist *red, int type, ospf_external_add(ospf, type, instance); - zclient_redistribute(ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP, type, + zclient_redistribute(ZEBRA_REDISTRIBUTE_ADD, ospf_zclient, AFI_IP, type, instance, ospf->vrf_id); if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE)) @@ -879,10 +879,10 @@ int ospf_redistribute_set(struct ospf *ospf, struct ospf_redist *red, int type, int ospf_redistribute_unset(struct ospf *ospf, int type, unsigned short instance) { - if (type == zclient->redist_default && instance == zclient->instance) + if (type == ospf_zclient->redist_default && instance == ospf_zclient->instance) return CMD_SUCCESS; - zclient_redistribute(ZEBRA_REDISTRIBUTE_DELETE, zclient, AFI_IP, type, + zclient_redistribute(ZEBRA_REDISTRIBUTE_DELETE, ospf_zclient, AFI_IP, type, instance, ospf->vrf_id); if (IS_DEBUG_OSPF(zebra, ZEBRA_REDISTRIBUTE)) @@ -933,7 +933,7 @@ int ospf_redistribute_default_set(struct ospf *ospf, int originate, int mtype, break; case DEFAULT_ORIGINATE_ZEBRA: zclient_redistribute_default(ZEBRA_REDISTRIBUTE_DEFAULT_DELETE, - zclient, AFI_IP, ospf->vrf_id); + ospf_zclient, AFI_IP, ospf->vrf_id); ospf->redistribute--; break; case DEFAULT_ORIGINATE_ALWAYS: @@ -951,7 +951,7 @@ int ospf_redistribute_default_set(struct ospf *ospf, int originate, int mtype, type_str = "normal"; ospf->redistribute++; zclient_redistribute_default(ZEBRA_REDISTRIBUTE_DEFAULT_ADD, - zclient, AFI_IP, ospf->vrf_id); + ospf_zclient, AFI_IP, ospf->vrf_id); break; case DEFAULT_ORIGINATE_ALWAYS: type_str = "always"; @@ -1242,7 +1242,7 @@ static int ospf_zebra_gr_update(struct ospf *ospf, int command, { struct zapi_cap api; - if (!zclient || zclient->sock < 0 || !ospf) + if (!ospf_zclient || ospf_zclient->sock < 0 || !ospf) return 1; memset(&api, 0, sizeof(api)); @@ -1250,7 +1250,7 @@ static int ospf_zebra_gr_update(struct ospf *ospf, int command, api.stale_removal_time = stale_time; api.vrf_id = ospf->vrf_id; - (void)zclient_capabilities_send(ZEBRA_CLIENT_CAPABILITIES, zclient, + (void)zclient_capabilities_send(ZEBRA_CLIENT_CAPABILITIES, ospf_zclient, &api); return 0; @@ -1495,7 +1495,7 @@ void ospf_zebra_import_default_route(struct ospf *ospf, bool unreg) struct prefix prefix = {}; int command; - if (zclient->sock < 0) { + if (ospf_zclient->sock < 0) { if (IS_DEBUG_OSPF(zebra, ZEBRA)) zlog_debug(" Not connected to Zebra vrf: %s", ospf_vrf_id_to_name(ospf->vrf_id)); @@ -1515,7 +1515,7 @@ void ospf_zebra_import_default_route(struct ospf *ospf, bool unreg) zserv_command_string(command), &prefix, ospf_vrf_id_to_name(ospf->vrf_id)); - if (zclient_send_rnh(zclient, command, &prefix, SAFI_UNICAST, false, + if (zclient_send_rnh(ospf_zclient, command, &prefix, SAFI_UNICAST, false, true, ospf->vrf_id) == ZCLIENT_SEND_FAILURE) flog_err(EC_LIB_ZAPI_SOCKET, "%s(%s): zclient_send_rnh() failed", __func__, ospf_vrf_id_to_name(ospf->vrf_id)); @@ -2011,7 +2011,7 @@ uint8_t ospf_distance_apply(struct ospf *ospf, struct prefix_ipv4 *p, void ospf_zebra_vrf_register(struct ospf *ospf) { - if (!zclient || zclient->sock < 0 || !ospf) + if (!ospf_zclient || ospf_zclient->sock < 0 || !ospf) return; if (ospf->vrf_id != VRF_UNKNOWN) { @@ -2019,13 +2019,13 @@ void ospf_zebra_vrf_register(struct ospf *ospf) zlog_debug("%s: Register VRF %s id %u", __func__, ospf_vrf_id_to_name(ospf->vrf_id), ospf->vrf_id); - zclient_send_reg_requests(zclient, ospf->vrf_id); + zclient_send_reg_requests(ospf_zclient, ospf->vrf_id); } } void ospf_zebra_vrf_deregister(struct ospf *ospf) { - if (!zclient || zclient->sock < 0 || !ospf) + if (!ospf_zclient || ospf_zclient->sock < 0 || !ospf) return; if (ospf->vrf_id != VRF_DEFAULT && ospf->vrf_id != VRF_UNKNOWN) { @@ -2035,7 +2035,7 @@ void ospf_zebra_vrf_deregister(struct ospf *ospf) ospf->vrf_id); /* Deregister for router-id, interfaces, * redistributed routes. */ - zclient_send_dereg_requests(zclient, ospf->vrf_id); + zclient_send_dereg_requests(ospf_zclient, ospf->vrf_id); } } @@ -2230,17 +2230,17 @@ static zclient_handler *const ospf_handlers[] = { [ZEBRA_CLIENT_CLOSE_NOTIFY] = ospf_zebra_client_close_notify, }; -void ospf_zebra_init(struct event_loop *master, unsigned short instance) +void ospf_zebra_init(struct event_loop *mst, unsigned short instance) { /* Allocate zebra structure. */ - zclient = zclient_new(master, &zclient_options_default, ospf_handlers, - array_size(ospf_handlers)); - zclient_init(zclient, ZEBRA_ROUTE_OSPF, instance, &ospfd_privs); - zclient->zebra_connected = ospf_zebra_connected; - zclient->nexthop_update = ospf_zebra_import_check_update; + ospf_zclient = zclient_new(mst, &zclient_options_default, ospf_handlers, + array_size(ospf_handlers)); + zclient_init(ospf_zclient, ZEBRA_ROUTE_OSPF, instance, &ospfd_privs); + ospf_zclient->zebra_connected = ospf_zebra_connected; + ospf_zclient->nexthop_update = ospf_zebra_import_check_update; /* Initialize special zclient for synchronous message exchanges. */ - zclient_sync = zclient_new(master, &zclient_options_sync, NULL, 0); + zclient_sync = zclient_new(mst, &zclient_options_sync, NULL, 0); zclient_sync->sock = -1; zclient_sync->redist_default = ZEBRA_ROUTE_OSPF; zclient_sync->instance = instance; @@ -2259,5 +2259,5 @@ void ospf_zebra_init(struct event_loop *master, unsigned short instance) void ospf_zebra_send_arp(const struct interface *ifp, const struct prefix *p) { - zclient_send_neigh_discovery_req(zclient, ifp, p); + zclient_send_neigh_discovery_req(ospf_zclient, ifp, p); } diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c index 90330d368d..1d2078469d 100644 --- a/ospfd/ospfd.c +++ b/ospfd/ospfd.c @@ -59,9 +59,6 @@ struct ospf_master *om; unsigned short ospf_instance; -extern struct zclient *zclient; -extern struct zclient *zclient_sync; - /* OSPF config processing timer thread */ struct event *t_ospf_cfg; @@ -648,8 +645,8 @@ void ospf_terminate(void) * One or more ospf_finish()'s may have deferred shutdown to a timer * thread */ - zclient_stop(zclient); - zclient_free(zclient); + zclient_stop(ospf_zclient); + zclient_free(ospf_zclient); zclient_stop(zclient_sync); zclient_free(zclient_sync); @@ -2214,13 +2211,13 @@ void ospf_update_bufsize(struct ospf *ospf, uint32_t recvsize, ospf_sock_bufsize_update(ospf, ospf->fd, type); } -void ospf_master_init(struct event_loop *master) +void ospf_master_init(struct event_loop *mst) { memset(&ospf_master, 0, sizeof(ospf_master)); om = &ospf_master; om->ospf = list_new(); - om->master = master; + om->master = mst; } /* Link OSPF instance to VRF. */ @@ -2273,20 +2270,20 @@ static void ospf_set_redist_vrf_bitmaps(struct ospf *ospf, bool set) "%s: setting redist vrf %d bitmap for type %d", __func__, ospf->vrf_id, type); if (set) - vrf_bitmap_set(&zclient->redist[AFI_IP][type], + vrf_bitmap_set(&ospf_zclient->redist[AFI_IP][type], ospf->vrf_id); else - vrf_bitmap_unset(&zclient->redist[AFI_IP][type], + vrf_bitmap_unset(&ospf_zclient->redist[AFI_IP][type], ospf->vrf_id); } red_list = ospf->redist[DEFAULT_ROUTE]; if (red_list) { if (set) - vrf_bitmap_set(&zclient->default_information[AFI_IP], + vrf_bitmap_set(&ospf_zclient->default_information[AFI_IP], ospf->vrf_id); else - vrf_bitmap_unset(&zclient->default_information[AFI_IP], + vrf_bitmap_unset(&ospf_zclient->default_information[AFI_IP], ospf->vrf_id); } } diff --git a/ospfd/ospfd.h b/ospfd/ospfd.h index 6051dff709..460ff0f6ae 100644 --- a/ospfd/ospfd.h +++ b/ospfd/ospfd.h @@ -695,7 +695,8 @@ struct ospf_nbr_nbma { extern struct ospf_master *om; extern unsigned short ospf_instance; extern const int ospf_redistributed_proto_max; -extern struct zclient *zclient; +extern struct zclient *ospf_zclient; +extern struct zclient *zclient_sync; extern struct event_loop *master; extern int ospf_zlog; extern struct zebra_privs_t ospfd_privs; diff --git a/pathd/path_ted.c b/pathd/path_ted.c index 0f8d3827ff..f9dff1f019 100644 --- a/pathd/path_ted.c +++ b/pathd/path_ted.c @@ -31,7 +31,7 @@ static enum zclient_send_status path_ted_link_state_sync(void); static void path_ted_timer_handler_sync(struct event *thread); static void path_ted_timer_handler_refresh(struct event *thread); -extern struct zclient *zclient; +extern struct zclient *pathd_zclient; struct ted_state ted_state_g = { .dbg = { .conf = "debug pathd mpls-te", .desc = "Pathd TED" } }; @@ -40,9 +40,9 @@ struct ted_state ted_state_g = { .dbg = { .conf = "debug pathd mpls-te", * path_path_ted public API function implementations */ -void path_ted_init(struct event_loop *master) +void path_ted_init(struct event_loop *loop) { - ted_state_g.main = master; + ted_state_g.main = loop; ted_state_g.link_state_delay_interval = TIMER_RETRY_DELAY; ted_state_g.segment_list_refresh_interval = TIMER_RETRY_DELAY; path_ted_register_vty(); @@ -82,7 +82,7 @@ uint32_t path_ted_start_importing_igp(const char *daemon_str) return 1; } - if (ls_register(zclient, false /*client*/) != 0) { + if (ls_register(pathd_zclient, false /*client*/) != 0) { PATH_TED_ERROR("%s: PATHD-TED: Unable to register Link State", __func__); ted_state_g.import = IMPORT_UNKNOWN; @@ -113,7 +113,7 @@ uint32_t path_ted_stop_importing_igp(void) uint32_t status = 0; if (ted_state_g.import != IMPORT_UNKNOWN) { - if (ls_unregister(zclient, false /*client*/) != 0) { + if (ls_unregister(pathd_zclient, false /*client*/) != 0) { PATH_TED_ERROR( "%s: PATHD-TED: Unable to unregister Link State", __func__); @@ -382,7 +382,7 @@ DEFUN (no_path_ted, ted_state_g.enabled = false; PATH_TED_DEBUG("%s: PATHD-TED: ON -> OFF", __func__); ted_state_g.import = IMPORT_UNKNOWN; - if (ls_unregister(zclient, false /*client*/) != 0) { + if (ls_unregister(pathd_zclient, false /*client*/) != 0) { vty_out(vty, "Unable to unregister Link State\n"); return CMD_WARNING; } @@ -538,7 +538,7 @@ enum zclient_send_status path_ted_link_state_sync(void) { enum zclient_send_status status; - status = ls_request_sync(zclient); + status = ls_request_sync(pathd_zclient); if (status == -1) { PATH_TED_ERROR( "%s: PATHD-TED: Opaque error asking for TED sync ", diff --git a/pathd/path_zebra.c b/pathd/path_zebra.c index ba03315c82..1078b37dd6 100644 --- a/pathd/path_zebra.c +++ b/pathd/path_zebra.c @@ -26,7 +26,7 @@ static int path_zebra_opaque_msg_handler(ZAPI_CALLBACK_ARGS); -struct zclient *zclient; +struct zclient *pathd_zclient; static struct zclient *zclient_sync; /* Event to retry synch zapi setup for label-manager */ @@ -189,7 +189,7 @@ void path_zebra_add_sr_policy(struct srte_policy *policy, segment->sid_value; policy->status = SRTE_POLICY_STATUS_GOING_UP; - (void)zebra_send_sr_policy(zclient, ZEBRA_SR_POLICY_SET, &zp); + (void)zebra_send_sr_policy(pathd_zclient, ZEBRA_SR_POLICY_SET, &zp); } /** @@ -209,7 +209,7 @@ void path_zebra_delete_sr_policy(struct srte_policy *policy) zp.segment_list.label_num = 0; policy->status = SRTE_POLICY_STATUS_DOWN; - (void)zebra_send_sr_policy(zclient, ZEBRA_SR_POLICY_DELETE, &zp); + (void)zebra_send_sr_policy(pathd_zclient, ZEBRA_SR_POLICY_DELETE, &zp); } /** @@ -351,13 +351,13 @@ static zclient_handler *const path_handlers[] = { * * @param master The master thread */ -void path_zebra_init(struct event_loop *master) +void path_zebra_init(struct event_loop *loop) { /* Initialize asynchronous zclient. */ - zclient = zclient_new(master, &zclient_options_default, path_handlers, - array_size(path_handlers)); - zclient_init(zclient, ZEBRA_ROUTE_SRTE, 0, &pathd_privs); - zclient->zebra_connected = path_zebra_connected; + pathd_zclient = zclient_new(loop, &zclient_options_default, path_handlers, + array_size(path_handlers)); + zclient_init(pathd_zclient, ZEBRA_ROUTE_SRTE, 0, &pathd_privs); + pathd_zclient->zebra_connected = path_zebra_connected; /* Initialize special zclient for synchronous message exchanges. */ zclient_sync = zclient_new(master, &zclient_options_sync, NULL, 0); @@ -373,8 +373,8 @@ void path_zebra_init(struct event_loop *master) void path_zebra_stop(void) { - zclient_stop(zclient); - zclient_free(zclient); + zclient_stop(pathd_zclient); + zclient_free(pathd_zclient); event_cancel(&t_sync_connect); zclient_stop(zclient_sync); zclient_free(zclient_sync); diff --git a/pbrd/pbr_zebra.c b/pbrd/pbr_zebra.c index 277271c6b6..dc8cbc56bf 100644 --- a/pbrd/pbr_zebra.c +++ b/pbrd/pbr_zebra.c @@ -35,7 +35,7 @@ DEFINE_MTYPE_STATIC(PBRD, PBR_INTERFACE, "PBR Interface"); /* Zebra structure to hold current status. */ -struct zclient *zclient; +struct zclient *pbr_zclient; struct pbr_interface *pbr_if_new(struct interface *ifp) { @@ -272,7 +272,7 @@ static void route_add_helper(struct zapi_route *api, struct nexthop_group nhg, } api->nexthop_num = i; - zclient_route_send(ZEBRA_ROUTE_ADD, zclient, api); + zclient_route_send(ZEBRA_ROUTE_ADD, pbr_zclient, api); } /* @@ -342,17 +342,17 @@ void route_delete(struct pbr_nexthop_group_cache *pnhgc, afi_t afi) switch (afi) { case AFI_IP: api.prefix.family = AF_INET; - zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api); + zclient_route_send(ZEBRA_ROUTE_DELETE, pbr_zclient, &api); break; case AFI_IP6: api.prefix.family = AF_INET6; - zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api); + zclient_route_send(ZEBRA_ROUTE_DELETE, pbr_zclient, &api); break; case AFI_MAX: api.prefix.family = AF_INET; - zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api); + zclient_route_send(ZEBRA_ROUTE_DELETE, pbr_zclient, &api); api.prefix.family = AF_INET6; - zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api); + zclient_route_send(ZEBRA_ROUTE_DELETE, pbr_zclient, &api); break; case AFI_L2VPN: DEBUGD(&pbr_dbg_zebra, @@ -403,22 +403,22 @@ static zclient_handler *const pbr_handlers[] = { void pbr_zebra_init(void) { - zclient = zclient_new(master, &zclient_options_default, pbr_handlers, - array_size(pbr_handlers)); + pbr_zclient = zclient_new(master, &zclient_options_default, pbr_handlers, + array_size(pbr_handlers)); - zclient_init(zclient, ZEBRA_ROUTE_PBR, 0, &pbr_privs); - zclient->zebra_connected = zebra_connected; - zclient->nexthop_update = pbr_zebra_nexthop_update; + zclient_init(pbr_zclient, ZEBRA_ROUTE_PBR, 0, &pbr_privs); + pbr_zclient->zebra_connected = zebra_connected; + pbr_zclient->nexthop_update = pbr_zebra_nexthop_update; } void pbr_zebra_destroy(void) { - if (zclient == NULL) + if (pbr_zclient == NULL) return; - zclient_stop(zclient); - zclient_free(zclient); - zclient = NULL; + zclient_stop(pbr_zclient); + zclient_free(pbr_zclient); + pbr_zclient = NULL; } void pbr_send_rnh(struct nexthop *nhop, bool reg) @@ -454,7 +454,7 @@ void pbr_send_rnh(struct nexthop *nhop, bool reg) break; } - if (zclient_send_rnh(zclient, command, &p, SAFI_UNICAST, false, false, + if (zclient_send_rnh(pbr_zclient, command, &p, SAFI_UNICAST, false, false, nhop->vrf_id) == ZCLIENT_SEND_FAILURE) { zlog_warn("%s: Failure to send nexthop to zebra", __func__); @@ -608,7 +608,7 @@ bool pbr_send_pbr_map(struct pbr_map_sequence *pbrms, if (!install && !is_installed) return false; - s = zclient->obuf; + s = pbr_zclient->obuf; stream_reset(s); zclient_create_header(s, @@ -621,7 +621,7 @@ bool pbr_send_pbr_map(struct pbr_map_sequence *pbrms, if (pbr_encode_pbr_map_sequence(s, pbrms, pmi->ifp)) { stream_putw_at(s, 0, stream_get_endp(s)); - zclient_send_message(zclient); + zclient_send_message(pbr_zclient); } else { DEBUGD(&pbr_dbg_zebra, "%s: %s seq %u encode failed, skipped", __func__, pbrm->name, pbrms->seqno); diff --git a/pceplib/pcep_pcc.c b/pceplib/pcep_pcc.c index 92a968ef78..d53469e7cd 100644 --- a/pceplib/pcep_pcc.c +++ b/pceplib/pcep_pcc.c @@ -47,11 +47,11 @@ struct cmd_line_args { }; bool pcc_active_ = true; -pcep_session *session = NULL; -struct cmd_line_args *cmd_line_args = NULL; +pcep_session *g_session = NULL; +struct cmd_line_args *g_cmd_line_args = NULL; /* pcep_event callback variables */ bool pcep_event_condition = false; -struct pcep_event *event = NULL; +struct pcep_event *g_event = NULL; pthread_mutex_t pcep_event_mutex; pthread_cond_t pcep_event_cond_var; @@ -180,7 +180,7 @@ void handle_signal_action(int sig_number) if (sig_number == SIGINT) { pcep_log(LOG_INFO, "%s: SIGINT was caught!", __func__); pcc_active_ = false; - if (cmd_line_args->eventpoll == false) { + if (g_cmd_line_args->eventpoll == false) { pthread_mutex_lock(&pcep_event_mutex); pcep_event_condition = true; pthread_cond_signal(&pcep_event_cond_var); @@ -189,12 +189,12 @@ void handle_signal_action(int sig_number) } else if (sig_number == SIGUSR1) { pcep_log(LOG_INFO, "%s: SIGUSR1 was caught, dumping counters", __func__); - dump_pcep_session_counters(session); + dump_pcep_session_counters(g_session); pceplib_memory_dump(); } else if (sig_number == SIGUSR2) { pcep_log(LOG_INFO, "%s: SIGUSR2 was caught, reseting counters", __func__); - reset_pcep_session_counters(session); + reset_pcep_session_counters(g_session); } } @@ -377,7 +377,7 @@ void pcep_event_callback(void *cb_data, pcep_event *e) pcep_log(LOG_NOTICE, "%s: [%ld-%ld] pcep_event_callback", __func__, time(NULL), pthread_self()); pthread_mutex_lock(&pcep_event_mutex); - event = e; + g_event = e; pcep_event_condition = true; pthread_cond_signal(&pcep_event_cond_var); pthread_mutex_unlock(&pcep_event_mutex); @@ -388,14 +388,14 @@ int main(int argc, char **argv) pcep_log(LOG_NOTICE, "%s: [%ld-%ld] starting pcc_pcep example client", __func__, time(NULL), pthread_self()); - cmd_line_args = get_cmdline_args(argc, argv); - if (cmd_line_args == NULL) { + g_cmd_line_args = get_cmdline_args(argc, argv); + if (g_cmd_line_args == NULL) { return -1; } setup_signals(); - if (cmd_line_args->eventpoll == false) { + if (g_cmd_line_args->eventpoll == false) { struct pceplib_infra_config infra_config; memset(&infra_config, 0, sizeof(infra_config)); infra_config.pcep_event_func = pcep_event_callback; @@ -415,31 +415,31 @@ int main(int argc, char **argv) pcep_configuration *config = create_default_pcep_configuration(); config->pcep_msg_versioning->draft_ietf_pce_segment_routing_07 = true; - config->src_pcep_port = cmd_line_args->src_tcp_port; + config->src_pcep_port = g_cmd_line_args->src_tcp_port; config->is_tcp_auth_md5 = true; - strlcpy(config->tcp_authentication_str, cmd_line_args->tcp_md5_str, + strlcpy(config->tcp_authentication_str, g_cmd_line_args->tcp_md5_str, sizeof(config->tcp_authentication_str)); - int af = (cmd_line_args->is_ipv6 ? AF_INET6 : AF_INET); + int af = (g_cmd_line_args->is_ipv6 ? AF_INET6 : AF_INET); struct hostent *host_info = - gethostbyname2(cmd_line_args->dest_ip_str, af); + gethostbyname2(g_cmd_line_args->dest_ip_str, af); if (host_info == NULL) { pcep_log(LOG_ERR, "%s: Error getting IP address.", __func__); return -1; } - if (cmd_line_args->is_ipv6) { + if (g_cmd_line_args->is_ipv6) { struct in6_addr host_address; memcpy(&host_address, host_info->h_addr, host_info->h_length); - session = connect_pce_ipv6(config, &host_address); + g_session = connect_pce_ipv6(config, &host_address); } else { struct in_addr host_address; memcpy(&host_address, host_info->h_addr, host_info->h_length); - session = connect_pce(config, &host_address); + g_session = connect_pce(config, &host_address); } - if (session == NULL) { + if (g_session == NULL) { pcep_log(LOG_WARNING, "%s: Error in connect_pce.", __func__); destroy_pcep_configuration(config); return -1; @@ -447,12 +447,12 @@ int main(int argc, char **argv) sleep(2); - send_pce_report_message(session); + send_pce_report_message(g_session); /*send_pce_path_request_message(session);*/ /* Wait for pcep_event's either by polling the event queue or by * callback */ - if (cmd_line_args->eventpoll == true) { + if (g_cmd_line_args->eventpoll == true) { /* Poll the pcep_event queue*/ while (pcc_active_) { if (event_queue_is_empty() == false) { @@ -479,8 +479,8 @@ int main(int argc, char **argv) /* Check if we have been interrupted by SIGINT */ if (pcc_active_) { - print_queue_event(event); - destroy_pcep_event(event); + print_queue_event(g_event); + destroy_pcep_event(g_event); } pcep_event_condition = false; @@ -492,9 +492,9 @@ int main(int argc, char **argv) } pcep_log(LOG_NOTICE, "%s: Disconnecting from PCE", __func__); - disconnect_pce(session); + disconnect_pce(g_session); destroy_pcep_configuration(config); - free(cmd_line_args); + free(g_cmd_line_args); if (!destroy_pcc()) { pcep_log(LOG_NOTICE, "%s: Error stopping PCC.", __func__); diff --git a/pceplib/pcep_utils_memory.c b/pceplib/pcep_utils_memory.c index c3a2ab90cd..225c058711 100644 --- a/pceplib/pcep_utils_memory.c +++ b/pceplib/pcep_utils_memory.c @@ -44,15 +44,15 @@ void *PCEPLIB_INFRA = &pceplib_infra_mt; void *PCEPLIB_MESSAGES = &pceplib_messages_mt; /* Initialize memory function pointers and memory type pointers */ -bool pceplib_memory_initialize(void *pceplib_infra_mt, - void *pceplib_messages_mt, +bool pceplib_memory_initialize(void *infra_mt, + void *messages_mt, pceplib_malloc_func mf, pceplib_calloc_func cf, pceplib_realloc_func rf, pceplib_strdup_func sf, pceplib_free_func ff) { - PCEPLIB_INFRA = (pceplib_infra_mt ? pceplib_infra_mt : PCEPLIB_INFRA); + PCEPLIB_INFRA = (infra_mt ? infra_mt : PCEPLIB_INFRA); PCEPLIB_MESSAGES = - (pceplib_messages_mt ? pceplib_messages_mt : PCEPLIB_MESSAGES); + (messages_mt ? messages_mt : PCEPLIB_MESSAGES); mfunc = (mf ? mf : mfunc); cfunc = (cf ? cf : cfunc); diff --git a/pimd/pim_mlag.c b/pimd/pim_mlag.c index dcef2d0d33..3b4e71ecf4 100644 --- a/pimd/pim_mlag.c +++ b/pimd/pim_mlag.c @@ -15,7 +15,7 @@ #include "pim_upstream.h" #include "pim_vxlan.h" -extern struct zclient *zclient; +extern struct zclient *pim_zclient; #define PIM_MLAG_METADATA_LEN 4 @@ -925,7 +925,7 @@ static void pim_mlag_register_handler(struct event *thread) { uint32_t bit_mask = 0; - if (!zclient) + if (!pim_zclient) return; SET_FLAG(bit_mask, (1 << MLAG_STATUS_UPDATE)); @@ -942,7 +942,7 @@ static void pim_mlag_register_handler(struct event *thread) zlog_debug("%s: Posting Client Register to MLAG mask: 0x%x", __func__, bit_mask); - zclient_send_mlag_register(zclient, bit_mask); + zclient_send_mlag_register(pim_zclient, bit_mask); } void pim_mlag_register(void) @@ -958,14 +958,14 @@ void pim_mlag_register(void) static void pim_mlag_deregister_handler(struct event *thread) { - if (!zclient) + if (!pim_zclient) return; if (PIM_DEBUG_MLAG) zlog_debug("%s: Posting Client De-Register to MLAG from PIM", __func__); router->connected_to_mlag = false; - zclient_send_mlag_deregister(zclient); + zclient_send_mlag_deregister(pim_zclient); } void pim_mlag_deregister(void) diff --git a/pimd/pim_nht.c b/pimd/pim_nht.c index 1e9ea24b26..d97b56e4d6 100644 --- a/pimd/pim_nht.c +++ b/pimd/pim_nht.c @@ -780,7 +780,6 @@ bool pim_nht_bsr_rpf_check(struct pim_instance *pim, pim_addr bsr_addr, */ struct pim_zlookup_nexthop nexthop_tab[router->multipath]; ifindex_t i; - struct interface *ifp = NULL; int num_ifindex; memset(nexthop_tab, 0, sizeof(nexthop_tab)); diff --git a/pimd/pim_upstream.c b/pimd/pim_upstream.c index e4603ff946..aed9d2be90 100644 --- a/pimd/pim_upstream.c +++ b/pimd/pim_upstream.c @@ -1624,8 +1624,7 @@ void pim_upstream_set_sptbit(struct pim_upstream *up, if (!starup || up->rpf.source_nexthop .interface != starup->rpf.source_nexthop.interface) { - struct pim_upstream *starup = up->parent; - + starup = up->parent; if (PIM_DEBUG_PIM_TRACE) zlog_debug( "%s: %s RPF_interface(S) != RPF_interface(RP(G))", diff --git a/pimd/pim_zebra.c b/pimd/pim_zebra.c index f0ec3c6b6e..1f7e2b255f 100644 --- a/pimd/pim_zebra.c +++ b/pimd/pim_zebra.c @@ -38,7 +38,7 @@ #undef PIM_DEBUG_IFADDR_DUMP #define PIM_DEBUG_IFADDR_DUMP -struct zclient *zclient; +struct zclient *pim_zclient; /* Router-id update message from zebra. */ @@ -349,16 +349,16 @@ static void pim_zebra_vxlan_replay(void) struct stream *s = NULL; /* Check socket. */ - if (!zclient || zclient->sock < 0) + if (!pim_zclient || pim_zclient->sock < 0) return; - s = zclient->obuf; + s = pim_zclient->obuf; stream_reset(s); zclient_create_header(s, ZEBRA_VXLAN_SG_REPLAY, VRF_DEFAULT); stream_putw_at(s, 0, stream_get_endp(s)); - zclient_send_message(zclient); + zclient_send_message(pim_zclient); } void pim_scan_oil(struct pim_instance *pim) @@ -448,14 +448,14 @@ static zclient_handler *const pim_handlers[] = { void pim_zebra_init(void) { /* Socket for receiving updates from Zebra daemon */ - zclient = zclient_new(router->master, &zclient_options_default, - pim_handlers, array_size(pim_handlers)); + pim_zclient = zclient_new(router->master, &zclient_options_default, + pim_handlers, array_size(pim_handlers)); - zclient->zebra_capabilities = pim_zebra_capabilities; - zclient->zebra_connected = pim_zebra_connected; - zclient->nexthop_update = pim_nexthop_update; + pim_zclient->zebra_capabilities = pim_zebra_capabilities; + pim_zclient->zebra_connected = pim_zebra_connected; + pim_zclient->nexthop_update = pim_nexthop_update; - zclient_init(zclient, ZEBRA_ROUTE_PIM, 0, &pimd_privs); + zclient_init(pim_zclient, ZEBRA_ROUTE_PIM, 0, &pimd_privs); if (PIM_DEBUG_PIM_TRACE) { zlog_notice("%s: zclient socket initialized", __func__); } @@ -508,8 +508,8 @@ void pim_zebra_zclient_update(struct vty *vty) { vty_out(vty, "Zclient update socket: "); - if (zclient) { - vty_out(vty, "%d failures=%d\n", zclient->sock, zclient->fail); + if (pim_zclient) { + vty_out(vty, "%d failures=%d\n", pim_zclient->sock, pim_zclient->fail); } else { vty_out(vty, "\n"); } @@ -517,8 +517,8 @@ void pim_zebra_zclient_update(struct vty *vty) struct zclient *pim_zebra_zclient_get(void) { - if (zclient) - return zclient; + if (pim_zclient) + return pim_zclient; else return NULL; } @@ -526,5 +526,5 @@ struct zclient *pim_zebra_zclient_get(void) void pim_zebra_interface_set_master(struct interface *vrf, struct interface *ifp) { - zclient_interface_set_master(zclient, vrf, ifp); + zclient_interface_set_master(pim_zclient, vrf, ifp); } diff --git a/pimd/pim_zlookup.c b/pimd/pim_zlookup.c index 4ffb5bac17..b8f73f9183 100644 --- a/pimd/pim_zlookup.c +++ b/pimd/pim_zlookup.c @@ -26,7 +26,7 @@ #include "pim_zlookup.h" #include "pim_addr.h" -static struct zclient *zlookup = NULL; +static struct zclient *pim_zlookup = NULL; struct event *zlookup_read; static void zclient_lookup_sched(struct zclient *zlookup, int delay); @@ -115,25 +115,25 @@ static void zclient_lookup_failed(struct zclient *zlookup) void zclient_lookup_free(void) { EVENT_OFF(zlookup_read); - zclient_stop(zlookup); - zclient_free(zlookup); - zlookup = NULL; + zclient_stop(pim_zlookup); + zclient_free(pim_zlookup); + pim_zlookup = NULL; } void zclient_lookup_new(void) { - zlookup = zclient_new(router->master, &zclient_options_sync, NULL, 0); - if (!zlookup) { + pim_zlookup = zclient_new(router->master, &zclient_options_sync, NULL, 0); + if (!pim_zlookup) { flog_err(EC_LIB_ZAPI_SOCKET, "%s: zclient_new() failure", __func__); return; } - zlookup->sock = -1; - zlookup->t_connect = NULL; - zlookup->privs = &pimd_privs; + pim_zlookup->sock = -1; + pim_zlookup->t_connect = NULL; + pim_zlookup->privs = &pimd_privs; - zclient_lookup_sched_now(zlookup); + zclient_lookup_sched_now(pim_zlookup); zlog_notice("%s: zclient lookup socket initialized", __func__); } @@ -328,11 +328,11 @@ static int zclient_rib_lookup(struct pim_instance *pim, struct pim_zlookup_nexth (safi == SAFI_MULTICAST ? "M" : "U")); /* Check socket. */ - if (zlookup->sock < 0) { + if (pim_zlookup->sock < 0) { flog_err(EC_LIB_ZAPI_SOCKET, "%s: zclient lookup socket is not connected", __func__); - zclient_lookup_failed(zlookup); + zclient_lookup_failed(pim_zlookup); return -1; } @@ -346,31 +346,31 @@ static int zclient_rib_lookup(struct pim_instance *pim, struct pim_zlookup_nexth ipaddr.ipa_type = PIM_IPADDR; ipaddr.ipaddr_pim = addr; - s = zlookup->obuf; + s = pim_zlookup->obuf; stream_reset(s); zclient_create_header(s, ZEBRA_NEXTHOP_LOOKUP, pim->vrf->vrf_id); stream_put_ipaddr(s, &ipaddr); stream_putc(s, safi); stream_putw_at(s, 0, stream_get_endp(s)); - ret = writen(zlookup->sock, s->data, stream_get_endp(s)); + ret = writen(pim_zlookup->sock, s->data, stream_get_endp(s)); if (ret < 0) { flog_err( EC_LIB_SOCKET, "%s: writen() failure: %d writing to zclient lookup socket", __func__, errno); - zclient_lookup_failed(zlookup); + zclient_lookup_failed(pim_zlookup); return -2; } if (ret == 0) { flog_err_sys(EC_LIB_SOCKET, "%s: connection closed on zclient lookup socket", __func__); - zclient_lookup_failed(zlookup); + zclient_lookup_failed(pim_zlookup); return -3; } - return zclient_read_nexthop(pim, zlookup, nexthop_tab, tab_size, addr); + return zclient_read_nexthop(pim, pim_zlookup, nexthop_tab, tab_size, addr); } static int zclient_lookup_nexthop_once(struct pim_instance *pim, @@ -562,8 +562,8 @@ int zclient_lookup_nexthop(struct pim_instance *pim, struct pim_zlookup_nexthop void pim_zlookup_show_ip_multicast(struct vty *vty) { vty_out(vty, "Zclient lookup socket: "); - if (zlookup) { - vty_out(vty, "%d failures=%d\n", zlookup->sock, zlookup->fail); + if (pim_zlookup) { + vty_out(vty, "%d failures=%d\n", pim_zlookup->sock, pim_zlookup->fail); } else { vty_out(vty, "\n"); } @@ -571,7 +571,7 @@ void pim_zlookup_show_ip_multicast(struct vty *vty) int pim_zlookup_sg_statistics(struct channel_oil *c_oil) { - struct stream *s = zlookup->obuf; + struct stream *s = pim_zlookup->obuf; uint16_t command = 0; unsigned long long lastused; pim_sgaddr sg; @@ -602,7 +602,7 @@ int pim_zlookup_sg_statistics(struct channel_oil *c_oil) stream_putw_at(s, 0, stream_get_endp(s)); count = stream_get_endp(s); - ret = writen(zlookup->sock, s->data, count); + ret = writen(pim_zlookup->sock, s->data, count); if (ret <= 0) { flog_err( EC_LIB_SOCKET, @@ -611,7 +611,7 @@ int pim_zlookup_sg_statistics(struct channel_oil *c_oil) return -1; } - s = zlookup->ibuf; + s = pim_zlookup->ibuf; while (command != ZEBRA_IPMR_ROUTE_STATS) { int err; @@ -621,12 +621,12 @@ int pim_zlookup_sg_statistics(struct channel_oil *c_oil) uint8_t version; stream_reset(s); - err = zclient_read_header(s, zlookup->sock, &length, &marker, + err = zclient_read_header(s, pim_zlookup->sock, &length, &marker, &version, &vrf_id, &command); if (err < 0) { flog_err(EC_LIB_ZAPI_MISSMATCH, "%s: zclient_read_header() failed", __func__); - zclient_lookup_failed(zlookup); + zclient_lookup_failed(pim_zlookup); return -1; } } @@ -642,7 +642,7 @@ int pim_zlookup_sg_statistics(struct channel_oil *c_oil) EC_LIB_ZAPI_MISSMATCH, "%s: Received wrong %pSG(%s) information requested", __func__, &more, c_oil->pim->vrf->name); - zclient_lookup_failed(zlookup); + zclient_lookup_failed(pim_zlookup); return -3; } diff --git a/pimd/pim_zpthread.c b/pimd/pim_zpthread.c index d6b2621ff4..45d8868808 100644 --- a/pimd/pim_zpthread.c +++ b/pimd/pim_zpthread.c @@ -13,7 +13,7 @@ #include "pim_mlag.h" #include "pim_zebra.h" -extern struct zclient *zclient; +extern struct zclient *pim_zclient; #define PIM_MLAG_POST_LIMIT 100 @@ -96,7 +96,7 @@ static void pim_mlag_zebra_flush_buffer(void) } } - zclient_send_mlag_data(zclient, router->mlag_stream); + zclient_send_mlag_data(pim_zclient, router->mlag_stream); stream_failure: stream_reset(router->mlag_stream); mlag_bulk_cnt = 0; diff --git a/ripd/rip_bfd.c b/ripd/rip_bfd.c index b59db11a30..a1529d1360 100644 --- a/ripd/rip_bfd.c +++ b/ripd/rip_bfd.c @@ -15,7 +15,7 @@ DEFINE_MTYPE(RIPD, RIP_BFD_PROFILE, "RIP BFD profile name"); -extern struct zclient *zclient; +extern struct zclient *ripd_zclient; static const char *rip_bfd_interface_profile(struct rip_interface *ri) { @@ -117,5 +117,5 @@ void rip_bfd_instance_update(struct rip *rip) void rip_bfd_init(struct event_loop *tm) { - bfd_protocol_integration_init(zclient, tm); + bfd_protocol_integration_init(ripd_zclient, tm); } diff --git a/ripd/rip_snmp.c b/ripd/rip_snmp.c index f6a7a82831..118b08e527 100644 --- a/ripd/rip_snmp.c +++ b/ripd/rip_snmp.c @@ -553,11 +553,11 @@ static uint8_t *rip2PeerTable(struct variable *v, oid name[], size_t *length, } /* Register RIPv2-MIB. */ -static int rip_snmp_init(struct event_loop *master) +static int rip_snmp_init(struct event_loop *mstr) { rip_ifaddr_table = route_table_init(); - smux_init(master); + smux_init(mstr); REGISTER_MIB("mibII/rip", rip_variables, variable, rip_oid); return 0; } diff --git a/ripd/rip_zebra.c b/ripd/rip_zebra.c index ce94e8e754..4ba63e50e4 100644 --- a/ripd/rip_zebra.c +++ b/ripd/rip_zebra.c @@ -21,7 +21,7 @@ #include "ripd/rip_interface.h" /* All information about zebra. */ -struct zclient *zclient = NULL; +struct zclient *ripd_zclient = NULL; /* Send ECMP routes to zebra. */ static void rip_zebra_ipv4_send(struct rip *rip, struct route_node *rp, @@ -72,7 +72,7 @@ static void rip_zebra_ipv4_send(struct rip *rip, struct route_node *rp, api.tag = rinfo->tag; } - zclient_route_send(cmd, zclient, &api); + zclient_route_send(cmd, ripd_zclient, &api); if (IS_RIP_DEBUG_ZEBRA) { if (rip->ecmp) @@ -137,14 +137,14 @@ static int rip_zebra_read_route(ZAPI_CALLBACK_ARGS) void rip_redistribute_conf_update(struct rip *rip, int type) { - zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP, + zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, ripd_zclient, AFI_IP, type, 0, rip->vrf->vrf_id); } void rip_redistribute_conf_delete(struct rip *rip, int type) { - if (zclient->sock > 0) - zebra_redistribute_send(ZEBRA_REDISTRIBUTE_DELETE, zclient, + if (ripd_zclient->sock > 0) + zebra_redistribute_send(ZEBRA_REDISTRIBUTE_DELETE, ripd_zclient, AFI_IP, type, 0, rip->vrf->vrf_id); /* Remove the routes from RIP table. */ @@ -162,7 +162,7 @@ void rip_redistribute_enable(struct rip *rip) if (!rip_redistribute_check(rip, i)) continue; - zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP, + zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, ripd_zclient, AFI_IP, i, 0, rip->vrf->vrf_id); } } @@ -173,7 +173,7 @@ void rip_redistribute_disable(struct rip *rip) if (!rip_redistribute_check(rip, i)) continue; - zebra_redistribute_send(ZEBRA_REDISTRIBUTE_DELETE, zclient, + zebra_redistribute_send(ZEBRA_REDISTRIBUTE_DELETE, ripd_zclient, AFI_IP, i, 0, rip->vrf->vrf_id); } } @@ -181,7 +181,7 @@ void rip_redistribute_disable(struct rip *rip) void rip_show_redistribute_config(struct vty *vty, struct rip *rip) { for (int i = 0; i < ZEBRA_ROUTE_MAX; i++) { - if (i == zclient->redist_default + if (i == ripd_zclient->redist_default || !rip_redistribute_check(rip, i)) continue; @@ -198,8 +198,8 @@ void rip_zebra_vrf_register(struct vrf *vrf) zlog_debug("%s: register VRF %s(%u) to zebra", __func__, vrf->name, vrf->vrf_id); - zclient_send_reg_requests(zclient, vrf->vrf_id); - bfd_client_sendmsg(zclient, ZEBRA_BFD_CLIENT_REGISTER, vrf->vrf_id); + zclient_send_reg_requests(ripd_zclient, vrf->vrf_id); + bfd_client_sendmsg(ripd_zclient, ZEBRA_BFD_CLIENT_REGISTER, vrf->vrf_id); } void rip_zebra_vrf_deregister(struct vrf *vrf) @@ -211,8 +211,8 @@ void rip_zebra_vrf_deregister(struct vrf *vrf) zlog_debug("%s: deregister VRF %s(%u) from zebra.", __func__, vrf->name, vrf->vrf_id); - zclient_send_dereg_requests(zclient, vrf->vrf_id); - bfd_client_sendmsg(zclient, ZEBRA_BFD_CLIENT_DEREGISTER, vrf->vrf_id); + zclient_send_dereg_requests(ripd_zclient, vrf->vrf_id); + bfd_client_sendmsg(ripd_zclient, ZEBRA_BFD_CLIENT_DEREGISTER, vrf->vrf_id); } static void rip_zebra_connected(struct zclient *zclient) @@ -233,18 +233,18 @@ static void rip_zebra_capabilities(struct zclient_capabilities *cap) zebra_ecmp_count = MIN(cap->ecmp, zebra_ecmp_count); } -void rip_zclient_init(struct event_loop *master) +void rip_zclient_init(struct event_loop *mst) { /* Set default value to the zebra client structure. */ - zclient = zclient_new(master, &zclient_options_default, rip_handlers, - array_size(rip_handlers)); - zclient_init(zclient, ZEBRA_ROUTE_RIP, 0, &ripd_privs); - zclient->zebra_connected = rip_zebra_connected; - zclient->zebra_capabilities = rip_zebra_capabilities; + ripd_zclient = zclient_new(mst, &zclient_options_default, rip_handlers, + array_size(rip_handlers)); + zclient_init(ripd_zclient, ZEBRA_ROUTE_RIP, 0, &ripd_privs); + ripd_zclient->zebra_connected = rip_zebra_connected; + ripd_zclient->zebra_capabilities = rip_zebra_capabilities; } void rip_zclient_stop(void) { - zclient_stop(zclient); - zclient_free(zclient); + zclient_stop(ripd_zclient); + zclient_free(ripd_zclient); } diff --git a/ripd/ripd.c b/ripd/ripd.c index 2d038507ab..c850df52ec 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -282,8 +282,14 @@ struct rip_info *rip_ecmp_replace(struct rip *rip, struct rip_info *rinfo_new) */ struct rip_info *rip_ecmp_delete(struct rip *rip, struct rip_info *rinfo) { - struct route_node *rp = rinfo->rp; - struct list *list = (struct list *)rp->info; + struct route_node *rp; + struct list *list; + + if (rinfo == NULL) + return NULL; + + rp = rinfo->rp; + list = (struct list *)rp->info; EVENT_OFF(rinfo->t_timeout); diff --git a/ripngd/ripng_zebra.c b/ripngd/ripng_zebra.c index bb5a880c02..87e275ad0d 100644 --- a/ripngd/ripng_zebra.c +++ b/ripngd/ripng_zebra.c @@ -19,7 +19,7 @@ #include "ripngd/ripng_debug.h" /* All information about zebra. */ -struct zclient *zclient = NULL; +struct zclient *ripng_zclient = NULL; /* Send ECMP routes to zebra. */ static void ripng_zebra_ipv6_send(struct ripng *ripng, struct agg_node *rp, @@ -67,7 +67,7 @@ static void ripng_zebra_ipv6_send(struct ripng *ripng, struct agg_node *rp, api.tag = rinfo->tag; } - zclient_route_send(cmd, zclient, &api); + zclient_route_send(cmd, ripng_zclient, &api); if (IS_RIPNG_DEBUG_ZEBRA) { if (ripng->ecmp) @@ -137,14 +137,14 @@ static int ripng_zebra_read_route(ZAPI_CALLBACK_ARGS) void ripng_redistribute_conf_update(struct ripng *ripng, int type) { - zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP6, + zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, ripng_zclient, AFI_IP6, type, 0, ripng->vrf->vrf_id); } void ripng_redistribute_conf_delete(struct ripng *ripng, int type) { - if (zclient->sock > 0) - zebra_redistribute_send(ZEBRA_REDISTRIBUTE_DELETE, zclient, + if (ripng_zclient->sock > 0) + zebra_redistribute_send(ZEBRA_REDISTRIBUTE_DELETE, ripng_zclient, AFI_IP6, type, 0, ripng->vrf->vrf_id); ripng_redistribute_withdraw(ripng, type); @@ -161,7 +161,7 @@ void ripng_redistribute_enable(struct ripng *ripng) if (!ripng_redistribute_check(ripng, i)) continue; - zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, zclient, + zebra_redistribute_send(ZEBRA_REDISTRIBUTE_ADD, ripng_zclient, AFI_IP6, i, 0, ripng->vrf->vrf_id); } } @@ -172,7 +172,7 @@ void ripng_redistribute_disable(struct ripng *ripng) if (!ripng_redistribute_check(ripng, i)) continue; - zebra_redistribute_send(ZEBRA_REDISTRIBUTE_DELETE, zclient, + zebra_redistribute_send(ZEBRA_REDISTRIBUTE_DELETE, ripng_zclient, AFI_IP6, i, 0, ripng->vrf->vrf_id); } } @@ -182,7 +182,7 @@ void ripng_redistribute_write(struct vty *vty, struct ripng *ripng) int i; for (i = 0; i < ZEBRA_ROUTE_MAX; i++) { - if (i == zclient->redist_default + if (i == ripng_zclient->redist_default || !ripng_redistribute_check(ripng, i)) continue; @@ -199,7 +199,7 @@ void ripng_zebra_vrf_register(struct vrf *vrf) zlog_debug("%s: register VRF %s(%u) to zebra", __func__, vrf->name, vrf->vrf_id); - zclient_send_reg_requests(zclient, vrf->vrf_id); + zclient_send_reg_requests(ripng_zclient, vrf->vrf_id); } void ripng_zebra_vrf_deregister(struct vrf *vrf) @@ -211,7 +211,7 @@ void ripng_zebra_vrf_deregister(struct vrf *vrf) zlog_debug("%s: deregister VRF %s(%u) from zebra.", __func__, vrf->name, vrf->vrf_id); - zclient_send_dereg_requests(zclient, vrf->vrf_id); + zclient_send_dereg_requests(ripng_zclient, vrf->vrf_id); } static void ripng_zebra_connected(struct zclient *zclient) @@ -232,19 +232,19 @@ static void ripng_zebra_capabilities(struct zclient_capabilities *cap) } /* Initialize zebra structure and it's commands. */ -void zebra_init(struct event_loop *master) +void zebra_init(struct event_loop *mst) { /* Allocate zebra structure. */ - zclient = zclient_new(master, &zclient_options_default, ripng_handlers, - array_size(ripng_handlers)); - zclient_init(zclient, ZEBRA_ROUTE_RIPNG, 0, &ripngd_privs); + ripng_zclient = zclient_new(mst, &zclient_options_default, ripng_handlers, + array_size(ripng_handlers)); + zclient_init(ripng_zclient, ZEBRA_ROUTE_RIPNG, 0, &ripngd_privs); - zclient->zebra_connected = ripng_zebra_connected; - zclient->zebra_capabilities = ripng_zebra_capabilities; + ripng_zclient->zebra_connected = ripng_zebra_connected; + ripng_zclient->zebra_capabilities = ripng_zebra_capabilities; } void ripng_zebra_stop(void) { - zclient_stop(zclient); - zclient_free(zclient); + zclient_stop(ripng_zclient); + zclient_free(ripng_zclient); } diff --git a/sharpd/sharp_zebra.c b/sharpd/sharp_zebra.c index 4447b69bf6..3a0877f8e8 100644 --- a/sharpd/sharp_zebra.c +++ b/sharpd/sharp_zebra.c @@ -23,7 +23,7 @@ #include "sharp_zebra.h" /* Zebra structure to hold current status. */ -struct zclient *zclient = NULL; +struct zclient *g_zclient = NULL; /* For registering threads. */ extern struct event_loop *master; @@ -34,23 +34,23 @@ extern struct zebra_privs_t sharp_privs; DEFINE_MTYPE_STATIC(SHARPD, ZC, "Test zclients"); /* Struct to hold list of test zclients */ -struct sharp_zclient { - struct sharp_zclient *prev; - struct sharp_zclient *next; +struct sharp_zclient_entry { + struct sharp_zclient_entry *prev; + struct sharp_zclient_entry *next; struct zclient *client; }; /* Head of test zclient list */ -static struct sharp_zclient *sharp_clients_head; +static struct sharp_zclient_entry *sharp_clients_head; static int sharp_opaque_handler(ZAPI_CALLBACK_ARGS); /* Utility to add a test zclient struct to the list */ static void add_zclient(struct zclient *client) { - struct sharp_zclient *node; + struct sharp_zclient_entry *node; - node = XCALLOC(MTYPE_ZC, sizeof(struct sharp_zclient)); + node = XCALLOC(MTYPE_ZC, sizeof(struct sharp_zclient_entry)); node->client = client; @@ -198,7 +198,7 @@ int sharp_install_lsps_helper(bool install_p, bool update_p, cmd = ZEBRA_MPLS_LABELS_DELETE; } - if (zebra_send_mpls_labels(zclient, cmd, &zl) == ZCLIENT_SEND_FAILURE) + if (zebra_send_mpls_labels(g_zclient, cmd, &zl) == ZCLIENT_SEND_FAILURE) return -1; return 0; @@ -291,7 +291,7 @@ static bool route_add(const struct prefix *p, vrf_id_t vrf_id, uint8_t instance, memcpy(api.opaque.data, opaque, api.opaque.length); } - if (zclient_route_send(ZEBRA_ROUTE_ADD, zclient, &api) == + if (zclient_route_send(ZEBRA_ROUTE_ADD, g_zclient, &api) == ZCLIENT_SEND_BUFFERED) return true; else @@ -315,7 +315,7 @@ static bool route_delete(struct prefix *p, vrf_id_t vrf_id, uint8_t instance) api.instance = instance; memcpy(&api.prefix, p, sizeof(*p)); - if (zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api) == + if (zclient_route_send(ZEBRA_ROUTE_DELETE, g_zclient, &api) == ZCLIENT_SEND_BUFFERED) return true; else @@ -471,7 +471,7 @@ static int route_notify_owner(ZAPI_CALLBACK_ARGS) enum zapi_route_notify_owner note; uint32_t table; - if (!zapi_route_notify_decode(zclient->ibuf, &p, &table, ¬e, NULL, + if (!zapi_route_notify_decode(g_zclient->ibuf, &p, &table, ¬e, NULL, NULL)) return -1; @@ -526,7 +526,7 @@ static void zebra_connected(struct zclient *zclient) void vrf_label_add(vrf_id_t vrf_id, afi_t afi, mpls_label_t label) { - zclient_send_vrf_label(zclient, vrf_id, afi, label, ZEBRA_LSP_SHARP); + zclient_send_vrf_label(g_zclient, vrf_id, afi, label, ZEBRA_LSP_SHARP); } void nhg_add(uint32_t id, const struct nexthop_group *nhg, @@ -565,7 +565,7 @@ void nhg_add(uint32_t id, const struct nexthop_group *nhg, if (sharp_nhgroup_id_is_installed(id)) { zlog_debug("%s: nhg %u: no nexthops, deleting nexthop group", __func__, id); - zclient_nhg_send(zclient, ZEBRA_NHG_DEL, &api_nhg); + zclient_nhg_send(g_zclient, ZEBRA_NHG_DEL, &api_nhg); return; } zlog_debug("%s: nhg %u not sent: no valid nexthops", __func__, @@ -606,7 +606,7 @@ void nhg_add(uint32_t id, const struct nexthop_group *nhg, done: if (is_valid) - zclient_nhg_send(zclient, ZEBRA_NHG_ADD, &api_nhg); + zclient_nhg_send(g_zclient, ZEBRA_NHG_ADD, &api_nhg); } void nhg_del(uint32_t id) @@ -615,7 +615,7 @@ void nhg_del(uint32_t id) api_nhg.id = id; - zclient_nhg_send(zclient, ZEBRA_NHG_DEL, &api_nhg); + zclient_nhg_send(g_zclient, ZEBRA_NHG_DEL, &api_nhg); } void sharp_zebra_nexthop_watch(struct prefix *p, vrf_id_t vrf_id, bool import, bool watch, @@ -629,7 +629,7 @@ void sharp_zebra_nexthop_watch(struct prefix *p, vrf_id_t vrf_id, bool import, b if (!watch) command = ZEBRA_NEXTHOP_UNREGISTER; - if (zclient_send_rnh(zclient, command, p, safi, connected, false, vrf_id) == + if (zclient_send_rnh(g_zclient, command, p, safi, connected, false, vrf_id) == ZCLIENT_SEND_FAILURE) zlog_warn("%s: Failure to send nexthop to zebra", __func__); } @@ -709,7 +709,7 @@ void sharp_redistribute_vrf(struct vrf *vrf, int type, bool turn_on) { zebra_redistribute_send(turn_on ? ZEBRA_REDISTRIBUTE_ADD : ZEBRA_REDISTRIBUTE_DELETE, - zclient, AFI_IP, type, 0, vrf->vrf_id); + g_zclient, AFI_IP, type, 0, vrf->vrf_id); } static zclient_handler *const sharp_opaque_handlers[] = { @@ -720,7 +720,7 @@ static zclient_handler *const sharp_opaque_handlers[] = { int sharp_zclient_create(uint32_t session_id) { struct zclient *client; - struct sharp_zclient *node; + struct sharp_zclient_entry *node; /* Check for duplicates */ for (node = sharp_clients_head; node != NULL; node = node->next) { @@ -745,7 +745,7 @@ int sharp_zclient_create(uint32_t session_id) /* Delete one of the extra test zclients */ int sharp_zclient_delete(uint32_t session_id) { - struct sharp_zclient *node; + struct sharp_zclient_entry *node; /* Search for session */ for (node = sharp_clients_head; node != NULL; node = node->next) { @@ -848,10 +848,10 @@ void sharp_opaque_send(uint32_t type, uint32_t proto, uint32_t instance, /* Send some messages - broadcast and unicast are supported */ for (i = 0; i < count; i++) { if (proto == 0) - ret = zclient_send_opaque(zclient, type, buf, + ret = zclient_send_opaque(g_zclient, type, buf, sizeof(buf)); else - ret = zclient_send_opaque_unicast(zclient, type, proto, + ret = zclient_send_opaque_unicast(g_zclient, type, proto, instance, session_id, buf, sizeof(buf)); if (ret == ZCLIENT_SEND_FAILURE) { @@ -868,9 +868,9 @@ void sharp_opaque_send(uint32_t type, uint32_t proto, uint32_t instance, void sharp_zebra_opaque_notif_reg(bool is_reg, uint32_t type) { if (is_reg) - zclient_opaque_request_notify(zclient, type); + zclient_opaque_request_notify(g_zclient, type); else - zclient_opaque_drop_notify(zclient, type); + zclient_opaque_drop_notify(g_zclient, type); } /* @@ -881,7 +881,7 @@ void sharp_opaque_reg_send(bool is_reg, uint32_t proto, uint32_t instance, { struct stream *s; - s = zclient->obuf; + s = g_zclient->obuf; stream_reset(s); if (is_reg) @@ -900,22 +900,22 @@ void sharp_opaque_reg_send(bool is_reg, uint32_t proto, uint32_t instance, /* Put length at the first point of the stream. */ stream_putw_at(s, 0, stream_get_endp(s)); - (void)zclient_send_message(zclient); + (void)zclient_send_message(g_zclient); } /* Link State registration */ void sharp_zebra_register_te(void) { /* First register to received Link State Update messages */ - zclient_register_opaque(zclient, LINK_STATE_UPDATE); + zclient_register_opaque(g_zclient, LINK_STATE_UPDATE); /* Then, request initial TED with SYNC message */ - ls_request_sync(zclient); + ls_request_sync(g_zclient); } void sharp_zebra_send_arp(const struct interface *ifp, const struct prefix *p) { - zclient_send_neigh_discovery_req(zclient, ifp, p); + zclient_send_neigh_discovery_req(g_zclient, ifp, p); } static int nhg_notify_owner(ZAPI_CALLBACK_ARGS) @@ -948,12 +948,12 @@ static int nhg_notify_owner(ZAPI_CALLBACK_ARGS) int sharp_zebra_srv6_manager_get_locator_chunk(const char *locator_name) { - return srv6_manager_get_locator_chunk(zclient, locator_name); + return srv6_manager_get_locator_chunk(g_zclient, locator_name); } int sharp_zebra_srv6_manager_release_locator_chunk(const char *locator_name) { - return srv6_manager_release_locator_chunk(zclient, locator_name); + return srv6_manager_release_locator_chunk(g_zclient, locator_name); } static int sharp_zebra_process_srv6_locator_chunk(ZAPI_CALLBACK_ARGS) @@ -1031,7 +1031,7 @@ int sharp_zebra_send_interface_protodown(struct interface *ifp, bool down) zlog_debug("Sending zebra to set %s protodown %s", ifp->name, down ? "on" : "off"); - if (zclient_send_interface_protodown(zclient, ifp->vrf->vrf_id, ifp, + if (zclient_send_interface_protodown(g_zclient, ifp->vrf->vrf_id, ifp, down) == ZCLIENT_SEND_FAILURE) return -1; @@ -1047,12 +1047,12 @@ int sharp_zebra_send_tc_filter_rate(struct interface *ifp, #define SHARPD_TC_HANDLE 0x0001 struct stream *s; - s = zclient->obuf; + s = g_zclient->obuf; struct tc_qdisc q = {.ifindex = ifp->ifindex, .kind = TC_QDISC_HTB}; zapi_tc_qdisc_encode(ZEBRA_TC_QDISC_INSTALL, s, &q); - if (zclient_send_message(zclient) == ZCLIENT_SEND_FAILURE) + if (zclient_send_message(g_zclient) == ZCLIENT_SEND_FAILURE) return -1; struct tc_class c = {.ifindex = ifp->ifindex, @@ -1062,7 +1062,7 @@ int sharp_zebra_send_tc_filter_rate(struct interface *ifp, .u.htb.rate = rate}; zapi_tc_class_encode(ZEBRA_TC_CLASS_ADD, s, &c); - if (zclient_send_message(zclient) == ZCLIENT_SEND_FAILURE) + if (zclient_send_message(g_zclient) == ZCLIENT_SEND_FAILURE) return -1; struct tc_filter f = {.ifindex = ifp->ifindex, @@ -1090,7 +1090,7 @@ int sharp_zebra_send_tc_filter_rate(struct interface *ifp, f.u.flower.classid = SHARPD_TC_HANDLE & 0xffff; zapi_tc_filter_encode(ZEBRA_TC_FILTER_ADD, s, &f); - if (zclient_send_message(zclient) == ZCLIENT_SEND_FAILURE) + if (zclient_send_message(g_zclient) == ZCLIENT_SEND_FAILURE) return -1; return 0; @@ -1098,7 +1098,7 @@ int sharp_zebra_send_tc_filter_rate(struct interface *ifp, void sharp_zebra_register_neigh(vrf_id_t vrf_id, afi_t afi, bool reg) { - zclient_register_neigh(zclient, vrf_id, afi, reg); + zclient_register_neigh(g_zclient, vrf_id, afi, reg); } @@ -1124,18 +1124,18 @@ void sharp_zebra_init(void) hook_register_prio(if_down, 0, sharp_ifp_down); hook_register_prio(if_unreal, 0, sharp_ifp_destroy); - zclient = zclient_new(master, &zclient_options_default, sharp_handlers, - array_size(sharp_handlers)); + g_zclient = zclient_new(master, &zclient_options_default, sharp_handlers, + array_size(sharp_handlers)); - zclient_init(zclient, ZEBRA_ROUTE_SHARP, 0, &sharp_privs); - zclient->zebra_connected = zebra_connected; - zclient->zebra_buffer_write_ready = sharp_zclient_buffer_ready; - zclient->nexthop_update = sharp_nexthop_update; + zclient_init(g_zclient, ZEBRA_ROUTE_SHARP, 0, &sharp_privs); + g_zclient->zebra_connected = zebra_connected; + g_zclient->zebra_buffer_write_ready = sharp_zclient_buffer_ready; + g_zclient->nexthop_update = sharp_nexthop_update; } void sharp_zebra_terminate(void) { - struct sharp_zclient *node = sharp_clients_head; + struct sharp_zclient_entry *node = sharp_clients_head; while (node) { sharp_zclient_delete(node->client->session_id); @@ -1143,6 +1143,6 @@ void sharp_zebra_terminate(void) node = sharp_clients_head; } - zclient_stop(zclient); - zclient_free(zclient); + zclient_stop(g_zclient); + zclient_free(g_zclient); } diff --git a/staticd/static_zebra.c b/staticd/static_zebra.c index e3b646a392..714f4b89ea 100644 --- a/staticd/static_zebra.c +++ b/staticd/static_zebra.c @@ -75,7 +75,7 @@ DECLARE_HASH(static_nht_hash, struct static_nht_data, itm, static_nht_data_cmp, static struct static_nht_hash_head static_nht_hash[1]; /* Zebra structure to hold current status. */ -struct zclient *zclient; +struct zclient *static_zclient; uint32_t zebra_ecmp_count = MULTIPATH_NUM; /* Interface addition message from zebra. */ @@ -211,7 +211,7 @@ static void static_zebra_nexthop_update(struct vrf *vrf, struct prefix *matched, struct static_nht_data *nhtd, lookup; afi_t afi = AFI_IP; - if (zclient->bfd_integration) + if (static_zclient->bfd_integration) bfd_nht_update(matched, nhr); if (matched->family == AF_INET6) @@ -395,7 +395,7 @@ void static_zebra_nht_register(struct static_nexthop *nh, bool reg) "Unregistering nexthop(%pFX) for %pRN", &lookup.nh, rn); } - if (zclient_send_rnh(zclient, cmd, &lookup.nh, si->safi, false, false, + if (zclient_send_rnh(static_zclient, cmd, &lookup.nh, si->safi, false, false, nh->nh_vrf_id) == ZCLIENT_SEND_FAILURE) zlog_warn("%s: Failure to send nexthop %pFX for %pRN to zebra", __func__, &lookup.nh, rn); @@ -549,7 +549,7 @@ extern void static_zebra_route_add(struct static_path *pn, bool install) zclient_route_send(install ? ZEBRA_ROUTE_ADD : ZEBRA_ROUTE_DELETE, - zclient, &api); + static_zclient, &api); } /** @@ -594,7 +594,7 @@ static void static_zebra_send_localsid(int cmd, const struct in6_addr *sid, uint memcpy(&api.prefix, &p, sizeof(p)); if (cmd == ZEBRA_ROUTE_DELETE) - return (void)zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api); + return (void)zclient_route_send(ZEBRA_ROUTE_DELETE, static_zclient, &api); SET_FLAG(api.flags, ZEBRA_FLAG_ALLOW_RECURSION); SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP); @@ -611,7 +611,7 @@ static void static_zebra_send_localsid(int cmd, const struct in6_addr *sid, uint api.nexthop_num = 1; - zclient_route_send(ZEBRA_ROUTE_ADD, zclient, &api); + zclient_route_send(ZEBRA_ROUTE_ADD, static_zclient, &api); } /** @@ -1004,7 +1004,8 @@ extern void static_zebra_request_srv6_sid(struct static_srv6_sid *sid) } /* Request SRv6 SID from SID Manager */ - ret = srv6_manager_get_sid(zclient, &ctx, &sid->addr.prefix, sid->locator->name, NULL); + ret = srv6_manager_get_sid(static_zclient, &ctx, &sid->addr.prefix, sid->locator->name, + NULL); if (ret < 0) zlog_warn("%s: error getting SRv6 SID!", __func__); } @@ -1091,7 +1092,7 @@ extern void static_zebra_release_srv6_sid(struct static_srv6_sid *sid) } /* remove the SRv6 SID from the zebra RIB */ - ret = srv6_manager_release_sid(zclient, &ctx); + ret = srv6_manager_release_sid(static_zclient, &ctx); if (ret == ZCLIENT_SEND_FAILURE) flog_err(EC_LIB_ZAPI_SOCKET, "zclient_send_get_srv6_sid() delete failed: %s", safe_strerror(errno)); @@ -1112,7 +1113,7 @@ int static_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(static_zclient, name); } static void request_srv6_sids(struct static_srv6_locator *locator) @@ -1367,16 +1368,16 @@ void static_zebra_init(void) hook_register_prio(if_down, 0, static_ifp_down); hook_register_prio(if_unreal, 0, static_ifp_destroy); - zclient = zclient_new(master, &zclient_options_default, static_handlers, - array_size(static_handlers)); + static_zclient = zclient_new(master, &zclient_options_default, static_handlers, + array_size(static_handlers)); - zclient_init(zclient, ZEBRA_ROUTE_STATIC, 0, &static_privs); - zclient->zebra_capabilities = static_zebra_capabilities; - zclient->zebra_connected = zebra_connected; - zclient->nexthop_update = static_zebra_nexthop_update; + zclient_init(static_zclient, ZEBRA_ROUTE_STATIC, 0, &static_privs); + static_zclient->zebra_capabilities = static_zebra_capabilities; + static_zclient->zebra_connected = zebra_connected; + static_zclient->nexthop_update = static_zebra_nexthop_update; static_nht_hash_init(static_nht_hash); - static_bfd_initialize(zclient, master); + static_bfd_initialize(static_zclient, master); } /* static_zebra_stop used by tests/lib/test_grpc.cpp */ @@ -1385,23 +1386,23 @@ void static_zebra_stop(void) static_nht_hash_clear(); static_nht_hash_fini(static_nht_hash); - if (!zclient) + if (!static_zclient) return; - zclient_stop(zclient); - zclient_free(zclient); - zclient = NULL; + zclient_stop(static_zclient); + zclient_free(static_zclient); + static_zclient = NULL; } void static_zebra_vrf_register(struct vrf *vrf) { if (vrf->vrf_id == VRF_DEFAULT) return; - zclient_send_reg_requests(zclient, vrf->vrf_id); + zclient_send_reg_requests(static_zclient, vrf->vrf_id); } void static_zebra_vrf_unregister(struct vrf *vrf) { if (vrf->vrf_id == VRF_DEFAULT) return; - zclient_send_dereg_requests(zclient, vrf->vrf_id); + zclient_send_dereg_requests(static_zclient, vrf->vrf_id); } diff --git a/tests/isisd/test_common.c b/tests/isisd/test_common.c index e47456965e..e22ee21365 100644 --- a/tests/isisd/test_common.c +++ b/tests/isisd/test_common.c @@ -33,11 +33,11 @@ test_topology_find_node(const struct isis_topology *topology, } const struct isis_topology * -test_topology_find(struct isis_topology *test_topologies, uint16_t number) +test_topology_find(struct isis_topology *topologies, uint16_t number) { - for (size_t i = 0; test_topologies[i].number; i++) - if (test_topologies[i].number == number) - return &test_topologies[i]; + for (size_t i = 0; topologies[i].number; i++) + if (topologies[i].number == number) + return &topologies[i]; return NULL; } diff --git a/tests/isisd/test_fuzz_isis_tlv.c b/tests/isisd/test_fuzz_isis_tlv.c index 48a2caacce..2a8a5bc5d7 100644 --- a/tests/isisd/test_fuzz_isis_tlv.c +++ b/tests/isisd/test_fuzz_isis_tlv.c @@ -161,7 +161,7 @@ static int test(FILE *input, FILE *output) struct listnode *node; for (ALL_LIST_ELEMENTS_RO(fragments, node, tlvs)) { stream_reset(s); - int rv = isis_pack_tlvs(tlvs, s, (size_t)-1, false, false); + rv = isis_pack_tlvs(tlvs, s, (size_t)-1, false, false); if (rv) { fprintf(output, "Could not pack fragment, too large.\n"); assert(0); diff --git a/tests/lib/test_darr.c b/tests/lib/test_darr.c index be319db1c1..d980db505d 100644 --- a/tests/lib/test_darr.c +++ b/tests/lib/test_darr.c @@ -157,12 +157,17 @@ static void test_int(void) assert(!memcmp(da2, a1, sizeof(a1))); - assert(darr_pop(da2) == 4); - assert(darr_pop(da2) == 3); - assert(darr_pop(da2) == 2); + i = darr_pop(da2); + assert(i == 4); + i = darr_pop(da2); + assert(i == 3); + i = darr_pop(da2); + assert(i == 2); assert(darr_len(da2) == 2); - assert(darr_pop(da2) == 1); - assert(darr_pop(da2) == 0); + i = darr_pop(da2); + assert(i == 1); + i = darr_pop(da2); + assert(i == 0); assert(darr_len(da2) == 0); darr_free(da2); @@ -323,38 +328,47 @@ static void test_string(void) char *da2 = NULL; const char **strings = NULL; uint sum = 0; + uint i; - assert(darr_strlen(da1) == 0); + i = darr_strlen(da1); + assert(i == 0); da1 = darr_strdup(src); - assert(darr_strlen(da1) == strlen(da1)); - assert(darr_strlen(da1) == srclen); + i = darr_strlen(da1); + assert(i == strlen(da1)); + i = darr_strlen(da1); + assert(i == srclen); assert(darr_len(da1) == srclen + 1); assert(darr_ilen(da1) == (int)srclen + 1); assert(darr_cap(da1) >= 8); assert(darr_last(da1) == darr_strnul(da1)); - assert(darr_strnul(da1) == da1 + darr_strlen(da1)); + i = darr_strlen(da1); + assert(darr_strnul(da1) == da1 + i); da2 = da1; darr_in_strdup(da1, src); assert(da1 == da2); - assert(darr_strlen(da1) == strlen(da1)); - assert(darr_strlen(da1) == srclen); + i = darr_strlen(da1); + assert(i == strlen(da1)); + assert(i == srclen); assert(darr_len(da1) == srclen + 1); darr_free(da1); assert(da1 == NULL); da1 = darr_strdup_cap(src, 128); - assert(darr_strlen(da1) == srclen); + i = darr_strlen(da1); + assert(i == srclen); assert(darr_cap(da1) >= 128); darr_in_strdup_cap(da1, src, 256); - assert(darr_strlen(da1) == srclen); + i = darr_strlen(da1); + assert(i == srclen); assert(darr_cap(da1) >= 256); darr_free(da1); da1 = darr_strdup_cap(add, 2); - assert(darr_strlen(da1) == addlen); + i = darr_strlen(da1); + assert(i == addlen); assert(darr_cap(da1) >= 8); darr_in_strdup(da1, "ab"); @@ -377,7 +391,8 @@ static void test_string(void) da2 = darr_strdup(add); darr_in_strcat_tail(da1, da2); assert(!strcmp("abHIJ", da1)); - assert(darr_strlen(da1) == 5); + i = darr_strlen(da1); + assert(i == 5); assert(darr_len(da1) == 6); darr_free(da1); darr_free(da2); @@ -386,14 +401,16 @@ static void test_string(void) da2 = darr_strdup(add); darr_in_strcat_tail(da1, da2); assert(!strcmp("abcde", da1)); - assert(darr_strlen(da1) == 5); + i = darr_strlen(da1); + assert(i == 5); assert(darr_len(da1) == 6); darr_free(da1); darr_free(da2); da1 = darr_sprintf("0123456789: %08X", 0xDEADBEEF); assert(!strcmp(da1, "0123456789: DEADBEEF")); - assert(darr_strlen(da1) == 20); + i = darr_strlen(da1); + assert(i == 20); assert(darr_cap(da1) == 128); da2 = da1; darr_in_sprintf(da1, "9876543210: %08x", 0x0BADF00D); @@ -405,11 +422,13 @@ static void test_string(void) da1 = NULL; darr_in_sprintf(da1, "0123456789: %08X", 0xDEADBEEF); assert(!strcmp(da1, "0123456789: DEADBEEF")); - assert(darr_strlen(da1) == 20); + i = darr_strlen(da1); + assert(i == 20); assert(darr_cap(da1) == 128); da1[5] = 0; - assert(darr_strlen_fixup(da1) == 5); + i = darr_strlen_fixup(da1); + assert(i == 5); darr_free(da1); da1 = darr_sprintf("0123456789: %08x", 0xDEADBEEF); diff --git a/tests/lib/test_printfrr.c b/tests/lib/test_printfrr.c index a81ebcdbcd..c915587c13 100644 --- a/tests/lib/test_printfrr.c +++ b/tests/lib/test_printfrr.c @@ -107,7 +107,7 @@ static int printchk(const char *ref, const char *fmt, ...) errors++; } - for (size_t i = 0; i < fb.outpos_i; i++) + for (i = 0; i < fb.outpos_i; i++) printf("\t[%zu: %u..%u] = \"%.*s\"\n", i, outpos[i].off_start, outpos[i].off_end, diff --git a/tools/start-stop-daemon.c b/tools/start-stop-daemon.c index 4406a68f61..5d6cf01936 100644 --- a/tools/start-stop-daemon.c +++ b/tools/start-stop-daemon.c @@ -73,14 +73,14 @@ size_t strlcpy(char *__restrict dest, #endif static int testmode = 0; -static int quietmode = 0; +static int g_quietmode = 0; static int exitnodo = 1; static int start = 0; static int stop = 0; static int background = 0; static int mpidfile = 0; -static int signal_nr = 15; -static const char *signal_str = NULL; +static int g_signal_nr = 15; +static const char *g_signal_str = NULL; static int user_id = -1; static int runas_uid = -1; static int runas_gid = -1; @@ -93,7 +93,7 @@ static char *execname = NULL; static char *startas = NULL; static const char *pidfile = NULL; static char what_stop[1024]; -static const char *schedule_str = NULL; +static const char *g_schedule_str = NULL; static const char *progname = ""; static int nicelevel = 0; @@ -438,7 +438,7 @@ static void parse_schedule(const char *schedule_str) if (count == 0) { schedule[0].type = sched_signal; - schedule[0].value = signal_nr; + schedule[0].value = g_signal_nr; parse_schedule_item(schedule_str, &schedule[1]); if (schedule[1].type != sched_timeout) { badusage( @@ -528,10 +528,10 @@ static void parse_options(int argc, char *const *argv) pidfile = optarg; break; case 'q': /* --quiet */ - quietmode = 1; + g_quietmode = 1; break; case 's': /* --signal */ - signal_str = optarg; + g_signal_str = optarg; break; case 't': /* --test */ testmode = 1; @@ -540,7 +540,7 @@ static void parse_options(int argc, char *const *argv) userspec = optarg; break; case 'v': /* --verbose */ - quietmode = -1; + g_quietmode = -1; break; case 'x': /* --exec */ execname = optarg; @@ -567,21 +567,21 @@ static void parse_options(int argc, char *const *argv) mpidfile = 1; break; case 'R': /* --retry | */ - schedule_str = optarg; + g_schedule_str = optarg; break; default: badusage(NULL); /* message printed by getopt */ } } - if (signal_str != NULL) { - if (parse_signal(signal_str, &signal_nr) != 0) + if (g_signal_str != NULL) { + if (parse_signal(g_signal_str, &g_signal_nr) != 0) badusage( "signal value must be numeric or name of signal (KILL, INTR, ...)"); } - if (schedule_str != NULL) { - parse_schedule(schedule_str); + if (g_schedule_str != NULL) { + parse_schedule(g_schedule_str); } if (start == stop) @@ -787,8 +787,8 @@ static int run_stop_schedule(void) n_killed = 0; if (schedule == NULL) { - do_stop(signal_nr, quietmode, &n_killed, &n_notkilled, 0); - if (n_notkilled > 0 && quietmode <= 0) + do_stop(g_signal_nr, g_quietmode, &n_killed, &n_notkilled, 0); + if (n_notkilled > 0 && g_quietmode <= 0) printf("%d pids were not killed\n", n_notkilled); if (n_killed) anykilled = 1; @@ -806,7 +806,7 @@ static int run_stop_schedule(void) continue; case sched_signal: - do_stop(value, quietmode, &n_killed, &n_notkilled, + do_stop(value, g_quietmode, &n_killed, &n_notkilled, retry_nr++); if (!n_killed) goto x_finished; @@ -899,7 +899,7 @@ static int run_stop_schedule(void) position++; } - if (quietmode <= 0) + if (g_quietmode <= 0) printf("Program %s, %d process(es), refused to die.\n", what_stop, n_killed); @@ -907,7 +907,7 @@ static int run_stop_schedule(void) x_finished: if (!anykilled) { - if (quietmode <= 0) + if (g_quietmode <= 0) printf("No %s found running; none killed.\n", what_stop); return exitnodo; @@ -969,7 +969,7 @@ int main(int argc, char **argv) do_findprocs(); if (found) { - if (quietmode <= 0) + if (g_quietmode <= 0) printf("%s already running.\n", execname); exit(exitnodo); } @@ -992,7 +992,7 @@ int main(int argc, char **argv) printf(".\n"); exit(0); } - if (quietmode < 0) + if (g_quietmode < 0) printf("Starting %s...\n", startas); *--argv = startas; if (changeroot != NULL) { @@ -1013,14 +1013,14 @@ int main(int argc, char **argv) if (background) { /* ok, we need to detach this process */ int i, fd; - if (quietmode < 0) + if (g_quietmode < 0) printf("Detaching to start %s...", startas); i = fork(); if (i < 0) { fatal("Unable to fork.\n"); } if (i) { /* parent */ - if (quietmode < 0) + if (g_quietmode < 0) printf("done.\n"); exit(0); } diff --git a/vrrpd/vrrp_zebra.c b/vrrpd/vrrp_zebra.c index 009432b217..6b4b3104ea 100644 --- a/vrrpd/vrrp_zebra.c +++ b/vrrpd/vrrp_zebra.c @@ -19,7 +19,7 @@ #define VRRP_LOGPFX "[ZEBRA] " -static struct zclient *zclient; +static struct zclient *vrrp_zclient; static void vrrp_zebra_debug_if_state(struct interface *ifp, const char *func) { @@ -161,7 +161,7 @@ void vrrp_zebra_radv_set(struct vrrp_router *r, bool enable) "Requesting Zebra to turn router advertisements %s for %s", r->vr->vrid, enable ? "on" : "off", r->mvl_ifp->name); - zclient_send_interface_radv_req(zclient, r->mvl_ifp->vrf->vrf_id, + zclient_send_interface_radv_req(vrrp_zclient, r->mvl_ifp->vrf->vrf_id, r->mvl_ifp, enable, VRRP_RADV_INT); } @@ -171,7 +171,7 @@ void vrrp_zclient_send_interface_protodown(struct interface *ifp, bool down) VRRP_LOGPFX "Requesting Zebra to set %s protodown %s", ifp->name, down ? "on" : "off"); - zclient_send_interface_protodown(zclient, ifp->vrf->vrf_id, ifp, down); + zclient_send_interface_protodown(vrrp_zclient, ifp->vrf->vrf_id, ifp, down); } static zclient_handler *const vrrp_handlers[] = { @@ -188,12 +188,12 @@ void vrrp_zebra_init(void) hook_register_prio(if_unreal, 0, vrrp_ifp_destroy); /* Socket for receiving updates from Zebra daemon */ - zclient = zclient_new(master, &zclient_options_default, vrrp_handlers, - array_size(vrrp_handlers)); + vrrp_zclient = zclient_new(master, &zclient_options_default, vrrp_handlers, + array_size(vrrp_handlers)); - zclient->zebra_connected = vrrp_zebra_connected; + vrrp_zclient->zebra_connected = vrrp_zebra_connected; - zclient_init(zclient, ZEBRA_ROUTE_VRRP, 0, &vrrp_privs); + zclient_init(vrrp_zclient, ZEBRA_ROUTE_VRRP, 0, &vrrp_privs); zlog_notice("%s: zclient socket initialized", __func__); } diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index 31e7ce12ba..fba39526c6 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -44,7 +44,7 @@ DEFINE_MTYPE_STATIC(MVTYSH, VTYSH_CMD, "Vtysh cmd copy"); /* Struct VTY. */ -struct vty *vty; +struct vty *gvty; /* VTY shell pager name. */ char *vtysh_pager_name = NULL; @@ -161,8 +161,8 @@ static int vtysh_reconnect(struct vtysh_client *vclient); static void vclient_close(struct vtysh_client *vclient) { if (vclient->fd >= 0) { - if (vty->of) - vty_out(vty, + if (gvty->of) + vty_out(gvty, "Warning: closing connection to %s because of an I/O error!\n", vclient->name); close(vclient->fd); @@ -282,8 +282,8 @@ static int vtysh_client_run(struct vtysh_client *vclient, const char *line, vclient, bufvalid, buf + bufsz - bufvalid - 1, pass_fd); if (nread <= 0) { - if (vty->of) - vty_out(vty, + if (gvty->of) + vty_out(gvty, "vtysh: error reading from %s: %s (%d)", vclient->name, safe_strerror(errno), errno); @@ -357,8 +357,8 @@ static int vtysh_client_run(struct vtysh_client *vclient, const char *line, /* eol is at line end now, either \n => \0 or \0\0\0 */ assert(eol && eol <= bufvalid); - if (vty->of) - vty_out(vty, "%s\n", buf); + if (gvty->of) + vty_out(gvty, "%s\n", buf); callback(cbarg, buf); @@ -371,8 +371,8 @@ static int vtysh_client_run(struct vtysh_client *vclient, const char *line, /* else if no callback, dump raw */ if (!callback) { - if (vty->of) - vty_out(vty, "%s", buf); + if (gvty->of) + vty_out(gvty, "%s", buf); memmove(buf, buf + textlen, bufvalid - buf - textlen); bufvalid -= textlen; if (end) @@ -431,8 +431,8 @@ static int vtysh_client_run_all(struct vtysh_client *head_client, rc_all = rc; } } - if (wrong_instance && !correct_instance && vty->of) { - vty_out(vty, + if (wrong_instance && !correct_instance && gvty->of) { + vty_out(gvty, "%% [%s]: command ignored as it targets an instance that is not running\n", head_client->name); rc_all = CMD_WARNING_CONFIG_FAILED; @@ -468,7 +468,7 @@ static int vtysh_client_execute_name(const char *name, const char *line) if (idx_client != -1) ret = vtysh_client_execute(&vtysh_client[idx_client], line); else { - vty_out(vty, "Client not found\n"); + vty_out(gvty, "Client not found\n"); ret = CMD_WARNING; } @@ -495,11 +495,11 @@ static void vtysh_client_config(struct vtysh_client *head_client, char *line) return; /* suppress output to user */ - vty->of_saved = vty->of; - vty->of = NULL; + gvty->of_saved = gvty->of; + gvty->of = NULL; vtysh_client_run_all(head_client, line, 1, vtysh_config_parse_line, NULL); - vty->of = vty->of_saved; + gvty->of = gvty->of_saved; } /* Command execution over the vty interface. */ @@ -522,11 +522,11 @@ static int vtysh_execute_func(const char *line, int pager) char ts[48]; (void)frr_timestamp(3, ts, sizeof(ts)); - vty_out(vty, "%% %s\n\n", ts); + vty_out(gvty, "%% %s\n\n", ts); } - saved_ret = ret = cmd_execute(vty, line, &cmd, 1); - saved_node = vty->node; + saved_ret = ret = cmd_execute(gvty, line, &cmd, 1); + saved_node = gvty->node; /* * If command doesn't succeeded in current node, try to walk up in node @@ -536,13 +536,13 @@ static int vtysh_execute_func(const char *line, int pager) while (ret != CMD_SUCCESS && ret != CMD_SUCCESS_DAEMON && ret != CMD_WARNING && ret != CMD_WARNING_CONFIG_FAILED && ret != CMD_ERR_AMBIGUOUS && ret != CMD_ERR_INCOMPLETE - && vty->node > CONFIG_NODE) { - vty->node = node_parent(vty->node); - ret = cmd_execute(vty, line, &cmd, 1); + && gvty->node > CONFIG_NODE) { + gvty->node = node_parent(gvty->node); + ret = cmd_execute(gvty, line, &cmd, 1); tried++; } - vty->node = saved_node; + gvty->node = saved_node; /* * If command succeeded in any other node than current (tried > 0) we @@ -567,17 +567,17 @@ static int vtysh_execute_func(const char *line, int pager) switch (ret) { case CMD_WARNING: case CMD_WARNING_CONFIG_FAILED: - if (vty->type == VTY_FILE) - vty_out(vty, "Warning...\n"); + if (gvty->type == VTY_FILE) + vty_out(gvty, "Warning...\n"); break; case CMD_ERR_AMBIGUOUS: - vty_out(vty, "%% Ambiguous command: %s\n", line); + vty_out(gvty, "%% Ambiguous command: %s\n", line); break; case CMD_ERR_NO_MATCH: - vty_out(vty, "%% Unknown command: %s\n", line); + vty_out(gvty, "%% Unknown command: %s\n", line); break; case CMD_ERR_INCOMPLETE: - vty_out(vty, "%% Command incomplete: %s\n", line); + vty_out(gvty, "%% Command incomplete: %s\n", line); break; case CMD_SUCCESS_DAEMON: { /* @@ -586,7 +586,7 @@ static int vtysh_execute_func(const char *line, int pager) * cause any problem but is really ugly. */ if (pager && strncmp(line, "exit", 4)) - vty_open_pager(vty); + vty_open_pager(gvty); if (!strcmp(cmd->string, "configure")) { for (i = 0; i < array_size(vtysh_client); i++) { @@ -602,17 +602,17 @@ static int vtysh_execute_func(const char *line, int pager) if (vline == NULL) { - if (vty->is_paged) - vty_close_pager(vty); + if (gvty->is_paged) + vty_close_pager(gvty); return CMD_SUCCESS; } - ret = cmd_execute_command(vline, vty, &cmd, 1); + ret = cmd_execute_command(vline, gvty, &cmd, 1); cmd_free_strvec(vline); if (ret != CMD_SUCCESS_DAEMON) break; } else if (cmd->func) { - (*cmd->func)(cmd, vty, 0, NULL); + (*cmd->func)(cmd, gvty, 0, NULL); break; } } @@ -653,11 +653,11 @@ static int vtysh_execute_func(const char *line, int pager) break; if (cmd->func) - (*cmd->func)(cmd, vty, 0, NULL); + (*cmd->func)(cmd, gvty, 0, NULL); } } - if (vty->is_paged) - vty_close_pager(vty); + if (gvty->is_paged) + vty_close_pager(gvty); return cmd_stat; } @@ -980,21 +980,21 @@ static int vtysh_process_questionmark(const char *input, int input_len) } else if (input_len && isspace((unsigned char)input[input_len - 1])) vector_set(vline, NULL); - describe = cmd_describe_command(vline, vty, &ret); + describe = cmd_describe_command(vline, gvty, &ret); /* Ambiguous and no match error. */ switch (ret) { case CMD_ERR_AMBIGUOUS: cmd_free_strvec(vline); vector_free(describe); - vty_out(vty, "%% Ambiguous command.\n"); + vty_out(gvty, "%% Ambiguous command.\n"); rl_on_new_line(); return 0; case CMD_ERR_NO_MATCH: cmd_free_strvec(vline); if (describe) vector_free(describe); - vty_out(vty, "%% There is no matched command.\n"); + vty_out(gvty, "%% There is no matched command.\n"); rl_on_new_line(); return 0; } @@ -1015,9 +1015,9 @@ static int vtysh_process_questionmark(const char *input, int input_len) for (i = 0; i < vector_active(describe); i++) if ((token = vector_slot(describe, i)) != NULL) { if (!token->desc) - vty_out(vty, " %-s\n", token->text); + vty_out(gvty, " %-s\n", token->text); else - vty_out(vty, " %-*s %s\n", width, token->text, + vty_out(gvty, " %-*s %s\n", width, token->text, token->desc); if (IS_VARYING_TOKEN(token->type)) { @@ -1033,7 +1033,7 @@ static int vtysh_process_questionmark(const char *input, int input_len) char *ac = cmd_variable_comp2str( varcomps, cols); - vty_out(vty, "%s\n", ac); + vty_out(gvty, "%s\n", ac); XFREE(MTYPE_TMP, ac); } @@ -1056,7 +1056,7 @@ static int vtysh_rl_describe(int a, int b) { int ret; - vty_out(vty, "\n"); + vty_out(gvty, "\n"); ret = vtysh_process_questionmark(rl_line_buffer, rl_end); rl_on_new_line(); @@ -1116,7 +1116,7 @@ static char *command_generator(const char *text, int state) if (!state) { index = 0; - if (vty->node == AUTH_NODE || vty->node == AUTH_ENABLE_NODE) + if (gvty->node == AUTH_NODE || gvty->node == AUTH_ENABLE_NODE) return NULL; vline = cmd_make_strvec(rl_line_buffer); @@ -1127,7 +1127,7 @@ static char *command_generator(const char *text, int state) isspace((unsigned char)rl_line_buffer[rl_end - 1])) vector_set(vline, NULL); - matched = cmd_complete_command(vline, vty, &complete_status); + matched = cmd_complete_command(vline, gvty, &complete_status); cmd_free_strvec(vline); } @@ -1672,13 +1672,13 @@ extern struct cmd_node vty_node; /* When '^Z' is received from vty, move down to the enable mode. */ static int vtysh_end(void) { - switch (vty->node) { + switch (gvty->node) { case VIEW_NODE: case ENABLE_NODE: /* Nothing to do. */ break; default: - vty->node = ENABLE_NODE; + gvty->node = ENABLE_NODE; break; } return CMD_SUCCESS; @@ -3627,7 +3627,7 @@ static void show_route_map_send(const char *route_map, bool json) strlcat(command_line, " json", sizeof(command_line)); if (json) - vty_out(vty, "{"); + vty_out(gvty, "{"); for (i = 0; i < array_size(vtysh_client); i++) { const struct vtysh_client *client = &vtysh_client[i]; @@ -3644,18 +3644,18 @@ static void show_route_map_send(const char *route_map, bool json) continue; if (json && !first) - vty_out(vty, ","); + vty_out(gvty, ","); else first = false; if (json) - vty_out(vty, "\"%s\":", vtysh_client[i].name); + vty_out(gvty, "\"%s\":", vtysh_client[i].name); vtysh_client_execute_name(vtysh_client[i].name, command_line); } if (json) - vty_out(vty, "}\n"); + vty_out(gvty, "}\n"); } DEFPY (show_route_map, @@ -3699,7 +3699,7 @@ static void show_prefix_list_send(afi_t afi, const char *prefix_list, strlcat(command_line, " json", sizeof(command_line)); if (json) - vty_out(vty, "{"); + vty_out(gvty, "{"); for (i = 0; i < array_size(vtysh_client); i++) { const struct vtysh_client *client = &vtysh_client[i]; @@ -3716,18 +3716,18 @@ static void show_prefix_list_send(afi_t afi, const char *prefix_list, continue; if (json && !first) - vty_out(vty, ","); + vty_out(gvty, ","); else first = false; if (json) - vty_out(vty, "\"%s\":", vtysh_client[i].name); + vty_out(gvty, "\"%s\":", vtysh_client[i].name); vtysh_client_execute_name(vtysh_client[i].name, command_line); } if (json) - vty_out(vty, "}\n"); + vty_out(gvty, "}\n"); } DEFPY (show_ip_prefix_list, @@ -3842,7 +3842,7 @@ static void show_access_list_send(afi_t afi, const char *access_list, bool json) strlcat(command_line, access_list, sizeof(command_line)); if (json) { strlcat(command_line, " json", sizeof(command_line)); - vty_out(vty, "{"); + vty_out(gvty, "{"); } for (i = 0; i < array_size(vtysh_client); i++) { @@ -3860,18 +3860,18 @@ static void show_access_list_send(afi_t afi, const char *access_list, bool json) continue; if (json && !first) - vty_out(vty, ","); + vty_out(gvty, ","); else first = false; if (json) - vty_out(vty, "\"%s\":", vtysh_client[i].name); + vty_out(gvty, "\"%s\":", vtysh_client[i].name); vtysh_client_execute_name(vtysh_client[i].name, command_line); } if (json) - vty_out(vty, "}\n"); + vty_out(gvty, "}\n"); } DEFPY (show_ip_access_list, @@ -3956,10 +3956,10 @@ static void backup_config_file(const char *fbackup) /* Move current configuration file to backup config file. */ if (unlink(integrate_sav) != 0 && errno != ENOENT) - vty_out(vty, "Unlink failed for %s: %s\n", integrate_sav, + vty_out(gvty, "Unlink failed for %s: %s\n", integrate_sav, strerror(errno)); if (rename(fbackup, integrate_sav) != 0 && errno != ENOENT) - vty_out(vty, "Error renaming %s to %s: %s\n", fbackup, + vty_out(gvty, "Error renaming %s to %s: %s\n", fbackup, integrate_sav, strerror(errno)); free(integrate_sav); } @@ -3981,12 +3981,12 @@ int vtysh_write_config_integrated(void) struct stat st; int err = 0; - vty_out(vty, "Building Configuration...\n"); + vty_out(gvty, "Building Configuration...\n"); backup_config_file(frr_config); fp = fopen(frr_config, "w"); if (fp == NULL) { - vty_out(vty, + vty_out(gvty, "%% Error: failed to open configuration file %s: %s\n", frr_config, safe_strerror(errno)); return CMD_WARNING_CONFIG_FAILED; @@ -3997,10 +3997,10 @@ int vtysh_write_config_integrated(void) vtysh_client_config(&vtysh_client[i], line); vtysh_config_write(); - vty->of_saved = vty->of; - vty->of = fp; + gvty->of_saved = gvty->of; + gvty->of = fp; vtysh_config_dump(); - vty->of = vty->of_saved; + gvty->of = gvty->of_saved; if (fchmod(fd, CONFIGFILE_MASK) != 0) { printf("%% Warning: can't chmod configuration file %s: %s\n", @@ -4964,7 +4964,7 @@ char *vtysh_prompt(void) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wformat-nonliteral" /* prompt formatting has a %s in the cmd_node prompt string. */ - snprintf(buf, sizeof(buf), cmd_prompt(vty->node), cmd_hostname_get()); + snprintf(buf, sizeof(buf), cmd_prompt(gvty->node), cmd_hostname_get()); #pragma GCC diagnostic pop return buf; } @@ -4987,12 +4987,12 @@ static void vtysh_autocomplete(vector comps, struct cmd_token *token) snprintf(accmd, sizeof(accmd), "autocomplete %d %s %s", token->type, token->text, token->varname ? token->varname : "-"); - vty->of_saved = vty->of; - vty->of = NULL; + gvty->of_saved = gvty->of; + gvty->of = NULL; for (i = 0; i < array_size(vtysh_client); i++) vtysh_client_run_all(&vtysh_client[i], accmd, 1, vtysh_ac_line, comps); - vty->of = vty->of_saved; + gvty->of = gvty->of_saved; } static const struct cmd_variable_handler vtysh_var_handler[] = { @@ -5004,8 +5004,8 @@ static const struct cmd_variable_handler vtysh_var_handler[] = { void vtysh_uninit(void) { - if (vty->of != stdout) - fclose(vty->of); + if (gvty->of != stdout) + fclose(gvty->of); } void vtysh_init_vty(void) @@ -5026,12 +5026,12 @@ void vtysh_init_vty(void) stderr_stdout_same = true; /* Make vty structure. */ - vty = vty_new(); - vty->type = VTY_SHELL; - vty->node = VIEW_NODE; + gvty = vty_new(); + gvty->type = VTY_SHELL; + gvty->node = VIEW_NODE; /* set default output */ - vty->of = stdout; + gvty->of = stdout; vtysh_pager_envdef(false); /* Initialize commands. */ diff --git a/vtysh/vtysh.h b/vtysh/vtysh.h index 3c532b99a8..6d5e559a2f 100644 --- a/vtysh/vtysh.h +++ b/vtysh/vtysh.h @@ -152,7 +152,7 @@ void suid_off(void); /* Child process execution flag. */ extern int execute_flag; -extern struct vty *vty; +extern struct vty *gvty; extern int user_mode; diff --git a/vtysh/vtysh_config.c b/vtysh/vtysh_config.c index 6536e1b376..4f6fc782c2 100644 --- a/vtysh/vtysh_config.c +++ b/vtysh/vtysh_config.c @@ -558,19 +558,19 @@ static void configvec_dump(vector vec, bool nested) continue; } - vty_out(vty, "%s\n", config->name); + vty_out(gvty, "%s\n", config->name); for (ALL_LIST_ELEMENTS(config->line, mnode, mnnode, line)) - vty_out(vty, "%s\n", line); + vty_out(gvty, "%s\n", line); configvec_dump(config->nested, true); if (config->exit) - vty_out(vty, "%s\n", config->exit); + vty_out(gvty, "%s\n", config->exit); if (!NO_DELIMITER(i)) - vty_out(vty, "!\n"); + vty_out(gvty, "!\n"); config_del(config); } @@ -579,7 +579,7 @@ static void configvec_dump(vector vec, bool nested) XFREE(MTYPE_VTYSH_CONFIG, configuration); vector_slot(vec, i) = NULL; if (!nested && NO_DELIMITER(i)) - vty_out(vty, "!\n"); + vty_out(gvty, "!\n"); } } @@ -589,11 +589,11 @@ void vtysh_config_dump(void) char *line; for (ALL_LIST_ELEMENTS(config_top, node, nnode, line)) - vty_out(vty, "%s\n", line); + vty_out(gvty, "%s\n", line); list_delete_all_node(config_top); - vty_out(vty, "!\n"); + vty_out(gvty, "!\n"); configvec_dump(configvec, false); } @@ -601,13 +601,13 @@ void vtysh_config_dump(void) /* Read up configuration file from file_name. */ static int vtysh_read_file(FILE *confp, bool dry_run) { - struct vty *vty; + struct vty *lvty; int ret; - vty = vty_new(); - vty->wfd = STDERR_FILENO; - vty->type = VTY_TERM; - vty->node = CONFIG_NODE; + lvty = vty_new(); + lvty->wfd = STDERR_FILENO; + lvty->type = VTY_TERM; + lvty->node = CONFIG_NODE; vtysh_execute_no_pager("enable"); /* @@ -622,7 +622,7 @@ static int vtysh_read_file(FILE *confp, bool dry_run) vtysh_execute_no_pager("XFRR_start_configuration"); /* Execute configuration file. */ - ret = vtysh_config_from_file(vty, confp); + ret = vtysh_config_from_file(lvty, confp); if (!dry_run) vtysh_execute_no_pager("XFRR_end_configuration"); @@ -630,7 +630,7 @@ static int vtysh_read_file(FILE *confp, bool dry_run) vtysh_execute_no_pager("end"); vtysh_execute_no_pager("disable"); - vty_close(vty); + vty_close(lvty); return (ret); } diff --git a/vtysh/vtysh_main.c b/vtysh/vtysh_main.c index 297d87ec41..16e166beac 100644 --- a/vtysh/vtysh_main.c +++ b/vtysh/vtysh_main.c @@ -726,7 +726,7 @@ int main(int argc, char **argv, char **env) vtysh_readline_init(); - vty_hello(vty); + vty_hello(gvty); /* Enter into enable node. */ if (!user_mode) diff --git a/zebra/interface.c b/zebra/interface.c index fd1ea380a5..f836b3ab35 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -1919,8 +1919,7 @@ static void zebra_if_dplane_ifp_handling(struct zebra_dplane_ctx *ctx) if (zif_type == ZEBRA_IF_VRF && !vrf_is_backend_netns()) interface_vrf_change(op, ifindex, name, tableid, ns_id); } else { - ifindex_t master_ifindex, bridge_ifindex, bond_ifindex, - link_ifindex; + ifindex_t master_ifindex, bridge_ifindex, link_ifindex; enum zebra_slave_iftype zif_slave_type; uint8_t bypass; uint64_t flags; @@ -2730,14 +2729,14 @@ static void if_dump_vty(struct vty *vty, struct interface *ifp) } if (gre_info->ifindex_link && (gre_info->link_nsid != NS_UNKNOWN)) { - struct interface *ifp; + struct interface *nifp; - ifp = if_lookup_by_index_per_ns( - zebra_ns_lookup(gre_info->link_nsid), - gre_info->ifindex_link); + nifp = if_lookup_by_index_per_ns( + zebra_ns_lookup(gre_info->link_nsid), + gre_info->ifindex_link); vty_out(vty, " Link Interface %s\n", - ifp == NULL ? "Unknown" : - ifp->name); + nifp == NULL ? "Unknown" : + nifp->name); } } @@ -3116,14 +3115,13 @@ static void if_dump_vty_json(struct vty *vty, struct interface *ifp, } if (gre_info->ifindex_link && (gre_info->link_nsid != NS_UNKNOWN)) { - struct interface *ifp; + struct interface *nifp; - ifp = if_lookup_by_index_per_ns( + nifp = if_lookup_by_index_per_ns( zebra_ns_lookup(gre_info->link_nsid), gre_info->ifindex_link); json_object_string_add(json_if, "linkInterface", - ifp == NULL ? "Unknown" - : ifp->name); + nifp == NULL ? "Unknown" : nifp->name); } } diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c index 4789cb62f2..8a6bfc45e0 100644 --- a/zebra/kernel_socket.c +++ b/zebra/kernel_socket.c @@ -1054,7 +1054,7 @@ void rtm_read(struct rt_msghdr *rtm) /* * Ignore our own messages. */ - if (rtm->rtm_type != RTM_GET && rtm->rtm_pid == pid) + if (rtm->rtm_type != RTM_GET && rtm->rtm_pid == zebra_pid) return; if (dest.sa.sa_family == AF_INET) { diff --git a/zebra/main.c b/zebra/main.c index af3998e384..b23307458b 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -57,7 +57,7 @@ char *zserv_path; /* process id. */ -pid_t pid; +pid_t zebra_pid; /* Pacify zclient.o in libfrr, which expects this variable. */ struct event_loop *master; @@ -520,7 +520,7 @@ int main(int argc, char **argv) */ /* Needed for BSD routing socket. */ - pid = getpid(); + zebra_pid = getpid(); /* Start dataplane system */ zebra_dplane_start(); diff --git a/zebra/rib.h b/zebra/rib.h index 7eaeb50c7e..652f6208f4 100644 --- a/zebra/rib.h +++ b/zebra/rib.h @@ -628,7 +628,7 @@ extern int rib_add_gr_run(afi_t afi, vrf_id_t vrf_id, uint8_t proto, extern void zebra_vty_init(void); extern uint32_t zebra_rib_dplane_results_count(void); -extern pid_t pid; +extern pid_t zebra_pid; extern uint32_t rt_table_main_id; diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index 9a60e32b65..a2e7997ab4 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -3139,13 +3139,11 @@ ssize_t netlink_nexthop_msg_encode(uint16_t cmd, if (nh->nh_srv6->seg6local_action != ZEBRA_SEG6_LOCAL_ACTION_UNSPEC) { uint32_t action; - uint16_t encap; - struct rtattr *nest; - const struct seg6local_context *ctx; + const struct seg6local_context *ctx6; req->nhm.nh_family = AF_INET6; action = nh->nh_srv6->seg6local_action; - ctx = &nh->nh_srv6->seg6local_ctx; + ctx6 = &nh->nh_srv6->seg6local_ctx; encap = LWTUNNEL_ENCAP_SEG6_LOCAL; if (!nl_attr_put(&req->n, buflen, NHA_ENCAP_TYPE, @@ -3174,7 +3172,7 @@ ssize_t netlink_nexthop_msg_encode(uint16_t cmd, return 0; if (!nl_attr_put( &req->n, buflen, - SEG6_LOCAL_NH6, &ctx->nh6, + SEG6_LOCAL_NH6, &ctx6->nh6, sizeof(struct in6_addr))) return 0; break; @@ -3187,7 +3185,7 @@ ssize_t netlink_nexthop_msg_encode(uint16_t cmd, if (!nl_attr_put32( &req->n, buflen, SEG6_LOCAL_TABLE, - ctx->table)) + ctx6->table)) return 0; break; case SEG6_LOCAL_ACTION_END_DX4: @@ -3198,7 +3196,7 @@ ssize_t netlink_nexthop_msg_encode(uint16_t cmd, return 0; if (!nl_attr_put( &req->n, buflen, - SEG6_LOCAL_NH4, &ctx->nh4, + SEG6_LOCAL_NH4, &ctx6->nh4, sizeof(struct in_addr))) return 0; break; @@ -3210,7 +3208,7 @@ ssize_t netlink_nexthop_msg_encode(uint16_t cmd, return 0; if (!nl_attr_put(&req->n, buflen, SEG6_LOCAL_NH6, - &ctx->nh6, + &ctx6->nh6, sizeof(struct in6_addr))) return 0; break; @@ -3223,7 +3221,7 @@ ssize_t netlink_nexthop_msg_encode(uint16_t cmd, if (!nl_attr_put32( &req->n, buflen, SEG6_LOCAL_TABLE, - ctx->table)) + ctx6->table)) return 0; break; case SEG6_LOCAL_ACTION_END_DT4: @@ -3235,7 +3233,7 @@ ssize_t netlink_nexthop_msg_encode(uint16_t cmd, if (!nl_attr_put32( &req->n, buflen, SEG6_LOCAL_VRFTABLE, - ctx->table)) + ctx6->table)) return 0; break; case SEG6_LOCAL_ACTION_END_DT46: @@ -3247,7 +3245,7 @@ ssize_t netlink_nexthop_msg_encode(uint16_t cmd, if (!nl_attr_put32( &req->n, buflen, SEG6_LOCAL_VRFTABLE, - ctx->table)) + ctx6->table)) return 0; break; default: @@ -3268,7 +3266,6 @@ ssize_t netlink_nexthop_msg_encode(uint16_t cmd, !sid_zero(nh->nh_srv6->seg6_segs)) { char tun_buf[4096]; ssize_t tun_len; - struct rtattr *nest; if (!nl_attr_put16(&req->n, buflen, NHA_ENCAP_TYPE, diff --git a/zebra/rtadv.c b/zebra/rtadv.c index a767bda72e..ce3f0320f5 100644 --- a/zebra/rtadv.c +++ b/zebra/rtadv.c @@ -1602,8 +1602,6 @@ DEFPY(show_ipv6_nd_ra_if, show_ipv6_nd_ra_if_cmd, struct vrf *vrf; RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { - struct zebra_vrf *zvrf; - zvrf = vrf->info; if (!zvrf) continue; diff --git a/zebra/zebra_fpm_netlink.c b/zebra/zebra_fpm_netlink.c index 95207ce75c..34c936155a 100644 --- a/zebra/zebra_fpm_netlink.c +++ b/zebra/zebra_fpm_netlink.c @@ -261,7 +261,7 @@ static int netlink_route_info_fill(struct netlink_route_info *ri, int cmd, ri->prefix = rib_dest_prefix(dest); ri->af = rib_dest_af(dest); - ri->nlmsg_pid = pid; + ri->nlmsg_pid = zebra_pid; ri->nlmsg_type = cmd; ri->rtm_protocol = RTPROT_UNSPEC; diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c index 589196ecb9..a033b3ea50 100644 --- a/zebra/zebra_nhg.c +++ b/zebra/zebra_nhg.c @@ -1161,11 +1161,32 @@ static void zebra_nhg_handle_uninstall(struct nhg_hash_entry *nhe) zebra_nhg_free(nhe); } +static void nhg_handle_install_one(struct nhg_connected *node) +{ + struct nhg_connected *rb_node_indirect_dep = NULL; + + frr_each_safe (nhg_connected_tree, &node->nhe->nhg_dependents, + rb_node_indirect_dep) { + SET_FLAG(rb_node_indirect_dep->nhe->flags, + NEXTHOP_GROUP_REINSTALL); + + if (IS_ZEBRA_DEBUG_NHG_DETAIL) + zlog_debug("%s nh id %u (flags 0x%x) associated dependents NHG %pNG (flags 0x%x) Re-install", + __func__, node->nhe->id, + node->nhe->flags, + rb_node_indirect_dep->nhe, + rb_node_indirect_dep->nhe->flags); + + zebra_nhg_install_kernel(rb_node_indirect_dep->nhe, + ZEBRA_ROUTE_MAX); + } + +} + static void zebra_nhg_handle_install(struct nhg_hash_entry *nhe, bool install) { /* Update validity of groups depending on it */ struct nhg_connected *rb_node_dep; - struct nhg_connected *rb_node_indirect_dep = NULL; frr_each_safe (nhg_connected_tree, &nhe->nhg_dependents, rb_node_dep) { zebra_nhg_set_valid(rb_node_dep->nhe, true); @@ -1173,19 +1194,7 @@ static void zebra_nhg_handle_install(struct nhg_hash_entry *nhe, bool install) if (install) { if (CHECK_FLAG(nhe->flags, NEXTHOP_GROUP_INSTALLED) && CHECK_FLAG(rb_node_dep->nhe->flags, NEXTHOP_GROUP_RECURSIVE)) { - frr_each_safe (nhg_connected_tree, &rb_node_dep->nhe->nhg_dependents, - rb_node_indirect_dep) { - SET_FLAG(rb_node_indirect_dep->nhe->flags, - NEXTHOP_GROUP_REINSTALL); - if (IS_ZEBRA_DEBUG_NHG_DETAIL) - zlog_debug("%s nh id %u (flags 0x%x) associated dependents NHG %pNG (flags 0x%x) Re-install", - __func__, rb_node_dep->nhe->id, - rb_node_dep->nhe->flags, - rb_node_indirect_dep->nhe, - rb_node_indirect_dep->nhe->flags); - zebra_nhg_install_kernel(rb_node_indirect_dep->nhe, - ZEBRA_ROUTE_MAX); - } + nhg_handle_install_one(rb_node_dep); } if (IS_ZEBRA_DEBUG_NHG_DETAIL) diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 0c4f7e02f8..e32b004ae9 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -317,9 +317,9 @@ static ssize_t printfrr_zebra_node(struct fbuf *buf, struct printfrr_eargs *ea, #define rnode_debug(node, vrf_id, msg, ...) \ do { \ - struct vrf *vrf = vrf_lookup_by_id(vrf_id); \ + struct vrf *_vrf = vrf_lookup_by_id(vrf_id); \ zlog_debug("%s: (%s:%pZNt):%pZN: " msg, __func__, \ - VRF_LOGNAME(vrf), node, node, ##__VA_ARGS__); \ + VRF_LOGNAME(_vrf), node, node, ##__VA_ARGS__); \ } while (0) #define rnode_info(node, vrf_id, msg, ...) \ @@ -1225,10 +1225,10 @@ static void rib_process(struct route_node *rn) * will not iterate so we are ok. */ if (IS_ZEBRA_DEBUG_RIB_DETAILED) { - struct route_entry *re = re_list_first(&dest->routes); + struct route_entry *rent = re_list_first(&dest->routes); zlog_debug("%s(%u:%u:%u):%pRN: Processing rn %p", VRF_LOGNAME(vrf), vrf_id, - re->table, safi, rn, rn); + rent->table, safi, rn, rn); } old_fib = dest->selected_fib; diff --git a/zebra/zebra_snmp.c b/zebra/zebra_snmp.c index 4b4f523253..06a9c0debe 100644 --- a/zebra/zebra_snmp.c +++ b/zebra/zebra_snmp.c @@ -418,11 +418,11 @@ static void get_fwtable_route_node(struct variable *v, oid objid[], objid[v->namelen + 5] = policy; { - struct nexthop *nexthop; + struct nexthop *nh; - nexthop = (*re)->nhe->nhg.nexthop; - if (nexthop) { - pnt = (uint8_t *)&nexthop->gate.ipv4; + nh = (*re)->nhe->nhg.nexthop; + if (nh) { + pnt = (uint8_t *)&nh->gate.ipv4; for (i = 0; i < 4; i++) objid[i + v->namelen + 6] = *pnt++; } diff --git a/zebra/zebra_srv6.c b/zebra/zebra_srv6.c index ebfd5c0908..ee0d6c41c6 100644 --- a/zebra/zebra_srv6.c +++ b/zebra/zebra_srv6.c @@ -36,6 +36,8 @@ DEFINE_MTYPE_STATIC(SRV6_MGR, ZEBRA_SRV6_USID_WLIB, DEFINE_MTYPE_STATIC(SRV6_MGR, ZEBRA_SRV6_SID, "SRv6 SID"); DEFINE_MTYPE_STATIC(SRV6_MGR, ZEBRA_SRV6_SID_CTX, "SRv6 SID context"); +static struct zebra_srv6 g_srv6; + /* Prototypes */ static int release_srv6_sid_func_dynamic(struct zebra_srv6_sid_block *block, uint32_t sid_func); @@ -705,8 +707,6 @@ void zebra_notify_srv6_locator_delete(struct srv6_locator *locator) } } -struct zebra_srv6 srv6; - struct zebra_srv6 *zebra_srv6_get_default(void) { static bool first_execution = true; @@ -715,11 +715,11 @@ struct zebra_srv6 *zebra_srv6_get_default(void) if (first_execution) { first_execution = false; - srv6.locators = list_new(); + g_srv6.locators = list_new(); /* Initialize list of SID formats */ - srv6.sid_formats = list_new(); - srv6.sid_formats->del = delete_srv6_sid_format; + g_srv6.sid_formats = list_new(); + g_srv6.sid_formats->del = delete_srv6_sid_format; /* Create SID format `usid-f3216` */ format_usidf3216 = create_srv6_sid_format_usid_f3216(); @@ -730,14 +730,14 @@ struct zebra_srv6 *zebra_srv6_get_default(void) srv6_sid_format_register(format_uncompressed); /* Init list to store SRv6 SIDs */ - srv6.sids = list_new(); - srv6.sids->del = delete_zebra_srv6_sid_ctx; + g_srv6.sids = list_new(); + g_srv6.sids->del = delete_zebra_srv6_sid_ctx; /* Init list to store SRv6 SID blocks */ - srv6.sid_blocks = list_new(); - srv6.sid_blocks->del = delete_zebra_srv6_sid_block; + g_srv6.sid_blocks = list_new(); + g_srv6.sid_blocks->del = delete_zebra_srv6_sid_block; } - return &srv6; + return &g_srv6; } /** @@ -2455,51 +2455,51 @@ void zebra_srv6_terminate(void) struct zebra_srv6_sid_block *block; struct zebra_srv6_sid_ctx *sid_ctx; - if (srv6.locators) { - while (listcount(srv6.locators)) { - locator = listnode_head(srv6.locators); + if (g_srv6.locators) { + while (listcount(g_srv6.locators)) { + locator = listnode_head(g_srv6.locators); - listnode_delete(srv6.locators, locator); + listnode_delete(g_srv6.locators, locator); srv6_locator_free(locator); } - list_delete(&srv6.locators); + list_delete(&g_srv6.locators); } /* Free SRv6 SIDs */ - if (srv6.sids) { - while (listcount(srv6.sids)) { - sid_ctx = listnode_head(srv6.sids); + if (g_srv6.sids) { + while (listcount(g_srv6.sids)) { + sid_ctx = listnode_head(g_srv6.sids); - listnode_delete(srv6.sids, sid_ctx); + listnode_delete(g_srv6.sids, sid_ctx); zebra_srv6_sid_ctx_free(sid_ctx); } - list_delete(&srv6.sids); + list_delete(&g_srv6.sids); } /* Free SRv6 SID blocks */ - if (srv6.sid_blocks) { - while (listcount(srv6.sid_blocks)) { - block = listnode_head(srv6.sid_blocks); + if (g_srv6.sid_blocks) { + while (listcount(g_srv6.sid_blocks)) { + block = listnode_head(g_srv6.sid_blocks); - listnode_delete(srv6.sid_blocks, block); + listnode_delete(g_srv6.sid_blocks, block); zebra_srv6_sid_block_free(block); } - list_delete(&srv6.sid_blocks); + list_delete(&g_srv6.sid_blocks); } /* Free SRv6 SID formats */ - if (srv6.sid_formats) { - while (listcount(srv6.sid_formats)) { - format = listnode_head(srv6.sid_formats); + if (g_srv6.sid_formats) { + while (listcount(g_srv6.sid_formats)) { + format = listnode_head(g_srv6.sid_formats); srv6_sid_format_unregister(format); srv6_sid_format_free(format); } - list_delete(&srv6.sid_formats); + list_delete(&g_srv6.sid_formats); } } diff --git a/zebra/zebra_srv6_vty.c b/zebra/zebra_srv6_vty.c index 22ba9386d9..3d5a76ff38 100644 --- a/zebra/zebra_srv6_vty.c +++ b/zebra/zebra_srv6_vty.c @@ -210,7 +210,7 @@ DEFUN (show_srv6_locator_detail, } for (ALL_LIST_ELEMENTS_RO(srv6->locators, node, locator)) { - struct listnode *node; + struct listnode *nnode; struct srv6_locator_chunk *chunk; if (strcmp(locator->name, locator_name) != 0) @@ -247,8 +247,7 @@ DEFUN (show_srv6_locator_detail, } vty_out(vty, "Chunks:\n"); - for (ALL_LIST_ELEMENTS_RO((struct list *)locator->chunks, node, - chunk)) { + for (ALL_LIST_ELEMENTS_RO((struct list *)locator->chunks, nnode, chunk)) { prefix2str(&chunk->prefix, str, sizeof(str)); vty_out(vty, "- prefix: %s, owner: %s\n", str, zebra_route_string(chunk->proto)); diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index a1731712d3..15bc2c20d2 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -1490,8 +1490,6 @@ DEFPY(show_nexthop_group, struct vrf *vrf; RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { - struct zebra_vrf *zvrf; - zvrf = vrf->info; if (!zvrf) continue;