Skip to content

Commit

Permalink
af_unix: Set drop reason in unix_stream_read_skb().
Browse files Browse the repository at this point in the history
unix_stream_read_skb() is called when BPF SOCKMAP reads some data
from a socket in the map.

SOCKMAP does not support MSG_OOB, and reading OOB results in a drop.

Let's set drop reasons respectively.

  * SOCKET_CLOSE  : the socket in SOCKMAP was close()d
  * UNIX_SKIP_OOB : OOB was read from the socket in SOCKMAP

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Link: https://patch.msgid.link/20250116053441.5758-7-kuniyu@amazon.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Kuniyuki Iwashima authored and Jakub Kicinski committed Jan 20, 2025
1 parent 533643b commit bace4b4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions net/unix/af_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -2724,7 +2724,7 @@ static int unix_stream_read_skb(struct sock *sk, skb_read_actor_t recv_actor)

if (sock_flag(sk, SOCK_DEAD)) {
unix_state_unlock(sk);
kfree_skb(skb);
kfree_skb_reason(skb, SKB_DROP_REASON_SOCKET_CLOSE);
return -ECONNRESET;
}

Expand All @@ -2738,7 +2738,7 @@ static int unix_stream_read_skb(struct sock *sk, skb_read_actor_t recv_actor)
unix_state_unlock(sk);

if (drop) {
kfree_skb(skb);
kfree_skb_reason(skb, SKB_DROP_REASON_UNIX_SKIP_OOB);
return -EAGAIN;
}
}
Expand Down

0 comments on commit bace4b4

Please sign in to comment.