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