public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Alexei Starovoitov <alexei.starovoitov@gmail•com>
To: David Ahern <dsa@cumulusnetworks•com>
Cc: netdev@vger•kernel.org, daniel@zonque•org, ast@fb•com,
	daniel@iogearbox•net, maheshb@google•com, tgraf@suug•ch
Subject: Re: [PATCH net-next v3 1/3] bpf: Refactor cgroups code in prep for new type
Date: Mon, 28 Nov 2016 12:06:43 -0800	[thread overview]
Message-ID: <20161128200641.GA7634@ast-mbp.thefacebook.com> (raw)
In-Reply-To: <1480348130-31354-2-git-send-email-dsa@cumulusnetworks.com>

On Mon, Nov 28, 2016 at 07:48:48AM -0800, David Ahern wrote:
> Code move only; no functional change intended.

not quite...

> Signed-off-by: David Ahern <dsa@cumulusnetworks•com>
...
>   * @sk: The socken sending or receiving traffic
> @@ -153,11 +166,15 @@ int __cgroup_bpf_run_filter(struct sock *sk,
>  
>  	prog = rcu_dereference(cgrp->bpf.effective[type]);
>  	if (prog) {
> -		unsigned int offset = skb->data - skb_network_header(skb);
> -
> -		__skb_push(skb, offset);
> -		ret = bpf_prog_run_save_cb(prog, skb) == 1 ? 0 : -EPERM;
> -		__skb_pull(skb, offset);
> +		switch (type) {
> +		case BPF_CGROUP_INET_INGRESS:
> +		case BPF_CGROUP_INET_EGRESS:
> +			ret = __cgroup_bpf_run_filter_skb(skb, prog);
> +			break;

hmm. what's a point of double jump table? It's only burning cycles
in the fast path. We already have
prog = rcu_dereference(cgrp->bpf.effective[type]); if (prog) {...}
Could you do a variant of __cgroup_bpf_run_filter() instead ?
That doesnt't take 'skb' as an argument.
It will also solve scary looking NULL skb from patch 2:
__cgroup_bpf_run_filter(sk, NULL, ...

and to avoid copy-pasting first dozen lines of current
__cgroup_bpf_run_filter can be moved into a helper that
__cgroup_bpf_run_filter_skb and
__cgroup_bpf_run_filter_sk will call.
Or some other way to rearrange that code.

  reply	other threads:[~2016-11-28 20:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-28 15:48 [PATCH net-next v3 0/3] net: Add bpf support to set sk_bound_dev_if David Ahern
2016-11-28 15:48 ` [PATCH net-next v3 1/3] bpf: Refactor cgroups code in prep for new type David Ahern
2016-11-28 20:06   ` Alexei Starovoitov [this message]
2016-11-28 20:31     ` David Ahern
2016-11-28 15:48 ` [PATCH net-next v3 2/3] bpf: Add new cgroup attach type to enable sock modifications David Ahern
2016-11-28 20:32   ` Alexei Starovoitov
2016-11-28 20:57     ` David Ahern
2016-11-28 15:48 ` [PATCH net-next v3 3/3] samples: bpf: add userspace example for modifying sk_bound_dev_if David Ahern
2016-11-28 20:37   ` Alexei Starovoitov
2016-11-28 20:47     ` David Ahern

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=20161128200641.GA7634@ast-mbp.thefacebook.com \
    --to=alexei.starovoitov@gmail$(echo .)com \
    --cc=ast@fb$(echo .)com \
    --cc=daniel@iogearbox$(echo .)net \
    --cc=daniel@zonque$(echo .)org \
    --cc=dsa@cumulusnetworks$(echo .)com \
    --cc=maheshb@google$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=tgraf@suug$(echo .)ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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