]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
bpf, sockmap: On receive programs try to fast track SK_PASS ingress
authorJohn Fastabend <john.fastabend@gmail.com>
Fri, 9 Oct 2020 18:36:37 +0000 (11:36 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 24 Nov 2020 12:39:06 +0000 (13:39 +0100)
commit98f54326845b1d1df16c105ccf7aa6f06933de22
tree7b8b8beb88f72150111f393d3435fb590e6a7a0f
parent029cf9bf04a6ad70e5da65e0280ab68a2fbc7711
bpf, sockmap: On receive programs try to fast track SK_PASS ingress

[ Upstream commit 9ecbfb06a078c4911fb444203e8e41d93d22f886 ]

When we receive an skb and the ingress skb verdict program returns
SK_PASS we currently set the ingress flag and put it on the workqueue
so it can be turned into a sk_msg and put on the sk_msg ingress queue.
Then finally telling userspace with data_ready hook.

Here we observe that if the workqueue is empty then we can try to
convert into a sk_msg type and call data_ready directly without
bouncing through a workqueue. Its a common pattern to have a recv
verdict program for visibility that always returns SK_PASS. In this
case unless there is an ENOMEM error or we overrun the socket we
can avoid the workqueue completely only using it when we fall back
to error cases caused by memory pressure.

By doing this we eliminate another case where data may be dropped
if errors occur on memory limits in workqueue.

Fixes: 51199405f9672 ("bpf: skb_verdict, support SK_PASS on RX BPF path")
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/160226859704.5692.12929678876744977669.stgit@john-Precision-5820-Tower
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/core/skmsg.c