summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToomas Soome <tsoome@me.com>2020-05-23 20:03:17 +0300
committerToomas Soome <tsoome@me.com>2021-02-26 19:01:41 +0200
commitcd93bdd351ff6db57bb306f3135a27aff71919d0 (patch)
treee0fc9fea90654ddc1a847e67d8fa39a04d57c8c9
parentf6e9c6bd978eaf32de099c7f4a16eb9d2f1e5ab1 (diff)
downloadillumos-joyent-cd93bdd351ff6db57bb306f3135a27aff71919d0.tar.gz
13535 snoop: multiply-defined symbols
Reviewed by: Yuri Pankov <yuripv@yuripv.dev> Reviewed by: Andy Fiddaman <andy@omniosce.org> Approved by: Dan McDonald <danmcd@joyent.com>
-rw-r--r--usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop.h22
-rw-r--r--usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_filter.c49
-rw-r--r--usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_pf.c51
-rw-r--r--usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_rpc.c23
4 files changed, 67 insertions, 78 deletions
diff --git a/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop.h b/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop.h
index 1d1d921f65..2d1a0b271d 100644
--- a/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop.h
+++ b/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop.h
@@ -100,7 +100,7 @@ extern void del_transient(int port);
* argument is interpreted.
*/
#define XID_CACHE_SIZE 256
-struct cache_struct {
+extern struct cache_struct {
int xid_num; /* RPC transaction id */
int xid_frame; /* Packet number */
int xid_prog; /* RPC program number */
@@ -110,6 +110,26 @@ struct cache_struct {
int xid_gss_service; /* none, integ, priv */
} xid_cache[XID_CACHE_SIZE];
+extern char *tkp, *sav_tkp;
+extern char *token;
+extern enum tokentype {
+ EOL,
+ ALPHA,
+ NUMBER,
+ FIELD,
+ ADDR_IP,
+ ADDR_ETHER,
+ SPECIAL,
+ ADDR_IP6,
+ ADDR_AT
+} tokentype;
+extern uint_t tokenval;
+
+enum direction { ANY, TO, FROM };
+extern enum direction dir;
+
+extern int eaddr; /* need ethernet addr */
+extern int opstack; /* operand stack depth */
/*
* The following macros advance the pointer passed to them. They
diff --git a/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_filter.c b/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_filter.c
index 16ea65e305..2118fb4179 100644
--- a/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_filter.c
+++ b/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_filter.c
@@ -499,31 +499,34 @@ static int slp_index = 0;
* Returns the index of dport in the table if found, otherwise -1.
*/
static int
-find_slp(uint_t dport) {
- int i;
+find_slp(uint_t dport)
+{
+ int i;
- if (!dport)
- return (0);
+ if (!dport)
+ return (0);
- for (i = slp_index; i >= 0; i--)
- if (slp_table[i] == dport) {
- return (i);
- }
- for (i = SLP_CACHE_SIZE - 1; i > slp_index; i--)
- if (slp_table[i] == dport) {
- return (i);
- }
- return (-1);
+ for (i = slp_index; i >= 0; i--)
+ if (slp_table[i] == dport) {
+ return (i);
+ }
+ for (i = SLP_CACHE_SIZE - 1; i > slp_index; i--)
+ if (slp_table[i] == dport) {
+ return (i);
+ }
+ return (-1);
}
-static void stash_slp(uint_t sport) {
- if (slp_table[slp_index - 1] == sport)
- /* avoid redundancy due to multicast retransmissions */
- return;
+static void
+stash_slp(uint_t sport)
+{
+ if (slp_table[slp_index - 1] == sport)
+ /* avoid redundancy due to multicast retransmissions */
+ return;
- slp_table[slp_index++] = sport;
- if (slp_index == SLP_CACHE_SIZE)
- slp_index = 0;
+ slp_table[slp_index++] = sport;
+ if (slp_index == SLP_CACHE_SIZE)
+ slp_index = 0;
}
/*
@@ -1123,8 +1126,7 @@ resolve_chain(uint_t p)
char *tkp, *sav_tkp;
char *token;
-enum { EOL, ALPHA, NUMBER, FIELD, ADDR_IP, ADDR_ETHER, SPECIAL,
- ADDR_IP6, ADDR_AT } tokentype;
+enum tokentype tokentype;
uint_t tokenval;
/*
@@ -1134,7 +1136,7 @@ uint_t tokenval;
* ALPHA: A name that begins with a letter and contains
* letters or digits, hyphens or underscores.
* NUMBER: A number. The value can be represented as
- * a decimal value (1234) or an octal value
+ * a decimal value (1234) or an octal value
* that begins with zero (066) or a hex value
* that begins with 0x or 0X (0xff).
* FIELD: A name followed by a left square bracket.
@@ -1460,7 +1462,6 @@ comparison(char *s)
return (n_checks > 0);
}
-enum direction { ANY, TO, FROM };
enum direction dir;
/*
diff --git a/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_pf.c b/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_pf.c
index 6eec24cd85..fc6ce7a5bb 100644
--- a/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_pf.c
+++ b/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_pf.c
@@ -74,10 +74,6 @@ extern struct Pf_ext_packetfilt pf;
static ushort_t *pfp;
jmp_buf env;
-int eaddr; /* need ethernet addr */
-
-int opstack; /* operand stack depth */
-
#define EQ(val) (strcmp(token, val) == 0)
#define IPV4_ONLY 0
#define IPV6_ONLY 1
@@ -234,14 +230,6 @@ datalink_t dl;
static int inBrace = 0, inBraceOR = 0;
static int foundOR = 0;
-char *tkp, *sav_tkp;
-char *token;
-enum { EOL, ALPHA, NUMBER, FIELD, ADDR_IP, ADDR_ETHER, SPECIAL,
- ADDR_IP6 } tokentype;
-uint_t tokenval;
-
-enum direction { ANY, TO, FROM };
-enum direction dir;
extern void next();
@@ -271,8 +259,7 @@ static void pf_matchfn(const char *name);
static void *last_offset_operation = (void*)pf_clear_offset_register;
static void
-pf_emit(x)
- ushort_t x;
+pf_emit(ushort_t x)
{
if (pfp > &pf.Pf_Filter[PF_MAXFILTERS - 1])
longjmp(env, 1);
@@ -280,9 +267,7 @@ pf_emit(x)
}
static void
-pf_codeprint(code, len)
- ushort_t *code;
- int len;
+pf_codeprint(ushort_t *code, int len)
{
ushort_t *pc;
ushort_t *plast = code + len;
@@ -599,10 +584,7 @@ pf_compare_zoneid(int offset, uint32_t val)
* Generate pf code to match an IPv4 or IPv6 address.
*/
static void
-pf_ipaddr_match(which, hostname, inet_type)
- enum direction which;
- char *hostname;
- int inet_type;
+pf_ipaddr_match(enum direction which, char *hostname, int inet_type)
{
bool_t found_host;
uint_t *addr4ptr;
@@ -766,7 +748,7 @@ pf_ipaddr_match(which, hostname, inet_type)
first = B_FALSE;
}
addr6ptr = (struct in6_addr *)
- hp->h_addr_list[++h_addr_index];
+ hp->h_addr_list[++h_addr_index];
}
if (!first) {
pf_emit(ENF_AND);
@@ -781,7 +763,7 @@ pf_ipaddr_match(which, hostname, inet_type)
pf_matchfn("ip6");
if (dl.dl_type == DL_ETHER) {
pf_check_vlan_tag(
- ENCAP_ETHERTYPE_OFF/2);
+ ENCAP_ETHERTYPE_OFF / 2);
}
pass++;
}
@@ -803,7 +785,7 @@ pf_ipaddr_match(which, hostname, inet_type)
first = B_FALSE;
}
addr6ptr = (struct in6_addr *)
- hp->h_addr_list[++h_addr_index];
+ hp->h_addr_list[++h_addr_index];
}
if (!first) {
pf_emit(ENF_AND);
@@ -858,9 +840,7 @@ pf_compare_address(int offset, uint_t len, uchar_t *addr)
* Compare ethernet addresses.
*/
static void
-pf_etheraddr_match(which, hostname)
- enum direction which;
- char *hostname;
+pf_etheraddr_match(enum direction which, char *hostname)
{
struct ether_addr e, *ep = NULL;
@@ -870,7 +850,7 @@ pf_etheraddr_match(which, hostname)
if (ether_hostton(hostname, &e))
if (!arp_for_ether(hostname, &e))
pr_err("cannot obtain ether addr for %s",
- hostname);
+ hostname);
ep = &e;
}
@@ -900,9 +880,7 @@ pf_etheraddr_match(which, hostname)
* an IP address.
*/
static void
-pf_netaddr_match(which, netname)
- enum direction which;
- char *netname;
+pf_netaddr_match(enum direction which, char *netname)
{
uint_t addr;
uint_t mask = 0xff000000;
@@ -1530,9 +1508,7 @@ pf_expression()
* filter.
*/
int
-pf_compile(e, print)
- char *e;
- int print;
+pf_compile(char *e, int print)
{
char *argstr;
char *sav_str, *ptr, *sav_ptr;
@@ -1616,8 +1592,7 @@ pf_compile(e, print)
/* CHECK IF NO OR AHEAD */
sav_ptr = (char *)((uintptr_t)sav_str +
- (uintptr_t)sav_tkp -
- (uintptr_t)argstr);
+ (uintptr_t)sav_tkp - (uintptr_t)argstr);
ptr = sav_ptr;
while (*ptr != '\0') {
switch (*ptr) {
@@ -1630,7 +1605,7 @@ pf_compile(e, print)
case 'o':
case 'O':
if ((*(ptr + 1) == 'R' ||
- *(ptr + 1) == 'r') && !inBr)
+ *(ptr + 1) == 'r') && !inBr)
aheadOR = 1;
break;
case ',':
@@ -1646,7 +1621,7 @@ pf_compile(e, print)
pf.Pf_Priority = 5;
if (print) {
pf_codeprint(&pf.Pf_Filter[0],
- pf.Pf_FilterLen);
+ pf.Pf_FilterLen);
}
compile(sav_ptr, print);
return (2);
diff --git a/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_rpc.c b/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_rpc.c
index be39961676..63d964c24c 100644
--- a/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_rpc.c
+++ b/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_rpc.c
@@ -61,6 +61,7 @@ static void rpc_detail_reply(int, int, struct cache_struct *, char *, int len);
static void print_creds(int);
static void print_verif(int);
static void stash_xid(ulong_t, int, int, int, int);
+struct cache_struct xid_cache[XID_CACHE_SIZE];
#define LAST_FRAG ((ulong_t)1 << 31)
@@ -257,8 +258,7 @@ rpc_detail_call(int flags, int xid, int rpcvers, int prog, int vers, int proc,
}
char *
-nameof_flavor(flavor)
- int flavor;
+nameof_flavor(int flavor)
{
switch (flavor) {
case AUTH_NONE : return ("None");
@@ -545,15 +545,13 @@ struct rpcnames {
};
int
-compare(a, b)
- register struct rpcnames *a, *b;
+compare(struct rpcnames *a, struct rpcnames *b)
{
return (a->rp_prog - b->rp_prog);
}
char *
-nameof_prog(prog)
- int prog;
+nameof_prog(int prog)
{
struct rpcnames *r;
struct rpcnames *bsearch();
@@ -570,8 +568,7 @@ nameof_prog(prog)
}
char *
-nameof_astat(status)
- int status;
+nameof_astat(int status)
{
switch (status) {
case SUCCESS : return ("Success");
@@ -585,8 +582,7 @@ nameof_astat(status)
}
char *
-nameof_why(why)
- int why;
+nameof_why(int why)
{
switch (why) {
case AUTH_BADCRED: return ("bogus credentials (seal broken)");
@@ -723,8 +719,7 @@ struct cache_struct *xcp = &xid_cache[0];
struct cache_struct *xcplast = &xid_cache[XID_CACHE_SIZE - 1];
struct cache_struct *
-find_xid(xid)
- ulong_t xid;
+find_xid(ulong_t xid)
{
struct cache_struct *x;
@@ -758,9 +753,7 @@ stash_xid(ulong_t xid, int frame, int prog, int vers, int proc)
}
void
-check_retransmit(line, xid)
- char *line;
- ulong_t xid;
+check_retransmit(char *line, ulong_t xid)
{
struct cache_struct *x;
extern int pi_frame;