From: Eric Dumazet Date: Thu, 9 Apr 2026 14:56:21 +0000 (+0000) Subject: net: always set reason in sk_filter_trim_cap() X-Git-Tag: v7.1-rc1~173^2~21^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=734ea7e324ad1cee2a21f909f756b5e2d903a224;p=thirdparty%2Fkernel%2Flinux.git net: always set reason in sk_filter_trim_cap() sk_filter_trim_cap() will soon return the drop reason by value. Make sure *reason is cleared when no error is returned, to ease this conversion. $ scripts/bloat-o-meter -t vmlinux.old vmlinux.new add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-7 (-7) Function old new delta sk_filter_trim_cap 889 882 -7 Total: Before=29722668, After=29722661, chg -0.00% Signed-off-by: Eric Dumazet Link: https://patch.msgid.link/20260409145625.2306224-3-edumazet@google.com Signed-off-by: Jakub Kicinski --- diff --git a/net/core/filter.c b/net/core/filter.c index cf2113af4bc9a..5569d83b8be06 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -121,7 +121,7 @@ EXPORT_SYMBOL_GPL(copy_bpf_fprog_from_user); * @sk: sock associated with &sk_buff * @skb: buffer to filter * @cap: limit on how short the eBPF program may trim the packet - * @reason: record drop reason on errors (negative return value) + * @reason: record drop reason * * Run the eBPF program and then cut skb->data to correct size returned by * the program. If pkt_len is 0 we toss packet. If skb->len is smaller @@ -168,11 +168,10 @@ int sk_filter_trim_cap(struct sock *sk, struct sk_buff *skb, pkt_len = bpf_prog_run_save_cb(filter->prog, skb); skb->sk = save_sk; err = pkt_len ? pskb_trim(skb, max(cap, pkt_len)) : -EPERM; - if (err) - *reason = SKB_DROP_REASON_SOCKET_FILTER; } rcu_read_unlock(); + *reason = err ? SKB_DROP_REASON_SOCKET_FILTER : 0; return err; } EXPORT_SYMBOL(sk_filter_trim_cap);