netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] socket: skip checking sk_err for recvmmsg(MSG_ERRQUEUE)
@ 2018-02-27 23:22 Soheil Hassas Yeganeh
  2018-03-02  2:28 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Soheil Hassas Yeganeh @ 2018-02-27 23:22 UTC (permalink / raw)
  To: davem, netdev; +Cc: edumazet, willemb, Soheil Hassas Yeganeh

From: Soheil Hassas Yeganeh <soheil@google.com>

recvmmsg does not call ___sys_recvmsg when sk_err is set.
That is fine for normal reads but, for MSG_ERRQUEUE, recvmmsg
should always call ___sys_recvmsg regardless of sk->sk_err to
be able to clear error queue. Otherwise, users are not able to
drain the error queue using recvmmsg.

Signed-off-by: Soheil Hassas Yeganeh <soheil@google.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Willem de Bruijn <willemb@google.com>
---
 net/socket.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/net/socket.c b/net/socket.c
index 645d32b4872c..d9a1ac233b35 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -2289,10 +2289,12 @@ int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
 	if (!sock)
 		return err;
 
-	err = sock_error(sock->sk);
-	if (err) {
-		datagrams = err;
-		goto out_put;
+	if (likely(!(flags & MSG_ERRQUEUE))) {
+		err = sock_error(sock->sk);
+		if (err) {
+			datagrams = err;
+			goto out_put;
+		}
 	}
 
 	entry = mmsg;
-- 
2.16.2.395.g2e18187dfd-goog

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net-next] socket: skip checking sk_err for recvmmsg(MSG_ERRQUEUE)
  2018-02-27 23:22 [PATCH net-next] socket: skip checking sk_err for recvmmsg(MSG_ERRQUEUE) Soheil Hassas Yeganeh
@ 2018-03-02  2:28 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2018-03-02  2:28 UTC (permalink / raw)
  To: soheil.kdev; +Cc: netdev, edumazet, willemb, soheil

From: Soheil Hassas Yeganeh <soheil.kdev@gmail.com>
Date: Tue, 27 Feb 2018 18:22:40 -0500

> From: Soheil Hassas Yeganeh <soheil@google.com>
> 
> recvmmsg does not call ___sys_recvmsg when sk_err is set.
> That is fine for normal reads but, for MSG_ERRQUEUE, recvmmsg
> should always call ___sys_recvmsg regardless of sk->sk_err to
> be able to clear error queue. Otherwise, users are not able to
> drain the error queue using recvmmsg.
> 
> Signed-off-by: Soheil Hassas Yeganeh <soheil@google.com>
> Reviewed-by: Eric Dumazet <edumazet@google.com>
> Signed-off-by: Willem de Bruijn <willemb@google.com>

Applied, thank you.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-03-02  2:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-27 23:22 [PATCH net-next] socket: skip checking sk_err for recvmmsg(MSG_ERRQUEUE) Soheil Hassas Yeganeh
2018-03-02  2:28 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).