netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Brenden Blanco <bblanco@plumgrid.com>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org, jhs@mojatatu.com,
	saeedm@dev.mellanox.co.il, kafai@fb.com, brouer@redhat.com,
	as754m@att.com, alexei.starovoitov@gmail.com,
	gerlitz.or@gmail.com, john.fastabend@gmail.com,
	hannes@stressinduktion.org, tgraf@suug.ch, tom@herbertland.com,
	daniel@iogearbox.net
Subject: Re: [PATCH v7 02/11] net: add ndo to setup/query xdp prog in adapter rx
Date: Mon, 11 Jul 2016 23:35:00 -0700	[thread overview]
Message-ID: <20160712063457.GB20499@gmail.com> (raw)
In-Reply-To: <20160711.231224.1254700854465723599.davem@davemloft.net>

On Mon, Jul 11, 2016 at 11:12:24PM -0700, David Miller wrote:
> From: Brenden Blanco <bblanco@plumgrid.com>
> Date: Mon, 11 Jul 2016 14:29:49 -0700
> 
> > +	if (fd >= 0) {
> > +		prog = bpf_prog_get_type(fd, BPF_PROG_TYPE_XDP);
> > +		if (IS_ERR(prog))
> > +			return PTR_ERR(prog);
> > +	}
> > +
> > +	xdp.command = XDP_SETUP_PROG;
> > +	xdp.prog = prog;
> > +	err = ops->ndo_xdp(dev, &xdp);
> > +	if (err < 0 && prog)
> > +		bpf_prog_put(prog);
> 
> I don't understand the reference counting on 'prog' here.
> 
> The enumeration documentation states that no matter what, the passed
> in prog doesn't need to be mangaged by the ->ndo_xdp() method.
> 
> Therefore, if that is true, we must always put the 'prog' here if it
> is non-NULL.  Regardless of the 'err' value.
> 
The documentation is unclear then. What I _meant_ to say is that the callee
is not responsible for putting the program on error, but on success it
takes ownership of the reference. In context of that, does the code make
sense? Is there a more conventional way of handling this?

Thanks for your review.

  reply	other threads:[~2016-07-12  6:35 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-11 21:29 [PATCH v7 00/11] Add driver bpf hook for early packet drop and forwarding Brenden Blanco
2016-07-11 21:29 ` [PATCH v7 01/11] bpf: add XDP prog type for early driver filter Brenden Blanco
2016-07-12  6:02   ` David Miller
2016-07-12  6:26     ` Brenden Blanco
2016-07-11 21:29 ` [PATCH v7 02/11] net: add ndo to setup/query xdp prog in adapter rx Brenden Blanco
2016-07-12  6:12   ` David Miller
2016-07-12  6:35     ` Brenden Blanco [this message]
2016-07-12  6:45       ` David Miller
2016-07-11 21:29 ` [PATCH v7 03/11] rtnl: add option for setting link xdp prog Brenden Blanco
2016-07-11 21:29 ` [PATCH v7 04/11] net/mlx4_en: add support for fast rx drop bpf program Brenden Blanco
2016-07-12  6:17   ` David Miller
2016-07-12 16:31     ` Brenden Blanco
2016-07-11 21:29 ` [PATCH v7 05/11] Add sample for adding simple drop program to link Brenden Blanco
2016-07-11 21:29 ` [PATCH v7 06/11] net/mlx4_en: add page recycle to prepare rx ring for tx support Brenden Blanco
2016-07-11 21:29 ` [PATCH v7 07/11] bpf: add XDP_TX xdp_action for direct forwarding Brenden Blanco
2016-07-11 21:29 ` [PATCH v7 08/11] net/mlx4_en: break out tx_desc write into separate function Brenden Blanco
2016-07-11 21:29 ` [PATCH v7 09/11] net/mlx4_en: add xdp forwarding and data write support Brenden Blanco
2016-07-13 15:25   ` Saeed Mahameed
2016-07-13 17:30     ` Brenden Blanco
2016-07-13 19:16       ` Saeed Mahameed
2016-07-11 21:29 ` [PATCH v7 10/11] bpf: enable direct packet data write for xdp progs Brenden Blanco
2016-07-11 21:29 ` [PATCH v7 11/11] bpf: add sample for xdp forwarding and rewrite Brenden Blanco
2016-07-11 21:53 ` [PATCH v7 00/11] Add driver bpf hook for early packet drop and forwarding Or Gerlitz
2016-07-11 22:06   ` Brenden Blanco
2016-07-11 23:26   ` Tom Herbert

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=20160712063457.GB20499@gmail.com \
    --to=bblanco@plumgrid.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=as754m@att.com \
    --cc=brouer@redhat.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=gerlitz.or@gmail.com \
    --cc=hannes@stressinduktion.org \
    --cc=jhs@mojatatu.com \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=netdev@vger.kernel.org \
    --cc=saeedm@dev.mellanox.co.il \
    --cc=tgraf@suug.ch \
    --cc=tom@herbertland.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;
as well as URLs for NNTP newsgroup(s).