Commit 51b08025 authored by Maciej Lipinski's avatar Maciej Lipinski Committed by Alessandro Rubini

[rtud] added possibility of adding MAC entry for multi-path (prepare for TRU)

parent 15fa9a48
......@@ -194,7 +194,7 @@ static int htab_count_buckets(struct rtu_addr addr)
* @param dynamic it indicates whether it's a dynamic entry
* @return 0 if entry was created or updated. -ENOMEM if no space is available.
*/
int rtu_fd_create_entry(uint8_t mac[ETH_ALEN], uint16_t vid, uint32_t port_mask, int dynamic)
int rtu_fd_create_entry(uint8_t mac[ETH_ALEN], uint16_t vid, uint32_t port_mask, int dynamic, int at_existing_entry)
{
struct filtering_entry *ent; // pointer to scan hashtable
uint8_t fid; // Filtering database identifier
......@@ -214,7 +214,10 @@ int rtu_fd_create_entry(uint8_t mac[ETH_ALEN], uint16_t vid, uint32_t port_mask,
{
TRACE_DBG(TRACE_INFO, "Entry for mac %s already found.", mac_to_string(mac));
mask_dst = port_mask; //ML: aging bugfix-> if we receive ureq for an existing entry,
if(at_existing_entry == ADD_TO_EXISTING) // enable multipath for redundancy
mask_dst = port_mask | ent->port_mask_dst ;
else
mask_dst = port_mask; //ML: aging bugfix-> if we receive ureq for an existing entry,
//it means that the port moved, so we override the existing mask...
mask_src = 0xFFFFFFFF;//ML: filtering on ingress is optional according to 802.1Q-2012
//by default it should not happen. TODO: add optional config
......
......@@ -39,6 +39,14 @@
// Filtering entries may be static (permanent) or dynamic (learned)
#define STATIC 0
#define DYNAMIC 1
// Tells the rtu_fd_create_entry() function what to do if MAC entry is added
// and the same MAC is already known to be at some port (coud be the same or different).
// Most of the time we would like to override the entry because the device simply moved
// to different "location" (port) but if we want to have redundant connection, we need to
// actually add this port to the entry and risk having loop in the network (if the TRU is
// not ON)
#define OVERRIDE_EXISTING 0
#define ADD_TO_EXISTING 1
int rtu_fd_init(uint16_t poly, unsigned long aging)
__attribute__((warn_unused_result));
......@@ -47,7 +55,8 @@ int rtu_fd_create_entry(
uint8_t mac[ETH_ALEN],
uint16_t vid,
uint32_t port_map,
int dynamic
int dynamic,
int at_existing_entry
) __attribute__((warn_unused_result));
int rtu_fd_set_aging_time(unsigned long t) __attribute__((warn_unused_result));
......
......@@ -86,7 +86,7 @@ static int rtu_create_static_entries()
TRACE(TRACE_INFO,"adding static routes for slow protocols...");
for(i = 0; i < NUM_RESERVED_ADDR; i++) {
slow_proto_mac[5] = i;
err = rtu_fd_create_entry(slow_proto_mac, 0, (1 << ports.num_physical_ports), STATIC);
err = rtu_fd_create_entry(slow_proto_mac, 0, (1 << ports.num_physical_ports), STATIC, OVERRIDE_EXISTING);
if(err)
return err;
}
......@@ -110,15 +110,15 @@ static int rtu_create_static_entries()
mac_to_string(pstate.hw_addr)
);
err = rtu_fd_create_entry(pstate.hw_addr, 0, (1 << ports.num_physical_ports), STATIC);
err = rtu_fd_create_entry(pstate.hw_addr, 0, (1 << ports.num_physical_ports), STATIC, OVERRIDE_EXISTING);
if(err)
return err;
}
// Broadcast MAC
TRACE(TRACE_INFO,"adding static route for broadcast MAC...");
err = rtu_fd_create_entry(bcast_mac, 0, enabled_port_mask | (1 << ports.num_physical_ports), STATIC);
err = rtu_fd_create_entry(ptp_mcast_mac, 0, (1 << ports.num_physical_ports), STATIC);
err = rtu_fd_create_entry(bcast_mac, 0, enabled_port_mask | (1 << ports.num_physical_ports), STATIC, OVERRIDE_EXISTING);
err = rtu_fd_create_entry(ptp_mcast_mac, 0, (1 << ports.num_physical_ports), STATIC, OVERRIDE_EXISTING);
if(err)
return err;
......@@ -241,7 +241,7 @@ static int rtu_daemon_learning_process()
vid = req.has_vid ? req.vid:0;
port_map = (1 << req.port_id);
// create or update entry at filtering database
err = rtu_fd_create_entry(req.src, vid, port_map, DYNAMIC);
err = rtu_fd_create_entry(req.src, vid, port_map, DYNAMIC, OVERRIDE_EXISTING);
err= 0;
if (err == -ENOMEM) {
// TODO remove oldest entries (802.1D says you MAY do it)
......
......@@ -128,7 +128,7 @@ int rtudexp_add_entry(const struct minipc_pd *pd,
TRACE(TRACE_INFO,"Create entry for (MAC=%s) port %x, mode:%s",mac_to_string(mac_tmp),1 << port,(mode)?"DYNAMIC":"STATIC");
*p_ret=rtu_fd_create_entry(mac_tmp, 0, 1 << port, mode);
*p_ret=rtu_fd_create_entry(mac_tmp, 0, 1 << port, mode, OVERRIDE_EXISTING);
return *p_ret;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment