]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.bin/sockstat/sockstat.1
Move SYSCTL_ADD_PROC() to unlocked context in if_ure to avoid lock order reversal.
[FreeBSD/FreeBSD.git] / usr.bin / sockstat / sockstat.1
1 .\"-
2 .\" Copyright (c) 1999 Dag-Erling Coïdan Smørgrav
3 .\" All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
7 .\" are met:
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\"    notice, this list of conditions and the following disclaimer
10 .\"    in this position and unchanged.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\"    notice, this list of conditions and the following disclaimer in the
13 .\"    documentation and/or other materials provided with the distribution.
14 .\" 3. The name of the author may not be used to endorse or promote products
15 .\"    derived from this software without specific prior written permission.
16 .\"
17 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 .\"
28 .\" $FreeBSD$
29 .\"
30 .Dd September 13, 2020
31 .Dt SOCKSTAT 1
32 .Os
33 .Sh NAME
34 .Nm sockstat
35 .Nd list open sockets
36 .Sh SYNOPSIS
37 .Nm
38 .Op Fl 46CcLlSsUuvw
39 .Op Fl j Ar jid
40 .Op Fl p Ar ports
41 .Op Fl P Ar protocols
42 .Sh DESCRIPTION
43 The
44 .Nm
45 command lists open Internet or
46 .Ux
47 domain sockets.
48 .Pp
49 The following options are available:
50 .Bl -tag -width Fl
51 .It Fl 4
52 Show
53 .Dv AF_INET
54 (IPv4) sockets.
55 .It Fl 6
56 Show
57 .Dv AF_INET6
58 (IPv6) sockets.
59 .It Fl C
60 Display the congestion control module, if applicable.
61 This is currently only implemented for TCP.
62 .It Fl c
63 Show connected sockets.
64 .It Fl j Ar jail
65 Show only sockets belonging to the specified jail ID or name.
66 .It Fl L
67 Only show Internet sockets if the local and foreign addresses are not
68 in the loopback network prefix
69 .Li 127.0.0.0/8 ,
70 or do not contain the IPv6 loopback address
71 .Li ::1 .
72 .It Fl l
73 Show listening sockets.
74 .It Fl p Ar ports
75 Only show Internet sockets if the local or foreign port number
76 is on the specified list.
77 The
78 .Ar ports
79 argument is a comma-separated list of port numbers and ranges
80 specified as first and last port separated by a dash.
81 .It Fl P Ar protocols
82 Only show sockets of the specified
83 .Ar protocols .
84 The
85 .Ar protocols
86 argument is a comma-separated list of protocol names,
87 as they are defined in
88 .Xr protocols 5 .
89 .It Fl q
90 Quiet mode, do not print the header line.
91 .It Fl S
92 Display the protocol stack, if applicable.
93 This is currently only implemented for TCP.
94 .It Fl s
95 Display the protocol state, if applicable.
96 This is currently only implemented for SCTP and TCP.
97 .It Fl U
98 Display the remote UDP encapsulation port number, if applicable.
99 This is currently only implemented for SCTP.
100 .It Fl u
101 Show
102 .Dv AF_LOCAL
103 .Pq Ux
104 sockets.
105 .It Fl v
106 Verbose mode.
107 .It Fl w
108 Use wider field size for displaying addresses.
109 .El
110 .Pp
111 If neither
112 .Fl 4 , 6
113 or
114 .Fl u
115 is specified,
116 .Nm
117 will list sockets in all three domains.
118 .Pp
119 If neither
120 .Fl c
121 or
122 .Fl l
123 is specified,
124 .Nm
125 will list both listening and connected sockets.
126 .Pp
127 The information listed for each
128 socket is:
129 .Bl -tag -width "FOREIGN ADDRESS"
130 .It Li USER
131 The user who owns the socket.
132 .It Li COMMAND
133 The command which holds the socket.
134 .It Li PID
135 The process ID of the command which holds the socket.
136 .It Li FD
137 The file descriptor number of the socket.
138 .It Li PROTO
139 The transport protocol associated with the socket for Internet
140 sockets, or the type of socket
141 .Pq stream, datagram, or seqpacket
142 for
143 .Ux
144 sockets.
145 .It Li LOCAL ADDRESS
146 For Internet sockets, this is the address the local end of the socket
147 is bound to (see
148 .Xr getsockname 2 ) .
149 For bound
150 .Ux
151 sockets, it is the socket's filename.
152 For other
153 .Ux
154 sockets, it is a right arrow followed by the endpoint's filename, or
155 .Dq Li ??
156 if the endpoint could not be determined.
157 .It Li FOREIGN ADDRESS
158 (Internet sockets only)
159 The address the foreign end of the socket is bound to (see
160 .Xr getpeername 2 ) .
161 .It Li ENCAPS
162 The remote UDP encapsulation port number if
163 .Fl U
164 is specified (only for SCTP).
165 .It Li PATH STATE
166 The path state if
167 .Fl s
168 is specified (only for SCTP).
169 .It Li CONN STATE
170 The connection state if
171 .Fl s
172 is specified (only for SCTP or TCP).
173 .It Li STACK
174 The protocol stack if
175 .Fl S
176 is specified (only for TCP).
177 .It Li CC
178 The congestion control if
179 .Fl C
180 is specified (only for TCP).
181 .El
182 .Pp
183 If a socket is associated with more than one file descriptor,
184 it is shown multiple times.
185 If a socket is not associated with any file descriptor,
186 the first four columns have no meaning.
187 .Sh EXAMPLES
188 Show information for IPv4 sockets listening on port 22 using protocol
189 TCP:
190 .Bd -literal -offset indent
191 $ sockstat -4 -l -P tcp -p 22
192 .Ed
193 .Pp
194 Show information for sockets using either TCP or UDP, if neither, the local nor
195 the foreign addresses are in the loopback network:
196 .Bd -literal -offset indent
197 $ sockstat -L -P tcp,udp
198 .Ed
199 .Pp
200 Show TCP IPv6 sockets which are listening and connected (default):
201 .Bd -literal -offset indent
202 $ sockstat -6 -P tcp
203 .Ed
204 .Sh SEE ALSO
205 .Xr fstat 1 ,
206 .Xr netstat 1 ,
207 .Xr procstat 1 ,
208 .Xr inet 4 ,
209 .Xr inet6 4 ,
210 .Xr protocols 5
211 .Sh HISTORY
212 The
213 .Nm
214 command appeared in
215 .Fx 3.1 .
216 .Sh AUTHORS
217 The
218 .Nm
219 command and this manual page were written by
220 .An Dag-Erling Sm\(/orgrav Aq Mt des@FreeBSD.org .