Skip to content

Commit 5119940

Browse files
jrfastabborkmann
authored andcommitted
bpf: skb_verdict, support SK_PASS on RX BPF path
Add SK_PASS verdict support to SK_SKB_VERDICT programs. Now that support for redirects exists we can implement SK_PASS as a redirect to the same socket. This simplifies the BPF programs and avoids an extra map lookup on RX path for simple visibility cases. Further, reduces user (BPF programmer in this context) confusion when their program drops skb due to lack of support. Signed-off-by: John Fastabend <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]>
1 parent 7a69c0f commit 5119940

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

net/core/skmsg.c

+16
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,22 @@ static void sk_psock_verdict_apply(struct sk_psock *psock,
669669
bool ingress;
670670

671671
switch (verdict) {
672+
case __SK_PASS:
673+
sk_other = psock->sk;
674+
if (sock_flag(sk_other, SOCK_DEAD) ||
675+
!sk_psock_test_state(psock, SK_PSOCK_TX_ENABLED)) {
676+
goto out_free;
677+
}
678+
if (atomic_read(&sk_other->sk_rmem_alloc) <=
679+
sk_other->sk_rcvbuf) {
680+
struct tcp_skb_cb *tcp = TCP_SKB_CB(skb);
681+
682+
tcp->bpf.flags |= BPF_F_INGRESS;
683+
skb_queue_tail(&psock->ingress_skb, skb);
684+
schedule_work(&psock->work);
685+
break;
686+
}
687+
goto out_free;
672688
case __SK_REDIRECT:
673689
sk_other = tcp_skb_bpf_redirect_fetch(skb);
674690
if (unlikely(!sk_other))

0 commit comments

Comments
 (0)