summaryrefslogtreecommitdiffstats
path: root/hicn-plugin/src
diff options
context:
space:
mode:
Diffstat (limited to 'hicn-plugin/src')
-rw-r--r--hicn-plugin/src/faces/face.h2
-rw-r--r--hicn-plugin/src/faces/ip/face_ip.c20
-rw-r--r--hicn-plugin/src/hicn.api10
-rw-r--r--hicn-plugin/src/hicn_api.c54
-rw-r--r--hicn-plugin/src/hicn_api_test.c52
5 files changed, 93 insertions, 45 deletions
diff --git a/hicn-plugin/src/faces/face.h b/hicn-plugin/src/faces/face.h
index b24fe8648..313f8ec86 100644
--- a/hicn-plugin/src/faces/face.h
+++ b/hicn-plugin/src/faces/face.h
@@ -67,7 +67,7 @@ typedef struct __attribute__ ((packed)) hicn_face_shared_s
union
{
hicn_face_type_t face_type;
- u32 int_face_type; //To forse the face_type_t to be 4B
+ u32 int_face_type; //To force the face_type_t to be 4B
};
} hicn_face_shared_t;
diff --git a/hicn-plugin/src/faces/ip/face_ip.c b/hicn-plugin/src/faces/ip/face_ip.c
index c1e264e44..a70cb1011 100644
--- a/hicn-plugin/src/faces/ip/face_ip.c
+++ b/hicn-plugin/src/faces/ip/face_ip.c
@@ -40,17 +40,21 @@ hicn_face_ip_init (vlib_main_t * vm)
/* Default Strategy has index 0 and it always exists */
strategy_face_ip4_vlib_edge = vlib_node_add_next (vm,
hicn_dpo_get_strategy_vft
- (default_dpo.hicn_dpo_get_type
- ())->get_strategy_node_index
+ (default_dpo.
+ hicn_dpo_get_type ())->
+ get_strategy_node_index
(),
- hicn_face_ip4_output_node.index);
+ hicn_face_ip4_output_node.
+ index);
strategy_face_ip6_vlib_edge = vlib_node_add_next (vm,
hicn_dpo_get_strategy_vft
- (default_dpo.hicn_dpo_get_type
- ())->get_strategy_node_index
+ (default_dpo.
+ hicn_dpo_get_type ())->
+ get_strategy_node_index
(),
- hicn_face_ip6_output_node.index);
+ hicn_face_ip6_output_node.
+ index);
/*
* Create and edge between al the other strategy nodes
* and the ip_encap nodes.
@@ -144,7 +148,6 @@ hicn_face_ip_add (const ip46_address_t * local_addr,
fib_type = FIB_PROTOCOL_IP6;
}
-
adj = adj_nbr_add_or_lock (fib_type, link_type, remote_addr, sw_if);
hicn_face_flags_t flags = (hicn_face_flags_t) 0;
@@ -231,7 +234,8 @@ hicn_face_ip_add (const ip46_address_t * local_addr,
}
retx_t *retx = vlib_process_signal_event_data (vlib_get_main (),
- hicn_mapme_eventmgr_process_node.index,
+ hicn_mapme_eventmgr_process_node.
+ index,
HICN_MAPME_EVENT_FACE_ADD, 1,
sizeof (retx_t));
*retx = (retx_t)
diff --git a/hicn-plugin/src/hicn.api b/hicn-plugin/src/hicn.api
index a6be15a92..46ce177ea 100644
--- a/hicn-plugin/src/hicn.api
+++ b/hicn-plugin/src/hicn.api
@@ -169,7 +169,10 @@ define hicn_api_face_ip_add
u32 context;
/* IP local address */
- u64 nh_addr[2];
+ u64 local_addr[2];
+
+ /* IP remote address */
+ u64 remote_addr[2];
/* IPv4 local port number */
u32 swif;
@@ -229,7 +232,10 @@ define hicn_api_face_ip_params_get_reply
i32 retval;
/* IP local address */
- u64 nh_addr[2];
+ u64 local_addr[2];
+
+ /* IP remote address */
+ u64 remote_addr[2];
/* VPP interface (index) associated with the face */
u32 swif;
diff --git a/hicn-plugin/src/hicn_api.c b/hicn-plugin/src/hicn_api.c
index f06350959..c532118b3 100644
--- a/hicn-plugin/src/hicn_api.c
+++ b/hicn-plugin/src/hicn_api.c
@@ -106,19 +106,26 @@ vl_api_hicn_api_node_params_set_t_handler (vl_api_hicn_api_node_params_set_t *
hicn_main_t *sm = &hicn_main;
int pit_max_size = clib_net_to_host_i32 (mp->pit_max_size);
- pit_max_size = pit_max_size == -1? HICN_PARAM_PIT_ENTRIES_DFLT : pit_max_size;
+ pit_max_size =
+ pit_max_size == -1 ? HICN_PARAM_PIT_ENTRIES_DFLT : pit_max_size;
f64 pit_dflt_lifetime_sec = mp->pit_dflt_lifetime_sec;
- pit_dflt_lifetime_sec = pit_dflt_lifetime_sec == -1? HICN_PARAM_PIT_LIFETIME_DFLT_DFLT_MS : pit_dflt_lifetime_sec;
+ pit_dflt_lifetime_sec =
+ pit_dflt_lifetime_sec ==
+ -1 ? HICN_PARAM_PIT_LIFETIME_DFLT_DFLT_MS : pit_dflt_lifetime_sec;
f64 pit_min_lifetime_sec = mp->pit_min_lifetime_sec;
- pit_min_lifetime_sec = pit_min_lifetime_sec == -1? HICN_PARAM_PIT_LIFETIME_DFLT_MIN_MS : pit_min_lifetime_sec;
+ pit_min_lifetime_sec =
+ pit_min_lifetime_sec ==
+ -1 ? HICN_PARAM_PIT_LIFETIME_DFLT_MIN_MS : pit_min_lifetime_sec;
f64 pit_max_lifetime_sec = mp->pit_max_lifetime_sec;
- pit_max_lifetime_sec = pit_max_lifetime_sec == -1? HICN_PARAM_PIT_LIFETIME_DFLT_MAX_MS : pit_max_lifetime_sec;
+ pit_max_lifetime_sec =
+ pit_max_lifetime_sec ==
+ -1 ? HICN_PARAM_PIT_LIFETIME_DFLT_MAX_MS : pit_max_lifetime_sec;
int cs_max_size = clib_net_to_host_i32 (mp->cs_max_size);
- cs_max_size = cs_max_size == -1? HICN_PARAM_CS_ENTRIES_DFLT : cs_max_size;
+ cs_max_size = cs_max_size == -1 ? HICN_PARAM_CS_ENTRIES_DFLT : cs_max_size;
int cs_reserved_app = clib_net_to_host_i32 (mp->cs_reserved_app);
cs_reserved_app = cs_reserved_app >= 0
@@ -183,17 +190,27 @@ static void
vl_api_hicn_api_face_ip_add_t_handler (vl_api_hicn_api_face_ip_add_t * mp)
{
vl_api_hicn_api_face_ip_add_reply_t *rmp;
- int rv;
+ int rv = HICN_ERROR_UNSPECIFIED;
hicn_main_t *sm = &hicn_main;
+ vnet_main_t *vnm = vnet_get_main ();
hicn_face_id_t faceid = HICN_FACE_NULL;
- ip46_address_t nh_addr;
- nh_addr.as_u64[0] = clib_net_to_host_u64 (((u64 *) (&mp->nh_addr))[0]);
- nh_addr.as_u64[1] = clib_net_to_host_u64 (((u64 *) (&mp->nh_addr))[1]);
+ ip46_address_t local_addr;
+ ip46_address_t remote_addr;
+ local_addr.as_u64[0] =
+ clib_net_to_host_u64 (((u64 *) (&mp->local_addr))[0]);
+ local_addr.as_u64[1] =
+ clib_net_to_host_u64 (((u64 *) (&mp->local_addr))[1]);
+ remote_addr.as_u64[0] =
+ clib_net_to_host_u64 (((u64 *) (&mp->remote_addr))[0]);
+ remote_addr.as_u64[1] =
+ clib_net_to_host_u64 (((u64 *) (&mp->remote_addr))[1]);
u32 swif = clib_net_to_host_u32 (mp->swif);
- rv = hicn_face_ip_add (&nh_addr, NULL, swif, &faceid);
+
+ if (vnet_get_sw_interface_safe (vnm, swif) != NULL)
+ rv = hicn_face_ip_add (&local_addr, &remote_addr, swif, &faceid);
/* *INDENT-OFF* */
REPLY_MACRO2 (VL_API_HICN_API_FACE_IP_ADD_REPLY /* , rmp, mp, rv */ ,(
@@ -570,14 +587,17 @@ hicn_face_api_entry_params_serialize (hicn_face_id_t faceid,
}
hicn_face_t *face = hicn_dpoi_get_from_idx (faceid);
- ip_adjacency_t *ip_adj = adj_get (face->shared.adj);
-
- if (ip_adj != NULL)
+ if (face != NULL && face->shared.face_type == hicn_face_ip_type)
{
- reply->nh_addr[0] =
- clib_host_to_net_u64 (ip_adj->sub_type.nbr.next_hop.as_u64[0]);
- reply->nh_addr[1] =
- clib_host_to_net_u64 (ip_adj->sub_type.nbr.next_hop.as_u64[1]);
+ hicn_face_ip_t *face_ip = (hicn_face_ip_t *) face->data;
+ reply->local_addr[0] =
+ clib_host_to_net_u64 (face_ip->local_addr.as_u64[0]);
+ reply->local_addr[1] =
+ clib_host_to_net_u64 (face_ip->local_addr.as_u64[1]);
+ reply->remote_addr[0] =
+ clib_host_to_net_u64 (face_ip->remote_addr.as_u64[0]);
+ reply->remote_addr[1] =
+ clib_host_to_net_u64 (face_ip->remote_addr.as_u64[1]);
reply->swif = clib_host_to_net_u32 (face->shared.sw_if);
reply->flags = clib_host_to_net_u32 (face->shared.flags);
}
diff --git a/hicn-plugin/src/hicn_api_test.c b/hicn-plugin/src/hicn_api_test.c
index 9d4519bf4..2619803b7 100644
--- a/hicn-plugin/src/hicn_api_test.c
+++ b/hicn-plugin/src/hicn_api_test.c
@@ -322,17 +322,27 @@ static int
api_hicn_api_face_ip_add (vat_main_t * vam)
{
unformat_input_t *input = vam->input;
- ip46_address_t nh_addr;
+ ip46_address_t local_addr = { 0 };
+ ip46_address_t remote_addr = { 0 };
+ int ret = HICN_ERROR_NONE;
+ int sw_if = 0;
vl_api_hicn_api_face_ip_add_t *mp;
- int swif, ret;
/* Parse args required to build the message */
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (input, "add %d %U",
- &swif, unformat_ip46_address, &nh_addr))
- {;
- }
+ if (unformat
+ (input, "local %U", unformat_ip4_address, &local_addr.ip4));
+ else
+ if (unformat
+ (input, "local %U", unformat_ip6_address, &local_addr.ip6));
+ else
+ if (unformat
+ (input, "remote %U", unformat_ip4_address, &remote_addr.ip4));
+ else
+ if (unformat
+ (input, "remote %U", unformat_ip6_address, &remote_addr.ip6));
+ else if (unformat (input, "intfc %d", &sw_if));
else
{
break;
@@ -340,16 +350,20 @@ api_hicn_api_face_ip_add (vat_main_t * vam)
}
/* Check for presence of both addresses */
- if ((nh_addr.as_u64[0] == (u64) 0) && (nh_addr.as_u64[1] == (u64) 0))
+ if ((!ip46_address_is_zero (&local_addr)
+ && ! !ip46_address_is_zero (&remote_addr)))
{
- clib_warning ("Next hop address not specified");
+ clib_warning
+ ("Incomplete IP face. Please specify local and remote address");
return (1);
}
/* Construct the API message */
M (HICN_API_FACE_IP_ADD, mp);
- mp->nh_addr[0] = clib_host_to_net_u64 (nh_addr.as_u64[0]);
- mp->nh_addr[1] = clib_host_to_net_u64 (nh_addr.as_u64[0]);
- mp->swif = clib_host_to_net_u32 (swif);
+ mp->local_addr[0] = clib_host_to_net_u64 (local_addr.as_u64[0]);
+ mp->local_addr[1] = clib_host_to_net_u64 (local_addr.as_u64[1]);
+ mp->remote_addr[0] = clib_host_to_net_u64 (remote_addr.as_u64[0]);
+ mp->remote_addr[1] = clib_host_to_net_u64 (remote_addr.as_u64[1]);
+ mp->swif = clib_host_to_net_u32 (sw_if);
/* send it... */
S (mp);
@@ -465,7 +479,8 @@ static void
vat_main_t *vam = hicn_test_main.vat_main;
i32 retval = ntohl (rmp->retval);
u8 *sbuf = 0;
- u64 nh_addr[2];
+ ip46_address_t remote_addr;
+ ip46_address_t local_addr;
if (vam->async_mode)
{
@@ -482,13 +497,16 @@ static void
return;
}
vec_reset_length (sbuf);
- nh_addr[0] = clib_net_to_host_u64 (rmp->nh_addr[0]);
- nh_addr[1] = clib_net_to_host_u64 (rmp->nh_addr[1]);
+ local_addr.as_u64[0] = clib_net_to_host_u64 (rmp->local_addr[0]);
+ local_addr.as_u64[1] = clib_net_to_host_u64 (rmp->local_addr[1]);
+ remote_addr.as_u64[0] = clib_net_to_host_u64 (rmp->remote_addr[0]);
+ remote_addr.as_u64[1] = clib_net_to_host_u64 (rmp->remote_addr[1]);
sbuf =
- format (sbuf, "%U", format_ip46_address, &nh_addr,
- 0 /* IP46_ANY_TYPE */ );
+ format (0, "local_addr %U remote_addr %U", format_ip46_address,
+ &local_addr, 0 /*IP46_ANY_TYPE */ , format_ip46_address,
+ &remote_addr, 0 /*IP46_ANY_TYPE */ );
- fformat (vam->ofp, "nh_addr %s swif %d flags %d\n",
+ fformat (vam->ofp, "%s swif %d flags %d\n",
sbuf,
clib_net_to_host_u16 (rmp->swif),
clib_net_to_host_i32 (rmp->flags));