L4Re Operating System Framework
Interface and Usage Documentation
Loading...
Searching...
No Matches
Mac_table< Size > Class Template Reference

Mac_table manages a 1:n association between ports and MAC addresses. More...

#include <mac_table.h>

+ Collaboration diagram for Mac_table< Size >:

Public Member Functions

Virtio_portlookup (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.
 

Detailed Description

template<std::size_t Size = 1024U>
class Mac_table< Size >

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.

Member Function Documentation

◆ flush()

template<std::size_t Size = 1024U>
void Mac_table< Size >::flush ( Virtio_port port)
inline

Flush all associations with a given port.

Parameters
portPointer 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().

+ Here is the caller graph for this function:

◆ learn()

template<std::size_t Size = 1024U>
void Mac_table< Size >::learn ( Mac_addr  src,
Virtio_port port 
)
inline

Learn a MAC address (add it to the MAC table).

Parameters
srcMAC address
portPointer 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().

+ Here is the call graph for this function:

◆ lookup()

template<std::size_t Size = 1024U>
Virtio_port * Mac_table< Size >::lookup ( Mac_addr  dst) const
inline

Find the destination port for a MAC address.

Parameters
dstMAC address
Return values
nullptrThe MAC address is not known (yet)
otherPointer to the destination port

Definition at line 56 of file mac_table.h.

Referenced by Mac_table< Size >::learn().

+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: