aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/ip/ip_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/ip/ip_api.c')
-rw-r--r--src/vnet/ip/ip_api.c325
1 files changed, 183 insertions, 142 deletions
diff --git a/src/vnet/ip/ip_api.c b/src/vnet/ip/ip_api.c
index b9fa001553f..749cb889be9 100644
--- a/src/vnet/ip/ip_api.c
+++ b/src/vnet/ip/ip_api.c
@@ -23,8 +23,10 @@
#include <vnet/interface.h>
#include <vnet/api_errno.h>
#include <vnet/ethernet/ethernet.h>
+#include <vnet/ethernet/ethernet_types_api.h>
#include <vnet/ip/ip.h>
#include <vnet/ip/ip_neighbor.h>
+#include <vnet/ip/ip_types_api.h>
#include <vnet/ip/ip6_neighbor.h>
#include <vnet/ip/ip_punt_drop.h>
#include <vnet/fib/fib_table.h>
@@ -120,13 +122,25 @@ _(IP_PUNT_REDIRECT_DUMP, ip_punt_redirect_dump)
extern void stats_dslock_with_hint (int hint, int tag);
extern void stats_dsunlock (void);
+static vl_api_ip_neighbor_flags_t
+ip_neighbor_flags_encode (ip_neighbor_flags_t f)
+{
+ vl_api_ip_neighbor_flags_t v = IP_API_NEIGHBOR_FLAG_NONE;
+
+ if (f & IP_NEIGHBOR_FLAG_STATIC)
+ v |= IP_API_NEIGHBOR_FLAG_STATIC;
+ if (f & IP_NEIGHBOR_FLAG_NO_FIB_ENTRY)
+ v |= IP_API_NEIGHBOR_FLAG_NO_FIB_ENTRY;
+
+ return (clib_host_to_net_u32 (v));
+}
+
static void
send_ip_neighbor_details (u32 sw_if_index,
- u8 is_ipv6,
- u8 is_static,
- u8 * mac_address,
- u8 * ip_address, vl_api_registration_t * reg,
- u32 context)
+ const ip46_address_t * ip_address,
+ const mac_address_t * mac,
+ ip_neighbor_flags_t flags,
+ vl_api_registration_t * reg, u32 context)
{
vl_api_ip_neighbor_details_t *mp;
@@ -134,11 +148,11 @@ send_ip_neighbor_details (u32 sw_if_index,
clib_memset (mp, 0, sizeof (*mp));
mp->_vl_msg_id = ntohs (VL_API_IP_NEIGHBOR_DETAILS);
mp->context = context;
- mp->sw_if_index = htonl (sw_if_index);
- mp->is_ipv6 = is_ipv6;
- mp->is_static = is_static;
- memcpy (mp->mac_address, mac_address, 6);
- memcpy (mp->ip_address, ip_address, (is_ipv6) ? 16 : 4);
+ mp->neighbor.sw_if_index = htonl (sw_if_index);
+ mp->neighbor.flags = ip_neighbor_flags_encode (flags);
+
+ ip_address_encode (ip_address, IP46_TYPE_ANY, &mp->neighbor.ip_address);
+ mac_address_encode (mac, mp->neighbor.mac_address);
vl_api_send_msg (reg, (u8 *) mp);
}
@@ -162,12 +176,15 @@ vl_api_ip_neighbor_dump_t_handler (vl_api_ip_neighbor_dump_t * mp)
/* *INDENT-OFF* */
vec_foreach (n, ns)
{
- send_ip_neighbor_details
- (n->key.sw_if_index, mp->is_ipv6,
- ((n->flags & IP6_NEIGHBOR_FLAG_STATIC) ? 1 : 0),
- (u8 *) n->link_layer_address,
- (u8 *) & (n->key.ip6_address.as_u8),
- reg, mp->context);
+ ip46_address_t nh = {
+ .ip6 = {
+ .as_u64[0] = n->key.ip6_address.as_u64[0],
+ .as_u64[1] = n->key.ip6_address.as_u64[1],
+ },
+ };
+ send_ip_neighbor_details (n->key.sw_if_index, &nh,
+ &n->mac, n->flags,
+ reg, mp->context);
}
/* *INDENT-ON* */
vec_free (ns);
@@ -180,11 +197,15 @@ vl_api_ip_neighbor_dump_t_handler (vl_api_ip_neighbor_dump_t * mp)
/* *INDENT-OFF* */
vec_foreach (n, ns)
{
- send_ip_neighbor_details (n->sw_if_index, mp->is_ipv6,
- ((n->flags & ETHERNET_ARP_IP4_ENTRY_FLAG_STATIC) ? 1 : 0),
- (u8*) n->ethernet_address,
- (u8*) & (n->ip4_address.as_u8),
- reg, mp->context);
+ ip46_address_t nh = {
+ .ip4 = {
+ .as_u32 = n->ip4_address.as_u32,
+ },
+ };
+
+ send_ip_neighbor_details (n->sw_if_index, &nh,
+ &n->mac, n->flags,
+ reg, mp->context);
}
/* *INDENT-ON* */
vec_free (ns);
@@ -654,36 +675,52 @@ vl_api_ip_punt_redirect_t_handler (vl_api_ip_punt_redirect_t * mp,
REPLY_MACRO (VL_API_IP_PUNT_REDIRECT_REPLY);
}
+static ip_neighbor_flags_t
+ip_neighbor_flags_decode (vl_api_ip_neighbor_flags_t v)
+{
+ ip_neighbor_flags_t f = IP_NEIGHBOR_FLAG_NONE;
+
+ v = clib_net_to_host_u32 (v);
+
+ if (v & IP_API_NEIGHBOR_FLAG_STATIC)
+ f |= IP_NEIGHBOR_FLAG_STATIC;
+ if (v & IP_API_NEIGHBOR_FLAG_NO_FIB_ENTRY)
+ f |= IP_NEIGHBOR_FLAG_NO_FIB_ENTRY;
+
+ return (f);
+}
+
static void
vl_api_ip_neighbor_add_del_t_handler (vl_api_ip_neighbor_add_del_t * mp,
vlib_main_t * vm)
{
- ip46_address_t ip = ip46_address_initializer;
vl_api_ip_neighbor_add_del_reply_t *rmp;
ip_neighbor_flags_t flags;
u32 stats_index = ~0;
+ ip46_address_t ip;
+ mac_address_t mac;
+ ip46_type_t type;
int rv = 0;
- VALIDATE_SW_IF_INDEX (mp);
+ VALIDATE_SW_IF_INDEX ((&mp->neighbor));
stats_dslock_with_hint (1 /* release hint */ , 7 /* tag */ );
- flags = IP_NEIGHBOR_FLAG_NODE;
- if (mp->is_static)
- flags |= IP_NEIGHBOR_FLAG_STATIC;
- if (mp->is_no_adj_fib)
- flags |= IP_NEIGHBOR_FLAG_NO_ADJ_FIB;
-
- if (mp->is_ipv6)
- clib_memcpy (&ip.ip6, mp->dst_address, 16);
- else
- clib_memcpy (&ip.ip4, mp->dst_address, 4);
+ flags = ip_neighbor_flags_decode (mp->neighbor.flags);
+ type = ip_address_decode (&mp->neighbor.ip_address, &ip);
+ mac_address_decode (mp->neighbor.mac_address, &mac);
+ /*
+ * there's no validation here of the ND/ARP entry being added.
+ * The expectation is that the FIB will ensure that nothing bad
+ * will come of adding bogus entries.
+ */
if (mp->is_add)
- rv = ip_neighbor_add (&ip, mp->is_ipv6, mp->mac_address,
- ntohl (mp->sw_if_index), flags, &stats_index);
+ rv = ip_neighbor_add (&ip, type, &mac,
+ ntohl (mp->neighbor.sw_if_index),
+ flags, &stats_index);
else
- rv = ip_neighbor_del (&ip, mp->is_ipv6, ntohl (mp->sw_if_index));
+ rv = ip_neighbor_del (&ip, type, ntohl (mp->neighbor.sw_if_index));
stats_dsunlock ();
@@ -1660,11 +1697,13 @@ static void
{
vlib_main_t *vm = vlib_get_main ();
vl_api_sw_interface_ip6nd_ra_prefix_reply_t *rmp;
+ fib_prefix_t pfx;
int rv = 0;
u8 is_no, use_default, no_advertise, off_link, no_autoconfig, no_onlink;
VALIDATE_SW_IF_INDEX (mp);
+ ip_prefix_decode (&mp->prefix, &pfx);
is_no = mp->is_no == 1;
use_default = mp->use_default == 1;
no_advertise = mp->no_advertise == 1;
@@ -1673,8 +1712,8 @@ static void
no_onlink = mp->no_onlink == 1;
rv = ip6_neighbor_ra_prefix (vm, ntohl (mp->sw_if_index),
- (ip6_address_t *) mp->address,
- mp->address_length, use_default,
+ &pfx.fp_addr.ip6,
+ pfx.fp_len, use_default,
ntohl (mp->val_lifetime),
ntohl (mp->pref_lifetime), no_advertise,
off_link, no_autoconfig, no_onlink, is_no);
@@ -1695,7 +1734,8 @@ send_ip6nd_proxy_details (vl_api_registration_t * reg,
mp->_vl_msg_id = ntohs (VL_API_IP6ND_PROXY_DETAILS);
mp->context = context;
mp->sw_if_index = htonl (sw_if_index);
- memcpy (mp->address, addr, 16);
+
+ ip6_address_encode (&addr->ip6, mp->ip);
vl_api_send_msg (reg, (u8 *) mp);
}
@@ -1763,12 +1803,13 @@ static void
vl_api_ip6nd_proxy_add_del_t_handler (vl_api_ip6nd_proxy_add_del_t * mp)
{
vl_api_ip6nd_proxy_add_del_reply_t *rmp;
+ ip6_address_t ip6;
int rv = 0;
VALIDATE_SW_IF_INDEX (mp);
- rv = ip6_neighbor_proxy_add_del (ntohl (mp->sw_if_index),
- (ip6_address_t *) mp->address, mp->is_del);
+ ip6_address_decode (mp->ip, &ip6);
+ rv = ip6_neighbor_proxy_add_del (ntohl (mp->sw_if_index), &ip6, mp->is_del);
BAD_SW_IF_INDEX_LABEL;
REPLY_MACRO (VL_API_IP6ND_PROXY_ADD_DEL_REPLY);
@@ -1910,8 +1951,9 @@ static void
clib_error_t *error;
clib_memset (&args, 0, sizeof (args));
- ip_set (&args.prefix.fp_addr, mp->ip, mp->is_ip4);
- args.prefix.fp_len = mp->plen ? mp->plen : (mp->is_ip4 ? 32 : 128);
+
+ ip_prefix_decode (&mp->pfx, &args.prefix);
+
args.sw_if_index = clib_net_to_host_u32 (mp->sw_if_index);
args.is_add = mp->is_add;
if ((error = vnet_ip_container_proxy_add_del (&args)))
@@ -2014,11 +2056,8 @@ static void
vl_api_ip_source_and_port_range_check_add_del_reply_t *rmp;
int rv = 0;
- u8 is_ipv6 = mp->is_ipv6;
u8 is_add = mp->is_add;
- u8 mask_length = mp->mask_length;
- ip4_address_t ip4_addr;
- ip6_address_t ip6_addr;
+ fib_prefix_t pfx;
u16 *low_ports = 0;
u16 *high_ports = 0;
u32 vrf_id;
@@ -2026,6 +2065,8 @@ static void
u8 num_ranges;
int i;
+ ip_prefix_decode (&mp->prefix, &pfx);
+
// Validate port range
num_ranges = mp->number_of_ranges;
if (num_ranges > 32)
@@ -2052,13 +2093,6 @@ static void
vec_add1 (high_ports, tmp_high + 1);
}
- // Validate mask_length
- if ((is_ipv6 && mask_length > 128) || (!is_ipv6 && mask_length > 32))
- {
- rv = VNET_API_ERROR_ADDRESS_LENGTH_MISMATCH;
- goto reply;
- }
-
vrf_id = ntohl (mp->vrf_id);
if (vrf_id < 1)
@@ -2068,20 +2102,18 @@ static void
}
- if (is_ipv6)
+ if (FIB_PROTOCOL_IP6 == pfx.fp_proto)
{
- clib_memcpy (ip6_addr.as_u8, mp->address, sizeof (ip6_addr.as_u8));
- rv = ip6_source_and_port_range_check_add_del (&ip6_addr,
- mask_length,
+ rv = ip6_source_and_port_range_check_add_del (&pfx.fp_addr.ip6,
+ pfx.fp_len,
vrf_id,
low_ports,
high_ports, is_add);
}
else
{
- clib_memcpy (ip4_addr.data, mp->address, sizeof (ip4_addr));
- rv = ip4_source_and_port_range_check_add_del (&ip4_addr,
- mask_length,
+ rv = ip4_source_and_port_range_check_add_del (&pfx.fp_addr.ip4,
+ pfx.fp_len,
vrf_id,
low_ports,
high_ports, is_add);
@@ -2181,10 +2213,22 @@ static void
#define IP4_ARP_EVENT 3
#define IP6_ND_EVENT 4
-static int arp_change_delete_callback (u32 pool_index, u8 * notused);
-static int nd_change_delete_callback (u32 pool_index, u8 * notused);
static vlib_node_registration_t ip_resolver_process_node;
+static int
+arp_change_delete_callback (u32 pool_index,
+ const mac_address_t * mac,
+ u32 sw_if_index, const ip4_address_t * address)
+{
+ vpe_api_main_t *am = &vpe_api_main;
+
+ if (pool_is_free_index (am->arp_events, pool_index))
+ return 1;
+
+ pool_put_index (am->arp_events, pool_index);
+ return 0;
+}
+
static void
handle_ip4_arp_event (u32 pool_index)
{
@@ -2206,7 +2250,7 @@ handle_ip4_arp_event (u32 pool_index)
{
(void) vnet_add_del_ip4_arp_change_event
(vnm, arp_change_delete_callback,
- event->pid, &event->address,
+ event->pid, event->ip,
ip_resolver_process_node.index, IP4_ARP_EVENT,
~0 /* pool index, notused */ , 0 /* is_add */ );
return;
@@ -2228,12 +2272,26 @@ handle_ip4_arp_event (u32 pool_index)
if (vlib_time_now (vm) > last_time + 10.0)
{
clib_warning ("arp event for %U to pid %d: queue stuffed!",
- format_ip4_address, &event->address, event->pid);
+ format_ip4_address, event->ip, event->pid);
last_time = vlib_time_now (vm);
}
}
}
+static int
+nd_change_delete_callback (u32 pool_index,
+ const mac_address_t * mac,
+ u32 sw_if_index, const ip6_address_t * addr)
+{
+ vpe_api_main_t *am = &vpe_api_main;
+
+ if (pool_is_free_index (am->nd_events, pool_index))
+ return 1;
+
+ pool_put_index (am->nd_events, pool_index);
+ return 0;
+}
+
static void
handle_ip6_nd_event (u32 pool_index)
{
@@ -2255,7 +2313,7 @@ handle_ip6_nd_event (u32 pool_index)
{
(void) vnet_add_del_ip6_nd_change_event
(vnm, nd_change_delete_callback,
- event->pid, &event->address,
+ event->pid, event->ip,
ip_resolver_process_node.index, IP6_ND_EVENT,
~0 /* pool index, notused */ , 0 /* is_add */ );
return;
@@ -2277,7 +2335,7 @@ handle_ip6_nd_event (u32 pool_index)
if (vlib_time_now (vm) > last_time + 10.0)
{
clib_warning ("ip6 nd event for %U to pid %d: queue stuffed!",
- format_ip6_address, &event->address, event->pid);
+ format_ip6_address, event->ip, event->pid);
last_time = vlib_time_now (vm);
}
}
@@ -2328,8 +2386,8 @@ VLIB_REGISTER_NODE (ip_resolver_process_node,static) = {
/* *INDENT-ON* */
static int
-nd_change_data_callback (u32 pool_index, u8 * new_mac,
- u32 sw_if_index, ip6_address_t * address)
+nd_change_data_callback (u32 pool_index, const mac_address_t * new_mac,
+ u32 sw_if_index, const ip6_address_t * address)
{
vpe_api_main_t *am = &vpe_api_main;
vl_api_ip6_nd_event_t *event;
@@ -2338,41 +2396,17 @@ nd_change_data_callback (u32 pool_index, u8 * new_mac,
return 1;
event = pool_elt_at_index (am->nd_events, pool_index);
- if (eth_mac_equal (event->new_mac, new_mac) &&
+ if (ethernet_mac_address_equal (event->mac, new_mac->bytes) &&
sw_if_index == ntohl (event->sw_if_index))
{
return 1;
}
- clib_memcpy (event->new_mac, new_mac, sizeof (event->new_mac));
+ mac_address_encode (new_mac, event->mac);
event->sw_if_index = htonl (sw_if_index);
return 0;
}
-static int
-arp_change_delete_callback (u32 pool_index, u8 * notused)
-{
- vpe_api_main_t *am = &vpe_api_main;
-
- if (pool_is_free_index (am->arp_events, pool_index))
- return 1;
-
- pool_put_index (am->arp_events, pool_index);
- return 0;
-}
-
-static int
-nd_change_delete_callback (u32 pool_index, u8 * notused)
-{
- vpe_api_main_t *am = &vpe_api_main;
-
- if (pool_is_free_index (am->nd_events, pool_index))
- return 1;
-
- pool_put_index (am->nd_events, pool_index);
- return 0;
-}
-
static vlib_node_registration_t wc_arp_process_node;
enum
@@ -2403,9 +2437,10 @@ wc_arp_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f)
wc_arp_report_t *arp_events = event_data;
for (i = 0; i < vec_len (arp_events); i++)
{
- /* discard dup event */
- if (arp_prev.ip4 == arp_events[i].ip4 &&
- eth_mac_equal ((u8 *) arp_prev.mac, arp_events[i].mac) &&
+ /* discard dup event - cast away volatile */
+ if (arp_prev.ip.as_u32 == arp_events[i].ip.as_u32 &&
+ mac_address_equal ((const mac_address_t *) &arp_prev.mac,
+ &arp_events[i].mac) &&
arp_prev.sw_if_index == arp_events[i].sw_if_index &&
(now - last_arp) < 10.0)
{
@@ -2428,9 +2463,9 @@ wc_arp_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f)
event->client_index = reg->client_index;
event->pid = reg->client_pid;
event->mac_ip = 1;
- event->address = arp_events[i].ip4;
+ ip4_address_encode(&arp_events[i].ip, event->ip);
event->sw_if_index = htonl(arp_events[i].sw_if_index);
- memcpy(event->new_mac, arp_events[i].mac, sizeof event->new_mac);
+ mac_address_encode(&arp_events[i].mac, event->mac);
vl_api_send_msg (vl_reg, (u8 *) event);
}
}));
@@ -2442,10 +2477,11 @@ wc_arp_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f)
wc_nd_report_t *nd_events = event_data;
for (i = 0; i < vec_len (nd_events); i++)
{
- /* discard dup event */
- if (ip6_address_is_equal
- ((ip6_address_t *) & nd_prev.ip6, &nd_events[i].ip6)
- && eth_mac_equal ((u8 *) nd_prev.mac, nd_events[i].mac)
+ /* discard dup event - cast away volatile */
+ if (ip6_address_is_equal ((const ip6_address_t *) &nd_prev.ip6,
+ &nd_events[i].ip6)
+ && mac_address_equal ((const mac_address_t *) &nd_prev.mac,
+ &nd_events[i].mac)
&& nd_prev.sw_if_index == nd_events[i].sw_if_index
&& (now - last_nd) < 10.0)
{
@@ -2467,9 +2503,9 @@ wc_arp_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f)
event->client_index = reg->client_index;
event->pid = reg->client_pid;
event->mac_ip = 1;
- memcpy(event->address, nd_events[i].ip6.as_u8, sizeof event->address);
+ ip6_address_encode(&nd_events[i].ip6, event->ip);
event->sw_if_index = htonl(nd_events[i].sw_if_index);
- memcpy(event->new_mac, nd_events[i].mac, sizeof event->new_mac);
+ mac_address_encode(&nd_events[i].mac, event->mac);
vl_api_send_msg (vl_reg, (u8 *) event);
}
}));
@@ -2507,7 +2543,8 @@ wc_arp_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f)
event->sw_if_index = clib_host_to_net_u32 (ra_events[i].sw_if_index);
- memcpy (event->router_address, ra_events[i].router_address, 16);
+ ip6_address_encode (&ra_events[i].router_address,
+ event->router_addr);
event->current_hop_limit = ra_events[i].current_hop_limit;
event->flags = ra_events[i].flags;
@@ -2531,9 +2568,7 @@ wc_arp_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f)
{
ra_report_prefix_info_t *info =
&ra_events[i].prefixes[j];
- memcpy (prefix->dst_address, info->dst_address.as_u8,
- 16);
- prefix->dst_address_length = info->dst_address_length;
+ ip_prefix_encode(&info->prefix, &prefix->prefix);
prefix->flags = info->flags;
prefix->valid_time =
clib_host_to_net_u32 (info->valid_time);
@@ -2564,8 +2599,9 @@ VLIB_REGISTER_NODE (wc_arp_process_node,static) = {
/* *INDENT-ON* */
static int
-arp_change_data_callback (u32 pool_index, u8 * new_mac,
- u32 sw_if_index, u32 address)
+arp_change_data_callback (u32 pool_index,
+ const mac_address_t * mac,
+ u32 sw_if_index, const ip4_address_t * address)
{
vpe_api_main_t *am = &vpe_api_main;
vl_api_ip4_arp_event_t *event;
@@ -2574,13 +2610,13 @@ arp_change_data_callback (u32 pool_index, u8 * new_mac,
return 1;
event = pool_elt_at_index (am->arp_events, pool_index);
- if (eth_mac_equal (event->new_mac, new_mac) &&
+ if (ethernet_mac_address_equal (event->mac, mac->bytes) &&
sw_if_index == ntohl (event->sw_if_index))
{
return 1;
}
- clib_memcpy (event->new_mac, new_mac, sizeof (event->new_mac));
+ mac_address_encode (mac, event->mac);
event->sw_if_index = htonl (sw_if_index);
return 0;
}
@@ -2591,9 +2627,12 @@ vl_api_want_ip4_arp_events_t_handler (vl_api_want_ip4_arp_events_t * mp)
vpe_api_main_t *am = &vpe_api_main;
vnet_main_t *vnm = vnet_get_main ();
vl_api_want_ip4_arp_events_reply_t *rmp;
+ ip4_address_t ip;
int rv = 0;
- if (mp->address == 0)
+ ip4_address_decode (mp->ip, &ip);
+
+ if (ip.as_u32 == 0)
{
uword *p =
hash_get (am->wc_ip4_arp_events_registration_hash, mp->client_index);
@@ -2639,7 +2678,7 @@ vl_api_want_ip4_arp_events_t_handler (vl_api_want_ip4_arp_events_t * mp)
pool_get (am->arp_events, event);
rv = vnet_add_del_ip4_arp_change_event
(vnm, arp_change_data_callback,
- mp->pid, &mp->address /* addr, in net byte order */ ,
+ mp->pid, mp->ip /* addr, in net byte order */ ,
ip_resolver_process_node.index,
IP4_ARP_EVENT, event - am->arp_events, 1 /* is_add */ );
@@ -2653,16 +2692,16 @@ vl_api_want_ip4_arp_events_t_handler (vl_api_want_ip4_arp_events_t * mp)
/* Python API expects events to have no context */
event->_vl_msg_id = htons (VL_API_IP4_ARP_EVENT);
event->client_index = mp->client_index;
- event->address = mp->address;
+ memcpy (event->ip, mp->ip, 4);
event->pid = mp->pid;
- if (mp->address == 0)
+ if (ip.as_u32 == 0)
event->mac_ip = 1;
}
else
{
rv = vnet_add_del_ip4_arp_change_event
(vnm, arp_change_delete_callback,
- mp->pid, &mp->address /* addr, in net byte order */ ,
+ mp->pid, mp->ip /* addr, in net byte order */ ,
ip_resolver_process_node.index,
IP4_ARP_EVENT, ~0 /* pool index */ , 0 /* is_add */ );
}
@@ -2700,7 +2739,7 @@ want_ip4_arp_events_reaper (u32 client_index)
event = pool_elt_at_index (am->arp_events, *event_id);
vnet_add_del_ip4_arp_change_event
(vnm, arp_change_delete_callback,
- event->pid, &event->address,
+ event->pid, event->ip,
ip_resolver_process_node.index, IP4_ARP_EVENT,
~0 /* pool index, notused */ , 0 /* is_add */ );
}
@@ -2728,9 +2767,12 @@ vl_api_want_ip6_nd_events_t_handler (vl_api_want_ip6_nd_events_t * mp)
vpe_api_main_t *am = &vpe_api_main;
vnet_main_t *vnm = vnet_get_main ();
vl_api_want_ip6_nd_events_reply_t *rmp;
+ ip6_address_t ip6;
int rv = 0;
- if (ip6_address_is_zero ((ip6_address_t *) mp->address))
+ ip6_address_decode (mp->ip, &ip6);
+
+ if (ip6_address_is_zero (&ip6))
{
uword *p =
hash_get (am->wc_ip6_nd_events_registration_hash, mp->client_index);
@@ -2777,7 +2819,7 @@ vl_api_want_ip6_nd_events_t_handler (vl_api_want_ip6_nd_events_t * mp)
rv = vnet_add_del_ip6_nd_change_event
(vnm, nd_change_data_callback,
- mp->pid, mp->address /* addr, in net byte order */ ,
+ mp->pid, &ip6,
ip_resolver_process_node.index,
IP6_ND_EVENT, event - am->nd_events, 1 /* is_add */ );
@@ -2790,14 +2832,14 @@ vl_api_want_ip6_nd_events_t_handler (vl_api_want_ip6_nd_events_t * mp)
event->_vl_msg_id = ntohs (VL_API_IP6_ND_EVENT);
event->client_index = mp->client_index;
- clib_memcpy (event->address, mp->address, sizeof event->address);
+ ip6_address_encode (&ip6, event->ip);
event->pid = mp->pid;
}
else
{
rv = vnet_add_del_ip6_nd_change_event
(vnm, nd_change_delete_callback,
- mp->pid, mp->address /* addr, in net byte order */ ,
+ mp->pid, &ip6 /* addr, in net byte order */ ,
ip_resolver_process_node.index,
IP6_ND_EVENT, ~0 /* pool index */ , 0 /* is_add */ );
}
@@ -2836,7 +2878,7 @@ want_ip6_nd_events_reaper (u32 client_index)
event = pool_elt_at_index (am->nd_events, *event_id);
vnet_add_del_ip6_nd_change_event
(vnm, nd_change_delete_callback,
- event->pid, &event->address,
+ event->pid, event->ip,
ip_resolver_process_node.index, IP6_ND_EVENT,
~0 /* pool index, notused */ , 0 /* is_add */ );
}
@@ -2923,26 +2965,24 @@ static void
vl_api_proxy_arp_add_del_t_handler (vl_api_proxy_arp_add_del_t * mp)
{
vl_api_proxy_arp_add_del_reply_t *rmp;
+ ip4_address_t lo, hi;
u32 fib_index;
int rv;
- ip4_main_t *im = &ip4_main;
- uword *p;
stats_dslock_with_hint (1 /* release hint */ , 6 /* tag */ );
- p = hash_get (im->fib_index_by_table_id, ntohl (mp->proxy.vrf_id));
+ fib_index = fib_table_find (FIB_PROTOCOL_IP4, ntohl (mp->proxy.table_id));
- if (!p)
+ if (~0 == fib_index)
{
rv = VNET_API_ERROR_NO_SUCH_FIB;
goto out;
}
- fib_index = p[0];
+ ip4_address_decode (mp->proxy.low, &lo);
+ ip4_address_decode (mp->proxy.hi, &hi);
- rv = vnet_proxy_arp_add_del ((ip4_address_t *) mp->proxy.low_address,
- (ip4_address_t *) mp->proxy.hi_address,
- fib_index, mp->is_add == 0);
+ rv = vnet_proxy_arp_add_del (&lo, &hi, fib_index, mp->is_add == 0);
out:
stats_dsunlock ();
@@ -2969,10 +3009,10 @@ send_proxy_arp_details (const ip4_address_t * lo_addr,
clib_memset (mp, 0, sizeof (*mp));
mp->_vl_msg_id = ntohs (VL_API_PROXY_ARP_DETAILS);
mp->context = ctx->context;
- mp->proxy.vrf_id = htonl (fib_index);
- clib_memcpy (mp->proxy.low_address, lo_addr,
- sizeof (mp->proxy.low_address));
- clib_memcpy (mp->proxy.hi_address, hi_addr, sizeof (mp->proxy.hi_address));
+ mp->proxy.table_id = htonl (fib_index);
+
+ ip4_address_encode (lo_addr, mp->proxy.low);
+ ip4_address_encode (hi_addr, mp->proxy.hi);
vl_api_send_msg (ctx->reg, (u8 *) mp);
@@ -3069,17 +3109,18 @@ vl_api_ip_probe_neighbor_t_handler (vl_api_ip_probe_neighbor_t * mp)
vlib_main_t *vm = vlib_get_main ();
vl_api_ip_probe_neighbor_reply_t *rmp;
clib_error_t *error;
+ ip46_address_t dst;
+ ip46_type_t itype;
VALIDATE_SW_IF_INDEX (mp);
u32 sw_if_index = ntohl (mp->sw_if_index);
+ itype = ip_address_decode (&mp->dst, &dst);
- if (mp->is_ipv6)
- error = ip6_probe_neighbor (vm, (ip6_address_t *) mp->dst_address,
- sw_if_index, 0);
+ if (IP46_TYPE_IP6 == itype)
+ error = ip6_probe_neighbor (vm, &dst.ip6, sw_if_index, 0);
else
- error = ip4_probe_neighbor (vm, (ip4_address_t *) mp->dst_address,
- sw_if_index, 0);
+ error = ip4_probe_neighbor (vm, &dst.ip4, sw_if_index, 0);
if (error)
{