aboutsummaryrefslogtreecommitdiffstats
path: root/hicn-plugin/src
diff options
context:
space:
mode:
authorAlberto Compagno <acompagn+fdio@cisco.com>2019-06-06 19:42:12 +0200
committerAlberto Compagno <acompagn+fdio@cisco.com>2019-06-06 23:02:14 +0200
commit27712b5f2a06c935a97643d91f6bd1345d05ec3b (patch)
treebd9dc4ee89daea07722db9376be4a5ef63b9ddf6 /hicn-plugin/src
parent2d555daf9034459ec5ef20f7d63cccd25c6c4b0c (diff)
[HICN-214] Updating next_node in the face that mapme add to the fib in order to forward interests
Change-Id: I97c408c9e910df0ea7c43c0341c0025521ced125 Signed-off-by: Alberto Compagno <acompagn+fdio@cisco.com>
Diffstat (limited to 'hicn-plugin/src')
-rw-r--r--hicn-plugin/src/faces/ip/face_ip_node.c13
-rw-r--r--hicn-plugin/src/faces/udp/dpo_udp.h7
-rw-r--r--hicn-plugin/src/faces/udp/face_udp.h8
-rw-r--r--hicn-plugin/src/faces/udp/face_udp_node.c37
-rw-r--r--hicn-plugin/src/faces/udp/iface_udp_node.c18
-rw-r--r--hicn-plugin/src/mapme.h18
-rw-r--r--hicn-plugin/src/mapme_ctrl_node.c36
7 files changed, 86 insertions, 51 deletions
diff --git a/hicn-plugin/src/faces/ip/face_ip_node.c b/hicn-plugin/src/faces/ip/face_ip_node.c
index 109750de8..945895fa0 100644
--- a/hicn-plugin/src/faces/ip/face_ip_node.c
+++ b/hicn-plugin/src/faces/ip/face_ip_node.c
@@ -465,7 +465,6 @@ static inline void
hicn_face_rewrite_interest (vlib_main_t * vm, vlib_buffer_t * b0,
hicn_face_t * face, u32 * next)
{
- ip_adjacency_t *adj = adj_get (face->shared.adj);
hicn_header_t *hicn = vlib_buffer_get_current (b0);
@@ -477,11 +476,19 @@ hicn_face_rewrite_interest (vlib_main_t * vm, vlib_buffer_t * b0,
hicn_ops_vft[type.l1]->rewrite_interest (type, &hicn->protocol,
&ip_face->local_addr, &temp_addr);
+ int is_iface = 0;
+ ip_adjacency_t *adj;
+ if (PREDICT_FALSE (face->shared.adj == ~0))
+ is_iface = 1;
+ else
+ adj = adj_get (face->shared.adj);
+
/* In case the adj is not complete, we look if a better one exists, otherwise we send an arp request
* This is necessary to account for the case in which when we create a face, there isn't a /128(/32) adjacency and we match with a more general route which is in glean state
* In this case in fact, the general route will not be update upone receiving of a arp or neighbour responde, but a new /128(/32) will be created
*/
- if (PREDICT_FALSE (adj->lookup_next_index < IP_LOOKUP_NEXT_REWRITE))
+ if (PREDICT_FALSE
+ (is_iface || adj->lookup_next_index < IP_LOOKUP_NEXT_REWRITE))
{
fib_prefix_t fib_pfx;
fib_node_index_t fib_entry_index;
@@ -495,6 +502,8 @@ hicn_face_rewrite_interest (vlib_main_t * vm, vlib_buffer_t * b0,
fib_entry_index = fib_table_lookup (fib_index, &fib_pfx);
face->shared.adj = fib_entry_get_adj (fib_entry_index);
+ face->shared.flags &= ~HICN_FACE_FLAGS_IFACE;
+ face->shared.flags |= HICN_FACE_FLAGS_FACE;
adj = adj_get (face->shared.adj);
diff --git a/hicn-plugin/src/faces/udp/dpo_udp.h b/hicn-plugin/src/faces/udp/dpo_udp.h
index 42b9864df..06c65a9c2 100644
--- a/hicn-plugin/src/faces/udp/dpo_udp.h
+++ b/hicn-plugin/src/faces/udp/dpo_udp.h
@@ -24,6 +24,9 @@
#include "../face.h"
#include "../../error.h"
+extern u32 strategy_face_udp4_vlib_edge;
+extern u32 strategy_face_udp6_vlib_edge;
+
/**
* @brief Initialize the internal structures of the dpo udp face module.
@@ -88,7 +91,7 @@ hicn_dpo_udp4_lock (dpo_id_t * dpo,
index_t dpoi_index = hicn_dpoi_get_index (face);
dpo_set (dpo, hicn_face_udp_type, DPO_PROTO_IP4, dpoi_index);
- dpo->dpoi_next_node = ~0;
+ dpo->dpoi_next_node = strategy_face_udp4_vlib_edge;
dpo_lock (dpo);
*hicnb_flags = HICN_BUFFER_FLAGS_DEFAULT;
@@ -208,7 +211,7 @@ hicn_dpo_udp6_lock (dpo_id_t * dpo,
hicn_face_id_t dpoi_index = hicn_dpoi_get_index (face);
dpo_set (dpo, hicn_face_udp_type, DPO_PROTO_IP6, dpoi_index);
- dpo->dpoi_next_node = ~0;
+ dpo->dpoi_next_node = strategy_face_udp6_vlib_edge;
dpo_lock (dpo);
*hicnb_flags = HICN_BUFFER_FLAGS_DEFAULT;
diff --git a/hicn-plugin/src/faces/udp/face_udp.h b/hicn-plugin/src/faces/udp/face_udp.h
index 2bd420b55..cea3e7262 100644
--- a/hicn-plugin/src/faces/udp/face_udp.h
+++ b/hicn-plugin/src/faces/udp/face_udp.h
@@ -248,7 +248,9 @@ hicn_iface_udp6_add (const ip6_address_t * local_addr,
remote_port, &key);
*pfaceid = hicn_dpoi_get_index (face);
- mhash_set_mem (&hicn_face_udp_hashtb, &key, (uword *) & pfaceid, 0);
+ hicn_face_id_t dpoi_index = hicn_dpoi_get_index (face);
+
+ mhash_set_mem (&hicn_face_udp_hashtb, &key, (uword *) & dpoi_index, 0);
for (int i = 0; i < HICN_N_COUNTER; i++)
{
@@ -300,7 +302,9 @@ hicn_iface_udp4_add (const ip4_address_t * local_addr,
remote_port, &key);
*pfaceid = hicn_dpoi_get_index (face);
- mhash_set_mem (&hicn_face_udp_hashtb, &key, (uword *) & pfaceid, 0);
+ hicn_face_id_t dpoi_index = hicn_dpoi_get_index (face);
+
+ mhash_set_mem (&hicn_face_udp_hashtb, &key, (uword *) & dpoi_index, 0);
for (int i = 0; i < HICN_N_COUNTER; i++)
{
diff --git a/hicn-plugin/src/faces/udp/face_udp_node.c b/hicn-plugin/src/faces/udp/face_udp_node.c
index 5d304693d..232b86d70 100644
--- a/hicn-plugin/src/faces/udp/face_udp_node.c
+++ b/hicn-plugin/src/faces/udp/face_udp_node.c
@@ -138,8 +138,8 @@ typedef enum
\
inner_ip_hdr = (u8 *)(udp_hdr + 1); \
u8 is_v6 = hicn_is_v6((hicn_header_t *)inner_ip_hdr); \
- u8 is_icmp = is_v6*(inner_ip_hdr[7] == IPPROTO_ICMPV6) + \
- (1 - is_v6)*(inner_ip_hdr[10] == IPPROTO_ICMPV4); \
+ u8 is_icmp = is_v6*(inner_ip_hdr[6] == IPPROTO_ICMPV6) + \
+ (1 - is_v6)*(inner_ip_hdr[9] == IPPROTO_ICMPV4); \
\
ret = HICN_DPO_UDP_LOCK_IP##ipv \
(&(hicnb0->face_dpo_id), \
@@ -236,13 +236,13 @@ typedef enum
\
inner_ip_hdr0 = (u8 *)(udp_hdr0 + 1); \
u8 is_v6_0 = hicn_is_v6((hicn_header_t *)inner_ip_hdr0); \
- u8 is_icmp0 = is_v6_0*(inner_ip_hdr0[7] == IPPROTO_ICMPV6) + \
- (1 - is_v6_0)*(inner_ip_hdr0[10] == IPPROTO_ICMPV4); \
+ u8 is_icmp0 = is_v6_0*(inner_ip_hdr0[6] == IPPROTO_ICMPV6) + \
+ (1 - is_v6_0)*(inner_ip_hdr0[9] == IPPROTO_ICMPV4); \
\
inner_ip_hdr1 = (u8 *)(udp_hdr1 + 1); \
u8 is_v6_1 = hicn_is_v6((hicn_header_t *)inner_ip_hdr1); \
- u8 is_icmp1 = is_v6_1*(inner_ip_hdr1[7] == IPPROTO_ICMPV6) + \
- (1 - is_v6_1)*(inner_ip_hdr1[10] == IPPROTO_ICMPV4); \
+ u8 is_icmp1 = is_v6_1*(inner_ip_hdr1[6] == IPPROTO_ICMPV6) + \
+ (1 - is_v6_1)*(inner_ip_hdr1[9] == IPPROTO_ICMPV4); \
\
ret0 = HICN_DPO_UDP_LOCK_IP##ipv \
(&(hicnb0->face_dpo_id), \
@@ -507,7 +507,6 @@ hicn_face_udp4_encap (vlib_main_t * vm,
ip4_header_t *ip0;
udp_header_t *udp0;
hicn_face_udp_t *face_udp = (hicn_face_udp_t *) face->data;
- ip_adjacency_t *adj = adj_get (face->shared.adj);
/* ip */
ip0 = vlib_buffer_get_current (outer_b0);
@@ -535,11 +534,19 @@ hicn_face_udp4_encap (vlib_main_t * vm,
length /* changed member */ );
ip0->checksum = sum0;
+ int is_iface = 0;
+ ip_adjacency_t *adj;
+ if (PREDICT_FALSE (face->shared.adj == ~0))
+ is_iface = 1;
+ else
+ adj = adj_get (face->shared.adj);
+
/* In case the adj is not complete, we look if a better one exists, otherwise we send an arp request
* This is necessary to account for the case in which when we create a face, there isn't a /128(/32) adjacency and we match with a more general route which is in glean state
* In this case in fact, the general route will not be update upone receiving of a arp or neighbour responde, but a new /128(/32) will be created
*/
- if (PREDICT_FALSE (adj->lookup_next_index < IP_LOOKUP_NEXT_REWRITE))
+ if (PREDICT_FALSE
+ (is_iface || adj->lookup_next_index < IP_LOOKUP_NEXT_REWRITE))
{
fib_prefix_t fib_pfx;
fib_node_index_t fib_entry_index;
@@ -555,6 +562,8 @@ hicn_face_udp4_encap (vlib_main_t * vm,
fib_entry_index = fib_table_lookup (fib_index, &fib_pfx);
face->shared.adj = fib_entry_get_adj (fib_entry_index);
+ face->shared.flags &= ~HICN_FACE_FLAGS_IFACE;
+ face->shared.flags |= HICN_FACE_FLAGS_FACE;
adj = adj_get (face->shared.adj);
}
@@ -573,7 +582,6 @@ hicn_face_udp6_encap (vlib_main_t * vm,
ip6_header_t *ip0;
udp_header_t *udp0;
hicn_face_udp_t *face_udp = (hicn_face_udp_t *) face->data;
- ip_adjacency_t *adj = adj_get (face->shared.adj);
/* ip */
ip0 = vlib_buffer_get_current (outer_b0);
@@ -595,11 +603,18 @@ hicn_face_udp6_encap (vlib_main_t * vm,
if (udp0->checksum == 0)
udp0->checksum = 0xffff;
+ int is_iface = 0;
+ ip_adjacency_t *adj;
+ if (PREDICT_FALSE (face->shared.adj == ~0))
+ is_iface = 1;
+ else
+ adj = adj_get (face->shared.adj);
+
/* In case the adj is not complete, we look if a better one exists, otherwise we send an arp request
* This is necessary to account for the case in which when we create a face, there isn't a /128(/32) adjacency and we match with a more general route which is in glean state
* In this case in fact, the general route will not be update upone receiving of a arp or neighbour responde, but a new /128(/32) will be created
*/
- if (PREDICT_FALSE (adj->lookup_next_index < IP_LOOKUP_NEXT_REWRITE))
+ if (PREDICT_FALSE (is_iface || adj->lookup_next_index < IP_LOOKUP_NEXT_REWRITE))
{
fib_prefix_t fib_pfx;
fib_node_index_t fib_entry_index;
@@ -615,6 +630,8 @@ hicn_face_udp6_encap (vlib_main_t * vm,
fib_entry_index = fib_table_lookup (fib_index, &fib_pfx);
face->shared.adj = fib_entry_get_adj (fib_entry_index);
+ face->shared.flags &= ~HICN_FACE_FLAGS_IFACE;
+ face->shared.flags |= HICN_FACE_FLAGS_FACE;
adj = adj_get (face->shared.adj);
}
diff --git a/hicn-plugin/src/faces/udp/iface_udp_node.c b/hicn-plugin/src/faces/udp/iface_udp_node.c
index 738aad829..1fdd68f0b 100644
--- a/hicn-plugin/src/faces/udp/iface_udp_node.c
+++ b/hicn-plugin/src/faces/udp/iface_udp_node.c
@@ -39,13 +39,11 @@ hicn_iface_udp_init (vlib_main_t * vm)
{
data_fwd_face_udp4_vlib_edge = vlib_node_add_next (vm,
hicn_data_fwd_node.index,
- hicn_iface_udp4_output_node.
- index);
+ hicn_iface_udp4_output_node.index);
data_fwd_face_udp6_vlib_edge = vlib_node_add_next (vm,
hicn_data_fwd_node.index,
- hicn_iface_udp6_output_node.
- index);
+ hicn_iface_udp6_output_node.index);
u32 temp_index4 = vlib_node_add_next (vm,
hicn_interest_hitcs_node.index,
@@ -173,8 +171,8 @@ typedef enum
\
inner_ip_hdr = (u8 *)(udp_hdr + 1); \
u8 is_v6 = hicn_is_v6((hicn_header_t *)inner_ip_hdr); \
- u8 is_icmp = is_v6*(inner_ip_hdr[7] == IPPROTO_ICMPV6) + \
- (1 - is_v6)*(inner_ip_hdr[10] == IPPROTO_ICMPV4); \
+ u8 is_icmp = is_v6*(inner_ip_hdr[6] == IPPROTO_ICMPV6) + \
+ (1 - is_v6)*(inner_ip_hdr[9] == IPPROTO_ICMPV4); \
\
next0 = is_icmp*NEXT_MAPME_UDP##ipv + \
(1-is_icmp)*NEXT_INTEREST_UDP##ipv; \
@@ -267,10 +265,10 @@ typedef enum
inner_ip_hdr1 = (u8 *)(udp_hdr1 + 1); \
u8 is_v6_0 = hicn_is_v6((hicn_header_t *)inner_ip_hdr0); \
u8 is_v6_1 = hicn_is_v6((hicn_header_t *)inner_ip_hdr1); \
- u8 is_icmp0 = is_v6_0*(inner_ip_hdr0[7] == IPPROTO_ICMPV6) + \
- (1 - is_v6_0)*(inner_ip_hdr0[10] == IPPROTO_ICMPV4); \
- u8 is_icmp1 = is_v6_1*(inner_ip_hdr1[7] == IPPROTO_ICMPV6) + \
- (1 - is_v6_1)*(inner_ip_hdr1[10] == IPPROTO_ICMPV4); \
+ u8 is_icmp0 = is_v6_0*(inner_ip_hdr0[6] == IPPROTO_ICMPV6) + \
+ (1 - is_v6_0)*(inner_ip_hdr0[9] == IPPROTO_ICMPV4); \
+ u8 is_icmp1 = is_v6_1*(inner_ip_hdr1[6] == IPPROTO_ICMPV6) + \
+ (1 - is_v6_1)*(inner_ip_hdr1[9] == IPPROTO_ICMPV4); \
\
next0 = is_icmp0*NEXT_MAPME_UDP##ipv + \
(1-is_icmp0)*NEXT_INTEREST_UDP##ipv; \
diff --git a/hicn-plugin/src/mapme.h b/hicn-plugin/src/mapme.h
index e0786eff8..cf68f6d00 100644
--- a/hicn-plugin/src/mapme.h
+++ b/hicn-plugin/src/mapme.h
@@ -125,6 +125,7 @@ hicn_mapme_tfib_add (hicn_mapme_tfib_t * tfib, dpo_id_t * face_id)
static_always_inline int
hicn_mapme_tfib_del (hicn_mapme_tfib_t * tfib, dpo_id_t * face_id)
{
+ dpo_id_t invalid = NEXT_HOP_INVALID;
/*
* We need to do a linear scan of TFIB entries to find the one to
* remove
@@ -133,7 +134,11 @@ hicn_mapme_tfib_del (hicn_mapme_tfib_t * tfib, dpo_id_t * face_id)
u8 pos = ~0;
for (pos = start_pos; pos < HICN_PARAM_FIB_ENTRY_NHOPS_MAX; pos++)
if (dpo_cmp (&tfib->next_hops[pos], face_id) == 0)
- break;
+ {
+ hicn_face_unlock (&tfib->next_hops[pos]);
+ tfib->next_hops[pos] = invalid;
+ break;
+ }
if (pos == HICN_PARAM_FIB_ENTRY_NHOPS_MAX)
/* Not found */
return -1;
@@ -215,7 +220,7 @@ extern dpo_type_t hicn_face_ip_type;
extern u32 strategy_face_ip4_vlib_edge;
extern u32 strategy_face_ip6_vlib_edge;
/* in faces/udp/face_udp.c */
-extern u32 strategy_face_udp6_vlib_edge;
+extern u32 strategy_face_udp4_vlib_edge;
extern u32 strategy_face_udp6_vlib_edge;
@@ -244,7 +249,7 @@ hicn_mapme_get_dpo_vlib_edge (dpo_id_t * dpo)
switch (dpo->dpoi_proto)
{
case DPO_PROTO_IP4:
- return strategy_face_udp6_vlib_edge;
+ return strategy_face_udp4_vlib_edge;
case DPO_PROTO_IP6:
return strategy_face_udp6_vlib_edge;
default:
@@ -293,10 +298,9 @@ hicn_mapme_get_dpo_face_node (dpo_id_t * dpo)
}
}
-
-#define DEBUG(...) vlib_log_debug(mapme_main.log_class, __VA_ARGS__)
-#define WARN(...) vlib_log_warn(mapme_main.log_class, __VA_ARGS__)
-#define ERROR(...) vlib_log_err(mapme_main.log_class, __VA_ARGS__)
+#define DEBUG(...) //vlib_log_debug(mapme_main.log_class, __VA_ARGS__)
+#define WARN(...) //vlib_log_warn(mapme_main.log_class, __VA_ARGS__)
+#define ERROR(...) //vlib_log_err(mapme_main.log_class, __VA_ARGS__)
#endif /* __HICN_MAPME__ */
diff --git a/hicn-plugin/src/mapme_ctrl_node.c b/hicn-plugin/src/mapme_ctrl_node.c
index 9fc0c9055..7e07045c2 100644
--- a/hicn-plugin/src/mapme_ctrl_node.c
+++ b/hicn-plugin/src/mapme_ctrl_node.c
@@ -157,15 +157,15 @@ hicn_mapme_process_ctrl (vlib_main_t * vm, vlib_buffer_t * b,
}
/* ... and set ingress face as next_hop */
+ in_face->dpoi_next_node = hicn_mapme_get_dpo_vlib_edge (in_face);
hicn_mapme_nh_set (tfib, in_face);
/* We transmit both the prefix and the full dpo (type will be needed to pick the right transmit node */
- retx_t *retx =
- vlib_process_signal_event_data (vm,
- hicn_mapme_eventmgr_process_node.
- index,
- HICN_MAPME_EVENT_FACE_NH_SET, 1,
- sizeof (retx_t));
+ retx_t *retx = vlib_process_signal_event_data (vm,
+ hicn_mapme_eventmgr_process_node.index,
+ HICN_MAPME_EVENT_FACE_NH_SET,
+ 1,
+ sizeof (retx_t));
*retx = (retx_t)
{
.prefix = prefix,.dpo = *dpo};
@@ -183,12 +183,11 @@ hicn_mapme_process_ctrl (vlib_main_t * vm, vlib_buffer_t * b,
hicn_mapme_nh_add (tfib, in_face);
/* Multipath, multihoming, multiple producers or duplicate interest */
- retx_t *retx =
- vlib_process_signal_event_data (vm,
- hicn_mapme_eventmgr_process_node.
- index,
- HICN_MAPME_EVENT_FACE_NH_ADD, 1,
- sizeof (retx_t));
+ retx_t *retx = vlib_process_signal_event_data (vm,
+ hicn_mapme_eventmgr_process_node.index,
+ HICN_MAPME_EVENT_FACE_NH_ADD,
+ 1,
+ sizeof (retx_t));
*retx = (retx_t)
{
.prefix = prefix,.dpo = *dpo};
@@ -201,12 +200,11 @@ hicn_mapme_process_ctrl (vlib_main_t * vm, vlib_buffer_t * b,
*/
hicn_mapme_tfib_add (tfib, in_face);
- retx_t *retx =
- vlib_process_signal_event_data (vm,
- hicn_mapme_eventmgr_process_node.
- index,
- HICN_MAPME_EVENT_FACE_PH_ADD, 1,
- sizeof (retx_t));
+ retx_t *retx = vlib_process_signal_event_data (vm,
+ hicn_mapme_eventmgr_process_node.index,
+ HICN_MAPME_EVENT_FACE_PH_ADD,
+ 1,
+ sizeof (retx_t));
*retx = (retx_t)
{
.prefix = prefix,.dpo = *dpo};
@@ -268,6 +266,8 @@ hicn_mapme_ctrl_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
preprocess_in_face (hb->type, &hb->face_dpo_id, &in_face);
hicn_mapme_process_ctrl (vm, b0, &in_face);
+ vnet_buffer (b0)->ip.adj_index[VLIB_TX] = in_face.dpoi_index;
+
vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
n_left_to_next, bi0, next0);