Commit b0573dea1fb32ebc72ffa05980fd840df1d80860
Committed by
David S. Miller
1 parent
f9e815b376
Exists in
master
and in
4 other branches
[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>
Showing 22 changed files with 58 additions and 2 deletions Side-by-side Diff
- include/asm-alpha/socket.h
- include/asm-arm/socket.h
- include/asm-arm26/socket.h
- include/asm-cris/socket.h
- include/asm-frv/socket.h
- include/asm-h8300/socket.h
- include/asm-i386/socket.h
- include/asm-ia64/socket.h
- include/asm-m32r/socket.h
- include/asm-m68k/socket.h
- include/asm-mips/socket.h
- include/asm-parisc/socket.h
- include/asm-ppc/socket.h
- include/asm-ppc64/socket.h
- include/asm-s390/socket.h
- include/asm-sh/socket.h
- include/asm-sparc/socket.h
- include/asm-sparc64/socket.h
- include/asm-v850/socket.h
- include/asm-x86_64/socket.h
- include/asm-xtensa/socket.h
- net/core/sock.c
include/asm-alpha/socket.h
include/asm-arm/socket.h
include/asm-arm26/socket.h
include/asm-cris/socket.h
include/asm-frv/socket.h
include/asm-h8300/socket.h
include/asm-i386/socket.h
include/asm-ia64/socket.h
include/asm-m32r/socket.h
include/asm-m68k/socket.h
include/asm-mips/socket.h
| ... | ... | @@ -37,6 +37,8 @@ |
| 37 | 37 | #define SO_ERROR 0x1007 /* get error status and clear */ |
| 38 | 38 | #define SO_SNDBUF 0x1001 /* Send buffer size. */ |
| 39 | 39 | #define SO_RCVBUF 0x1002 /* Receive buffer. */ |
| 40 | +#define SO_SNDBUFFORCE 0x100a | |
| 41 | +#define SO_RCVBUFFORCE 0x100b | |
| 40 | 42 | #define SO_SNDLOWAT 0x1003 /* send low-water mark */ |
| 41 | 43 | #define SO_RCVLOWAT 0x1004 /* receive low-water mark */ |
| 42 | 44 | #define SO_SNDTIMEO 0x1005 /* send timeout */ |
include/asm-parisc/socket.h
| ... | ... | @@ -16,6 +16,8 @@ |
| 16 | 16 | /* To add :#define SO_REUSEPORT 0x0200 */ |
| 17 | 17 | #define SO_SNDBUF 0x1001 |
| 18 | 18 | #define SO_RCVBUF 0x1002 |
| 19 | +#define SO_SNDBUFFORCE 0x100a | |
| 20 | +#define SO_RCVBUFFORCE 0x100b | |
| 19 | 21 | #define SO_SNDLOWAT 0x1003 |
| 20 | 22 | #define SO_RCVLOWAT 0x1004 |
| 21 | 23 | #define SO_SNDTIMEO 0x1005 |
include/asm-ppc/socket.h
include/asm-ppc64/socket.h
include/asm-s390/socket.h
include/asm-sh/socket.h
include/asm-sparc/socket.h
include/asm-sparc64/socket.h
include/asm-v850/socket.h
include/asm-x86_64/socket.h
include/asm-xtensa/socket.h
net/core/sock.c
| ... | ... | @@ -260,7 +260,7 @@ |
| 260 | 260 | |
| 261 | 261 | if (val > sysctl_wmem_max) |
| 262 | 262 | val = sysctl_wmem_max; |
| 263 | - | |
| 263 | +set_sndbuf: | |
| 264 | 264 | sk->sk_userlocks |= SOCK_SNDBUF_LOCK; |
| 265 | 265 | if ((val * 2) < SOCK_MIN_SNDBUF) |
| 266 | 266 | sk->sk_sndbuf = SOCK_MIN_SNDBUF; |
| ... | ... | @@ -274,6 +274,13 @@ |
| 274 | 274 | sk->sk_write_space(sk); |
| 275 | 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 | 284 | case SO_RCVBUF: |
| 278 | 285 | /* Don't error on this BSD doesn't and if you think |
| 279 | 286 | about it this is right. Otherwise apps have to |
| ... | ... | @@ -282,7 +289,7 @@ |
| 282 | 289 | |
| 283 | 290 | if (val > sysctl_rmem_max) |
| 284 | 291 | val = sysctl_rmem_max; |
| 285 | - | |
| 292 | +set_rcvbuf: | |
| 286 | 293 | sk->sk_userlocks |= SOCK_RCVBUF_LOCK; |
| 287 | 294 | /* FIXME: is this lower bound the right one? */ |
| 288 | 295 | if ((val * 2) < SOCK_MIN_RCVBUF) |
| ... | ... | @@ -290,6 +297,13 @@ |
| 290 | 297 | else |
| 291 | 298 | sk->sk_rcvbuf = val * 2; |
| 292 | 299 | break; |
| 300 | + | |
| 301 | + case SO_RCVBUFFORCE: | |
| 302 | + if (!capable(CAP_NET_ADMIN)) { | |
| 303 | + ret = -EPERM; | |
| 304 | + break; | |
| 305 | + } | |
| 306 | + goto set_rcvbuf; | |
| 293 | 307 | |
| 294 | 308 | case SO_KEEPALIVE: |
| 295 | 309 | #ifdef CONFIG_INET |