Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Eric Dumazet and committed by
Jakub Kicinski
734ea7e3 900f27fb

+2 -3
+2 -3
net/core/filter.c
··· 121 121 * @sk: sock associated with &sk_buff 122 122 * @skb: buffer to filter 123 123 * @cap: limit on how short the eBPF program may trim the packet 124 - * @reason: record drop reason on errors (negative return value) 124 + * @reason: record drop reason 125 125 * 126 126 * Run the eBPF program and then cut skb->data to correct size returned by 127 127 * the program. If pkt_len is 0 we toss packet. If skb->len is smaller ··· 168 168 pkt_len = bpf_prog_run_save_cb(filter->prog, skb); 169 169 skb->sk = save_sk; 170 170 err = pkt_len ? pskb_trim(skb, max(cap, pkt_len)) : -EPERM; 171 - if (err) 172 - *reason = SKB_DROP_REASON_SOCKET_FILTER; 173 171 } 174 172 rcu_read_unlock(); 175 173 174 + *reason = err ? SKB_DROP_REASON_SOCKET_FILTER : 0; 176 175 return err; 177 176 } 178 177 EXPORT_SYMBOL(sk_filter_trim_cap);