summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormikeb <mikeb@openbsd.org>2011-11-01 00:00:01 +0000
committermikeb <mikeb@openbsd.org>2011-11-01 00:00:01 +0000
commitf15dea013e4fb713b56e97482c3b57f0c3859a14 (patch)
tree5f328955a5cda5129661151494b598ab3482d493
parentDon't forget to cancel bulk update failure timeout when destroying an (diff)
downloadwireguard-openbsd-f15dea013e4fb713b56e97482c3b57f0c3859a14.tar.xz
wireguard-openbsd-f15dea013e4fb713b56e97482c3b57f0c3859a14.zip
List sockets existing only in the specified or current routing domain.
Prompted by the mail from Andreas Bartelt, tested by Andreas and me. ok henning
-rw-r--r--usr.bin/netstat/inet.c7
-rw-r--r--usr.bin/netstat/main.c21
-rw-r--r--usr.bin/netstat/netstat.h4
3 files changed, 19 insertions, 13 deletions
diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c
index 3df11b39114..c48b3c089c4 100644
--- a/usr.bin/netstat/inet.c
+++ b/usr.bin/netstat/inet.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: inet.c,v 1.118 2011/07/05 05:14:41 bluhm Exp $ */
+/* $OpenBSD: inet.c,v 1.119 2011/11/01 00:00:01 mikeb Exp $ */
/* $NetBSD: inet.c,v 1.14 1995/10/03 21:42:37 thorpej Exp $ */
/*
@@ -108,7 +108,7 @@ void tcpcb_dump(u_long);
* -a (all) flag is specified.
*/
void
-protopr(u_long off, char *name, int af, u_long pcbaddr)
+protopr(u_long off, char *name, int af, u_int tableid, u_long pcbaddr)
{
struct inpcbtable table;
struct inpcb *head, *next, *prev;
@@ -169,6 +169,9 @@ protopr(u_long off, char *name, int af, u_long pcbaddr)
continue;
}
+ if (inpcb.inp_rtableid != tableid)
+ continue;
+
kread((u_long)inpcb.inp_socket, &sockb, sizeof (sockb));
if (istcp) {
kread((u_long)inpcb.inp_ppcb, &tcpcb, sizeof (tcpcb));
diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c
index a0c3be357df..aac2d3d10a8 100644
--- a/usr.bin/netstat/main.c
+++ b/usr.bin/netstat/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.89 2011/07/09 00:45:40 henning Exp $ */
+/* $OpenBSD: main.c,v 1.90 2011/11/01 00:00:01 mikeb Exp $ */
/* $NetBSD: main.c,v 1.9 1996/05/07 02:55:02 thorpej Exp $ */
/*
@@ -98,7 +98,7 @@ struct nlist nl[] = {
struct protox {
u_char pr_index; /* index into nlist of cb head */
- void (*pr_cblocks)(u_long, char *, int, u_long);
+ void (*pr_cblocks)(u_long, char *, int, u_int, u_long);
/* control blocks printing routine */
void (*pr_stats)(char *); /* statistics printing routine */
char *pr_name; /* well-known name */
@@ -136,7 +136,7 @@ struct protox *protoprotox[] = {
protox, ip6protox, NULL
};
-static void printproto(struct protox *, char *, int, u_long);
+static void printproto(struct protox *, char *, int, u_int, u_long);
static void usage(void);
static struct protox *name2protox(char *);
static struct protox *knownname(char *);
@@ -357,7 +357,7 @@ main(int argc, char *argv[])
exit(0);
}
if (pflag) {
- printproto(tp, tp->pr_name, af, pcbaddr);
+ printproto(tp, tp->pr_name, af, tableid, pcbaddr);
exit(0);
}
/*
@@ -409,17 +409,18 @@ main(int argc, char *argv[])
break;
if (tp->pr_name == 0)
continue;
- printproto(tp, p->p_name, AF_INET, pcbaddr);
+ printproto(tp, p->p_name, AF_INET, tableid, pcbaddr);
}
endprotoent();
}
if (af == PF_PFLOW || af == AF_UNSPEC) {
tp = name2protox("pflow");
- printproto(tp, tp->pr_name, af, pcbaddr);
+ printproto(tp, tp->pr_name, af, tableid, pcbaddr);
}
if (af == AF_INET6 || af == AF_UNSPEC)
for (tp = ip6protox; tp->pr_name; tp++)
- printproto(tp, tp->pr_name, AF_INET6, pcbaddr);
+ printproto(tp, tp->pr_name, AF_INET6, tableid,
+ pcbaddr);
if ((af == AF_UNIX || af == AF_UNSPEC) && !sflag)
unixpr(nl[N_UNIXSW].n_value, pcbaddr);
exit(0);
@@ -431,7 +432,8 @@ main(int argc, char *argv[])
* is not in the namelist, ignore this one.
*/
static void
-printproto(struct protox *tp, char *name, int af, u_long pcbaddr)
+printproto(struct protox *tp, char *name, int af, u_int tableid,
+ u_long pcbaddr)
{
if (sflag) {
if (tp->pr_stats != NULL)
@@ -441,7 +443,8 @@ printproto(struct protox *tp, char *name, int af, u_long pcbaddr)
if (tp->pr_cblocks != NULL &&
i < sizeof(nl) / sizeof(nl[0]) &&
(nl[i].n_value || af != AF_UNSPEC))
- (*tp->pr_cblocks)(nl[i].n_value, name, af, pcbaddr);
+ (*tp->pr_cblocks)(nl[i].n_value, name, af, tableid,
+ pcbaddr);
}
}
diff --git a/usr.bin/netstat/netstat.h b/usr.bin/netstat/netstat.h
index 4a412270674..7583c1f9ca0 100644
--- a/usr.bin/netstat/netstat.h
+++ b/usr.bin/netstat/netstat.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: netstat.h,v 1.60 2011/07/09 00:45:40 henning Exp $ */
+/* $OpenBSD: netstat.h,v 1.61 2011/11/01 00:00:01 mikeb Exp $ */
/* $NetBSD: netstat.h,v 1.6 1996/05/07 02:55:05 thorpej Exp $ */
/*
@@ -70,7 +70,7 @@ int kread(u_long addr, void *buf, int size);
char *plural(u_int64_t);
char *plurales(u_int64_t);
-void protopr(u_long, char *, int, u_long);
+void protopr(u_long, char *, int, u_int, u_long);
void tcp_stats(char *);
void udp_stats(char *);
void ip_stats(char *);