[Click] AGNOSTIC vs. PUSH/PULL
Eddie Kohler
kohler at cs.ucla.edu
Tue Mar 2 13:00:12 EST 2010
Jesse,
We have very few elements that behave as you describe: N inputs and N outputs,
and all packets from input N are emitted on output N. For that reason I don't
think it's worthwhile to change the default push() and pull() behavior.
simple_action() is after all meant to be simple.
Your element sounds like it wants the following definition:
elementclass Foo {
...
const char *flow_code() const { return "#/#"; }
...
void push(int port, Packet *p) {
if ((p = simple_action(p)))
output(port).push(p);
}
Packet *pull(int port) {
Packet *p = input(port).pull();
if (p)
p = simple_action(p);
return p;
}
};
Note the flow_code(). Without the flow_code(), Click will believe that
packets arriving on any port could be emitted on any port, and you won't get
the agnostic behavior you might expect.
Eddie
Jesse Brown wrote:
> All:
>
> I am currently working on a router config that looks similar to the
> following:
>
> elementclass Monitor {
> input ->
> ipc :: IPClassifier (tcp, udp, icmp, -);
> f :: Foo;
>
> ipc[0] -> Print("tcp-in") -> [0]f[0] -> Print("tcp-out") -> output;
> ipc[1] -> Print("udp-in") -> [1]f[1] -> Print("udp-out") -> output;
> ipc[2] -> Print("icmp-in") -> [2]f[2] -> Print("icmp-out") -> output;
> ipc[3] -> Print("other-in") -> [3]f[3] -> Print("other-out") ->
> output;
> }
>
> FromDevice(eth0, PROMISC true) ->
> ... ->
> Monitor ->
> ... ->
> Queue -> ToDevice(eth1);
>
>
> This is obviously simplified but conveys my point, I think.
> If I define Foo as
> const char *class_name() const { return "Foo"; }
> const char *port_count() const { return "-/-"; }
> const char *processing() const { return AGNOSTIC; }
>
> Packet *simple_action(Packet *);
>
> Then I will always get
>
> icmp-in: 98 | 00151715 a8e50015 17163621 08004500 00540000 40004001
> tcp-out: 98 | 00151715 a8e50015 17163621 08004500 00540000 40004001
>
> Due to how Element::push behaves.
>
> In order to have a single copy of this element that can be located
> anywhere in a router I have to define Foo::simple_action, Foo::pull, and
> Foo::push. Is there a more standard way to get the behavior I am after?
> My desired result would look like:
>
> icmp-in: 98 | 00151715 a8e50015 17163621 08004500 00540000 40004001
> icmp-out: 98 | 00151715 a8e50015 17163621 08004500 00540000 40004001
>
> in the above example.
>
> Also, is there a reason that both Element::push and Element::pull ignore
> the port by default? Would the attached patch break existing behavior?
>
> Thanks,
>
> Jesse
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> click mailing list
> click at amsterdam.lcs.mit.edu
> https://amsterdam.lcs.mit.edu/mailman/listinfo/click
More information about the click
mailing list