diff options
-rw-r--r-- | arch/alpha/include/uapi/asm/socket.h | 2 | ||||
-rw-r--r-- | arch/avr32/include/uapi/asm/socket.h | 2 | ||||
-rw-r--r-- | arch/cris/include/uapi/asm/socket.h | 2 | ||||
-rw-r--r-- | arch/frv/include/uapi/asm/socket.h | 2 | ||||
-rw-r--r-- | arch/h8300/include/uapi/asm/socket.h | 2 | ||||
-rw-r--r-- | arch/ia64/include/uapi/asm/socket.h | 2 | ||||
-rw-r--r-- | arch/m32r/include/uapi/asm/socket.h | 2 | ||||
-rw-r--r-- | arch/mips/include/uapi/asm/socket.h | 2 | ||||
-rw-r--r-- | arch/mn10300/include/uapi/asm/socket.h | 2 | ||||
-rw-r--r-- | arch/parisc/include/uapi/asm/socket.h | 2 | ||||
-rw-r--r-- | arch/powerpc/include/uapi/asm/socket.h | 2 | ||||
-rw-r--r-- | arch/s390/include/uapi/asm/socket.h | 2 | ||||
-rw-r--r-- | arch/sparc/include/uapi/asm/socket.h | 2 | ||||
-rw-r--r-- | arch/xtensa/include/uapi/asm/socket.h | 2 | ||||
-rw-r--r-- | include/net/ll_poll.h | 12 | ||||
-rw-r--r-- | include/net/sock.h | 2 | ||||
-rw-r--r-- | include/uapi/asm-generic/socket.h | 2 | ||||
-rw-r--r-- | net/core/sock.c | 20 | ||||
-rw-r--r-- | net/socket.c | 1 |
19 files changed, 58 insertions, 7 deletions
diff --git a/arch/alpha/include/uapi/asm/socket.h b/arch/alpha/include/uapi/asm/socket.h index eee6ea76bdaf..4885825e498d 100644 --- a/arch/alpha/include/uapi/asm/socket.h +++ b/arch/alpha/include/uapi/asm/socket.h | |||
@@ -81,4 +81,6 @@ | |||
81 | 81 | ||
82 | #define SO_SELECT_ERR_QUEUE 45 | 82 | #define SO_SELECT_ERR_QUEUE 45 |
83 | 83 | ||
84 | #define SO_LL 46 | ||
85 | |||
84 | #endif /* _UAPI_ASM_SOCKET_H */ | 86 | #endif /* _UAPI_ASM_SOCKET_H */ |
diff --git a/arch/avr32/include/uapi/asm/socket.h b/arch/avr32/include/uapi/asm/socket.h index 37401f535126..79b61798ebf8 100644 --- a/arch/avr32/include/uapi/asm/socket.h +++ b/arch/avr32/include/uapi/asm/socket.h | |||
@@ -74,4 +74,6 @@ | |||
74 | 74 | ||
75 | #define SO_SELECT_ERR_QUEUE 45 | 75 | #define SO_SELECT_ERR_QUEUE 45 |
76 | 76 | ||
77 | #define SO_LL 46 | ||
78 | |||
77 | #endif /* __ASM_AVR32_SOCKET_H */ | 79 | #endif /* __ASM_AVR32_SOCKET_H */ |
diff --git a/arch/cris/include/uapi/asm/socket.h b/arch/cris/include/uapi/asm/socket.h index ba409c9947bc..47b1ec55092d 100644 --- a/arch/cris/include/uapi/asm/socket.h +++ b/arch/cris/include/uapi/asm/socket.h | |||
@@ -76,6 +76,8 @@ | |||
76 | 76 | ||
77 | #define SO_SELECT_ERR_QUEUE 45 | 77 | #define SO_SELECT_ERR_QUEUE 45 |
78 | 78 | ||
79 | #define SO_LL 46 | ||
80 | |||
79 | #endif /* _ASM_SOCKET_H */ | 81 | #endif /* _ASM_SOCKET_H */ |
80 | 82 | ||
81 | 83 | ||
diff --git a/arch/frv/include/uapi/asm/socket.h b/arch/frv/include/uapi/asm/socket.h index 31dbb5d8e13d..dbc08520f22c 100644 --- a/arch/frv/include/uapi/asm/socket.h +++ b/arch/frv/include/uapi/asm/socket.h | |||
@@ -74,5 +74,7 @@ | |||
74 | 74 | ||
75 | #define SO_SELECT_ERR_QUEUE 45 | 75 | #define SO_SELECT_ERR_QUEUE 45 |
76 | 76 | ||
77 | #define SO_LL 46 | ||
78 | |||
77 | #endif /* _ASM_SOCKET_H */ | 79 | #endif /* _ASM_SOCKET_H */ |
78 | 80 | ||
diff --git a/arch/h8300/include/uapi/asm/socket.h b/arch/h8300/include/uapi/asm/socket.h index 5d1c6d0870e6..a38d38a6520b 100644 --- a/arch/h8300/include/uapi/asm/socket.h +++ b/arch/h8300/include/uapi/asm/socket.h | |||
@@ -74,4 +74,6 @@ | |||
74 | 74 | ||
75 | #define SO_SELECT_ERR_QUEUE 45 | 75 | #define SO_SELECT_ERR_QUEUE 45 |
76 | 76 | ||
77 | #define SO_LL 46 | ||
78 | |||
77 | #endif /* _ASM_SOCKET_H */ | 79 | #endif /* _ASM_SOCKET_H */ |
diff --git a/arch/ia64/include/uapi/asm/socket.h b/arch/ia64/include/uapi/asm/socket.h index 6b4329f18b29..d3358b760681 100644 --- a/arch/ia64/include/uapi/asm/socket.h +++ b/arch/ia64/include/uapi/asm/socket.h | |||
@@ -83,4 +83,6 @@ | |||
83 | 83 | ||
84 | #define SO_SELECT_ERR_QUEUE 45 | 84 | #define SO_SELECT_ERR_QUEUE 45 |
85 | 85 | ||
86 | #define SO_LL 46 | ||
87 | |||
86 | #endif /* _ASM_IA64_SOCKET_H */ | 88 | #endif /* _ASM_IA64_SOCKET_H */ |
diff --git a/arch/m32r/include/uapi/asm/socket.h b/arch/m32r/include/uapi/asm/socket.h index 2a3b59e0e171..44aaf4639a4a 100644 --- a/arch/m32r/include/uapi/asm/socket.h +++ b/arch/m32r/include/uapi/asm/socket.h | |||
@@ -74,4 +74,6 @@ | |||
74 | 74 | ||
75 | #define SO_SELECT_ERR_QUEUE 45 | 75 | #define SO_SELECT_ERR_QUEUE 45 |
76 | 76 | ||
77 | #define SO_LL 46 | ||
78 | |||
77 | #endif /* _ASM_M32R_SOCKET_H */ | 79 | #endif /* _ASM_M32R_SOCKET_H */ |
diff --git a/arch/mips/include/uapi/asm/socket.h b/arch/mips/include/uapi/asm/socket.h index 3b211507be7f..6a07992ba6c6 100644 --- a/arch/mips/include/uapi/asm/socket.h +++ b/arch/mips/include/uapi/asm/socket.h | |||
@@ -92,4 +92,6 @@ | |||
92 | 92 | ||
93 | #define SO_SELECT_ERR_QUEUE 45 | 93 | #define SO_SELECT_ERR_QUEUE 45 |
94 | 94 | ||
95 | #define SO_LL 46 | ||
96 | |||
95 | #endif /* _UAPI_ASM_SOCKET_H */ | 97 | #endif /* _UAPI_ASM_SOCKET_H */ |
diff --git a/arch/mn10300/include/uapi/asm/socket.h b/arch/mn10300/include/uapi/asm/socket.h index b4ce844c9391..db80fd3e398b 100644 --- a/arch/mn10300/include/uapi/asm/socket.h +++ b/arch/mn10300/include/uapi/asm/socket.h | |||
@@ -74,4 +74,6 @@ | |||
74 | 74 | ||
75 | #define SO_SELECT_ERR_QUEUE 45 | 75 | #define SO_SELECT_ERR_QUEUE 45 |
76 | 76 | ||
77 | #define SO_LL 46 | ||
78 | |||
77 | #endif /* _ASM_SOCKET_H */ | 79 | #endif /* _ASM_SOCKET_H */ |
diff --git a/arch/parisc/include/uapi/asm/socket.h b/arch/parisc/include/uapi/asm/socket.h index 70c512a386f7..f866fff9a004 100644 --- a/arch/parisc/include/uapi/asm/socket.h +++ b/arch/parisc/include/uapi/asm/socket.h | |||
@@ -73,6 +73,8 @@ | |||
73 | 73 | ||
74 | #define SO_SELECT_ERR_QUEUE 0x4026 | 74 | #define SO_SELECT_ERR_QUEUE 0x4026 |
75 | 75 | ||
76 | #define SO_LL 0x4027 | ||
77 | |||
76 | /* O_NONBLOCK clashes with the bits used for socket types. Therefore we | 78 | /* O_NONBLOCK clashes with the bits used for socket types. Therefore we |
77 | * have to define SOCK_NONBLOCK to a different value here. | 79 | * have to define SOCK_NONBLOCK to a different value here. |
78 | */ | 80 | */ |
diff --git a/arch/powerpc/include/uapi/asm/socket.h b/arch/powerpc/include/uapi/asm/socket.h index a36daf3c6f9a..405fb09bda94 100644 --- a/arch/powerpc/include/uapi/asm/socket.h +++ b/arch/powerpc/include/uapi/asm/socket.h | |||
@@ -81,4 +81,6 @@ | |||
81 | 81 | ||
82 | #define SO_SELECT_ERR_QUEUE 45 | 82 | #define SO_SELECT_ERR_QUEUE 45 |
83 | 83 | ||
84 | #define SO_LL 46 | ||
85 | |||
84 | #endif /* _ASM_POWERPC_SOCKET_H */ | 86 | #endif /* _ASM_POWERPC_SOCKET_H */ |
diff --git a/arch/s390/include/uapi/asm/socket.h b/arch/s390/include/uapi/asm/socket.h index 2dacb306835c..0c5105fbaaf3 100644 --- a/arch/s390/include/uapi/asm/socket.h +++ b/arch/s390/include/uapi/asm/socket.h | |||
@@ -80,4 +80,6 @@ | |||
80 | 80 | ||
81 | #define SO_SELECT_ERR_QUEUE 45 | 81 | #define SO_SELECT_ERR_QUEUE 45 |
82 | 82 | ||
83 | #define SO_LL 46 | ||
84 | |||
83 | #endif /* _ASM_SOCKET_H */ | 85 | #endif /* _ASM_SOCKET_H */ |
diff --git a/arch/sparc/include/uapi/asm/socket.h b/arch/sparc/include/uapi/asm/socket.h index 89f49b68a21c..b46c3fa0b265 100644 --- a/arch/sparc/include/uapi/asm/socket.h +++ b/arch/sparc/include/uapi/asm/socket.h | |||
@@ -70,6 +70,8 @@ | |||
70 | 70 | ||
71 | #define SO_SELECT_ERR_QUEUE 0x0029 | 71 | #define SO_SELECT_ERR_QUEUE 0x0029 |
72 | 72 | ||
73 | #define SO_LL 0x0030 | ||
74 | |||
73 | /* Security levels - as per NRL IPv6 - don't actually do anything */ | 75 | /* Security levels - as per NRL IPv6 - don't actually do anything */ |
74 | #define SO_SECURITY_AUTHENTICATION 0x5001 | 76 | #define SO_SECURITY_AUTHENTICATION 0x5001 |
75 | #define SO_SECURITY_ENCRYPTION_TRANSPORT 0x5002 | 77 | #define SO_SECURITY_ENCRYPTION_TRANSPORT 0x5002 |
diff --git a/arch/xtensa/include/uapi/asm/socket.h b/arch/xtensa/include/uapi/asm/socket.h index a8f44f50e651..b21ace4fc9ba 100644 --- a/arch/xtensa/include/uapi/asm/socket.h +++ b/arch/xtensa/include/uapi/asm/socket.h | |||
@@ -85,4 +85,6 @@ | |||
85 | 85 | ||
86 | #define SO_SELECT_ERR_QUEUE 45 | 86 | #define SO_SELECT_ERR_QUEUE 45 |
87 | 87 | ||
88 | #define SO_LL 46 | ||
89 | |||
88 | #endif /* _XTENSA_SOCKET_H */ | 90 | #endif /* _XTENSA_SOCKET_H */ |
diff --git a/include/net/ll_poll.h b/include/net/ll_poll.h index 6930cbd943e2..fcc7c365cee5 100644 --- a/include/net/ll_poll.h +++ b/include/net/ll_poll.h | |||
@@ -39,12 +39,12 @@ extern unsigned int sysctl_net_ll_poll __read_mostly; | |||
39 | /* we can use sched_clock() because we don't care much about precision | 39 | /* we can use sched_clock() because we don't care much about precision |
40 | * we only care that the average is bounded | 40 | * we only care that the average is bounded |
41 | */ | 41 | */ |
42 | static inline u64 ll_end_time(void) | 42 | static inline u64 ll_end_time(struct sock *sk) |
43 | { | 43 | { |
44 | u64 end_time = ACCESS_ONCE(sysctl_net_ll_poll); | 44 | u64 end_time = ACCESS_ONCE(sk->sk_ll_usec); |
45 | 45 | ||
46 | /* we don't mind a ~2.5% imprecision | 46 | /* we don't mind a ~2.5% imprecision |
47 | * sysctl_net_ll_poll is a u_int so this can't overflow | 47 | * sk->sk_ll_usec is a u_int so this can't overflow |
48 | */ | 48 | */ |
49 | end_time = (end_time << 10) + sched_clock(); | 49 | end_time = (end_time << 10) + sched_clock(); |
50 | 50 | ||
@@ -53,7 +53,7 @@ static inline u64 ll_end_time(void) | |||
53 | 53 | ||
54 | static inline bool sk_valid_ll(struct sock *sk) | 54 | static inline bool sk_valid_ll(struct sock *sk) |
55 | { | 55 | { |
56 | return sysctl_net_ll_poll && sk->sk_napi_id && | 56 | return sk->sk_ll_usec && sk->sk_napi_id && |
57 | !need_resched() && !signal_pending(current); | 57 | !need_resched() && !signal_pending(current); |
58 | } | 58 | } |
59 | 59 | ||
@@ -65,7 +65,7 @@ static inline bool can_poll_ll(u64 end_time) | |||
65 | static inline bool sk_poll_ll(struct sock *sk, int nonblock) | 65 | static inline bool sk_poll_ll(struct sock *sk, int nonblock) |
66 | { | 66 | { |
67 | const struct net_device_ops *ops; | 67 | const struct net_device_ops *ops; |
68 | u64 end_time = ll_end_time(); | 68 | u64 end_time = ll_end_time(sk); |
69 | struct napi_struct *napi; | 69 | struct napi_struct *napi; |
70 | int rc = false; | 70 | int rc = false; |
71 | 71 | ||
@@ -118,7 +118,7 @@ static inline void sk_mark_ll(struct sock *sk, struct sk_buff *skb) | |||
118 | 118 | ||
119 | #else /* CONFIG_NET_LL_RX_POLL */ | 119 | #else /* CONFIG_NET_LL_RX_POLL */ |
120 | 120 | ||
121 | static inline u64 ll_end_time(void) | 121 | static inline u64 ll_end_time(struct sock *sk) |
122 | { | 122 | { |
123 | return 0; | 123 | return 0; |
124 | } | 124 | } |
diff --git a/include/net/sock.h b/include/net/sock.h index ac8e1818380c..21db792bffa5 100644 --- a/include/net/sock.h +++ b/include/net/sock.h | |||
@@ -230,6 +230,7 @@ struct cg_proto; | |||
230 | * @sk_wmem_queued: persistent queue size | 230 | * @sk_wmem_queued: persistent queue size |
231 | * @sk_forward_alloc: space allocated forward | 231 | * @sk_forward_alloc: space allocated forward |
232 | * @sk_napi_id: id of the last napi context to receive data for sk | 232 | * @sk_napi_id: id of the last napi context to receive data for sk |
233 | * @sk_ll_usec: usecs to busypoll when there is no data | ||
233 | * @sk_allocation: allocation mode | 234 | * @sk_allocation: allocation mode |
234 | * @sk_sndbuf: size of send buffer in bytes | 235 | * @sk_sndbuf: size of send buffer in bytes |
235 | * @sk_flags: %SO_LINGER (l_onoff), %SO_BROADCAST, %SO_KEEPALIVE, | 236 | * @sk_flags: %SO_LINGER (l_onoff), %SO_BROADCAST, %SO_KEEPALIVE, |
@@ -328,6 +329,7 @@ struct sock { | |||
328 | #endif | 329 | #endif |
329 | #ifdef CONFIG_NET_LL_RX_POLL | 330 | #ifdef CONFIG_NET_LL_RX_POLL |
330 | unsigned int sk_napi_id; | 331 | unsigned int sk_napi_id; |
332 | unsigned int sk_ll_usec; | ||
331 | #endif | 333 | #endif |
332 | atomic_t sk_drops; | 334 | atomic_t sk_drops; |
333 | int sk_rcvbuf; | 335 | int sk_rcvbuf; |
diff --git a/include/uapi/asm-generic/socket.h b/include/uapi/asm-generic/socket.h index c5d2e3a1cf68..ca3a20d772ac 100644 --- a/include/uapi/asm-generic/socket.h +++ b/include/uapi/asm-generic/socket.h | |||
@@ -76,4 +76,6 @@ | |||
76 | 76 | ||
77 | #define SO_SELECT_ERR_QUEUE 45 | 77 | #define SO_SELECT_ERR_QUEUE 45 |
78 | 78 | ||
79 | #define SO_LL 46 | ||
80 | |||
79 | #endif /* __ASM_GENERIC_SOCKET_H */ | 81 | #endif /* __ASM_GENERIC_SOCKET_H */ |
diff --git a/net/core/sock.c b/net/core/sock.c index 788c0da5eed1..1e744b12fda3 100644 --- a/net/core/sock.c +++ b/net/core/sock.c | |||
@@ -913,6 +913,19 @@ set_rcvbuf: | |||
913 | sock_valbool_flag(sk, SOCK_SELECT_ERR_QUEUE, valbool); | 913 | sock_valbool_flag(sk, SOCK_SELECT_ERR_QUEUE, valbool); |
914 | break; | 914 | break; |
915 | 915 | ||
916 | #ifdef CONFIG_NET_LL_RX_POLL | ||
917 | case SO_LL: | ||
918 | /* allow unprivileged users to decrease the value */ | ||
919 | if ((val > sk->sk_ll_usec) && !capable(CAP_NET_ADMIN)) | ||
920 | ret = -EPERM; | ||
921 | else { | ||
922 | if (val < 0) | ||
923 | ret = -EINVAL; | ||
924 | else | ||
925 | sk->sk_ll_usec = val; | ||
926 | } | ||
927 | break; | ||
928 | #endif | ||
916 | default: | 929 | default: |
917 | ret = -ENOPROTOOPT; | 930 | ret = -ENOPROTOOPT; |
918 | break; | 931 | break; |
@@ -1170,6 +1183,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname, | |||
1170 | v.val = sock_flag(sk, SOCK_SELECT_ERR_QUEUE); | 1183 | v.val = sock_flag(sk, SOCK_SELECT_ERR_QUEUE); |
1171 | break; | 1184 | break; |
1172 | 1185 | ||
1186 | #ifdef CONFIG_NET_LL_RX_POLL | ||
1187 | case SO_LL: | ||
1188 | v.val = sk->sk_ll_usec; | ||
1189 | break; | ||
1190 | #endif | ||
1191 | |||
1173 | default: | 1192 | default: |
1174 | return -ENOPROTOOPT; | 1193 | return -ENOPROTOOPT; |
1175 | } | 1194 | } |
@@ -2288,6 +2307,7 @@ void sock_init_data(struct socket *sock, struct sock *sk) | |||
2288 | 2307 | ||
2289 | #ifdef CONFIG_NET_LL_RX_POLL | 2308 | #ifdef CONFIG_NET_LL_RX_POLL |
2290 | sk->sk_napi_id = 0; | 2309 | sk->sk_napi_id = 0; |
2310 | sk->sk_ll_usec = sysctl_net_ll_poll; | ||
2291 | #endif | 2311 | #endif |
2292 | 2312 | ||
2293 | /* | 2313 | /* |
diff --git a/net/socket.c b/net/socket.c index caaffa14e87e..3eec3f76b49c 100644 --- a/net/socket.c +++ b/net/socket.c | |||
@@ -108,7 +108,6 @@ | |||
108 | 108 | ||
109 | #ifdef CONFIG_NET_LL_RX_POLL | 109 | #ifdef CONFIG_NET_LL_RX_POLL |
110 | unsigned int sysctl_net_ll_poll __read_mostly; | 110 | unsigned int sysctl_net_ll_poll __read_mostly; |
111 | EXPORT_SYMBOL_GPL(sysctl_net_ll_poll); | ||
112 | #endif | 111 | #endif |
113 | 112 | ||
114 | static int sock_no_open(struct inode *irrelevant, struct file *dontcare); | 113 | static int sock_no_open(struct inode *irrelevant, struct file *dontcare); |