From: Yue Zhang <yuezha@microsoft.com>
To: netdev@vger.kernel.org, driverdev-devel@linuxdriverproject.org,
linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org,
olaf@aepfle.de, jasowang@redhat.com, davem@davemloft.net
Cc: huishao@microsoft.com, haiyangz@microsoft.com
Subject: [PATCH] Hyperv: Trigger DHCP renew after host hibernation
Date: Fri, 18 Jul 2014 03:55:03 -0700 [thread overview]
Message-ID: <1405680903-28176-1-git-send-email-yuezha@microsoft.com> (raw)
From: Yue Zhang <yuezha@microsoft.com>
This patch addresses the comment from Olaf Hering and Greg KH
for a previous commit 3a494e710367 ("hyperv: Add handler for
RNDIS_STATUS_NETWORK_CHANGE event")
In previous solution, the driver calls "network restart" to
force a DHCP renew when the host is back from hibernation.
In this fix, the driver will keep network carrier offline for
10 seconds and then bring it back. So that ifplugd daemon will
notice this change and refresh DHCP lease.
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Cc: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Yue Zhang <yuezha@microsoft.com>
---
drivers/net/hyperv/netvsc_drv.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index a9c5eaa..559c97d 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -33,6 +33,7 @@
#include <linux/if_vlan.h>
#include <linux/in.h>
#include <linux/slab.h>
+#include <linux/delay.h>
#include <net/arp.h>
#include <net/route.h>
#include <net/sock.h>
@@ -792,8 +793,7 @@ static void netvsc_link_change(struct work_struct *w)
struct netvsc_device *net_device;
struct rndis_device *rdev;
bool notify, refresh = false;
- char *argv[] = { "/etc/init.d/network", "restart", NULL };
- char *envp[] = { "HOME=/", "PATH=/sbin:/usr/sbin:/bin:/usr/bin", NULL };
+ int delay;
rtnl_lock();
@@ -816,8 +816,21 @@ static void netvsc_link_change(struct work_struct *w)
rtnl_unlock();
- if (refresh)
- call_usermodehelper(argv[0], argv, envp, UMH_WAIT_EXEC);
+ if (refresh) {
+ /*
+ * Keep the carrier offline for 10 seconds
+ * to notify ifplugd daemon network change
+ */
+ for (delay = 0; delay < 10; delay++) {
+ rtnl_lock();
+ netif_carrier_off(net);
+ rtnl_unlock();
+ ssleep(1);
+ }
+ rtnl_lock();
+ netif_carrier_on(net);
+ rtnl_unlock();
+ }
if (notify)
netdev_notify_peers(net);
--
1.9.1
next reply other threads:[~2014-07-18 10:55 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-18 10:55 Yue Zhang [this message]
2014-07-18 10:13 ` [PATCH] Hyperv: Trigger DHCP renew after host hibernation Varka Bhadram
2014-07-21 2:45 ` Yue Zhang (OSTC DEV)
2014-07-18 13:40 ` Richard Weinberger
2014-07-21 2:44 ` Yue Zhang (OSTC DEV)
2014-07-21 6:55 ` Richard Weinberger
2014-07-21 8:05 ` Yue Zhang (OSTC DEV)
2014-07-21 8:17 ` Richard Weinberger
2014-07-21 8:44 ` Yue Zhang (OSTC DEV)
2014-07-21 9:01 ` Richard Weinberger
2014-07-21 9:18 ` Olaf Hering
2014-07-21 21:32 ` David Miller
2014-08-07 22:37 ` Richard Weinberger
2014-08-08 3:13 ` Dexuan Cui
2014-08-08 3:32 ` Greg KH
2014-08-08 8:11 ` Dexuan Cui
2014-08-08 13:45 ` Greg KH
2014-08-08 16:28 ` Stephen Hemminger
2014-08-11 3:23 ` Dexuan Cui
2014-08-11 3:51 ` Florian Fainelli
2014-08-11 4:22 ` Bill Fink
2014-08-12 7:51 ` Dexuan Cui
2014-08-12 7:48 ` Dexuan Cui
2014-08-11 10:45 ` Tom Gundersen
2014-08-12 8:29 ` Dexuan Cui
2014-08-13 13:15 ` Tom Gundersen
2014-08-13 13:34 ` Dan Williams
2014-08-14 5:19 ` Dexuan Cui
2014-08-11 3:29 ` Dexuan Cui
2014-07-21 9:42 ` Tom Gundersen
2014-07-21 10:21 ` Yue Zhang (OSTC DEV)
2014-07-21 13:11 ` Lennart Poettering
2014-07-21 17:17 ` Dan Williams
2014-07-21 14:06 ` Tom Gundersen
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=1405680903-28176-1-git-send-email-yuezha@microsoft.com \
--to=yuezha@microsoft.com \
--cc=davem@davemloft.net \
--cc=driverdev-devel@linuxdriverproject.org \
--cc=gregkh@linuxfoundation.org \
--cc=haiyangz@microsoft.com \
--cc=huishao@microsoft.com \
--cc=jasowang@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=olaf@aepfle.de \
/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).