aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Lo <loj@cisco.com>2016-07-05 18:34:40 -0400
committerDave Barach <openvpp@barachs.net>2016-07-06 14:02:21 +0000
commitcbec1a18e2538b0dd808f22b6b53a71e8bf285fd (patch)
tree09a9e0ae7b24c7df9d806937a27a92eb77f26c9a
parent141977f60d85c7a9ff1c422843b0c6dbf77fa498 (diff)
VPP-182: IPv4 static ARP entries should not be deleted on interface down
IPv4 static ARP entries should remain when interface is set admin-down and be reapplied on interface admin-up. Change-Id: Ic0051865154230c2561d6e6421b05d842f147ca7 Signed-off-by: John Lo <loj@cisco.com>
-rw-r--r--vnet/vnet/ethernet/arp.c43
1 files changed, 24 insertions, 19 deletions
diff --git a/vnet/vnet/ethernet/arp.c b/vnet/vnet/ethernet/arp.c
index fa13d52603b..68642d1798d 100644
--- a/vnet/vnet/ethernet/arp.c
+++ b/vnet/vnet/ethernet/arp.c
@@ -263,31 +263,36 @@ ethernet_arp_sw_interface_up_down (vnet_main_t * vnm,
{
ethernet_arp_main_t * am = &ethernet_arp_main;
ethernet_arp_ip4_entry_t * e;
+ u32 i;
+ u32 * to_add_del = 0;
- if (! (flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP))
- {
- u32 i, * to_delete = 0;
-
- pool_foreach (e, am->ip4_entry_pool, ({
- if (e->key.sw_if_index == sw_if_index)
- vec_add1 (to_delete, e - am->ip4_entry_pool);
- }));
+ pool_foreach (e, am->ip4_entry_pool, ({
+ if (e->key.sw_if_index == sw_if_index)
+ vec_add1 (to_add_del, e - am->ip4_entry_pool);
+ }));
- for (i = 0; i < vec_len (to_delete); i++)
- {
- ethernet_arp_ip4_over_ethernet_address_t delme;
- e = pool_elt_at_index (am->ip4_entry_pool, to_delete[i]);
+ for (i = 0; i < vec_len (to_add_del); i++)
+ {
+ ethernet_arp_ip4_over_ethernet_address_t arp_add;
+ e = pool_elt_at_index (am->ip4_entry_pool, to_add_del[i]);
- clib_memcpy (&delme.ethernet, e->ethernet_address, 6);
- delme.ip4.as_u32 = e->key.ip4_address.as_u32;
+ clib_memcpy (&arp_add.ethernet, e->ethernet_address, 6);
+ arp_add.ip4.as_u32 = e->key.ip4_address.as_u32;
- vnet_arp_unset_ip4_over_ethernet (vnm, e->key.sw_if_index,
- e->key.fib_index, &delme);
- }
-
- vec_free (to_delete);
+ if (flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP)
+ {
+ vnet_arp_set_ip4_over_ethernet (vnm,
+ e->key.sw_if_index, e->key.fib_index, &arp_add,
+ e->flags & ETHERNET_ARP_IP4_ENTRY_FLAG_STATIC);
+ }
+ else if ((e->flags & ETHERNET_ARP_IP4_ENTRY_FLAG_STATIC) == 0)
+ {
+ vnet_arp_unset_ip4_over_ethernet (vnm,
+ e->key.sw_if_index, e->key.fib_index, &arp_add);
+ }
}
+ vec_free (to_add_del);
return 0;
}