RE: [PATCH] Hyperv: Trigger DHCP renew after host hibernation

2014-07-21 Thread Yue Zhang (OSTC DEV)
> From: Tom Gundersen [mailto:t...@jklm.no]
> Sent: Monday, July 21, 2014 5:42 PM
> 
> On Fri, Jul 18, 2014 at 12:55 PM, Yue Zhang  wrote:
> > From: Yue Zhang 
> >
> > 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 
> > Cc: K. Y. Srinivasan 
> >
> > Signed-off-by: Yue Zhang 
> > ---
> >  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 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > @@ -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();
> > +   }
> 
> Why is it necessary to wait for ten seconds? Why not just:
> 
> if (refresh) {
> rtnl_lock();
> netif_carrier_off(net);
> netif_carrier_on(net);
> rtnl_unlock();
> }
> 
> At least systemd-networkd will renew the dhcp lease as long as it gets
> NEWLINK messages indicating that the carrier was lost and regained,
> regardless of the time between events. Is there any reason not to do
> this?
> 
> Cheers,
> 
> Tom
> 

Hi, Tom

Some network monitoring daemon, like ifplugd has a deferring mechanism.
When it detects carriers is offline, it doesn't trigger DHCP renew immediately. 
Instead it will wait for another 5 seconds to check whether carrier is back to 
online status. In that case, it will avoid renew DHCP lease.

And also there is some optimization in Linux's network stack. If link state
flipped so quickly, like the code you proposed. It is very likely the event 
won't
be delivered to user space.

Thanks
---
Yue


RE: [PATCH] Hyperv: Trigger DHCP renew after host hibernation

2014-07-21 Thread Yue Zhang (OSTC DEV)
> From: Richard Weinberger [mailto:rich...@nod.at]
> Sent: Monday, July 21, 2014 4:18 PM
> 
> Yue,
> 
> Am 21.07.2014 10:05, schrieb Yue Zhang (OSTC DEV):
> > The problem of systemd implementation is that in different distros, the 
> > ways 
> > to restart service are different. Propagating the event to userspace also 
> > doesn't 
> > help for this issue.
> 
> This way each distro can provide their own restart script.
> Same as every distro has custom start scripts, etc...
> 
> > The advantage of current solution is that it simulates a cable plugging 
> > in/out event. IMHO, in all the distros, this simulated event has already 
> > been well 
> > handled. It is a dup effect to implement new hooks.
> 
> Iff the current solution works for _all_ networking implementations.
> 
> Thanks,
> //richard

Hi, Richard

IMHO, all networking implementations should handle the cable offline event. 
Consider
this situation. I unplugged the network cable and connect it to a new network 
switch
after 10 seconds. If the DHCP renew is not triggered, the network will break. I 
think in 
normal cases, it should already been handled properly. Unless there is a strong 
justification for not doing this. In that case, we shouldn't renew DHCP anyway.

Thanks

Yue


RE: [PATCH] Hyperv: Trigger DHCP renew after host hibernation

2014-07-21 Thread Yue Zhang (OSTC DEV)
> From: Richard Weinberger [mailto:rich...@nod.at]
> Sent: Monday, July 21, 2014 2:55 PM
> 
> Yue,
> 
> Am 21.07.2014 04:44, schrieb Yue Zhang (OSTC DEV):
> >> From: Richard Weinberger [mailto:richard.weinber...@gmail.com]
> >> Why 10? Is this a random number which works by accident for ifplugd?
> >> What about other networking implementations, is 10 also ok for them?
> >> --
> >> Thanks,
> >> //richard
> >
> > Hi, Richard
> >
> > I checked ifplugd's code. The deferring time is 5 seconds. That's how
> comes
> > the "10s". I agree with you this is a magic number and should be avoid.
> However,
> > this is the only feasible solution right now. If there is a better 
> > solution, I will
> be
> > glad to switch to it.
> >
> > I tested the fix in Redhat, Ubuntu and SUSE and it works in all of them.
> 
> The problem I see is that there is no good way to trigger a DHCP renew from
> a network device drivers. You're on the wrong layer.
> 10 seconds may work but this is IMHO a hack which can easily break.
> There are also more networking implementations than ifplugd.
> Specially the systemd implementation looks promising.
> 
> Can't you propagate the RNDIS_STATUS_NETWORK_CHANGE event to
> userspace?
> IIRC on HyperV guests already have a guest daemon. Let the daemon handle
> the event such that distros can install their own hooks...
> 
> Thanks,
> //richard

Hi, Richard

The problem of systemd implementation is that in different distros, the ways to 
restart service are different. Propagating the event to userspace also doesn't 
help
for this issue. 

The advantage of current solution is that it simulates a cable plugging in/out 
event.
IMHO, in all the distros, this simulated event has already been well handled. 
It is a
dup effect to implement new hooks.

Thanks

Yue


RE: [PATCH] Hyperv: Trigger DHCP renew after host hibernation

2014-07-21 Thread Yue Zhang (OSTC DEV)
 From: Richard Weinberger [mailto:rich...@nod.at]
 Sent: Monday, July 21, 2014 2:55 PM
 
 Yue,
 
 Am 21.07.2014 04:44, schrieb Yue Zhang (OSTC DEV):
  From: Richard Weinberger [mailto:richard.weinber...@gmail.com]
  Why 10? Is this a random number which works by accident for ifplugd?
  What about other networking implementations, is 10 also ok for them?
  --
  Thanks,
  //richard
 
  Hi, Richard
 
  I checked ifplugd's code. The deferring time is 5 seconds. That's how
 comes
  the 10s. I agree with you this is a magic number and should be avoid.
 However,
  this is the only feasible solution right now. If there is a better 
  solution, I will
 be
  glad to switch to it.
 
  I tested the fix in Redhat, Ubuntu and SUSE and it works in all of them.
 
 The problem I see is that there is no good way to trigger a DHCP renew from
 a network device drivers. You're on the wrong layer.
 10 seconds may work but this is IMHO a hack which can easily break.
 There are also more networking implementations than ifplugd.
 Specially the systemd implementation looks promising.
 
 Can't you propagate the RNDIS_STATUS_NETWORK_CHANGE event to
 userspace?
 IIRC on HyperV guests already have a guest daemon. Let the daemon handle
 the event such that distros can install their own hooks...
 
 Thanks,
 //richard

Hi, Richard

The problem of systemd implementation is that in different distros, the ways to 
restart service are different. Propagating the event to userspace also doesn't 
help
for this issue. 

The advantage of current solution is that it simulates a cable plugging in/out 
event.
IMHO, in all the distros, this simulated event has already been well handled. 
It is a
dup effect to implement new hooks.

Thanks

Yue


RE: [PATCH] Hyperv: Trigger DHCP renew after host hibernation

2014-07-21 Thread Yue Zhang (OSTC DEV)
 From: Richard Weinberger [mailto:rich...@nod.at]
 Sent: Monday, July 21, 2014 4:18 PM
 
 Yue,
 
 Am 21.07.2014 10:05, schrieb Yue Zhang (OSTC DEV):
  The problem of systemd implementation is that in different distros, the 
  ways 
  to restart service are different. Propagating the event to userspace also 
  doesn't 
  help for this issue.
 
 This way each distro can provide their own restart script.
 Same as every distro has custom start scripts, etc...
 
  The advantage of current solution is that it simulates a cable plugging 
  in/out event. IMHO, in all the distros, this simulated event has already 
  been well 
  handled. It is a dup effect to implement new hooks.
 
 Iff the current solution works for _all_ networking implementations.
 
 Thanks,
 //richard

Hi, Richard

IMHO, all networking implementations should handle the cable offline event. 
Consider
this situation. I unplugged the network cable and connect it to a new network 
switch
after 10 seconds. If the DHCP renew is not triggered, the network will break. I 
think in 
normal cases, it should already been handled properly. Unless there is a strong 
justification for not doing this. In that case, we shouldn't renew DHCP anyway.

Thanks

Yue


RE: [PATCH] Hyperv: Trigger DHCP renew after host hibernation

2014-07-21 Thread Yue Zhang (OSTC DEV)
 From: Tom Gundersen [mailto:t...@jklm.no]
 Sent: Monday, July 21, 2014 5:42 PM
 
 On Fri, Jul 18, 2014 at 12:55 PM, Yue Zhang yue...@microsoft.com wrote:
  From: Yue Zhang yue...@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 haiya...@microsoft.com
  Cc: K. Y. Srinivasan k...@microsoft.com
 
  Signed-off-by: Yue Zhang yue...@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();
  +   }
 
 Why is it necessary to wait for ten seconds? Why not just:
 
 if (refresh) {
 rtnl_lock();
 netif_carrier_off(net);
 netif_carrier_on(net);
 rtnl_unlock();
 }
 
 At least systemd-networkd will renew the dhcp lease as long as it gets
 NEWLINK messages indicating that the carrier was lost and regained,
 regardless of the time between events. Is there any reason not to do
 this?
 
 Cheers,
 
 Tom
 

Hi, Tom

Some network monitoring daemon, like ifplugd has a deferring mechanism.
When it detects carriers is offline, it doesn't trigger DHCP renew immediately. 
Instead it will wait for another 5 seconds to check whether carrier is back to 
online status. In that case, it will avoid renew DHCP lease.

And also there is some optimization in Linux's network stack. If link state
flipped so quickly, like the code you proposed. It is very likely the event 
won't
be delivered to user space.

Thanks
---
Yue


RE: [PATCH] Hyperv: Trigger DHCP renew after host hibernation

2014-07-20 Thread Yue Zhang (OSTC DEV)
> From: Varka Bhadram [mailto:varkabhad...@gmail.com]
> Sent: Friday, July 18, 2014 6:13 PM
> 
> On 07/18/2014 04:25 PM, Yue Zhang wrote:
> > @@ -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
> > +*/
> 
> This should be networking comment style..
> 
>   /* bla bla..
>* bla
>*/
> 
> --
> Regards,
> Varka Bhadram.

I will fix this.

Thanks
Yue
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH] Hyperv: Trigger DHCP renew after host hibernation

2014-07-20 Thread Yue Zhang (OSTC DEV)
> From: Richard Weinberger [mailto:richard.weinber...@gmail.com]
> Sent: Friday, July 18, 2014 9:41 PM
> 
> On Fri, Jul 18, 2014 at 12:55 PM, Yue Zhang  wrote:
> > From: Yue Zhang 
> >
> > 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 
> > Cc: K. Y. Srinivasan 
> >
> > Signed-off-by: Yue Zhang 
> > ---
> >  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 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > @@ -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
> > +*/
> 
> Why 10? Is this a random number which works by accident for ifplugd?
> What about other networking implementations, is 10 also ok for them?
> --
> Thanks,
> //richard

Hi, Richard

I checked ifplugd's code. The deferring time is 5 seconds. That's how  comes 
the "10s". I agree with you this is a magic number and should be avoid. 
However, 
this is the only feasible solution right now. If there is a better solution, I 
will be 
glad to switch to it.

I tested the fix in Redhat, Ubuntu and SUSE and it works in all of them.

Thanks
Yie


RE: [PATCH] Hyperv: Trigger DHCP renew after host hibernation

2014-07-20 Thread Yue Zhang (OSTC DEV)
 From: Richard Weinberger [mailto:richard.weinber...@gmail.com]
 Sent: Friday, July 18, 2014 9:41 PM
 
 On Fri, Jul 18, 2014 at 12:55 PM, Yue Zhang yue...@microsoft.com wrote:
  From: Yue Zhang yue...@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 haiya...@microsoft.com
  Cc: K. Y. Srinivasan k...@microsoft.com
 
  Signed-off-by: Yue Zhang yue...@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
  +*/
 
 Why 10? Is this a random number which works by accident for ifplugd?
 What about other networking implementations, is 10 also ok for them?
 --
 Thanks,
 //richard

Hi, Richard

I checked ifplugd's code. The deferring time is 5 seconds. That's how  comes 
the 10s. I agree with you this is a magic number and should be avoid. 
However, 
this is the only feasible solution right now. If there is a better solution, I 
will be 
glad to switch to it.

I tested the fix in Redhat, Ubuntu and SUSE and it works in all of them.

Thanks
Yie


RE: [PATCH] Hyperv: Trigger DHCP renew after host hibernation

2014-07-20 Thread Yue Zhang (OSTC DEV)
 From: Varka Bhadram [mailto:varkabhad...@gmail.com]
 Sent: Friday, July 18, 2014 6:13 PM
 
 On 07/18/2014 04:25 PM, Yue Zhang wrote:
  @@ -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
  +*/
 
 This should be networking comment style..
 
   /* bla bla..
* bla
*/
 
 --
 Regards,
 Varka Bhadram.

I will fix this.

Thanks
Yue
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Hyperv: Trigger DHCP renew after host hibernation

2014-07-18 Thread Yue Zhang
From: Yue Zhang 

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 
Cc: K. Y. Srinivasan 

Signed-off-by: Yue Zhang 
---
 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 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Hyperv: Trigger DHCP renew after host hibernation

2014-07-18 Thread Yue Zhang
From: Yue Zhang yue...@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 haiya...@microsoft.com
Cc: K. Y. Srinivasan k...@microsoft.com

Signed-off-by: Yue Zhang yue...@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

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3] Tools: hv: fix file overwriting of hv_fcopy_daemon

2014-06-27 Thread Yue Zhang
From: Yue Zhang 

hv_fcopy_daemon fails to overwrite a file if the target file already
exits.

Add O_TRUNC flag on opening.

Signed-off-by: Yue Zhang 
---
 tools/hv/hv_fcopy_daemon.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/hv/hv_fcopy_daemon.c b/tools/hv/hv_fcopy_daemon.c
index fba1c75..8f96b3e 100644
--- a/tools/hv/hv_fcopy_daemon.c
+++ b/tools/hv/hv_fcopy_daemon.c
@@ -88,7 +88,8 @@ static int hv_start_fcopy(struct hv_start_fcopy *smsg)
}
}
 
-   target_fd = open(target_fname, O_RDWR | O_CREAT | O_CLOEXEC, 0744);
+   target_fd = open(target_fname,
+O_RDWR | O_CREAT | O_TRUNC | O_CLOEXEC, 0744);
if (target_fd == -1) {
syslog(LOG_INFO, "Open Failed: %s", strerror(errno));
goto done;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH] Tools: hv: fix file overwriting of hv_fcopy_daemon

2014-06-27 Thread Yue Zhang (OSTC DEV)


> -Original Message-
> From: Greg KH [mailto:g...@kroah.com]
> > From: Yue Zhang 
> >
> > hv_fcopy_daemon fails to overwrite a file if the target file already
> > exits.
> >
> > Add O_TRUNC flag on opening.
> >
> > MS-TFS: 341345
> 
> It's as if the people on your team don't talk to each other about what they
> should, or should not, include in their patch descriptions...
> 
> Please remove.

Sorry for this. It is added by mistake. I will remove it.

Yue Zhang
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2] Tools: hv: fix file overwriting of hv_fcopy_daemon

2014-06-27 Thread Yue Zhang
From: Yue Zhang 

hv_fcopy_daemon fails to overwrite a file if the target file already
exits.

Add O_TRUNC flag on opening.

Signed-off-by: Yue Zhang 
---
 tools/hv/hv_fcopy_daemon.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/hv/hv_fcopy_daemon.c b/tools/hv/hv_fcopy_daemon.c
index fba1c75..2a86297 100644
--- a/tools/hv/hv_fcopy_daemon.c
+++ b/tools/hv/hv_fcopy_daemon.c
@@ -88,7 +88,8 @@ static int hv_start_fcopy(struct hv_start_fcopy *smsg)
}
}
 
-   target_fd = open(target_fname, O_RDWR | O_CREAT | O_CLOEXEC, 0744);
+   target_fd = open(target_fname,
+   O_RDWR | O_CREAT | O_TRUNC | O_CLOEXEC, 0744);
if (target_fd == -1) {
syslog(LOG_INFO, "Open Failed: %s", strerror(errno));
goto done;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Tools: hv: fix file overwriting of hv_fcopy_daemon

2014-06-27 Thread Yue Zhang
From: Yue Zhang 

hv_fcopy_daemon fails to overwrite a file if the target file already
exits.

Add O_TRUNC flag on opening.

MS-TFS: 341345

Signed-off-by: Yue Zhang 
---
 tools/hv/hv_fcopy_daemon.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/hv/hv_fcopy_daemon.c b/tools/hv/hv_fcopy_daemon.c
index fba1c75..2a86297 100644
--- a/tools/hv/hv_fcopy_daemon.c
+++ b/tools/hv/hv_fcopy_daemon.c
@@ -88,7 +88,8 @@ static int hv_start_fcopy(struct hv_start_fcopy *smsg)
}
}
 
-   target_fd = open(target_fname, O_RDWR | O_CREAT | O_CLOEXEC, 0744);
+   target_fd = open(target_fname,
+   O_RDWR | O_CREAT | O_TRUNC | O_CLOEXEC, 0744);
if (target_fd == -1) {
syslog(LOG_INFO, "Open Failed: %s", strerror(errno));
goto done;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Tools: hv: fix file overwriting of hv_fcopy_daemon

2014-06-27 Thread Yue Zhang
From: Yue Zhang yue...@microsoft.com

hv_fcopy_daemon fails to overwrite a file if the target file already
exits.

Add O_TRUNC flag on opening.

MS-TFS: 341345

Signed-off-by: Yue Zhang yue...@microsoft.com
---
 tools/hv/hv_fcopy_daemon.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/hv/hv_fcopy_daemon.c b/tools/hv/hv_fcopy_daemon.c
index fba1c75..2a86297 100644
--- a/tools/hv/hv_fcopy_daemon.c
+++ b/tools/hv/hv_fcopy_daemon.c
@@ -88,7 +88,8 @@ static int hv_start_fcopy(struct hv_start_fcopy *smsg)
}
}
 
-   target_fd = open(target_fname, O_RDWR | O_CREAT | O_CLOEXEC, 0744);
+   target_fd = open(target_fname,
+   O_RDWR | O_CREAT | O_TRUNC | O_CLOEXEC, 0744);
if (target_fd == -1) {
syslog(LOG_INFO, Open Failed: %s, strerror(errno));
goto done;
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v2] Tools: hv: fix file overwriting of hv_fcopy_daemon

2014-06-27 Thread Yue Zhang
From: Yue Zhang yue...@microsoft.com

hv_fcopy_daemon fails to overwrite a file if the target file already
exits.

Add O_TRUNC flag on opening.

Signed-off-by: Yue Zhang yue...@microsoft.com
---
 tools/hv/hv_fcopy_daemon.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/hv/hv_fcopy_daemon.c b/tools/hv/hv_fcopy_daemon.c
index fba1c75..2a86297 100644
--- a/tools/hv/hv_fcopy_daemon.c
+++ b/tools/hv/hv_fcopy_daemon.c
@@ -88,7 +88,8 @@ static int hv_start_fcopy(struct hv_start_fcopy *smsg)
}
}
 
-   target_fd = open(target_fname, O_RDWR | O_CREAT | O_CLOEXEC, 0744);
+   target_fd = open(target_fname,
+   O_RDWR | O_CREAT | O_TRUNC | O_CLOEXEC, 0744);
if (target_fd == -1) {
syslog(LOG_INFO, Open Failed: %s, strerror(errno));
goto done;
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH] Tools: hv: fix file overwriting of hv_fcopy_daemon

2014-06-27 Thread Yue Zhang (OSTC DEV)


 -Original Message-
 From: Greg KH [mailto:g...@kroah.com]
  From: Yue Zhang yue...@microsoft.com
 
  hv_fcopy_daemon fails to overwrite a file if the target file already
  exits.
 
  Add O_TRUNC flag on opening.
 
  MS-TFS: 341345
 
 It's as if the people on your team don't talk to each other about what they
 should, or should not, include in their patch descriptions...
 
 Please remove.

Sorry for this. It is added by mistake. I will remove it.

Yue Zhang
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v3] Tools: hv: fix file overwriting of hv_fcopy_daemon

2014-06-27 Thread Yue Zhang
From: Yue Zhang yue...@microsoft.com

hv_fcopy_daemon fails to overwrite a file if the target file already
exits.

Add O_TRUNC flag on opening.

Signed-off-by: Yue Zhang yue...@microsoft.com
---
 tools/hv/hv_fcopy_daemon.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/hv/hv_fcopy_daemon.c b/tools/hv/hv_fcopy_daemon.c
index fba1c75..8f96b3e 100644
--- a/tools/hv/hv_fcopy_daemon.c
+++ b/tools/hv/hv_fcopy_daemon.c
@@ -88,7 +88,8 @@ static int hv_start_fcopy(struct hv_start_fcopy *smsg)
}
}
 
-   target_fd = open(target_fname, O_RDWR | O_CREAT | O_CLOEXEC, 0744);
+   target_fd = open(target_fname,
+O_RDWR | O_CREAT | O_TRUNC | O_CLOEXEC, 0744);
if (target_fd == -1) {
syslog(LOG_INFO, Open Failed: %s, strerror(errno));
goto done;
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH] Tools: hv: fix file overwriting of hv_fcopy_daemon

2014-06-26 Thread Yue Zhang (OSTC DEV)


> -Original Message-
> From: KY Srinivasan
> > -Original Message-
> > From: Yue Zhang [mailto:yue...@microsoft.com]
> > hv_fcopy_daemon fails to overwrite a file if the target file already exits.
> >
> > Add O_TRUNC flag on opening.
> >
> > Signed-off-by: Yue Zhang 
> > ---
> >  tools/hv/hv_fcopy_daemon.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/tools/hv/hv_fcopy_daemon.c b/tools/hv/hv_fcopy_daemon.c
> > index fba1c75..01eee6b 100644
> > --- a/tools/hv/hv_fcopy_daemon.c
> > +++ b/tools/hv/hv_fcopy_daemon.c
> > @@ -88,7 +88,8 @@ static int hv_start_fcopy(struct hv_start_fcopy
> > *smsg)  }  }
> >
> > -target_fd = open(target_fname, O_RDWR | O_CREAT | O_CLOEXEC, 0744);
> > +target_fd = open(target_fname,
> > +O_RDWR | O_CREAT | O_TRUNC |
> Please align O_RDWR to align with the first argument (target_fname).
Thanks. I will fix it. 
> 
> K. Y
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Tools: hv: fix file overwriting of hv_fcopy_daemon

2014-06-26 Thread Yue Zhang
From: Yue Zhang 

hv_fcopy_daemon fails to overwrite a file if the target file already
exits.

Add O_TRUNC flag on opening.

Signed-off-by: Yue Zhang 
---
 tools/hv/hv_fcopy_daemon.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/hv/hv_fcopy_daemon.c b/tools/hv/hv_fcopy_daemon.c
index fba1c75..01eee6b 100644
--- a/tools/hv/hv_fcopy_daemon.c
+++ b/tools/hv/hv_fcopy_daemon.c
@@ -88,7 +88,8 @@ static int hv_start_fcopy(struct hv_start_fcopy *smsg)
}
}
 
-   target_fd = open(target_fname, O_RDWR | O_CREAT | O_CLOEXEC, 0744);
+   target_fd = open(target_fname,
+   O_RDWR | O_CREAT | O_TRUNC | O_CLOEXEC, 0744);
if (target_fd == -1) {
syslog(LOG_INFO, "Open Failed: %s", strerror(errno));
goto done;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Tools: hv: fix file overwriting of hv_fcopy_daemon

2014-06-26 Thread Yue Zhang
From: Yue Zhang yue...@microsoft.com

hv_fcopy_daemon fails to overwrite a file if the target file already
exits.

Add O_TRUNC flag on opening.

Signed-off-by: Yue Zhang yue...@microsoft.com
---
 tools/hv/hv_fcopy_daemon.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/hv/hv_fcopy_daemon.c b/tools/hv/hv_fcopy_daemon.c
index fba1c75..01eee6b 100644
--- a/tools/hv/hv_fcopy_daemon.c
+++ b/tools/hv/hv_fcopy_daemon.c
@@ -88,7 +88,8 @@ static int hv_start_fcopy(struct hv_start_fcopy *smsg)
}
}
 
-   target_fd = open(target_fname, O_RDWR | O_CREAT | O_CLOEXEC, 0744);
+   target_fd = open(target_fname,
+   O_RDWR | O_CREAT | O_TRUNC | O_CLOEXEC, 0744);
if (target_fd == -1) {
syslog(LOG_INFO, Open Failed: %s, strerror(errno));
goto done;
-- 
1.9.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [PATCH] Tools: hv: fix file overwriting of hv_fcopy_daemon

2014-06-26 Thread Yue Zhang (OSTC DEV)


 -Original Message-
 From: KY Srinivasan
  -Original Message-
  From: Yue Zhang [mailto:yue...@microsoft.com]
  hv_fcopy_daemon fails to overwrite a file if the target file already exits.
 
  Add O_TRUNC flag on opening.
 
  Signed-off-by: Yue Zhang yue...@microsoft.com
  ---
   tools/hv/hv_fcopy_daemon.c | 3 ++-
   1 file changed, 2 insertions(+), 1 deletion(-)
 
  diff --git a/tools/hv/hv_fcopy_daemon.c b/tools/hv/hv_fcopy_daemon.c
  index fba1c75..01eee6b 100644
  --- a/tools/hv/hv_fcopy_daemon.c
  +++ b/tools/hv/hv_fcopy_daemon.c
  @@ -88,7 +88,8 @@ static int hv_start_fcopy(struct hv_start_fcopy
  *smsg)  }  }
 
  -target_fd = open(target_fname, O_RDWR | O_CREAT | O_CLOEXEC, 0744);
  +target_fd = open(target_fname,
  +O_RDWR | O_CREAT | O_TRUNC |
 Please align O_RDWR to align with the first argument (target_fname).
Thanks. I will fix it. 
 
 K. Y
 

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/