netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* question: Any way to trigger DHCP renewal from kernel code?
@ 2014-05-22 22:24 Haiyang Zhang
  2014-05-23  0:49 ` Vlad Yasevich
  2014-05-23 15:06 ` Dan Williams
  0 siblings, 2 replies; 5+ messages in thread
From: Haiyang Zhang @ 2014-05-22 22:24 UTC (permalink / raw)
  To: netdev@vger.kernel.org

Hi,

Our synthetic network driver is notified when the Hyper-V host 
resume from sleep/hibernation. We need to renew DHCP in this case.
I'm looking for a way to trigger DHCP renewal from kernel mode 
code.

Can anyone help me?

Thanks,
- Haiyang

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

* Re: question: Any way to trigger DHCP renewal from kernel code?
  2014-05-22 22:24 question: Any way to trigger DHCP renewal from kernel code? Haiyang Zhang
@ 2014-05-23  0:49 ` Vlad Yasevich
  2014-05-23  9:20   ` zhuyj
  2014-05-23 15:06 ` Dan Williams
  1 sibling, 1 reply; 5+ messages in thread
From: Vlad Yasevich @ 2014-05-23  0:49 UTC (permalink / raw)
  To: Haiyang Zhang, netdev@vger.kernel.org

On 05/22/2014 06:24 PM, Haiyang Zhang wrote:
> Hi,
> 
> Our synthetic network driver is notified when the Hyper-V host 
> resume from sleep/hibernation. We need to renew DHCP in this case.
> I'm looking for a way to trigger DHCP renewal from kernel mode 
> code.
> 
> Can anyone help me?

One idea:

Generate a udev event and a udev rule that triggers a renew when
event is received.

-vlad

> 
> Thanks,
> - Haiyang
> 
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

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

* Re: question: Any way to trigger DHCP renewal from kernel code?
  2014-05-23  0:49 ` Vlad Yasevich
@ 2014-05-23  9:20   ` zhuyj
  0 siblings, 0 replies; 5+ messages in thread
From: zhuyj @ 2014-05-23  9:20 UTC (permalink / raw)
  To: Vlad Yasevich, Haiyang Zhang, netdev@vger.kernel.org, zhuyj

On 05/23/2014 08:49 AM, Vlad Yasevich wrote:
> On 05/22/2014 06:24 PM, Haiyang Zhang wrote:
>> Hi,
>>
>> Our synthetic network driver is notified when the Hyper-V host
>> resume from sleep/hibernation. We need to renew DHCP in this case.
>> I'm looking for a way to trigger DHCP renewal from kernel mode
>> code.
>>
>> Can anyone help me?
> One idea:
>
> Generate a udev event and a udev rule that triggers a renew when
> event is received.
>
> -vlad
Another idea:

crontab, Periodically trigger a renew.

Zhu Yanjun
>
>> Thanks,
>> - Haiyang
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe netdev" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

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

* Re: question: Any way to trigger DHCP renewal from kernel code?
  2014-05-22 22:24 question: Any way to trigger DHCP renewal from kernel code? Haiyang Zhang
  2014-05-23  0:49 ` Vlad Yasevich
@ 2014-05-23 15:06 ` Dan Williams
  2014-05-23 15:19   ` Haiyang Zhang
  1 sibling, 1 reply; 5+ messages in thread
From: Dan Williams @ 2014-05-23 15:06 UTC (permalink / raw)
  To: Haiyang Zhang; +Cc: netdev@vger.kernel.org

On Thu, 2014-05-22 at 22:24 +0000, Haiyang Zhang wrote:
> Hi,
> 
> Our synthetic network driver is notified when the Hyper-V host 
> resume from sleep/hibernation. We need to renew DHCP in this case.
> I'm looking for a way to trigger DHCP renewal from kernel mode 
> code.

Another approach could be to change the 'operstate' of your synthetic
netdevice to IF_OPER_DORMANT and then back to IF_OPER_UP.  Possibly like
drivers/net/hsr/hsr_device.c does in __hsr_set_operstate().

The netdev_state_change() call will send out a netlink message that the
device has changed, which includes the device flags.  Before changing
the operstate, the flags will include IFF_RUNNING, which indicates the
netdevice is operating and passing traffic.  When you change the
operstate to IF_OPER_DORMANT, a netlink message will be sent which does
*not* include IFF_RUNNING.  Then changing back to IF_OPER_UP will emit a
netlink message that *does* include IFF_RUNNING again.

The DHCP client can listen for device flag changes and trigger a DHCP
renew when the IFF_RUNNING flag re-appears on the device.  There are
some notes about this in Documentation/networking/operstates.txt too.

(Random note: long ago when WiMAX was relevant there was also a need to
trigger a DHCP renew in userspace based on events from the driver; a
renew should be performed when the device comes out of fast sleep, which
can happen quite often.  I don't remember how Inaky solved this, but I
think it was out-of-band driver messages to the userspace control
daemon.  A more standardized kernel facility somewhat less convoluted
than manually munging operstates would have been nice...)

Dan

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

* RE: question: Any way to trigger DHCP renewal from kernel code?
  2014-05-23 15:06 ` Dan Williams
@ 2014-05-23 15:19   ` Haiyang Zhang
  0 siblings, 0 replies; 5+ messages in thread
From: Haiyang Zhang @ 2014-05-23 15:19 UTC (permalink / raw)
  To: Dan Williams; +Cc: netdev@vger.kernel.org



> -----Original Message-----
> From: Dan Williams [mailto:dcbw@redhat.com]
> Sent: Friday, May 23, 2014 11:07 AM
> To: Haiyang Zhang
> Cc: netdev@vger.kernel.org
> Subject: Re: question: Any way to trigger DHCP renewal from kernel code?
> 
> On Thu, 2014-05-22 at 22:24 +0000, Haiyang Zhang wrote:
> > Hi,
> >
> > Our synthetic network driver is notified when the Hyper-V host
> > resume from sleep/hibernation. We need to renew DHCP in this case.
> > I'm looking for a way to trigger DHCP renewal from kernel mode
> > code.
> 
> Another approach could be to change the 'operstate' of your synthetic
> netdevice to IF_OPER_DORMANT and then back to IF_OPER_UP.  Possibly like
> drivers/net/hsr/hsr_device.c does in __hsr_set_operstate().
> 
> The netdev_state_change() call will send out a netlink message that the
> device has changed, which includes the device flags.  Before changing
> the operstate, the flags will include IFF_RUNNING, which indicates the
> netdevice is operating and passing traffic.  When you change the
> operstate to IF_OPER_DORMANT, a netlink message will be sent which does
> *not* include IFF_RUNNING.  Then changing back to IF_OPER_UP will emit a
> netlink message that *does* include IFF_RUNNING again.
> 
> The DHCP client can listen for device flag changes and trigger a DHCP
> renew when the IFF_RUNNING flag re-appears on the device.  There are
> some notes about this in Documentation/networking/operstates.txt too.
> 
> (Random note: long ago when WiMAX was relevant there was also a need to
> trigger a DHCP renew in userspace based on events from the driver; a
> renew should be performed when the device comes out of fast sleep, which
> can happen quite often.  I don't remember how Inaky solved this, but I
> think it was out-of-band driver messages to the userspace control
> daemon.  A more standardized kernel facility somewhat less convoluted
> than manually munging operstates would have been nice...)

Thanks a lot to you and others for the help!

- Haiyang


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

end of thread, other threads:[~2014-05-23 15:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-22 22:24 question: Any way to trigger DHCP renewal from kernel code? Haiyang Zhang
2014-05-23  0:49 ` Vlad Yasevich
2014-05-23  9:20   ` zhuyj
2014-05-23 15:06 ` Dan Williams
2014-05-23 15:19   ` Haiyang Zhang

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