netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Toke Høiland-Jørgensen" <toke@redhat.com>
To: Jesper Dangaard Brouer <hawk@kernel.org>,
	netdev@vger.kernel.org, edumazet@google.com
Cc: Jesper Dangaard Brouer <hawk@kernel.org>,
	pabeni@redhat.com, kuba@kernel.org, davem@davemloft.net,
	lorenzo@kernel.org,
	Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	mtahhan@redhat.com, huangjie.albert@bytedance.com,
	Yunsheng Lin <linyunsheng@huawei.com>,
	Liang Chen <liangchen.linux@gmail.com>
Subject: Re: [PATCH net-next RFC v1 2/4] veth: use generic-XDP functions when dealing with SKBs
Date: Thu, 24 Aug 2023 12:30:50 +0200	[thread overview]
Message-ID: <87msyg91gl.fsf@toke.dk> (raw)
In-Reply-To: <169272715407.1975370.3989385869434330916.stgit@firesoul>

Jesper Dangaard Brouer <hawk@kernel.org> writes:

> The root-cause the realloc issue is that veth_xdp_rcv_skb() code path (that
> handles SKBs like generic-XDP) is calling a native-XDP function
> xdp_do_redirect(), instead of simply using xdp_do_generic_redirect() that can
> handle SKBs.
>
> The existing code tries to steal the packet-data from the SKB (and frees the SKB
> itself). This cause issues as SKBs can have different memory models that are
> incompatible with native-XDP call xdp_do_redirect(). For this reason the checks
> in veth_convert_skb_to_xdp_buff() becomes more strict. This in turn makes this a
> bad approach. Simply leveraging generic-XDP helpers e.g. generic_xdp_tx() and
> xdp_do_generic_redirect() as this resolves the issue given netstack can handle
> these different SKB memory models.

While this does solve the memory issue, it's also a subtle change of
semantics. For one thing, generic_xdp_tx() has this comment above it:

/* When doing generic XDP we have to bypass the qdisc layer and the
 * network taps in order to match in-driver-XDP behavior. This also means
 * that XDP packets are able to starve other packets going through a qdisc,
 * and DDOS attacks will be more effective. In-driver-XDP use dedicated TX
 * queues, so they do not have this starvation issue.
 */

Also, more generally, this means that if you have a setup with
XDP_REDIRECT-based forwarding in on a host with a mix of physical and
veth devices, all the traffic originating from the veth devices will go
on different TXQs than that originating from a physical NIC. Or if a
veth device has a mix of xdp_frame-backed packets and skb-backed
packets, those will also go on different queues, potentially leading to
reordering.

I'm not sure exactly how much of an issue this is in practice, but at
least from a conceptual PoV it's a change in behaviour that I don't
think we should be making lightly. WDYT?

-Toke


  reply	other threads:[~2023-08-24 10:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-22 17:59 [PATCH net-next RFC v1 0/4] veth: reduce reallocations of SKBs when XDP bpf-prog is loaded Jesper Dangaard Brouer
2023-08-22 17:59 ` [PATCH net-next RFC v1 1/4] veth: use same bpf_xdp_adjust_head check as generic-XDP Jesper Dangaard Brouer
2023-08-22 17:59 ` [PATCH net-next RFC v1 2/4] veth: use generic-XDP functions when dealing with SKBs Jesper Dangaard Brouer
2023-08-24 10:30   ` Toke Høiland-Jørgensen [this message]
2023-08-29 14:37     ` Jesper Dangaard Brouer
2023-09-01 13:32       ` Toke Høiland-Jørgensen
2023-08-22 17:59 ` [PATCH net-next RFC v1 3/4] veth: lift skb_head_is_locked restriction for SKB based XDP Jesper Dangaard Brouer
2023-08-22 17:59 ` [PATCH net-next RFC v1 4/4] veth: when XDP is loaded increase needed_headroom Jesper Dangaard Brouer
2023-08-24  4:27 ` [PATCH net-next RFC v1 0/4] veth: reduce reallocations of SKBs when XDP bpf-prog is loaded Liang Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87msyg91gl.fsf@toke.dk \
    --to=toke@redhat.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hawk@kernel.org \
    --cc=huangjie.albert@bytedance.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=kuba@kernel.org \
    --cc=liangchen.linux@gmail.com \
    --cc=linyunsheng@huawei.com \
    --cc=lorenzo@kernel.org \
    --cc=mtahhan@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).