netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Hyperv: Trigger DHCP renew after host hibernation
@ 2014-07-18 10:55 Yue Zhang
  2014-07-18 10:13 ` Varka Bhadram
                   ` (2 more replies)
  0 siblings, 3 replies; 34+ messages in thread
From: Yue Zhang @ 2014-07-18 10:55 UTC (permalink / raw)
  To: netdev, driverdev-devel, linux-kernel, gregkh, olaf, jasowang,
	davem
  Cc: huishao, haiyangz

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

^ permalink raw reply related	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2014-08-14  5:19 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-18 10:55 [PATCH] Hyperv: Trigger DHCP renew after host hibernation Yue Zhang
2014-07-18 10:13 ` 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

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).