ipv4: add ip_sock_set_mtu_discover

Add a helper to directly set the IP_MTU_DISCOVER sockopt from kernel
space without going through a fake uaccess.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: David Howells <dhowells@redhat.com> [rxrpc bits]
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Christoph Hellwig
2020-05-28 07:12:29 +02:00
committed by David S. Miller
parent db45c0ef25
commit 2de569bda2
4 changed files with 18 additions and 16 deletions

View File

@@ -597,6 +597,17 @@ void ip_sock_set_recverr(struct sock *sk)
}
EXPORT_SYMBOL(ip_sock_set_recverr);
int ip_sock_set_mtu_discover(struct sock *sk, int val)
{
if (val < IP_PMTUDISC_DONT || val > IP_PMTUDISC_OMIT)
return -EINVAL;
lock_sock(sk);
inet_sk(sk)->pmtudisc = val;
release_sock(sk);
return 0;
}
EXPORT_SYMBOL(ip_sock_set_mtu_discover);
/*
* Socket option code for IP. This is the end of the line after any
* TCP,UDP etc options on an IP socket.