From 85fd8df03df56027645a52c91e9dac6712d86195 Mon Sep 17 00:00:00 2001
From: Yu Watanabe <watanabe.yu+github@gmail.com>
Date: Sun, 8 Sep 2024 00:15:38 +0900
Subject: [PATCH] missing_socket: drop unnecessary definitions

Now, we have copy of vm_sockets.h, hence these definitions are not
necessary anymore.
---
 meson.build                |  1 -
 src/basic/missing_socket.h | 41 --------------------------------------
 src/basic/socket-util.h    |  5 +++--
 3 files changed, 3 insertions(+), 44 deletions(-)

diff --git a/meson.build b/meson.build
index fbc2bbdf2f2..c26302d25ca 100644
--- a/meson.build
+++ b/meson.build
@@ -764,7 +764,6 @@ foreach header : ['crypt.h',
                   'linux/ioprio.h',
                   'linux/memfd.h',
                   'linux/time_types.h',
-                  'linux/vm_sockets.h',
                   'sys/auxv.h',
                   'sys/sdt.h',
                   'threads.h',
diff --git a/src/basic/missing_socket.h b/src/basic/missing_socket.h
index 5d9c5b483d9..55de40a3216 100644
--- a/src/basic/missing_socket.h
+++ b/src/basic/missing_socket.h
@@ -3,42 +3,6 @@
 
 #include <sys/socket.h>
 
-#if HAVE_LINUX_VM_SOCKETS_H
-#include <linux/vm_sockets.h>
-#else
-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 */
-
-#ifndef VMADDR_CID_ANY
-#define VMADDR_CID_ANY -1U
-#endif
-
-#ifndef VMADDR_CID_HYPERVISOR
-#define VMADDR_CID_HYPERVISOR 0U
-#endif
-
-#ifndef VMADDR_CID_LOCAL
-#define VMADDR_CID_LOCAL 1U
-#endif
-
-#ifndef VMADDR_CID_HOST
-#define VMADDR_CID_HOST 2U
-#endif
-
-#ifndef VMADDR_PORT_ANY
-#define VMADDR_PORT_ANY -1U
-#endif
-
 #ifndef AF_VSOCK
 #define AF_VSOCK 40
 #endif
@@ -104,8 +68,3 @@ struct sockaddr_vm {
 #ifndef IPV6_RECVFRAGSIZE
 #define IPV6_RECVFRAGSIZE 77
 #endif
-
-/* linux/sockios.h */
-#ifndef SIOCGSKNS
-#define SIOCGSKNS 0x894C
-#endif
diff --git a/src/basic/socket-util.h b/src/basic/socket-util.h
index 64eb6d7cdaa..ba86b907a7e 100644
--- a/src/basic/socket-util.h
+++ b/src/basic/socket-util.h
@@ -2,15 +2,16 @@
 #pragma once
 
 #include <inttypes.h>
-#include <linux/netlink.h>
 #include <linux/if_ether.h>
 #include <linux/if_infiniband.h>
 #include <linux/if_packet.h>
+#include <linux/netlink.h>
+#include <sys/socket.h> /* linux/vms_sockets.h requires 'struct sockaddr' */
+#include <linux/vm_sockets.h>
 #include <netinet/in.h>
 #include <stdbool.h>
 #include <stddef.h>
 #include <string.h>
-#include <sys/socket.h>
 #include <sys/types.h>
 #include <sys/un.h>