diff options
author | David S. Miller <davem@davemloft.net> | 2011-08-08 01:48:07 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-08-08 01:48:07 -0400 |
commit | 6602a4baf4d1a73cc4685a39ef859e1c5ddf654c (patch) | |
tree | d25eac2abeb52608af77e55b1acd56c8904aecea /include/linux/socket.h | |
parent | dd23198e58cd35259dd09e8892bbdb90f1d57748 (diff) |
net: Make userland include of netlink.h more sane.
Currently userland will barf when including linux/netlink.h unless it
precisely includes sys/socket.h first. The issue is where the
definition of "sa_family_t" comes from.
We've been back and forth on how to fix this issue in the past, see:
http://thread.gmane.org/gmane.linux.debian.devel.bugs.general/622621
http://thread.gmane.org/gmane.linux.network/143380
Ben Hutchings suggested we take a hint from how we handle the
sockaddr_storage type. First we define a "__kernel_sa_family_t"
to linux/socket.h that is always defined.
Then if __KERNEL__ is defined, we also define "sa_family_t" as
equal to "__kernel_sa_family_t".
Then in places like linux/netlink.h we use __kernel_sa_family_t
in user visible datastructures.
Reported-by: Michel Machado <michel@digirati.com.br>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/socket.h')
-rw-r--r-- | include/linux/socket.h | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/include/linux/socket.h b/include/linux/socket.h index e17f82266639..d0e77f607a79 100644 --- a/include/linux/socket.h +++ b/include/linux/socket.h | |||
@@ -8,8 +8,10 @@ | |||
8 | #define _K_SS_ALIGNSIZE (__alignof__ (struct sockaddr *)) | 8 | #define _K_SS_ALIGNSIZE (__alignof__ (struct sockaddr *)) |
9 | /* Implementation specific desired alignment */ | 9 | /* Implementation specific desired alignment */ |
10 | 10 | ||
11 | typedef unsigned short __kernel_sa_family_t; | ||
12 | |||
11 | struct __kernel_sockaddr_storage { | 13 | struct __kernel_sockaddr_storage { |
12 | unsigned short ss_family; /* address family */ | 14 | __kernel_sa_family_t ss_family; /* address family */ |
13 | /* Following field(s) are implementation specific */ | 15 | /* Following field(s) are implementation specific */ |
14 | char __data[_K_SS_MAXSIZE - sizeof(unsigned short)]; | 16 | char __data[_K_SS_MAXSIZE - sizeof(unsigned short)]; |
15 | /* space to achieve desired size, */ | 17 | /* space to achieve desired size, */ |
@@ -35,7 +37,7 @@ struct seq_file; | |||
35 | extern void socket_seq_show(struct seq_file *seq); | 37 | extern void socket_seq_show(struct seq_file *seq); |
36 | #endif | 38 | #endif |
37 | 39 | ||
38 | typedef unsigned short sa_family_t; | 40 | typedef __kernel_sa_family_t sa_family_t; |
39 | 41 | ||
40 | /* | 42 | /* |
41 | * 1003.1g requires sa_family_t and that sa_data is char. | 43 | * 1003.1g requires sa_family_t and that sa_data is char. |