diff options
author | Shawn Landden <shawnlandden@gmail.com> | 2013-07-08 18:28:14 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-07-11 03:09:18 +0200 |
commit | f7db7a691c3f532cf60886312459f2baea755283 (patch) | |
tree | 242efce2ac1d95b02892e7146bd632cfdb4d2e13 /src | |
parent | 4c5420a0c1429de866c4dfbe2f973cfa241bdbe4 (diff) |
basic SO_REUSEPORT support
Diffstat (limited to 'src')
-rw-r--r-- | src/core/dbus-socket.c | 2 | ||||
-rw-r--r-- | src/core/socket.c | 11 | ||||
-rw-r--r-- | src/core/socket.h | 1 | ||||
-rw-r--r-- | src/shared/missing.h | 4 |
4 files changed, 18 insertions, 0 deletions
diff --git a/src/core/dbus-socket.c b/src/core/dbus-socket.c index da317edb86..30c4b6302c 100644 --- a/src/core/dbus-socket.c +++ b/src/core/dbus-socket.c @@ -67,6 +67,7 @@ " <property name=\"MessageQueueMessageSize\" type=\"x\" access=\"read\"/>\n" \ " <property name=\"Listen\" type=\"a(ss)\" access=\"read\"/>\n" \ " <property name=\"Result\" type=\"s\" access=\"read\"/>\n" \ + " <property name=\"ReusePort\" type=\"b\" access=\"read\"/>\n" \ " <property name=\"SmackLabel\" type=\"s\" access=\"read\"/>\n" \ " <property name=\"SmackLabelIPIn\" type=\"s\" access=\"read\"/>\n" \ " <property name=\"SmackLabelIPOut\" type=\"s\" access=\"read\"/>\n" \ @@ -194,6 +195,7 @@ static const BusProperty bus_socket_properties[] = { { "MessageQueueMaxMessages", bus_property_append_long, "x", offsetof(Socket, mq_maxmsg) }, { "MessageQueueMessageSize", bus_property_append_long, "x", offsetof(Socket, mq_msgsize) }, { "Result", bus_socket_append_socket_result, "s", offsetof(Socket, result) }, + { "ReusePort", bus_property_append_bool, "b", offsetof(Socket, reuseport) }, { "SmackLabel", bus_property_append_string, "s", offsetof(Socket, smack), true }, { "SmackLabelIPIn", bus_property_append_string, "s", offsetof(Socket, smack_ip_in), true }, { "SmackLabelIPOut",bus_property_append_string, "s", offsetof(Socket, smack_ip_out), true }, diff --git a/src/core/socket.c b/src/core/socket.c index 2def0c9ead..cf88bae9da 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -536,6 +536,11 @@ static void socket_dump(Unit *u, FILE *f, const char *prefix) { "%sMessageQueueMessageSize: %li\n", prefix, s->mq_msgsize); + if (s->reuseport) + fprintf(f, + "%sReusePort: %s\n", + prefix, yes_no(s->reuseport)); + if (s->smack) fprintf(f, "%sSmackLabel: %s\n", @@ -792,6 +797,12 @@ static void socket_apply_socket_options(Socket *s, int fd) { if (setsockopt(fd, SOL_TCP, TCP_CONGESTION, s->tcp_congestion, strlen(s->tcp_congestion)+1) < 0) log_warning_unit(UNIT(s)->id, "TCP_CONGESTION failed: %m"); + if (s->reuseport) { + int b = s->reuseport; + if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &b, sizeof(b))) + log_warning_unit(UNIT(s)->id, "SO_REUSEPORT failed: %m"); + } + #ifdef HAVE_SMACK if (s->smack_ip_in) if (fsetxattr(fd, "security.SMACK64IPIN", s->smack_ip_in, strlen(s->smack_ip_in), 0) < 0) diff --git a/src/core/socket.h b/src/core/socket.h index 15942c1c90..8f9dfdbfb0 100644 --- a/src/core/socket.h +++ b/src/core/socket.h @@ -144,6 +144,7 @@ struct Socket { size_t pipe_size; char *bind_to_device; char *tcp_congestion; + bool reuseport; long mq_maxmsg; long mq_msgsize; diff --git a/src/shared/missing.h b/src/shared/missing.h index 24a8392b22..534b3ccd4e 100644 --- a/src/shared/missing.h +++ b/src/shared/missing.h @@ -266,3 +266,7 @@ static inline int name_to_handle_at(int fd, const char *name, struct file_handle #ifndef TFD_TIMER_CANCEL_ON_SET #define TFD_TIMER_CANCEL_ON_SET (1 << 1) #endif + +#ifndef SO_REUSEPORT +#define SO_REUSEPORT 15 +#endif |