Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ipv4: add ip_sock_set_recverr

Add a helper to directly set the IP_RECVERR 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>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Christoph Hellwig and committed by
David S. Miller
db45c0ef c4e446bf

+10 -7
+1
include/net/ip.h
··· 766 766 } 767 767 768 768 void ip_sock_set_freebind(struct sock *sk); 769 + void ip_sock_set_recverr(struct sock *sk); 769 770 void ip_sock_set_tos(struct sock *sk, int val); 770 771 771 772 #endif /* _IP_H */
+8
net/ipv4/ip_sockglue.c
··· 589 589 } 590 590 EXPORT_SYMBOL(ip_sock_set_freebind); 591 591 592 + void ip_sock_set_recverr(struct sock *sk) 593 + { 594 + lock_sock(sk); 595 + inet_sk(sk)->recverr = true; 596 + release_sock(sk); 597 + } 598 + EXPORT_SYMBOL(ip_sock_set_recverr); 599 + 592 600 /* 593 601 * Socket option code for IP. This is the end of the line after any 594 602 * TCP,UDP etc options on an IP socket.
+1 -7
net/rxrpc/local_object.c
··· 171 171 /* Fall through */ 172 172 case AF_INET: 173 173 /* we want to receive ICMP errors */ 174 - opt = 1; 175 - ret = kernel_setsockopt(local->socket, SOL_IP, IP_RECVERR, 176 - (char *) &opt, sizeof(opt)); 177 - if (ret < 0) { 178 - _debug("setsockopt failed"); 179 - goto error; 180 - } 174 + ip_sock_set_recverr(local->socket->sk); 181 175 182 176 /* we want to set the don't fragment bit */ 183 177 opt = IP_PMTUDISC_DO;