aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorVladimir Isaev <visaev@netgate.com>2020-07-16 17:05:18 +0300
committerMatthew Smith <mgsmith@netgate.com>2020-07-31 16:02:49 +0000
commitb2f44bd8e7d226d851d4d05981914e642a4da571 (patch)
treed9e1c242be1860237ce5d2c10f9d53c99085df9f /src/vnet
parent5d27037d165ce55dd80aa472a367923d6a08f755 (diff)
ip-neighbor: Allow to replace dynamic entry
Before this patch it was not allowed to replace a dynamic ARP entry with a static one with the same mac-address. Type: fix Signed-off-by: Vladimir Isaev <visaev@netgate.com> Change-Id: I6cfc0e510ffdf141c61874288f11a60395182374
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/ip-neighbor/ip_neighbor.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/vnet/ip-neighbor/ip_neighbor.c b/src/vnet/ip-neighbor/ip_neighbor.c
index 09b56058f72..4111b02d0d8 100644
--- a/src/vnet/ip-neighbor/ip_neighbor.c
+++ b/src/vnet/ip-neighbor/ip_neighbor.c
@@ -141,6 +141,8 @@ ip_neighbor_list_remove (ip_neighbor_t * ipn)
elt = pool_elt_at_index (ip_neighbor_elt_pool, ipn->ipn_elt);
clib_llist_remove (ip_neighbor_elt_pool, ipne_anchor, elt);
+
+ ipn->ipn_elt = ~0;
}
}
@@ -492,6 +494,17 @@ ip_neighbor_add (const ip46_address_t * ip,
return -2;
}
+ /* A dynamic entry can become static, but not vice-versa.
+ * i.e. since if it was programmed by the CP then it must
+ * be removed by the CP */
+ if ((flags & IP_NEIGHBOR_FLAG_STATIC) &&
+ !(ipn->ipn_flags & IP_NEIGHBOR_FLAG_STATIC))
+ {
+ ip_neighbor_list_remove (ipn);
+ ipn->ipn_flags |= IP_NEIGHBOR_FLAG_STATIC;
+ ipn->ipn_flags &= ~IP_NEIGHBOR_FLAG_DYNAMIC;
+ }
+
/*
* prevent a DoS attack from the data-plane that
* spams us with no-op updates to the MAC address
@@ -503,17 +516,6 @@ ip_neighbor_add (const ip46_address_t * ip,
}
mac_address_copy (&ipn->ipn_mac, mac);
-
- /* A dynamic entry can become static, but not vice-versa.
- * i.e. since if it was programmed by the CP then it must
- * be removed by the CP */
- if ((flags & IP_NEIGHBOR_FLAG_STATIC) &&
- !(ipn->ipn_flags & IP_NEIGHBOR_FLAG_STATIC))
- {
- ip_neighbor_list_remove (ipn);
- ipn->ipn_flags |= IP_NEIGHBOR_FLAG_STATIC;
- ipn->ipn_flags &= ~IP_NEIGHBOR_FLAG_DYNAMIC;
- }
}
else
{