* [Buildroot] [PATCH 1/1] busybox: udhcpc create leases file
@ 2015-04-30 1:41 Matt Weber
2015-04-30 14:31 ` Peter Korsgaard
0 siblings, 1 reply; 7+ messages in thread
From: Matt Weber @ 2015-04-30 1:41 UTC (permalink / raw)
To: buildroot
Signed-off-by: Matt Weber <matt@thewebers.ws>
---
package/busybox/udhcpc.script | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/package/busybox/udhcpc.script b/package/busybox/udhcpc.script
index 50c52e6..d5d81bf 100755
--- a/package/busybox/udhcpc.script
+++ b/package/busybox/udhcpc.script
@@ -61,6 +61,29 @@ case "$1" in
echo adding dns $i
echo "nameserver $i # $interface" >> $RESOLV_CONF
done
+
+ # Based on http://sourceforge.net/p/kboot/mailman/message/1168535/
+ {
+ echo "lease {"
+ echo " interface \"$interface\";"
+ echo " fixed-address $ip;"
+ [ -n "$boot_file" ] && echo " filename \"$boot_file\";"
+ [ -n "$subnet" ] && echo " option subnet-mask $subnet;"
+ [ -n "$router" ] && echo " option routers $router;"
+ echo " option dhcp-lease-time $lease;"
+ echo " option dhcp-message-type $dhcptype;"
+ [ -n "$dns" ] && echo " option domain-name-servers $dns;"
+ echo " option dhcp-server-identifier ${siaddr:-$serverid};"
+ [ -n "$domain" ] && echo " option domain-name \"$domain\";"
+ d=$(expr "$(date "+%Y.%m.%d-%H:%M:%S")" : "\(.*\):")
+ t=$(date -d "$d:$(expr $lease / 2)" "+%w %Y/%m/%d %H:%M:%S" 2>/dev/null)
+ [ -n "$t" ] && echo " renew $t;"
+ t=$(date -d "$d:$(expr 7 '*' $lease / 8)" "+%w %Y/%m/%d %H:%M:%S" 2>/dev/null)
+ [ -n "$t" ] && echo " rebind $t;"
+ t=$(date -d "$d:$lease" "+%w %Y/%m/%d %H:%M:%S" 2>/dev/null)
+ [ -n "$t" ] && echo " expire $t;"
+ echo "}"
+ } >> /var/lib/misc/udhcpc-$interface.leases
;;
esac
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Buildroot] [PATCH 1/1] busybox: udhcpc create leases file
2015-04-30 1:41 [Buildroot] [PATCH 1/1] busybox: udhcpc create leases file Matt Weber
@ 2015-04-30 14:31 ` Peter Korsgaard
2015-04-30 14:48 ` Matthew Weber
0 siblings, 1 reply; 7+ messages in thread
From: Peter Korsgaard @ 2015-04-30 14:31 UTC (permalink / raw)
To: buildroot
>>>>> "Matt" == Matt Weber <matt@thewebers.ws> writes:
> Signed-off-by: Matt Weber <matt@thewebers.ws>
> ---
> package/busybox/udhcpc.script | 23 +++++++++++++++++++++++
> 1 file changed, 23 insertions(+)
> diff --git a/package/busybox/udhcpc.script b/package/busybox/udhcpc.script
> index 50c52e6..d5d81bf 100755
> --- a/package/busybox/udhcpc.script
> +++ b/package/busybox/udhcpc.script
> @@ -61,6 +61,29 @@ case "$1" in
> echo adding dns $i
> echo "nameserver $i # $interface" >> $RESOLV_CONF
> done
> +
> + # Based on http://sourceforge.net/p/kboot/mailman/message/1168535/
A more detailed commit message would be good. After looking at that URL
I'm still not quite sure what this is needed for? It doesn't seem to be
read again anywhere.
> + } >> /var/lib/misc/udhcpc-$interface.leases
Are you sure this should append the file and not overwrite it? Why would
you want to keep older lease info around when you receive a new one?
Perhaps this belongs in a hook in your rootfs overlay?
--
Bye, Peter Korsgaard
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Buildroot] [PATCH 1/1] busybox: udhcpc create leases file
2015-04-30 14:31 ` Peter Korsgaard
@ 2015-04-30 14:48 ` Matthew Weber
2015-04-30 14:59 ` Peter Korsgaard
0 siblings, 1 reply; 7+ messages in thread
From: Matthew Weber @ 2015-04-30 14:48 UTC (permalink / raw)
To: buildroot
Peter,
On Thu, Apr 30, 2015 at 9:31 AM, Peter Korsgaard <peter@korsgaard.com> wrote:
>>>>>> "Matt" == Matt Weber <matt@thewebers.ws> writes:
>
> > Signed-off-by: Matt Weber <matt@thewebers.ws>
> > ---
> > package/busybox/udhcpc.script | 23 +++++++++++++++++++++++
> > 1 file changed, 23 insertions(+)
>
> > diff --git a/package/busybox/udhcpc.script b/package/busybox/udhcpc.script
> > index 50c52e6..d5d81bf 100755
> > --- a/package/busybox/udhcpc.script
> > +++ b/package/busybox/udhcpc.script
> > @@ -61,6 +61,29 @@ case "$1" in
> > echo adding dns $i
> > echo "nameserver $i # $interface" >> $RESOLV_CONF
> > done
> > +
> > + # Based on http://sourceforge.net/p/kboot/mailman/message/1168535/
>
> A more detailed commit message would be good. After looking at that URL
> I'm still not quite sure what this is needed for? It doesn't seem to be
> read again anywhere.
Sorry, I can add that. In general, it adds the leases functionality
that mimics full dhclient behavior. This file can then be used at a
system level to know least expiration and other server provided
information.
>
>> + } >> /var/lib/misc/udhcpc-$interface.leases
>
> Are you sure this should append the file and not overwrite it? Why would
> you want to keep older lease info around when you receive a new one?
I just mimic'd dhclient but I could see in a embedded space you might
only want to keep the latest and when a lease expires, removing this
file. I think the full client usually used this file to set an
interface after reboot to the previous lease if one was still valid.
I wasn't going to keep this behavior since for embedded devices it
doesn't make sense.
>
> Perhaps this belongs in a hook in your rootfs overlay?
Right now there isn't any way to get dhcp lease information after a
lease is provided. It seemed this should be a standard capability of
the script. I do agree I should make it not append and clean up when
there isnt' a lease.
Thanks for the feedback!
--
Matthew L Weber / Pr Software Engineer
Airborne Information Systems / Security Systems and Software / Secure Platforms
MS 131-100, C Ave NE, Cedar Rapids, IA, 52498, USA
www.rockwellcollins.com
Note: Any Export License Required Information and License Restricted
Third Party Intellectual Property (TPIP) content must be encrypted and
sent to matthew.weber at corp.rockwellcollins.com.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Buildroot] [PATCH 1/1] busybox: udhcpc create leases file
2015-04-30 14:48 ` Matthew Weber
@ 2015-04-30 14:59 ` Peter Korsgaard
2015-04-30 16:23 ` Matthew Weber
2015-04-30 20:03 ` Arnout Vandecappelle
0 siblings, 2 replies; 7+ messages in thread
From: Peter Korsgaard @ 2015-04-30 14:59 UTC (permalink / raw)
To: buildroot
>>>>> "Matthew" == Matthew Weber <matthew.weber@rockwellcollins.com> writes:
Hi,
>> > + # Based on http://sourceforge.net/p/kboot/mailman/message/1168535/
>>
>> A more detailed commit message would be good. After looking at that URL
>> I'm still not quite sure what this is needed for? It doesn't seem to be
>> read again anywhere.
> Sorry, I can add that. In general, it adds the leases functionality
> that mimics full dhclient behavior. This file can then be used at a
> system level to know least expiration and other server provided
> information.
Ok, good. Is that really something we want to enforce for everyone using
udhcpc with Buildroot?
>>> + } >> /var/lib/misc/udhcpc-$interface.leases
>>
>> Are you sure this should append the file and not overwrite it? Why would
>> you want to keep older lease info around when you receive a new one?
> I just mimic'd dhclient but I could see in a embedded space you might
> only want to keep the latest and when a lease expires, removing this
> file. I think the full client usually used this file to set an
> interface after reboot to the previous lease if one was still valid.
> I wasn't going to keep this behavior since for embedded devices it
> doesn't make sense.
Ok.
>>
>> Perhaps this belongs in a hook in your rootfs overlay?
> Right now there isn't any way to get dhcp lease information after a
> lease is provided. It seemed this should be a standard capability of
> the script. I do agree I should make it not append and clean up when
> there isnt' a lease.
I'm still not convinced this isn't something that belongs in a project
specific rootfs overlay instead. That's part of the reason why we now
support custom hooks in the udhcpc script.
--
Venlig hilsen,
Peter Korsgaard
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Buildroot] [PATCH 1/1] busybox: udhcpc create leases file
2015-04-30 14:59 ` Peter Korsgaard
@ 2015-04-30 16:23 ` Matthew Weber
2015-04-30 20:03 ` Arnout Vandecappelle
1 sibling, 0 replies; 7+ messages in thread
From: Matthew Weber @ 2015-04-30 16:23 UTC (permalink / raw)
To: buildroot
Peter,
On Thu, Apr 30, 2015 at 9:59 AM, Peter Korsgaard <peter@korsgaard.com> wrote:
>>>>>> "Matthew" == Matthew Weber <matthew.weber@rockwellcollins.com> writes:
>
> Hi,
>
> >> > + # Based on http://sourceforge.net/p/kboot/mailman/message/1168535/
> >>
> >> A more detailed commit message would be good. After looking at that URL
> >> I'm still not quite sure what this is needed for? It doesn't seem to be
> >> read again anywhere.
>
> > Sorry, I can add that. In general, it adds the leases functionality
> > that mimics full dhclient behavior. This file can then be used at a
> > system level to know least expiration and other server provided
> > information.
>
> Ok, good. Is that really something we want to enforce for everyone using
> udhcpc with Buildroot?
Possibly not. I'm good with doing a hook script for now. Half of my
sending this patch in was to just publish the concept if anyone else
wants to use/add to it.
Thanks!
--
Matthew L Weber / Pr Software Engineer
Airborne Information Systems / Security Systems and Software / Secure Platforms
MS 131-100, C Ave NE, Cedar Rapids, IA, 52498, USA
www.rockwellcollins.com
Note: Any Export License Required Information and License Restricted
Third Party Intellectual Property (TPIP) content must be encrypted and
sent to matthew.weber at corp.rockwellcollins.com.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Buildroot] [PATCH 1/1] busybox: udhcpc create leases file
2015-04-30 14:59 ` Peter Korsgaard
2015-04-30 16:23 ` Matthew Weber
@ 2015-04-30 20:03 ` Arnout Vandecappelle
2015-05-01 21:13 ` Peter Korsgaard
1 sibling, 1 reply; 7+ messages in thread
From: Arnout Vandecappelle @ 2015-04-30 20:03 UTC (permalink / raw)
To: buildroot
On 04/30/15 16:59, Peter Korsgaard wrote:
>>>>>> "Matthew" == Matthew Weber <matthew.weber@rockwellcollins.com> writes:
>
> Hi,
>
> >> > + # Based on http://sourceforge.net/p/kboot/mailman/message/1168535/
> >>
> >> A more detailed commit message would be good. After looking at that URL
> >> I'm still not quite sure what this is needed for? It doesn't seem to be
> >> read again anywhere.
>
> > Sorry, I can add that. In general, it adds the leases functionality
> > that mimics full dhclient behavior. This file can then be used at a
> > system level to know least expiration and other server provided
> > information.
>
> Ok, good. Is that really something we want to enforce for everyone using
> udhcpc with Buildroot?
I don't see why not. It's creating a small file in /tmp, that's all. Except for
the appending, of course, otherwise a long-running system could just fill up
/tmp with leases. Overwriting has the disadvantage that there's a race condition
when the file is truncated at the same time that another process is reading from
it, but I don't think the complexity of fixing that race is worth the bother.
Regards,
Arnout
>
> >>> + } >> /var/lib/misc/udhcpc-$interface.leases
> >>
> >> Are you sure this should append the file and not overwrite it? Why would
> >> you want to keep older lease info around when you receive a new one?
>
> > I just mimic'd dhclient but I could see in a embedded space you might
> > only want to keep the latest and when a lease expires, removing this
> > file. I think the full client usually used this file to set an
> > interface after reboot to the previous lease if one was still valid.
> > I wasn't going to keep this behavior since for embedded devices it
> > doesn't make sense.
>
> Ok.
>
> >>
> >> Perhaps this belongs in a hook in your rootfs overlay?
>
> > Right now there isn't any way to get dhcp lease information after a
> > lease is provided. It seemed this should be a standard capability of
> > the script. I do agree I should make it not append and clean up when
> > there isnt' a lease.
>
> I'm still not convinced this isn't something that belongs in a project
> specific rootfs overlay instead. That's part of the reason why we now
> support custom hooks in the udhcpc script.
>
--
Arnout Vandecappelle arnout at mind be
Senior Embedded Software Architect +32-16-286500
Essensium/Mind http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint: 7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Buildroot] [PATCH 1/1] busybox: udhcpc create leases file
2015-04-30 20:03 ` Arnout Vandecappelle
@ 2015-05-01 21:13 ` Peter Korsgaard
0 siblings, 0 replies; 7+ messages in thread
From: Peter Korsgaard @ 2015-05-01 21:13 UTC (permalink / raw)
To: buildroot
>>>>> "Arnout" == Arnout Vandecappelle <arnout@mind.be> writes:
Hi,
>> > Sorry, I can add that. In general, it adds the leases functionality
>> > that mimics full dhclient behavior. This file can then be used at a
>> > system level to know least expiration and other server provided
>> > information.
>>
>> Ok, good. Is that really something we want to enforce for everyone using
>> udhcpc with Buildroot?
> I don't see why not. It's creating a small file in /tmp, that's all. Except for
> the appending, of course, otherwise a long-running system could just fill up
> /tmp with leases. Overwriting has the disadvantage that there's a race condition
> when the file is truncated at the same time that another process is reading from
> it, but I don't think the complexity of fixing that race is worth the bother.
True. I would like to see this (and other non-essential things like
E.G. avahi-autoipd) move to hooks though.
I wonder if the dhclient format is a sensible choice. Is that something
any "standard" programs can work with? It doesn't seem very easy to
parse in shell scripts. Maybe just shell compatible NAME="<val>" strings
would be better?
--
Venlig hilsen,
Peter Korsgaard
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-05-01 21:13 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-30 1:41 [Buildroot] [PATCH 1/1] busybox: udhcpc create leases file Matt Weber
2015-04-30 14:31 ` Peter Korsgaard
2015-04-30 14:48 ` Matthew Weber
2015-04-30 14:59 ` Peter Korsgaard
2015-04-30 16:23 ` Matthew Weber
2015-04-30 20:03 ` Arnout Vandecappelle
2015-05-01 21:13 ` Peter Korsgaard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox