Skip to content

Commit 68ab5d1

Browse files
Paolo Abenidavem330
authored andcommitted
ipv6: provide and use ipv6 specific version for {recv, send}msg
This will simplify indirect call wrapper invocation in the following patch. No functional change intended, any - out-of-tree - IPv6 user of inet_{recv,send}msg can keep using the existing functions. SCTP code still uses the existing version even for ipv6: as this series will not add ICW for SCTP, moving to the new helper would not give any benefit. The only other in-kernel user of inet_{recv,send}msg is pvcalls_conn_back_read(), but psvcalls explicitly creates only IPv4 socket, so no need to update that code path, too. v1 -> v2: drop inet6_{recv,send}msg declaration from header file, prefer ICW macro instead Signed-off-by: Paolo Abeni <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e473093 commit 68ab5d1

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed

net/ipv6/af_inet6.c

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,33 @@ int inet6_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
564564
}
565565
EXPORT_SYMBOL(inet6_ioctl);
566566

567+
int inet6_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
568+
{
569+
struct sock *sk = sock->sk;
570+
571+
if (unlikely(inet_send_prepare(sk)))
572+
return -EAGAIN;
573+
574+
return sk->sk_prot->sendmsg(sk, msg, size);
575+
}
576+
577+
int inet6_recvmsg(struct socket *sock, struct msghdr *msg, size_t size,
578+
int flags)
579+
{
580+
struct sock *sk = sock->sk;
581+
int addr_len = 0;
582+
int err;
583+
584+
if (likely(!(flags & MSG_ERRQUEUE)))
585+
sock_rps_record_flow(sk);
586+
587+
err = sk->sk_prot->recvmsg(sk, msg, size, flags & MSG_DONTWAIT,
588+
flags & ~MSG_DONTWAIT, &addr_len);
589+
if (err >= 0)
590+
msg->msg_namelen = addr_len;
591+
return err;
592+
}
593+
567594
const struct proto_ops inet6_stream_ops = {
568595
.family = PF_INET6,
569596
.owner = THIS_MODULE,
@@ -580,8 +607,8 @@ const struct proto_ops inet6_stream_ops = {
580607
.shutdown = inet_shutdown, /* ok */
581608
.setsockopt = sock_common_setsockopt, /* ok */
582609
.getsockopt = sock_common_getsockopt, /* ok */
583-
.sendmsg = inet_sendmsg, /* ok */
584-
.recvmsg = inet_recvmsg, /* ok */
610+
.sendmsg = inet6_sendmsg, /* retpoline's sake */
611+
.recvmsg = inet6_recvmsg, /* retpoline's sake */
585612
#ifdef CONFIG_MMU
586613
.mmap = tcp_mmap,
587614
#endif
@@ -614,8 +641,8 @@ const struct proto_ops inet6_dgram_ops = {
614641
.shutdown = inet_shutdown, /* ok */
615642
.setsockopt = sock_common_setsockopt, /* ok */
616643
.getsockopt = sock_common_getsockopt, /* ok */
617-
.sendmsg = inet_sendmsg, /* ok */
618-
.recvmsg = inet_recvmsg, /* ok */
644+
.sendmsg = inet6_sendmsg, /* retpoline's sake */
645+
.recvmsg = inet6_recvmsg, /* retpoline's sake */
619646
.mmap = sock_no_mmap,
620647
.sendpage = sock_no_sendpage,
621648
.set_peek_off = sk_set_peek_off,

0 commit comments

Comments
 (0)