diff options
author | Jan Engelhardt <jengelh@medozas.de> | 2009-08-04 03:28:29 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-08-05 16:02:57 -0400 |
commit | 0d6038ee76f2e06b79d0465807f67e86bf4025de (patch) | |
tree | ffb88e2f817ae2a76fece58a7f7d0de3fd37fbaf | |
parent | 49c794e94649020248e37b78db16cd25bad38b4f (diff) |
net: implement a SO_DOMAIN getsockoption
This sockopt goes in line with SO_TYPE and SO_PROTOCOL. It makes it
possible for userspace programs to pass around file descriptors — I
am referring to arguments-to-functions, but it may even work for the
fd passing over UNIX sockets — without needing to also pass the
auxiliary information (PF_INET6/IPPROTO_TCP).
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | arch/alpha/include/asm/socket.h | 1 | ||||
-rw-r--r-- | arch/arm/include/asm/socket.h | 1 | ||||
-rw-r--r-- | arch/avr32/include/asm/socket.h | 1 | ||||
-rw-r--r-- | arch/cris/include/asm/socket.h | 1 | ||||
-rw-r--r-- | arch/frv/include/asm/socket.h | 1 | ||||
-rw-r--r-- | arch/h8300/include/asm/socket.h | 1 | ||||
-rw-r--r-- | arch/ia64/include/asm/socket.h | 1 | ||||
-rw-r--r-- | arch/m32r/include/asm/socket.h | 1 | ||||
-rw-r--r-- | arch/m68k/include/asm/socket.h | 1 | ||||
-rw-r--r-- | arch/microblaze/include/asm/socket.h | 1 | ||||
-rw-r--r-- | arch/mips/include/asm/socket.h | 1 | ||||
-rw-r--r-- | arch/mn10300/include/asm/socket.h | 1 | ||||
-rw-r--r-- | arch/parisc/include/asm/socket.h | 1 | ||||
-rw-r--r-- | arch/powerpc/include/asm/socket.h | 1 | ||||
-rw-r--r-- | arch/s390/include/asm/socket.h | 1 | ||||
-rw-r--r-- | arch/sparc/include/asm/socket.h | 1 | ||||
-rw-r--r-- | arch/x86/include/asm/socket.h | 1 | ||||
-rw-r--r-- | arch/xtensa/include/asm/socket.h | 1 | ||||
-rw-r--r-- | include/asm-generic/socket.h | 1 | ||||
-rw-r--r-- | net/core/sock.c | 5 |
20 files changed, 24 insertions, 0 deletions
diff --git a/arch/alpha/include/asm/socket.h b/arch/alpha/include/asm/socket.h index 2f8b4d377749..26773e3246e2 100644 --- a/arch/alpha/include/asm/socket.h +++ b/arch/alpha/include/asm/socket.h | |||
@@ -33,6 +33,7 @@ | |||
33 | #define SO_SNDTIMEO 0x1013 | 33 | #define SO_SNDTIMEO 0x1013 |
34 | #define SO_ACCEPTCONN 0x1014 | 34 | #define SO_ACCEPTCONN 0x1014 |
35 | #define SO_PROTOCOL 0x1028 | 35 | #define SO_PROTOCOL 0x1028 |
36 | #define SO_DOMAIN 0x1029 | ||
36 | 37 | ||
37 | /* linux-specific, might as well be the same as on i386 */ | 38 | /* linux-specific, might as well be the same as on i386 */ |
38 | #define SO_NO_CHECK 11 | 39 | #define SO_NO_CHECK 11 |
diff --git a/arch/arm/include/asm/socket.h b/arch/arm/include/asm/socket.h index 7f47454ffbf3..92ac61d294fd 100644 --- a/arch/arm/include/asm/socket.h +++ b/arch/arm/include/asm/socket.h | |||
@@ -58,5 +58,6 @@ | |||
58 | #define SCM_TIMESTAMPING SO_TIMESTAMPING | 58 | #define SCM_TIMESTAMPING SO_TIMESTAMPING |
59 | 59 | ||
60 | #define SO_PROTOCOL 38 | 60 | #define SO_PROTOCOL 38 |
61 | #define SO_DOMAIN 39 | ||
61 | 62 | ||
62 | #endif /* _ASM_SOCKET_H */ | 63 | #endif /* _ASM_SOCKET_H */ |
diff --git a/arch/avr32/include/asm/socket.h b/arch/avr32/include/asm/socket.h index 6af2866a4f00..fe863f9794d5 100644 --- a/arch/avr32/include/asm/socket.h +++ b/arch/avr32/include/asm/socket.h | |||
@@ -58,5 +58,6 @@ | |||
58 | #define SCM_TIMESTAMPING SO_TIMESTAMPING | 58 | #define SCM_TIMESTAMPING SO_TIMESTAMPING |
59 | 59 | ||
60 | #define SO_PROTOCOL 38 | 60 | #define SO_PROTOCOL 38 |
61 | #define SO_DOMAIN 39 | ||
61 | 62 | ||
62 | #endif /* __ASM_AVR32_SOCKET_H */ | 63 | #endif /* __ASM_AVR32_SOCKET_H */ |
diff --git a/arch/cris/include/asm/socket.h b/arch/cris/include/asm/socket.h index f3859fb0990c..45ec49bdb7b1 100644 --- a/arch/cris/include/asm/socket.h +++ b/arch/cris/include/asm/socket.h | |||
@@ -60,6 +60,7 @@ | |||
60 | #define SCM_TIMESTAMPING SO_TIMESTAMPING | 60 | #define SCM_TIMESTAMPING SO_TIMESTAMPING |
61 | 61 | ||
62 | #define SO_PROTOCOL 38 | 62 | #define SO_PROTOCOL 38 |
63 | #define SO_DOMAIN 39 | ||
63 | 64 | ||
64 | #endif /* _ASM_SOCKET_H */ | 65 | #endif /* _ASM_SOCKET_H */ |
65 | 66 | ||
diff --git a/arch/frv/include/asm/socket.h b/arch/frv/include/asm/socket.h index 8dab3486ffa4..2dea726095c2 100644 --- a/arch/frv/include/asm/socket.h +++ b/arch/frv/include/asm/socket.h | |||
@@ -58,6 +58,7 @@ | |||
58 | #define SCM_TIMESTAMPING SO_TIMESTAMPING | 58 | #define SCM_TIMESTAMPING SO_TIMESTAMPING |
59 | 59 | ||
60 | #define SO_PROTOCOL 38 | 60 | #define SO_PROTOCOL 38 |
61 | #define SO_DOMAIN 39 | ||
61 | 62 | ||
62 | #endif /* _ASM_SOCKET_H */ | 63 | #endif /* _ASM_SOCKET_H */ |
63 | 64 | ||
diff --git a/arch/h8300/include/asm/socket.h b/arch/h8300/include/asm/socket.h index ba770d09cd63..1547f01c8e22 100644 --- a/arch/h8300/include/asm/socket.h +++ b/arch/h8300/include/asm/socket.h | |||
@@ -58,5 +58,6 @@ | |||
58 | #define SCM_TIMESTAMPING SO_TIMESTAMPING | 58 | #define SCM_TIMESTAMPING SO_TIMESTAMPING |
59 | 59 | ||
60 | #define SO_PROTOCOL 38 | 60 | #define SO_PROTOCOL 38 |
61 | #define SO_DOMAIN 39 | ||
61 | 62 | ||
62 | #endif /* _ASM_SOCKET_H */ | 63 | #endif /* _ASM_SOCKET_H */ |
diff --git a/arch/ia64/include/asm/socket.h b/arch/ia64/include/asm/socket.h index 091cd9d47d0f..0b0d5ff062e5 100644 --- a/arch/ia64/include/asm/socket.h +++ b/arch/ia64/include/asm/socket.h | |||
@@ -67,5 +67,6 @@ | |||
67 | #define SCM_TIMESTAMPING SO_TIMESTAMPING | 67 | #define SCM_TIMESTAMPING SO_TIMESTAMPING |
68 | 68 | ||
69 | #define SO_PROTOCOL 38 | 69 | #define SO_PROTOCOL 38 |
70 | #define SO_DOMAIN 39 | ||
70 | 71 | ||
71 | #endif /* _ASM_IA64_SOCKET_H */ | 72 | #endif /* _ASM_IA64_SOCKET_H */ |
diff --git a/arch/m32r/include/asm/socket.h b/arch/m32r/include/asm/socket.h index d36f5928fb79..3390a864f224 100644 --- a/arch/m32r/include/asm/socket.h +++ b/arch/m32r/include/asm/socket.h | |||
@@ -58,5 +58,6 @@ | |||
58 | #define SCM_TIMESTAMPING SO_TIMESTAMPING | 58 | #define SCM_TIMESTAMPING SO_TIMESTAMPING |
59 | 59 | ||
60 | #define SO_PROTOCOL 38 | 60 | #define SO_PROTOCOL 38 |
61 | #define SO_DOMAIN 39 | ||
61 | 62 | ||
62 | #endif /* _ASM_M32R_SOCKET_H */ | 63 | #endif /* _ASM_M32R_SOCKET_H */ |
diff --git a/arch/m68k/include/asm/socket.h b/arch/m68k/include/asm/socket.h index 060cb7ed024f..eee01cce921b 100644 --- a/arch/m68k/include/asm/socket.h +++ b/arch/m68k/include/asm/socket.h | |||
@@ -58,5 +58,6 @@ | |||
58 | #define SCM_TIMESTAMPING SO_TIMESTAMPING | 58 | #define SCM_TIMESTAMPING SO_TIMESTAMPING |
59 | 59 | ||
60 | #define SO_PROTOCOL 38 | 60 | #define SO_PROTOCOL 38 |
61 | #define SO_DOMAIN 39 | ||
61 | 62 | ||
62 | #endif /* _ASM_SOCKET_H */ | 63 | #endif /* _ASM_SOCKET_H */ |
diff --git a/arch/microblaze/include/asm/socket.h b/arch/microblaze/include/asm/socket.h index 96bf8bfa935e..7361ae7cfcde 100644 --- a/arch/microblaze/include/asm/socket.h +++ b/arch/microblaze/include/asm/socket.h | |||
@@ -67,5 +67,6 @@ | |||
67 | #define SCM_TIMESTAMPING SO_TIMESTAMPING | 67 | #define SCM_TIMESTAMPING SO_TIMESTAMPING |
68 | 68 | ||
69 | #define SO_PROTOCOL 38 | 69 | #define SO_PROTOCOL 38 |
70 | #define SO_DOMAIN 39 | ||
70 | 71 | ||
71 | #endif /* _ASM_MICROBLAZE_SOCKET_H */ | 72 | #endif /* _ASM_MICROBLAZE_SOCKET_H */ |
diff --git a/arch/mips/include/asm/socket.h b/arch/mips/include/asm/socket.h index 289ce5f5f2a3..ae05accd9fe4 100644 --- a/arch/mips/include/asm/socket.h +++ b/arch/mips/include/asm/socket.h | |||
@@ -43,6 +43,7 @@ To add: #define SO_REUSEPORT 0x0200 /* Allow local address and port reuse. */ | |||
43 | #define SO_RCVTIMEO 0x1006 /* receive timeout */ | 43 | #define SO_RCVTIMEO 0x1006 /* receive timeout */ |
44 | #define SO_ACCEPTCONN 0x1009 | 44 | #define SO_ACCEPTCONN 0x1009 |
45 | #define SO_PROTOCOL 0x1028 /* protocol type */ | 45 | #define SO_PROTOCOL 0x1028 /* protocol type */ |
46 | #define SO_DOMAIN 0x1029 /* domain/socket family */ | ||
46 | 47 | ||
47 | /* linux-specific, might as well be the same as on i386 */ | 48 | /* linux-specific, might as well be the same as on i386 */ |
48 | #define SO_NO_CHECK 11 | 49 | #define SO_NO_CHECK 11 |
diff --git a/arch/mn10300/include/asm/socket.h b/arch/mn10300/include/asm/socket.h index 19d7cf709b77..4df75af29d76 100644 --- a/arch/mn10300/include/asm/socket.h +++ b/arch/mn10300/include/asm/socket.h | |||
@@ -58,5 +58,6 @@ | |||
58 | #define SCM_TIMESTAMPING SO_TIMESTAMPING | 58 | #define SCM_TIMESTAMPING SO_TIMESTAMPING |
59 | 59 | ||
60 | #define SO_PROTOCOL 38 | 60 | #define SO_PROTOCOL 38 |
61 | #define SO_DOMAIN 39 | ||
61 | 62 | ||
62 | #endif /* _ASM_SOCKET_H */ | 63 | #endif /* _ASM_SOCKET_H */ |
diff --git a/arch/parisc/include/asm/socket.h b/arch/parisc/include/asm/socket.h index a658b09df624..960b1e5d8e16 100644 --- a/arch/parisc/include/asm/socket.h +++ b/arch/parisc/include/asm/socket.h | |||
@@ -25,6 +25,7 @@ | |||
25 | #define SO_ERROR 0x1007 | 25 | #define SO_ERROR 0x1007 |
26 | #define SO_TYPE 0x1008 | 26 | #define SO_TYPE 0x1008 |
27 | #define SO_PROTOCOL 0x1028 | 27 | #define SO_PROTOCOL 0x1028 |
28 | #define SO_DOMAIN 0x1029 | ||
28 | #define SO_PEERNAME 0x2000 | 29 | #define SO_PEERNAME 0x2000 |
29 | 30 | ||
30 | #define SO_NO_CHECK 0x400b | 31 | #define SO_NO_CHECK 0x400b |
diff --git a/arch/powerpc/include/asm/socket.h b/arch/powerpc/include/asm/socket.h index 609049d7117e..3ab8b3e6feb0 100644 --- a/arch/powerpc/include/asm/socket.h +++ b/arch/powerpc/include/asm/socket.h | |||
@@ -65,5 +65,6 @@ | |||
65 | #define SCM_TIMESTAMPING SO_TIMESTAMPING | 65 | #define SCM_TIMESTAMPING SO_TIMESTAMPING |
66 | 66 | ||
67 | #define SO_PROTOCOL 38 | 67 | #define SO_PROTOCOL 38 |
68 | #define SO_DOMAIN 39 | ||
68 | 69 | ||
69 | #endif /* _ASM_POWERPC_SOCKET_H */ | 70 | #endif /* _ASM_POWERPC_SOCKET_H */ |
diff --git a/arch/s390/include/asm/socket.h b/arch/s390/include/asm/socket.h index 65baa9a83abc..e42df89a0b85 100644 --- a/arch/s390/include/asm/socket.h +++ b/arch/s390/include/asm/socket.h | |||
@@ -66,5 +66,6 @@ | |||
66 | #define SCM_TIMESTAMPING SO_TIMESTAMPING | 66 | #define SCM_TIMESTAMPING SO_TIMESTAMPING |
67 | 67 | ||
68 | #define SO_PROTOCOL 38 | 68 | #define SO_PROTOCOL 38 |
69 | #define SO_DOMAIN 39 | ||
69 | 70 | ||
70 | #endif /* _ASM_SOCKET_H */ | 71 | #endif /* _ASM_SOCKET_H */ |
diff --git a/arch/sparc/include/asm/socket.h b/arch/sparc/include/asm/socket.h index 9cbbfafd0538..3a5ae3d12088 100644 --- a/arch/sparc/include/asm/socket.h +++ b/arch/sparc/include/asm/socket.h | |||
@@ -30,6 +30,7 @@ | |||
30 | #define SO_ERROR 0x1007 | 30 | #define SO_ERROR 0x1007 |
31 | #define SO_TYPE 0x1008 | 31 | #define SO_TYPE 0x1008 |
32 | #define SO_PROTOCOL 0x1028 | 32 | #define SO_PROTOCOL 0x1028 |
33 | #define SO_DOMAIN 0x1029 | ||
33 | 34 | ||
34 | 35 | ||
35 | /* Linux specific, keep the same. */ | 36 | /* Linux specific, keep the same. */ |
diff --git a/arch/x86/include/asm/socket.h b/arch/x86/include/asm/socket.h index 1077d2535a32..b2a8c74f2d06 100644 --- a/arch/x86/include/asm/socket.h +++ b/arch/x86/include/asm/socket.h | |||
@@ -58,5 +58,6 @@ | |||
58 | #define SCM_TIMESTAMPING SO_TIMESTAMPING | 58 | #define SCM_TIMESTAMPING SO_TIMESTAMPING |
59 | 59 | ||
60 | #define SO_PROTOCOL 38 | 60 | #define SO_PROTOCOL 38 |
61 | #define SO_DOMAIN 39 | ||
61 | 62 | ||
62 | #endif /* _ASM_X86_SOCKET_H */ | 63 | #endif /* _ASM_X86_SOCKET_H */ |
diff --git a/arch/xtensa/include/asm/socket.h b/arch/xtensa/include/asm/socket.h index e47f172142f1..beb3a6bdb61d 100644 --- a/arch/xtensa/include/asm/socket.h +++ b/arch/xtensa/include/asm/socket.h | |||
@@ -69,5 +69,6 @@ | |||
69 | #define SCM_TIMESTAMPING SO_TIMESTAMPING | 69 | #define SCM_TIMESTAMPING SO_TIMESTAMPING |
70 | 70 | ||
71 | #define SO_PROTOCOL 38 | 71 | #define SO_PROTOCOL 38 |
72 | #define SO_DOMAIN 39 | ||
72 | 73 | ||
73 | #endif /* _XTENSA_SOCKET_H */ | 74 | #endif /* _XTENSA_SOCKET_H */ |
diff --git a/include/asm-generic/socket.h b/include/asm-generic/socket.h index 7e24d186616e..538991cef6f0 100644 --- a/include/asm-generic/socket.h +++ b/include/asm-generic/socket.h | |||
@@ -61,5 +61,6 @@ | |||
61 | #define SCM_TIMESTAMPING SO_TIMESTAMPING | 61 | #define SCM_TIMESTAMPING SO_TIMESTAMPING |
62 | 62 | ||
63 | #define SO_PROTOCOL 38 | 63 | #define SO_PROTOCOL 38 |
64 | #define SO_DOMAIN 39 | ||
64 | 65 | ||
65 | #endif /* __ASM_GENERIC_SOCKET_H */ | 66 | #endif /* __ASM_GENERIC_SOCKET_H */ |
diff --git a/net/core/sock.c b/net/core/sock.c index ebce661234ac..3ac34ea6ec05 100644 --- a/net/core/sock.c +++ b/net/core/sock.c | |||
@@ -483,6 +483,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname, | |||
483 | break; | 483 | break; |
484 | case SO_TYPE: | 484 | case SO_TYPE: |
485 | case SO_PROTOCOL: | 485 | case SO_PROTOCOL: |
486 | case SO_DOMAIN: | ||
486 | case SO_ERROR: | 487 | case SO_ERROR: |
487 | ret = -ENOPROTOOPT; | 488 | ret = -ENOPROTOOPT; |
488 | break; | 489 | break; |
@@ -769,6 +770,10 @@ int sock_getsockopt(struct socket *sock, int level, int optname, | |||
769 | v.val = sk->sk_protocol; | 770 | v.val = sk->sk_protocol; |
770 | break; | 771 | break; |
771 | 772 | ||
773 | case SO_DOMAIN: | ||
774 | v.val = sk->sk_family; | ||
775 | break; | ||
776 | |||
772 | case SO_ERROR: | 777 | case SO_ERROR: |
773 | v.val = -sock_error(sk); | 778 | v.val = -sock_error(sk); |
774 | if (v.val == 0) | 779 | if (v.val == 0) |