[Click] Scoping/naming issues

Cliff Frey cliff at meraki.com
Mon Jan 17 22:15:44 EST 2011


You are likely not missing anything.  It is correct that elementclasses, as
they currently work, do not allow you to easily create one elementclass that
fully handles IP packets in one direction.  I was basically encouraging you
to put all IP and ARP packets in both directions in one (fairly large)
elementclass, which contains and ARPQuerier and an ARPResponder.  For
instance, input/output 0 on your element class could be Ethernet frames
from/to eth0, and input/output 1 could be IP packets to the rest of your
click configuration.

So, to expand my example more, you end up with:
elementclass MyNull { input -> output }

// input/output 0: ethernet frames
// input/output 1: IP
elementclass IpToEth {
 $ip, $mac |
  input [0] -> from_enet :: MyNull();
  input [1] -> from_ip :: MyNull();
  to_enet :: MyNull() -> [0] output;
  to_ip :: MyNull() -> [1] output;

  ar :: ARPResponder($ip $mac);
  arpq :: ARPQuerier($ip, $mac);

  from_enet
  -> from_enet_et_cl :: Classifier(12/0800, 12/0806 20/0001, 12/0806
20/0002);

  from_enet_et_cl [0] -> Strip(14) -> check_ip :: CheckIPHeader(0) -> to_ip;
  from_enet_et_cl [1] -> ar -> to_enet;
  from_enet_et_cl [2] -> [1] arpq;

  from_ip -> arpq -> to_enet;
}



On Mon, Jan 17, 2011 at 6:25 PM, Philip Prindeville <
philipp_subx at redfish-solutions.com> wrote:

> Not really sure how your example relates to my problem statement...
>
> In my case, the ARPQuerier() I'm creating has specific state it retains,
> and:
>
> (1) needs to be plumbed into the middle of a pipeline in one other
> elementclass (for IP packets);
> (2) needs to be plumbed to the outputs of several instances of the above
> elementclass (for the ARP packets);
>
> Maybe I'm missing something in what you're saying.
>
>
>
> On 1/17/11 6:09 PM, Cliff Frey wrote:
>
>> I actually really like this property of elementclasses.  Specifically, an
>> elementclass is a substitute for an element.  In cases like you describe
>> Philip, i end up writing configs like:
>>
>> elementclass MyNull { input -> output; }
>>
>> // input/output 0: internet
>> // input/output 1: LAN
>> elementclass MyRouter {
>>  input [0] -> from_inet :: MyNull();
>>  input [1] -> from_lan :: MyNull();
>>  to_inet :: MyNull() -> [0] output;
>>  to_lan :: MyNull() -> [1] output;
>>
>>  from_inet -> Classifier(12/0800, ...)
>>  ...
>> }
>> On Mon, Jan 17, 2011 at 4:55 PM, Philip Prindeville <
>> philipp_subx at redfish-solutions.com <mailto:
>> philipp_subx at redfish-solutions.com>> wrote:
>>
>>    Yeah, it especially makes sense to have arpfoo be global if it needs to
>> be accessible from two different elementclass's, one that deals with the IP
>> flow (input [0] and output [0]) and another one that deals strictly with the
>> ARP request/reply flow (input [1] and output [1]).
>>
>>    Someone else will have to come up with the patches...  I've not yet
>> dabbled in the code itself.
>>
>>
>>    On 1/17/11 4:35 PM, Eddie Kohler wrote:
>>    > Hi Philip,
>>    >
>>    > I can see why you thought compound elements would work that way, but
>> they don't.  They are very strictly encapsulated: all connections to other
>> elements must take place through explicit inputs and outputs.
>>    >
>>    > I admit it would make sense to do it the way you've imagined.
>>  Patches welcome...
>>    >
>>    > Eddie
>>    >
>>    >
>>    > On 1/15/11 2:53 PM, Philip Prindeville wrote:
>>    >> I've got a configuration where I do:
>>    >>
>>    >> ...
>>    >> arpfoo :: ARPQuerier(...);
>>    >>
>>    >> elementclass Bar {
>>    >> ...
>>    >>       class :: classifier(...);
>>    >> ...
>>    >>        class [2] ->   [1] arpfoo;
>>    >> ...
>>    >> }
>>    >>
>>    >>
>>    >> but it complains that "unknown element class 'arpfoo'" in a few
>> places, and that input 1 isn't used...
>>    >>
>>    >> So I'm confused.  Everything is scoped globally... even stuff
>> defined within an elementclass gets scoped globally.
>>    >>
>>    >> Why then can't I access a global variable from within an
>> elementclass's scope?
>>    >>
>>    >> What am I missing?
>>    >>
>>    >> Thanks,
>>    >>
>>    >> -Philip
>>
>>
>


More information about the click mailing list