netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nikolay Aleksandrov <nikolay@redhat.com>
To: Or Gerlitz <ogerlitz@mellanox.com>,
	"David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org, Roland Dreier <roland@kernel.org>,
	Amir Vadai <amirv@mellanox.com>, Tal Alon <talal@mellanox.com>,
	Moni Shoua <monis@mellanox.com>
Subject: Re: [PATCH net-next 03/10] net/bonding: Notify state change on slaves
Date: Tue, 03 Feb 2015 17:09:27 +0100	[thread overview]
Message-ID: <54D0F2B7.4000005@redhat.com> (raw)
In-Reply-To: <1422974919-28084-4-git-send-email-ogerlitz@mellanox.com>

On 03/02/15 15:48, Or Gerlitz wrote:
> From: Moni Shoua <monis@mellanox.com>
> 
> Use notifier chain to dispatch an event upon a change in slave state.
> Event is dispatched with slave specific info.
> 
> Signed-off-by: Moni Shoua <monis@mellanox.com>
> Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
> ---
>  drivers/net/bonding/bond_main.c |   42 +++++++++++++++++++++++++++++++++++++++
>  include/net/bonding.h           |   12 +++++++++++
>  2 files changed, 54 insertions(+), 0 deletions(-)
> 

Hi Or,
A few questions below,

> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> index 0665608..c9771f3 100644
> --- a/drivers/net/bonding/bond_main.c
> +++ b/drivers/net/bonding/bond_main.c
> @@ -1191,6 +1191,47 @@ static void bond_fill_ifslave(struct slave *slave, struct ifslave *info)
>  	info->link_failure_count = slave->link_failure_count;
>  }
>  
> +static void bond_netdev_notify(struct slave *slave, struct net_device *dev)
> +{
> +	struct bonding *bond = slave->bond;
^^^^^^^^^^^
What if the struct slave where "slave" points to gets freed before this execution ?

> +	struct netdev_bonding_info bonding_info;
> +
> +	rtnl_lock();
> +	/* make sure that slave is still valid */
> +	if (dev->priv_flags & IFF_BONDING) {
^^^^^^^
What if the slave is released, enslaved to a different bond and the old bond is
destroyed between the dereference up there and the rtnl_lock() ?
Or the bonding gets unloaded altogether ?

> +		bond_fill_ifslave(slave, &bonding_info.slave);
> +		bond_fill_ifbond(bond, &bonding_info.master);
> +		netdev_bonding_info_change(slave->dev, &bonding_info);
> +	}
> +	rtnl_unlock();
> +}
> +
> +static void bond_netdev_notify_work(struct work_struct *_work)
> +{
> +	struct netdev_notify_work *w =
> +		container_of(_work, struct netdev_notify_work, work.work);
> +
> +	bond_netdev_notify(w->slave, w->dev);
> +	dev_put(w->dev);
> +}
> +
> +void bond_queue_slave_event(struct slave *slave)
> +{
> +	struct netdev_notify_work *nnw = kzalloc(sizeof(*nnw), GFP_ATOMIC);
^^^^^^^^
Where's this freed after the work's done ?

> +
> +	if (!nnw)
> +		return;
> +
> +	INIT_DELAYED_WORK(&nnw->work, bond_netdev_notify_work);
> +	nnw->slave = slave;
> +	nnw->dev = slave->dev;
> +
> +	if (queue_delayed_work(slave->bond->wq, &nnw->work, 0))
> +		dev_hold(slave->dev);
> +	else
> +		kfree(nnw);
> +}
> +
<snip>

Cheers,
 Nik

  reply	other threads:[~2015-02-03 16:09 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-03 14:48 [PATCH 00/10] Add HA and LAG support to mlx4 RoCE and SRIOV services Or Gerlitz
2015-02-03 14:48 ` [PATCH net-next 01/10] net/core: Add event for a change in slave state Or Gerlitz
2015-02-03 14:48 ` [PATCH net-next 02/10] net/bonding: Move slave state changes to a helper function Or Gerlitz
2015-02-03 14:48 ` [PATCH net-next 03/10] net/bonding: Notify state change on slaves Or Gerlitz
2015-02-03 16:09   ` Nikolay Aleksandrov [this message]
2015-02-03 17:17     ` Moni Shoua
2015-02-03 14:48 ` [PATCH net-next 04/10] net/mlx4_core: Port aggregation low level interface Or Gerlitz
2015-02-03 14:48 ` [PATCH net-next 05/10] net/mlx4_core: Port aggregation upper layer interface Or Gerlitz
2015-02-03 14:48 ` [PATCH net-next 06/10] net/mlx4_en: Port aggregation configuration Or Gerlitz
2015-02-03 14:48 ` [PATCH 07/10] IB/mlx4: reuse mlx4_mac_to_u64() Or Gerlitz
2015-02-03 14:48 ` [PATCH net-next 07/10] IB/mlx4: Reuse mlx4_mac_to_u64() Or Gerlitz
2015-02-03 14:48 ` [PATCH net-next 08/10] IB/mlx4: Add port aggregation support Or Gerlitz
2015-02-03 14:48 ` [PATCH net-next 09/10] IB/mlx4: Create mirror flows in port aggregation mode Or Gerlitz
2015-02-03 14:48 ` [PATCH net-next 10/10] IB/mlx4: Load balance ports " Or Gerlitz
2015-02-03 14:59 ` [PATCH 00/10] Add HA and LAG support to mlx4 RoCE and SRIOV services Or Gerlitz
2015-02-05  0:14 ` David Miller

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=54D0F2B7.4000005@redhat.com \
    --to=nikolay@redhat.com \
    --cc=amirv@mellanox.com \
    --cc=davem@davemloft.net \
    --cc=monis@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=ogerlitz@mellanox.com \
    --cc=roland@kernel.org \
    --cc=talal@mellanox.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).