mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-04 21:15:07 -05:00
socket: add support for systemd sockets
Before opening new IPv4/IPv6 server sockets, chronyd will check for matching reusable sockets passed from the service manager (for example, passed via systemd socket activation: https://www.freedesktop.org/software/systemd/man/latest/sd_listen_fds.html) and use those instead. Aside from IPV6_V6ONLY (which cannot be set on already-bound sockets), the daemon sets the same socket options on reusable sockets as it would on sockets it opens itself. Unit tests test the correct parsing of the LISTEN_FDS environment variable. Add 011-systemd system test to test socket activation for DGRAM and STREAM sockets (both IPv4 and IPv6). The tests use the systemd-socket-activate test tool, which has some limitations requiring workarounds discussed in inline comments.
This commit is contained in:
committed by
Miroslav Lichvar
parent
c063b9e78a
commit
e6a0476eb7
6
socket.h
6
socket.h
@@ -73,6 +73,9 @@ typedef struct {
|
||||
int descriptor;
|
||||
} SCK_Message;
|
||||
|
||||
/* Pre-initialisation function */
|
||||
extern void SCK_PreInitialise(void);
|
||||
|
||||
/* Initialisation function (the specified IP family is enabled,
|
||||
or all if IPADDR_UNSPEC) */
|
||||
extern void SCK_Initialise(int family);
|
||||
@@ -106,6 +109,9 @@ extern int SCK_OpenUnixStreamSocket(const char *remote_addr, const char *local_a
|
||||
int flags);
|
||||
extern int SCK_OpenUnixSocketPair(int flags, int *other_fd);
|
||||
|
||||
/* Check if a file descriptor was passed from the service manager */
|
||||
extern int SCK_IsReusable(int sock_fd);
|
||||
|
||||
/* Set and get a socket option of int size */
|
||||
extern int SCK_SetIntOption(int sock_fd, int level, int name, int value);
|
||||
extern int SCK_GetIntOption(int sock_fd, int level, int name, int *value);
|
||||
|
||||
Reference in New Issue
Block a user