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:
parent
db45c0ef25
commit
2de569bda2
|
@ -766,6 +766,7 @@ static inline bool inetdev_valid_mtu(unsigned int mtu)
|
||||||
}
|
}
|
||||||
|
|
||||||
void ip_sock_set_freebind(struct sock *sk);
|
void ip_sock_set_freebind(struct sock *sk);
|
||||||
|
int ip_sock_set_mtu_discover(struct sock *sk, int val);
|
||||||
void ip_sock_set_recverr(struct sock *sk);
|
void ip_sock_set_recverr(struct sock *sk);
|
||||||
void ip_sock_set_tos(struct sock *sk, int val);
|
void ip_sock_set_tos(struct sock *sk, int val);
|
||||||
|
|
||||||
|
|
|
@ -597,6 +597,17 @@ void ip_sock_set_recverr(struct sock *sk)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(ip_sock_set_recverr);
|
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
|
* Socket option code for IP. This is the end of the line after any
|
||||||
* TCP,UDP etc options on an IP socket.
|
* TCP,UDP etc options on an IP socket.
|
||||||
|
|
|
@ -174,13 +174,7 @@ static int rxrpc_open_socket(struct rxrpc_local *local, struct net *net)
|
||||||
ip_sock_set_recverr(local->socket->sk);
|
ip_sock_set_recverr(local->socket->sk);
|
||||||
|
|
||||||
/* we want to set the don't fragment bit */
|
/* we want to set the don't fragment bit */
|
||||||
opt = IP_PMTUDISC_DO;
|
ip_sock_set_mtu_discover(local->socket->sk, IP_PMTUDISC_DO);
|
||||||
ret = kernel_setsockopt(local->socket, SOL_IP, IP_MTU_DISCOVER,
|
|
||||||
(char *) &opt, sizeof(opt));
|
|
||||||
if (ret < 0) {
|
|
||||||
_debug("setsockopt failed");
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* We want receive timestamps. */
|
/* We want receive timestamps. */
|
||||||
sock_enable_timestamps(local->socket->sk);
|
sock_enable_timestamps(local->socket->sk);
|
||||||
|
|
|
@ -321,7 +321,7 @@ int rxrpc_send_data_packet(struct rxrpc_call *call, struct sk_buff *skb,
|
||||||
struct kvec iov[2];
|
struct kvec iov[2];
|
||||||
rxrpc_serial_t serial;
|
rxrpc_serial_t serial;
|
||||||
size_t len;
|
size_t len;
|
||||||
int ret, opt;
|
int ret;
|
||||||
|
|
||||||
_enter(",{%d}", skb->len);
|
_enter(",{%d}", skb->len);
|
||||||
|
|
||||||
|
@ -473,18 +473,14 @@ send_fragmentable:
|
||||||
switch (conn->params.local->srx.transport.family) {
|
switch (conn->params.local->srx.transport.family) {
|
||||||
case AF_INET6:
|
case AF_INET6:
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
opt = IP_PMTUDISC_DONT;
|
ip_sock_set_mtu_discover(conn->params.local->socket->sk,
|
||||||
kernel_setsockopt(conn->params.local->socket,
|
IP_PMTUDISC_DONT);
|
||||||
SOL_IP, IP_MTU_DISCOVER,
|
|
||||||
(char *)&opt, sizeof(opt));
|
|
||||||
ret = kernel_sendmsg(conn->params.local->socket, &msg,
|
ret = kernel_sendmsg(conn->params.local->socket, &msg,
|
||||||
iov, 2, len);
|
iov, 2, len);
|
||||||
conn->params.peer->last_tx_at = ktime_get_seconds();
|
conn->params.peer->last_tx_at = ktime_get_seconds();
|
||||||
|
|
||||||
opt = IP_PMTUDISC_DO;
|
ip_sock_set_mtu_discover(conn->params.local->socket->sk,
|
||||||
kernel_setsockopt(conn->params.local->socket,
|
IP_PMTUDISC_DO);
|
||||||
SOL_IP, IP_MTU_DISCOVER,
|
|
||||||
(char *)&opt, sizeof(opt));
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in New Issue