net: implement a SO_DOMAIN getsockoption
authorJan Engelhardt <jengelh@medozas.de>
Tue, 4 Aug 2009 07:28:29 +0000 (07:28 +0000)
committerDavid S. Miller <davem@davemloft.net>
Wed, 5 Aug 2009 20:02:57 +0000 (13:02 -0700)
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>
20 files changed:
arch/alpha/include/asm/socket.h
arch/arm/include/asm/socket.h
arch/avr32/include/asm/socket.h
arch/cris/include/asm/socket.h
arch/frv/include/asm/socket.h
arch/h8300/include/asm/socket.h
arch/ia64/include/asm/socket.h
arch/m32r/include/asm/socket.h
arch/m68k/include/asm/socket.h
arch/microblaze/include/asm/socket.h
arch/mips/include/asm/socket.h
arch/mn10300/include/asm/socket.h
arch/parisc/include/asm/socket.h
arch/powerpc/include/asm/socket.h
arch/s390/include/asm/socket.h
arch/sparc/include/asm/socket.h
arch/x86/include/asm/socket.h
arch/xtensa/include/asm/socket.h
include/asm-generic/socket.h
net/core/sock.c

index 2f8b4d3..26773e3 100644 (file)
@@ -33,6 +33,7 @@
 #define        SO_SNDTIMEO     0x1013
 #define SO_ACCEPTCONN  0x1014
 #define SO_PROTOCOL    0x1028
+#define SO_DOMAIN      0x1029
 
 /* linux-specific, might as well be the same as on i386 */
 #define SO_NO_CHECK    11
index 7f47454..92ac61d 100644 (file)
@@ -58,5 +58,6 @@
 #define SCM_TIMESTAMPING       SO_TIMESTAMPING
 
 #define SO_PROTOCOL            38
+#define SO_DOMAIN              39
 
 #endif /* _ASM_SOCKET_H */
index 6af2866..fe863f9 100644 (file)
@@ -58,5 +58,6 @@
 #define SCM_TIMESTAMPING       SO_TIMESTAMPING
 
 #define SO_PROTOCOL            38
+#define SO_DOMAIN              39
 
 #endif /* __ASM_AVR32_SOCKET_H */
index f3859fb..45ec49b 100644 (file)
@@ -60,6 +60,7 @@
 #define SCM_TIMESTAMPING       SO_TIMESTAMPING
 
 #define SO_PROTOCOL            38
+#define SO_DOMAIN              39
 
 #endif /* _ASM_SOCKET_H */
 
index 8dab348..2dea726 100644 (file)
@@ -58,6 +58,7 @@
 #define SCM_TIMESTAMPING       SO_TIMESTAMPING
 
 #define SO_PROTOCOL            38
+#define SO_DOMAIN              39
 
 #endif /* _ASM_SOCKET_H */
 
index ba770d0..1547f01 100644 (file)
@@ -58,5 +58,6 @@
 #define SCM_TIMESTAMPING       SO_TIMESTAMPING
 
 #define SO_PROTOCOL            38
+#define SO_DOMAIN              39
 
 #endif /* _ASM_SOCKET_H */
index 091cd9d..0b0d5ff 100644 (file)
@@ -67,5 +67,6 @@
 #define SCM_TIMESTAMPING       SO_TIMESTAMPING
 
 #define SO_PROTOCOL            38
+#define SO_DOMAIN              39
 
 #endif /* _ASM_IA64_SOCKET_H */
index d36f592..3390a86 100644 (file)
@@ -58,5 +58,6 @@
 #define SCM_TIMESTAMPING       SO_TIMESTAMPING
 
 #define SO_PROTOCOL            38
+#define SO_DOMAIN              39
 
 #endif /* _ASM_M32R_SOCKET_H */
index 060cb7e..eee01cc 100644 (file)
@@ -58,5 +58,6 @@
 #define SCM_TIMESTAMPING       SO_TIMESTAMPING
 
 #define SO_PROTOCOL            38
+#define SO_DOMAIN              39
 
 #endif /* _ASM_SOCKET_H */
index 96bf8bf..7361ae7 100644 (file)
@@ -67,5 +67,6 @@
 #define SCM_TIMESTAMPING       SO_TIMESTAMPING
 
 #define SO_PROTOCOL            38
+#define SO_DOMAIN              39
 
 #endif /* _ASM_MICROBLAZE_SOCKET_H */
index 289ce5f..ae05acc 100644 (file)
@@ -43,6 +43,7 @@ To add: #define SO_REUSEPORT 0x0200   /* Allow local address and port reuse.  */
 #define SO_RCVTIMEO    0x1006  /* receive timeout */
 #define SO_ACCEPTCONN  0x1009
 #define SO_PROTOCOL    0x1028  /* protocol type */
+#define SO_DOMAIN      0x1029  /* domain/socket family */
 
 /* linux-specific, might as well be the same as on i386 */
 #define SO_NO_CHECK    11
index 19d7cf7..4df75af 100644 (file)
@@ -58,5 +58,6 @@
 #define SCM_TIMESTAMPING       SO_TIMESTAMPING
 
 #define SO_PROTOCOL            38
+#define SO_DOMAIN              39
 
 #endif /* _ASM_SOCKET_H */
index a658b09..960b1e5 100644 (file)
@@ -25,6 +25,7 @@
 #define SO_ERROR       0x1007
 #define SO_TYPE                0x1008
 #define SO_PROTOCOL    0x1028
+#define SO_DOMAIN      0x1029
 #define SO_PEERNAME    0x2000
 
 #define SO_NO_CHECK    0x400b
index 609049d..3ab8b3e 100644 (file)
@@ -65,5 +65,6 @@
 #define SCM_TIMESTAMPING       SO_TIMESTAMPING
 
 #define SO_PROTOCOL            38
+#define SO_DOMAIN              39
 
 #endif /* _ASM_POWERPC_SOCKET_H */
index 65baa9a..e42df89 100644 (file)
@@ -66,5 +66,6 @@
 #define SCM_TIMESTAMPING       SO_TIMESTAMPING
 
 #define SO_PROTOCOL            38
+#define SO_DOMAIN              39
 
 #endif /* _ASM_SOCKET_H */
index 9cbbfaf..3a5ae3d 100644 (file)
@@ -30,6 +30,7 @@
 #define SO_ERROR       0x1007
 #define SO_TYPE                0x1008
 #define SO_PROTOCOL    0x1028
+#define SO_DOMAIN      0x1029
 
 
 /* Linux specific, keep the same. */
index 1077d25..b2a8c74 100644 (file)
@@ -58,5 +58,6 @@
 #define SCM_TIMESTAMPING       SO_TIMESTAMPING
 
 #define SO_PROTOCOL            38
+#define SO_DOMAIN              39
 
 #endif /* _ASM_X86_SOCKET_H */
index e47f172..beb3a6b 100644 (file)
@@ -69,5 +69,6 @@
 #define SCM_TIMESTAMPING       SO_TIMESTAMPING
 
 #define SO_PROTOCOL            38
+#define SO_DOMAIN              39
 
 #endif /* _XTENSA_SOCKET_H */
index 7e24d18..538991c 100644 (file)
@@ -61,5 +61,6 @@
 #define SCM_TIMESTAMPING       SO_TIMESTAMPING
 
 #define SO_PROTOCOL            38
+#define SO_DOMAIN              39
 
 #endif /* __ASM_GENERIC_SOCKET_H */
index ebce661..3ac34ea 100644 (file)
@@ -483,6 +483,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
                break;
        case SO_TYPE:
        case SO_PROTOCOL:
+       case SO_DOMAIN:
        case SO_ERROR:
                ret = -ENOPROTOOPT;
                break;
@@ -769,6 +770,10 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
                v.val = sk->sk_protocol;
                break;
 
+       case SO_DOMAIN:
+               v.val = sk->sk_family;
+               break;
+
        case SO_ERROR:
                v.val = -sock_error(sk);
                if (v.val == 0)