flag parameters: arch-specific SOCK_NONBLOCK
Subsystems (2)
PATCH 1/1 flag parameters: arch-specific SOCK_NONBLOCK
The value of O_NONBLOCK clashes on Alpha dn PARISC with the bits used for socket types. Therefore we cannot define SOCK_NONBLOCK as O_NONBLOCK on these platforms. This patch adds support for an arch-specific SOCK_NONBLOCK value which doesn't add costs for other architectures.
include/asm-alpha/socket.h | 5 +++++ include/asm-parisc/socket.h | 5 +++++ include/linux/net.h | 2 ++ net/socket.c | 9 +++++++++ 4 files changed, 21 insertions(+)
Signed-off-by Ulrich Drepper <[email protected]>
include/asm-alpha/socket.h +5 -0
@@ -62,4 +62,9 @@#define SO_MARK 36 +/* O_NONBLOCK clashes with the bits used for socket types. Therefore we +* have to define SOCK_NONBLOCK to a different value here. +*/ +#define SOCK_NONBLOCK 0x40000000 +#endif /* _ASM_SOCKET_H */
include/asm-parisc/socket.h +5 -0
@@ -54,4 +54,9 @@#define SO_MARK 0x401f +/* O_NONBLOCK clashes with the bits used for socket types. Therefore we +* have to define SOCK_NONBLOCK to a different value here. +*/ +#define SOCK_NONBLOCK 0x40000000 +#endif /* _ASM_SOCKET_H */
include/linux/net.h +2 -0
@@ -102,7 +102,9 @@ enum sock_type {/* Flags for socket, socketpair, paccept */ #define SOCK_CLOEXEC O_CLOEXEC +#ifndef SOCK_NONBLOCK #define SOCK_NONBLOCK O_NONBLOCK +#endif #endif /* ARCH_HAS_SOCKET_TYPES */
net/socket.c +9 -0
@@ -1231,6 +1231,9 @@ asmlinkage long sys_socket(int family, int type, int protocol)return -EINVAL ; type &=SOCK_TYPE_MASK ; +if (SOCK_NONBLOCK !=O_NONBLOCK && (flags &SOCK_NONBLOCK )) + flags = (flags & ~SOCK_NONBLOCK ) |O_NONBLOCK ; + retval =sock_create (family, type, protocol, &sock);if (retval <0 ) goto out;
@@ -1265,6 +1268,9 @@ asmlinkage long sys_socketpair(int family, int type, int protocol,return -EINVAL ; type &=SOCK_TYPE_MASK ; +if (SOCK_NONBLOCK !=O_NONBLOCK && (flags &SOCK_NONBLOCK )) + flags = (flags & ~SOCK_NONBLOCK ) |O_NONBLOCK ; +/* * Obtain the first socket and check if the underlying protocol * supports the socketpair call.
@@ -1430,6 +1436,9 @@ long do_accept(int fd, struct sockaddr __user *upeer_sockaddr,if (flags & ~(SOCK_CLOEXEC |SOCK_NONBLOCK ))return -EINVAL ; +if (SOCK_NONBLOCK !=O_NONBLOCK && (flags &SOCK_NONBLOCK )) + flags = (flags & ~SOCK_NONBLOCK ) |O_NONBLOCK ; + sock =sockfd_lookup_light (fd, &err, &fput_needed);if (!sock) goto out;
Quoted 6 lines · Ulrich Drepper
The value of
O_NONBLOCKclashes on Alpha dn PARISC with the bits used for socket types. Therefore we cannot defineSOCK_NONBLOCKasO_NONBLOCKon these platforms. This patch adds support for an arch-specificSOCK_NONBLOCKvalue which doesn't add costs for other architectures.
Quoted 9 lines
include/asm-alpha/socket.h | 5 +++++ include/asm-parisc/socket.h | 5 +++++ include/linux/net.h | 2 ++ net/socket.c | 9 +++++++++ 4 files changed, 21 insertions(+)Signed-off-by Ulrich Drepper <[email protected]>
This looks fine to me. Thanks, Ulrich!
Acked-by Kyle McMartin <[email protected]>