]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
missing.h: add AF_VSOCK bits
authorStefan Hajnoczi <stefanha@redhat.com>
Tue, 10 Jan 2017 13:35:18 +0000 (13:35 +0000)
committerStefan Hajnoczi <stefanha@redhat.com>
Tue, 10 Jan 2017 15:27:00 +0000 (15:27 +0000)
Ubuntu 14.04 (Trusty) kernel header packages ship without
<linux/vm_sockets.h>.  Only struct sockaddr_vm and VMADDR_CID_ANY will
be needed by systemd and they are simple enough to go in missing.h.

CentOS 7 <sys/socket.h> does not define AF_VSOCK.  Define it so the code
can compile although actual socket(2) calls may fail at runtime if the
address family isn't available.

configure.ac
src/basic/missing.h

index 11bd46cbab02ecec3c1eb4108516c1a27389f9b0..371158efe5e11ddd3fd72dfc0b084a138d3aa2d0 100644 (file)
@@ -285,6 +285,7 @@ AM_CONDITIONAL([HAVE_PYTHON], [test "x$have_python" = "xyes"])
 AC_CHECK_HEADERS([sys/capability.h], [], [AC_MSG_ERROR([*** POSIX caps headers not found])])
 AC_CHECK_HEADERS([linux/btrfs.h], [], [])
 AC_CHECK_HEADERS([linux/memfd.h], [], [])
+AC_CHECK_HEADERS([linux/vm_sockets.h], [], [], [#include <sys/socket.h>])
 
 # unconditionally pull-in librt with old glibc versions
 AC_SEARCH_LIBS([clock_gettime], [rt], [], [])
index dd4425697f1329406d95727b81f12f4204baece7..480462357de9e0f04ba7b54ceb1e4c7f12a106eb 100644 (file)
@@ -34,6 +34,7 @@
 #include <net/ethernet.h>
 #include <stdlib.h>
 #include <sys/resource.h>
+#include <sys/socket.h>
 #include <sys/syscall.h>
 #include <uchar.h>
 #include <unistd.h>
 #include <linux/btrfs.h>
 #endif
 
+#ifdef HAVE_LINUX_VM_SOCKETS_H
+#include <linux/vm_sockets.h>
+#else
+#define VMADDR_CID_ANY -1U
+struct sockaddr_vm {
+        unsigned short svm_family;
+        unsigned short svm_reserved1;
+        unsigned int svm_port;
+        unsigned int svm_cid;
+        unsigned char svm_zero[sizeof(struct sockaddr) -
+                               sizeof(unsigned short) -
+                               sizeof(unsigned short) -
+                               sizeof(unsigned int) -
+                               sizeof(unsigned int)];
+};
+#endif /* !HAVE_LINUX_VM_SOCKETS_H */
+
 #include "macro.h"
 
 #ifndef RLIMIT_RTTIME
@@ -1163,4 +1181,8 @@ struct ethtool_link_settings {
 #define SOL_ALG 279
 #endif
 
+#ifndef AF_VSOCK
+#define AF_VSOCK 40
+#endif
+
 #include "missing_syscall.h"