]> www.infradead.org Git - users/hch/misc.git/commitdiff
af_unix: Set drop reason in unix_stream_read_skb().
authorKuniyuki Iwashima <kuniyu@amazon.com>
Thu, 16 Jan 2025 05:34:39 +0000 (14:34 +0900)
committerJakub Kicinski <kuba@kernel.org>
Mon, 20 Jan 2025 19:27:41 +0000 (11:27 -0800)
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>
net/unix/af_unix.c

index e31fda1d319f6542e40304171e0c0760d7f76fb9..de4966e1b7ff95a4eecb8c2ba29a318c65d6459a 100644 (file)
@@ -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;
                }
 
@@ -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;
                }
        }