From 0561943a780e2a6345823c80180c692d1c1f2a61 Mon Sep 17 00:00:00 2001 From: Mark Stapp Date: Thu, 23 Jan 2025 15:14:49 -0500 Subject: [PATCH] ospfd: clean up -Wshadow warnings Clean up various "shadow" warnings. Signed-off-by: Mark Stapp --- ospfd/ospf_bfd.c | 2 +- ospfd/ospf_flood.c | 8 ++---- ospfd/ospf_ldp_sync.c | 14 ++++------ ospfd/ospf_packet.c | 6 ++-- ospfd/ospf_te.c | 12 ++++---- ospfd/ospf_vty.c | 2 -- ospfd/ospf_zebra.c | 64 +++++++++++++++++++++---------------------- ospfd/ospfd.c | 19 ++++++------- ospfd/ospfd.h | 3 +- 9 files changed, 61 insertions(+), 69 deletions(-) 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; -- 2.39.5