Commit e143e24a authored by Maciej Lipinski's avatar Maciej Lipinski

[issue #11] Prevent static MAC entries from removing by dynamic entires

If a static entry is in the HASH table, this is for a reason. In the
very unlikely event, when the same MAC is seen on another port,
the static entry should not be overriden by the learned (dynamic).
This was not the case. This commit prevents static MAC entries
from being overriden by dynamic entries.
parent 9c44101b
......@@ -332,7 +332,18 @@ int rtu_fd_create_entry(uint8_t mac[ETH_ALEN], uint16_t vid, uint32_t port_mask,
//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
if ((ent->port_mask_dst != mask_dst)
// Prevent overriding staticly configured entry with
// learned (dynamic) entry. Very marginal case that has
// happened...
if ((at_existing_entry == OVERRIDE_EXISTING_DYNAMIC) &&
ent->dynamic == RTU_ENTRY_TYPE_STATIC &&
dynamic == RTU_ENTRY_TYPE_DYNAMIC){
pr_warning("Prevented updating existing static "
"entry for mac %s with dynamic entry.\n",
mac_to_string(mac));
}
else if ((ent->port_mask_dst != mask_dst)
|| (ent->port_mask_src != mask_src)
|| (ent->dynamic != dynamic)) {
/* new entry */
......
......@@ -40,9 +40,11 @@
// 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
// not ON). On the other hand, if a static entry exists, we might not want to override
// it by dynamic entry.
#define OVERRIDE_EXISTING 0 // either dynamic or static (by config)
#define ADD_TO_EXISTING 1 // to be used for redundancy (with caution)
#define OVERRIDE_EXISTING_DYNAMIC 2 // but not static (by learning)
int rtu_fd_init(uint16_t poly, unsigned long aging)
__attribute__ ((warn_unused_result));
......
......@@ -270,7 +270,7 @@ static int rtu_daemon_learning_process(void)
err =
rtu_fd_create_entry(req.src, vid, port_map,
RTU_ENTRY_TYPE_DYNAMIC,
OVERRIDE_EXISTING);
OVERRIDE_EXISTING_DYNAMIC);
err = 0;
if (err == -ENOMEM) {
// TODO remove oldest entries (802.1D says you MAY do it)
......
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