Skip to content

Commit

Permalink
ipv6: add ip6_sock_set_recvpktinfo
Browse files Browse the repository at this point in the history
Add a helper to directly set the IPV6_RECVPKTINFO 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>
  • Loading branch information
Christoph Hellwig authored and David S. Miller committed May 28, 2020
1 parent 18d5ad6 commit 7d7207c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
7 changes: 7 additions & 0 deletions include/net/ipv6.h
Original file line number Diff line number Diff line change
Expand Up @@ -1262,4 +1262,11 @@ static inline int ip6_sock_set_addr_preferences(struct sock *sk, bool val)
return ret;
}

static inline void ip6_sock_set_recvpktinfo(struct sock *sk)
{
lock_sock(sk);
inet6_sk(sk)->rxopt.bits.rxinfo = true;
release_sock(sk);
}

#endif /* _NET_IPV6_H */
10 changes: 2 additions & 8 deletions net/sunrpc/svcsock.c
Original file line number Diff line number Diff line change
Expand Up @@ -595,8 +595,6 @@ static struct svc_xprt_class svc_udp_class = {

static void svc_udp_init(struct svc_sock *svsk, struct svc_serv *serv)
{
int err, level, optname, one = 1;

svc_xprt_init(sock_net(svsk->sk_sock->sk), &svc_udp_class,
&svsk->sk_xprt, serv);
clear_bit(XPT_CACHE_AUTH, &svsk->sk_xprt.xpt_flags);
Expand All @@ -617,17 +615,13 @@ static void svc_udp_init(struct svc_sock *svsk, struct svc_serv *serv)
switch (svsk->sk_sk->sk_family) {
case AF_INET:
ip_sock_set_pktinfo(svsk->sk_sock->sk);
return;
break;
case AF_INET6:
level = SOL_IPV6;
optname = IPV6_RECVPKTINFO;
ip6_sock_set_recvpktinfo(svsk->sk_sock->sk);
break;
default:
BUG();
}
err = kernel_setsockopt(svsk->sk_sock, level, optname,
(char *)&one, sizeof(one));
dprintk("svc: kernel_setsockopt returned %d\n", err);
}

/*
Expand Down

0 comments on commit 7d7207c

Please sign in to comment.