summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2026-04-09 14:56:21 +0000
committerJakub Kicinski <kuba@kernel.org>2026-04-12 14:30:25 -0700
commit734ea7e324ad1cee2a21f909f756b5e2d903a224 (patch)
tree4f2aa6314472a58057bac1a10c69461ef0036125 /net
parent900f27fb797c7eaf0b84b7a6516613e19746bc4e (diff)
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 <edumazet@google.com> Link: https://patch.msgid.link/20260409145625.2306224-3-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net')
-rw-r--r--net/core/filter.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/net/core/filter.c b/net/core/filter.c
index cf2113af4bc9..5569d83b8be0 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);