aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/tcpsso/tcpsso.8
blob: 37968c8afa543cebbdd373dd886ba70a1ee286fa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
.\"
.\" SPDX-License-Identifier: BSD-2-Clause
.\"
.\" Copyright (c) 2022 Michael Tuexen <tuexen@FreeBSD.org>
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd January 14, 2024
.Dt TCPSSO 8
.Os
.Sh NAME
.Nm tcpsso
.Nd set a socket option on a TCP endpoint
.Sh SYNOPSIS
.Nm
.Fl i Ar id
.Op Ar level
.Ar optname
.Ar optval
.Nm
.Fl a
.Op Ar level
.Ar optname
.Ar optval
.Nm
.Fl C Ar cc-algo
.Op Fl S Ar stack
.Op Fl s Ar state
.Op Ar level
.Ar optname
.Ar optval
.Nm
.Op Fl C Ar cc-algo
.Fl S Ar stack
.Op Fl s Ar state
.Op Ar level
.Ar optname
.Ar optval
.Nm
.Op Fl C Ar cc-algo
.Op Fl S Ar stack
.Fl s Ar state
.Op Ar level
.Ar optname
.Ar optval
.Sh DESCRIPTION
The
.Nm
command applies a
.Ar level
level socket option with name
.Ar optname
and value
.Ar optval
on a TCP endpoint from the command line.
.Pp
TCP endpoints in the
.Dv SYN_RCVD
state can only be handled by
.Nm
if their prior state was
.Dv SYN_SENT .
.Pp
.Op Ar level
can be specified as a non-negative number or a symbolic name like
.Dv SOL_SOCKET ,
.Dv IPPROTO_IP ,
.Dv IPPROTO_IPV6 ,
or
.Dv IPPROTO_TCP .
If not specified,
.Nm
deduces the level from
.Ar optname ,
if provided as a symbolic name.
If that is not the case,
.Dv IPPROTO_TCP
is used.
.Pp
.Ar optname
can be specified as a non-negative number or a symbolic name like
.Dv SO_DEBUG ,
.Dv IP_TOS ,
.Dv IPV6_TCLASS ,
.Dv TCP_LOG ,
.Dv TCP_CONGESTION ,
or
.Dv TCP_FUNCTION_BLK .
.Pp
.Ar optval
can be an integer value, which will be converted to a binary value and
passed as an int value.
If it cannot be parsed as an integer value, it will be processed as a string.
If the
.Ar optname
is
.Dv TCP_FUNCTION_BLK
then
.Ar optval
is converted to a
.Vt "struct tcp_function_set" .
.Pp
If
.Fl i Ar id
is specified then
.Nm
will apply the socket option to the TCP endpoint with the
.Dv inp_gencnt
provided as
.Ar id .
The
.Dv inp_gencnt
for existing TCP endpoints can be determined by using
.Xr sockstat 1 .
.Pp
If
.Fl a
is specified then
.Nm
will apply the socket option to all TCP endpoints subject to the above state
restrictions.
.Pp
If
.Fl C Ar cc-algo
is specified then
.Nm
will apply the socket option to all TCP endpoints using the TCP
congestion control algorithm
.Ar cc-algo
and subject to the above state restrictions.
.Pp
If
.Fl S Ar stack
is specified then
.Nm
will apply the socket option to all TCP endpoints using the TCP
stack
.Ar stack
and subject to the above state restrictions.
.Pp
If
.Fl s Ar state
is specified then
.Nm
will apply the socket option to all TCP endpoints being in the state
.Ar state .
.Ar state
is one of
.Dv CLOSED ,
.Dv LISTEN ,
.Dv SYN_SENT ,
.Dv SYN_RCVD ,
.Dv ESTABLISHED ,
.Dv CLOSE_WAIT ,
.Dv FIN_WAIT_1 ,
.Dv CLOSING ,
.Dv LAST_ACK ,
.Dv FIN_WAIT_2,
or
.Dv TIME_WAIT .
Using
.Dv SYN_RCVD
only applies to TCP endpoints in the state
.Dv SYN_RCVD
if their prior state was
.Dv SYN_SENT .
.Pp
If multiple of
.Fl C Ar cc-algo ,
.Fl S Ar stack ,
and
.Fl s Ar state
are specified,
.Nm
will apply the socket option to all TCP endpoints using the congestion
control algorithm
.Ar cc-algo ,
being in the state
.Ar state ,
and using the TCP stack
.Ar stack ,
if specified.
.Pp
If none of the
.Fl a ,
.Fl C ,
.Fl S ,
or
.Fl s
options are specified then the option
.Fl i
must be specified.
.Sh EXIT STATUS
.Ex -std
.Sh EXAMPLES
To diagnose a problem with a particular TCP connection to
.Xr sshd 8 ,
first determine its
.Dv inp_gencnt
using
.Xr sockstat 1 :
.Bd -literal -offset indent
# sockstat -4 -c -i -p 22 -P tcp -q
root     sshd       827   4  tcp4 \e
	192.168.1.1:22        192.168.1.2:53736     435
.Ed
.Pp
Then, use the following command to enable Black Box Logging on it:
.Bd -literal -offset indent
# tcpsso -i 435 TCP_LOG 4
.Ed
.Pp
To switch all TCP endpoints from using the freebsd stack to the rack stack use:
.Bd -literal -offset indent
# tcpsso -S freebsd TCP_FUNCTION_BLK rack
.Ed
.Pp
The following command will set the congestion control module of all TCP
endpoints currently using cubic as its congestion control algorithm to the
congestion control algorithm newreno:
.Bd -literal -offset indent
# tcpsso -C cubic TCP_CONGESTION newreno
.Ed
.Sh SEE ALSO
.Xr sockstat 1 ,
.Xr setsockopt 2 ,
.Xr tcp 4 ,
.Xr tcp_functions 9
.Sh HISTORY
The
.Nm
command first appeared in
.Fx 14 .
.Sh AUTHORS
.An Michael Tuexen Aq Mt tuexen@FreeBSD.org