mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 07:12:09 +00:00
[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>
This commit is contained in:
parent
f9e815b376
commit
b0573dea1f
22 changed files with 58 additions and 2 deletions
|
@ -260,7 +260,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
|
|||
|
||||
if (val > sysctl_wmem_max)
|
||||
val = sysctl_wmem_max;
|
||||
|
||||
set_sndbuf:
|
||||
sk->sk_userlocks |= SOCK_SNDBUF_LOCK;
|
||||
if ((val * 2) < SOCK_MIN_SNDBUF)
|
||||
sk->sk_sndbuf = SOCK_MIN_SNDBUF;
|
||||
|
@ -274,6 +274,13 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
|
|||
sk->sk_write_space(sk);
|
||||
break;
|
||||
|
||||
case SO_SNDBUFFORCE:
|
||||
if (!capable(CAP_NET_ADMIN)) {
|
||||
ret = -EPERM;
|
||||
break;
|
||||
}
|
||||
goto set_sndbuf;
|
||||
|
||||
case SO_RCVBUF:
|
||||
/* Don't error on this BSD doesn't and if you think
|
||||
about it this is right. Otherwise apps have to
|
||||
|
@ -282,7 +289,7 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
|
|||
|
||||
if (val > sysctl_rmem_max)
|
||||
val = sysctl_rmem_max;
|
||||
|
||||
set_rcvbuf:
|
||||
sk->sk_userlocks |= SOCK_RCVBUF_LOCK;
|
||||
/* FIXME: is this lower bound the right one? */
|
||||
if ((val * 2) < SOCK_MIN_RCVBUF)
|
||||
|
@ -291,6 +298,13 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
|
|||
sk->sk_rcvbuf = val * 2;
|
||||
break;
|
||||
|
||||
case SO_RCVBUFFORCE:
|
||||
if (!capable(CAP_NET_ADMIN)) {
|
||||
ret = -EPERM;
|
||||
break;
|
||||
}
|
||||
goto set_rcvbuf;
|
||||
|
||||
case SO_KEEPALIVE:
|
||||
#ifdef CONFIG_INET
|
||||
if (sk->sk_protocol == IPPROTO_TCP)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue