hc
2024-05-14 bedbef8ad3e75a304af6361af235302bcc61d06b
kernel/net/ipv4/tcp_bpf.c
....@@ -6,6 +6,7 @@
66 #include <linux/bpf.h>
77 #include <linux/init.h>
88 #include <linux/wait.h>
9
+#include <linux/util_macros.h>
910
1011 #include <net/inet_common.h>
1112 #include <net/tls.h>
....@@ -125,8 +126,11 @@
125126 tmp->sg.end = i;
126127 if (apply) {
127128 apply_bytes -= size;
128
- if (!apply_bytes)
129
+ if (!apply_bytes) {
130
+ if (sge->length)
131
+ sk_msg_iter_var_prev(i);
129132 break;
133
+ }
130134 }
131135 } while (i != msg->sg.end);
132136
....@@ -258,7 +262,7 @@
258262 sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk);
259263 ret = sk_wait_event(sk, &timeo,
260264 !list_empty(&psock->ingress_msg) ||
261
- !skb_queue_empty(&sk->sk_receive_queue), &wait);
265
+ !skb_queue_empty_lockless(&sk->sk_receive_queue), &wait);
262266 sk_clear_bit(SOCKWQ_ASYNC_WAITDATA, sk);
263267 remove_wait_queue(sk_sleep(sk), &wait);
264268 return ret;
....@@ -316,7 +320,7 @@
316320 bool cork = false, enospc = sk_msg_full(msg);
317321 struct sock *sk_redir;
318322 u32 tosend, origsize, sent, delta = 0;
319
- u32 eval = __SK_NONE;
323
+ u32 eval;
320324 int ret;
321325
322326 more_data:
....@@ -347,6 +351,7 @@
347351 tosend = msg->sg.size;
348352 if (psock->apply_bytes && psock->apply_bytes < tosend)
349353 tosend = psock->apply_bytes;
354
+ eval = __SK_NONE;
350355
351356 switch (psock->eval) {
352357 case __SK_PASS:
....@@ -638,10 +643,9 @@
638643 */
639644 void tcp_bpf_clone(const struct sock *sk, struct sock *newsk)
640645 {
641
- int family = sk->sk_family == AF_INET6 ? TCP_BPF_IPV6 : TCP_BPF_IPV4;
642646 struct proto *prot = newsk->sk_prot;
643647
644
- if (prot == &tcp_bpf_prots[family][TCP_BPF_BASE])
648
+ if (is_insidevar(prot, tcp_bpf_prots))
645649 newsk->sk_prot = sk->sk_prot_creator;
646650 }
647651 #endif /* CONFIG_BPF_STREAM_PARSER */