Commit 0d6038ee authored by Jan Engelhardt's avatar Jan Engelhardt Committed by David S. Miller

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: default avatarJan Engelhardt <jengelh@medozas.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 49c794e9
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#define SO_SNDTIMEO 0x1013 #define SO_SNDTIMEO 0x1013
#define SO_ACCEPTCONN 0x1014 #define SO_ACCEPTCONN 0x1014
#define SO_PROTOCOL 0x1028 #define SO_PROTOCOL 0x1028
#define SO_DOMAIN 0x1029
/* linux-specific, might as well be the same as on i386 */ /* linux-specific, might as well be the same as on i386 */
#define SO_NO_CHECK 11 #define SO_NO_CHECK 11
......
...@@ -58,5 +58,6 @@ ...@@ -58,5 +58,6 @@
#define SCM_TIMESTAMPING SO_TIMESTAMPING #define SCM_TIMESTAMPING SO_TIMESTAMPING
#define SO_PROTOCOL 38 #define SO_PROTOCOL 38
#define SO_DOMAIN 39
#endif /* _ASM_SOCKET_H */ #endif /* _ASM_SOCKET_H */
...@@ -58,5 +58,6 @@ ...@@ -58,5 +58,6 @@
#define SCM_TIMESTAMPING SO_TIMESTAMPING #define SCM_TIMESTAMPING SO_TIMESTAMPING
#define SO_PROTOCOL 38 #define SO_PROTOCOL 38
#define SO_DOMAIN 39
#endif /* __ASM_AVR32_SOCKET_H */ #endif /* __ASM_AVR32_SOCKET_H */
...@@ -60,6 +60,7 @@ ...@@ -60,6 +60,7 @@
#define SCM_TIMESTAMPING SO_TIMESTAMPING #define SCM_TIMESTAMPING SO_TIMESTAMPING
#define SO_PROTOCOL 38 #define SO_PROTOCOL 38
#define SO_DOMAIN 39
#endif /* _ASM_SOCKET_H */ #endif /* _ASM_SOCKET_H */
......
...@@ -58,6 +58,7 @@ ...@@ -58,6 +58,7 @@
#define SCM_TIMESTAMPING SO_TIMESTAMPING #define SCM_TIMESTAMPING SO_TIMESTAMPING
#define SO_PROTOCOL 38 #define SO_PROTOCOL 38
#define SO_DOMAIN 39
#endif /* _ASM_SOCKET_H */ #endif /* _ASM_SOCKET_H */
...@@ -58,5 +58,6 @@ ...@@ -58,5 +58,6 @@
#define SCM_TIMESTAMPING SO_TIMESTAMPING #define SCM_TIMESTAMPING SO_TIMESTAMPING
#define SO_PROTOCOL 38 #define SO_PROTOCOL 38
#define SO_DOMAIN 39
#endif /* _ASM_SOCKET_H */ #endif /* _ASM_SOCKET_H */
...@@ -67,5 +67,6 @@ ...@@ -67,5 +67,6 @@
#define SCM_TIMESTAMPING SO_TIMESTAMPING #define SCM_TIMESTAMPING SO_TIMESTAMPING
#define SO_PROTOCOL 38 #define SO_PROTOCOL 38
#define SO_DOMAIN 39
#endif /* _ASM_IA64_SOCKET_H */ #endif /* _ASM_IA64_SOCKET_H */
...@@ -58,5 +58,6 @@ ...@@ -58,5 +58,6 @@
#define SCM_TIMESTAMPING SO_TIMESTAMPING #define SCM_TIMESTAMPING SO_TIMESTAMPING
#define SO_PROTOCOL 38 #define SO_PROTOCOL 38
#define SO_DOMAIN 39
#endif /* _ASM_M32R_SOCKET_H */ #endif /* _ASM_M32R_SOCKET_H */
...@@ -58,5 +58,6 @@ ...@@ -58,5 +58,6 @@
#define SCM_TIMESTAMPING SO_TIMESTAMPING #define SCM_TIMESTAMPING SO_TIMESTAMPING
#define SO_PROTOCOL 38 #define SO_PROTOCOL 38
#define SO_DOMAIN 39
#endif /* _ASM_SOCKET_H */ #endif /* _ASM_SOCKET_H */
...@@ -67,5 +67,6 @@ ...@@ -67,5 +67,6 @@
#define SCM_TIMESTAMPING SO_TIMESTAMPING #define SCM_TIMESTAMPING SO_TIMESTAMPING
#define SO_PROTOCOL 38 #define SO_PROTOCOL 38
#define SO_DOMAIN 39
#endif /* _ASM_MICROBLAZE_SOCKET_H */ #endif /* _ASM_MICROBLAZE_SOCKET_H */
...@@ -43,6 +43,7 @@ To add: #define SO_REUSEPORT 0x0200 /* Allow local address and port reuse. */ ...@@ -43,6 +43,7 @@ To add: #define SO_REUSEPORT 0x0200 /* Allow local address and port reuse. */
#define SO_RCVTIMEO 0x1006 /* receive timeout */ #define SO_RCVTIMEO 0x1006 /* receive timeout */
#define SO_ACCEPTCONN 0x1009 #define SO_ACCEPTCONN 0x1009
#define SO_PROTOCOL 0x1028 /* protocol type */ #define SO_PROTOCOL 0x1028 /* protocol type */
#define SO_DOMAIN 0x1029 /* domain/socket family */
/* linux-specific, might as well be the same as on i386 */ /* linux-specific, might as well be the same as on i386 */
#define SO_NO_CHECK 11 #define SO_NO_CHECK 11
......
...@@ -58,5 +58,6 @@ ...@@ -58,5 +58,6 @@
#define SCM_TIMESTAMPING SO_TIMESTAMPING #define SCM_TIMESTAMPING SO_TIMESTAMPING
#define SO_PROTOCOL 38 #define SO_PROTOCOL 38
#define SO_DOMAIN 39
#endif /* _ASM_SOCKET_H */ #endif /* _ASM_SOCKET_H */
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#define SO_ERROR 0x1007 #define SO_ERROR 0x1007
#define SO_TYPE 0x1008 #define SO_TYPE 0x1008
#define SO_PROTOCOL 0x1028 #define SO_PROTOCOL 0x1028
#define SO_DOMAIN 0x1029
#define SO_PEERNAME 0x2000 #define SO_PEERNAME 0x2000
#define SO_NO_CHECK 0x400b #define SO_NO_CHECK 0x400b
......
...@@ -65,5 +65,6 @@ ...@@ -65,5 +65,6 @@
#define SCM_TIMESTAMPING SO_TIMESTAMPING #define SCM_TIMESTAMPING SO_TIMESTAMPING
#define SO_PROTOCOL 38 #define SO_PROTOCOL 38
#define SO_DOMAIN 39
#endif /* _ASM_POWERPC_SOCKET_H */ #endif /* _ASM_POWERPC_SOCKET_H */
...@@ -66,5 +66,6 @@ ...@@ -66,5 +66,6 @@
#define SCM_TIMESTAMPING SO_TIMESTAMPING #define SCM_TIMESTAMPING SO_TIMESTAMPING
#define SO_PROTOCOL 38 #define SO_PROTOCOL 38
#define SO_DOMAIN 39
#endif /* _ASM_SOCKET_H */ #endif /* _ASM_SOCKET_H */
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#define SO_ERROR 0x1007 #define SO_ERROR 0x1007
#define SO_TYPE 0x1008 #define SO_TYPE 0x1008
#define SO_PROTOCOL 0x1028 #define SO_PROTOCOL 0x1028
#define SO_DOMAIN 0x1029
/* Linux specific, keep the same. */ /* Linux specific, keep the same. */
......
...@@ -58,5 +58,6 @@ ...@@ -58,5 +58,6 @@
#define SCM_TIMESTAMPING SO_TIMESTAMPING #define SCM_TIMESTAMPING SO_TIMESTAMPING
#define SO_PROTOCOL 38 #define SO_PROTOCOL 38
#define SO_DOMAIN 39
#endif /* _ASM_X86_SOCKET_H */ #endif /* _ASM_X86_SOCKET_H */
...@@ -69,5 +69,6 @@ ...@@ -69,5 +69,6 @@
#define SCM_TIMESTAMPING SO_TIMESTAMPING #define SCM_TIMESTAMPING SO_TIMESTAMPING
#define SO_PROTOCOL 38 #define SO_PROTOCOL 38
#define SO_DOMAIN 39
#endif /* _XTENSA_SOCKET_H */ #endif /* _XTENSA_SOCKET_H */
...@@ -61,5 +61,6 @@ ...@@ -61,5 +61,6 @@
#define SCM_TIMESTAMPING SO_TIMESTAMPING #define SCM_TIMESTAMPING SO_TIMESTAMPING
#define SO_PROTOCOL 38 #define SO_PROTOCOL 38
#define SO_DOMAIN 39
#endif /* __ASM_GENERIC_SOCKET_H */ #endif /* __ASM_GENERIC_SOCKET_H */
...@@ -483,6 +483,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname, ...@@ -483,6 +483,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
break; break;
case SO_TYPE: case SO_TYPE:
case SO_PROTOCOL: case SO_PROTOCOL:
case SO_DOMAIN:
case SO_ERROR: case SO_ERROR:
ret = -ENOPROTOOPT; ret = -ENOPROTOOPT;
break; break;
...@@ -769,6 +770,10 @@ int sock_getsockopt(struct socket *sock, int level, int optname, ...@@ -769,6 +770,10 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
v.val = sk->sk_protocol; v.val = sk->sk_protocol;
break; break;
case SO_DOMAIN:
v.val = sk->sk_family;
break;
case SO_ERROR: case SO_ERROR:
v.val = -sock_error(sk); v.val = -sock_error(sk);
if (v.val == 0) if (v.val == 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment