From: Jesper Dangaard Brouer <hawk@kernel.org>
To: 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: [PATCH net-next RFC v1 1/4] veth: use same bpf_xdp_adjust_head check as generic-XDP
Date: Tue, 22 Aug 2023 19:59:07 +0200 [thread overview]
Message-ID: <169272714720.1975370.12172959079424954030.stgit@firesoul> (raw)
In-Reply-To: <169272709850.1975370.16698220879817216294.stgit@firesoul>
This is a consistency patch, no functional change.
Both veth_xdp_rcv_skb() and bpf_prog_run_generic_xdp() checks if XDP bpf_prog
adjusted packet head via BPF-helper bpf_xdp_adjust_head(). The order of
subtracting orig_data and xdp->data are opposite between the two functions. This
is confusing when reviewing and reading the code.
This patch choose to follow generic-XDP and adjust veth_xdp_rcv_skb().
In veth_xdp_rcv_skb() the skb_mac_header length have been __skb_push()'ed.
Thus, we skip the skb->mac_header adjustments like bpf_prog_run_generic_xdp()
and instead do a skb_reset_mac_header() as skb->data point to Eth header.
Signed-off-by: Jesper Dangaard Brouer <hawk@kernel.org>
---
drivers/net/veth.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index 953f6d8f8db0..be7b62f57087 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -897,12 +897,13 @@ static struct sk_buff *veth_xdp_rcv_skb(struct veth_rq *rq,
rcu_read_unlock();
/* check if bpf_xdp_adjust_head was used */
- off = orig_data - xdp->data;
- if (off > 0)
- __skb_push(skb, off);
- else if (off < 0)
- __skb_pull(skb, -off);
-
+ off = xdp->data - orig_data;
+ if (off) {
+ if (off > 0)
+ __skb_pull(skb, off);
+ else if (off < 0)
+ __skb_push(skb, -off);
+ }
skb_reset_mac_header(skb);
/* check if bpf_xdp_adjust_tail was used */
next prev parent reply other threads:[~2023-08-22 17:59 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 ` Jesper Dangaard Brouer [this message]
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
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=169272714720.1975370.12172959079424954030.stgit@firesoul \
--to=hawk@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--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