]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: socket options fix SCTP_NODELAY 2245/head
authorSusant Sahani <ssahani@gmail.com>
Thu, 31 Dec 2015 06:35:57 +0000 (12:05 +0530)
committerSusant Sahani <ssahani@gmail.com>
Thu, 31 Dec 2015 06:35:57 +0000 (12:05 +0530)
SCTP_NODELAY is diffrent to TCP_NODELAY.
Apply proper options in case of SCTP.

src/basic/missing.h
src/core/socket.c

index d539ed00e4065e576ac67bc565df97c064580013..880e724cb4cb0c879cea4c5653dc6da00545d90b 100644 (file)
 #define NETLINK_LIST_MEMBERSHIPS 9
 #endif
 
+#ifndef SOL_SCTP
+#define SOL_SCTP 132
+#endif
+
 #if !HAVE_DECL_PIVOT_ROOT
 static inline int pivot_root(const char *new_root, const char *put_old) {
         return syscall(SYS_pivot_root, new_root, put_old);
index d6b0c963e87526e35824e3035c6a7006236f6ffd..2e4173aabc08c16d0fe25b42d0b65a89e1ca3c34 100644 (file)
@@ -28,9 +28,9 @@
 #include <sys/epoll.h>
 #include <sys/stat.h>
 #include <unistd.h>
+#include <linux/sctp.h>
 
 #include "sd-event.h"
-
 #include "alloc-util.h"
 #include "bus-error.h"
 #include "bus-util.h"
@@ -877,8 +877,14 @@ static void socket_apply_socket_options(Socket *s, int fd) {
 
         if (s->no_delay) {
                 int b = s->no_delay;
-                if (setsockopt(fd, SOL_TCP, TCP_NODELAY, &b, sizeof(b)) < 0)
-                        log_unit_warning_errno(UNIT(s), errno, "TCP_NODELAY failed: %m");
+
+                if (s->socket_protocol == IPPROTO_SCTP) {
+                        if (setsockopt(fd, SOL_SCTP, SCTP_NODELAY, &b, sizeof(b)) < 0)
+                                log_unit_warning_errno(UNIT(s), errno, "SCTP_NODELAY failed: %m");
+                } else {
+                        if (setsockopt(fd, SOL_TCP, TCP_NODELAY, &b, sizeof(b)) < 0)
+                                log_unit_warning_errno(UNIT(s), errno, "TCP_NODELAY failed: %m");
+                }
         }
 
         if (s->broadcast) {