Thread (11 messages) 11 messages, 2 authors, 2021-03-26

Re: [bpf PATCH 2/2] bpf, sockmap: fix incorrect fwd_alloc accounting

flat view

From: John Fastabend <john.fastabend@gmail.com>
Date: 2021-03-26 01:00:10
Also in: bpf

Cong Wang wrote:
On Wed, Mar 24, 2021 at 7:46 PM John Fastabend [off-list ref] wrote:
quoted
Cong Wang wrote:
quoted
On Wed, Mar 24, 2021 at 2:00 PM John Fastabend [off-list ref] wrote:
quoted
Incorrect accounting fwd_alloc can result in a warning when the socket
is torn down,
[...]
quoted
quoted
To resolve lets only account for sockets on the ingress queue that are
still associated with the current socket. On the redirect case we will
check memory limits per 6fa9201a89898, but will omit fwd_alloc accounting
until skb is actually enqueued. When the skb is sent via skb_send_sock_locked
or received with sk_psock_skb_ingress memory will be claimed on psock_other.
                     ^^^^^^^^^^^^^^^^^^^^
quoted
You mean sk_psock_skb_ingress(), right?
Yes.
skb_send_sock_locked() actually allocates its own skb when sending, hence
it uses a different skb for memory accounting.
quoted
[...]
quoted
quoted
@@ -880,12 +876,13 @@ static void sk_psock_strp_read(struct strparser *strp, struct sk_buff *skb)
                kfree_skb(skb);
                goto out;
        }
-       skb_set_owner_r(skb, sk);
        prog = READ_ONCE(psock->progs.skb_verdict);
        if (likely(prog)) {
+               skb->sk = psock->sk;
Why is skb_orphan() not needed here?
These come from strparser which do not have skb->sk set.
Hmm, but sk_psock_verdict_recv() passes a clone too, like
strparser, so either we need it for both, or not at all. Clones
do not have skb->sk, so I think you can remove the one in
sk_psock_verdict_recv() too.
Agree skb_orphan can just be removed, I was being overly
paranoid.

Thanks.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help