Page MenuHomeFreeBSD

sockstat: don't use getprotoent(3)
ClosedPublic

Authored by glebius on Mon, Jun 8, 11:22 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Jun 20, 1:54 PM
Unknown Object (File)
Fri, Jun 19, 1:42 AM
Unknown Object (File)
Thu, Jun 18, 8:15 PM
Unknown Object (File)
Thu, Jun 18, 1:43 PM
Unknown Object (File)
Thu, Jun 18, 12:27 PM
Unknown Object (File)
Wed, Jun 17, 10:30 PM
Unknown Object (File)
Wed, Jun 17, 11:48 AM
Unknown Object (File)
Mon, Jun 15, 10:04 PM
Subscribers

Details

Summary

This removes requirement for existence of obsolete IPPROTO_DIVERT in
<netinet/in.h> and the 'divert' entry in /etc/protocols.

Also, this avoids running through the nsdispatch(3) machinery on startup,
cutting down about 20 syscalls, three of which are open(2). The code of
sockstat(1) itself is also reduced.

The only UI change for a normal execution is that now the divert(4)
sockets are reported as "divert4" instead of "div4". The prefix "4"
itself is also incorrect, as divert(4) is not a part of IPv4. This will
be addressed in a separate change.

There is small UI change for incorrect runs. Previously protocols listed
in /etc/protocols, but not supported, would err out like this:

  1. sockstat -P ggp sockstat: protocol 3 not supported

And non-existent protocols would err out like this:

  1. sockstat -P foo sockstat: cap_getprotobyname: No error: 0 USER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDRESS

Now both cases will consistently err:

sockstat: protocol foo not supported

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Forgot manual page changes.

This revision is now accepted and ready to land.Thu, Jun 11, 7:33 PM
This revision was automatically updated to reflect the committed changes.