All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kubakici@wp.pl>
To: Jiri Pirko <jiri@resnulli.us>
Cc: Linux Netdev List <netdev@vger.kernel.org>,
	oss-drivers@netronome.com, Daniel Borkmann <daniel@iogearbox.net>,
	Alexei Starovoitov <alexei.starovoitov@gmail.com>
Subject: Re: [RFC net-next 0/6] xdp: make stack perform remove and tests
Date: Fri, 24 Nov 2017 20:55:05 -0800	[thread overview]
Message-ID: <20171124205505.2d3a11a8@cakuba.netronome.com> (raw)
In-Reply-To: <CAJpBn1xz6oBh+P9PdzvZtDtq7uYd+vzHJBXHWRzPxf5-z5qRog@mail.gmail.com>

On Fri, 24 Nov 2017 00:02:32 -0800, Jakub Kicinski wrote:
> >>Something I'm still battling with, and would appreciate help of
> >>wiser people is that occasionally during the test something makes
> >>the refcount of init_net drop to 0 :S  I tried to create a simple
> >>reproducer, but seems like just running the script in the loop is
> >>the easiest way to go...  Could it have something to do with the
> >>recent TC work?  The driver is pretty simple and never touches  
> >
> > I don't see how...  
> 
> To be clear I meant the changes made to destruction of filters, not
> your work. The BPF code doesn't touch ref counts and cls exts do seem
> to hold a ref on the net...  but perhaps that's just pointing the
> finger unnecessarily :)  I will try to investigate again tomorrow.

Looks like I was lazy when adding the offload and just called
__cls_bpf_delete_prog() instead of extending the error path.  
Cong missed this extra call in aae2c35ec892 ("cls_bpf: use
tcf_exts_get_net() before call_rcu()").  We need something like 
this:

diff --git a/net/sched/cls_bpf.c b/net/sched/cls_bpf.c
index a9f3e317055c..40d4289aea28 100644
--- a/net/sched/cls_bpf.c
+++ b/net/sched/cls_bpf.c
@@ -514,12 +514,8 @@ static int cls_bpf_change(struct net *net, struct sk_buff *in_skb,
                goto errout_idr;
 
        ret = cls_bpf_offload(tp, prog, oldprog);
-       if (ret) {
-               if (!oldprog)
-                       idr_remove_ext(&head->handle_idr, prog->handle);
-               __cls_bpf_delete_prog(prog);
-               return ret;
-       }
+       if (ret)
+               goto errout_parms;
 
        if (!tc_in_hw(prog->gen_flags))
                prog->gen_flags |= TCA_CLS_FLAGS_NOT_IN_HW;
@@ -537,6 +533,13 @@ static int cls_bpf_change(struct net *net, struct sk_buff *in_skb,
        *arg = prog;
        return 0;
 
+errout_parms:
+       if (cls_bpf_is_ebpf(prog))
+               bpf_prog_put(prog->filter);
+       else
+               bpf_prog_destroy(prog->filter);
+       kfree(prog->bpf_name);
+       kfree(prog->bpf_ops);
 errout_idr:
        if (!oldprog)
                idr_remove_ext(&head->handle_idr, prog->handle);

  reply	other threads:[~2017-11-25  4:55 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-24  2:36 [RFC net-next 0/6] xdp: make stack perform remove and tests Jakub Kicinski
2017-11-24  2:36 ` [RFC net-next 1/6] net: xdp: avoid output parameters when querying XDP prog Jakub Kicinski
2017-11-24  2:36 ` [RFC net-next 2/6] net: xdp: report flags program was installed with on query Jakub Kicinski
2017-11-24  2:36 ` [RFC net-next 3/6] net: xdp: make the stack take care of the tear down Jakub Kicinski
2017-11-24 23:24   ` Daniel Borkmann
2017-11-25  3:28     ` Jakub Kicinski
2017-11-24  2:36 ` [RFC net-next 4/6] netdevsim: add software driver for testing offloads Jakub Kicinski
2017-11-24  7:24   ` Jiri Pirko
2017-11-24  7:49     ` Jakub Kicinski
2017-11-24  8:07       ` Jiri Pirko
2017-11-27 19:30   ` David Miller
2017-11-27 19:42     ` Jakub Kicinski
2017-11-28 14:55       ` Phil Sutter
2017-11-28 16:20       ` Jiri Pirko
2017-11-24  2:36 ` [RFC net-next 5/6] netdevsim: add bpf offload support Jakub Kicinski
2017-11-24  2:36 ` [RFC net-next 6/6] selftests/bpf: add offload test based on netdevsim Jakub Kicinski
2017-11-24  7:45 ` [RFC net-next 0/6] xdp: make stack perform remove and tests Jiri Pirko
2017-11-24  8:02   ` Jakub Kicinski
2017-11-25  4:55     ` Jakub Kicinski [this message]
2017-11-26  1:02 ` Alexei Starovoitov
2017-11-26  1:43   ` Jakub Kicinski
2017-11-26  7:43     ` 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=20171124205505.2d3a11a8@cakuba.netronome.com \
    --to=kubakici@wp.pl \
    --cc=alexei.starovoitov@gmail.com \
    --cc=daniel@iogearbox.net \
    --cc=jiri@resnulli.us \
    --cc=netdev@vger.kernel.org \
    --cc=oss-drivers@netronome.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 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.