From: Hannes Frederic Sowa <hannes@redhat.com>
To: Jiri Pirko <jiri@resnulli.us>
Cc: netdev@vger.kernel.org, davem@davemloft.net, jhs@mojatatu.com,
stephen@networkplumber.org
Subject: Re: [patch net-next] tc: add BPF based action
Date: Thu, 08 Jan 2015 15:55:37 +0100 [thread overview]
Message-ID: <1420728937.5928.8.camel@redhat.com> (raw)
In-Reply-To: <1420649035-9522-1-git-send-email-jiri@resnulli.us>
On Mi, 2015-01-07 at 17:43 +0100, Jiri Pirko wrote:
> +static int tcf_bpf(struct sk_buff *skb, const struct tc_action *a,
> + struct tcf_result *res)
> +{
> + struct tcf_bpf *b = a->priv;
> + int action;
> + int filter_res;
> +
> + spin_lock(&b->tcf_lock);
> + b->tcf_tm.lastuse = jiffies;
> + bstats_update(&b->tcf_bstats, skb);
> + action = b->tcf_action;
> +
> + filter_res = BPF_PROG_RUN(b->filter, skb);
> + if (filter_res == -1)
> + goto drop;
> +
> + goto unlock;
> +
> +drop:
> + action = TC_ACT_SHOT;
> + b->tcf_qstats.drops++;
> +unlock:
> + spin_unlock(&b->tcf_lock);
> + return action;
> +}
In theory this could be like:
filter_res = BPF_PROG_RUN(b->filter, skb);
spin_lock(&b->tcf_lock);
<update stats...>
if (filter_res == -1)
goto drop;
action = b->tcf_action;
...
to keep BPF_PROG_RUN out of the spin_lock?
Bye,
Hannes
next prev parent reply other threads:[~2015-01-08 14:55 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-07 16:43 [patch net-next] tc: add BPF based action Jiri Pirko
2015-01-07 16:47 ` [patch iproute2 1/2] tc: push bpf common code into separate file Jiri Pirko
2015-01-07 16:47 ` [patch iproute2 2/2] tc: add support for BPF based actions Jiri Pirko
2015-01-07 18:50 ` Cong Wang
2015-01-07 19:52 ` Jiri Pirko
2015-01-07 19:58 ` Cong Wang
2015-01-14 1:19 ` Stephen Hemminger
2015-01-14 9:19 ` Jiri Pirko
2015-01-07 18:33 ` [patch net-next] tc: add BPF based action Daniel Borkmann
2015-01-07 18:46 ` Cong Wang
2015-01-08 7:26 ` Jiri Pirko
2015-01-08 14:55 ` Hannes Frederic Sowa [this message]
2015-01-08 15:01 ` Jiri Pirko
-- strict thread matches above, loose matches on Subject: below --
2015-01-08 19:04 Alexei Starovoitov
2015-01-12 10:52 ` Jiri Pirko
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=1420728937.5928.8.camel@redhat.com \
--to=hannes@redhat.com \
--cc=davem@davemloft.net \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.org \
/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.