git: 8e7c2e14cffa - main - netstat: display c and C flags properly
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 09 Jun 2023 21:59:14 UTC
The branch main has been updated by rscheff: URL: https://cgit.FreeBSD.org/src/commit/?id=8e7c2e14cffaa33f1f1413f8a3e462611217b8e8 commit 8e7c2e14cffaa33f1f1413f8a3e462611217b8e8 Author: Richard Scheffenegger <rscheff@FreeBSD.org> AuthorDate: 2023-06-09 21:57:00 +0000 Commit: Richard Scheffenegger <rscheff@FreeBSD.org> CommitDate: 2023-06-09 21:58:00 +0000 netstat: display c and C flags properly Restructure c and C flag checks for string length to work properly. Quickly bypass for non TCP protos too. Reviewed By: tuexen Sponsored by: NetApp, Inc. Differential Revision: https://reviews.freebsd.org/D40480 --- usr.bin/netstat/inet.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c index fd1a6ff20e42..691f9d9e912c 100644 --- a/usr.bin/netstat/inet.c +++ b/usr.bin/netstat/inet.c @@ -237,23 +237,20 @@ protopr(u_long off, const char *name, int af1, int proto) if (!pcblist_sysctl(proto, name, &buf)) return; - if (cflag || Cflag) { + if (istcp && (cflag || Cflag)) { fnamelen = strlen("Stack"); cnamelen = strlen("CC"); oxig = xig = (struct xinpgen *)buf; for (xig = (struct xinpgen*)((char *)xig + xig->xig_len); xig->xig_len > sizeof(struct xinpgen); xig = (struct xinpgen *)((char *)xig + xig->xig_len)) { - if (istcp) { - tp = (struct xtcpcb *)xig; - inp = &tp->xt_inp; - } else { + tp = (struct xtcpcb *)xig; + inp = &tp->xt_inp; + if (inp->inp_gencnt > oxig->xig_gen) continue; - } + so = &inp->xi_socket; if (so->xso_protocol != proto) continue; - if (inp->inp_gencnt > oxig->xig_gen) - continue; fnamelen = max(fnamelen, (int)strlen(tp->xt_stack)); cnamelen = max(cnamelen, (int)strlen(tp->xt_cc)); }