From: David Miller <davem@davemloft.net>
To: chavey@google.com
Cc: fubar@us.ibm.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: Subject: [PATCH 001/001] bonding: add support for netdev link events.
Date: Mon, 23 Feb 2009 15:47:03 -0800 (PST) [thread overview]
Message-ID: <20090223.154703.114857595.davem@davemloft.net> (raw)
In-Reply-To: <97949e3e0902231201n4781d2c4q261bfc62ba1cb7fc@mail.gmail.com>
From: Laurent Chavey <chavey@google.com>
Date: Mon, 23 Feb 2009 12:01:38 -0800
> From: Laurent Chavey <chavey@google.com>
>
> kernel:2.6.28
>
> Add a netdev link event handler so the bond state machine can react to
> link state changes using async netdev events rather than having to
> use mii monitor polling.
>
> Signed-off-by: Laurent Chavey <chavey@google.com>
Please post networking patches to netdev@vger.kernel.org,
thank you.
> ---
>
>
> --- linux-2.6.28.org/drivers/net/bonding/bond_main.c 2008-12-24
> 15:26:37.000000000 -0800
> +++ linux-2.6.28/drivers/net/bonding/bond_main.c 2009-02-23
> 10:59:12.000000000 -0800
> @@ -2477,7 +2477,11 @@ void bond_mii_monitor(struct work_struct
> }
>
> re_arm:
> - if (bond->params.miimon)
> + /* A netdev event may have set some delay work, in that
> + * case do not remove it and let it take priority.
> + */
> + if (bond->params.miimon && !bond->kill_timers &&
> + !delayed_work_pending(&bond->mii_work))
> queue_delayed_work(bond->wq, &bond->mii_work,
> msecs_to_jiffies(bond->params.miimon));
> out:
> @@ -3521,6 +3525,33 @@ static int bond_master_netdev_event(unsi
> return NOTIFY_DONE;
> }
>
> +static inline void bond_netdev_link_event(struct bonding *bond)
> +{
> + if (!bond->params.use_carrier)
> + return;
> +
> + write_lock_bh(&bond->lock);
> + if (bond->kill_timers) {
> + write_unlock_bh(&bond->lock);
> + return;
> + }
> +
> + if (delayed_work_pending(&bond->mii_work)) {
> + /* cancel_delayed_work(&bond->mii_work); calls del_timer_sync().
> + * We implement a version that does not call del_timer_sync().
> + * if an active timer is found, then the job is not on the WQ.
> + * we clear the PENDING bit, so the job can be added later
> + * else the job maybe done (PENDING bit is clear) or it maybe
> + * running, then we do not care and do only add a new job
> + * if the job has completed.
> + */
> + if (del_timer(&bond->mii_work.timer))
> + work_clear_pending(&bond->mii_work.work);
> + }
> + queue_delayed_work(bond->wq, &bond->mii_work, 0);
> + write_unlock_bh(&bond->lock);
> +}
> +
> static int bond_slave_netdev_event(unsigned long event, struct
> net_device *slave_dev)
> {
> struct net_device *bond_dev = slave_dev->master;
> @@ -3536,15 +3567,17 @@ static int bond_slave_netdev_event(unsig
> }
> break;
> case NETDEV_CHANGE:
> - /*
> - * TODO: is this what we get if somebody
> - * sets up a hierarchical bond, then rmmod's
> - * one of the slave bonding devices?
> - */
> - break;
> + case NETDEV_UP:
> case NETDEV_DOWN:
> + if (bond_dev && bond_dev->priv &&
> + ARPHRD_ETHER == slave_dev->type) {
> + bond_netdev_link_event(bond_dev->priv);
> + }
> +
> /*
> - * ... Or is it this?
> + * TODO: do we get a NETDEV_CHANGE or NETDEV_DOWN event
> + * if somebody sets up a hierarchical bond, then rmmod's
> + * one of the slave bonding devices?
> */
> break;
> case NETDEV_CHANGEMTU:
> @@ -5196,4 +5229,3 @@ MODULE_SUPPORTED_DEVICE("most ethernet d
> * tab-width: 8
> * End:
> */
> -
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
prev parent reply other threads:[~2009-02-23 23:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-23 20:01 Laurent Chavey
2009-02-23 23:47 ` David Miller [this message]
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=20090223.154703.114857595.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=chavey@google.com \
--cc=fubar@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®