Date: Sat, 25 Jun 2016 12:46:19 +0000 (UTC) From: Michael Tuexen <tuexen@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302197 - head/usr.bin/sockstat Message-ID: <201606251246.u5PCkJkH031782@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: tuexen Date: Sat Jun 25 12:46:18 2016 New Revision: 302197 URL: https://svnweb.freebsd.org/changeset/base/302197 Log: 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 Modified: head/usr.bin/sockstat/sockstat.c Modified: head/usr.bin/sockstat/sockstat.c ============================================================================== --- head/usr.bin/sockstat/sockstat.c Sat Jun 25 11:34:06 2016 (r302196) +++ head/usr.bin/sockstat/sockstat.c Sat Jun 25 12:46:18 2016 (r302197) @@ -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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201606251246.u5PCkJkH031782>