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: 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>

authored by

Eric Dumazet and committed by
Jakub Kicinski
c78bcbd5 734ea7e3

+13 -8
+5 -3
drivers/net/tun.c
··· 1031 1031 goto drop; 1032 1032 } 1033 1033 1034 - if (tfile->socket.sk->sk_filter && 1035 - sk_filter_reason(tfile->socket.sk, skb, &drop_reason)) 1036 - goto drop; 1034 + if (tfile->socket.sk->sk_filter) { 1035 + drop_reason = sk_filter_reason(tfile->socket.sk, skb); 1036 + if (drop_reason) 1037 + goto drop; 1038 + } 1037 1039 1038 1040 len = run_ebpf_filter(tun, skb, len); 1039 1041 if (len == 0) {
+6 -3
include/linux/filter.h
··· 1102 1102 return sk_filter_trim_cap(sk, skb, 1, &ignore_reason); 1103 1103 } 1104 1104 1105 - static inline int sk_filter_reason(struct sock *sk, struct sk_buff *skb, 1106 - enum skb_drop_reason *reason) 1105 + static inline enum skb_drop_reason 1106 + sk_filter_reason(struct sock *sk, struct sk_buff *skb) 1107 1107 { 1108 - return sk_filter_trim_cap(sk, skb, 1, reason); 1108 + enum skb_drop_reason drop_reason; 1109 + 1110 + sk_filter_trim_cap(sk, skb, 1, &drop_reason); 1111 + return drop_reason; 1109 1112 } 1110 1113 1111 1114 struct bpf_prog *bpf_prog_select_runtime(struct bpf_prog *fp, int *err);
+2 -2
net/core/sock.c
··· 526 526 enum skb_drop_reason drop_reason; 527 527 int err; 528 528 529 - err = sk_filter_reason(sk, skb, &drop_reason); 530 - if (err) 529 + drop_reason = sk_filter_reason(sk, skb); 530 + if (drop_reason) 531 531 return drop_reason; 532 532 533 533 err = __sock_queue_rcv_skb(sk, skb);