From f414dea1316a48aba3e8e293201ebd51652d3ef4 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Sun, 9 Jul 2017 15:17:29 -0700
Subject: [PATCH] Define in_* structs for non-glibc system libs

These defines and structs are required to be coming from
userspace netinet/in.h, which is being overridden in klibc
however, libc-compat.h from kernel is only written keeping
glibc in mind, and does not provide adequate guards for musl
to infer that these structs should be defined in linux/in.h

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 usr/include/netinet/in.h | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

Index: git/usr/include/netinet/in.h
===================================================================
--- git.orig/usr/include/netinet/in.h
+++ git/usr/include/netinet/in.h
@@ -5,6 +5,42 @@
 #ifndef _NETINET_IN_H
 #define _NETINET_IN_H
 
+#ifndef __GLIBC__
+#include <linux/libc-compat.h>
+
+#undef __UAPI_DEF_IN_ADDR
+#undef __UAPI_DEF_IN_IPPROTO
+#undef __UAPI_DEF_IN_PKTINFO
+#undef __UAPI_DEF_IP_MREQ
+#undef __UAPI_DEF_SOCKADDR_IN
+#undef __UAPI_DEF_IN_CLASS
+#undef __UAPI_DEF_IN6_ADDR
+#undef __UAPI_DEF_IN6_ADDR_ALT
+#undef __UAPI_DEF_SOCKADDR_IN6
+#undef __UAPI_DEF_IPV6_MREQ
+#undef __UAPI_DEF_IPPROTO_V6
+#undef __UAPI_DEF_IPV6_OPTIONS
+#undef __UAPI_DEF_IN6_PKTINFO
+#undef __UAPI_DEF_IP6_MTUINFO
+#undef __UAPI_DEF_IF_IFREQ
+
+#define __UAPI_DEF_IN_ADDR      1
+#define __UAPI_DEF_IN_IPPROTO   1
+#define __UAPI_DEF_IN_PKTINFO   1
+#define __UAPI_DEF_IP_MREQ      1
+#define __UAPI_DEF_SOCKADDR_IN  1
+#define __UAPI_DEF_IN_CLASS     1
+#define __UAPI_DEF_IN6_ADDR     1
+#define __UAPI_DEF_IN6_ADDR_ALT 1
+#define __UAPI_DEF_SOCKADDR_IN6 1
+#define __UAPI_DEF_IPV6_MREQ    1
+#define __UAPI_DEF_IPPROTO_V6   1
+#define __UAPI_DEF_IPV6_OPTIONS 1
+#define __UAPI_DEF_IN6_PKTINFO  1
+#define __UAPI_DEF_IP6_MTUINFO  1
+#define __UAPI_DEF_IF_IFREQ     1
+#endif
+
 #include <klibc/extern.h>
 #include <stdint.h>
 #include <endian.h>		/* Must be included *before* <linux/in.h> */
Index: git/usr/include/net/if.h
===================================================================
--- git.orig/usr/include/net/if.h
+++ git/usr/include/net/if.h
@@ -1,6 +1,17 @@
 #ifndef _NET_IF_H
 #define _NET_IF_H
 
+#ifndef __GLIBC__
+#include <linux/libc-compat.h>
+#undef __UAPI_DEF_IF_IFREQ
+#define __UAPI_DEF_IF_IFREQ            1
+#undef __UAPI_DEF_IF_IFNAMSIZ
+#define __UAPI_DEF_IF_IFNAMSIZ         1
+#undef __UAPI_DEF_IF_IFMAP
+#define __UAPI_DEF_IF_IFMAP            1
+#undef __UAPI_DEF_IF_NET_DEVICE_FLAGS
+#define __UAPI_DEF_IF_NET_DEVICE_FLAGS 1
+#endif
 #include <sys/socket.h>
 #include <sys/types.h>
 #include <linux/if.h>
