]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/systemd.socket.xml
socket-util: add AF_VSOCK address family
[thirdparty/systemd.git] / man / systemd.socket.xml
CommitLineData
8dd4c05b 1<?xml version='1.0'?> <!--*- Mode: nxml; nxml-child-indent: 2; indent-tabs-mode: nil -*-->
1f812fea 2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
12b42c76 3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
1f812fea
LP
4
5<!--
6 This file is part of systemd.
7
8 Copyright 2010 Lennart Poettering
9
10 systemd is free software; you can redistribute it and/or modify it
5430f7f2
LP
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
1f812fea
LP
13 (at your option) any later version.
14
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5430f7f2 18 Lesser General Public License for more details.
1f812fea 19
5430f7f2 20 You should have received a copy of the GNU Lesser General Public License
1f812fea
LP
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22-->
23
24<refentry id="systemd.socket">
798d3a52
ZJS
25 <refentryinfo>
26 <title>systemd.socket</title>
27 <productname>systemd</productname>
28
29 <authorgroup>
30 <author>
31 <contrib>Developer</contrib>
32 <firstname>Lennart</firstname>
33 <surname>Poettering</surname>
34 <email>lennart@poettering.net</email>
35 </author>
36 </authorgroup>
37 </refentryinfo>
38
39 <refmeta>
40 <refentrytitle>systemd.socket</refentrytitle>
41 <manvolnum>5</manvolnum>
42 </refmeta>
43
44 <refnamediv>
45 <refname>systemd.socket</refname>
46 <refpurpose>Socket unit configuration</refpurpose>
47 </refnamediv>
48
49 <refsynopsisdiv>
50 <para><filename><replaceable>socket</replaceable>.socket</filename></para>
51 </refsynopsisdiv>
52
53 <refsect1>
54 <title>Description</title>
55
56 <para>A unit configuration file whose name ends in
57 <literal>.socket</literal> encodes information about an IPC or
58 network socket or a file system FIFO controlled and supervised by
59 systemd, for socket-based activation.</para>
60
61 <para>This man page lists the configuration options specific to
62 this unit type. See
63 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>
64 for the common options of all unit configuration files. The common
65 configuration items are configured in the generic [Unit] and
66 [Install] sections. The socket specific configuration options are
67 configured in the [Socket] section.</para>
68
69 <para>Additional options are listed in
70 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
71 which define the execution environment the
72 <option>ExecStartPre=</option>, <option>ExecStartPost=</option>,
73 <option>ExecStopPre=</option> and <option>ExecStopPost=</option>
74 commands are executed in, and in
75 <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
76 which define the way the processes are terminated, and in
77 <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
78 which configure resource control settings for the processes of the
79 socket.</para>
80
81 <para>For each socket file, a matching service file must exist,
82 describing the service to start on incoming traffic on the socket
83 (see
84 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>
85 for more information about .service files). The name of the
86 .service unit is by default the same as the name of the .socket
87 unit, but can be altered with the <option>Service=</option> option
88 described below. Depending on the setting of the
89 <option>Accept=</option> option described below, this .service
90 unit must either be named like the .socket unit, but with the
91 suffix replaced, unless overridden with <option>Service=</option>;
92 or it must be a template unit named the same way. Example: a
93 socket file <filename>foo.socket</filename> needs a matching
94 service <filename>foo.service</filename> if
95 <option>Accept=false</option> is set. If
96 <option>Accept=true</option> is set, a service template file
97 <filename>foo@.service</filename> must exist from which services
98 are instantiated for each incoming connection.</para>
99
cc4e4df4
LP
100 <para>Unless <varname>DefaultDependencies=</varname> in the <literal>[Unit]</literal> section is set to
101 <option>false</option>, socket units will implicitly have dependencies of type <varname>Requires=</varname> and
102 <varname>After=</varname> on <filename>sysinit.target</filename> as well as dependencies of type
103 <varname>Conflicts=</varname> and <varname>Before=</varname> on <filename>shutdown.target</filename>. These ensure
104 that socket units pull in basic system initialization, and are terminated cleanly prior to system shutdown. Only
105 sockets involved with early boot or late system shutdown should disable this option.</para>
798d3a52
ZJS
106
107 <para>Socket units will have a <varname>Before=</varname>
108 dependency on the service which they trigger added implicitly. No
109 implicit <varname>WantedBy=</varname> or
110 <varname>RequiredBy=</varname> dependency from the socket to the
111 service is added. This means that the service may be started
112 without the socket, in which case it must be able to open sockets
113 by itself. To prevent this, an explicit
114 <varname>Requires=</varname> dependency may be added.</para>
115
116 <para>Socket units may be used to implement on-demand starting of
117 services, as well as parallelized starting of services. See the
118 blog stories linked at the end for an introduction.</para>
119
120 <para>Note that the daemon software configured for socket
121 activation with socket units needs to be able to accept sockets
122 from systemd, either via systemd's native socket passing interface
123 (see
124 <citerefentry><refentrytitle>sd_listen_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry>
125 for details) or via the traditional
b5c7d097 126 <citerefentry project='freebsd'><refentrytitle>inetd</refentrytitle><manvolnum>8</manvolnum></citerefentry>-style
798d3a52
ZJS
127 socket passing (i.e. sockets passed in via standard input and
128 output, using <varname>StandardInput=socket</varname> in the
129 service file).</para>
130 </refsect1>
131
c129bd5d
LP
132 <refsect1>
133 <title>Automatic Dependencies</title>
134
135 <para>Socket units automatically gain a <varname>Before=</varname>
136 dependency on the service units they activate.</para>
137
138 <para>Socket units referring to file system paths (such as AF_UNIX
139 sockets or FIFOs) implicitly gain <varname>Requires=</varname> and
140 <varname>After=</varname> dependencies on all mount units
141 necessary to access those paths.</para>
142
143 <para>Socket units using the <varname>BindToDevice=</varname>
144 setting automatically gain a <varname>BindsTo=</varname> and
145 <varname>After=</varname> dependency on the device unit
146 encapsulating the specified network interface.</para>
147
148 <para>If <varname>DefaultDependencies=yes</varname> is set (the
149 default), socket units automatically gain a
150 <varname>Before=</varname> dependency on
151 <filename>sockets.target</filename>. They also gain a pair of
152 <varname>After=</varname> and <varname>Requires=</varname>
153 dependency on <filename>sysinit.target</filename>, and a pair of
154 <varname>Before=</varname> and <varname>Conflicts=</varname>
155 dependencies on <filename>shutdown.target</filename>. These
156 dependencies ensure that the socket unit is started before normal
157 services at boot, and is stopped on shutdown.</para>
158
159 <para>Additional implicit dependencies may be added as result of
160 execution and resource control parameters as documented in
161 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>
162 and
163 <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
164 </refsect1>
165
798d3a52
ZJS
166 <refsect1>
167 <title>Options</title>
168
169 <para>Socket files must include a [Socket] section, which carries
170 information about the socket or FIFO it supervises. A number of
171 options that may be used in this section are shared with other
172 unit types. These options are documented in
173 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>
174 and
175 <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
176 The options specific to the [Socket] section of socket units are
177 the following:</para>
178
179 <variablelist class='unit-directives'>
180 <varlistentry>
181 <term><varname>ListenStream=</varname></term>
182 <term><varname>ListenDatagram=</varname></term>
183 <term><varname>ListenSequentialPacket=</varname></term>
184 <listitem><para>Specifies an address to listen on for a stream
185 (<constant>SOCK_STREAM</constant>), datagram
186 (<constant>SOCK_DGRAM</constant>), or sequential packet
187 (<constant>SOCK_SEQPACKET</constant>) socket, respectively.
188 The address can be written in various formats:</para>
189
190 <para>If the address starts with a slash
191 (<literal>/</literal>), it is read as file system socket in
192 the <constant>AF_UNIX</constant> socket family.</para>
193
194 <para>If the address starts with an at symbol
195 (<literal>@</literal>), it is read as abstract namespace
196 socket in the <constant>AF_UNIX</constant> family. The
197 <literal>@</literal> is replaced with a
198 <constant>NUL</constant> character before binding. For
199 details, see
200 <citerefentry project='man-pages'><refentrytitle>unix</refentrytitle><manvolnum>7</manvolnum></citerefentry>.</para>
201
202 <para>If the address string is a single number, it is read as
203 port number to listen on via IPv6. Depending on the value of
204 <varname>BindIPv6Only=</varname> (see below) this might result
205 in the service being available via both IPv6 and IPv4
206 (default) or just via IPv6.
207 </para>
208
209 <para>If the address string is a string in the format
210 v.w.x.y:z, it is read as IPv4 specifier for listening on an
211 address v.w.x.y on a port z.</para>
212
213 <para>If the address string is a string in the format [x]:y,
214 it is read as IPv6 address x on a port y. Note that this might
215 make the service available via IPv4, too, depending on the
216 <varname>BindIPv6Only=</varname> setting (see below).
217 </para>
218
219 <para>Note that <constant>SOCK_SEQPACKET</constant> (i.e.
220 <varname>ListenSequentialPacket=</varname>) is only available
221 for <constant>AF_UNIX</constant> sockets.
222 <constant>SOCK_STREAM</constant> (i.e.
223 <varname>ListenStream=</varname>) when used for IP sockets
224 refers to TCP sockets, <constant>SOCK_DGRAM</constant> (i.e.
225 <varname>ListenDatagram=</varname>) to UDP.</para>
226
b938cb90 227 <para>These options may be specified more than once, in which
798d3a52
ZJS
228 case incoming traffic on any of the sockets will trigger
229 service activation, and all listed sockets will be passed to
230 the service, regardless of whether there is incoming traffic
231 on them or not. If the empty string is assigned to any of
232 these options, the list of addresses to listen on is reset,
233 all prior uses of any of these options will have no
234 effect.</para>
235
236 <para>It is also possible to have more than one socket unit
237 for the same service when using <varname>Service=</varname>,
238 and the service will receive all the sockets configured in all
239 the socket units. Sockets configured in one unit are passed in
240 the order of configuration, but no ordering between socket
241 units is specified.</para>
242
243 <para>If an IP address is used here, it is often desirable to
244 listen on it before the interface it is configured on is up
245 and running, and even regardless of whether it will be up and
246 running at any point. To deal with this, it is recommended to
247 set the <varname>FreeBind=</varname> option described
248 below.</para></listitem>
249 </varlistentry>
250
251 <varlistentry>
252 <term><varname>ListenFIFO=</varname></term>
253 <listitem><para>Specifies a file system FIFO to listen on.
254 This expects an absolute file system path as argument.
255 Behavior otherwise is very similar to the
256 <varname>ListenDatagram=</varname> directive
257 above.</para></listitem>
258 </varlistentry>
259
260 <varlistentry>
261 <term><varname>ListenSpecial=</varname></term>
262 <listitem><para>Specifies a special file in the file system to
263 listen on. This expects an absolute file system path as
264 argument. Behavior otherwise is very similar to the
265 <varname>ListenFIFO=</varname> directive above. Use this to
266 open character device nodes as well as special files in
267 <filename>/proc</filename> and
268 <filename>/sys</filename>.</para></listitem>
269 </varlistentry>
270
271 <varlistentry>
272 <term><varname>ListenNetlink=</varname></term>
273 <listitem><para>Specifies a Netlink family to create a socket
274 for to listen on. This expects a short string referring to the
275 <constant>AF_NETLINK</constant> family name (such as
276 <varname>audit</varname> or <varname>kobject-uevent</varname>)
277 as argument, optionally suffixed by a whitespace followed by a
278 multicast group integer. Behavior otherwise is very similar to
279 the <varname>ListenDatagram=</varname> directive
280 above.</para></listitem>
281 </varlistentry>
282
283 <varlistentry>
284 <term><varname>ListenMessageQueue=</varname></term>
285 <listitem><para>Specifies a POSIX message queue name to listen
286 on. This expects a valid message queue name (i.e. beginning
287 with /). Behavior otherwise is very similar to the
288 <varname>ListenFIFO=</varname> directive above. On Linux
289 message queue descriptors are actually file descriptors and
290 can be inherited between processes.</para></listitem>
291 </varlistentry>
292
8c7c9839
PS
293 <varlistentry>
294 <term><varname>ListenUSBFunction=</varname></term>
3d314510
LP
295 <listitem><para>Specifies a <ulink
296 url="https://www.kernel.org/doc/Documentation/usb/functionfs.txt">USB
00bb64ec 297 FunctionFS</ulink> endpoints location to listen on, for
3d314510 298 implementation of USB gadget functions. This expects an
00bb64ec
PS
299 absolute file system path of functionfs mount point as the argument.
300 Behavior otherwise is very similar to the <varname>ListenFIFO=</varname>
a8eaaee7 301 directive above. Use this to open the FunctionFS endpoint
3d314510
LP
302 <filename>ep0</filename>. When using this option, the
303 activated service has to have the
22065311
ZJS
304 <varname>USBFunctionDescriptors=</varname> and
305 <varname>USBFunctionStrings=</varname> options set.
81eb21b9 306 </para></listitem>
8c7c9839
PS
307 </varlistentry>
308
74bb646e
SS
309 <varlistentry>
310 <term><varname>SocketProtocol=</varname></term>
311 <listitem><para>Takes a one of <option>udplite</option>
312 or <option>sctp</option>. Specifies a socket protocol
313 (<constant>IPPROTO_UDPLITE</constant>) UDP-Lite
314 (<constant>IPPROTO_SCTP</constant>) SCTP socket respectively. </para>
315 </listitem>
316 </varlistentry>
317
798d3a52
ZJS
318 <varlistentry>
319 <term><varname>BindIPv6Only=</varname></term>
320 <listitem><para>Takes a one of <option>default</option>,
321 <option>both</option> or <option>ipv6-only</option>. Controls
322 the IPV6_V6ONLY socket option (see
3ba3a79d 323 <citerefentry project='die-net'><refentrytitle>ipv6</refentrytitle><manvolnum>7</manvolnum></citerefentry>
798d3a52
ZJS
324 for details). If <option>both</option>, IPv6 sockets bound
325 will be accessible via both IPv4 and IPv6. If
326 <option>ipv6-only</option>, they will be accessible via IPv6
327 only. If <option>default</option> (which is the default,
328 surprise!), the system wide default setting is used, as
329 controlled by
330 <filename>/proc/sys/net/ipv6/bindv6only</filename>, which in
331 turn defaults to the equivalent of
332 <option>both</option>.</para>
333 </listitem>
334 </varlistentry>
335
336 <varlistentry>
337 <term><varname>Backlog=</varname></term>
338 <listitem><para>Takes an unsigned integer argument. Specifies
339 the number of connections to queue that have not been accepted
340 yet. This setting matters only for stream and sequential
341 packet sockets. See
342 <citerefentry><refentrytitle>listen</refentrytitle><manvolnum>2</manvolnum></citerefentry>
343 for details. Defaults to SOMAXCONN (128).</para></listitem>
344 </varlistentry>
345
346 <varlistentry>
347 <term><varname>BindToDevice=</varname></term>
348 <listitem><para>Specifies a network interface name to bind
349 this socket to. If set, traffic will only be accepted from the
350 specified network interfaces. This controls the
c129bd5d
LP
351 SO_BINDTODEVICE socket option (see <citerefentry
352 project='man-pages'><refentrytitle>socket</refentrytitle><manvolnum>7</manvolnum></citerefentry>
798d3a52
ZJS
353 for details). If this option is used, an automatic dependency
354 from this socket unit on the network interface device unit
355 (<citerefentry><refentrytitle>systemd.device</refentrytitle><manvolnum>5</manvolnum></citerefentry>
c129bd5d
LP
356 is created. Note that setting this parameter might result in
357 additional dependencies to be added to the unit (see
358 above).</para></listitem>
798d3a52
ZJS
359 </varlistentry>
360
361 <varlistentry>
362 <term><varname>SocketUser=</varname></term>
363 <term><varname>SocketGroup=</varname></term>
364
365 <listitem><para>Takes a UNIX user/group name. When specified,
366 all AF_UNIX sockets and FIFO nodes in the file system are
367 owned by the specified user and group. If unset (the default),
368 the nodes are owned by the root user/group (if run in system
369 context) or the invoking user/group (if run in user context).
370 If only a user is specified but no group, then the group is
371 derived from the user's default group.</para></listitem>
372 </varlistentry>
373
374 <varlistentry>
375 <term><varname>SocketMode=</varname></term>
376 <listitem><para>If listening on a file system socket or FIFO,
377 this option specifies the file system access mode used when
378 creating the file node. Takes an access mode in octal
379 notation. Defaults to 0666.</para></listitem>
380 </varlistentry>
381
382 <varlistentry>
383 <term><varname>DirectoryMode=</varname></term>
384 <listitem><para>If listening on a file system socket or FIFO,
385 the parent directories are automatically created if needed.
386 This option specifies the file system access mode used when
387 creating these directories. Takes an access mode in octal
388 notation. Defaults to 0755.</para></listitem>
389 </varlistentry>
390
391 <varlistentry>
392 <term><varname>Accept=</varname></term>
393 <listitem><para>Takes a boolean argument. If true, a service
394 instance is spawned for each incoming connection and only the
395 connection socket is passed to it. If false, all listening
396 sockets themselves are passed to the started service unit, and
397 only one service unit is spawned for all connections (also see
398 above). This value is ignored for datagram sockets and FIFOs
399 where a single service unit unconditionally handles all
400 incoming traffic. Defaults to <option>false</option>. For
401 performance reasons, it is recommended to write new daemons
402 only in a way that is suitable for
403 <option>Accept=false</option>. A daemon listening on an
404 <constant>AF_UNIX</constant> socket may, but does not need to,
405 call
406 <citerefentry><refentrytitle>close</refentrytitle><manvolnum>2</manvolnum></citerefentry>
407 on the received socket before exiting. However, it must not
408 unlink the socket from a file system. It should not invoke
409 <citerefentry><refentrytitle>shutdown</refentrytitle><manvolnum>2</manvolnum></citerefentry>
410 on sockets it got with <varname>Accept=false</varname>, but it
411 may do so for sockets it got with
412 <varname>Accept=true</varname> set. Setting
413 <varname>Accept=true</varname> is mostly useful to allow
414 daemons designed for usage with
b5c7d097 415 <citerefentry project='freebsd'><refentrytitle>inetd</refentrytitle><manvolnum>8</manvolnum></citerefentry>
798d3a52 416 to work unmodified with systemd socket
3b1c5241
SL
417 activation.</para>
418
b938cb90 419 <para>For IPv4 and IPv6 connections, the <varname>REMOTE_ADDR</varname>
a8eaaee7 420 environment variable will contain the remote IP address, and <varname>REMOTE_PORT</varname>
3b1c5241 421 will contain the remote port. This is the same as the format used by CGI.
b938cb90 422 For SOCK_RAW, the port is the IP protocol.</para></listitem>
798d3a52
ZJS
423 </varlistentry>
424
55301ec0
LP
425 <varlistentry>
426 <term><varname>Writable=</varname></term>
427 <listitem><para>Takes a boolean argument. May only be used in
428 conjunction with <varname>ListenSpecial=</varname>. If true,
429 the specified special file is opened in read-write mode, if
b938cb90 430 false, in read-only mode. Defaults to false.</para></listitem>
55301ec0
LP
431 </varlistentry>
432
798d3a52
ZJS
433 <varlistentry>
434 <term><varname>MaxConnections=</varname></term>
435 <listitem><para>The maximum number of connections to
436 simultaneously run services instances for, when
437 <option>Accept=true</option> is set. If more concurrent
438 connections are coming in, they will be refused until at least
439 one existing connection is terminated. This setting has no
440 effect on sockets configured with
441 <option>Accept=false</option> or datagram sockets. Defaults to
442 64.</para></listitem>
443 </varlistentry>
444
445 <varlistentry>
9d565427
SS
446 <term><varname>MaxConnectionsPerSource=</varname></term>
447 <listitem><para>The maximum number of connections for a service per source IP address.
cfaf4b75 448 This is very similar to the <varname>MaxConnections=</varname> directive
9d565427
SS
449 above. Disabled by default.</para>
450 </listitem>
451 </varlistentry>
452
453 <varlistentry>
798d3a52
ZJS
454 <term><varname>KeepAlive=</varname></term>
455 <listitem><para>Takes a boolean argument. If true, the TCP/IP
456 stack will send a keep alive message after 2h (depending on
457 the configuration of
458 <filename>/proc/sys/net/ipv4/tcp_keepalive_time</filename>)
459 for all TCP streams accepted on this socket. This controls the
460 SO_KEEPALIVE socket option (see
3ba3a79d 461 <citerefentry project='man-pages'><refentrytitle>socket</refentrytitle><manvolnum>7</manvolnum></citerefentry>
798d3a52
ZJS
462 and the <ulink
463 url="http://www.tldp.org/HOWTO/html_single/TCP-Keepalive-HOWTO/">TCP
464 Keepalive HOWTO</ulink> for details.) Defaults to
465 <option>false</option>.</para></listitem>
466 </varlistentry>
467
468 <varlistentry>
469 <term><varname>KeepAliveTimeSec=</varname></term>
b938cb90 470 <listitem><para>Takes time (in seconds) as argument. The connection needs to remain
798d3a52
ZJS
471 idle before TCP starts sending keepalive probes. This controls the TCP_KEEPIDLE
472 socket option (see
3ba3a79d 473 <citerefentry project='man-pages'><refentrytitle>socket</refentrytitle><manvolnum>7</manvolnum></citerefentry>
798d3a52
ZJS
474 and the <ulink
475 url="http://www.tldp.org/HOWTO/html_single/TCP-Keepalive-HOWTO/">TCP
476 Keepalive HOWTO</ulink> for details.)
477 Defaults value is 7200 seconds (2 hours).</para></listitem>
478 </varlistentry>
479
480 <varlistentry>
481 <term><varname>KeepAliveIntervalSec=</varname></term>
482 <listitem><para>Takes time (in seconds) as argument between
483 individual keepalive probes, if the socket option SO_KEEPALIVE
a8eaaee7 484 has been set on this socket. This controls
798d3a52 485 the TCP_KEEPINTVL socket option (see
3ba3a79d 486 <citerefentry project='man-pages'><refentrytitle>socket</refentrytitle><manvolnum>7</manvolnum></citerefentry>
798d3a52
ZJS
487 and the <ulink
488 url="http://www.tldp.org/HOWTO/html_single/TCP-Keepalive-HOWTO/">TCP
489 Keepalive HOWTO</ulink> for details.) Defaults value is 75
490 seconds.</para></listitem>
491 </varlistentry>
492
493 <varlistentry>
494 <term><varname>KeepAliveProbes=</varname></term>
7ca41557 495 <listitem><para>Takes an integer as argument. It is the number of
798d3a52
ZJS
496 unacknowledged probes to send before considering the
497 connection dead and notifying the application layer. This
498 controls the TCP_KEEPCNT socket option (see
3ba3a79d 499 <citerefentry project='man-pages'><refentrytitle>socket</refentrytitle><manvolnum>7</manvolnum></citerefentry>
798d3a52
ZJS
500 and the <ulink
501 url="http://www.tldp.org/HOWTO/html_single/TCP-Keepalive-HOWTO/">TCP
502 Keepalive HOWTO</ulink> for details.) Defaults value is
503 9.</para></listitem>
504 </varlistentry>
505
506 <varlistentry>
507 <term><varname>NoDelay=</varname></term>
508 <listitem><para>Takes a boolean argument. TCP Nagle's
509 algorithm works by combining a number of small outgoing
510 messages, and sending them all at once. This controls the
511 TCP_NODELAY socket option (see
3ba3a79d 512 <citerefentry project='die-net'><refentrytitle>tcp</refentrytitle><manvolnum>7</manvolnum></citerefentry>
798d3a52
ZJS
513 Defaults to <option>false</option>.</para></listitem>
514 </varlistentry>
515
516 <varlistentry>
517 <term><varname>Priority=</varname></term>
518 <listitem><para>Takes an integer argument controlling the
519 priority for all traffic sent from this socket. This controls
520 the SO_PRIORITY socket option (see
3ba3a79d 521 <citerefentry project='man-pages'><refentrytitle>socket</refentrytitle><manvolnum>7</manvolnum></citerefentry>
798d3a52
ZJS
522 for details.).</para></listitem>
523 </varlistentry>
524
525 <varlistentry>
526 <term><varname>DeferAcceptSec=</varname></term>
527
528 <listitem><para>Takes time (in seconds) as argument. If set,
529 the listening process will be awakened only when data arrives
530 on the socket, and not immediately when connection is
531 established. When this option is set, the
532 <constant>TCP_DEFER_ACCEPT</constant> socket option will be
533 used (see
3ba3a79d 534 <citerefentry project='die-net'><refentrytitle>tcp</refentrytitle><manvolnum>7</manvolnum></citerefentry>),
798d3a52
ZJS
535 and the kernel will ignore initial ACK packets without any
536 data. The argument specifies the approximate amount of time
537 the kernel should wait for incoming data before falling back
2dd67817 538 to the normal behavior of honoring empty ACK packets. This
798d3a52
ZJS
539 option is beneficial for protocols where the client sends the
540 data first (e.g. HTTP, in contrast to SMTP), because the
541 server process will not be woken up unnecessarily before it
542 can take any action.
543 </para>
544
545 <para>If the client also uses the
546 <constant>TCP_DEFER_ACCEPT</constant> option, the latency of
547 the initial connection may be reduced, because the kernel will
548 send data in the final packet establishing the connection (the
549 third packet in the "three-way handshake").</para>
550
551 <para>Disabled by default.</para>
552 </listitem>
553 </varlistentry>
554
555 <varlistentry>
556 <term><varname>ReceiveBuffer=</varname></term>
557 <term><varname>SendBuffer=</varname></term>
558 <listitem><para>Takes an integer argument controlling the
559 receive or send buffer sizes of this socket, respectively.
560 This controls the SO_RCVBUF and SO_SNDBUF socket options (see
3ba3a79d 561 <citerefentry project='man-pages'><refentrytitle>socket</refentrytitle><manvolnum>7</manvolnum></citerefentry>
798d3a52
ZJS
562 for details.). The usual suffixes K, M, G are supported and
563 are understood to the base of 1024.</para></listitem>
564 </varlistentry>
565
566 <varlistentry>
567 <term><varname>IPTOS=</varname></term>
568 <listitem><para>Takes an integer argument controlling the IP
569 Type-Of-Service field for packets generated from this socket.
570 This controls the IP_TOS socket option (see
3ba3a79d 571 <citerefentry project='die-net'><refentrytitle>ip</refentrytitle><manvolnum>7</manvolnum></citerefentry>
798d3a52
ZJS
572 for details.). Either a numeric string or one of
573 <option>low-delay</option>, <option>throughput</option>,
574 <option>reliability</option> or <option>low-cost</option> may
575 be specified.</para></listitem>
576 </varlistentry>
577
578 <varlistentry>
579 <term><varname>IPTTL=</varname></term>
580 <listitem><para>Takes an integer argument controlling the IPv4
581 Time-To-Live/IPv6 Hop-Count field for packets generated from
582 this socket. This sets the IP_TTL/IPV6_UNICAST_HOPS socket
583 options (see
3ba3a79d 584 <citerefentry project='die-net'><refentrytitle>ip</refentrytitle><manvolnum>7</manvolnum></citerefentry>
798d3a52 585 and
3ba3a79d 586 <citerefentry project='die-net'><refentrytitle>ipv6</refentrytitle><manvolnum>7</manvolnum></citerefentry>
798d3a52
ZJS
587 for details.)</para></listitem>
588 </varlistentry>
589
590 <varlistentry>
591 <term><varname>Mark=</varname></term>
592 <listitem><para>Takes an integer value. Controls the firewall
593 mark of packets generated by this socket. This can be used in
594 the firewall logic to filter packets from this socket. This
595 sets the SO_MARK socket option. See
3ba3a79d 596 <citerefentry project='die-net'><refentrytitle>iptables</refentrytitle><manvolnum>8</manvolnum></citerefentry>
798d3a52
ZJS
597 for details.</para></listitem>
598 </varlistentry>
599
600 <varlistentry>
601 <term><varname>ReusePort=</varname></term>
602 <listitem><para>Takes a boolean value. If true, allows
603 multiple
604 <citerefentry><refentrytitle>bind</refentrytitle><manvolnum>2</manvolnum></citerefentry>s
605 to this TCP or UDP port. This controls the SO_REUSEPORT socket
606 option. See
3ba3a79d 607 <citerefentry project='man-pages'><refentrytitle>socket</refentrytitle><manvolnum>7</manvolnum></citerefentry>
798d3a52
ZJS
608 for details.</para></listitem>
609 </varlistentry>
610
611 <varlistentry>
612 <term><varname>SmackLabel=</varname></term>
613 <term><varname>SmackLabelIPIn=</varname></term>
614 <term><varname>SmackLabelIPOut=</varname></term>
615 <listitem><para>Takes a string value. Controls the extended
616 attributes <literal>security.SMACK64</literal>,
617 <literal>security.SMACK64IPIN</literal> and
618 <literal>security.SMACK64IPOUT</literal>, respectively, i.e.
619 the security label of the FIFO, or the security label for the
620 incoming or outgoing connections of the socket, respectively.
621 See <ulink
622 url="https://www.kernel.org/doc/Documentation/security/Smack.txt">Smack.txt</ulink>
623 for details.</para></listitem>
624 </varlistentry>
625
626 <varlistentry>
627 <term><varname>SELinuxContextFromNet=</varname></term>
628 <listitem><para>Takes a boolean argument. When true, systemd
629 will attempt to figure out the SELinux label used for the
630 instantiated service from the information handed by the peer
631 over the network. Note that only the security level is used
632 from the information provided by the peer. Other parts of the
633 resulting SELinux context originate from either the target
634 binary that is effectively triggered by socket unit or from
635 the value of the <varname>SELinuxContext=</varname> option.
636 This configuration option only affects sockets with
637 <varname>Accept=</varname> mode set to
638 <literal>true</literal>. Also note that this option is useful
639 only when MLS/MCS SELinux policy is deployed. Defaults to
640 <literal>false</literal>. </para></listitem>
641 </varlistentry>
642
643 <varlistentry>
644 <term><varname>PipeSize=</varname></term>
645 <listitem><para>Takes a size in bytes. Controls the pipe
646 buffer size of FIFOs configured in this socket unit. See
647 <citerefentry><refentrytitle>fcntl</refentrytitle><manvolnum>2</manvolnum></citerefentry>
648 for details. The usual suffixes K, M, G are supported and are
649 understood to the base of 1024.</para></listitem>
650 </varlistentry>
651
652 <varlistentry>
653 <term><varname>MessageQueueMaxMessages=</varname>,
654 <varname>MessageQueueMessageSize=</varname></term>
655 <listitem><para>These two settings take integer values and
656 control the mq_maxmsg field or the mq_msgsize field,
657 respectively, when creating the message queue. Note that
658 either none or both of these variables need to be set. See
3ba3a79d 659 <citerefentry project='die-net'><refentrytitle>mq_setattr</refentrytitle><manvolnum>3</manvolnum></citerefentry>
798d3a52
ZJS
660 for details.</para></listitem>
661 </varlistentry>
662
663 <varlistentry>
664 <term><varname>FreeBind=</varname></term>
665 <listitem><para>Takes a boolean value. Controls whether the
666 socket can be bound to non-local IP addresses. This is useful
667 to configure sockets listening on specific IP addresses before
668 those IP addresses are successfully configured on a network
669 interface. This sets the IP_FREEBIND socket option. For
670 robustness reasons it is recommended to use this option
671 whenever you bind a socket to a specific IP address. Defaults
672 to <option>false</option>.</para></listitem>
673 </varlistentry>
674
675 <varlistentry>
676 <term><varname>Transparent=</varname></term>
677 <listitem><para>Takes a boolean value. Controls the
678 IP_TRANSPARENT socket option. Defaults to
679 <option>false</option>.</para></listitem>
680 </varlistentry>
681
682 <varlistentry>
683 <term><varname>Broadcast=</varname></term>
684 <listitem><para>Takes a boolean value. This controls the
685 SO_BROADCAST socket option, which allows broadcast datagrams
686 to be sent from this socket. Defaults to
687 <option>false</option>.</para></listitem>
688 </varlistentry>
689
690 <varlistentry>
691 <term><varname>PassCredentials=</varname></term>
692 <listitem><para>Takes a boolean value. This controls the
693 SO_PASSCRED socket option, which allows
694 <constant>AF_UNIX</constant> sockets to receive the
695 credentials of the sending process in an ancillary message.
696 Defaults to <option>false</option>.</para></listitem>
697 </varlistentry>
698
699 <varlistentry>
700 <term><varname>PassSecurity=</varname></term>
701 <listitem><para>Takes a boolean value. This controls the
702 SO_PASSSEC socket option, which allows
703 <constant>AF_UNIX</constant> sockets to receive the security
704 context of the sending process in an ancillary message.
705 Defaults to <option>false</option>.</para></listitem>
706 </varlistentry>
707
708 <varlistentry>
709 <term><varname>TCPCongestion=</varname></term>
710 <listitem><para>Takes a string value. Controls the TCP
711 congestion algorithm used by this socket. Should be one of
712 "westwood", "veno", "cubic", "lp" or any other available
713 algorithm supported by the IP stack. This setting applies only
714 to stream sockets.</para></listitem>
715 </varlistentry>
716
717 <varlistentry>
718 <term><varname>ExecStartPre=</varname></term>
719 <term><varname>ExecStartPost=</varname></term>
720 <listitem><para>Takes one or more command lines, which are
721 executed before or after the listening sockets/FIFOs are
722 created and bound, respectively. The first token of the
723 command line must be an absolute filename, then followed by
724 arguments for the process. Multiple command lines may be
725 specified following the same scheme as used for
726 <varname>ExecStartPre=</varname> of service unit
727 files.</para></listitem>
728 </varlistentry>
729
730 <varlistentry>
731 <term><varname>ExecStopPre=</varname></term>
732 <term><varname>ExecStopPost=</varname></term>
733 <listitem><para>Additional commands that are executed before
734 or after the listening sockets/FIFOs are closed and removed,
735 respectively. Multiple command lines may be specified
736 following the same scheme as used for
737 <varname>ExecStartPre=</varname> of service unit
738 files.</para></listitem>
739 </varlistentry>
740
741 <varlistentry>
742 <term><varname>TimeoutSec=</varname></term>
743 <listitem><para>Configures the time to wait for the commands
744 specified in <varname>ExecStartPre=</varname>,
745 <varname>ExecStartPost=</varname>,
746 <varname>ExecStopPre=</varname> and
747 <varname>ExecStopPost=</varname> to finish. If a command does
748 not exit within the configured time, the socket will be
749 considered failed and be shut down again. All commands still
750 running will be terminated forcibly via
751 <constant>SIGTERM</constant>, and after another delay of this
752 time with <constant>SIGKILL</constant>. (See
753 <option>KillMode=</option> in
754 <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>.)
755 Takes a unit-less value in seconds, or a time span value such
756 as "5min 20s". Pass <literal>0</literal> to disable the
757 timeout logic. Defaults to
758 <varname>DefaultTimeoutStartSec=</varname> from the manager
759 configuration file (see
760 <citerefentry><refentrytitle>systemd-system.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>).
761 </para></listitem>
762 </varlistentry>
763
764 <varlistentry>
765 <term><varname>Service=</varname></term>
766 <listitem><para>Specifies the service unit name to activate on
767 incoming traffic. This setting is only allowed for sockets
768 with <varname>Accept=no</varname>. It defaults to the service
769 that bears the same name as the socket (with the suffix
770 replaced). In most cases, it should not be necessary to use
c129bd5d
LP
771 this option. Note that setting this parameter might result in
772 additional dependencies to be added to the unit (see
773 above).</para></listitem>
798d3a52
ZJS
774 </varlistentry>
775
776 <varlistentry>
777 <term><varname>RemoveOnStop=</varname></term>
778 <listitem><para>Takes a boolean argument. If enabled, any file
779 nodes created by this socket unit are removed when it is
780 stopped. This applies to AF_UNIX sockets in the file system,
781 POSIX message queues, FIFOs, as well as any symlinks to them
782 configured with <varname>Symlinks=</varname>. Normally, it
783 should not be necessary to use this option, and is not
784 recommended as services might continue to run after the socket
785 unit has been terminated and it should still be possible to
786 communicate with them via their file system node. Defaults to
787 off.</para></listitem>
788 </varlistentry>
789
790 <varlistentry>
791 <term><varname>Symlinks=</varname></term>
792 <listitem><para>Takes a list of file system paths. The
793 specified paths will be created as symlinks to the AF_UNIX
794 socket path or FIFO path of this socket unit. If this setting
795 is used, only one AF_UNIX socket in the file system or one
796 FIFO may be configured for the socket unit. Use this option to
797 manage one or more symlinked alias names for a socket, binding
798 their lifecycle together. Defaults to the empty
799 list.</para></listitem>
800 </varlistentry>
801
8dd4c05b
LP
802 <varlistentry>
803 <term><varname>FileDescriptorName=</varname></term>
804 <listitem><para>Assigns a name to all file descriptors this
805 socket unit encapsulates. This is useful to help activated
a8eaaee7 806 services identify specific file descriptors, if multiple fds
8dd4c05b
LP
807 are passed. Services may use the
808 <citerefentry><refentrytitle>sd_listen_fds_with_names</refentrytitle><manvolnum>3</manvolnum></citerefentry>
809 call to acquire the names configured for the received file
810 descriptors. Names may contain any ASCII character, but must
a8eaaee7 811 exclude control characters and <literal>:</literal>, and must
8dd4c05b 812 be at most 255 characters in length. If this setting is not
b938cb90 813 used, the file descriptor name defaults to the name of the
8dd4c05b
LP
814 socket unit, including its <filename>.socket</filename>
815 suffix.</para></listitem>
816 </varlistentry>
817
8b26cdbd
LP
818 <varlistentry>
819 <term><varname>TriggerLimitIntervalSec=</varname></term>
db985064 820 <term><varname>TriggerLimitBurst=</varname></term>
8b26cdbd
LP
821
822 <listitem><para>Configures a limit on how often this socket unit my be activated within a specific time
823 interval. The <varname>TriggerLimitIntervalSec=</varname> may be used to configure the length of the time
824 interval in the usual time units <literal>us</literal>, <literal>ms</literal>, <literal>s</literal>,
1f15ce28 825 <literal>min</literal>, <literal>h</literal>, … and defaults to 2s (See
8b26cdbd 826 <citerefentry><refentrytitle>systemd.time</refentrytitle><manvolnum>7</manvolnum></citerefentry> for details on
1f15ce28
LP
827 the various time units understood). The <varname>TriggerLimitBurst=</varname> setting takes a positive integer
828 value and specifies the number of permitted activations per time interval, and defaults to 200 for
829 <varname>Accept=yes</varname> sockets (thus by default permitting 200 activations per 2s), and 20 otherwise (20
830 activations per 2s). Set either to 0 to disable any form of trigger rate limiting. If the limit is hit, the
831 socket unit is placed into a failure mode, and will not be connectible anymore until restarted. Note that this
832 limit is enforced before the service activation is enqueued.</para></listitem>
8b26cdbd
LP
833 </varlistentry>
834
798d3a52
ZJS
835 </variablelist>
836
837 <para>Check
838 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>
839 and
840 <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>
841 for more settings.</para>
842
843 </refsect1>
844
845 <refsect1>
846 <title>See Also</title>
847 <para>
848 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
849 <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
850 <citerefentry><refentrytitle>systemd.unit</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
851 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
852 <citerefentry><refentrytitle>systemd.kill</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
853 <citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
854 <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
8dd4c05b
LP
855 <citerefentry><refentrytitle>systemd.directives</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
856 <citerefentry><refentrytitle>sd_listen_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
857 <citerefentry><refentrytitle>sd_listen_fds_with_names</refentrytitle><manvolnum>3</manvolnum></citerefentry>
798d3a52 858 </para>
798d3a52
ZJS
859 <para>
860 For more extensive descriptions see the "systemd for Developers" series:
861 <ulink url="http://0pointer.de/blog/projects/socket-activation.html">Socket Activation</ulink>,
862 <ulink url="http://0pointer.de/blog/projects/socket-activation2.html">Socket Activation, part II</ulink>,
863 <ulink url="http://0pointer.de/blog/projects/inetd.html">Converting inetd Services</ulink>,
864 <ulink url="http://0pointer.de/blog/projects/socket-activated-containers.html">Socket Activated Internet Services and OS Containers</ulink>.
865 </para>
866 </refsect1>
1f812fea
LP
867
868</refentry>