The computation of the length was not taking into account that IPv6 endpoints, which are not IPv6 only, have a suffix of 46.
Details
Details
Diff Detail
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
Comment Actions
Can you give an example of the incorrect output? Does it matter whether "-q" is in use?
Comment Actions
Here is the output without the fix:
tuexen@ampere32:~ % sockstat -Psctp USER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDRESS nobody thttpd 3572 4 sctp46 10.0.1.86:80 *:* ?? ?? ?? ?? ?? 192.168.1.86:80 ?? ?? ?? ?? ?? ?? 2a02:c6a0:4015:11::86 ?? ?? ?? ?? ?? ?? fe80::6a05:caff:fe92: ?? ?? ?? ?? ?? ?? 212.201.121.86:80 ?? ?? ?? ?? ?? ?? 127.0.0.1:80 ?? ?? ?? ?? ?? ?? fe80::1%lo0:80 ?? ?? ?? ?? ?? ?? ::1:80 ??
Here is the output without the fix and using -q:
tuexen@ampere32:~ % sockstat -qPsctp nobody thttpd 3572 4 sctp46 10.0.1.86:80 *:* ?? ?? ?? ?? ?? 192.168.1.86:80 ?? ?? ?? ?? ?? ?? 2a02:c6a0:4015:11::86 ?? ?? ?? ?? ?? ?? fe80::6a05:caff:fe92: ?? ?? ?? ?? ?? ?? 212.201.121.86:80 ?? ?? ?? ?? ?? ?? 127.0.0.1:80 ?? ?? ?? ?? ?? ?? fe80::1%lo0:80 ?? ?? ?? ?? ?? ?? ::1:80 ??
In both cases the problem is that sctp46 is too long and you have the misalignment in the first row. In case sctp4 and sctp6 it would look OK.
With the fix the output is:
tuexen@ampere32:~ % sockstat -Psctp USER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDRESS nobody thttpd 3572 4 sctp46 10.0.1.86:80 *:* ?? ?? ?? ?? ?? 192.168.1.86:80 ?? ?? ?? ?? ?? ?? 2a02:c6a0:4015:11::86 ?? ?? ?? ?? ?? ?? fe80::6a05:caff:fe92: ?? ?? ?? ?? ?? ?? 212.201.121.86:80 ?? ?? ?? ?? ?? ?? 127.0.0.1:80 ?? ?? ?? ?? ?? ?? fe80::1%lo0:80 ?? ?? ?? ?? ?? ?? ::1:80 ??
The problem is that the PROTO column is computed with:
snprintf(buf, bufsize, "%s%s%s",
s->protoname,
s->vflag & INP_IPV4 ? "4" : "",
s->vflag & INP_IPV6 ? "6" : "");whereas the length is computed by:
len = strlen(s->protoname);
if (s->vflag & (INP_IPV4 | INP_IPV6))
len += 1;So in the 46 case, you are off by one character.
Comment Actions
the same issue will come up with udplite (udplite4, udplite6, and udplite46), since the protocol name can be longer than PROTO.
I plan to add this soon.