![]() |
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 | |
Port_iface * | lookup (Mac_addr dst, l4_uint16_t vlan_id) const |
Find the destination port for a MAC address and VLAN id. | |
void | learn (Mac_addr src, Port_iface *port, l4_uint16_t vlan_id) |
Learn a MAC address (add it to the MAC table). | |
void | flush (Port_iface *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 growth 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 40 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 129 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 |
vlan_id | VLAN id of the packet destination. |
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 78 of file mac_table.h.
References L4_UNLIKELY, and Mac_table< Size >::lookup().
|
inline |
Find the destination port for a MAC address and VLAN id.
dst | MAC address |
vlan_id | VLAN id |
nullptr | The MAC address is not known (yet) |
other | Pointer to the destination port |
Definition at line 58 of file mac_table.h.
Referenced by Mac_table< Size >::learn().