Skip to content

Commit

Permalink
espintcp: recv() should return 0 when the peer socket is closed
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
qsn authored and klassert committed Jul 17, 2020
1 parent ac1321e commit e229c87
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion net/xfrm/espintcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,11 @@ static int espintcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
flags |= nonblock ? MSG_DONTWAIT : 0;

skb = __skb_recv_datagram(sk, &ctx->ike_queue, flags, &off, &err);
if (!skb)
if (!skb) {
if (err == -EAGAIN && sk->sk_shutdown & RCV_SHUTDOWN)
return 0;
return err;
}

copied = len;
if (copied > skb->len)
Expand Down

0 comments on commit e229c87

Please sign in to comment.