Use in_addr in ip_mreq_source and ip_msfilter.
This adds a new mechanism to say "replace struct S with #include <bits/S.h>".
Also switch epoll_event over to the new mechanism.
Also use the kernel's struct sockaddr_storage directly rather than behind
an unnecessary #define.
This patch also removes some dead code in the header scrubber. This code
still needs rewriting completely. I learned that a "block" isn't necessarily
a single struct definition, say; it might be a run of them. It seems like
a block is a run of preprocessor directives or a run of regular code.
Bug: https://issuetracker.google.com/36987220
Test: new test
Change-Id: Ic6a5c09559766a4babe3cd4c3ea538b885e07308
diff --git a/libc/kernel/uapi/linux/eventpoll.h b/libc/kernel/uapi/linux/eventpoll.h
index d0a5f6e..eec1077 100644
--- a/libc/kernel/uapi/linux/eventpoll.h
+++ b/libc/kernel/uapi/linux/eventpoll.h
@@ -18,6 +18,7 @@
****************************************************************************/
#ifndef _UAPI_LINUX_EVENTPOLL_H
#define _UAPI_LINUX_EVENTPOLL_H
+#include <bits/epoll_event.h>
#include <linux/fcntl.h>
#include <linux/types.h>
#define EPOLL_CLOEXEC O_CLOEXEC
@@ -44,8 +45,4 @@
#else
#define EPOLL_PACKED
#endif
-struct __kernel_uapi_epoll_event {
- __u32 events;
- __u64 data;
-} EPOLL_PACKED;
#endif
diff --git a/libc/kernel/uapi/linux/if.h b/libc/kernel/uapi/linux/if.h
index d815ef8..15de690 100644
--- a/libc/kernel/uapi/linux/if.h
+++ b/libc/kernel/uapi/linux/if.h
@@ -31,10 +31,27 @@
#if __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO != 0 || __UAPI_DEF_IF_NET_DEVICE_FLAGS != 0
enum net_device_flags {
#if __UAPI_DEF_IF_NET_DEVICE_FLAGS
- IFF_UP = 1 << 0, IFF_BROADCAST = 1 << 1, IFF_DEBUG = 1 << 2, IFF_LOOPBACK = 1 << 3, IFF_POINTOPOINT = 1 << 4, IFF_NOTRAILERS = 1 << 5, IFF_RUNNING = 1 << 6, IFF_NOARP = 1 << 7, IFF_PROMISC = 1 << 8, IFF_ALLMULTI = 1 << 9, IFF_MASTER = 1 << 10, IFF_SLAVE = 1 << 11, IFF_MULTICAST = 1 << 12, IFF_PORTSEL = 1 << 13, IFF_AUTOMEDIA = 1 << 14, IFF_DYNAMIC = 1 << 15,
+ IFF_UP = 1 << 0,
+ IFF_BROADCAST = 1 << 1,
+ IFF_DEBUG = 1 << 2,
+ IFF_LOOPBACK = 1 << 3,
+ IFF_POINTOPOINT = 1 << 4,
+ IFF_NOTRAILERS = 1 << 5,
+ IFF_RUNNING = 1 << 6,
+ IFF_NOARP = 1 << 7,
+ IFF_PROMISC = 1 << 8,
+ IFF_ALLMULTI = 1 << 9,
+ IFF_MASTER = 1 << 10,
+ IFF_SLAVE = 1 << 11,
+ IFF_MULTICAST = 1 << 12,
+ IFF_PORTSEL = 1 << 13,
+ IFF_AUTOMEDIA = 1 << 14,
+ IFF_DYNAMIC = 1 << 15,
#endif
#if __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO
- IFF_LOWER_UP = 1 << 16, IFF_DORMANT = 1 << 17, IFF_ECHO = 1 << 18,
+ IFF_LOWER_UP = 1 << 16,
+ IFF_DORMANT = 1 << 17,
+ IFF_ECHO = 1 << 18,
#endif
};
#endif
diff --git a/libc/kernel/uapi/linux/in.h b/libc/kernel/uapi/linux/in.h
index 351126a..788a6d9 100644
--- a/libc/kernel/uapi/linux/in.h
+++ b/libc/kernel/uapi/linux/in.h
@@ -18,6 +18,9 @@
****************************************************************************/
#ifndef _UAPI_LINUX_IN_H
#define _UAPI_LINUX_IN_H
+#include <bits/ip_msfilter.h>
+#include <bits/ip_mreq_source.h>
+#include <bits/in_addr.h>
#include <linux/types.h>
#include <linux/libc-compat.h>
#include <linux/socket.h>
@@ -77,9 +80,6 @@
};
#endif
#if __UAPI_DEF_IN_ADDR
-struct in_addr {
- __be32 s_addr;
-};
#endif
#define IP_TOS 1
#define IP_TTL 2
@@ -147,36 +147,24 @@
struct in_addr imr_address;
int imr_ifindex;
};
-struct ip_mreq_source {
- __be32 imr_multiaddr;
- __be32 imr_interface;
- __be32 imr_sourceaddr;
-};
-struct ip_msfilter {
- __be32 imsf_multiaddr;
- __be32 imsf_interface;
- __u32 imsf_fmode;
- __u32 imsf_numsrc;
- __be32 imsf_slist[1];
-};
#define IP_MSFILTER_SIZE(numsrc) (sizeof(struct ip_msfilter) - sizeof(__u32) + (numsrc) * sizeof(__u32))
struct group_req {
__u32 gr_interface;
- struct __kernel_sockaddr_storage gr_group;
+ struct sockaddr_storage gr_group;
};
struct group_source_req {
__u32 gsr_interface;
- struct __kernel_sockaddr_storage gsr_group;
- struct __kernel_sockaddr_storage gsr_source;
+ struct sockaddr_storage gsr_group;
+ struct sockaddr_storage gsr_source;
};
struct group_filter {
__u32 gf_interface;
- struct __kernel_sockaddr_storage gf_group;
+ struct sockaddr_storage gf_group;
__u32 gf_fmode;
__u32 gf_numsrc;
- struct __kernel_sockaddr_storage gf_slist[1];
+ struct sockaddr_storage gf_slist[1];
};
-#define GROUP_FILTER_SIZE(numsrc) (sizeof(struct group_filter) - sizeof(struct __kernel_sockaddr_storage) + (numsrc) * sizeof(struct __kernel_sockaddr_storage))
+#define GROUP_FILTER_SIZE(numsrc) (sizeof(struct group_filter) - sizeof(struct sockaddr_storage) + (numsrc) * sizeof(struct sockaddr_storage))
#endif
#if __UAPI_DEF_IN_PKTINFO
struct in_pktinfo {
diff --git a/libc/kernel/uapi/linux/rds.h b/libc/kernel/uapi/linux/rds.h
index ccb3f54..cfb0a3b 100644
--- a/libc/kernel/uapi/linux/rds.h
+++ b/libc/kernel/uapi/linux/rds.h
@@ -145,7 +145,7 @@
__u64 flags;
};
struct rds_get_mr_for_dest_args {
- struct __kernel_sockaddr_storage dest_addr;
+ struct sockaddr_storage dest_addr;
struct rds_iovec vec;
__u64 cookie_addr;
__u64 flags;
diff --git a/libc/kernel/uapi/linux/socket.h b/libc/kernel/uapi/linux/socket.h
index 371ba30..4f52bcb 100644
--- a/libc/kernel/uapi/linux/socket.h
+++ b/libc/kernel/uapi/linux/socket.h
@@ -21,7 +21,7 @@
#define _K_SS_MAXSIZE 128
#define _K_SS_ALIGNSIZE (__alignof__(struct sockaddr *))
typedef unsigned short __kernel_sa_family_t;
-struct __kernel_sockaddr_storage {
+struct sockaddr_storage {
__kernel_sa_family_t ss_family;
char __data[_K_SS_MAXSIZE - sizeof(unsigned short)];
} __attribute__((aligned(_K_SS_ALIGNSIZE)));
diff --git a/libc/kernel/uapi/linux/tcp.h b/libc/kernel/uapi/linux/tcp.h
index f5134d6..13354e6 100644
--- a/libc/kernel/uapi/linux/tcp.h
+++ b/libc/kernel/uapi/linux/tcp.h
@@ -188,7 +188,7 @@
#define TCP_MD5SIG_MAXKEYLEN 80
#define TCP_MD5SIG_FLAG_PREFIX 1
struct tcp_md5sig {
- struct __kernel_sockaddr_storage tcpm_addr;
+ struct sockaddr_storage tcpm_addr;
__u8 tcpm_flags;
__u8 tcpm_prefixlen;
__u16 tcpm_keylen;