History

uapi: fix linux/if.h userspace compilation errors

Include <sys/socket.h> (guarded by ifndef __KERNEL__) to fix the following linux/if.h userspace compilation errors: /usr/include/linux/if.h:234:19: error: field 'ifru_addr' has incomplete type struct sockaddr ifru_addr; /usr/include/linux/if.h:235:19: error: field 'ifru_dstaddr' has incomplete type struct sockaddr ifru_dstaddr; /usr/include/linux/if.h:236:19: error: field 'ifru_broadaddr' has incomplete type struct sockaddr ifru_broadaddr; /usr/include/linux/if.h:237:19: error: field 'ifru_netmask' has incomplete type struct sockaddr ifru_netmask; /usr/include/linux/if.h:238:20: error: field 'ifru_hwaddr' has incomplete type struct sockaddr ifru_hwaddr; This also fixes userspace compilation of the following uapi headers: linux/atmbr2684.h linux/gsmmux.h linux/if_arp.h linux/if_bonding.h linux/if_frad.h linux/if_pppox.h linux/if_tunnel.h linux/netdevice.h linux/route.h linux/wireless.h As no uapi header provides a definition of struct sockaddr, inclusion of <sys/socket.h> seems to be the most conservative and the only safe fix available. All current users of <linux/if.h> are very likely to be including <sys/socket.h> already because the latter is the sole provider of struct sockaddr definition in libc, so adding a uapi header with a definition of struct sockaddr would create a potential conflict with <sys/socket.h>. Replacing struct sockaddr in the definition of struct ifreq with a different type would create a potential incompatibility with current users of struct ifreq who might rely on ifru_addr et al members being of type struct sockaddr.

Dmitry V. Levin committed 9 years ago

Commit 2618be71 parent 12d656a1 file · +4 −0Browse files

Showing the changes to include/uapi/linux (1 of 1 file). Show all

Unified · Split

include/uapi/linux/if.h+4−0
@@ -24,6 +24,10 @@ · 23 unmodified lines
24#include <linux/socket.h> /* for "struct sockaddr" et al */24#include <linux/socket.h> /* for "struct sockaddr" et al */
25#include <linux/compiler.h> /* for "__user" et al */25#include <linux/compiler.h> /* for "__user" et al */
26 26
27#ifndef __KERNEL__
28#include <sys/socket.h> /* for struct sockaddr. */
29#endif
30
27#if __UAPI_DEF_IF_IFNAMSIZ31#if __UAPI_DEF_IF_IFNAMSIZ
28#define IFNAMSIZ 1632#define IFNAMSIZ 16
29#endif /* __UAPI_DEF_IF_IFNAMSIZ */33#endif /* __UAPI_DEF_IF_IFNAMSIZ */