Lines Matching refs:psock
14 int __tcp_bpf_recvmsg(struct sock *sk, struct sk_psock *psock,
22 msg_rx = list_first_entry_or_null(&psock->ingress_msg,
72 if (msg_rx == list_last_entry(&psock->ingress_msg,
86 msg_rx = list_first_entry_or_null(&psock->ingress_msg,
94 static int bpf_tcp_ingress(struct sock *sk, struct sk_psock *psock,
139 sk_psock_queue_msg(psock, tmp);
140 sk_psock_data_ready(sk, psock);
222 struct sk_psock *psock = sk_psock_get(sk);
225 if (unlikely(!psock))
228 ret = ingress ? bpf_tcp_ingress(sk, psock, msg, bytes, flags) :
230 sk_psock_put(sk, psock);
238 struct sk_psock *psock;
242 psock = sk_psock(sk);
243 if (likely(psock))
244 empty = list_empty(&psock->ingress_msg);
249 static int tcp_bpf_wait_data(struct sock *sk, struct sk_psock *psock,
264 !list_empty(&psock->ingress_msg) ||
274 struct sk_psock *psock;
280 psock = sk_psock_get(sk);
281 if (unlikely(!psock))
284 sk_psock_queue_empty(psock)) {
285 sk_psock_put(sk, psock);
290 copied = __tcp_bpf_recvmsg(sk, psock, msg, len, flags);
296 data = tcp_bpf_wait_data(sk, psock, flags, timeo, &err);
298 if (!sk_psock_queue_empty(psock))
301 sk_psock_put(sk, psock);
313 sk_psock_put(sk, psock);
317 static int tcp_bpf_send_verdict(struct sock *sk, struct sk_psock *psock,
327 if (psock->eval == __SK_NONE) {
334 psock->eval = sk_psock_msg_verdict(sk, psock, msg);
340 psock->cork_bytes = msg->cork_bytes - msg->sg.size;
341 if (!psock->cork) {
342 psock->cork = kzalloc(sizeof(*psock->cork),
344 if (!psock->cork)
347 memcpy(psock->cork, msg, sizeof(*msg));
352 if (psock->apply_bytes && psock->apply_bytes < tosend)
353 tosend = psock->apply_bytes;
356 switch (psock->eval) {
363 sk_msg_apply_bytes(psock, tosend);
366 sk_redir = psock->sk_redir;
367 sk_msg_apply_bytes(psock, tosend);
368 if (!psock->apply_bytes) {
370 eval = psock->eval;
371 psock->eval = __SK_NONE;
372 psock->sk_redir = NULL;
374 if (psock->cork) {
376 psock->cork = NULL;
405 sk_msg_apply_bytes(psock, tosend);
411 if (!psock->apply_bytes) {
412 psock->eval = __SK_NONE;
413 if (psock->sk_redir) {
414 sock_put(psock->sk_redir);
415 psock->sk_redir = NULL;
433 struct sk_psock *psock;
441 psock = sk_psock_get(sk);
442 if (unlikely(!psock))
459 if (psock->cork) {
460 msg_tx = psock->cork;
483 if (psock->cork_bytes) {
484 if (size > psock->cork_bytes)
485 psock->cork_bytes = 0;
487 psock->cork_bytes -= size;
488 if (psock->cork_bytes && !enospc)
491 psock->eval = __SK_NONE;
492 psock->cork_bytes = 0;
495 err = tcp_bpf_send_verdict(sk, psock, msg_tx, &copied, flags);
504 if (msg_tx && msg_tx != psock->cork)
513 sk_psock_put(sk, psock);
522 struct sk_psock *psock;
525 psock = sk_psock_get(sk);
526 if (unlikely(!psock))
530 if (psock->cork) {
531 msg = psock->cork;
546 if (psock->cork_bytes) {
547 if (size > psock->cork_bytes)
548 psock->cork_bytes = 0;
550 psock->cork_bytes -= size;
551 if (psock->cork_bytes && !enospc)
554 psock->eval = __SK_NONE;
555 psock->cork_bytes = 0;
558 err = tcp_bpf_send_verdict(sk, psock, msg, &copied, flags);
561 sk_psock_put(sk, psock);
616 * into ops if e.g. a psock is not present. Make sure they are
624 struct proto *tcp_bpf_get_proto(struct sock *sk, struct sk_psock *psock)
627 int config = psock->progs.msg_parser ? TCP_BPF_TX : TCP_BPF_BASE;
630 if (tcp_bpf_assert_proto_ops(psock->sk_proto))
633 tcp_bpf_check_v6_needs_rebuild(psock->sk_proto);
641 * the default ones because the child does not inherit the psock state