aboutsummaryrefslogtreecommitdiffstats
path: root/hicn-plugin
diff options
context:
space:
mode:
Diffstat (limited to 'hicn-plugin')
-rw-r--r--hicn-plugin/src/cli.c11
-rw-r--r--hicn-plugin/src/faces/ip/face_ip_cli.c61
-rw-r--r--hicn-plugin/src/hicn_api.c63
-rw-r--r--hicn-plugin/src/hicn_api_test.c10
-rw-r--r--hicn-plugin/src/punt.c142
-rw-r--r--hicn-plugin/src/punt.h14
-rw-r--r--hicn-plugin/src/route.c2
7 files changed, 217 insertions, 86 deletions
diff --git a/hicn-plugin/src/cli.c b/hicn-plugin/src/cli.c
index 12a65495a..3905e0af1 100644
--- a/hicn-plugin/src/cli.c
+++ b/hicn-plugin/src/cli.c
@@ -658,7 +658,7 @@ hicn_cli_punting_command_fn (vlib_main_t * vm, unformat_input_t * main_input,
clib_host_to_net_u16
(src_port),
clib_host_to_net_u16
- (dst_port));
+ (dst_port), NO_L2);
else
return (clib_error_return
(0,
@@ -667,8 +667,8 @@ hicn_cli_punting_command_fn (vlib_main_t * vm, unformat_input_t * main_input,
else
{
ret =
- hicn_punt_interest_data_for_ethernet (vm, &prefix, subnet_mask,
- sw_if_index, type);
+ hicn_punt_interest_data_for_ip (vm, &prefix, subnet_mask,
+ sw_if_index, type, NO_L2);
}
}
break;
@@ -689,9 +689,10 @@ hicn_cli_punting_command_fn (vlib_main_t * vm, unformat_input_t * main_input,
ret = ip46_address_is_ip4 (&prefix) ?
hicn_punt_remove_ip4_address (vm, &(prefix.ip4), subnet_mask, 1,
sw_if_index,
- 0) :
+ 0, NO_L2) :
hicn_punt_remove_ip6_address (vm, (ip6_address_t *) & prefix,
- subnet_mask, 1, sw_if_index, 0);
+ subnet_mask, 1, sw_if_index, 0,
+ NO_L2);
}
}
break;
diff --git a/hicn-plugin/src/faces/ip/face_ip_cli.c b/hicn-plugin/src/faces/ip/face_ip_cli.c
index 534ae7f63..ba7765541 100644
--- a/hicn-plugin/src/faces/ip/face_ip_cli.c
+++ b/hicn-plugin/src/faces/ip/face_ip_cli.c
@@ -60,10 +60,12 @@ hicn_face_ip_cli_set_command_fn (vlib_main_t * vm,
else if (unformat (line_input, "add"))
{
face_op = HICN_FACE_ADD;
- if (unformat (line_input, "local %U remote %U intfc %U",
- unformat_ip46_address, &local_addr, IP46_TYPE_ANY,
- unformat_ip46_address, &remote_addr, IP46_TYPE_ANY,
- unformat_vnet_sw_interface, vnm, &sw_if));
+ if (unformat (line_input, "local %U ",
+ unformat_ip46_address, &local_addr, IP46_TYPE_ANY));
+ else if (unformat (line_input, "remote %U intfc %U",
+ unformat_ip46_address, &remote_addr,
+ IP46_TYPE_ANY, unformat_vnet_sw_interface, vnm,
+ &sw_if));
else
{
return clib_error_return (0, "%s '%U'",
@@ -90,6 +92,57 @@ hicn_face_ip_cli_set_command_fn (vlib_main_t * vm,
}
}
+ if (ip46_address_is_zero (&local_addr))
+ {
+ if (!vnet_sw_interface_is_valid (vnm, sw_if))
+ return clib_error_return (0, "interface not valid");
+
+ if (ip46_address_is_ip4 (&remote_addr))
+ {
+ ip_interface_address_t *interface_address;
+ ip4_address_t *addr =
+ ip4_interface_address_matching_destination (&ip4_main,
+ &remote_addr.ip4,
+ sw_if,
+ &interface_address);
+
+ if (addr == NULL)
+ addr = ip4_interface_first_address (&ip4_main,
+ sw_if, &interface_address);
+
+ if (addr == NULL)
+ return clib_error_return (0,
+ "no valid ip address on interface %d",
+ sw_if);
+
+ ip46_address_set_ip4 (&local_addr, addr);
+ }
+ else
+ {
+ ip_interface_address_t *interface_address;
+ ip6_interface_address_matching_destination (&ip6_main,
+ &remote_addr.ip6, sw_if,
+ &interface_address);
+
+ ip6_address_t *addr = NULL;
+ if (interface_address != NULL)
+ addr =
+ (ip6_address_t *)
+ ip_interface_address_get_address (&ip6_main.lookup_main,
+ interface_address);
+
+ if (addr == NULL)
+ addr = ip6_interface_first_address (&ip6_main, sw_if);
+
+ if (addr == NULL)
+ return clib_error_return (0,
+ "no valid ip address on interface %d",
+ sw_if);
+
+ ip46_address_set_ip6 (&local_addr, addr);
+ }
+ }
+
int rv;
switch (face_op)
{
diff --git a/hicn-plugin/src/hicn_api.c b/hicn-plugin/src/hicn_api.c
index 6249d6e5e..b4d518774 100644
--- a/hicn-plugin/src/hicn_api.c
+++ b/hicn-plugin/src/hicn_api.c
@@ -208,15 +208,68 @@ vl_api_hicn_api_face_ip_add_t_handler (vl_api_hicn_api_face_ip_add_t * mp)
remote_addr.as_u64[1] =
clib_net_to_host_u64 (((u64 *) (&mp->remote_addr))[1]);
- u32 swif = clib_net_to_host_u32 (mp->swif);
+ u32 sw_if = clib_net_to_host_u32 (mp->swif);
+
+ if (ip46_address_is_zero (&local_addr))
+ {
+ if (vnet_sw_interface_is_valid (vnm, sw_if))
+ {
+ rv = HICN_ERROR_NONE;
+ }
+
+ if (rv == HICN_ERROR_NONE && ip46_address_is_ip4 (&remote_addr))
+ {
+ ip_interface_address_t *interface_address;
+ ip4_address_t *addr =
+ ip4_interface_address_matching_destination (&ip4_main,
+ &remote_addr.ip4,
+ sw_if,
+ &interface_address);
+ if (addr == NULL)
+ addr = ip4_interface_first_address (&ip4_main,
+ sw_if, &interface_address);
+
+ if (addr == NULL)
+ rv = HICN_ERROR_UNSPECIFIED;
+ else
+ ip46_address_set_ip4 (&local_addr, addr);
+ }
+ else
+ {
+ ip_interface_address_t *interface_address;
+ ip6_interface_address_matching_destination (&ip6_main,
+ &remote_addr.ip6, sw_if,
+ &interface_address);
+ ip6_address_t *addr = NULL;
+ if (rv == HICN_ERROR_NONE && interface_address != NULL)
+ {
+ addr =
+ (ip6_address_t *)
+ ip_interface_address_get_address (&ip6_main.lookup_main,
+ interface_address);
+ }
+ else
+ {
+ addr = ip6_interface_first_address (&ip6_main, sw_if);
+ }
- if (vnet_get_sw_interface_safe (vnm, swif) != NULL)
- rv = hicn_face_ip_add (&local_addr, &remote_addr, swif, &faceid);
+ if (addr == NULL)
+ rv = HICN_ERROR_UNSPECIFIED;
+ else
+ ip46_address_set_ip6 (&local_addr, addr);
+ }
+ }
+
+ if (rv == HICN_ERROR_NONE)
+ rv = hicn_face_ip_add (&local_addr, &remote_addr, sw_if, &faceid);
+ else
+ faceid = HICN_FACE_NULL;
/* *INDENT-OFF* */
REPLY_MACRO2 (VL_API_HICN_API_FACE_IP_ADD_REPLY /* , rmp, mp, rv */ ,(
{
- rmp->faceid = clib_host_to_net_u16 ((u16) faceid);
+ rmp->faceid = clib_host_to_net_u16 ((u32) faceid);
+ rmp->retval = rv;
}));
/* *INDENT-ON* */
}
@@ -500,7 +553,7 @@ static void vl_api_hicn_api_punting_add_t_handler
u32 swif = clib_net_to_host_u32 (mp->swif);
rv =
- hicn_punt_interest_data_for_ethernet (vm, &prefix, subnet_mask, swif, 0);
+ hicn_punt_interest_data_for_ip (vm, &prefix, subnet_mask, swif, 0, NO_L2);
REPLY_MACRO (VL_API_HICN_API_PUNTING_ADD_REPLY /* , rmp, mp, rv */ );
}
diff --git a/hicn-plugin/src/hicn_api_test.c b/hicn-plugin/src/hicn_api_test.c
index 909bc540f..4225f0078 100644
--- a/hicn-plugin/src/hicn_api_test.c
+++ b/hicn-plugin/src/hicn_api_test.c
@@ -362,11 +362,9 @@ api_hicn_api_face_ip_add (vat_main_t * vam)
}
/* Check for presence of both addresses */
- if ((!ip46_address_is_zero (&local_addr)
- && ! !ip46_address_is_zero (&remote_addr)))
+ if (ip46_address_is_zero (&remote_addr))
{
- clib_warning
- ("Incomplete IP face. Please specify local and remote address");
+ clib_warning ("Incomplete IP face. Please specify remote address");
return (1);
}
/* Construct the API message */
@@ -558,7 +556,7 @@ api_hicn_api_face_stats_dump (vat_main_t * vam)
/* memif-details message handler */
static void
-vl_api_hicn_api_face_stats_details_t_handler
+ vl_api_hicn_api_face_stats_details_t_handler
(vl_api_hicn_api_face_stats_details_t * mp)
{
vat_main_t *vam = hicn_test_main.vat_main;
@@ -1071,7 +1069,7 @@ _(hicn_api_node_params_set, "PIT size <sz> CS size <sz>" \
_(hicn_api_node_params_get, "") \
_(hicn_api_node_stats_get, "") \
_(hicn_api_face_ip_del, "face <faceID>") \
-_(hicn_api_face_ip_add, "add <swif> <address>") \
+_(hicn_api_face_ip_add, "local <address> remote <address> intfc <swif>")\
_(hicn_api_face_stats_dump, "") \
_(hicn_api_route_nhops_add, "add prefix <IP4/IP6>/<subnet> face <faceID> weight <weight>") \
_(hicn_api_face_ip_params_get, "face <faceID>") \
diff --git a/hicn-plugin/src/punt.c b/hicn-plugin/src/punt.c
index ea553bf76..68c0bafb9 100644
--- a/hicn-plugin/src/punt.c
+++ b/hicn-plugin/src/punt.c
@@ -89,11 +89,11 @@ ip_version_t ipv66 = {
.ip_version = 0x60,
};
-#define _(NAME, BASE, LAYER, FIELD, PUNT_ID) \
- field_t NAME = { \
- .offset = BASE + offsetof(LAYER, FIELD), \
- .len = STRUCT_SIZE_OF(LAYER, FIELD), \
- .punt_id = PUNT_ID, \
+#define _(NAME, BASE, LAYER, FIELD, PUNT_ID) \
+ field_t NAME = { \
+ .offset = BASE + offsetof(LAYER, FIELD), \
+ .len = STRUCT_SIZE_OF(LAYER, FIELD), \
+ .punt_id = PUNT_ID, \
};
foreach_field
#undef _
@@ -108,7 +108,6 @@ foreach_field
#define NEXT_MAPME_ACK4 hicn_punt_glb.next_hit_data_ipv4
#define NEXT_MAPME_CTRL6 hicn_punt_glb.next_hit_interest_ipv6
#define NEXT_MAPME_ACK6 hicn_punt_glb.next_hit_data_ipv6
-
/* Maximum number of vector allowed in match. Value hardcoded in vnet_classify_hash_packet_inline in vnet_classify.h */
#define MAX_MATCH_SIZE 5
/**
@@ -117,7 +116,7 @@ foreach_field
*
*
*/
-hicn_punt_glb_t hicn_punt_glb;
+ hicn_punt_glb_t hicn_punt_glb;
/**
* We use the function build_bit_array to populate an initially empty buffer
@@ -371,28 +370,29 @@ hicn_punt_add_del_vnettbl (ip_version_t * ip, field_t * field, u8 mask,
int
hicn_punt_add_del_vnettbl_udp (ip_version_t * outer, ip_version_t * inner,
field_t * field, u8 mask, u32 next_tbl_index,
- u32 intfc, u8 base_offset, int is_add)
+ u32 intfc, u8 base_offset, u8 use_current_data,
+ int is_add)
{
u8 udp_mask[inner->addr_len_bits];
build_ip_address_mask (mask, udp_mask, sizeof (udp_mask));
u16 port_value = 0xffff;
u8 protocol_value = 0xff;
-
+
return _hicn_punt_add_del_vnettbl (outer, field->punt_id, mask,
next_tbl_index, intfc, base_offset,
is_add,
- HICN_CLASSIFY_NO_CURRENT_DATA_FLAG,
+ use_current_data,
outer->protocol_field, &protocol_value,
outer->udp_sport, &port_value,
outer->udp_dport, &port_value, field,
udp_mask, NULL);
}
-#define hicn_punt_add_vnettbl_udp(outer, inner, field, mask, next_tbl_index, intfc, base_offset) \
- (hicn_punt_add_del_vnettbl_udp(outer, inner, field, mask, next_tbl_index, intfc, base_offset, OP_ADD))
+#define hicn_punt_add_vnettbl_udp(outer, inner, field, mask, next_tbl_index, intfc, base_offset, use_current_data) \
+ (hicn_punt_add_del_vnettbl_udp(outer, inner, field, mask, next_tbl_index, intfc, base_offset, use_current_data, OP_ADD))
-#define hicn_punt_del_vnettbl_udp(outer, inner, field, mask, next_tbl_index, intfc, base_offset) \
- (hicn_punt_add_del_vnettbl_udp(outer, inner, field, mask, next_tbl_index, intfc, base_offset, OP_DEL))
+#define hicn_punt_del_vnettbl_udp(outer, inner, field, mask, next_tbl_index, intfc, base_offset, use_current_data) \
+ (hicn_punt_add_del_vnettbl_udp(outer, inner, field, mask, next_tbl_index, intfc, base_offset, use_current_data, OP_DEL))
/**
* @brief Add or remove a vnet session matching the list of fields/values passed
@@ -481,7 +481,7 @@ hicn_punt_add_del_vnetssn_udp (ip_version_t * outer, ip_version_t * inner,
u8 mask, u32 next_hit_index, u32 intfc,
u8 base_offset, u8 protocol, u16 sport,
u16 dport, int is_add)
-{
+{
return _hicn_punt_add_del_vnetssn (outer, field->punt_id, mask,
next_hit_index, intfc, base_offset,
is_add, outer->protocol_field, &protocol,
@@ -520,7 +520,7 @@ hicn_punt_enable_disable_vnet_ip4_table_on_intf (vlib_main_t * vm,
int
hicn_punt_remove_ip4_address (vlib_main_t * vm, ip4_address_t * addr,
u8 mask, int skip, u32 sw_if_index,
- int is_enable)
+ int is_enable, u8 with_l2)
{
vnet_classify_main_t *cm = &vnet_classify_main;
@@ -528,7 +528,7 @@ hicn_punt_remove_ip4_address (vlib_main_t * vm, ip4_address_t * addr,
u32 table_index = ~0;
- u32 base_offset = (skip ? ETH_L2 : NO_L2);
+ u32 base_offset = (with_l2 ? ETH_L2 : NO_L2);
ip46_address_t addr46;
ip46_address_set_ip4 (&addr46, addr);
@@ -562,7 +562,7 @@ hicn_punt_remove_ip4_address (vlib_main_t * vm, ip4_address_t * addr,
int
hicn_punt_remove_ip6_address (vlib_main_t * vm, ip6_address_t * addr,
u8 mask, int skip, u32 sw_if_index,
- int is_enable)
+ int is_enable, u8 with_l2)
{
vnet_classify_main_t *cm = &vnet_classify_main;
@@ -570,7 +570,7 @@ hicn_punt_remove_ip6_address (vlib_main_t * vm, ip6_address_t * addr,
u32 table_index = ~0;
- u32 base_offset = (skip ? ETH_L2 : NO_L2);
+ u32 base_offset = (with_l2 ? ETH_L2 : NO_L2);
hicn_punt_del_vnetssn (&ipv6, &ipv6_src, (ip46_address_t *) addr, mask,
hicn_punt_glb.next_hit_data_ipv6, sw_if_index,
@@ -763,10 +763,16 @@ hicn_punt_init (vlib_main_t * vm)
u32
hicn_punt_interest_data_for_udp (vlib_main_t * vm,
ip46_address_t * prefix, u8 mask,
- u32 swif, u8 punt_type, u16 sport, u16 dport)
+ u32 swif, u8 punt_type, u16 sport, u16 dport,
+ u8 with_l2)
{
int skip = 1;
u32 table_index;
+ // If we want l2 then we punt from data (and not current)
+ u8 use_current_data =
+ with_l2 ? HICN_CLASSIFY_NO_CURRENT_DATA_FLAG :
+ HICN_CLASSIFY_CURRENT_DATA_FLAG;
+ u8 base_offset = with_l2 ? ETH_L2 : NO_L2;
if (punt_type != HICN_PUNT_IP_TYPE && punt_type != HICN_PUNT_UDP4_TYPE
&& punt_type != HICN_PUNT_UDP6_TYPE)
@@ -779,16 +785,18 @@ hicn_punt_interest_data_for_udp (vlib_main_t * vm,
if (punt_type == HICN_PUNT_UDP4_TYPE)
{
- skip = 2;
+ //If we consider ethernet we can skip 32 bytes, otherwise only 16
+ skip = 1 + with_l2;
/* Create Vnet table for a given mask */
hicn_punt_add_vnettbl_udp (&ipv44, &ipv4, &udp44_src, mask, ~0,
- swif, ETH_L2);
+ swif, base_offset, use_current_data);
table_index =
hicn_punt_glb.udp44_vnet_tbl_idx[swif][skip][HICN_PUNT_SRC][mask];
hicn_punt_add_vnettbl_udp (&ipv44, &ipv4, &udp44_dst, mask,
- table_index, swif, ETH_L2);
+ table_index, swif, base_offset,
+ use_current_data);
/*
* Add a session for the specified ip address and
* subnet mask
@@ -796,28 +804,32 @@ hicn_punt_interest_data_for_udp (vlib_main_t * vm,
hicn_punt_add_vnetssn_udp (&ipv44, &ipv4, &udp44_src,
prefix, mask,
hicn_punt_glb.next_hit_data_udp4,
- swif, ETH_L2, IPPROTO_UDP, sport, dport);
+ swif, base_offset, IPPROTO_UDP, sport,
+ dport);
hicn_punt_add_vnetssn_udp (&ipv44, &ipv4, &udp44_dst,
prefix, mask,
hicn_punt_glb.next_hit_interest_udp4,
- swif, ETH_L2, IPPROTO_UDP, sport, dport);
+ swif, base_offset, IPPROTO_UDP, sport,
+ dport);
hicn_punt_enable_disable_vnet_ip4_table_on_intf (vm, swif,
OP_ENABLE);
}
else //PUNTING is UDP6
{
- skip = 3;
+ //If we consider ethernet we can skip 48 bytes, otherwise only 32
+ skip = 2 + with_l2;
/* Create Vnet table for a given mask */
hicn_punt_add_vnettbl_udp (&ipv64, &ipv6, &udp64_src, mask, ~0,
- swif, ETH_L2);
+ swif, base_offset, use_current_data);
table_index =
hicn_punt_glb.udp64_vnet_tbl_idx[swif][skip][HICN_PUNT_SRC][mask];
hicn_punt_add_vnettbl_udp (&ipv64, &ipv6, &udp64_dst, mask,
- table_index, swif, ETH_L2);
+ table_index, swif, base_offset,
+ use_current_data);
/*
* Add a session for the specified ip address and
@@ -826,12 +838,14 @@ hicn_punt_interest_data_for_udp (vlib_main_t * vm,
hicn_punt_add_vnetssn_udp (&ipv64, &ipv4, &udp64_src,
prefix, mask,
hicn_punt_glb.next_hit_data_udp6,
- swif, ETH_L2, IPPROTO_UDP, sport, dport);
+ swif, base_offset, IPPROTO_UDP, sport,
+ dport);
hicn_punt_add_vnetssn_udp (&ipv64, &ipv4, &udp64_dst,
prefix, mask,
hicn_punt_glb.next_hit_interest_udp6,
- swif, ETH_L2, IPPROTO_UDP, sport, dport);
+ swif, base_offset, IPPROTO_UDP, sport,
+ dport);
hicn_punt_enable_disable_vnet_ip6_table_on_intf (vm, swif,
OP_ENABLE);
@@ -841,18 +855,20 @@ hicn_punt_interest_data_for_udp (vlib_main_t * vm,
{
if (punt_type == HICN_PUNT_UDP4_TYPE)
{
- skip = 2;
+ //If we consider ethernet we can skip 32 bytes, otherwise only 16
+ skip = 1 + with_l2;
/* Create Vnet table for a given mask */
if (mask > 96)
return HICN_ERROR_PUNT_INVAL;
hicn_punt_add_vnettbl_udp (&ipv46, &ipv4, &udp46_src, mask, ~0,
- swif, ETH_L2);
+ swif, base_offset, use_current_data);
table_index =
hicn_punt_glb.udp46_vnet_tbl_idx[swif][skip][HICN_PUNT_SRC][mask];
hicn_punt_add_vnettbl_udp (&ipv46, &ipv4, &udp46_dst, mask,
- table_index, swif, ETH_L2);
+ table_index, swif, base_offset,
+ use_current_data);
/*
* Add a session for the specified ip address and
@@ -861,11 +877,12 @@ hicn_punt_interest_data_for_udp (vlib_main_t * vm,
hicn_punt_add_vnetssn_udp (&ipv46, &ipv4, &udp46_src,
prefix, mask,
hicn_punt_glb.next_hit_data_udp4,
- swif, ETH_L2, IPPROTO_UDP, sport, dport);
- hicn_punt_add_vnetssn_udp (&ipv46, &ipv4, &udp46_dst,
- prefix, mask,
+ swif, base_offset, IPPROTO_UDP, sport,
+ dport);
+ hicn_punt_add_vnetssn_udp (&ipv46, &ipv4, &udp46_dst, prefix, mask,
hicn_punt_glb.next_hit_interest_udp4,
- swif, ETH_L2, IPPROTO_UDP, sport, dport);
+ swif, base_offset, IPPROTO_UDP, sport,
+ dport);
hicn_punt_enable_disable_vnet_ip4_table_on_intf (vm, swif,
OP_ENABLE);
@@ -874,15 +891,17 @@ hicn_punt_interest_data_for_udp (vlib_main_t * vm,
{
if (mask > 122)
return HICN_ERROR_PUNT_INVAL;
-
- skip = 3;
+
+ //If we consider ethernet we can skip 48 bytes, otherwise only 32
+ skip = 2 + with_l2;
hicn_punt_add_vnettbl_udp (&ipv66, &ipv6, &udp66_src, mask, ~0,
- swif, ETH_L2);
+ swif, base_offset, use_current_data);
table_index =
hicn_punt_glb.udp66_vnet_tbl_idx[swif][skip][HICN_PUNT_SRC][mask];
hicn_punt_add_vnettbl_udp (&ipv66, &ipv6, &udp66_dst, mask,
- table_index, swif, ETH_L2);
+ table_index, swif, base_offset,
+ use_current_data);
/*
* Add a session for the specified ip address and
@@ -891,11 +910,12 @@ hicn_punt_interest_data_for_udp (vlib_main_t * vm,
hicn_punt_add_vnetssn_udp (&ipv66, &ipv6, &udp66_src,
prefix, mask,
hicn_punt_glb.next_hit_data_udp6,
- swif, ETH_L2, IPPROTO_UDP, sport, dport);
- hicn_punt_add_vnetssn_udp (&ipv66, &ipv6, &udp66_dst,
- prefix, mask,
+ swif, base_offset, IPPROTO_UDP, sport,
+ dport);
+ hicn_punt_add_vnetssn_udp (&ipv66, &ipv6, &udp66_dst, prefix, mask,
hicn_punt_glb.next_hit_interest_udp6,
- swif, ETH_L2, IPPROTO_UDP, sport, dport);
+ swif, base_offset, IPPROTO_UDP, sport,
+ dport);
hicn_punt_enable_disable_vnet_ip6_table_on_intf (vm, swif,
OP_ENABLE);
@@ -908,13 +928,17 @@ hicn_punt_interest_data_for_udp (vlib_main_t * vm,
u32
-hicn_punt_interest_data_for_ethernet (vlib_main_t * vm,
- ip46_address_t * prefix, u8 mask,
- u32 swif, u8 punt_type)
+hicn_punt_interest_data_for_ip (vlib_main_t * vm,
+ ip46_address_t * prefix, u8 mask,
+ u32 swif, u8 punt_type, u8 with_l2)
{
int skip = 1;
u32 table_index;
- u8 use_current_data = HICN_CLASSIFY_NO_CURRENT_DATA_FLAG;
+ // If we want l2 then we punt from data (and not current)
+ u8 use_current_data =
+ with_l2 ? HICN_CLASSIFY_NO_CURRENT_DATA_FLAG :
+ HICN_CLASSIFY_CURRENT_DATA_FLAG;
+ u8 base_offset = with_l2 ? ETH_L2 : NO_L2;
if (punt_type != HICN_PUNT_IP_TYPE && punt_type != HICN_PUNT_UDP4_TYPE
&& punt_type != HICN_PUNT_UDP6_TYPE)
@@ -928,14 +952,14 @@ hicn_punt_interest_data_for_ethernet (vlib_main_t * vm,
if (punt_type == HICN_PUNT_IP_TYPE)
{
/* Create Vnet table for a given mask */
- hicn_punt_add_vnettbl (&ipv4, &ipv4_src, mask, ~0, swif, ETH_L2,
- use_current_data);
+ hicn_punt_add_vnettbl (&ipv4, &ipv4_src, mask, ~0, swif,
+ base_offset, use_current_data);
table_index =
hicn_punt_glb.ip4_vnet_tbl_idx[swif][skip][HICN_PUNT_SRC][mask];
hicn_punt_add_vnettbl (&ipv4, &ipv4_dst, mask, table_index, swif,
- ETH_L2, use_current_data);
+ base_offset, use_current_data);
/*
* Add a session for the specified ip address and
@@ -944,11 +968,11 @@ hicn_punt_interest_data_for_ethernet (vlib_main_t * vm,
hicn_punt_add_vnetssn (&ipv4, &ipv4_src,
prefix, mask,
hicn_punt_glb.next_hit_data_ipv4, swif,
- ETH_L2);
+ base_offset);
hicn_punt_add_vnetssn (&ipv4, &ipv4_dst,
prefix, mask,
hicn_punt_glb.next_hit_interest_ipv4, swif,
- ETH_L2);
+ base_offset);
hicn_punt_enable_disable_vnet_ip4_table_on_intf (vm, swif,
OP_ENABLE);
@@ -966,14 +990,14 @@ hicn_punt_interest_data_for_ethernet (vlib_main_t * vm,
return HICN_ERROR_PUNT_INVAL;
/* Create Vnet table for a given mask */
- hicn_punt_add_vnettbl (&ipv6, &ipv6_src, mask, ~0, swif, ETH_L2,
- use_current_data);
+ hicn_punt_add_vnettbl (&ipv6, &ipv6_src, mask, ~0, swif,
+ base_offset, use_current_data);
table_index =
hicn_punt_glb.ip6_vnet_tbl_idx[swif][skip][HICN_PUNT_SRC][mask];
hicn_punt_add_vnettbl (&ipv6, &ipv6_dst, mask, table_index, swif,
- ETH_L2, use_current_data);
+ base_offset, use_current_data);
/*
* Add a session for the specified ip address and
@@ -981,10 +1005,10 @@ hicn_punt_interest_data_for_ethernet (vlib_main_t * vm,
*/
hicn_punt_add_vnetssn (&ipv6, &ipv6_src, prefix,
mask, hicn_punt_glb.next_hit_data_ipv6, swif,
- ETH_L2);
+ base_offset);
hicn_punt_add_vnetssn (&ipv6, &ipv6_dst, prefix,
mask, hicn_punt_glb.next_hit_interest_ipv6,
- swif, ETH_L2);
+ swif, base_offset);
hicn_punt_enable_disable_vnet_ip6_table_on_intf (vm, swif,
OP_ENABLE);
diff --git a/hicn-plugin/src/punt.h b/hicn-plugin/src/punt.h
index ebc27e9d4..3e6900064 100644
--- a/hicn-plugin/src/punt.h
+++ b/hicn-plugin/src/punt.h
@@ -296,14 +296,16 @@ hicn_punt_enable_disable_vnet_ip6_table_on_intf (vlib_main_t * vm,
u32 hicn_punt_interest_data_for_udp (vlib_main_t * vm,
ip46_address_t * prefix, u8 mask,
u32 swif, u8 punt_type, u16 sport,
- u16 dport);
-u32 hicn_punt_interest_data_for_ethernet (vlib_main_t * vm,
- ip46_address_t * prefix, u8 mask,
- u32 swif, u8 type);
+ u16 dport, u8 with_l2);
+u32 hicn_punt_interest_data_for_ip (vlib_main_t * vm,
+ ip46_address_t * prefix, u8 mask,
+ u32 swif, u8 type, u8 with_l2);
int hicn_punt_remove_ip6_address (vlib_main_t * vm, ip6_address_t * addr,
- u8 mask, int skip, u32 swif, int is_enable);
+ u8 mask, int skip, u32 swif, int is_enable,
+ u8 with_l2);
int hicn_punt_remove_ip4_address (vlib_main_t * vm, ip4_address_t * addr,
- u8 mask, int skip, u32 swif, int is_enable);
+ u8 mask, int skip, u32 swif, int is_enable,
+ u8 with_l2);
void hicn_punt_init (vlib_main_t * vm);
int
diff --git a/hicn-plugin/src/route.c b/hicn-plugin/src/route.c
index 9202efbd4..11302aba4 100644
--- a/hicn-plugin/src/route.c
+++ b/hicn-plugin/src/route.c
@@ -108,7 +108,7 @@ hicn_route_add (hicn_face_id_t * face_id, u32 len,
vlib_main_t *vm = vlib_get_main ();
hicn_face_vft_t *face_vft = NULL;
- if (face_id == NULL)
+ if (face_id == NULL || !hicn_dpoi_idx_is_valid (*face_id))
{
return HICN_ERROR_ROUTE_INVAL;
}