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