Commit 055dc21a authored by Tom Herbert's avatar Tom Herbert Committed by David S. Miller

soreuseport: infrastructure

Definitions and macros for implementing soreusport.
Signed-off-by: default avatarTom Herbert <therbert@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4a633a60
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#define SO_BROADCAST 0x0020 #define SO_BROADCAST 0x0020
#define SO_LINGER 0x0080 #define SO_LINGER 0x0080
#define SO_OOBINLINE 0x0100 #define SO_OOBINLINE 0x0100
/* To add :#define SO_REUSEPORT 0x0200 */ #define SO_REUSEPORT 0x0200
#define SO_TYPE 0x1008 #define SO_TYPE 0x1008
#define SO_ERROR 0x1007 #define SO_ERROR 0x1007
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#define SO_PRIORITY 12 #define SO_PRIORITY 12
#define SO_LINGER 13 #define SO_LINGER 13
#define SO_BSDCOMPAT 14 #define SO_BSDCOMPAT 14
/* To add :#define SO_REUSEPORT 15 */ #define SO_REUSEPORT 15
#define SO_PASSCRED 16 #define SO_PASSCRED 16
#define SO_PEERCRED 17 #define SO_PEERCRED 17
#define SO_RCVLOWAT 18 #define SO_RCVLOWAT 18
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#define SO_PRIORITY 12 #define SO_PRIORITY 12
#define SO_LINGER 13 #define SO_LINGER 13
#define SO_BSDCOMPAT 14 #define SO_BSDCOMPAT 14
/* To add :#define SO_REUSEPORT 15 */ #define SO_REUSEPORT 15
#define SO_PASSCRED 16 #define SO_PASSCRED 16
#define SO_PEERCRED 17 #define SO_PEERCRED 17
#define SO_RCVLOWAT 18 #define SO_RCVLOWAT 18
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#define SO_PRIORITY 12 #define SO_PRIORITY 12
#define SO_LINGER 13 #define SO_LINGER 13
#define SO_BSDCOMPAT 14 #define SO_BSDCOMPAT 14
/* To add :#define SO_REUSEPORT 15 */ #define SO_REUSEPORT 15
#define SO_PASSCRED 16 #define SO_PASSCRED 16
#define SO_PEERCRED 17 #define SO_PEERCRED 17
#define SO_RCVLOWAT 18 #define SO_RCVLOWAT 18
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#define SO_PRIORITY 12 #define SO_PRIORITY 12
#define SO_LINGER 13 #define SO_LINGER 13
#define SO_BSDCOMPAT 14 #define SO_BSDCOMPAT 14
/* To add :#define SO_REUSEPORT 15 */ #define SO_REUSEPORT 15
#define SO_PASSCRED 16 #define SO_PASSCRED 16
#define SO_PEERCRED 17 #define SO_PEERCRED 17
#define SO_RCVLOWAT 18 #define SO_RCVLOWAT 18
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#define SO_PRIORITY 12 #define SO_PRIORITY 12
#define SO_LINGER 13 #define SO_LINGER 13
#define SO_BSDCOMPAT 14 #define SO_BSDCOMPAT 14
/* To add :#define SO_REUSEPORT 15 */ #define SO_REUSEPORT 15
#define SO_PASSCRED 16 #define SO_PASSCRED 16
#define SO_PEERCRED 17 #define SO_PEERCRED 17
#define SO_RCVLOWAT 18 #define SO_RCVLOWAT 18
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#define SO_PRIORITY 12 #define SO_PRIORITY 12
#define SO_LINGER 13 #define SO_LINGER 13
#define SO_BSDCOMPAT 14 #define SO_BSDCOMPAT 14
/* To add :#define SO_REUSEPORT 15 */ #define SO_REUSEPORT 15
#define SO_PASSCRED 16 #define SO_PASSCRED 16
#define SO_PEERCRED 17 #define SO_PEERCRED 17
#define SO_RCVLOWAT 18 #define SO_RCVLOWAT 18
......
...@@ -28,8 +28,7 @@ ...@@ -28,8 +28,7 @@
#define SO_LINGER 0x0080 /* Block on close of a reliable #define SO_LINGER 0x0080 /* Block on close of a reliable
socket to transmit pending data. */ socket to transmit pending data. */
#define SO_OOBINLINE 0x0100 /* Receive out-of-band data in-band. */ #define SO_OOBINLINE 0x0100 /* Receive out-of-band data in-band. */
#if 0 #define SO_REUSEPORT 0x0200 /* Allow local address and port reuse. */
To add: #define SO_REUSEPORT 0x0200 /* Allow local address and port reuse. */
#endif #endif
#define SO_TYPE 0x1008 /* Compatible name for SO_STYLE. */ #define SO_TYPE 0x1008 /* Compatible name for SO_STYLE. */
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#define SO_PRIORITY 12 #define SO_PRIORITY 12
#define SO_LINGER 13 #define SO_LINGER 13
#define SO_BSDCOMPAT 14 #define SO_BSDCOMPAT 14
/* To add :#define SO_REUSEPORT 15 */ #define SO_REUSEPORT 15
#define SO_PASSCRED 16 #define SO_PASSCRED 16
#define SO_PEERCRED 17 #define SO_PEERCRED 17
#define SO_RCVLOWAT 18 #define SO_RCVLOWAT 18
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#define SO_BROADCAST 0x0020 #define SO_BROADCAST 0x0020
#define SO_LINGER 0x0080 #define SO_LINGER 0x0080
#define SO_OOBINLINE 0x0100 #define SO_OOBINLINE 0x0100
/* To add :#define SO_REUSEPORT 0x0200 */ #define SO_REUSEPORT 0x0200
#define SO_SNDBUF 0x1001 #define SO_SNDBUF 0x1001
#define SO_RCVBUF 0x1002 #define SO_RCVBUF 0x1002
#define SO_SNDBUFFORCE 0x100a #define SO_SNDBUFFORCE 0x100a
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#define SO_PRIORITY 12 #define SO_PRIORITY 12
#define SO_LINGER 13 #define SO_LINGER 13
#define SO_BSDCOMPAT 14 #define SO_BSDCOMPAT 14
/* To add :#define SO_REUSEPORT 15 */ #define SO_REUSEPORT 15
#define SO_RCVLOWAT 16 #define SO_RCVLOWAT 16
#define SO_SNDLOWAT 17 #define SO_SNDLOWAT 17
#define SO_RCVTIMEO 18 #define SO_RCVTIMEO 18
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#define SO_PRIORITY 12 #define SO_PRIORITY 12
#define SO_LINGER 13 #define SO_LINGER 13
#define SO_BSDCOMPAT 14 #define SO_BSDCOMPAT 14
/* To add :#define SO_REUSEPORT 15 */ #define SO_REUSEPORT 15
#define SO_PASSCRED 16 #define SO_PASSCRED 16
#define SO_PEERCRED 17 #define SO_PEERCRED 17
#define SO_RCVLOWAT 18 #define SO_RCVLOWAT 18
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#define SO_PEERCRED 0x0040 #define SO_PEERCRED 0x0040
#define SO_LINGER 0x0080 #define SO_LINGER 0x0080
#define SO_OOBINLINE 0x0100 #define SO_OOBINLINE 0x0100
/* To add :#define SO_REUSEPORT 0x0200 */ #define SO_REUSEPORT 0x0200
#define SO_BSDCOMPAT 0x0400 #define SO_BSDCOMPAT 0x0400
#define SO_RCVLOWAT 0x0800 #define SO_RCVLOWAT 0x0800
#define SO_SNDLOWAT 0x1000 #define SO_SNDLOWAT 0x1000
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#define SO_PRIORITY 12 #define SO_PRIORITY 12
#define SO_LINGER 13 #define SO_LINGER 13
#define SO_BSDCOMPAT 14 #define SO_BSDCOMPAT 14
/* To add :#define SO_REUSEPORT 15 */ #define SO_REUSEPORT 15
#define SO_PASSCRED 16 #define SO_PASSCRED 16
#define SO_PEERCRED 17 #define SO_PEERCRED 17
#define SO_RCVLOWAT 18 #define SO_RCVLOWAT 18
......
...@@ -74,4 +74,10 @@ static inline int arch_get_random_int(unsigned int *v) ...@@ -74,4 +74,10 @@ static inline int arch_get_random_int(unsigned int *v)
} }
#endif #endif
/* Pseudo random number generator from numerical recipes. */
static inline u32 next_pseudo_random32(u32 seed)
{
return seed * 1664525 + 1013904223;
}
#endif /* _LINUX_RANDOM_H */ #endif /* _LINUX_RANDOM_H */
...@@ -140,6 +140,7 @@ typedef __u64 __bitwise __addrpair; ...@@ -140,6 +140,7 @@ typedef __u64 __bitwise __addrpair;
* @skc_family: network address family * @skc_family: network address family
* @skc_state: Connection state * @skc_state: Connection state
* @skc_reuse: %SO_REUSEADDR setting * @skc_reuse: %SO_REUSEADDR setting
* @skc_reuseport: %SO_REUSEPORT setting
* @skc_bound_dev_if: bound device index if != 0 * @skc_bound_dev_if: bound device index if != 0
* @skc_bind_node: bind hash linkage for various protocol lookup tables * @skc_bind_node: bind hash linkage for various protocol lookup tables
* @skc_portaddr_node: second hash linkage for UDP/UDP-Lite protocol * @skc_portaddr_node: second hash linkage for UDP/UDP-Lite protocol
...@@ -179,7 +180,8 @@ struct sock_common { ...@@ -179,7 +180,8 @@ struct sock_common {
unsigned short skc_family; unsigned short skc_family;
volatile unsigned char skc_state; volatile unsigned char skc_state;
unsigned char skc_reuse; unsigned char skc_reuse:4;
unsigned char skc_reuseport:4;
int skc_bound_dev_if; int skc_bound_dev_if;
union { union {
struct hlist_node skc_bind_node; struct hlist_node skc_bind_node;
...@@ -297,6 +299,7 @@ struct sock { ...@@ -297,6 +299,7 @@ struct sock {
#define sk_family __sk_common.skc_family #define sk_family __sk_common.skc_family
#define sk_state __sk_common.skc_state #define sk_state __sk_common.skc_state
#define sk_reuse __sk_common.skc_reuse #define sk_reuse __sk_common.skc_reuse
#define sk_reuseport __sk_common.skc_reuseport
#define sk_bound_dev_if __sk_common.skc_bound_dev_if #define sk_bound_dev_if __sk_common.skc_bound_dev_if
#define sk_bind_node __sk_common.skc_bind_node #define sk_bind_node __sk_common.skc_bind_node
#define sk_prot __sk_common.skc_prot #define sk_prot __sk_common.skc_prot
......
...@@ -22,8 +22,7 @@ ...@@ -22,8 +22,7 @@
#define SO_PRIORITY 12 #define SO_PRIORITY 12
#define SO_LINGER 13 #define SO_LINGER 13
#define SO_BSDCOMPAT 14 #define SO_BSDCOMPAT 14
/* To add :#define SO_REUSEPORT 15 */ #define SO_REUSEPORT 15
#ifndef SO_PASSCRED /* powerpc only differs in these */ #ifndef SO_PASSCRED /* powerpc only differs in these */
#define SO_PASSCRED 16 #define SO_PASSCRED 16
#define SO_PEERCRED 17 #define SO_PEERCRED 17
......
...@@ -665,6 +665,9 @@ int sock_setsockopt(struct socket *sock, int level, int optname, ...@@ -665,6 +665,9 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
case SO_REUSEADDR: case SO_REUSEADDR:
sk->sk_reuse = (valbool ? SK_CAN_REUSE : SK_NO_REUSE); sk->sk_reuse = (valbool ? SK_CAN_REUSE : SK_NO_REUSE);
break; break;
case SO_REUSEPORT:
sk->sk_reuseport = valbool;
break;
case SO_TYPE: case SO_TYPE:
case SO_PROTOCOL: case SO_PROTOCOL:
case SO_DOMAIN: case SO_DOMAIN:
...@@ -972,6 +975,10 @@ int sock_getsockopt(struct socket *sock, int level, int optname, ...@@ -972,6 +975,10 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
v.val = sk->sk_reuse; v.val = sk->sk_reuse;
break; break;
case SO_REUSEPORT:
v.val = sk->sk_reuseport;
break;
case SO_KEEPALIVE: case SO_KEEPALIVE:
v.val = sock_flag(sk, SOCK_KEEPOPEN); v.val = sock_flag(sk, SOCK_KEEPOPEN);
break; break;
......
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