summaryrefslogtreecommitdiffstats
path: root/hicn-plugin
diff options
context:
space:
mode:
Diffstat (limited to 'hicn-plugin')
-rw-r--r--hicn-plugin/src/cli.c291
-rw-r--r--hicn-plugin/src/pg.c249
-rw-r--r--hicn-plugin/src/pg.h16
3 files changed, 304 insertions, 252 deletions
diff --git a/hicn-plugin/src/cli.c b/hicn-plugin/src/cli.c
index fd1c68169..920d206f8 100644
--- a/hicn-plugin/src/cli.c
+++ b/hicn-plugin/src/cli.c
@@ -53,26 +53,6 @@ typedef enum
} interface_type_t;
/*
- * Supporting function that return if the interface is IP or ethernet
- */
-static interface_type_t
-hicn_cli_is_ip_interface (vlib_main_t * vm,
- vnet_main_t * vnm, u32 sw_if_index)
-{
-
- vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, sw_if_index);
-
- vnet_device_class_t *dev_class =
- vnet_get_device_class (vnm, hi->dev_class_index);
- if (!strcmp (dev_class->name, "Loopback"))
- {
- return IP;
- }
- return ETHERNET;
-
-}
-
-/*
* cli handler for 'control start'
*/
static clib_error_t *
@@ -84,7 +64,8 @@ hicn_cli_node_ctl_start_set_command_fn (vlib_main_t * vm,
ret = hicn_infra_plugin_enable_disable (1 /* enable */ ,
node_ctl_params.pit_max_size,
- node_ctl_params.pit_max_lifetime_sec,
+ node_ctl_params.
+ pit_max_lifetime_sec,
node_ctl_params.cs_max_size,
node_ctl_params.cs_reserved_app);
@@ -127,7 +108,8 @@ hicn_cli_node_ctl_stop_set_command_fn (vlib_main_t * vm,
}
ret = hicn_infra_plugin_enable_disable (0 /* !enable */ ,
node_ctl_params.pit_max_size,
- node_ctl_params.pit_max_lifetime_sec,
+ node_ctl_params.
+ pit_max_lifetime_sec,
node_ctl_params.cs_max_size,
node_ctl_params.cs_reserved_app);
@@ -460,11 +442,12 @@ hicn_cli_fib_set_command_fn (vlib_main_t * vm, unformat_input_t * main_input,
}
}
- fib_prefix_from_ip46_addr(&address, &prefix);
- prefix.fp_len=plen;
+ fib_prefix_from_ip46_addr (&address, &prefix);
+ prefix.fp_len = plen;
/* Check parse */
if (addpfx <= 1
- && ((ip46_address_is_zero (&prefix.fp_addr)) || faceid == HICN_FACE_NULL))
+ && ((ip46_address_is_zero (&prefix.fp_addr))
+ || faceid == HICN_FACE_NULL))
{
cl_err =
clib_error_return (0, "Please specify prefix and a valid faceid...");
@@ -680,19 +663,16 @@ hicn_cli_pgen_client_set_command_fn (vlib_main_t * vm,
unformat_input_t * main_input,
vlib_cli_command_t * cmd)
{
- hicn_main_t *sm = &hicn_main;
hicnpg_main_t *hpgm = &hicnpg_main;
ip46_address_t src_addr;
- fib_prefix_t prefix;
+ fib_prefix_t *prefix = malloc (sizeof (fib_prefix_t));
vnet_main_t *vnm = vnet_get_main ();
u32 sw_if_index = ~0;
u16 lifetime = 4000;
int rv = VNET_API_ERROR_UNIMPLEMENTED;
u32 max_seq = ~0;
u32 n_flows = ~0;
- u16 mask = 0;
u32 n_ifaces = 1;
- u32 hicn_underneath = ~0;
/* Get a line of input. */
unformat_input_t _line_input, *line_input = &_line_input;
@@ -700,13 +680,6 @@ hicn_cli_pgen_client_set_command_fn (vlib_main_t * vm,
{
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (line_input, "fwd"))
- {
- if (unformat (line_input, "ip"))
- hicn_underneath = 0;
- else if (unformat (line_input, "hicn"))
- hicn_underneath = 1;
- }
if (unformat
(line_input, "intfc %U", unformat_vnet_sw_interface, vnm,
&sw_if_index))
@@ -723,8 +696,8 @@ hicn_cli_pgen_client_set_command_fn (vlib_main_t * vm,
;
}
else if (unformat (line_input, "name %U/%d",
- unformat_ip46_address, &prefix.fp_addr, IP46_TYPE_ANY,
- &prefix.fp_len))
+ unformat_ip46_address, &prefix->fp_addr,
+ IP46_TYPE_ANY, &prefix->fp_len))
{
;
}
@@ -750,72 +723,49 @@ hicn_cli_pgen_client_set_command_fn (vlib_main_t * vm,
}
}
hpgm->interest_lifetime = lifetime;
- mask = prefix.fp_len;
if (sw_if_index == ~0)
{
return (clib_error_return (0, "Packet generator interface missing"));
}
- if (hicn_underneath == ~0)
- {
- return (clib_error_return
- (0, "Choose the underlying forwarder type ip|hicn"));
- }
- else if (hicn_underneath && !sm->is_enabled)
+
+ //Remove bits that are out of the subnet
+ if (ip46_address_is_ip4 (&prefix->fp_addr))
{
- return (clib_error_return (0, "hICN not enabled in VPP"));
+ ip4_address_t mask;
+ ip4_preflen_to_mask (prefix->fp_len, &mask);
+ prefix->fp_addr.ip4.as_u32 = prefix->fp_addr.ip4.as_u32 & mask.as_u32;
+ prefix->fp_proto = FIB_PROTOCOL_IP4;
}
- else if (!hicn_underneath && sm->is_enabled)
+ else
{
- return (clib_error_return (0, "hICN enabled in VPP"));
+ ip6_address_t mask;
+ ip6_preflen_to_mask (prefix->fp_len, &mask);
+ prefix->fp_addr.ip6.as_u64[0] =
+ prefix->fp_addr.ip6.as_u64[0] & mask.as_u64[0];
+ prefix->fp_addr.ip6.as_u64[1] =
+ prefix->fp_addr.ip6.as_u64[1] & mask.as_u64[1];
+ prefix->fp_proto = FIB_PROTOCOL_IP6;
}
- int skip = 1;
- int base_offset = ETH_L2;
- u8 use_current_data = HICN_CLASSIFY_NO_CURRENT_DATA_FLAG;
-
- if (hicn_cli_is_ip_interface (vm, vnm, sw_if_index) == IP)
- {
- skip = 0;
- base_offset = NO_L2;
- use_current_data = HICN_CLASSIFY_CURRENT_DATA_FLAG;
- }
/*
- * Register punting on src address generated by pg and data punting
- * on the name
+ * Enable the feature to divert data packet to the hicnpg-data node to count
+ * how many data packets have been received.
+ * Diver all the packets from the packet-generator to the hicn-pg-interest node
+ * to generate valid interests.
*/
- if (ip46_address_is_ip4 (&src_addr) && ip46_address_is_ip4 (&prefix.fp_addr))
+ if (ip46_address_is_ip4 (&src_addr)
+ && ip46_address_is_ip4 (&prefix->fp_addr))
{
- prefix.fp_proto = FIB_PROTOCOL_IP4;
- /* Add data node to the vpp graph */
- u32 next_hit_node = vlib_node_add_next (vm,
- hicn_punt_glb.
- hicn_node_info.ip4_inacl_node_index,
- hicn_pg_data_node.index);
+ prefix->fp_proto = FIB_PROTOCOL_IP4;
+
+ vnet_feature_enable_disable ("ip4-unicast", "hicnpg-data",
+ sw_if_index, 1, 0, 0);
/* Add pgen_client node to the vpp graph */
vlib_node_add_next (vm,
pg_input_node.index, hicn_pg_interest_node.index);
- /* Create the punting table if it does not exist */
- hicn_punt_add_vnettbl (&ipv4, &ipv4_src, mask, ~0, sw_if_index,
- base_offset, use_current_data);
- hicn_punt_add_vnettbl (&ipv4, &ipv4_dst, mask,
- hicn_punt_glb.ip4_vnet_tbl_idx[sw_if_index][skip]
- [HICN_PUNT_SRC][mask], sw_if_index, base_offset,
- use_current_data);
-
- /* Add a session to the table */
- hicn_punt_add_vnetssn (&ipv4, &ipv4_src,
- &prefix,
- next_hit_node, sw_if_index, base_offset);
-
- hicn_punt_add_vnetssn (&ipv4, &ipv4_src,
- &prefix,
- next_hit_node, sw_if_index, base_offset);
-
- hicn_punt_enable_disable_vnet_ip4_table_on_intf (vm, sw_if_index,
- OP_ENABLE);
pg_node_t *pn;
pn = pg_get_node (hicn_pg_interest_node.index);
@@ -823,39 +773,17 @@ hicn_cli_pgen_client_set_command_fn (vlib_main_t * vm,
}
else if (!ip46_address_is_ip4 (&src_addr)
- && !ip46_address_is_ip4 (&prefix.fp_addr))
+ && !ip46_address_is_ip4 (&prefix->fp_addr))
{
- prefix.fp_proto = FIB_PROTOCOL_IP6;
- /* Add node to the vpp graph */
- u32 next_hit_node = vlib_node_add_next (vm,
- hicn_punt_glb.hicn_node_info.
- ip6_inacl_node_index,
- hicn_pg_data_node.index);
+ prefix->fp_proto = FIB_PROTOCOL_IP6;
+
+ vnet_feature_enable_disable ("ip6-unicast", "hicnpg-data",
+ sw_if_index, 1, 0, 0);
/* Add pgen_client node to the vpp graph */
vlib_node_add_next (vm, pg_input_node.index,
hicn_pg_interest_node.index);
- /* Create the punting table if it does not exist */
- hicn_punt_add_vnettbl (&ipv6, &ipv6_src, mask, ~0, sw_if_index,
- base_offset, use_current_data);
- hicn_punt_add_vnettbl (&ipv6, &ipv6_dst, mask,
- hicn_punt_glb.ip6_vnet_tbl_idx[sw_if_index][skip]
- [HICN_PUNT_SRC][mask], sw_if_index, base_offset,
- use_current_data);
-
- /* Add a session to the table */
- hicn_punt_add_vnetssn (&ipv6, &ipv6_src,
- &prefix,
- next_hit_node, sw_if_index, base_offset);
-
- hicn_punt_add_vnetssn (&ipv6, &ipv6_src,
- &prefix,
- next_hit_node, sw_if_index, base_offset);
-
- hicn_punt_enable_disable_vnet_ip6_table_on_intf (vm, sw_if_index,
- OP_ENABLE);
-
pg_node_t *pn;
pn = pg_get_node (hicn_pg_interest_node.index);
pn->unformat_edit = unformat_pg_ip6_header;
@@ -869,11 +797,11 @@ hicn_cli_pgen_client_set_command_fn (vlib_main_t * vm,
hpgm->pgen_clt_src_addr = src_addr;
- hpgm->pgen_clt_hicn_name = prefix.fp_addr;
+ hpgm->pgen_clt_hicn_name = prefix;
hpgm->max_seq_number = max_seq;
hpgm->n_flows = n_flows;
hpgm->n_ifaces = n_ifaces;
- hpgm->hicn_underneath = hicn_underneath;
+ hpgm->sw_if = sw_if_index;
vlib_cli_output (vm, "ifaces %d", hpgm->n_ifaces);
rv = 0;
@@ -904,13 +832,10 @@ hicn_cli_pgen_server_set_command_fn (vlib_main_t * vm,
clib_error_t *cl_err;
int rv = HICN_ERROR_NONE;
hicnpg_server_main_t *pg_main = &hicnpg_server_main;
- hicn_main_t *sm = &hicn_main;
- fib_prefix_t prefix;
- u32 subnet_mask;
- int payload_size = 0;
+ int payload_size = 1440;
u32 sw_if_index = ~0;
vnet_main_t *vnm = vnet_get_main ();
- u32 hicn_underneath = ~0;
+ fib_prefix_t *prefix = calloc (1, sizeof (fib_prefix_t));
/* Get a line of input. */
unformat_input_t _line_input, *line_input = &_line_input;
@@ -919,16 +844,9 @@ hicn_cli_pgen_server_set_command_fn (vlib_main_t * vm,
/* Parse the arguments */
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (line_input, "fwd"))
- {
- if (unformat (line_input, "ip"))
- hicn_underneath = 0;
- else if (unformat (line_input, "hicn"))
- hicn_underneath = 1;
- }
if (unformat (line_input, "name %U/%d",
- unformat_ip46_address, &prefix.fp_addr, IP46_TYPE_ANY,
- &prefix.fp_len))
+ unformat_ip46_address, &prefix->fp_addr,
+ IP46_TYPE_ANY, &prefix->fp_len))
{;
}
else if (unformat (line_input, "size %d", &payload_size))
@@ -955,99 +873,50 @@ hicn_cli_pgen_server_set_command_fn (vlib_main_t * vm,
}
}
}
- prefix.fp_proto = ip46_address_is_ip4(&prefix.fp_addr) ? FIB_PROTOCOL_IP4 : FIB_PROTOCOL_IP6;
- subnet_mask = prefix.fp_len;
+
/* Attach our packet-gen node for ip4 udp local traffic */
- if (payload_size == 0 || sw_if_index == ~0)
+ if ((prefix->fp_addr.ip6.as_u64[0] == (u64) 0
+ && prefix->fp_addr.ip6.as_u64[1] == 0) || payload_size == 0
+ || sw_if_index == ~0)
{
return clib_error_return (0,
- "Error: must supply local port, payload size and incoming interface");
+ "Error: must supply local port, payload size and incoming hICN prefix");
}
- if (hicn_underneath == ~0)
- {
- return (clib_error_return
- (0, "Choose the underlying forwarder type ip|hicn"));
- }
- else if (hicn_underneath && !sm->is_enabled)
+
+ //Remove bits that are out of the subnet
+ if (ip46_address_is_ip4 (&prefix->fp_addr))
{
- return (clib_error_return (0, "hICN not enabled in VPP"));
+ ip4_address_t mask;
+ ip4_preflen_to_mask (prefix->fp_len, &mask);
+ prefix->fp_addr.ip4.as_u32 = prefix->fp_addr.ip4.as_u32 & mask.as_u32;
+ prefix->fp_proto = FIB_PROTOCOL_IP4;
}
- else if (!hicn_underneath && sm->is_enabled)
+ else
{
- return (clib_error_return (0, "hICN enabled in VPP"));
+ ip6_address_t mask;
+ ip6_preflen_to_mask (prefix->fp_len, &mask);
+ prefix->fp_addr.ip6.as_u64[0] =
+ prefix->fp_addr.ip6.as_u64[0] & mask.as_u64[0];
+ prefix->fp_addr.ip6.as_u64[1] =
+ prefix->fp_addr.ip6.as_u64[1] & mask.as_u64[1];
+ prefix->fp_proto = FIB_PROTOCOL_IP6;
}
- pg_main->hicn_underneath = hicn_underneath;
/* Allocate the buffer with the actual content payload TLV */
vlib_buffer_alloc (vm, &pg_main->pgen_svr_buffer_idx, 1);
vlib_buffer_t *rb = NULL;
rb = vlib_get_buffer (vm, pg_main->pgen_svr_buffer_idx);
+ pg_main->pgen_srv_hicn_name = prefix;
+
/* Initialize the buffer data with zeros */
memset (rb->data, 0, payload_size);
rb->current_length = payload_size;
- int skip = 2;
- int base_offset = ETH_L2;
- u8 use_current_data = HICN_CLASSIFY_NO_CURRENT_DATA_FLAG;
-
- if (hicn_cli_is_ip_interface (vm, vnm, sw_if_index) == IP)
- {
- skip = 1;
- base_offset = NO_L2;
- use_current_data = HICN_CLASSIFY_CURRENT_DATA_FLAG;
- }
- if (ip46_address_is_ip4 (&prefix.fp_addr))
- {
- /* Add node to the vpp graph */
- u32 next_hit_node = vlib_node_add_next (vm,
- hicn_punt_glb.
- hicn_node_info.ip4_inacl_node_index,
- hicn_pg_server_node.index);
-
- /* Create the punting table if it does not exist */
- hicn_punt_add_vnettbl (&ipv4, &ipv4_src, subnet_mask, ~0, sw_if_index,
- base_offset, use_current_data);
- hicn_punt_add_vnettbl (&ipv4, &ipv4_dst, subnet_mask,
- hicn_punt_glb.ip4_vnet_tbl_idx[sw_if_index][skip]
- [HICN_PUNT_SRC][subnet_mask - 1], sw_if_index,
- base_offset, use_current_data);
-
-
- /* Add a session to the table */
- hicn_punt_add_vnetssn (&ipv4, &ipv4_dst,
- &prefix, next_hit_node, sw_if_index,
- base_offset);
-
- hicn_punt_enable_disable_vnet_ip4_table_on_intf (vm, sw_if_index,
- OP_ENABLE);
-
- }
- else
- {
- /* Add node to the vpp graph */
- u32 next_hit_node = vlib_node_add_next (vm,
- hicn_punt_glb.hicn_node_info.
- ip6_inacl_node_index,
- hicn_pg_server_node.index);
-
- /* Create the punting table if it does not exist */
- hicn_punt_add_vnettbl (&ipv6, &ipv6_src, subnet_mask, ~0, sw_if_index,
- base_offset, use_current_data);
- hicn_punt_add_vnettbl (&ipv6, &ipv6_dst, subnet_mask,
- hicn_punt_glb.ip6_vnet_tbl_idx[sw_if_index][skip]
- [HICN_PUNT_SRC][subnet_mask - 1], sw_if_index,
- base_offset, use_current_data);
-
-
- /* Add a session to the table */
- hicn_punt_add_vnetssn (&ipv6, &ipv6_dst,
- &prefix, next_hit_node, sw_if_index,
- base_offset);
-
- hicn_punt_enable_disable_vnet_ip6_table_on_intf (vm, sw_if_index,
- OP_ENABLE);
- }
+ vnet_feature_enable_disable ("ip4-unicast", "hicnpg-server",
+ sw_if_index, 1, 0, 0);
+ vnet_feature_enable_disable ("ip6-unicast", "hicnpg-server",
+ sw_if_index, 1, 0, 0);
switch (rv)
{
@@ -1121,17 +990,17 @@ VLIB_CLI_COMMAND(hicn_cli_show_command, static)=
/* cli declaration for 'punting' */
VLIB_CLI_COMMAND(hicn_cli_punting_command, static)=
-{
- .path = "hicn punting",
- .short_help = "hicn punting {add|delete} prefix <prefix> intfc <sw_if> {type ip | type <udp4|udp6> src_port <port> dst_port <port>}",
- .function = hicn_cli_punting_command_fn,
-};
+ {
+ .path = "hicn punting",
+ .short_help = "hicn punting {add|delete} prefix <prefix> intfc <sw_if> {type ip | type <udp4|udp6> src_port <port> dst_port <port>}",
+ .function = hicn_cli_punting_command_fn,
+ };
/* cli declaration for 'hicn pgen client' */
VLIB_CLI_COMMAND(hicn_cli_pgen_client_set_command, static)=
{
.path = "hicn pgen client",
- .short_help = "hicn pgen client fwd <ip|hicn> src <src_addr> n_ifaces <n_ifaces> name <prefix> lifetime <interest-lifetime> intfc <data in-interface> max_seq <max sequence number> n_flows <number of flows>",
+ .short_help = "hicn pgen client src <src_addr> name <prefix> { n_ifaces <n_ifaces> lifetime <interest-lifetime> intfc <data in-interface> max_seq <max sequence number> n_flows <number of flows>}",
.long_help = "Run hicn in packet-gen client mode\n",
.function = hicn_cli_pgen_client_set_command_fn,
};
@@ -1140,7 +1009,7 @@ VLIB_CLI_COMMAND(hicn_cli_pgen_client_set_command, static)=
VLIB_CLI_COMMAND(hicn_cli_pgen_server_set_command, static)=
{
.path = "hicn pgen server",
- .short_help = "hicn pgen server fwd <ip|hicn> name <prefix> intfc <interest in-interface> size <payload_size>",
+ .short_help = "hicn pgen server name <prefix> intfc <interest in-interface> size <payload_size>",
.long_help = "Run hicn in packet-gen server mode\n",
.function = hicn_cli_pgen_server_set_command_fn,
};
diff --git a/hicn-plugin/src/pg.c b/hicn-plugin/src/pg.c
index 8181d865e..9938e85ba 100644
--- a/hicn-plugin/src/pg.c
+++ b/hicn-plugin/src/pg.c
@@ -57,8 +57,6 @@ typedef enum
{
HICNPG_INTEREST_NEXT_V4_LOOKUP,
HICNPG_INTEREST_NEXT_V6_LOOKUP,
- HICNPG_INTEREST_NEXT_IFACE_IP4_INPUT,
- HICNPG_INTEREST_NEXT_IFACE_IP6_INPUT,
HICNPG_INTEREST_NEXT_DROP,
HICNPG_N_NEXT,
} hicnpg_interest_next_t;
@@ -79,12 +77,11 @@ hicnpg_main_t hicnpg_main = {
.interest_lifetime = 4,
.n_flows = (u32) 0,
.n_ifaces = (u32) 1,
- .hicn_underneath = 0
+ .sw_if = (u32) 0
};
hicnpg_server_main_t hicnpg_server_main = {
.node_index = 0,
- .hicn_underneath = 0
};
/* packet trace format function */
@@ -193,6 +190,8 @@ hicnpg_client_interest_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
sw_if_index1 = vnet_buffer (b1)->sw_if_index[VLIB_RX];
+ vnet_buffer (b0)->sw_if_index[VLIB_RX] = hpgm->sw_if;
+ vnet_buffer (b1)->sw_if_index[VLIB_RX] = hpgm->sw_if;
/* Check icn packets, locate names */
if (hicn_interest_parse_pkt (b0, &name0, &namelen0, &hicn0, &isv6_0)
@@ -225,7 +224,6 @@ hicnpg_client_interest_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
next0 =
isv6_0 ? HICNPG_INTEREST_NEXT_V6_LOOKUP :
HICNPG_INTEREST_NEXT_V4_LOOKUP;
- next0 += 2 * hpgm->hicn_underneath;
}
if (hicn_interest_parse_pkt (b1, &name1, &namelen1, &hicn1, &isv6_1)
== HICN_ERROR_NONE)
@@ -257,7 +255,6 @@ hicnpg_client_interest_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
next1 =
isv6_1 ? HICNPG_INTEREST_NEXT_V6_LOOKUP :
HICNPG_INTEREST_NEXT_V4_LOOKUP;
- next1 += 2 * hpgm->hicn_underneath;
}
/* Send pkt to next node */
vnet_buffer (b0)->sw_if_index[VLIB_TX] = ~0;
@@ -320,6 +317,7 @@ hicnpg_client_interest_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
b0 = vlib_get_buffer (vm, bi0);
sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
+ vnet_buffer (b0)->sw_if_index[VLIB_RX] = hpgm->sw_if;
/* Check icn packets, locate names */
if (hicn_interest_parse_pkt (b0, &name0, &namelen0, &hicn0, &isv6_0)
@@ -353,7 +351,6 @@ hicnpg_client_interest_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
next0 =
isv6_0 ? HICNPG_INTEREST_NEXT_V6_LOOKUP :
HICNPG_INTEREST_NEXT_V4_LOOKUP;
- next0 += 2 * hpgm->hicn_underneath;
}
/* Send pkt to ip lookup */
vnet_buffer (b0)->sw_if_index[VLIB_TX] = ~0;
@@ -407,7 +404,7 @@ hicn_rewrite_interestv4 (vlib_main_t * vm, vlib_buffer_t * b0, u32 seq_number,
.ip4 = hicnpg_main.pgen_clt_src_addr.ip4,
};
hicn_name_t dst_name = {
- .ip4.prefix_as_ip4 = hicnpg_main.pgen_clt_hicn_name.ip4,
+ .ip4.prefix_as_ip4 = hicnpg_main.pgen_clt_hicn_name->fp_addr.ip4,
.ip4.suffix = seq_number,
};
@@ -453,7 +450,7 @@ hicn_rewrite_interestv6 (vlib_main_t * vm, vlib_buffer_t * b0, u32 seq_number,
.ip6 = hicnpg_main.pgen_clt_src_addr.ip6,
};
hicn_name_t dst_name = {
- .ip6.prefix_as_ip6 = hicnpg_main.pgen_clt_hicn_name.ip6,
+ .ip6.prefix_as_ip6 = hicnpg_main.pgen_clt_hicn_name->fp_addr.ip6,
.ip6.suffix = seq_number,
};
src_addr.ip6.as_u32[3] += clib_host_to_net_u32 (iface);
@@ -559,8 +556,6 @@ VLIB_REGISTER_NODE(hicn_pg_interest_node) ={
{
[HICNPG_INTEREST_NEXT_V4_LOOKUP] = "ip4-lookup",
[HICNPG_INTEREST_NEXT_V6_LOOKUP] = "ip6-lookup",
- [HICNPG_INTEREST_NEXT_IFACE_IP4_INPUT] = "hicn-iface-ip4-input",
- [HICNPG_INTEREST_NEXT_IFACE_IP6_INPUT] = "hicn-iface-ip6-input",
[HICNPG_INTEREST_NEXT_DROP] = "error-drop"
},
};
@@ -573,6 +568,8 @@ VLIB_REGISTER_NODE(hicn_pg_interest_node) ={
typedef enum
{
HICNPG_DATA_NEXT_DROP,
+ HICNPG_DATA_NEXT_LOOKUP4,
+ HICNPG_DATA_NEXT_LOOKUP6,
HICNPG_DATA_N_NEXT,
} hicnpg_data_next_t;
@@ -600,6 +597,93 @@ format_hicnpg_data_trace (u8 * s, va_list * args)
}
+static_always_inline int
+match_ip4_name (u32 * name, fib_prefix_t * prefix)
+{
+ u32 xor = 0;
+
+ xor = *name & prefix->fp_addr.ip4.data_u32;
+
+ return xor == prefix->fp_addr.ip4.data_u32;
+}
+
+static_always_inline int
+match_ip6_name (u8 * name, fib_prefix_t * prefix)
+{
+ union
+ {
+ u32x4 as_u32x4;
+ u64 as_u64[2];
+ u32 as_u32[4];
+ } xor_sum __attribute__ ((aligned (sizeof (u32x4))));
+
+ 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->fp_addr.ip6.as_u64[0]) &&
+ (xor_sum.as_u64[1] == prefix->fp_addr.ip6.as_u64[1]);
+}
+
+
+/*
+ * Return 0,1,2.
+ * 0 matches
+ * 1 does not match and the prefix is ip4
+ * 2 does not match and the prefix is ip6
+ */
+static_always_inline u32
+match_data (vlib_buffer_t * b, fib_prefix_t * prefix)
+{
+ u8 *ptr = vlib_buffer_get_current (b);
+ u8 v = *ptr & 0xf0;
+ u32 next = 0;
+
+ if (PREDICT_TRUE (v == 0x40 && ip46_address_is_ip4 (&prefix->fp_addr)))
+ {
+ if (!match_ip4_name ((u32 *) & (ptr[12]), prefix))
+ next = 1;
+ }
+ else
+ if (PREDICT_TRUE (v == 0x60 && !ip46_address_is_ip4 (&prefix->fp_addr)))
+ {
+ if (!match_ip6_name (&(ptr[8]), prefix))
+ next = 2;
+ }
+
+ return next;
+}
+
+/*
+ * Return 0,1,2.
+ * 0 matches
+ * 1 does not match and the prefix is ip4
+ * 2 does not match and the prefix is ip6
+ */
+static_always_inline u32
+match_interest (vlib_buffer_t * b, fib_prefix_t * prefix)
+{
+ u8 *ptr = vlib_buffer_get_current (b);
+ u8 v = *ptr & 0xf0;
+ u32 next = 0;
+
+ if (PREDICT_TRUE (v == 0x40 && ip46_address_is_ip4 (&prefix->fp_addr)))
+ {
+ if (!match_ip4_name ((u32 *) & (ptr[16]), prefix))
+ next = 1;
+ }
+ else
+ if (PREDICT_TRUE (v == 0x60 && !ip46_address_is_ip4 (&prefix->fp_addr)))
+ {
+ if (!match_ip6_name (&(ptr[24]), prefix))
+ next = 2;
+ }
+
+ return next;
+}
+
+
+
+
/*
* Node function for the icn packet-generator client. The goal here is to
* manipulate/tweak a stream of packets that have been injected by the vpp
@@ -617,6 +701,7 @@ hicnpg_client_data_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_buffer_t *b0, *b1;
u8 pkt_type0 = 0, pkt_type1 = 0;
u16 msg_type0 = 1, msg_type1 = 1;
+ hicnpg_main_t *hpgm = &hicnpg_main;
from = vlib_frame_vector_args (frame);
n_left_from = frame->n_vectors;
@@ -664,8 +749,33 @@ hicnpg_client_data_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
sw_if_index1 = vnet_buffer (b1)->sw_if_index[VLIB_RX];
- /* Increment a counter */
- content_msgs_received += 2;
+ next0 =
+ HICNPG_DATA_NEXT_DROP + match_data (b0, hpgm->pgen_clt_hicn_name);
+ next1 =
+ HICNPG_DATA_NEXT_DROP + match_data (b1, hpgm->pgen_clt_hicn_name);
+
+ if (PREDICT_FALSE (vnet_get_feature_count
+ (vnet_buffer (b0)->feature_arc_index,
+ vnet_buffer (b0)->sw_if_index[VLIB_RX]) > 1))
+ vnet_feature_next (&next0, b0);
+
+ if (PREDICT_FALSE (vnet_get_feature_count
+ (vnet_buffer (b1)->feature_arc_index,
+ vnet_buffer (b1)->sw_if_index[VLIB_RX]) > 1))
+ vnet_feature_next (&next1, b1);
+
+
+ if (next0 == HICNPG_DATA_NEXT_DROP)
+ {
+ /* Increment a counter */
+ content_msgs_received++;
+ }
+
+ if (next1 == HICNPG_DATA_NEXT_DROP)
+ {
+ /* Increment a counter */
+ content_msgs_received++;
+ }
if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)))
{
@@ -688,6 +798,10 @@ hicnpg_client_data_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
t->next_index = next1;
}
}
+
+ vlib_validate_buffer_enqueue_x2 (vm, node, next_index,
+ to_next, n_left_to_next,
+ bi0, bi1, next0, next1);
pkts_processed += 2;
}
@@ -708,8 +822,19 @@ hicnpg_client_data_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
- /* Increment a counter */
- content_msgs_received++;
+ next0 =
+ HICNPG_DATA_NEXT_DROP + match_data (b0, hpgm->pgen_clt_hicn_name);
+
+ if (PREDICT_FALSE (vnet_get_feature_count
+ (vnet_buffer (b0)->feature_arc_index,
+ vnet_buffer (b0)->sw_if_index[VLIB_RX]) > 1))
+ vnet_feature_next (&next0, b0);
+
+ if (next0 == HICNPG_DATA_NEXT_DROP)
+ {
+ /* Increment a counter */
+ content_msgs_received++;
+ }
if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)
&& (b0->flags & VLIB_BUFFER_IS_TRACED)))
@@ -721,6 +846,10 @@ hicnpg_client_data_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
t->sw_if_index = sw_if_index0;
t->next_index = next0;
}
+
+ vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
+ n_left_to_next, bi0, next0);
+
pkts_processed++;
}
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
@@ -747,11 +876,33 @@ VLIB_REGISTER_NODE(hicn_pg_data_node) =
.n_next_nodes = HICNPG_DATA_N_NEXT,
.next_nodes =
{
- [HICNPG_DATA_NEXT_DROP] = "error-drop"
+ [HICNPG_DATA_NEXT_DROP] = "error-drop",
+ [HICNPG_DATA_NEXT_LOOKUP4] = "ip4-lookup",
+ [HICNPG_DATA_NEXT_LOOKUP6] = "ip6-lookup",
},
};
/* *INDENT-ON* */
+/* *INDENT-OFF* */
+VNET_FEATURE_INIT(hicn_data_input_ip4_arc, static)=
+ {
+ .arc_name = "ip4-unicast",
+ .node_name = "hicnpg-data",
+ .runs_before = VNET_FEATURES("ip4-inacl"),
+ };
+/* *INDENT-ON* */
+
+
+/* *INDENT-OFF* */
+VNET_FEATURE_INIT(hicn_data_input_ip6_arc, static)=
+ {
+ .arc_name = "ip6-unicast",
+ .node_name = "hicnpg-data",
+ .runs_before = VNET_FEATURES("ip6-inacl"),
+ };
+/* *INDENT-ON* */
+
+
/*
* End of packet-generator client node
*/
@@ -790,8 +941,6 @@ typedef enum
{
HICNPG_SERVER_NEXT_V4_LOOKUP,
HICNPG_SERVER_NEXT_V6_LOOKUP,
- HICNPG_SERVER_NEXT_FACE_IP4_INPUT,
- HICNPG_SERVER_NEXT_FACE_IP6_INPUT,
HICNPG_SERVER_NEXT_DROP,
HICNPG_SERVER_N_NEXT,
} icnpg_server_next_t;
@@ -892,8 +1041,19 @@ hicnpg_node_server_fn (vlib_main_t * vm,
sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
sw_if_index1 = vnet_buffer (b1)->sw_if_index[VLIB_RX];
- if (hicn_interest_parse_pkt (b0, &name0, &namelen0, &hicn0, &isv6_0)
- == HICN_ERROR_NONE)
+ vnet_buffer (b0)->sw_if_index[VLIB_TX] = ~0;
+ vnet_buffer (b1)->sw_if_index[VLIB_TX] = ~0;
+
+ u32 match0 = match_interest (b0, hpgsm->pgen_srv_hicn_name);
+ u32 match1 = match_interest (b1, hpgsm->pgen_srv_hicn_name);
+
+ if (match0)
+ {
+ next0 = match0 - 1;
+ }
+ else
+ if (hicn_interest_parse_pkt
+ (b0, &name0, &namelen0, &hicn0, &isv6_0) == HICN_ERROR_NONE)
{
/* this node grabs only interests */
vlib_buffer_t *rb = NULL;
@@ -906,11 +1066,15 @@ hicnpg_node_server_fn (vlib_main_t * vm,
next0 =
isv6_0 ? HICNPG_SERVER_NEXT_V6_LOOKUP :
HICNPG_SERVER_NEXT_V4_LOOKUP;
- /* if hicn_underneath ,the following will results as next0 = HICNPG_SERVER_NEXT_DATA_LOOKUP */
- next0 += 2 * hpgsm->hicn_underneath;
}
- if (hicn_interest_parse_pkt (b1, &name1, &namelen1, &hicn1, &isv6_1)
- == HICN_ERROR_NONE)
+
+ if (match1)
+ {
+ next1 = match1 - 1;
+ }
+ else
+ if (hicn_interest_parse_pkt
+ (b1, &name1, &namelen1, &hicn1, &isv6_1) == HICN_ERROR_NONE)
{
/* this node grabs only interests */
vlib_buffer_t *rb = NULL;
@@ -923,8 +1087,6 @@ hicnpg_node_server_fn (vlib_main_t * vm,
next1 =
isv6_1 ? HICNPG_SERVER_NEXT_V6_LOOKUP :
HICNPG_SERVER_NEXT_V4_LOOKUP;
- /* if hicn_underneath ,the following will results as next0 = HICNPG_SERVER_NEXT_DATA_LOOKUP */
- next1 += 2 * hpgsm->hicn_underneath;
}
pkts_processed += 2;
@@ -983,10 +1145,17 @@ hicnpg_node_server_fn (vlib_main_t * vm,
b0 = vlib_get_buffer (vm, bi0);
sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
+ vnet_buffer (b0)->sw_if_index[VLIB_TX] = ~0;
+ u32 match0 = match_interest (b0, hpgsm->pgen_srv_hicn_name);
- if (hicn_interest_parse_pkt (b0, &name0, &namelen0, &hicn0, &isv6_0)
- == HICN_ERROR_NONE)
+ if (match0)
+ {
+ next0 = match0 - 1;
+ }
+ else
+ if (hicn_interest_parse_pkt
+ (b0, &name0, &namelen0, &hicn0, &isv6_0) == HICN_ERROR_NONE)
{
/* this node grabs only interests */
vlib_buffer_t *rb = NULL;
@@ -999,8 +1168,6 @@ hicnpg_node_server_fn (vlib_main_t * vm,
next0 =
isv6_0 ? HICNPG_SERVER_NEXT_V6_LOOKUP :
HICNPG_SERVER_NEXT_V4_LOOKUP;
- /* if hicn_underneath ,the following will results as next0 = HICNPG_SERVER_NEXT_DATA_LOOKUP */
- next0 += 2 * hpgsm->hicn_underneath;
}
if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)
&& (b0->flags & VLIB_BUFFER_IS_TRACED)))
@@ -1122,16 +1289,32 @@ VLIB_REGISTER_NODE(hicn_pg_server_node) =
.n_next_nodes = HICNPG_SERVER_N_NEXT,
/* edit / add dispositions here */
.next_nodes =
- {
+ {
[HICNPG_SERVER_NEXT_V4_LOOKUP] = "ip4-lookup",
[HICNPG_SERVER_NEXT_V6_LOOKUP] = "ip6-lookup",
- [HICNPG_SERVER_NEXT_FACE_IP4_INPUT] = "hicn-face-ip4-input",
- [HICNPG_SERVER_NEXT_FACE_IP6_INPUT] = "hicn-face-ip6-input",
[HICNPG_SERVER_NEXT_DROP] = "error-drop",
},
};
/* *INDENT-ON* */
+/* *INDENT-OFF* */
+VNET_FEATURE_INIT(hicn_pg_server_ip6, static)=
+ {
+ .arc_name = "ip6-unicast",
+ .node_name = "hicnpg-server",
+ .runs_before = VNET_FEATURES("ip6-inacl"),
+ };
+/* *INDENT-ON* */
+
+/* *INDENT-OFF* */
+VNET_FEATURE_INIT(hicn_pg_server_ip4, static)=
+ {
+ .arc_name = "ip4-unicast",
+ .node_name = "hicnpg-server",
+ .runs_before = VNET_FEATURES("ip4-inacl"),
+ };
+/* *INDENT-ON* */
+
/*
* End of packet-generator server node
*/
diff --git a/hicn-plugin/src/pg.h b/hicn-plugin/src/pg.h
index 083afb6b3..35f570880 100644
--- a/hicn-plugin/src/pg.h
+++ b/hicn-plugin/src/pg.h
@@ -16,21 +16,18 @@
#ifndef __HICN_PG_H__
#define __HICN_PG_H__
-/* Subnet-mask for punting data in the client node */
-#define SUBNET_MASK4 32
-#define SUBNET_MASK6 128
-
typedef struct hicnpg_main_s
{
u32 index;
+ fib_prefix_t *pgen_clt_hicn_name;
u32 index_ifaces;
+ u32 n_ifaces;
u32 max_seq_number;
u32 n_flows;
- u32 n_ifaces;
- u32 hicn_underneath;
ip46_address_t pgen_clt_src_addr;
- ip46_address_t pgen_clt_hicn_name;
+
u16 interest_lifetime;
+ u32 sw_if;
} hicnpg_main_t;
extern hicnpg_main_t hicnpg_main;
@@ -38,13 +35,16 @@ extern hicnpg_main_t hicnpg_main;
typedef struct hicnpg_server_main_s
{
u32 node_index;
- u32 hicn_underneath;
/* Arbitrary content */
u32 pgen_svr_buffer_idx;
+ fib_prefix_t *pgen_srv_hicn_name;
} hicnpg_server_main_t;
extern hicnpg_server_main_t hicnpg_server_main;
+extern vlib_node_registration_t hicn_pg_interest_node;
+extern vlib_node_registration_t hicn_pg_data_node;
+
#endif // __HICN_PG_H__
/*