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