xref: /freebsd/share/man/man9/tcp_functions.9 (revision 859f0f0d6bf753c16caa0103a541c69fb6bd5e37)
1cf3c688cSJonathan T. Looney.\"
2cf3c688cSJonathan T. Looney.\" Copyright (c) 2016 Jonathan Looney <jtl@FreeBSD.org>
3cf3c688cSJonathan T. Looney.\" All rights reserved.
4cf3c688cSJonathan T. Looney.\"
5cf3c688cSJonathan T. Looney.\" Redistribution and use in source and binary forms, with or without
6cf3c688cSJonathan T. Looney.\" modification, are permitted provided that the following conditions
7cf3c688cSJonathan T. Looney.\" are met:
8cf3c688cSJonathan T. Looney.\" 1. Redistributions of source code must retain the above copyright
9cf3c688cSJonathan T. Looney.\"    notice, this list of conditions and the following disclaimer.
10cf3c688cSJonathan T. Looney.\" 2. Redistributions in binary form must reproduce the above copyright
11cf3c688cSJonathan T. Looney.\"    notice, this list of conditions and the following disclaimer in the
12cf3c688cSJonathan T. Looney.\"    documentation and/or other materials provided with the distribution.
13cf3c688cSJonathan T. Looney.\"
14cf3c688cSJonathan T. Looney.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15cf3c688cSJonathan T. Looney.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16cf3c688cSJonathan T. Looney.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17cf3c688cSJonathan T. Looney.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
18cf3c688cSJonathan T. Looney.\" ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19cf3c688cSJonathan T. Looney.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20cf3c688cSJonathan T. Looney.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21cf3c688cSJonathan T. Looney.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22cf3c688cSJonathan T. Looney.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23cf3c688cSJonathan T. Looney.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24cf3c688cSJonathan T. Looney.\" SUCH DAMAGE.
25cf3c688cSJonathan T. Looney.\"
26*859f0f0dSMichael Tuexen.Dd July 13, 2024
27cf3c688cSJonathan T. Looney.Dt TCP_FUNCTIONS 9
28cf3c688cSJonathan T. Looney.Os
29cf3c688cSJonathan T. Looney.Sh NAME
30cf3c688cSJonathan T. Looney.Nm tcp_functions
31cf3c688cSJonathan T. Looney.Nd Alternate TCP Stack Framework
32cf3c688cSJonathan T. Looney.Sh SYNOPSIS
33cf3c688cSJonathan T. Looney.In netinet/tcp.h
34cf3c688cSJonathan T. Looney.In netinet/tcp_var.h
35cf3c688cSJonathan T. Looney.Ft int
36cf3c688cSJonathan T. Looney.Fn register_tcp_functions "struct tcp_function_block *blk" "int wait"
37cf3c688cSJonathan T. Looney.Ft int
38dc6a41b9SJonathan T. Looney.Fn register_tcp_functions_as_name "struct tcp_function_block *blk" \
39dc6a41b9SJonathan T. Looney"const char *name" "int wait"
40*859f0f0dSMichael Tuexen.Ft int
41dc6a41b9SJonathan T. Looney.Fn register_tcp_functions_as_names "struct tcp_function_block *blk" \
42dc6a41b9SJonathan T. Looney"int wait" "const char *names[]" "int *num_names"
43dc6a41b9SJonathan T. Looney.Ft int
44cf3c688cSJonathan T. Looney.Fn deregister_tcp_functions "struct tcp_function_block *blk"
45cf3c688cSJonathan T. Looney.Sh DESCRIPTION
46cf3c688cSJonathan T. LooneyThe
47cf3c688cSJonathan T. Looney.Nm
48cf3c688cSJonathan T. Looneyframework allows a kernel developer to implement alternate TCP stacks.
49cf3c688cSJonathan T. LooneyThe alternate stacks can be compiled in the kernel or can be implemented in
50cf3c688cSJonathan T. Looneyloadable kernel modules.
51cf3c688cSJonathan T. LooneyThis functionality is intended to encourage experimentation with the TCP stack
52cf3c688cSJonathan T. Looneyand to allow alternate behaviors to be deployed for different TCP connections
53cf3c688cSJonathan T. Looneyon a single system.
54cf3c688cSJonathan T. Looney.Pp
55cf3c688cSJonathan T. LooneyA system administrator can set a system default stack.
56cf3c688cSJonathan T. LooneyBy default, all TCP connections will use the system default stack.
57cf3c688cSJonathan T. LooneyAdditionally, users can specify a particular stack to use on a per-connection
58cf3c688cSJonathan T. Looneybasis.
59cf3c688cSJonathan T. Looney(See
60cf3c688cSJonathan T. Looney.Xr tcp 4
61cf3c688cSJonathan T. Looneyfor details on setting the system default stack, or selecting a specific stack
62cf3c688cSJonathan T. Looneyfor a given connection.)
63cf3c688cSJonathan T. Looney.Pp
64cf3c688cSJonathan T. LooneyThis man page treats "TCP stacks" as synonymous with "function blocks".
65cf3c688cSJonathan T. LooneyThis is intentional.
66cf3c688cSJonathan T. LooneyA "TCP stack" is a collection of functions that implement a set of behavior.
67cf3c688cSJonathan T. LooneyTherefore, an alternate "function block" defines an alternate "TCP stack".
68cf3c688cSJonathan T. Looney.Pp
69dc6a41b9SJonathan T. LooneyThe
70dc6a41b9SJonathan T. Looney.Fn register_tcp_functions ,
71dc6a41b9SJonathan T. Looney.Fn register_tcp_functions_as_name ,
72dc6a41b9SJonathan T. Looneyand
73dc6a41b9SJonathan T. Looney.Fn register_tcp_functions_as_names
74dc6a41b9SJonathan T. Looneyfunctions request that the system add a specified function block
75dc6a41b9SJonathan T. Looneyand register it for use with a given name.
76dc6a41b9SJonathan T. LooneyModules may register the same function block multiple times with different
77dc6a41b9SJonathan T. Looneynames.
78dc6a41b9SJonathan T. LooneyHowever, names must be globally unique among all registered function blocks.
79dc6a41b9SJonathan T. LooneyAlso, modules may not ever modify the contents of the function block (including
80dc6a41b9SJonathan T. Looneythe name) after it has been registered, unless the module first successfully
81dc6a41b9SJonathan T. Looneyde-registers the function block.
82cf3c688cSJonathan T. Looney.Pp
83cf3c688cSJonathan T. LooneyThe
84cf3c688cSJonathan T. Looney.Fn register_tcp_functions
85dc6a41b9SJonathan T. Looneyfunction requests that the system register the function block with the name
86dc6a41b9SJonathan T. Looneydefined in the function block's
87dc6a41b9SJonathan T. Looney.Va tfb_tcp_block_name
88dc6a41b9SJonathan T. Looneyfield.
89dc6a41b9SJonathan T. LooneyNote that this is the only one of the three registration functions that
90dc6a41b9SJonathan T. Looneyautomatically registers the function block using the name defined in the
91dc6a41b9SJonathan T. Looneyfunction block's
92dc6a41b9SJonathan T. Looney.Va tfb_tcp_block_name
93dc6a41b9SJonathan T. Looneyfield.
94dc6a41b9SJonathan T. LooneyIf a module uses one of the other registration functions, it may request that
95dc6a41b9SJonathan T. Looneythe system register the function block using the name defined in the
96dc6a41b9SJonathan T. Looneyfunction block's
97dc6a41b9SJonathan T. Looney.Va tfb_tcp_block_name
98dc6a41b9SJonathan T. Looneyfield by explicitly providing that name.
99dc6a41b9SJonathan T. Looney.Pp
100dc6a41b9SJonathan T. LooneyThe
101dc6a41b9SJonathan T. Looney.Fn register_tcp_functions_as_name
102dc6a41b9SJonathan T. Looneyfunction requests that the system register the function block with the name
103dc6a41b9SJonathan T. Looneyprovided in the
104dc6a41b9SJonathan T. Looney.Fa name
105dc6a41b9SJonathan T. Looneyargument.
106dc6a41b9SJonathan T. Looney.Pp
107dc6a41b9SJonathan T. LooneyThe
108dc6a41b9SJonathan T. Looney.Fn register_tcp_functions_as_names
109dc6a41b9SJonathan T. Looneyfunction requests that the system register the function block with all the
110dc6a41b9SJonathan T. Looneynames provided in the
111dc6a41b9SJonathan T. Looney.Fa names
112dc6a41b9SJonathan T. Looneyargument.
113dc6a41b9SJonathan T. LooneyThe
114dc6a41b9SJonathan T. Looney.Fa num_names
115dc6a41b9SJonathan T. Looneyargument provides a pointer to the number of names.
116*859f0f0dSMichael TuexenThis number must not exceed TCP_FUNCTION_NAME_NUM_MAX.
117dc6a41b9SJonathan T. LooneyThis function will either succeed in registering all of the names in the array,
118dc6a41b9SJonathan T. Looneyor none of the names in the array.
119dc6a41b9SJonathan T. LooneyOn failure, the
120dc6a41b9SJonathan T. Looney.Fa num_names
121dc6a41b9SJonathan T. Looneyargument is updated with the index number of the entry in the
122dc6a41b9SJonathan T. Looney.Fa names
123dc6a41b9SJonathan T. Looneyarray which the system was processing when it encountered the error.
124cf3c688cSJonathan T. Looney.Pp
125cf3c688cSJonathan T. LooneyThe
126cf3c688cSJonathan T. Looney.Fn deregister_tcp_functions
127cf3c688cSJonathan T. Looneyfunction requests that the system remove a specified function block from the
128cf3c688cSJonathan T. Looneysystem.
129dc6a41b9SJonathan T. LooneyIf this call succeeds, it will completely deregister the function block,
130dc6a41b9SJonathan T. Looneyregardless of the number of names used to register the function block.
131cf3c688cSJonathan T. LooneyIf the call fails because sockets are still using the specified function block,
132cf3c688cSJonathan T. Looneythe system will mark the function block as being in the process of being
133cf3c688cSJonathan T. Looneyremoved.
134cf3c688cSJonathan T. LooneyThis will prevent additional sockets from using the specified function block.
135cf3c688cSJonathan T. LooneyHowever, it will not impact sockets that are already using the function block.
136cf3c688cSJonathan T. Looney.Pp
137dc6a41b9SJonathan T. Looney.Nm
138dc6a41b9SJonathan T. Looneymodules must call one or more of the registration functions during
139dc6a41b9SJonathan T. Looneyinitialization and successfully call the
140dc6a41b9SJonathan T. Looney.Fn deregister_tcp_functions
141dc6a41b9SJonathan T. Looneyfunction prior to allowing the module to be unloaded.
142dc6a41b9SJonathan T. Looney.Pp
143cf3c688cSJonathan T. LooneyThe
144cf3c688cSJonathan T. Looney.Fa blk
145cf3c688cSJonathan T. Looneyargument is a pointer to a
146cf3c688cSJonathan T. Looney.Vt "struct tcp_function_block" ,
147cf3c688cSJonathan T. Looneywhich is explained below (see
148cf3c688cSJonathan T. Looney.Sx Function Block Structure ) .
149cf3c688cSJonathan T. LooneyThe
150cf3c688cSJonathan T. Looney.Fa wait
151cf3c688cSJonathan T. Looneyargument is used as the
152cf3c688cSJonathan T. Looney.Fa flags
153cf3c688cSJonathan T. Looneyargument to
154cf3c688cSJonathan T. Looney.Xr malloc 9 ,
155cf3c688cSJonathan T. Looneyand must be set to one of the valid values defined in that man page.
156cf3c688cSJonathan T. Looney.Ss Function Block Structure
157cf3c688cSJonathan T. LooneyThe
158cf3c688cSJonathan T. Looney.Fa blk argument is a pointer to a
159cf3c688cSJonathan T. Looney.Vt "struct tcp_function_block" ,
160cf3c688cSJonathan T. Looneywhich has the following members:
161cf3c688cSJonathan T. Looney.Bd -literal -offset indent
162cf3c688cSJonathan T. Looneystruct tcp_function_block {
163cf3c688cSJonathan T. Looney	char	tfb_tcp_block_name[TCP_FUNCTION_NAME_LEN_MAX];
164cf3c688cSJonathan T. Looney	int	(*tfb_tcp_output)(struct tcpcb *);
165cf3c688cSJonathan T. Looney	void	(*tfb_tcp_do_segment)(struct mbuf *, struct tcphdr *,
166cf3c688cSJonathan T. Looney			    struct socket *, struct tcpcb *,
167cf3c688cSJonathan T. Looney			    int, int, uint8_t,
168cf3c688cSJonathan T. Looney			    int);
169cf3c688cSJonathan T. Looney	int     (*tfb_tcp_ctloutput)(struct socket *so,
170cf3c688cSJonathan T. Looney			    struct sockopt *sopt,
171cf3c688cSJonathan T. Looney			    struct inpcb *inp, struct tcpcb *tp);
172cf3c688cSJonathan T. Looney	/* Optional memory allocation/free routine */
173cf3c688cSJonathan T. Looney	void	(*tfb_tcp_fb_init)(struct tcpcb *);
174587d67c0SRandall Stewart	void	(*tfb_tcp_fb_fini)(struct tcpcb *, int);
175cf3c688cSJonathan T. Looney	/* Optional timers, must define all if you define one */
176cf3c688cSJonathan T. Looney	int	(*tfb_tcp_timer_stop_all)(struct tcpcb *);
177cf3c688cSJonathan T. Looney	void	(*tfb_tcp_timer_activate)(struct tcpcb *,
178cf3c688cSJonathan T. Looney			    uint32_t, u_int);
179cf3c688cSJonathan T. Looney	int	(*tfb_tcp_timer_active)(struct tcpcb *, uint32_t);
180cf3c688cSJonathan T. Looney	void	(*tfb_tcp_timer_stop)(struct tcpcb *, uint32_t);
18186c9325dSMichael Tuexen	/* Optional function */
182cf3c688cSJonathan T. Looney	void	(*tfb_tcp_rexmit_tmr)(struct tcpcb *);
18386c9325dSMichael Tuexen	/* Mandatory function */
18486c9325dSMichael Tuexen	int	(*tfb_tcp_handoff_ok)(struct tcpcb *);
185587d67c0SRandall Stewart	/* System use */
186cf3c688cSJonathan T. Looney	volatile uint32_t tfb_refcnt;
187cf3c688cSJonathan T. Looney	uint32_t  tfb_flags;
188cf3c688cSJonathan T. Looney};
189cf3c688cSJonathan T. Looney.Ed
190cf3c688cSJonathan T. Looney.Pp
191cf3c688cSJonathan T. LooneyThe
192cf3c688cSJonathan T. Looney.Va tfb_tcp_block_name
193cf3c688cSJonathan T. Looneyfield identifies the unique name of the TCP stack, and should be no longer than
194cf3c688cSJonathan T. LooneyTCP_FUNCTION_NAME_LEN_MAX-1 characters in length.
195cf3c688cSJonathan T. Looney.Pp
196cf3c688cSJonathan T. LooneyThe
197cf3c688cSJonathan T. Looney.Va tfb_tcp_output ,
198cf3c688cSJonathan T. Looney.Va tfb_tcp_do_segment ,
199cf3c688cSJonathan T. Looneyand
200cf3c688cSJonathan T. Looney.Va tfb_tcp_ctloutput
201cf3c688cSJonathan T. Looneyfields are pointers to functions that perform the equivalent actions
202cf3c688cSJonathan T. Looneyas the default
203cf3c688cSJonathan T. Looney.Fn tcp_output ,
204cf3c688cSJonathan T. Looney.Fn tcp_do_segment ,
205cf3c688cSJonathan T. Looneyand
206cf3c688cSJonathan T. Looney.Fn tcp_default_ctloutput
207cf3c688cSJonathan T. Looneyfunctions, respectively.
208cf3c688cSJonathan T. LooneyEach of these function pointers must be non-NULL.
209cf3c688cSJonathan T. Looney.Pp
210cf3c688cSJonathan T. LooneyIf a TCP stack needs to initialize data when a socket first selects the TCP
211cf3c688cSJonathan T. Looneystack (or, when the socket is first opened), it should set a non-NULL
212cf3c688cSJonathan T. Looneypointer in the
213cf3c688cSJonathan T. Looney.Va tfb_tcp_fb_init
214cf3c688cSJonathan T. Looneyfield.
215cf3c688cSJonathan T. LooneyLikewise, if a TCP stack needs to cleanup data when a socket stops using the
216cf3c688cSJonathan T. LooneyTCP stack (or, when the socket is closed), it should set a non-NULL pointer
217cf3c688cSJonathan T. Looneyin the
218cf3c688cSJonathan T. Looney.Va tfb_tcp_fb_fini
219cf3c688cSJonathan T. Looneyfield.
220cf3c688cSJonathan T. Looney.Pp
221587d67c0SRandall StewartIf the
222587d67c0SRandall Stewart.Va tfb_tcp_fb_fini
223587d67c0SRandall Stewartargument is non-NULL, the function to which it points is called when the
224587d67c0SRandall Stewartkernel is destroying the TCP control block or when the socket is transitioning
225587d67c0SRandall Stewartto use a different TCP stack.
226587d67c0SRandall StewartThe function is called with arguments of the TCP control block and an integer
227587d67c0SRandall Stewartflag.
228587d67c0SRandall StewartThe flag will be zero if the socket is transitioning to use another TCP stack
229587d67c0SRandall Stewartor one if the TCP control block is being destroyed.
230587d67c0SRandall Stewart.Pp
231cf3c688cSJonathan T. LooneyIf the TCP stack implements additional timers, the TCP stack should set a
232cf3c688cSJonathan T. Looneynon-NULL pointer in the
233cf3c688cSJonathan T. Looney.Va tfb_tcp_timer_stop_all ,
234cf3c688cSJonathan T. Looney.Va tfb_tcp_timer_activate ,
235cf3c688cSJonathan T. Looney.Va tfb_tcp_timer_active ,
236cf3c688cSJonathan T. Looneyand
237cf3c688cSJonathan T. Looney.Va tfb_tcp_timer_stop
238cf3c688cSJonathan T. Looneyfields.
239cf3c688cSJonathan T. LooneyThese fields should all be
240cf3c688cSJonathan T. Looney.Dv NULL
241cf3c688cSJonathan T. Looneyor should all contain pointers to functions.
242cf3c688cSJonathan T. LooneyThe
243cf3c688cSJonathan T. Looney.Va tfb_tcp_timer_activate ,
244cf3c688cSJonathan T. Looney.Va tfb_tcp_timer_active ,
245cf3c688cSJonathan T. Looneyand
246cf3c688cSJonathan T. Looney.Va tfb_tcp_timer_stop
247cf3c688cSJonathan T. Looneyfunctions will be called when the
248cf3c688cSJonathan T. Looney.Fn tcp_timer_activate ,
249cf3c688cSJonathan T. Looney.Fn tcp_timer_active ,
250cf3c688cSJonathan T. Looneyand
251cf3c688cSJonathan T. Looney.Fn tcp_timer_stop
252cf3c688cSJonathan T. Looneyfunctions, respectively, are called with a timer type other than the standard
253cf3c688cSJonathan T. Looneytypes.
254cf3c688cSJonathan T. LooneyThe functions defined by the TCP stack have the same semantics (both for
255cf3c688cSJonathan T. Looneyarguments and return values) as the normal timer functions they supplement.
256cf3c688cSJonathan T. Looney.Pp
257cf3c688cSJonathan T. LooneyAdditionally, a stack may define its own actions to take when the retransmit
258cf3c688cSJonathan T. Looneytimer fires by setting a non-NULL function pointer in the
259cf3c688cSJonathan T. Looney.Va tfb_tcp_rexmit_tmr
260cf3c688cSJonathan T. Looneyfield.
261cf3c688cSJonathan T. LooneyThis function is called very early in the process of handling a retransmit
262cf3c688cSJonathan T. Looneytimer.
263cf3c688cSJonathan T. LooneyHowever, care must be taken to ensure the retransmit timer leaves the
264cf3c688cSJonathan T. LooneyTCP control block in a valid state for the remainder of the retransmit
265cf3c688cSJonathan T. Looneytimer logic.
266cf3c688cSJonathan T. Looney.Pp
26786c9325dSMichael TuexenA user may select a new TCP stack before calling at any time.
26886c9325dSMichael TuexenTherefore, the function pointer
269587d67c0SRandall Stewart.Va tfb_tcp_handoff_ok
27086c9325dSMichael Tuexenfield must be non-NULL.
27186c9325dSMichael TuexenIf a user attempts to select that TCP stack, the kernel will call the function
27286c9325dSMichael Tuexenpointed to by the
273587d67c0SRandall Stewart.Va tfb_tcp_handoff_ok
274587d67c0SRandall Stewartfield.
275587d67c0SRandall StewartThe function should return 0 if the user is allowed to switch the socket to use
27686c9325dSMichael Tuexenthe TCP stack. In this case, the kernel will call the function pointed to by
27786c9325dSMichael Tuexen.Va tfb_tcp_fb_init
27886c9325dSMichael Tuexenif this function pointer is non-NULL and finally perform the stack switch.
27986c9325dSMichael TuexenIf the user is not allowed to switch the socket, the function should undo any
28086c9325dSMichael Tuexenchanges it made to the connection state configuration and return an error code,
28186c9325dSMichael Tuexenwhich will be returned to the user.
282587d67c0SRandall Stewart.Pp
283cf3c688cSJonathan T. LooneyThe
284cf3c688cSJonathan T. Looney.Va tfb_refcnt
285cf3c688cSJonathan T. Looneyand
286cf3c688cSJonathan T. Looney.Va tfb_flags
287cf3c688cSJonathan T. Looneyfields are used by the kernel's TCP code and will be initialized when the
288cf3c688cSJonathan T. LooneyTCP stack is registered.
289cf3c688cSJonathan T. Looney.Ss Requirements for Alternate TCP Stacks
290cf3c688cSJonathan T. LooneyIf the TCP stack needs to store data beyond what is stored in the default
291cf3c688cSJonathan T. LooneyTCP control block, the TCP stack can initialize its own per-connection storage.
292cf3c688cSJonathan T. LooneyThe
293cf3c688cSJonathan T. Looney.Va t_fb_ptr
294cf3c688cSJonathan T. Looneyfield in the
295cf3c688cSJonathan T. Looney.Vt "struct tcpcb"
296cf3c688cSJonathan T. Looneycontrol block structure has been reserved to hold a pointer to this
297cf3c688cSJonathan T. Looneyper-connection storage.
298cf3c688cSJonathan T. LooneyIf the TCP stack uses this alternate storage, it should understand that the
299cf3c688cSJonathan T. Looneyvalue of the
300cf3c688cSJonathan T. Looney.Va t_fb_ptr
301cf3c688cSJonathan T. Looneypointer may not be initialized to
302cf3c688cSJonathan T. Looney.Dv NULL .
303cf3c688cSJonathan T. LooneyTherefore, it should use a
304cf3c688cSJonathan T. Looney.Va tfb_tcp_fb_init
305cf3c688cSJonathan T. Looneyfunction to initialize this field.
306cf3c688cSJonathan T. LooneyAdditionally, it should use a
307cf3c688cSJonathan T. Looney.Va tfb_tcp_fb_fini
308cf3c688cSJonathan T. Looneyfunction to deallocate storage when the socket is closed.
309cf3c688cSJonathan T. Looney.Pp
310cf3c688cSJonathan T. LooneyIt is understood that alternate TCP stacks may keep different sets of data.
311cf3c688cSJonathan T. LooneyHowever, in order to ensure that data is available to both the user and the
312cf3c688cSJonathan T. Looneyrest of the system in a standardized format, alternate TCP stacks must
313cf3c688cSJonathan T. Looneyupdate all fields in the TCP control block to the greatest extent practical.
314cf3c688cSJonathan T. Looney.Sh RETURN VALUES
315cf3c688cSJonathan T. LooneyThe
316dc6a41b9SJonathan T. Looney.Fn register_tcp_functions ,
317dc6a41b9SJonathan T. Looney.Fn register_tcp_functions_as_name ,
318dc6a41b9SJonathan T. Looney.Fn register_tcp_functions_as_names ,
319cf3c688cSJonathan T. Looneyand
320cf3c688cSJonathan T. Looney.Fn deregister_tcp_functions
321cf3c688cSJonathan T. Looneyfunctions return zero on success and non-zero on failure.
322cf3c688cSJonathan T. LooneyIn particular, the
323cf3c688cSJonathan T. Looney.Fn deregister_tcp_functions
324cf3c688cSJonathan T. Looneywill return
325cf3c688cSJonathan T. Looney.Er EBUSY
326cf3c688cSJonathan T. Looneyuntil no more connections are using the specified TCP stack.
327cf3c688cSJonathan T. LooneyA module calling
328cf3c688cSJonathan T. Looney.Fn deregister_tcp_functions
329cf3c688cSJonathan T. Looneymust be prepared to wait until all connections have stopped using the
330cf3c688cSJonathan T. Looneyspecified TCP stack.
331cf3c688cSJonathan T. Looney.Sh ERRORS
332cf3c688cSJonathan T. LooneyThe
333*859f0f0dSMichael Tuexen.Fn register_tcp_functions ,
334*859f0f0dSMichael Tuexen.Fn register_tcp_functions_as_name ,
335*859f0f0dSMichael Tuexenand
336*859f0f0dSMichael Tuexen.Fn register_tcp_functions_as_names
337*859f0f0dSMichael Tuexenfunctions will fail if:
338cf3c688cSJonathan T. Looney.Bl -tag -width Er
339cf3c688cSJonathan T. Looney.It Bq Er EINVAL
340cf3c688cSJonathan T. LooneyAny of the members of the
341cf3c688cSJonathan T. Looney.Fa blk
342cf3c688cSJonathan T. Looneyargument are set incorrectly.
343cf3c688cSJonathan T. Looney.It Bq Er ENOMEM
344cf3c688cSJonathan T. LooneyThe function could not allocate memory for its internal data.
345cf3c688cSJonathan T. Looney.It Bq Er EALREADY
346*859f0f0dSMichael TuexenThe
347*859f0f0dSMichael Tuexen.Fa blk
348*859f0f0dSMichael Tuexenis already registered or a function block is already registered with the same
349*859f0f0dSMichael Tuexenname.
350*859f0f0dSMichael Tuexen.El
351*859f0f0dSMichael TuexenAdditionally,
352*859f0f0dSMichael Tuexen.Fn register_tcp_functions_as_names
353*859f0f0dSMichael Tuexenwill fail if:
354*859f0f0dSMichael Tuexen.Bl -tag -width Er
355*859f0f0dSMichael Tuexen.It Bq Er E2BIG
356*859f0f0dSMichael TuexenThe number of names pointed to by the
357*859f0f0dSMichael Tuexen.Fa num_names
358*859f0f0dSMichael Tuexenargument is larger than TCP_FUNCTION_NAME_NUM_MAX.
359cf3c688cSJonathan T. Looney.El
360cf3c688cSJonathan T. LooneyThe
361cf3c688cSJonathan T. Looney.Fn deregister_tcp_functions
362cf3c688cSJonathan T. Looneyfunction will fail if:
363cf3c688cSJonathan T. Looney.Bl -tag -width Er
364cf3c688cSJonathan T. Looney.It Bq Er EPERM
365cf3c688cSJonathan T. LooneyThe
366cf3c688cSJonathan T. Looney.Fa blk
367cf3c688cSJonathan T. Looneyargument references the kernel's compiled-in default function block.
368cf3c688cSJonathan T. Looney.It Bq Er EBUSY
369cf3c688cSJonathan T. LooneyThe function block is still in use by one or more sockets, or is defined as
370cf3c688cSJonathan T. Looneythe current default function block.
371cf3c688cSJonathan T. Looney.It Bq Er ENOENT
372cf3c688cSJonathan T. LooneyThe
373cf3c688cSJonathan T. Looney.Fa blk
374cf3c688cSJonathan T. Looneyargument references a function block that is not currently registered.
375c85d7166SChristian Brueffer.El
376cf3c688cSJonathan T. Looney.Sh SEE ALSO
377587d67c0SRandall Stewart.Xr connect 2 ,
378587d67c0SRandall Stewart.Xr listen 2 ,
379587d67c0SRandall Stewart.Xr tcp 4 ,
380587d67c0SRandall Stewart.Xr malloc 9
381cf3c688cSJonathan T. Looney.Sh HISTORY
382cf3c688cSJonathan T. LooneyThis framework first appeared in
383cf3c688cSJonathan T. Looney.Fx 11.0 .
384cf3c688cSJonathan T. Looney.Sh AUTHORS
385cf3c688cSJonathan T. Looney.An -nosplit
386cf3c688cSJonathan T. LooneyThe
387cf3c688cSJonathan T. Looney.Nm
388cf3c688cSJonathan T. Looneyframework was written by
389cf3c688cSJonathan T. Looney.An Randall Stewart Aq Mt rrs@FreeBSD.org .
390cf3c688cSJonathan T. Looney.Pp
391cf3c688cSJonathan T. LooneyThis manual page was written by
392cf3c688cSJonathan T. Looney.An Jonathan Looney Aq Mt jtl@FreeBSD.org .
393