[systemd-devel] [PATCH 2/2] socket: Introduce SCTP support

Susant Sahani susant at redhat.com
Sun Jul 27 23:48:30 PDT 2014


This patch adds SCTP protcol support for socket activation.
SCTP socket can be configured via the conf parameter
'ListenStreamControlTrans' which is kind of too long.
---
 man/systemd.socket.xml                | 3 ++-
 src/core/load-fragment-gperf.gperf.m4 | 1 +
 src/core/load-fragment.c              | 5 ++++-
 src/core/socket.c                     | 8 ++++++--
 4 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/man/systemd.socket.xml b/man/systemd.socket.xml
index ddd74a6..934a45e 100644
--- a/man/systemd.socket.xml
+++ b/man/systemd.socket.xml
@@ -168,10 +168,11 @@
                                 <term><varname>ListenStream=</varname></term>
                                 <term><varname>ListenDatagram=</varname></term>
                                 <term><varname>ListenSequentialPacket=</varname></term>
+                                <term><varname>ListenStreamControlTrans=</varname></term>
                                 <listitem><para>Specifies an address
                                 to listen on for a stream
                                 (<constant>SOCK_STREAM</constant>), datagram (<constant>SOCK_DGRAM</constant>),
-                                or sequential packet
+                                SCTP (<constant>IPPROTO_SCTP</constant>),or sequential packet
                                 (<constant>SOCK_SEQPACKET</constant>) socket, respectively. The address
                                 can be written in various formats:</para>
 
diff --git a/src/core/load-fragment-gperf.gperf.m4 b/src/core/load-fragment-gperf.gperf.m4
index f4acdda..a295923 100644
--- a/src/core/load-fragment-gperf.gperf.m4
+++ b/src/core/load-fragment-gperf.gperf.m4
@@ -211,6 +211,7 @@ KILL_CONTEXT_CONFIG_ITEMS(Service)m4_dnl
 m4_dnl
 Socket.ListenStream,             config_parse_socket_listen,         SOCKET_SOCKET,                 0
 Socket.ListenDatagram,           config_parse_socket_listen,         SOCKET_SOCKET,                 0
+Socket.ListenStreamControlTrans, config_parse_socket_listen,         SOCKET_SOCKET,                 0
 Socket.ListenSequentialPacket,   config_parse_socket_listen,         SOCKET_SOCKET,                 0
 Socket.ListenFIFO,               config_parse_socket_listen,         SOCKET_FIFO,                   0
 Socket.ListenNetlink,            config_parse_socket_listen,         SOCKET_SOCKET,                 0
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index 81f1379..0ae116b 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -358,7 +358,10 @@ int config_parse_socket_listen(const char *unit,
                         p->address.type = SOCK_STREAM;
                 else if (streq(lvalue, "ListenDatagram"))
                         p->address.type = SOCK_DGRAM;
-                else {
+                else if (streq(lvalue, "ListenStreamControlTrans")) {
+                         p->address.type = SOCK_STREAM;
+                         p->address.protocol = IPPROTO_SCTP;
+                } else {
                         assert(streq(lvalue, "ListenSequentialPacket"));
                         p->address.type = SOCK_SEQPACKET;
                 }
diff --git a/src/core/socket.c b/src/core/socket.c
index 7070bd7..82d8eaf 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -445,11 +445,14 @@ static int socket_load(Unit *u) {
         return socket_verify(s);
 }
 
-_const_ static const char* listen_lookup(int family, int type) {
+_const_ static const char* listen_lookup(int family, int type, int protocol) {
 
         if (family == AF_NETLINK)
                 return "ListenNetlink";
 
+        if (protocol == IPPROTO_SCTP)
+                return "ListenStreamControlTrans";
+
         if (type == SOCK_STREAM)
                 return "ListenStream";
         else if (type == SOCK_DGRAM)
@@ -607,7 +610,8 @@ static void socket_dump(Unit *u, FILE *f, const char *prefix) {
                         else
                                 t = k;
 
-                        fprintf(f, "%s%s: %s\n", prefix, listen_lookup(socket_address_family(&p->address), p->address.type), t);
+                        fprintf(f, "%s%s: %s\n", prefix, listen_lookup(socket_address_family(&p->address),
+                                                                       p->address.type, p->address.protocol), t);
                         free(k);
                 } else if (p->type == SOCKET_SPECIAL)
                         fprintf(f, "%sListenSpecial: %s\n", prefix, p->path);
-- 
1.9.3



More information about the systemd-devel mailing list