public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: "Nikita V. Shirokov" <tehnerd@tehnerd.com>
Cc: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	netdev@vger.kernel.org
Subject: Re: [PATCH bpf-next 01/10] [bpf]: adding bpf_xdp_adjust_tail helper
Date: Tue, 17 Apr 2018 15:58:22 -0700	[thread overview]
Message-ID: <20180417225820.54sbtmynk7d4dxwa@ast-mbp> (raw)
In-Reply-To: <20180417065131.3632-2-tehnerd@tehnerd.com>

On Mon, Apr 16, 2018 at 11:51:22PM -0700, Nikita V. Shirokov wrote:
> Adding new bpf helper which would allow us to manipulate
> xdp's data_end pointer, and allow us to reduce packet's size
> indended use case: to generate ICMP messages from XDP context,
> where such message would contain truncated original packet.
> 
> Signed-off-by: Nikita V. Shirokov <tehnerd@tehnerd.com>
> ---
>  include/uapi/linux/bpf.h | 10 +++++++++-
>  net/core/filter.c        | 29 ++++++++++++++++++++++++++++-
>  2 files changed, 37 insertions(+), 2 deletions(-)
> 
> diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
> index c5ec89732a8d..9a2d1a04eb24 100644
> --- a/include/uapi/linux/bpf.h
> +++ b/include/uapi/linux/bpf.h
> @@ -755,6 +755,13 @@ union bpf_attr {
>   *     @addr: pointer to struct sockaddr to bind socket to
>   *     @addr_len: length of sockaddr structure
>   *     Return: 0 on success or negative error code
> + *
> + * int bpf_xdp_adjust_tail(xdp_md, delta)
> + *     Adjust the xdp_md.data_end by delta. Only shrinking of packet's
> + *     size is supported.
> + *     @xdp_md: pointer to xdp_md
> + *     @delta: A negative integer to be added to xdp_md.data_end
> + *     Return: 0 on success or negative on error
>   */
>  #define __BPF_FUNC_MAPPER(FN)		\
>  	FN(unspec),			\
> @@ -821,7 +828,8 @@ union bpf_attr {
>  	FN(msg_apply_bytes),		\
>  	FN(msg_cork_bytes),		\
>  	FN(msg_pull_data),		\
> -	FN(bind),
> +	FN(bind),			\
> +	FN(xdp_adjust_tail),
>  
>  /* integer value in 'imm' field of BPF_CALL instruction selects which helper
>   * function eBPF program intends to call
> diff --git a/net/core/filter.c b/net/core/filter.c
> index d31aff93270d..6c8ac7b548d6 100644
> --- a/net/core/filter.c
> +++ b/net/core/filter.c
> @@ -2717,6 +2717,30 @@ static const struct bpf_func_proto bpf_xdp_adjust_head_proto = {
>  	.arg2_type	= ARG_ANYTHING,
>  };
>  
> +BPF_CALL_2(bpf_xdp_adjust_tail, struct xdp_buff *, xdp, int, offset)
> +{
> +	/* only shrinking is allowed for now. */
> +	if (unlikely(offset > 0))
> +		return -EINVAL;

why allow offset == 0 ?
It's a nop. xdp_adjust_head allows it, but it's not a reason
to repeat the same here.
Like we may decide to do something with offset==0 in the future.
Let's keep it reserved.

In the subject please replace
[bpf]: adding bpf_xdp_adjust_tail helper
with
bpf: adding bpf_xdp_adjust_tail helper

"[bpf] foo bar" subject used to be llvm patch convention,
but lately we switched it to kernel style as well with "bpf: foo bar"

  parent reply	other threads:[~2018-04-17 22:58 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-17  6:51 [PATCH bpf-next 00/10] introduction of bpf_xdp_adjust_tail Nikita V. Shirokov
2018-04-17  6:51 ` [PATCH bpf-next 01/10] [bpf]: adding bpf_xdp_adjust_tail helper Nikita V. Shirokov
2018-04-17 14:14   ` kbuild test robot
2018-04-17 22:58   ` Alexei Starovoitov [this message]
2018-04-17  6:51 ` [PATCH bpf-next 02/10] [bpf]: adding tests for bpf_xdp_adjust_tail Nikita V. Shirokov
2018-04-17 23:04   ` Alexei Starovoitov
2018-04-17  6:51 ` [PATCH bpf-next 03/10] [bpf]: add bpf_xdp_adjust_tail sample prog Nikita V. Shirokov
2018-04-17  6:51 ` [PATCH bpf-next 04/10] [bpf]: make generic xdp compatible w/ bpf_xdp_adjust_tail Nikita V. Shirokov
2018-04-17 23:06   ` Alexei Starovoitov
2018-04-17  6:51 ` [PATCH bpf-next 05/10] [bpf]: make mlx4 " Nikita V. Shirokov
2018-04-17 23:06   ` Alexei Starovoitov
2018-04-17  6:51 ` [PATCH bpf-next 06/10] [bpf]: make bnxt " Nikita V. Shirokov
2018-04-17 23:07   ` Alexei Starovoitov
2018-04-17  6:51 ` [PATCH bpf-next 07/10] [bpf]: make cavium thunder " Nikita V. Shirokov
2018-04-17 23:07   ` Alexei Starovoitov
2018-04-17  6:51 ` [PATCH bpf-next 08/10] [bpf]: make netronome nfp " Nikita V. Shirokov
2018-04-17 23:08   ` Alexei Starovoitov
2018-04-18  0:40     ` Jakub Kicinski
2018-04-17  6:51 ` [PATCH bpf-next 09/10] [bpf]: make tun " Nikita V. Shirokov
2018-04-18  2:16   ` Jason Wang
2018-04-17  6:51 ` [PATCH bpf-next 10/10] [bpf]: make virtio " Nikita V. Shirokov
2018-04-18  2:16   ` Jason Wang

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=20180417225820.54sbtmynk7d4dxwa@ast-mbp \
    --to=alexei.starovoitov@gmail.com \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=netdev@vger.kernel.org \
    --cc=tehnerd@tehnerd.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