summaryrefslogtreecommitdiff
path: root/src/basic
diff options
context:
space:
mode:
Diffstat (limited to 'src/basic')
-rw-r--r--src/basic/socket-label.c9
-rw-r--r--src/basic/socket-util.h1
-rw-r--r--src/basic/util.c2
3 files changed, 10 insertions, 2 deletions
diff --git a/src/basic/socket-label.c b/src/basic/socket-label.c
index cbe3ff216e..144e6fd86e 100644
--- a/src/basic/socket-label.c
+++ b/src/basic/socket-label.c
@@ -38,6 +38,7 @@ int socket_address_listen(
int backlog,
SocketAddressBindIPv6Only only,
const char *bind_to_device,
+ bool reuse_port,
bool free_bind,
bool transparent,
mode_t directory_mode,
@@ -83,6 +84,12 @@ int socket_address_listen(
if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, bind_to_device, strlen(bind_to_device)+1) < 0)
return -errno;
+ if (reuse_port) {
+ one = 1;
+ if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &one, sizeof(one)) < 0)
+ log_warning_errno(errno, "SO_REUSEPORT failed: %m");
+ }
+
if (free_bind) {
one = 1;
if (setsockopt(fd, IPPROTO_IP, IP_FREEBIND, &one, sizeof(one)) < 0)
@@ -146,7 +153,7 @@ int make_socket_fd(int log_level, const char* address, int flags) {
}
fd = socket_address_listen(&a, flags, SOMAXCONN, SOCKET_ADDRESS_DEFAULT,
- NULL, false, false, 0755, 0644, NULL);
+ NULL, false, false, false, 0755, 0644, NULL);
if (fd < 0 || log_get_max_level() >= log_level) {
_cleanup_free_ char *p = NULL;
diff --git a/src/basic/socket-util.h b/src/basic/socket-util.h
index 538cf59174..6b0ce7836f 100644
--- a/src/basic/socket-util.h
+++ b/src/basic/socket-util.h
@@ -80,6 +80,7 @@ int socket_address_listen(
int backlog,
SocketAddressBindIPv6Only only,
const char *bind_to_device,
+ bool reuse_port,
bool free_bind,
bool transparent,
mode_t directory_mode,
diff --git a/src/basic/util.c b/src/basic/util.c
index a574c9c661..aa912bde28 100644
--- a/src/basic/util.c
+++ b/src/basic/util.c
@@ -3627,7 +3627,7 @@ bool string_is_safe(const char *p) {
if (*t > 0 && *t < ' ')
return false;
- if (strchr("\\\"\'\0x7f", *t))
+ if (strchr("\\\"\'\x7f", *t))
return false;
}