Skip to content

Commit 62bc4ef

Browse files
committed
core: socket options fix SCTP_NODELAY
SCTP_NODELAY is diffrent to TCP_NODELAY. Apply proper options in case of SCTP.
1 parent b485d20 commit 62bc4ef

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/basic/missing.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@
131131
#define NETLINK_LIST_MEMBERSHIPS 9
132132
#endif
133133

134+
#ifndef SOL_SCTP
135+
#define SOL_SCTP 132
136+
#endif
137+
134138
#if !HAVE_DECL_PIVOT_ROOT
135139
static inline int pivot_root(const char *new_root, const char *put_old) {
136140
return syscall(SYS_pivot_root, new_root, put_old);

src/core/socket.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
#include <sys/epoll.h>
2929
#include <sys/stat.h>
3030
#include <unistd.h>
31+
#include <linux/sctp.h>
3132

3233
#include "sd-event.h"
33-
3434
#include "alloc-util.h"
3535
#include "bus-error.h"
3636
#include "bus-util.h"
@@ -877,8 +877,14 @@ static void socket_apply_socket_options(Socket *s, int fd) {
877877

878878
if (s->no_delay) {
879879
int b = s->no_delay;
880-
if (setsockopt(fd, SOL_TCP, TCP_NODELAY, &b, sizeof(b)) < 0)
881-
log_unit_warning_errno(UNIT(s), errno, "TCP_NODELAY failed: %m");
880+
881+
if (s->socket_protocol == IPPROTO_SCTP) {
882+
if (setsockopt(fd, SOL_SCTP, SCTP_NODELAY, &b, sizeof(b)) < 0)
883+
log_unit_warning_errno(UNIT(s), errno, "SCTP_NODELAY failed: %m");
884+
} else {
885+
if (setsockopt(fd, SOL_TCP, TCP_NODELAY, &b, sizeof(b)) < 0)
886+
log_unit_warning_errno(UNIT(s), errno, "TCP_NODELAY failed: %m");
887+
}
882888
}
883889

884890
if (s->broadcast) {

0 commit comments

Comments
 (0)