summaryrefslogtreecommitdiffstats
path: root/src/vnet/ip/ip_neighbor.c
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2018-08-10 05:30:06 -0700
committerDamjan Marion <dmarion@me.com>2019-01-30 19:47:53 +0000
commit37029305c671f4e2d091d6f6c22142634e409043 (patch)
treef47257c77b860213fcd1901686874dee43ad1f73 /src/vnet/ip/ip_neighbor.c
parent13b2ba2ad5527c8185dce368993a3877e7daf7a2 (diff)
Use IP and MAC API types for neighbors
use address_t and mac_address_t for IPv6 and ARP entries and all other API calls in ip.api aprat from the route ones, that will follow in a separate commit Change-Id: I67161737c2184d3f8fc1e79ebd2b55121c5b0191 Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src/vnet/ip/ip_neighbor.c')
-rw-r--r--src/vnet/ip/ip_neighbor.c39
1 files changed, 17 insertions, 22 deletions
diff --git a/src/vnet/ip/ip_neighbor.c b/src/vnet/ip/ip_neighbor.c
index 7d1998d25b8..ad89d3ff679 100644
--- a/src/vnet/ip/ip_neighbor.c
+++ b/src/vnet/ip/ip_neighbor.c
@@ -49,8 +49,8 @@ static ip_neighbor_scan_config_t ip_neighbor_scan_conf;
int
ip_neighbor_add (const ip46_address_t * ip,
- u8 is_ip6,
- const u8 * mac,
+ ip46_type_t type,
+ const mac_address_t * mac,
u32 sw_if_index,
ip_neighbor_flags_t flags, u32 * stats_index)
{
@@ -63,13 +63,10 @@ ip_neighbor_add (const ip46_address_t * ip,
* The expectation is that the FIB will ensure that nothing bad
* will come of adding bogus entries.
*/
- if (is_ip6)
+ if (IP46_TYPE_IP6 == type)
{
rv = vnet_set_ip6_ethernet_neighbor (vlib_get_main (),
- sw_if_index, &ip->ip6, mac, 6,
- (flags & IP_NEIGHBOR_FLAG_STATIC),
- (flags &
- IP_NEIGHBOR_FLAG_NO_ADJ_FIB));
+ sw_if_index, &ip->ip6, mac, flags);
fproto = FIB_PROTOCOL_IP6;
linkt = VNET_LINK_IP6;
}
@@ -77,16 +74,12 @@ ip_neighbor_add (const ip46_address_t * ip,
{
ethernet_arp_ip4_over_ethernet_address_t a = {
.ip4 = ip->ip4,
+ .mac = *mac,
};
- clib_memcpy (&a.ethernet, mac, 6);
-
- rv = vnet_arp_set_ip4_over_ethernet (vnet_get_main (),
- sw_if_index,
- &a,
- (flags & IP_NEIGHBOR_FLAG_STATIC),
- (flags &
- IP_NEIGHBOR_FLAG_NO_ADJ_FIB));
+ rv =
+ vnet_arp_set_ip4_over_ethernet (vnet_get_main (), sw_if_index, &a,
+ flags);
fproto = FIB_PROTOCOL_IP4;
linkt = VNET_LINK_IP4;
}
@@ -98,11 +91,11 @@ ip_neighbor_add (const ip46_address_t * ip,
}
int
-ip_neighbor_del (const ip46_address_t * ip, u8 is_ip6, u32 sw_if_index)
+ip_neighbor_del (const ip46_address_t * ip, ip46_type_t type, u32 sw_if_index)
{
int rv;
- if (is_ip6)
+ if (IP46_TYPE_IP6 == type)
{
rv = vnet_unset_ip6_ethernet_neighbor (vlib_get_main (),
sw_if_index, &ip->ip6);
@@ -180,14 +173,14 @@ ip_neighbor_scan (vlib_main_t * vm, f64 start_time, u32 start_idx,
if (!is_ip6)
{
n4 = pool_elt_at_index (np4, curr_idx);
- if (n4->flags & ETHERNET_ARP_IP4_ENTRY_FLAG_STATIC)
+ if (n4->flags & IP_NEIGHBOR_FLAG_STATIC)
goto next_neighbor;
update_time = n4->time_last_updated;
}
else
{
n6 = pool_elt_at_index (np6, curr_idx);
- if (n6->flags & IP6_NEIGHBOR_FLAG_STATIC)
+ if (n6->flags & IP_NEIGHBOR_FLAG_STATIC)
goto next_neighbor;
update_time = n6->time_last_updated;
}
@@ -199,9 +192,11 @@ ip_neighbor_scan (vlib_main_t * vm, f64 start_time, u32 start_idx,
/* delete stale neighbor */
if (!is_ip6)
{
- ethernet_arp_ip4_over_ethernet_address_t delme;
- clib_memcpy (&delme.ethernet, n4->ethernet_address, 6);
- delme.ip4.as_u32 = n4->ip4_address.as_u32;
+ ethernet_arp_ip4_over_ethernet_address_t delme = {
+ .ip4.as_u32 = n4->ip4_address.as_u32,
+ .mac = n4->mac,
+ };
+
vnet_arp_unset_ip4_over_ethernet (vnm, n4->sw_if_index, &delme);
}
else