From owner-svn-src-head@freebsd.org Wed Aug 26 22:50:54 2015 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 0CF1F9C39A8; Wed, 26 Aug 2015 22:50:54 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::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 D8422DAE; Wed, 26 Aug 2015 22:50:53 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7QMorJn097152; Wed, 26 Aug 2015 22:50:53 GMT (envelope-from tuexen@FreeBSD.org) Received: (from tuexen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7QMorfm097151; Wed, 26 Aug 2015 22:50:53 GMT (envelope-from tuexen@FreeBSD.org) Message-Id: <201508262250.t7QMorfm097151@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tuexen set sender to tuexen@FreeBSD.org using -f From: Michael Tuexen Date: Wed, 26 Aug 2015 22:50:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r287178 - 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.20 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: Wed, 26 Aug 2015 22:50:54 -0000 Author: tuexen Date: Wed Aug 26 22:50:53 2015 New Revision: 287178 URL: https://svnweb.freebsd.org/changeset/base/287178 Log: Print the status on the first line of a socket description, not at the last one. This doesn't matter for TCP, but it does for the upcoming SCTP support. PR: 201585 MFC after: 3 weeks Modified: head/usr.bin/sockstat/sockstat.c Modified: head/usr.bin/sockstat/sockstat.c ============================================================================== --- head/usr.bin/sockstat/sockstat.c Wed Aug 26 22:19:53 2015 (r287177) +++ head/usr.bin/sockstat/sockstat.c Wed Aug 26 22:50:53 2015 (r287178) @@ -911,7 +911,7 @@ static void displaysock(struct sock *s, int pos) { void *p; - int hash; + int hash, first; struct addr *laddr, *faddr; struct sock *s_tmp; @@ -924,6 +924,7 @@ displaysock(struct sock *s, int pos) pos += xprintf("6 "); laddr = s->laddr; faddr = s->faddr; + first = 1; while (laddr != NULL || faddr != NULL) { while (pos < 36) pos += xprintf(" "); @@ -975,6 +976,14 @@ displaysock(struct sock *s, int pos) default: abort(); } + if (first && opt_s && s->proto == IPPROTO_TCP) { + while (pos < 80) + pos += xprintf(" "); + if (s->state >= 0 && s->state < TCP_NSTATES) + pos += xprintf("%s", tcpstates[s->state]); + else + pos += xprintf("?"); + } if (laddr != NULL) laddr = laddr->next; if (faddr != NULL) @@ -983,15 +992,9 @@ displaysock(struct sock *s, int pos) xprintf("\n"); pos = 0; } + first = 0; } - if (opt_s && s->proto == IPPROTO_TCP) { - while (pos < 80) - pos += xprintf(" "); - if (s->state >= 0 && s->state < TCP_NSTATES) - pos += xprintf("%s", tcpstates[s->state]); - else - pos += xprintf("?"); - } + xprintf("\n"); } static void @@ -1036,7 +1039,6 @@ display(void) pos += xprintf(" "); pos += xprintf("%d ", xf->xf_fd); displaysock(s, pos); - xprintf("\n"); } } if (opt_j >= 0) @@ -1051,7 +1053,6 @@ display(void) pos += xprintf("%-8s %-10s %-5s %-2s ", "?", "?", "?", "?"); displaysock(s, pos); - xprintf("\n"); } } }