aboutsummaryrefslogtreecommitdiffstats
path: root/hicn-plugin/src/faces
diff options
context:
space:
mode:
authorAlberto Compagno <acompagn+fdio@cisco.com>2019-08-22 09:48:32 +0200
committerAlberto Compagno <acompagn+fdio@cisco.com>2019-11-04 18:10:09 +0100
commitccf813e13eba7b5c71cc3090582f50f25ba7b721 (patch)
tree2316f2d00a2c6fa8dc5c4195386cf9554cc49726 /hicn-plugin/src/faces
parent6b7f4c3f9d9d26a5aa71be8f5976956aff387e8f (diff)
[HICN-262] Fix binary api to prevent byteswapping of ip addresses in vapi
Change-Id: If3f9a7db1e1310fdc08d1003b28e5e1d4006b61e Signed-off-by: Alberto Compagno <acompagn+fdio@cisco.com>
Diffstat (limited to 'hicn-plugin/src/faces')
-rw-r--r--hicn-plugin/src/faces/app/face_app_cli.c13
-rw-r--r--hicn-plugin/src/faces/app/face_prod.c35
-rw-r--r--hicn-plugin/src/faces/app/face_prod.h4
-rw-r--r--hicn-plugin/src/faces/app/face_prod_node.c24
4 files changed, 36 insertions, 40 deletions
diff --git a/hicn-plugin/src/faces/app/face_app_cli.c b/hicn-plugin/src/faces/app/face_app_cli.c
index d55e990de..200f813cb 100644
--- a/hicn-plugin/src/faces/app/face_app_cli.c
+++ b/hicn-plugin/src/faces/app/face_app_cli.c
@@ -34,14 +34,14 @@ hicn_face_app_cli_set_command_fn (vlib_main_t * vm,
vlib_cli_command_t * cmd)
{
vnet_main_t *vnm = vnet_get_main ();
- ip46_address_t prefix;
+ fib_prefix_t prefix;
hicn_face_id_t face_id = HICN_FACE_NULL;
u32 cs_reserved = HICN_PARAM_FACE_DFT_CS_RESERVED;
int ret = HICN_ERROR_NONE;
int sw_if;
int face_op = HICN_FACE_NONE;
int prod = 0;
- int len;
+
/* Get a line of input. */
unformat_input_t _line_input, *line_input = &_line_input;
@@ -71,7 +71,7 @@ hicn_face_app_cli_set_command_fn (vlib_main_t * vm,
else
if (unformat
(line_input, "prod prefix %U/%d", unformat_ip46_address,
- &prefix, IP46_TYPE_ANY, &len))
+ &prefix.fp_addr, IP46_TYPE_ANY, &prefix.fp_len))
{
prod = 1;
}
@@ -114,14 +114,11 @@ hicn_face_app_cli_set_command_fn (vlib_main_t * vm,
ip4_address_t cons_addr4;
ip6_address_t cons_addr6;
- hicn_prefix_t name_prefix = {
- .name = prefix,
- .len = len,
- };
if (prod)
{
+ prefix.fp_proto = ip46_address_is_ip4(&prefix.fp_addr) ? FIB_PROTOCOL_IP4 : FIB_PROTOCOL_IP6;
rv =
- hicn_face_prod_add (&name_prefix, sw_if, &cs_reserved,
+ hicn_face_prod_add (&prefix, sw_if, &cs_reserved,
&prod_addr, &face_id);
if (rv == HICN_ERROR_NONE)
{
diff --git a/hicn-plugin/src/faces/app/face_prod.c b/hicn-plugin/src/faces/app/face_prod.c
index bbcc7fa6e..6c12e6d33 100644
--- a/hicn-plugin/src/faces/app/face_prod.c
+++ b/hicn-plugin/src/faces/app/face_prod.c
@@ -29,7 +29,7 @@ hicn_face_prod_state_t *face_state_vec;
u32 *face_state_pool;
static int
-hicn_app_state_create (u32 swif, hicn_prefix_t * prefix)
+hicn_app_state_create (u32 swif, fib_prefix_t * prefix)
{
/* Make sure that the pool is not empty */
pool_validate_index (face_state_pool, 0);
@@ -54,14 +54,14 @@ hicn_app_state_create (u32 swif, hicn_prefix_t * prefix)
/* Create the appif and store in the vector */
vec_validate (face_state_vec, swif);
clib_memcpy (&(face_state_vec[swif].prefix), prefix,
- sizeof (hicn_prefix_t));
+ sizeof (fib_prefix_t));
/* Set as busy the element in the vector */
pool_get (face_state_pool, swif_app);
*swif_app = swif;
int ret = HICN_ERROR_NONE;
- if (ip46_address_is_ip4 (&(prefix->name)))
+ if (ip46_address_is_ip4 (&(prefix->fp_addr)))
{
ret =
vnet_feature_enable_disable ("ip4-unicast", "hicn-face-prod-input",
@@ -86,7 +86,7 @@ hicn_app_state_del (u32 swif)
u32 *temp;
u32 *swif_app = NULL;
u8 found = 0;
- ip46_address_t *prefix_addr;
+ fib_prefix_t *prefix;
/* *INDENT-OFF* */
pool_foreach (temp, face_state_pool,{
if (*temp == swif)
@@ -98,12 +98,12 @@ hicn_app_state_del (u32 swif)
);
/* *INDENT-ON* */
- prefix_addr = &(face_state_vec[swif].prefix.name);
+ prefix = &(face_state_vec[swif].prefix);
if (!found)
return HICN_ERROR_APPFACE_NOT_FOUND;
int ret = HICN_ERROR_NONE;
- if (ip46_address_is_ip4 (prefix_addr))
+ if (ip46_address_is_ip4 (&prefix->fp_addr))
{
ret =
vnet_feature_enable_disable ("ip4-unicast", "hicn-face-prod-input",
@@ -123,7 +123,7 @@ hicn_app_state_del (u32 swif)
}
int
-hicn_face_prod_add (hicn_prefix_t * prefix, u32 sw_if, u32 * cs_reserved,
+hicn_face_prod_add (fib_prefix_t * prefix, u32 sw_if, u32 * cs_reserved,
ip46_address_t * prod_addr, hicn_face_id_t * faceid)
{
vlib_main_t *vm = vlib_get_main ();
@@ -146,12 +146,12 @@ hicn_face_prod_add (hicn_prefix_t * prefix, u32 sw_if, u32 * cs_reserved,
vnet_sw_interface_set_flags (vnm, sw_if, if_flags);
u8 *s0;
- s0 = format (0, "Prefix %U/%u", format_ip6_address,
- &prefix->name, prefix->len);
+ s0 = format (0, "Prefix %U", format_fib_prefix,
+ prefix);
vlib_cli_output (vm, "Received request for %s, swif %d\n", s0, sw_if);
- if (ip46_address_is_zero (&prefix->name))
+ if (ip46_address_is_zero (&prefix->fp_addr))
{
return HICN_ERROR_APPFACE_PROD_PREFIX_NULL;
}
@@ -159,16 +159,16 @@ hicn_face_prod_add (hicn_prefix_t * prefix, u32 sw_if, u32 * cs_reserved,
* Check if a producer face is already existing for the same prefix
* and sw_if
*/
- if (ip46_address_is_ip4 (&prefix->name))
+ if (ip46_address_is_ip4 (&prefix->fp_addr))
{
face =
- hicn_face_ip4_get (&(prefix->name.ip4), sw_if,
+ hicn_face_ip4_get (&(prefix->fp_addr.ip4), sw_if,
&hicn_face_ip_remote_hashtb);
}
else
{
face =
- hicn_face_ip6_get (&(prefix->name.ip6), sw_if,
+ hicn_face_ip6_get (&(prefix->fp_addr.ip6), sw_if,
&hicn_face_ip_remote_hashtb);
if (face != NULL)
return HICN_ERROR_FACE_ALREADY_CREATED;
@@ -202,7 +202,7 @@ hicn_face_prod_add (hicn_prefix_t * prefix, u32 sw_if, u32 * cs_reserved,
else
{
/* Otherwise create the face */
- if (ip46_address_is_ip4 (&prefix->name))
+ if (ip46_address_is_ip4 (&prefix->fp_addr))
{
/*
* Otherwise retrieve an ip address to assign as a
@@ -226,7 +226,7 @@ hicn_face_prod_add (hicn_prefix_t * prefix, u32 sw_if, u32 * cs_reserved,
ip6_address_t remote_app_ip6;
get_two_ip6_addresses (&local_app_ip6, &remote_app_ip6);
u8 *s0;
- s0 = format (0, "Prefix %U", format_ip6_address, &local_app_ip6);
+ s0 = format (0, "%U", format_ip6_address, &local_app_ip6);
vlib_cli_output (vm, "Setting ip address %s\n", s0);
@@ -264,7 +264,7 @@ hicn_face_prod_add (hicn_prefix_t * prefix, u32 sw_if, u32 * cs_reserved,
&& hicn_face_prod_set_lru_max (*faceid, cs_reserved) == HICN_ERROR_NONE)
{
hicn_app_state_create (sw_if, prefix);
- ret = hicn_route_add (faceid, 1, &(prefix->name), prefix->len);
+ ret = hicn_route_add (faceid, 1, prefix);
}
*prod_addr = local_app_ip;
@@ -294,8 +294,7 @@ hicn_face_prod_del (hicn_face_id_t face_id)
prod_face->policy.max = 0;
/* Remove the face from the fib */
- hicn_route_del_nhop (&(face_state_vec[face->shared.sw_if].prefix.name),
- (face_state_vec[face->shared.sw_if].prefix.len),
+ hicn_route_del_nhop (&(face_state_vec[face->shared.sw_if].prefix),
face_id);
int ret = hicn_face_ip_del (face_id);
diff --git a/hicn-plugin/src/faces/app/face_prod.h b/hicn-plugin/src/faces/app/face_prod.h
index 89b74680b..74c62c3bb 100644
--- a/hicn-plugin/src/faces/app/face_prod.h
+++ b/hicn-plugin/src/faces/app/face_prod.h
@@ -49,7 +49,7 @@
*/
typedef struct
{
- hicn_prefix_t prefix;
+ fib_prefix_t prefix;
} hicn_face_prod_state_t;
extern hicn_face_prod_state_t *face_state_vec;
@@ -77,7 +77,7 @@ typedef struct __attribute__ ((packed)) hicn_face_prod_t_
* send data to the producer face
*/
int
-hicn_face_prod_add (hicn_prefix_t * prefix, u32 swif, u32 * cs_reserved,
+hicn_face_prod_add (fib_prefix_t * prefix, u32 swif, u32 * cs_reserved,
ip46_address_t * prod_addr, hicn_face_id_t * faceid);
/**
diff --git a/hicn-plugin/src/faces/app/face_prod_node.c b/hicn-plugin/src/faces/app/face_prod_node.c
index a9fbfa7bf..c92585624 100644
--- a/hicn-plugin/src/faces/app/face_prod_node.c
+++ b/hicn-plugin/src/faces/app/face_prod_node.c
@@ -70,17 +70,17 @@ format_face_prod_input_trace (u8 * s, va_list * args)
}
static_always_inline int
-match_ip4_name (u32 * name, hicn_prefix_t * prefix)
+match_ip4_name (u32 * name, fib_prefix_t * prefix)
{
u32 xor = 0;
- xor = *name & prefix->name.ip4.data_u32;
+ xor = *name & prefix->fp_addr.ip4.data_u32;
- return xor == prefix->name.ip4.data_u32;
+ return xor == prefix->fp_addr.ip4.data_u32;
}
static_always_inline int
-match_ip6_name (u32x4 * name, hicn_prefix_t * prefix)
+match_ip6_name (u32x4 * name, fib_prefix_t * prefix)
{
union
{
@@ -93,32 +93,32 @@ match_ip6_name (u32x4 * name, hicn_prefix_t * prefix)
if (U32X4_ALIGNED (name))
{ //SSE can't handle unaligned data
xor_sum.as_u32x4 = *((u32x4 *) name) &
- UNION_CAST (prefix->name.ip6.as_u64[0], u32x4);
+ UNION_CAST (prefix->fp_addr.ip6.as_u64[0], u32x4);
}
else
#endif /* CLIB_HAVE_VEC128 */
{
- xor_sum.as_u64[0] = ((u64 *) name)[0] & prefix->name.ip6.as_u64[0];
- xor_sum.as_u64[1] = ((u64 *) name)[1] & prefix->name.ip6.as_u64[1];
+ xor_sum.as_u64[0] = ((u64 *) name)[0] & prefix->fp_addr.ip6.as_u64[0];
+ xor_sum.as_u64[1] = ((u64 *) name)[1] & prefix->fp_addr.ip6.as_u64[1];
}
- return (xor_sum.as_u64[0] == prefix->name.ip6.as_u64[0]) &&
- (xor_sum.as_u64[1] == prefix->name.ip6.as_u64[1]);
+ return (xor_sum.as_u64[0] == prefix->fp_addr.ip6.as_u64[0]) &&
+ (xor_sum.as_u64[1] == prefix->fp_addr.ip6.as_u64[1]);
}
static_always_inline u32
hicn_face_prod_next_from_data_hdr (vlib_node_runtime_t * node,
- vlib_buffer_t * b, hicn_prefix_t * prefix)
+ vlib_buffer_t * b, fib_prefix_t * prefix)
{
u8 *ptr = vlib_buffer_get_current (b);
u8 v = *ptr & 0xf0;
int match_res = 1;
- if (PREDICT_TRUE (v == 0x40 && ip46_address_is_ip4 (&prefix->name)))
+ if (PREDICT_TRUE (v == 0x40 && ip46_address_is_ip4 (&prefix->fp_addr)))
{
match_res = match_ip4_name ((u32 *) & (ptr[12]), prefix);
}
- else if (PREDICT_TRUE (v == 0x60 && !ip46_address_is_ip4 (&prefix->name)))
+ else if (PREDICT_TRUE (v == 0x60 && !ip46_address_is_ip4 (&prefix->fp_addr)))
{
match_res = match_ip6_name ((u32x4 *) & (ptr[8]), prefix);
}