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
This commit is contained in:
parent
af9ce4e9bb
commit
8e7c2e14cf
@ -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 {
|
||||
continue;
|
||||
}
|
||||
if (so->xso_protocol != proto)
|
||||
continue;
|
||||
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;
|
||||
fnamelen = max(fnamelen, (int)strlen(tp->xt_stack));
|
||||
cnamelen = max(cnamelen, (int)strlen(tp->xt_cc));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user