From: Jesper Dangaard Brouer <brouer@redhat.com>
To: Martin KaFai Lau <kafai@fb.com>
Cc: <netdev@vger.kernel.org>, Alexei Starovoitov <ast@fb.com>,
Brenden Blanco <bblanco@plumgrid.com>,
Daniel Borkmann <daniel@iogearbox.net>,
David Miller <davem@davemloft.net>,
Saeed Mahameed <saeedm@mellanox.com>,
Tariq Toukan <tariqt@mellanox.com>,
Kernel Team <kernel-team@fb.com>,
brouer@redhat.com
Subject: Re: [PATCH v2 net-next 1/4] bpf: xdp: Allow head adjustment in XDP prog
Date: Mon, 5 Dec 2016 08:35:33 +0100 [thread overview]
Message-ID: <20161205083533.1467e329@redhat.com> (raw)
In-Reply-To: <1480821446-4122277-2-git-send-email-kafai@fb.com>
On Sat, 3 Dec 2016 19:17:23 -0800 Martin KaFai Lau <kafai@fb.com> wrote:
> This patch allows XDP prog to extend/remove the packet
> data at the head (like adding or removing header). It is
> done by adding a new XDP helper bpf_xdp_adjust_head().
>
> It also renames bpf_helper_changes_skb_data() to
> bpf_helper_changes_pkt_data() to better reflect
> that XDP prog does not work on skb.
>
> Acked-by: Alexei Starovoitov <ast@kernel.org>
> Signed-off-by: Martin KaFai Lau <kafai@fb.com>
> ---
[...]
> diff --git a/net/core/filter.c b/net/core/filter.c
> index 56b43587d200..ccef948cf58a 100644
> --- a/net/core/filter.c
> +++ b/net/core/filter.c
> @@ -2234,7 +2234,34 @@ static const struct bpf_func_proto bpf_skb_change_head_proto = {
> .arg3_type = ARG_ANYTHING,
> };
>
> -bool bpf_helper_changes_skb_data(void *func)
> +BPF_CALL_2(bpf_xdp_adjust_head, struct xdp_buff *, xdp, int, offset)
> +{
> + /* Both mlx4 and mlx5 driver align each packet to PAGE_SIZE when
> + * XDP prog is set.
> + * If the above is not true for the other drivers to support
> + * bpf_xdp_adjust_head, struct xdp_buff can be extended.
> + */
> + unsigned long addr = (unsigned long)xdp->data & PAGE_MASK;
> + void *data_hard_start = (void *)addr;
> + void *data = xdp->data + offset;
> +
> + if (unlikely(data < data_hard_start || data > xdp->data_end - ETH_HLEN))
> + return -EINVAL;
> +
> + xdp->data = data;
> +
> + return 0;
> +}
Thanks for adjusting this, I like Daniel's suggestion.
For this patch:
Acked-by: Jesper Dangaard Brouer <brouer@redhat.com>
As it still looks like 3/4 need some adjustments based on Saeed's
comments.
--
Best regards,
Jesper Dangaard Brouer
MSc.CS, Principal Kernel Engineer at Red Hat
LinkedIn: http://www.linkedin.com/in/brouer
next prev parent reply other threads:[~2016-12-05 7:35 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-04 3:17 [PATCH v2 net-next 0/4]: Allow head adjustment in XDP prog Martin KaFai Lau
2016-12-04 3:17 ` [PATCH v2 net-next 1/4] bpf: xdp: " Martin KaFai Lau
2016-12-04 15:11 ` Daniel Borkmann
2016-12-05 7:35 ` Jesper Dangaard Brouer [this message]
2016-12-06 17:35 ` John Fastabend
2016-12-06 18:52 ` Martin KaFai Lau
2016-12-04 3:17 ` [PATCH v2 net-next 2/4] mlx4: xdp: Allow raising MTU up to one page minus eth and vlan hdrs Martin KaFai Lau
2016-12-04 3:17 ` [PATCH v2 net-next 3/4] mlx4: xdp: Reserve headroom for receiving packet when XDP prog is active Martin KaFai Lau
2016-12-05 0:54 ` Saeed Mahameed
2016-12-05 19:55 ` Martin KaFai Lau
2016-12-06 16:50 ` Saeed Mahameed
2016-12-06 17:42 ` John Fastabend
2016-12-06 18:27 ` Martin KaFai Lau
2016-12-06 21:40 ` Saeed Mahameed
2016-12-06 22:25 ` Martin KaFai Lau
2016-12-04 3:17 ` [PATCH v2 net-next 4/4] bpf: xdp: Add XDP example for head adjustment Martin KaFai Lau
2016-12-05 17:53 ` [PATCH v2 net-next 0/4]: Allow head adjustment in XDP prog Jakub Kicinski
2016-12-05 18:25 ` Jesper Dangaard Brouer
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=20161205083533.1467e329@redhat.com \
--to=brouer@redhat.com \
--cc=ast@fb.com \
--cc=bblanco@plumgrid.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=kafai@fb.com \
--cc=kernel-team@fb.com \
--cc=netdev@vger.kernel.org \
--cc=saeedm@mellanox.com \
--cc=tariqt@mellanox.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.