[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1491719118.4309.1.camel@sipsolutions.net>
Date: Sun, 09 Apr 2017 08:25:18 +0200
From: Johannes Berg <johannes@...solutions.net>
To: David Miller <davem@...emloft.net>, netdev@...r.kernel.org
Cc: xdp-newbies@...r.kernel.org
Subject: Re: [PATCH net-next RFC] Generic XDP
On Sat, 2017-04-08 at 20:07 -0700, David Miller wrote:
> +static int generic_xdp_install(struct net_device *dev, struct
> netdev_xdp *xdp)
> +{
> + struct bpf_prog *new = xdp->prog;
> + int ret = 0;
> +
> + switch (xdp->command) {
> + case XDP_SETUP_PROG: {
> + struct bpf_prog *old;
> +
> + old = xchg(&dev->xdp_prog, new);
> + if (old)
> + bpf_prog_put(old);
I don't really see why you need the xchg() here - just fetching the old
program and setting the new one should be sufficient since you're under
RTNL here.
That would also let you use rcu_assign_pointer() which seems like the
right thing to do here, along with marking the xdp_prog pointer as
__rcu? That'd also let you use rcu_dereference() instead of READ_ONCE()
which seems like the better annotation?
johannes
Powered by blists - more mailing lists