Netdev List
 help / color / mirror / Atom feed
From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: Petar Penkov <peterpenkov96@gmail.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net, ast@kernel.org,
	daniel@iogearbox.net, simon.horman@netronome.com,
	ecree@solarflare.com, songliubraving@fb.com, tom@herbertland.com,
	Petar Penkov <ppenkov@google.com>,
	Willem de Bruijn <willemb@google.com>
Subject: Re: [bpf-next, v3 1/5] flow_dissector: implements flow dissector BPF hook
Date: Thu, 13 Sep 2018 12:43:37 -0700	[thread overview]
Message-ID: <20180913194335.fszwj4jj4yputxlv@ast-mbp> (raw)
In-Reply-To: <20180913174557.188828-2-peterpenkov96@gmail.com>

On Thu, Sep 13, 2018 at 10:45:53AM -0700, Petar Penkov wrote:
> From: Petar Penkov <ppenkov@google.com>
> 
> Adds a hook for programs of type BPF_PROG_TYPE_FLOW_DISSECTOR and
> attach type BPF_FLOW_DISSECTOR that is executed in the flow dissector
> path. The BPF program is per-network namespace.
> 
> Signed-off-by: Petar Penkov <ppenkov@google.com>
> Signed-off-by: Willem de Bruijn <willemb@google.com>
...
> @@ -2333,6 +2335,7 @@ struct __sk_buff {
>  	/* ... here. */
>  
>  	__u32 data_meta;
> +	struct bpf_flow_keys *flow_keys;

the bpf prog form patch 4 looks much better now. Thanks!

>  };
>  
>  struct bpf_tunnel_key {
> @@ -2778,4 +2781,27 @@ enum bpf_task_fd_type {
>  	BPF_FD_TYPE_URETPROBE,		/* filename + offset */
>  };
>  
> +struct bpf_flow_keys {
> +	__u16	nhoff;
> +	__u16	thoff;
> +	__u16	addr_proto;			/* ETH_P_* of valid addrs */
> +	__u8	is_frag;
> +	__u8	is_first_frag;
> +	__u8	is_encap;
> +	__be16	n_proto;
> +	__u8	ip_proto;
> +	union {
> +		struct {
> +			__be32	ipv4_src;
> +			__be32	ipv4_dst;
> +		};
> +		struct {
> +			__u32	ipv6_src[4];	/* in6_addr; network order */
> +			__u32	ipv6_dst[4];	/* in6_addr; network order */
> +		};
> +	};
> +	__be16	sport;
> +	__be16	dport;
> +};

can you please pack it?
struct bpf_flow_keys {
	__u16                      nhoff;                /*     0     2 */
	__u16                      thoff;                /*     2     2 */
	__u16                      addr_proto;           /*     4     2 */
	__u8                       is_frag;              /*     6     1 */
	__u8                       is_first_frag;        /*     7     1 */
	__u8                       is_encap;             /*     8     1 */

	/* XXX 1 byte hole, try to pack */

	__be16                     n_proto;              /*    10     2 */
	__u8                       ip_proto;             /*    12     1 */

	/* XXX 3 bytes hole, try to pack */

	union {

also is_frag and other fields are not used by the kernel and
only used by the prog to pass data between tail_calls ?
In such case reserve some space in bpf_flow_keys similar to skb->cb
so it can contain any fields and accommodate for inevitable changes
to bpf flow dissector prog in the future.

  reply	other threads:[~2018-09-14  0:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-13 17:45 [bpf-next, v3 0/5] Introduce eBPF flow dissector Petar Penkov
2018-09-13 17:45 ` [bpf-next, v3 1/5] flow_dissector: implements flow dissector BPF hook Petar Penkov
2018-09-13 19:43   ` Alexei Starovoitov [this message]
2018-09-13 20:51     ` Willem de Bruijn
2018-09-13 20:57       ` Alexei Starovoitov
2018-09-13 21:00         ` Willem de Bruijn
2018-09-13 17:45 ` [bpf-next, v3 2/5] bpf: sync bpf.h uapi with tools/ Petar Penkov
2018-09-13 17:45 ` [bpf-next, v3 3/5] bpf: support flow dissector in libbpf and bpftool Petar Penkov
2018-09-13 17:45 ` [bpf-next, v3 4/5] flow_dissector: implements eBPF parser Petar Penkov
2018-09-13 17:45 ` [bpf-next, v3 5/5] selftests/bpf: test bpf flow dissection Petar Penkov

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=20180913194335.fszwj4jj4yputxlv@ast-mbp \
    --to=alexei.starovoitov@gmail.com \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=ecree@solarflare.com \
    --cc=netdev@vger.kernel.org \
    --cc=peterpenkov96@gmail.com \
    --cc=ppenkov@google.com \
    --cc=simon.horman@netronome.com \
    --cc=songliubraving@fb.com \
    --cc=tom@herbertland.com \
    --cc=willemb@google.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