From: John Fastabend <john.fastabend@gmail.com>
To: Alexei Starovoitov <ast@plumgrid.com>,
"David S. Miller" <davem@davemloft.net>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>,
Daniel Borkmann <daniel@iogearbox.net>,
netdev@vger.kernel.org
Subject: Re: [PATCH net-next 2/2] bpf: add bpf_redirect() helper
Date: Tue, 15 Sep 2015 21:50:27 -0700 [thread overview]
Message-ID: <55F8F513.10803@gmail.com> (raw)
In-Reply-To: <55F8EBFB.2080009@plumgrid.com>
On 15-09-15 09:11 PM, Alexei Starovoitov wrote:
> On 9/15/15 8:10 PM, John Fastabend wrote:
>> Nice, I like this. But just to be sure I read this correctly this will
>> only work on the ingress qdisc for now right? To get the tx side working
>> will require a bit more care.
>
> correct.
> For egress I'm waiting for Daniel to resubmit his preclassifier patch
> and I'll hook this skb_do_redirect() there as well.
> Other options are also possible, but preclassifier looks the best for
> this purpose, since it's lockless.
>
Great, works for me. One other question/observation,
+int skb_do_redirect(struct sk_buff *skb)
+{
[...]
+
+ if (unlikely(!(dev->flags & IFF_UP))) {
+ kfree_skb(skb);
+ return -EINVAL;
+ }
The IFF_UP check is not needed as best I can tell, the dev_queue_xmit()
will check if the qdisc is active and the dev_forward_skb() path will
do a !netif_running check in enqueue_to_backlog() call.
Looks like you can remove the check. I would prefer to let the stack
handle this case using normal mechanisms.
I had to do a bit of tracking but netif_running check equates roughly
to your IFF_UP case via,
> __dev_change_flags()
> [...]
> if ((old_flags ^ flags) & IFF_UP)
> ret = ((old_flags & IFF_UP) ? __dev_close : __dev_open)(dev);
>
>
> __dev_close()
> [...]
> __dev_close_many()
>
> __dev_close_many()
> [...]
> clear_bit(__LINK_STATE_START, &dev->state);
Seem reasonable? Or did you put it there to work around some specific
case I'm missing?
.John
next prev parent reply other threads:[~2015-09-16 4:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-16 1:51 [PATCH net-next 0/2] bpf: performance improvements Alexei Starovoitov
2015-09-16 1:51 ` [PATCH net-next 1/2] cls_bpf: introduce integrated actions Alexei Starovoitov
2015-09-16 1:51 ` [PATCH net-next 2/2] bpf: add bpf_redirect() helper Alexei Starovoitov
2015-09-16 3:10 ` John Fastabend
2015-09-16 4:11 ` Alexei Starovoitov
2015-09-16 4:50 ` John Fastabend [this message]
2015-09-16 5:08 ` Alexei Starovoitov
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=55F8F513.10803@gmail.com \
--to=john.fastabend@gmail.com \
--cc=ast@plumgrid.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=jhs@mojatatu.com \
--cc=netdev@vger.kernel.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.