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