net: change sk_filter_reason() to return the reason by value

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>
This commit is contained in:
Eric Dumazet
2026-04-09 14:56:22 +00:00
committed by Jakub Kicinski
parent 734ea7e324
commit c78bcbd519
3 changed files with 13 additions and 8 deletions

View 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) {

View 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);

View 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);