mirror of
https://github.com/freebsd/freebsd-src
synced 2024-07-22 10:48:02 +00:00
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))
|
if (!pcblist_sysctl(proto, name, &buf))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (cflag || Cflag) {
|
if (istcp && (cflag || Cflag)) {
|
||||||
fnamelen = strlen("Stack");
|
fnamelen = strlen("Stack");
|
||||||
cnamelen = strlen("CC");
|
cnamelen = strlen("CC");
|
||||||
oxig = xig = (struct xinpgen *)buf;
|
oxig = xig = (struct xinpgen *)buf;
|
||||||
for (xig = (struct xinpgen*)((char *)xig + xig->xig_len);
|
for (xig = (struct xinpgen*)((char *)xig + xig->xig_len);
|
||||||
xig->xig_len > sizeof(struct xinpgen);
|
xig->xig_len > sizeof(struct xinpgen);
|
||||||
xig = (struct xinpgen *)((char *)xig + xig->xig_len)) {
|
xig = (struct xinpgen *)((char *)xig + xig->xig_len)) {
|
||||||
if (istcp) {
|
tp = (struct xtcpcb *)xig;
|
||||||
tp = (struct xtcpcb *)xig;
|
inp = &tp->xt_inp;
|
||||||
inp = &tp->xt_inp;
|
|
||||||
} else {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (so->xso_protocol != proto)
|
|
||||||
continue;
|
|
||||||
if (inp->inp_gencnt > oxig->xig_gen)
|
if (inp->inp_gencnt > oxig->xig_gen)
|
||||||
continue;
|
continue;
|
||||||
|
so = &inp->xi_socket;
|
||||||
|
if (so->xso_protocol != proto)
|
||||||
|
continue;
|
||||||
fnamelen = max(fnamelen, (int)strlen(tp->xt_stack));
|
fnamelen = max(fnamelen, (int)strlen(tp->xt_stack));
|
||||||
cnamelen = max(cnamelen, (int)strlen(tp->xt_cc));
|
cnamelen = max(cnamelen, (int)strlen(tp->xt_cc));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue