Execute Based Class Matching

Jeffrey Hutzelman jhutz at cmu.edu
Wed Jan 28 04:00:13 UTC 2009


--On Wednesday, January 28, 2009 02:51:15 AM +0000 Patricio Latini 
<p_latini at hotmail.com> wrote:

> The problem i have seen with using subclasses for this is how flexible
> and dynamic the could be, for instance if I want to match agent.remote-id
> of an incoming packet with the hardware address of an existing client
> (subclass) to see if the packet is passing though a "known" device, i
> have two keep to subclass tables, one for the hardware of the device and
> other for the agent.remote-id of the client both containing virtually the
> same info.

Oh, that's unfortunate.  You essentially want to match two different 
expressions against the same hash table.  I'm pretty sure this doesn't work 
today, but I don't see why the server couldn't be extended to allow a 
parent class to contain more than one "match" (not "match if") statement, 
with the semantics that each expression is evaluated and looked up, and the 
class matches if any of the lookups succeed.



> With this approach, with small changes to the return
> parser (accept full strings instead of just integers)

Except that's not a small change; it discards the exit status of a command 
(which, among other things, tells us whether it succeeded) in favor of its 
output.  That may be desirable for some cases, but I wouldn't advocate 
changing the existing semantics of execute().


> Regading how to improve this,
> in order to reduce the number of execute() statements, i have been trying
> to make a set myvalue=execute(...); match if (myvalue=x); in the first
> subclass; and then if the following classes are related (that they use
> the same execute parameters), just do the match if (myvalue=x).

That approach won't work, because those lines don't run in the order you 
think they do.  "set" is an executable statement and is processed fairly 
late, after we've determined that the client is a member of the class (and 
that we're going to give it a lease, and for what address).  The "match if" 
is _not_ an executable statement; it's a special property of the class, and 
the expression is evaluated when deciding whether the client is a member of 
that class.

-- Jeff



More information about the dhcp-users mailing list