dhcpd user/vendor class support

Denys Vlasenko vda.linux at googlemail.com
Fri Oct 1 22:19:06 UTC 2010


On Tuesday 07 September 2010 11:16, Smith Will wrote:
> On Mon, Sep 6, 2010 at 7:48 PM, Denys Vlasenko <vda.linux at googlemail.com> wrote:
> > On Mon, Sep 6, 2010 at 4:07 PM, Smith Will <smith.rday at gmail.com> wrote:
> >> On Mon, Sep 6, 2010 at 5:17 PM, Denys Vlasenko <vda.linux at googlemail.com> wrote:
> >> > On Mon, Sep 6, 2010 at 11:14 AM, Smith Will <smith.rday at gmail.com> wrote:
> >> >> Hi list,
> >> >> Seems dhcp server within busybox does not yet has support for
> >> >> interpreting user/vendor classes. I checked code for busybox-1.17.2
> >> >
> >> > What do you mean by "interpreting"?
> >> >
> >> Means if the busybox dhcp server understands these options.. :)
> >
> > Aha, you want udhcpd to _analyze_ options sent by clients.
> >
> Correct.
> 
> >> >> Did i miss something or this feature hasnt been looked into yet?
> >> >
> >> > It is somewhat hard to spot. Look into examples/udhcp/udhcpd.conf
> >> > file:
> >> >
> >> > ...
> >> > # Arbitrary option in hex form:
> >> > option  0x08    01020304        # option 8: "cookie server IP addr: 1.2.3.4"
> >> > ...
> >> >
> >> > Basically, if you want udhcpd to advertise an option and it is not
> >> > supported by name, you can still add it with the above format.
> >> > For vendor info element, you need to use
> >> >
> >> > option 0x2b <hex string>
> >>
> >> Ok, i have this scenario:
> >>
> >> I use ISC dhclient ( version 3.1.1) and within my dhclient.conf i use
> >> " send user-class "busybox-dhcp" ".
> >> My intention is that busybox dhcp server assigns me one of the address
> >> from non-default/non-global pool of addresses ( as an example, default
> >> pool can be 192.168.1.50 to 192.168.1.100 while for the "busybox-dhcp"
> >> user class, i would want udhcpd from busybox to give out an address
> >> from 192.168.1.150 to 192.168.1.200).Is this possible?
> >> Within /etc/udhcpd.conf, i can use "start 192.168.1.50" and "end
> >> 192.168.1.100" for default pool but for the user class pool of
> >> "busybox-dhcp", how do i specify?
> >
> > udhcpd can not send options selectively.
> >
> >
> >> option 0x4d < how do i specify the other pool name and range? >
> >
> > option directive simply adds (or replaces) options to the set of options
> > sent by udhcpd in replies to DHCPDISCOVER/DHCPREQUEST packets
> > from clients.
> >
> > That is,
> >
> > option 0x4d 1122334455
> >
> > means "among other options, send option with code 0x4d, length 5
> > and contents 1122334455".
> >
> > There is no way to specify "add this option only if some conditions are met".
>
> Hmm..But wouldnt it be nice if this feature is also supported by busybox udhcpd?

It can be useful for some users.

> I looked at couple of other servers ( ISC and dnsmasq) who support
> these kind of features.
> While the ISC one have braces ( { and } to define classes or in
> general to identify different "sections" within the configuration
> file) while the dnsmasq seems to rely on one liner with delimiters
> (,=).
> 
> Some thoughts to start with user class support for udhcpd:
> 
> 1. Have like this in udhcpd.conf:
> =======================================
> option userclass <start-address>: <end-address>:<max-leases>
> ========================================
> 
> ":" is just an example but this could be anything.
> This aprroach is similar to dnsmasq.

This syntax doesn't specify what userclass option value(s) from clients
should result in specified <start-address>: <end-address>:<max-leases>
being used.


> 2. Have like this in udhcpd.conf:
> 
> =======================
> option userclass start
> 
> start < start-address>
> end   <end-addresses>
> max_leases <num>
> 
> option userclass end
> ========================

This makes more sense because it allows more things to be per-block.
But I still don't see where do you specify userclass value.
I'd expect something like:

if userclass = "Printer" then
  start <start-address>
  end   <end-addresses>
  max_leases <num>
endif

if hostname = "baduser" then
  start 0.0.0.0
  end   0.0.0.0
  max_leases 0
endif

This would be very generic (but complex to implement)

> The first approach requires special handling within "udhcp_str2optset"
> function but a need to re-invent the method of specfiying parameters
> and their order arises ( with ":" ) ?
> 
> The second approach gives an advantage of the fact that the parameters
> can be _exactly_ used within class as like we do globally. We just
> treat a class as a sub-set of "keywords".But needs special handling
> within "read_config" ?
> 
> First of all, does extending udhcpd in this way makes sense?

Yes.

> If it does, do the above approaches make sense or there is any simpler approach?

Offload it to a shell script and use its exit code or stdout
as a differentiator which set of parameters to use?


udhcpd.conf
===========

# Runs with environment variables set to match client's options
# (udhcpc currently does similar thing on client side):
analyzer_script  /path/to/script

# Default: used if analyzer_script exited 0
start <start-address>
end   <end-addresses>
max_leases <num>

# used if analyzer_script exited 1
group 1
 start <start-address>
 end   <end-addresses>
 max_leases <num>
 ...
endgroup

# used if analyzer_script exited 2
group 2
 start <start-address>
 end   <end-addresses>
 max_leases <num>
 ...
endgroup

# else: if analyzer_script exited >2, then lease is not provided



-- 
vda


More information about the busybox mailing list