Skip to content

Commit

Permalink
zebra: Create a zebra_privs.h that allows the inclusion of the priv
Browse files Browse the repository at this point in the history
The `extern struct ...` privs structure should not be declared
in a .c file.  Remove it and put it into it's own header.
I didn't see a header it really belonged to so we get a new
header.

Signed-off-by: Donald Sharp <[email protected]>
  • Loading branch information
donaldsharp committed Sep 26, 2024
1 parent 891e750 commit c9565d3
Show file tree
Hide file tree
Showing 17 changed files with 17 additions and 29 deletions.
3 changes: 1 addition & 2 deletions zebra/if_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@
#include "zebra/netconf_netlink.h"
#include "zebra/zebra_trace.h"
#include "zebra/zebra_evpn_arp_nd.h"

extern struct zebra_privs_t zserv_privs;
#include "zebra/zebra_privs.h"

/* Utility function to parse hardware link-layer address and update ifp */
static void netlink_interface_update_hw_addr(struct rtattr **tb,
Expand Down
3 changes: 1 addition & 2 deletions zebra/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@
#include "zebra/interface.h"
#include "zebra/zebra_errors.h"
#include "zebra/debug.h"
#include "zebra/zebra_privs.h"

#ifdef HAVE_BSD_LINK_DETECT
#include <net/if_media.h>
#endif /* HAVE_BSD_LINK_DETECT*/

extern struct zebra_privs_t zserv_privs;

/* clear and set interface name string */
void ifreq_set_name(struct ifreq *ifreq, struct interface *ifp)
{
Expand Down
3 changes: 1 addition & 2 deletions zebra/ipforward_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
#include "privs.h"

#include "zebra/ipforward.h"

extern struct zebra_privs_t zserv_privs;
#include "zebra/zebra_privs.h"

static const char proc_net_snmp[] = "/proc/net/snmp";

Expand Down
4 changes: 2 additions & 2 deletions zebra/ipforward_sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
#include "log.h"
#include "lib_errors.h"

#define MIB_SIZ 4
#include "zebra/zebra_privs.h"

extern struct zebra_privs_t zserv_privs;
#define MIB_SIZ 4

/* IPv4 forwarding control MIB. */
int mib[MIB_SIZ] = {CTL_NET, PF_INET, IPPROTO_IP, IPCTL_FORWARDING};
Expand Down
4 changes: 1 addition & 3 deletions zebra/irdp_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,9 @@
#include "sockunion.h"
#include "log.h"
#include "network.h"
#include "zebra/zebra_privs.h"

/* GLOBAL VARS */

extern struct zebra_privs_t zserv_privs;

struct event *t_irdp_raw;

/* Timer interval of irdp. */
Expand Down
3 changes: 1 addition & 2 deletions zebra/kernel_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "zebra/netconf_netlink.h"
#include "zebra/zebra_errors.h"
#include "zebra/ge_netlink.h"
#include "zebra/zebra_privs.h"

#ifndef SO_RCVBUFFORCE
#define SO_RCVBUFFORCE (33)
Expand Down Expand Up @@ -168,8 +169,6 @@ static const struct message rttype_str[] = {{RTN_UNSPEC, "none"},

extern struct event_loop *master;

extern struct zebra_privs_t zserv_privs;

DEFINE_MTYPE_STATIC(ZEBRA, NL_BUF, "Zebra Netlink buffers");

/* Hashtable and mutex to allow lookup of nlsock structs by socket/fd value.
Expand Down
3 changes: 1 addition & 2 deletions zebra/kernel_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
#include "zebra/rib.h"
#include "zebra/zebra_errors.h"
#include "zebra/zebra_ptm.h"

extern struct zebra_privs_t zserv_privs;
#include "zebra/zebra_privs.h"

/*
* Historically, the BSD routing socket has aligned data following a
Expand Down
2 changes: 1 addition & 1 deletion zebra/netconf_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "zebra/kernel_netlink.h"
#include "zebra/netconf_netlink.h"
#include "zebra/debug.h"
#include "zebra/zebra_privs.h"

static struct rtattr *netconf_rta(struct netconfmsg *ncm)
{
Expand Down Expand Up @@ -175,7 +176,6 @@ int netlink_request_netconf(int sockfd)
return netlink_request(nls, &req);
}

extern struct zebra_privs_t zserv_privs;
/*
* Currently netconf has no ability to set from netlink.
* So we've received a request to do this work in the data plane.
Expand Down
3 changes: 1 addition & 2 deletions zebra/rt_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
#include "zebra/kernel_socket.h"
#include "zebra/zebra_mpls.h"
#include "zebra/zebra_errors.h"

extern struct zebra_privs_t zserv_privs;
#include "zebra/zebra_privs.h"

#ifdef __OpenBSD__
static int kernel_rtm_add_labels(struct mpls_label_stack *nh_label,
Expand Down
3 changes: 1 addition & 2 deletions zebra/rtadv.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
#include "zebra/zebra_vrf.h"
#include "zebra/zebra_errors.h"
#include "zebra/zebra_router.h"

extern struct zebra_privs_t zserv_privs;
#include "zebra/zebra_privs.h"

static uint32_t interfaces_configured_for_ra_from_bgp;
#define RTADV_ADATA_SIZE 1024
Expand Down
1 change: 1 addition & 0 deletions zebra/subdir.am
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ noinst_HEADERS += \
zebra/zebra_nhg_private.h \
zebra/zebra_ns.h \
zebra/zebra_opaque.h \
zebra/zebra_privs.h \
zebra/zebra_pbr.h \
zebra/zebra_ptm.h \
zebra/zebra_ptm_redistribute.h \
Expand Down
2 changes: 1 addition & 1 deletion zebra/zebra_evpn_arp_nd.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ struct ethhdr;
#include "zebra_evpn_mac.h"
#include "zebra_evpn_mh.h"
#include "zebra_evpn_arp_nd.h"
#include "zebra_privs.h"

struct zebra_evpn_arp_nd_info zevpn_arp_nd_info;
extern struct zebra_privs_t zserv_privs;

#ifdef GNU_LINUX
#define DO_NOT_CRASH_COMPILER 0
Expand Down
3 changes: 1 addition & 2 deletions zebra/zebra_mpls_openbsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
#include "interface.h"
#include "log.h"
#include "lib_errors.h"

extern struct zebra_privs_t zserv_privs;
#include "zebra/zebra_privs.h"

struct {
uint32_t rtseq;
Expand Down
1 change: 1 addition & 0 deletions zebra/zebra_netns_notify.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "zebra_netns_id.h"
#include "zebra_errors.h"
#include "interface.h"
#include "zebra_privs.h"

#ifdef HAVE_NETLINK

Expand Down
2 changes: 0 additions & 2 deletions zebra/zebra_netns_notify.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ extern void zebra_ns_notify_init(void);
extern void zebra_ns_notify_parse(void);
extern void zebra_ns_notify_close(void);

extern struct zebra_privs_t zserv_privs;

#ifdef __cplusplus
}
#endif
Expand Down
3 changes: 1 addition & 2 deletions zebra/zebra_ns.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
#include "table_manager.h"
#include "zebra_errors.h"
#include "zebra_dplane.h"

extern struct zebra_privs_t zserv_privs;
#include "zebra_privs.h"

DEFINE_MTYPE_STATIC(ZEBRA, ZEBRA_NS, "Zebra Name Space");

Expand Down
3 changes: 1 addition & 2 deletions zebra/zserv.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,9 @@
#include "zebra/zserv.h" /* for zserv */
#include "zebra/zebra_router.h"
#include "zebra/zebra_errors.h" /* for error messages */
#include "zebra/zebra_privs.h"
/* clang-format on */

/* privileges */
extern struct zebra_privs_t zserv_privs;

/* The listener socket for clients connecting to us */
static int zsock;
Expand Down

0 comments on commit c9565d3

Please sign in to comment.