]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: change sk_filter_reason() to return the reason by value
authorEric Dumazet <edumazet@google.com>
Thu, 9 Apr 2026 14:56:22 +0000 (14:56 +0000)
committerJakub Kicinski <kuba@kernel.org>
Sun, 12 Apr 2026 21:30:25 +0000 (14:30 -0700)
sk_filter_trim_cap will soon return the reason by value,
do the same for sk_filter_reason().

$ scripts/bloat-o-meter -t vmlinux.old vmlinux.new
add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-21 (-21)
Function                                     old     new   delta
sock_queue_rcv_skb_reason                    128     126      -2
tun_net_xmit                                1146    1127     -19
Total: Before=29722661, After=29722640, chg -0.00%

Signed-off-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20260409145625.2306224-4-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/tun.c
include/linux/filter.h
net/core/sock.c

index c492fda6fc15a79c13f56cb15dc273331b854422..b183189f185354051bded95f43bd77ee4f7cde24 100644 (file)
@@ -1031,9 +1031,11 @@ static netdev_tx_t tun_net_xmit(struct sk_buff *skb, struct net_device *dev)
                goto drop;
        }
 
-       if (tfile->socket.sk->sk_filter &&
-           sk_filter_reason(tfile->socket.sk, skb, &drop_reason))
-               goto drop;
+       if (tfile->socket.sk->sk_filter) {
+               drop_reason = sk_filter_reason(tfile->socket.sk, skb);
+               if (drop_reason)
+                       goto drop;
+       }
 
        len = run_ebpf_filter(tun, skb, len);
        if (len == 0) {
index 44d7ae95ddbccd0ba72740b5547e91e1990686f2..59931e5810b4fcff5788616a3875767421dba3bc 100644 (file)
@@ -1102,10 +1102,13 @@ static inline int sk_filter(struct sock *sk, struct sk_buff *skb)
        return sk_filter_trim_cap(sk, skb, 1, &ignore_reason);
 }
 
-static inline int sk_filter_reason(struct sock *sk, struct sk_buff *skb,
-                                  enum skb_drop_reason *reason)
+static inline enum skb_drop_reason
+sk_filter_reason(struct sock *sk, struct sk_buff *skb)
 {
-       return sk_filter_trim_cap(sk, skb, 1, reason);
+       enum skb_drop_reason drop_reason;
+
+       sk_filter_trim_cap(sk, skb, 1, &drop_reason);
+       return drop_reason;
 }
 
 struct bpf_prog *bpf_prog_select_runtime(struct bpf_prog *fp, int *err);
index d39a4d6ccafd9e03f4e82482d3f3e46ce5d58771..1ffcb15d0fc5e39201aab24616d40a37aa41c823 100644 (file)
@@ -526,8 +526,8 @@ sock_queue_rcv_skb_reason(struct sock *sk, struct sk_buff *skb)
        enum skb_drop_reason drop_reason;
        int err;
 
-       err = sk_filter_reason(sk, skb, &drop_reason);
-       if (err)
+       drop_reason = sk_filter_reason(sk, skb);
+       if (drop_reason)
                return drop_reason;
 
        err = __sock_queue_rcv_skb(sk, skb);