summaryrefslogtreecommitdiff
path: root/net/ipv4/ip_sockglue.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2020-05-28 08:12:30 +0300
committerDavid S. Miller <davem@davemloft.net>2020-05-28 21:11:45 +0300
commitc1f9ec5776dd05eaf62cf6788ecdfc905dc8ec2b (patch)
treea57b9eabde6a05a80239467f15256f64fe184148 /net/ipv4/ip_sockglue.c
parent2de569bda2a66d1308ad3f205bb29cf4f95f5636 (diff)
downloadlinux-c1f9ec5776dd05eaf62cf6788ecdfc905dc8ec2b.tar.xz
ipv4: add ip_sock_set_pktinfo
Add a helper to directly set the IP_PKTINFO sockopt from kernel space without going through a fake uaccess. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/ip_sockglue.c')
-rw-r--r--net/ipv4/ip_sockglue.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
index aa115be11dcf..84ec3703c909 100644
--- a/net/ipv4/ip_sockglue.c
+++ b/net/ipv4/ip_sockglue.c
@@ -608,6 +608,14 @@ int ip_sock_set_mtu_discover(struct sock *sk, int val)
}
EXPORT_SYMBOL(ip_sock_set_mtu_discover);
+void ip_sock_set_pktinfo(struct sock *sk)
+{
+ lock_sock(sk);
+ inet_sk(sk)->cmsg_flags |= IP_CMSG_PKTINFO;
+ release_sock(sk);
+}
+EXPORT_SYMBOL(ip_sock_set_pktinfo);
+
/*
* Socket option code for IP. This is the end of the line after any
* TCP,UDP etc options on an IP socket.