]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
inspawn: switch from SOCK_DGRAM to SOCK_SEQPACKET for internal socketpairs
authorLennart Poettering <lennart@poettering.net>
Mon, 7 Sep 2015 23:17:47 +0000 (01:17 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 7 Sep 2015 23:17:47 +0000 (01:17 +0200)
SOCK_DGRAM and SOCK_SEQPACKET have very similar semantics when used with
socketpair(). However, SOCK_SEQPACKET has the advantage of knowing a
hangup concept, since it is inherently connection-oriented.

Since we use socket pairs to communicate between the nspawn main process
and the nspawn child process, where the child might die abnormally it's
interesting to us to learn about this via hangups if the child side of
the pair is closed. Hence, let's switch to SOCK_SEQPACKET for these
internal communication sockets.

Fixes #956.

src/nspawn/nspawn.c

index 8cd3cbc6207e8462d514883e5cdf9aac2bfe34d0..9517e41202451d56e04bb71a6402341904b2275f 100644 (file)
@@ -3272,23 +3272,23 @@ int main(int argc, char *argv[]) {
                         goto finish;
                 }
 
-                if (socketpair(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0, kmsg_socket_pair) < 0) {
+                if (socketpair(AF_UNIX, SOCK_SEQPACKET|SOCK_CLOEXEC, 0, kmsg_socket_pair) < 0) {
                         r = log_error_errno(errno, "Failed to create kmsg socket pair: %m");
                         goto finish;
                 }
 
-                if (socketpair(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0, rtnl_socket_pair) < 0) {
+                if (socketpair(AF_UNIX, SOCK_SEQPACKET|SOCK_CLOEXEC, 0, rtnl_socket_pair) < 0) {
                         r = log_error_errno(errno, "Failed to create rtnl socket pair: %m");
                         goto finish;
                 }
 
-                if (socketpair(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0, pid_socket_pair) < 0) {
+                if (socketpair(AF_UNIX, SOCK_SEQPACKET|SOCK_CLOEXEC, 0, pid_socket_pair) < 0) {
                         r = log_error_errno(errno, "Failed to create pid socket pair: %m");
                         goto finish;
                 }
 
                 if (arg_userns)
-                        if (socketpair(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0, uid_shift_socket_pair) < 0) {
+                        if (socketpair(AF_UNIX, SOCK_SEQPACKET|SOCK_CLOEXEC, 0, uid_shift_socket_pair) < 0) {
                                 r = log_error_errno(errno, "Failed to create uid shift socket pair: %m");
                                 goto finish;
                         }