From: Hannes Frederic Sowa <hannes@stressinduktion.org>
To: Cong Wang <xiyou.wangcong@gmail.com>
Cc: netdev@vger.kernel.org,
Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>,
"David S. Miller" <davem@davemloft.net>
Subject: Re: [Patch net-next 3/5] ipv6: clean up ipv6_dev_ac_inc()
Date: Wed, 10 Sep 2014 14:23:35 +0200 [thread overview]
Message-ID: <1410351815.3135.14.camel@localhost> (raw)
In-Reply-To: <1410306738-18036-4-git-send-email-xiyou.wangcong@gmail.com>
On Di, 2014-09-09 at 16:52 -0700, Cong Wang wrote:
> Make it accept inet6_dev, and rename it to __ipv6_dev_ac_inc()
> to reflect this change.
>
> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
> ---
> include/net/addrconf.h | 2 +-
> net/ipv6/addrconf.c | 2 +-
> net/ipv6/anycast.c | 17 +++++------------
> 3 files changed, 7 insertions(+), 14 deletions(-)
>
> diff --git a/include/net/addrconf.h b/include/net/addrconf.h
> index f679877..9b1d42e 100644
> --- a/include/net/addrconf.h
> +++ b/include/net/addrconf.h
> @@ -202,7 +202,7 @@ int ipv6_sock_ac_drop(struct sock *sk, int ifindex,
> const struct in6_addr *addr);
> void ipv6_sock_ac_close(struct sock *sk);
>
> -int ipv6_dev_ac_inc(struct net_device *dev, const struct in6_addr *addr);
> +int __ipv6_dev_ac_inc(struct inet6_dev *idev, const struct in6_addr *addr);
> int __ipv6_dev_ac_dec(struct inet6_dev *idev, const struct in6_addr *addr);
> bool ipv6_chk_acast_addr(struct net *net, struct net_device *dev,
> const struct in6_addr *addr);
> diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
> index ad4598f..6b6a373 100644
> --- a/net/ipv6/addrconf.c
> +++ b/net/ipv6/addrconf.c
> @@ -1725,7 +1725,7 @@ static void addrconf_join_anycast(struct inet6_ifaddr *ifp)
> ipv6_addr_prefix(&addr, &ifp->addr, ifp->prefix_len);
> if (ipv6_addr_any(&addr))
> return;
> - ipv6_dev_ac_inc(ifp->idev->dev, &addr);
> + __ipv6_dev_ac_inc(ifp->idev, &addr);
> }
>
> /* caller must hold RTNL */
> diff --git a/net/ipv6/anycast.c b/net/ipv6/anycast.c
> index d10f2e2..bec8d14 100644
> --- a/net/ipv6/anycast.c
> +++ b/net/ipv6/anycast.c
> @@ -122,7 +122,7 @@ int ipv6_sock_ac_join(struct sock *sk, int ifindex, const struct in6_addr *addr)
> goto error;
> }
>
> - err = ipv6_dev_ac_inc(dev, addr);
> + err = __ipv6_dev_ac_inc(idev, addr);
> if (!err) {
> pac->acl_next = np->ipv6_ac_list;
> np->ipv6_ac_list = pac;
> @@ -215,20 +215,15 @@ static void aca_put(struct ifacaddr6 *ac)
> /*
> * device anycast group inc (add if not found)
> */
> -int ipv6_dev_ac_inc(struct net_device *dev, const struct in6_addr *addr)
> +int __ipv6_dev_ac_inc(struct inet6_dev *idev, const struct in6_addr *addr)
> {
> struct ifacaddr6 *aca;
> - struct inet6_dev *idev;
> struct rt6_info *rt;
> int err;
>
> ASSERT_RTNL();
>
> - idev = in6_dev_get(dev);
> -
> - if (idev == NULL)
> - return -EINVAL;
> -
> + in6_dev_hold(idev);
Please move this in6_dev_hold down to where it gets attached to the
ifacaddr6 and remove the in6_dev_put from below the out: label.
> write_lock_bh(&idev->lock);
> if (idev->dead) {
> err = -ENODEV;
> @@ -267,7 +262,7 @@ int ipv6_dev_ac_inc(struct net_device *dev, const struct in6_addr *addr)
> aca->aca_users = 1;
> /* aca_tstamp should be updated upon changes */
> aca->aca_cstamp = aca->aca_tstamp = jiffies;
> - atomic_set(&aca->aca_refcnt, 2);
> + atomic_set(&aca->aca_refcnt, 1);
> spin_lock_init(&aca->aca_lock);
>
> aca->aca_next = idev->ac_list;
> @@ -276,9 +271,7 @@ int ipv6_dev_ac_inc(struct net_device *dev, const struct in6_addr *addr)
>
> ip6_ins_rt(rt);
>
> - addrconf_join_solict(dev, &aca->aca_addr);
> -
> - aca_put(aca);
I am not sure why you changed the aca_refcnt code. idev->ac_list is only
protected by idev->lock and you publish one reference and unlock, thus
you need a second reference during addrconf_join_solict. All accesses
should also be protected by rtnl, so it shouldn't be a problem, but if
people review the code they might have problems to figure that out.
Maybe you can also remove the idev->lock?
> + addrconf_join_solict(idev->dev, &aca->aca_addr);
> return 0;
> out:
> write_unlock_bh(&idev->lock);
Thanks,
Hannes
next prev parent reply other threads:[~2014-09-10 12:23 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-09 23:52 [Patch net-next 0/5] ipv6: clean up locking in anycast and mcast Cong Wang
2014-09-09 23:52 ` [Patch net-next 1/5] ipv6: drop useless rcu_read_lock() in anycast Cong Wang
2014-09-09 23:52 ` [Patch net-next 2/5] ipv6: remove ipv6_sk_ac_lock Cong Wang
2014-09-09 23:52 ` [Patch net-next 3/5] ipv6: clean up ipv6_dev_ac_inc() Cong Wang
2014-09-10 12:23 ` Hannes Frederic Sowa [this message]
2014-09-10 21:32 ` Cong Wang
2014-09-09 23:52 ` [Patch net-next 4/5] ipv6: drop ipv6_sk_mc_lock in mcast Cong Wang
2014-09-10 17:16 ` Sabrina Dubroca
2014-09-10 22:36 ` Cong Wang
2014-09-09 23:52 ` [Patch net-next 5/5] ipv6: drop some rcu_read_lock " Cong Wang
2014-09-10 20:01 ` [Patch net-next 0/5] ipv6: clean up locking in anycast and mcast David Miller
2014-09-10 23:54 ` Cong Wang
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=1410351815.3135.14.camel@localhost \
--to=hannes@stressinduktion.org \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=xiyou.wangcong@gmail.com \
--cc=yoshfuji@linux-ipv6.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.