From owner-svn-src-head@freebsd.org Sat Jun 25 12:46:20 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1A3E3B80C08; Sat, 25 Jun 2016 12:46:20 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D0DE91C2E; Sat, 25 Jun 2016 12:46:19 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5PCkJ64031783; Sat, 25 Jun 2016 12:46:19 GMT (envelope-from tuexen@FreeBSD.org) Received: (from tuexen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5PCkJkH031782; Sat, 25 Jun 2016 12:46:19 GMT (envelope-from tuexen@FreeBSD.org) Message-Id: <201606251246.u5PCkJkH031782@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tuexen set sender to tuexen@FreeBSD.org using -f From: Michael Tuexen Date: Sat, 25 Jun 2016 12:46:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r302197 - head/usr.bin/sockstat X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Jun 2016 12:46:20 -0000 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;