Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: expose and fix variable shadowing warnings #17915

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from
7 changes: 5 additions & 2 deletions babeld/babel_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -746,8 +746,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);
}
}

Expand Down Expand Up @@ -965,6 +967,7 @@ DEFUN (show_babel_route,
{
struct route_stream *routes = NULL;
struct xroute_stream *xroutes = NULL;

routes = route_stream(0);
if(routes) {
while(1) {
Expand Down
33 changes: 17 additions & 16 deletions babeld/babel_zebra.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -94,10 +94,11 @@ 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);
/* perhaps should we remove xroutes having the same type... */
zclient_redistribute(ZEBRA_REDISTRIBUTE_DELETE, babel_zclient, afi, type, 0,
VRF_DEFAULT);
/* perhaps should we remove xroutes having the same type... */
}
return CMD_SUCCESS;
}
Expand Down Expand Up @@ -230,24 +231,24 @@ 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);
install_element(ENABLE_NODE, &no_debug_babel_cmd);
install_element(CONFIG_NODE, &debug_babel_cmd);
install_element(CONFIG_NODE, &no_debug_babel_cmd);
install_element(BABEL_NODE, &babel_redistribute_type_cmd);
install_element(ENABLE_NODE, &debug_babel_cmd);
install_element(ENABLE_NODE, &no_debug_babel_cmd);
install_element(CONFIG_NODE, &debug_babel_cmd);
install_element(CONFIG_NODE, &no_debug_babel_cmd);

install_element(ENABLE_NODE, &show_debugging_babel_cmd);
install_element(ENABLE_NODE, &show_debugging_babel_cmd);
}

void
babel_zebra_close_connexion(void)
{
zclient_stop(zclient);
zclient_free(zclient);
zclient_stop(babel_zclient);
zclient_free(babel_zclient);
}
2 changes: 1 addition & 1 deletion babeld/babel_zebra.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions babeld/babeld.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
3 changes: 1 addition & 2 deletions babeld/kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion babeld/route.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
32 changes: 16 additions & 16 deletions bfdd/ptm_adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;


/*
Expand Down Expand Up @@ -205,7 +205,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 */
Expand Down Expand Up @@ -254,7 +254,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)
Expand Down Expand Up @@ -590,7 +590,7 @@ static void bfdd_client_deregister(struct stream *msg)

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);
Expand Down Expand Up @@ -643,7 +643,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)
Expand Down Expand Up @@ -827,40 +827,40 @@ 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();
}

void bfdd_zclient_terminate(void)
{
zclient_free(zclient);
zclient_free(bfd_zclient);
}


Expand Down
3 changes: 2 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -467,14 +467,15 @@ AC_C_FLAG([-Wbad-function-cast])
AC_C_FLAG([-Wwrite-strings])
AC_C_FLAG([-Wundef])
AC_C_FLAG([-Wimplicit-fallthrough])
AC_C_FLAG([-Wshadow])
AC_C_FLAG([-Wno-error=shadow])
if test "$enable_gcc_ultra_verbose" = "yes" ; then
AC_C_FLAG([-Wcast-qual])
AC_C_FLAG([-Wmissing-noreturn])
AC_C_FLAG([-Wmissing-format-attribute])
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
Expand Down
2 changes: 1 addition & 1 deletion eigrpd/eigrp_northbound.c
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,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:
Expand Down
8 changes: 4 additions & 4 deletions eigrpd/eigrp_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,14 +282,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);
}
Expand Down
28 changes: 13 additions & 15 deletions eigrpd/eigrp_zebra.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -98,11 +98,11 @@ 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;
}


Expand Down Expand Up @@ -187,7 +187,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));
Expand Down Expand Up @@ -221,22 +221,22 @@ 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));
api.vrf_id = eigrp->vrf_id;
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);
Expand All @@ -247,10 +247,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,
Expand All @@ -275,7 +273,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;
Expand All @@ -288,7 +286,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;
}
Expand Down
7 changes: 3 additions & 4 deletions eigrpd/eigrpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;


Expand Down Expand Up @@ -237,9 +236,9 @@ void eigrp_finish(struct eigrp *eigrp)
/* eigrp being shut-down? If so, was this the last eigrp instance? */
if (CHECK_FLAG(eigrp_om->options, EIGRP_MASTER_SHUTDOWN)
&& (listcount(eigrp_om->eigrp) == 0)) {
if (zclient) {
zclient_stop(zclient);
zclient_free(zclient);
if (eigrp_zclient) {
zclient_stop(eigrp_zclient);
zclient_free(eigrp_zclient);
}
exit(0);
}
Expand Down
2 changes: 1 addition & 1 deletion eigrpd/eigrpd.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,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;
Expand Down
2 changes: 0 additions & 2 deletions isisd/isis_adjacency.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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,
Expand Down
Loading
Loading