Skip to content

Commit e229c87

Browse files
qsnklassert
authored andcommitted
espintcp: recv() should return 0 when the peer socket is closed
man 2 recv says: RETURN VALUE When a stream socket peer has performed an orderly shutdown, the return value will be 0 (the traditional "end-of-file" return). Currently, this works for blocking reads, but non-blocking reads will return -EAGAIN. This patch overwrites that return value when the peer won't send us any more data. Fixes: e27cca9 ("xfrm: add espintcp (RFC 8229)") Reported-by: Andrew Cagney <[email protected]> Tested-by: Andrew Cagney <[email protected]> Signed-off-by: Sabrina Dubroca <[email protected]> Signed-off-by: Steffen Klassert <[email protected]>
1 parent ac1321e commit e229c87

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

net/xfrm/espintcp.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,11 @@ static int espintcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
109109
flags |= nonblock ? MSG_DONTWAIT : 0;
110110

111111
skb = __skb_recv_datagram(sk, &ctx->ike_queue, flags, &off, &err);
112-
if (!skb)
112+
if (!skb) {
113+
if (err == -EAGAIN && sk->sk_shutdown & RCV_SHUTDOWN)
114+
return 0;
113115
return err;
116+
}
114117

115118
copied = len;
116119
if (copied > skb->len)

0 commit comments

Comments
 (0)