1From e9b500b3fea1ab678502f85a4bd360119e737215 Mon Sep 17 00:00:00 2001
2From: "Dmitry V. Levin" <ldv@altlinux.org>
3Date: Mon, 20 Feb 2017 14:58:41 +0300
4Subject: [PATCH 3/5] uapi: fix linux/if.h userspace compilation errors
5
6Include <sys/socket.h> (guarded by ifndef __KERNEL__) to fix
7the following linux/if.h userspace compilation errors:
8
9/usr/include/linux/if.h:234:19: error: field 'ifru_addr' has incomplete type
10   struct sockaddr ifru_addr;
11/usr/include/linux/if.h:235:19: error: field 'ifru_dstaddr' has incomplete type
12   struct sockaddr ifru_dstaddr;
13/usr/include/linux/if.h:236:19: error: field 'ifru_broadaddr' has incomplete type
14   struct sockaddr ifru_broadaddr;
15/usr/include/linux/if.h:237:19: error: field 'ifru_netmask' has incomplete type
16   struct sockaddr ifru_netmask;
17/usr/include/linux/if.h:238:20: error: field 'ifru_hwaddr' has incomplete type
18   struct  sockaddr ifru_hwaddr;
19
20This also fixes userspace compilation of the following uapi headers:
21  linux/atmbr2684.h
22  linux/gsmmux.h
23  linux/if_arp.h
24  linux/if_bonding.h
25  linux/if_frad.h
26  linux/if_pppox.h
27  linux/if_tunnel.h
28  linux/netdevice.h
29  linux/route.h
30  linux/wireless.h
31
32As no uapi header provides a definition of struct sockaddr, inclusion
33of <sys/socket.h> seems to be the most conservative and the only safe
34fix available.
35
36All current users of <linux/if.h> are very likely to be including
37<sys/socket.h> already because the latter is the sole provider
38of struct sockaddr definition in libc, so adding a uapi header
39with a definition of struct sockaddr would create a potential
40conflict with <sys/socket.h>.
41
42Replacing struct sockaddr in the definition of struct ifreq with
43a different type would create a potential incompatibility with current
44users of struct ifreq who might rely on ifru_addr et al members being
45of type struct sockaddr.
46
47Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
48Signed-off-by: David S. Miller <davem@davemloft.net>
49(cherry picked from commit 2618be7dccf8739b89e1906b64bd8d551af351e6)
50
51Change-Id: Ic0f66c7a623b63436496b28e7265d806420bf912
52Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
53---
54 include/uapi/linux/if.h | 4 ++++
55 1 file changed, 4 insertions(+)
56
57diff --git a/include/uapi/linux/if.h b/include/uapi/linux/if.h
58index 752f5dc040a5..21cfd1298913 100644
59--- a/include/uapi/linux/if.h
60+++ b/include/uapi/linux/if.h
61@@ -24,6 +24,10 @@
62 #include <linux/socket.h>		/* for "struct sockaddr" et al	*/
63 #include <linux/compiler.h>		/* for "__user" et al           */
64
65+#ifndef __KERNEL__
66+#include <sys/socket.h>			/* for struct sockaddr.		*/
67+#endif
68+
69 #if __UAPI_DEF_IF_IFNAMSIZ
70 #define	IFNAMSIZ	16
71 #endif /* __UAPI_DEF_IF_IFNAMSIZ */
72--
732.20.1
74
75