diff options
author | tuexen <tuexen@FreeBSD.org> | 2016-06-25 12:46:18 +0000 |
---|---|---|
committer | tuexen <tuexen@FreeBSD.org> | 2016-06-25 12:46:18 +0000 |
commit | 6e8e43ab0e17ea11cd4b88bbdbe88c9ef0fd7098 (patch) | |
tree | 40955e8d59a79abdd76cfd63d476b716472dcf28 /usr.bin | |
parent | dd2c794a7da6e8daa63da7ac9ff4a0729ece4d7d (diff) | |
download | FreeBSD-src-6e8e43ab0e17ea11cd4b88bbdbe88c9ef0fd7098.zip FreeBSD-src-6e8e43ab0e17ea11cd4b88bbdbe88c9ef0fd7098.tar.gz |
This patch fixes two bugs:
* sctp46, tcp46, and udp46 sockets are displayed as such and not as
sctp4 6, tcp4 6, udp4 6. This bug was introduced in
http://svnweb.freebsd.org/base?view=revision&revision=187915
* For SCTP sockets, the the -4 and -6 flags are honoured as much as
possible. This means IPv4 sockets are handled correctly, IPv6
sockets are displayed as sctp46, since it is currently not possible
to distinguish between sctp6 and sctp46.
Approved by: re (gjb)
MFC after: 1 week
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/sockstat/sockstat.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/usr.bin/sockstat/sockstat.c b/usr.bin/sockstat/sockstat.c index 7d533d0..e4c5a8f 100644 --- a/usr.bin/sockstat/sockstat.c +++ b/usr.bin/sockstat/sockstat.c @@ -338,7 +338,12 @@ gather_sctp(void) sock->state = SCTP_LISTEN; if (xinpcb->flags & SCTP_PCB_FLAGS_BOUND_V6) { sock->family = AF_INET6; - sock->vflag = INP_IPV6; + /* + * Currently there is no way to distinguish between + * IPv6 only sockets or dual family sockets. + * So mark it as dual socket. + */ + sock->vflag = INP_IPV6 | INP_IPV4; } else { sock->family = AF_INET; sock->vflag = INP_IPV4; @@ -406,6 +411,7 @@ gather_sctp(void) offset += sizeof(struct xsctp_tcb); if (no_stcb) { if (opt_l && + (sock->vflag & vflag) && (!opt_L || !local_all_loopback) && ((xinpcb->flags & SCTP_PCB_FLAGS_UDPTYPE) || (xstcb->last == 1))) { @@ -428,7 +434,12 @@ gather_sctp(void) sock->state = (int)xstcb->state; if (xinpcb->flags & SCTP_PCB_FLAGS_BOUND_V6) { sock->family = AF_INET6; - sock->vflag = INP_IPV6; + /* + * Currently there is no way to distinguish + * between IPv6 only sockets or dual family + * sockets. So mark it as dual socket. + */ + sock->vflag = INP_IPV6 | INP_IPV4; } else { sock->family = AF_INET; sock->vflag = INP_IPV4; @@ -519,7 +530,9 @@ gather_sctp(void) prev_faddr = faddr; } if (opt_c) { - if (!opt_L || !(local_all_loopback || foreign_all_loopback)) { + if ((sock->vflag & vflag) && + (!opt_L || + !(local_all_loopback || foreign_all_loopback))) { hash = (int)((uintptr_t)sock->socket % HASHSIZE); sock->next = sockhash[hash]; sockhash[hash] = sock; @@ -963,9 +976,11 @@ displaysock(struct sock *s, int pos) pos += xprintf(" "); pos += xprintf("%s", s->protoname); if (s->vflag & INP_IPV4) - pos += xprintf("4 "); + pos += xprintf("4"); if (s->vflag & INP_IPV6) - pos += xprintf("6 "); + pos += xprintf("6"); + if (s->vflag & (INP_IPV4 | INP_IPV6)) + pos += xprintf(" "); laddr = s->laddr; faddr = s->faddr; first = 1; |