Skip to content
Tom Barbette edited this page Oct 3, 2018 · 2 revisions

LinearIPLookup Element Documentation

NAME

LinearIPLookup — Click element; simple IP routing table

SYNOPSIS

LinearIPLookup(ADDR1/MASK1 [GW1] OUT1, ADDR2/MASK2 [GW2] OUT2, ...)

Ports: 1 input, any number of outputs
Processing: push

DESCRIPTION

Note: Lookups and table updates with LinearIPLookup are extremely slow; the RadixIPLookup and DirectIPLookup elements should be preferred in almost all cases. See IPRouteTable for a performance comparison. We provide LinearIPLookup nevertheless for its simplicity.

Expects a destination IP address annotation with each packet. Looks up that address in its routing table, using longest-prefix-match, sets the destination annotation to the corresponding GW (if specified), and emits the packet on the indicated OUTput port.

Each argument is a route, specifying a destination and mask, an optional gateway IP address, and an output port.

LinearIPLookup uses a linear search algorithm that may look at every route on each packet. It is therefore most suitable for small routing tables.

EXAMPLES

This example delivers broadcasts and packets addressed to the local host (18.26.4.24) to itself, packets to net 18.26.4 to the local interface, and all others via gateway 18.26.4.1:

  ... -> GetIPAddress(16) -> rt;
  rt :: LinearIPLookup(18.26.4.24/32 0,
                       18.26.4.255/32 0,
                       18.26.4.0/32 0,
                       18.26.4/24 1,
                       0/0 18.26.4.1 1);
  rt[0] -> ToHost;
  rt[1] -> ... -> ToDevice(eth0);

ELEMENT HANDLERS

  • table (read-only) — Outputs a human-readable version of the current routing table.
  • lookup (read-only) — Reports the OUTput port and GW corresponding to an address.
  • add (write-only) — Adds a route to the table. Format should be `ADDR/MASK [GW] OUT'. Fails if a route for ADDR/MASK already exists.
  • set (write-only) — Sets a route, whether or not a route for the same prefix already exists.
  • remove (write-only) — Removes a route from the table. Format should be `ADDR/MASK'.
  • ctrl (write-only) — Adds or removes a group of routes. Write `add/set ADDR/MASK [GW] OUT' to add a route, and `remove ADDR/MASK' to remove a route. You can supply multiple commands, one per line; all commands are executed as one atomic operation.

SEE ALSO

RadixIPLookup, DirectIPLookup, RangeIPLookup, StaticIPLookup, SortedIPLookup, LinuxIPLookup, IPRouteTable

Generated by click-elem2man from ../elements/ip/lineariplookup.hh:7 on 2018/10/03.

Clone this wiki locally