diff options
author | Gleb Smirnoff <glebius@FreeBSD.org> | 2017-10-02 23:29:56 +0000 |
---|---|---|
committer | Gleb Smirnoff <glebius@FreeBSD.org> | 2017-10-02 23:29:56 +0000 |
commit | 0e229f343f4e8791f84a7acc6300f0bd1476c7b5 (patch) | |
tree | 2811f4d846f70a25dfb21f6569e58b90a61dd304 /usr.bin/sockstat | |
parent | 9d1d1d1900e60d56d2505beb8286ed7b9dde63c1 (diff) | |
download | src-test-0e229f343f4e8791f84a7acc6300f0bd1476c7b5.tar.gz src-test-0e229f343f4e8791f84a7acc6300f0bd1476c7b5.zip |
Hide struct socket and struct unpcb from the userland.
Violators may define _WANT_SOCKET and _WANT_UNPCB respectively and
are not guaranteed for stability of the structures. The violators
list is the the usual one: libprocstat(3) and netstat(1) internally
and lsof in ports.
In struct xunpcb remove the inclusion of kernel structure and add
a bunch of spare fields. The xsocket already has socket not included,
but add there spares as well. Embed xsockbuf into xsocket.
Sort declarations in sys/socketvar.h to separate kernel only from
userland available ones.
PR: 221820 (exp-run)
Notes
Notes:
svn path=/head/; revision=324227
Diffstat (limited to 'usr.bin/sockstat')
-rw-r--r-- | usr.bin/sockstat/sockstat.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/usr.bin/sockstat/sockstat.c b/usr.bin/sockstat/sockstat.c index ea439dc8d1f10..02b43b81374c5 100644 --- a/usr.bin/sockstat/sockstat.c +++ b/usr.bin/sockstat/sockstat.c @@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$"); #include <sys/user.h> #include <sys/un.h> +#define _WANT_UNPCB #include <sys/unpcb.h> #include <net/route.h> @@ -784,8 +785,8 @@ gather_unix(int proto) warnx("struct xunpcb size mismatch"); goto out; } - if ((xup->xu_unp.unp_conn == NULL && !opt_l) || - (xup->xu_unp.unp_conn != NULL && !opt_c)) + if ((xup->unp_conn == NULL && !opt_l) || + (xup->unp_conn != NULL && !opt_c)) continue; if ((sock = calloc(1, sizeof(*sock))) == NULL) err(1, "malloc()"); @@ -798,11 +799,11 @@ gather_unix(int proto) sock->proto = proto; sock->family = AF_UNIX; sock->protoname = protoname; - if (xup->xu_unp.unp_addr != NULL) + if (xup->xu_addr.sun_family == AF_UNIX) laddr->address = *(struct sockaddr_storage *)(void *)&xup->xu_addr; - else if (xup->xu_unp.unp_conn != NULL) - *(void **)&(faddr->address) = xup->xu_unp.unp_conn; + else if (xup->unp_conn != NULL) + *(void **)&(faddr->address) = xup->unp_conn; laddr->next = NULL; faddr->next = NULL; sock->laddr = laddr; |