![]() |
L4Re Operating System Framework
Interface and Usage Documentation
|
Mac_table manages a 1:n association between ports and MAC addresses. More...
#include <mac_table.h>
Public Member Functions | |
Virtio_port * | lookup (Mac_addr dst) const |
Find the destination port for a MAC address. | |
void | learn (Mac_addr src, Virtio_port *port) |
Learn a MAC address (add it to the MAC table). | |
void | flush (Virtio_port *port) |
Flush all associations with a given port. | |
Mac_table manages a 1:n association between ports and MAC addresses.
There are different types of devices which might be attached to a port. For a normal device the switch sees exactly one MAC address per port - the MAC address of the device attached to it. But there might be other devices like software bridges attached to the port sending packets with different MAC addresses to the port. Therefore the switch has to manage a 1:n association between ports and MAC addresses. The MAC table manages this association.
When a packet comes in we need to find the destination port for the packet and therefore perform a lookup based on the MAC address.
To prevent unbounded grow of the lookup table the number of entries is limited. Replacement is done on a round-robin basis. If the capacity was reached the oldest entry is evicted.
Definition at line 39 of file mac_table.h.
|
inline |
Flush all associations with a given port.
port | Pointer to port that is to be flushed |
This function removes all references to a given port from the MAC table. Since we manage a 1:n association between ports and MAC addresses there might be more than one entry for a given port and we have to iterate over the whole array to delete every reference to the port.
Definition at line 122 of file mac_table.h.
Referenced by Virtio_switch::check_ports().
|
inline |
Learn a MAC address (add it to the MAC table).
src | MAC address |
port | Pointer to the port object that can be used to reach MAC address src |
Will evict the oldest learned address from the table if the maximum capacity was reached and if the MAC address was not known yet. The source port of the table entry is always updated to cope with clients that move between ports.
Definition at line 74 of file mac_table.h.
References L4_UNLIKELY, and Mac_table< Size >::lookup().
|
inline |
Find the destination port for a MAC address.
dst | MAC address |
nullptr | The MAC address is not known (yet) |
other | Pointer to the destination port |
Definition at line 56 of file mac_table.h.
Referenced by Mac_table< Size >::learn().