diff options
author | Patrick McHardy <kaber@trash.net> | 2005-08-09 22:30:51 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2005-08-29 18:31:35 -0400 |
commit | b0573dea1fb32ebc72ffa05980fd840df1d80860 (patch) | |
tree | ae10ad849dce6dbeec1b281fbd51214030f21902 /net/core/sock.c | |
parent | f9e815b376dc19e6afc551cd755ac64e9e42d81f (diff) |
[NET]: Introduce SO_{SND,RCV}BUFFORCE socket options
Allows overriding of sysctl_{wmem,rmrm}_max
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/sock.c')
-rw-r--r-- | net/core/sock.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/net/core/sock.c b/net/core/sock.c index 12f6d9a2a522..51a5e7ddee85 100644 --- a/net/core/sock.c +++ b/net/core/sock.c | |||
@@ -260,7 +260,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname, | |||
260 | 260 | ||
261 | if (val > sysctl_wmem_max) | 261 | if (val > sysctl_wmem_max) |
262 | val = sysctl_wmem_max; | 262 | val = sysctl_wmem_max; |
263 | 263 | set_sndbuf: | |
264 | sk->sk_userlocks |= SOCK_SNDBUF_LOCK; | 264 | sk->sk_userlocks |= SOCK_SNDBUF_LOCK; |
265 | if ((val * 2) < SOCK_MIN_SNDBUF) | 265 | if ((val * 2) < SOCK_MIN_SNDBUF) |
266 | sk->sk_sndbuf = SOCK_MIN_SNDBUF; | 266 | sk->sk_sndbuf = SOCK_MIN_SNDBUF; |
@@ -274,6 +274,13 @@ int sock_setsockopt(struct socket *sock, int level, int optname, | |||
274 | sk->sk_write_space(sk); | 274 | sk->sk_write_space(sk); |
275 | break; | 275 | break; |
276 | 276 | ||
277 | case SO_SNDBUFFORCE: | ||
278 | if (!capable(CAP_NET_ADMIN)) { | ||
279 | ret = -EPERM; | ||
280 | break; | ||
281 | } | ||
282 | goto set_sndbuf; | ||
283 | |||
277 | case SO_RCVBUF: | 284 | case SO_RCVBUF: |
278 | /* Don't error on this BSD doesn't and if you think | 285 | /* Don't error on this BSD doesn't and if you think |
279 | about it this is right. Otherwise apps have to | 286 | about it this is right. Otherwise apps have to |
@@ -282,7 +289,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname, | |||
282 | 289 | ||
283 | if (val > sysctl_rmem_max) | 290 | if (val > sysctl_rmem_max) |
284 | val = sysctl_rmem_max; | 291 | val = sysctl_rmem_max; |
285 | 292 | set_rcvbuf: | |
286 | sk->sk_userlocks |= SOCK_RCVBUF_LOCK; | 293 | sk->sk_userlocks |= SOCK_RCVBUF_LOCK; |
287 | /* FIXME: is this lower bound the right one? */ | 294 | /* FIXME: is this lower bound the right one? */ |
288 | if ((val * 2) < SOCK_MIN_RCVBUF) | 295 | if ((val * 2) < SOCK_MIN_RCVBUF) |
@@ -291,6 +298,13 @@ int sock_setsockopt(struct socket *sock, int level, int optname, | |||
291 | sk->sk_rcvbuf = val * 2; | 298 | sk->sk_rcvbuf = val * 2; |
292 | break; | 299 | break; |
293 | 300 | ||
301 | case SO_RCVBUFFORCE: | ||
302 | if (!capable(CAP_NET_ADMIN)) { | ||
303 | ret = -EPERM; | ||
304 | break; | ||
305 | } | ||
306 | goto set_rcvbuf; | ||
307 | |||
294 | case SO_KEEPALIVE: | 308 | case SO_KEEPALIVE: |
295 | #ifdef CONFIG_INET | 309 | #ifdef CONFIG_INET |
296 | if (sk->sk_protocol == IPPROTO_TCP) | 310 | if (sk->sk_protocol == IPPROTO_TCP) |