aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMauro <you@example.com>2021-02-11 11:03:12 +0000
committerMauro Sardara <msardara@cisco.com>2021-02-11 11:59:38 +0000
commiteedc20451418af57a6ffe4c6d41652828f01b9fe (patch)
tree86d442cc4093cfc862672d5db74a561a3d4b9b0e
parent9e06c0466f7bf8c2fe80f5fc79fe1cb95053eedd (diff)
[HICN-683] Add clang format for hicn-plugin.
As vpp has moved away from the dear old indent, also the hicn plugin should do the same and use clang-format. Signed-off-by: Mauro Sardara <msardara@cisco.com> Change-Id: Iee896f3ce01cef53b1acfccbebeef66ca77add7d Signed-off-by: Mauro Sardara <msardara@cisco.com>
-rw-r--r--hicn-plugin/.clang-format21
-rw-r--r--hicn-plugin/src/cli.c442
-rw-r--r--hicn-plugin/src/data_input_node.c167
-rw-r--r--hicn-plugin/src/data_pcslookup_node.c38
-rw-r--r--hicn-plugin/src/faces/app/face_app_cli.c83
-rw-r--r--hicn-plugin/src/faces/app/face_prod_node.c87
-rw-r--r--hicn-plugin/src/faces/face_node.c822
-rw-r--r--hicn-plugin/src/faces/iface_node.c843
-rw-r--r--hicn-plugin/src/hicn.c45
-rw-r--r--hicn-plugin/src/interest_pcslookup_node.c44
-rw-r--r--hicn-plugin/src/mapme_ack_node.c54
-rw-r--r--hicn-plugin/src/mapme_ctrl_node.c123
-rw-r--r--hicn-plugin/src/pg.c438
-rw-r--r--hicn-plugin/src/strategies/strategy_mw.c2
-rw-r--r--hicn-plugin/src/strategies/strategy_mw_cli.c49
-rw-r--r--hicn-plugin/src/strategy_node.c65
-rw-r--r--hicn-plugin/src/udp_tunnels/udp_decap_node.c606
-rw-r--r--hicn-plugin/src/udp_tunnels/udp_tunnel.c218
18 files changed, 1929 insertions, 2218 deletions
diff --git a/hicn-plugin/.clang-format b/hicn-plugin/.clang-format
new file mode 100644
index 000000000..8b5c955ce
--- /dev/null
+++ b/hicn-plugin/.clang-format
@@ -0,0 +1,21 @@
+# Minimal clang-format version is 8
+
+BasedOnStyle: GNU
+UseTab: Always
+SpaceAfterCStyleCast: true
+SortIncludes: false
+AlignConsecutiveMacros: true
+BreakBeforeTernaryOperators: false
+BreakBeforeBinaryOperators: None
+ContinuationIndentWidth: 2
+
+ForEachMacros:
+ - 'clib_bitmap_foreach'
+ - 'pool_foreach'
+ - 'pool_foreach_index'
+ - 'vec_foreach'
+ - 'vec_foreach_backwards'
+ - 'vec_foreach_index'
+ - 'vec_foreach_index_backwards'
+ - 'vlib_foreach_rx_tx'
+
diff --git a/hicn-plugin/src/cli.c b/hicn-plugin/src/cli.c
index 1adf3595c..81a97c604 100644
--- a/hicn-plugin/src/cli.c
+++ b/hicn-plugin/src/cli.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2020 Cisco and/or its affiliates.
+ * Copyright (c) 2017-2021 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -19,7 +19,7 @@
#include <vlibmemory/api.h>
#include <vnet/udp/udp.h> // port registration
-#include <vnet/ip/ip6_packet.h> // ip46_address_t
+#include <vnet/ip/ip6_packet.h> // ip46_address_t
#include <vnet/ip/format.h>
#include <vnet/fib/fib_types.h>
@@ -51,32 +51,31 @@ typedef enum
* cli handler for 'control start'
*/
static clib_error_t *
-hicn_cli_node_ctl_start_set_command_fn (vlib_main_t * vm,
- unformat_input_t * main_input,
- vlib_cli_command_t * cmd)
+hicn_cli_node_ctl_start_set_command_fn (vlib_main_t *vm,
+ unformat_input_t *main_input,
+ vlib_cli_command_t *cmd)
{
int ret;
- ret = hicn_infra_plugin_enable_disable (1 /* enable */ ,
- node_ctl_params.pit_max_size,
- node_ctl_params.pit_max_lifetime_sec,
- node_ctl_params.cs_max_size, ~0);
+ ret = hicn_infra_plugin_enable_disable (
+ 1 /* enable */, node_ctl_params.pit_max_size,
+ node_ctl_params.pit_max_lifetime_sec, node_ctl_params.cs_max_size, ~0);
vlib_cli_output (vm, "hicn: fwdr initialize => %s\n",
get_error_string (ret));
- return (ret == HICN_ERROR_NONE) ? 0 : clib_error_return (0,
- get_error_string
- (ret));
+ return (ret == HICN_ERROR_NONE) ?
+ 0 :
+ clib_error_return (0, get_error_string (ret));
}
/*
* cli handler for 'control stop'
*/
static clib_error_t *
-hicn_cli_node_ctl_stop_set_command_fn (vlib_main_t * vm,
- unformat_input_t * main_input,
- vlib_cli_command_t * cmd)
+hicn_cli_node_ctl_stop_set_command_fn (vlib_main_t *vm,
+ unformat_input_t *main_input,
+ vlib_cli_command_t *cmd)
{
int ret;
@@ -99,32 +98,30 @@ hicn_cli_node_ctl_stop_set_command_fn (vlib_main_t * vm,
format_unformat_error, line_input);
}
}
- ret = hicn_infra_plugin_enable_disable (0 /* !enable */ ,
- node_ctl_params.pit_max_size,
- node_ctl_params.pit_max_lifetime_sec,
- node_ctl_params.cs_max_size, ~0);
+ ret = hicn_infra_plugin_enable_disable (
+ 0 /* !enable */, node_ctl_params.pit_max_size,
+ node_ctl_params.pit_max_lifetime_sec, node_ctl_params.cs_max_size, ~0);
- return (ret == HICN_ERROR_NONE) ? 0 : clib_error_return (0,
- get_error_string
- (ret));
+ return (ret == HICN_ERROR_NONE) ?
+ 0 :
+ clib_error_return (0, get_error_string (ret));
}
-#define DFLTD_RANGE_OK(val, min, max) \
-({ \
- __typeof__ (val) _val = (val); \
- __typeof__ (min) _min = (min); \
- __typeof__ (max) _max = (max); \
- (_val == -1) || \
- (_val >= _min && _val <= _max); \
-})
+#define DFLTD_RANGE_OK(val, min, max) \
+ ({ \
+ __typeof__ (val) _val = (val); \
+ __typeof__ (min) _min = (min); \
+ __typeof__ (max) _max = (max); \
+ (_val == -1) || (_val >= _min && _val <= _max); \
+ })
/*
* cli handler for 'control param'
*/
static clib_error_t *
-hicn_cli_node_ctl_param_set_command_fn (vlib_main_t * vm,
- unformat_input_t * main_input,
- vlib_cli_command_t * cmd)
+hicn_cli_node_ctl_param_set_command_fn (vlib_main_t *vm,
+ unformat_input_t *main_input,
+ vlib_cli_command_t *cmd)
{
int rv = 0;
@@ -133,16 +130,15 @@ hicn_cli_node_ctl_param_set_command_fn (vlib_main_t * vm,
if (hicn_main.is_enabled)
{
- return (clib_error_return
- (0, "params cannot be altered once hicn started"));
+ return (
+ clib_error_return (0, "params cannot be altered once hicn started"));
}
/* Get a line of input. */
unformat_input_t _line_input, *line_input = &_line_input;
if (!unformat_user (main_input, unformat_line_input, line_input))
{
- return clib_error_return (0,
- get_error_string
- (HICN_ERROR_FWD_ALREADY_ENABLED));
+ return clib_error_return (
+ 0, get_error_string (HICN_ERROR_FWD_ALREADY_ENABLED));
}
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
@@ -160,9 +156,9 @@ hicn_cli_node_ctl_param_set_command_fn (vlib_main_t * vm,
}
else if (unformat (line_input, "maxlife %f", &lifetime))
{
- if (!DFLTD_RANGE_OK
- (lifetime, HICN_PARAM_PIT_LIFETIME_BOUND_MIN_SEC,
- HICN_PARAM_PIT_LIFETIME_BOUND_MAX_SEC))
+ if (!DFLTD_RANGE_OK (lifetime,
+ HICN_PARAM_PIT_LIFETIME_BOUND_MIN_SEC,
+ HICN_PARAM_PIT_LIFETIME_BOUND_MAX_SEC))
{
rv = HICN_ERROR_PIT_CONFIG_MAXLT_OOB;
break;
@@ -201,25 +197,24 @@ hicn_cli_node_ctl_param_set_command_fn (vlib_main_t * vm,
}
if (node_ctl_params.cs_max_size == 0)
- vlib_cli_output (vm,
- "CS size set to 0. Consider disable CS at compilation time for better performances\n");
-
- return (rv == HICN_ERROR_NONE) ? 0 : clib_error_return (0, "%s '%U'",
- get_error_string
- (rv),
- format_unformat_error,
- line_input);
+ vlib_cli_output (vm, "CS size set to 0. Consider disable CS at "
+ "compilation time for better performances\n");
+
+ return (rv == HICN_ERROR_NONE) ?
+ 0 :
+ clib_error_return (0, "%s '%U'", get_error_string (rv),
+ format_unformat_error, line_input);
}
/*
* cli handler for 'hicn show'
*/
static clib_error_t *
-hicn_cli_show_command_fn (vlib_main_t * vm, unformat_input_t * main_input,
- vlib_cli_command_t * cmd)
+hicn_cli_show_command_fn (vlib_main_t *vm, unformat_input_t *main_input,
+ vlib_cli_command_t *cmd)
{
- int face_p = 0, fib_p = 0, all_p, internal_p = 0, strategies_p = 0, ret =
- HICN_ERROR_NONE;
+ int face_p = 0, fib_p = 0, all_p, internal_p = 0, strategies_p = 0,
+ ret = HICN_ERROR_NONE;
/* Get a line of input. */
unformat_input_t _line_input, *line_input = &_line_input;
@@ -294,8 +289,7 @@ hicn_cli_show_command_fn (vlib_main_t * vm, unformat_input_t * main_input,
" PIT:: max entries:%d,"
" lifetime default: max:%05.3f\n"
" CS:: max entries:%d\n",
- hicn_main.is_enabled ? "en" : "dis",
- hicn_infra_pit_size,
+ hicn_main.is_enabled ? "en" : "dis", hicn_infra_pit_size,
((f64) hicn_main.pit_lifetime_max_ms) / SEC_MS,
hicn_infra_cs_size);
@@ -303,25 +297,26 @@ hicn_cli_show_command_fn (vlib_main_t * vm, unformat_input_t * main_input,
, *rmp = &rm;
if (hicn_mgmt_node_stats_get (&rm) == HICN_ERROR_NONE)
{
- vlib_cli_output (vm, //compare vl_api_hicn_api_node_stats_get_reply_t_handler block
- " PIT entries (now): %d\n"
- " CS total entries (now): %d, network entries (now): %d\n"
- " Forwarding statistics:\n"
- " pkts_processed: %d\n"
- " pkts_interest_count: %d\n"
- " pkts_data_count: %d\n"
- " pkts_from_cache_count: %d\n"
- " interests_aggregated: %d\n"
- " interests_retransmitted: %d\n",
- clib_net_to_host_u64 (rmp->pit_entries_count),
- clib_net_to_host_u64 (rmp->cs_entries_count),
- clib_net_to_host_u64 (rmp->cs_entries_ntw_count),
- clib_net_to_host_u64 (rmp->pkts_processed),
- clib_net_to_host_u64 (rmp->pkts_interest_count),
- clib_net_to_host_u64 (rmp->pkts_data_count),
- clib_net_to_host_u64 (rmp->pkts_from_cache_count),
- clib_net_to_host_u64 (rmp->interests_aggregated),
- clib_net_to_host_u64 (rmp->interests_retx));
+ vlib_cli_output (
+ vm, // compare vl_api_hicn_api_node_stats_get_reply_t_handler block
+ " PIT entries (now): %d\n"
+ " CS total entries (now): %d, network entries (now): %d\n"
+ " Forwarding statistics:\n"
+ " pkts_processed: %d\n"
+ " pkts_interest_count: %d\n"
+ " pkts_data_count: %d\n"
+ " pkts_from_cache_count: %d\n"
+ " interests_aggregated: %d\n"
+ " interests_retransmitted: %d\n",
+ clib_net_to_host_u64 (rmp->pit_entries_count),
+ clib_net_to_host_u64 (rmp->cs_entries_count),
+ clib_net_to_host_u64 (rmp->cs_entries_ntw_count),
+ clib_net_to_host_u64 (rmp->pkts_processed),
+ clib_net_to_host_u64 (rmp->pkts_interest_count),
+ clib_net_to_host_u64 (rmp->pkts_data_count),
+ clib_net_to_host_u64 (rmp->pkts_from_cache_count),
+ clib_net_to_host_u64 (rmp->interests_aggregated),
+ clib_net_to_host_u64 (rmp->interests_retx));
}
if (face_p || all_p)
{
@@ -329,7 +324,6 @@ hicn_cli_show_command_fn (vlib_main_t * vm, unformat_input_t * main_input,
strbuf = format_hicn_face_all (strbuf, 1, 0);
vlib_cli_output (vm, "%s", strbuf);
-
}
if (strategies_p || all_p)
{
@@ -343,7 +337,8 @@ done:
{
vlib_cli_output (vm, "Plugin features: cs:%d\n", HICN_FEATURE_CS);
vlib_cli_output (vm,
- "Removed CS entries (and freed vlib buffers) %d, Removed PIT entries %d\n",
+ "Removed CS entries (and freed vlib buffers) %d, "
+ "Removed PIT entries %d\n",
hicn_main.pitcs.pcs_cs_dealloc,
hicn_main.pitcs.pcs_pit_dealloc);
vlib_cli_output (vm,
@@ -351,20 +346,19 @@ done:
hicn_main.pitcs.pcs_table->ht_bucket_count,
hicn_main.pitcs.pcs_table->ht_overflow_bucket_count,
hicn_main.pitcs.pcs_table->ht_overflow_buckets_used);
-
}
- return (ret == HICN_ERROR_NONE) ? 0 : clib_error_return (0, "%s\n",
- get_error_string
- (ret));
+ return (ret == HICN_ERROR_NONE) ?
+ 0 :
+ clib_error_return (0, "%s\n", get_error_string (ret));
}
/*
* cli handler for 'fib'
*/
static clib_error_t *
-hicn_cli_strategy_set_command_fn (vlib_main_t * vm,
- unformat_input_t * main_input,
- vlib_cli_command_t * cmd)
+hicn_cli_strategy_set_command_fn (vlib_main_t *vm,
+ unformat_input_t *main_input,
+ vlib_cli_command_t *cmd)
{
clib_error_t *cl_err = 0;
@@ -387,10 +381,11 @@ hicn_cli_strategy_set_command_fn (vlib_main_t * vm,
{
addpfx = 2;
}
- else if (addpfx != -1
- && unformat (line_input, "prefix %U/%d", unformat_ip46_address,
- &address, IP46_TYPE_ANY, &plen))
- {;
+ else if (addpfx != -1 &&
+ unformat (line_input, "prefix %U/%d", unformat_ip46_address,
+ &address, IP46_TYPE_ANY, &plen))
+ {
+ ;
}
else
{
@@ -412,10 +407,9 @@ hicn_cli_strategy_set_command_fn (vlib_main_t * vm,
}
rv = hicn_route_set_strategy (&prefix, strategy_id);
- cl_err =
- (rv == HICN_ERROR_NONE) ? NULL : clib_error_return (0,
- get_error_string
- (rv));
+ cl_err = (rv == HICN_ERROR_NONE) ?
+ NULL :
+ clib_error_return (0, get_error_string (rv));
done:
return (cl_err);
@@ -425,9 +419,9 @@ done:
* cli handler for 'pgen'
*/
static clib_error_t *
-hicn_cli_pgen_client_set_command_fn (vlib_main_t * vm,
- unformat_input_t * main_input,
- vlib_cli_command_t * cmd)
+hicn_cli_pgen_client_set_command_fn (vlib_main_t *vm,
+ unformat_input_t *main_input,
+ vlib_cli_command_t *cmd)
{
hicnpg_main_t *hpgm = &hicnpg_main;
ip46_address_t src_addr;
@@ -446,14 +440,13 @@ 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, "intfc %U", unformat_vnet_sw_interface, vnm,
- &sw_if_index))
+ if (unformat (line_input, "intfc %U", unformat_vnet_sw_interface,
+ vnm, &sw_if_index))
{
;
}
- else if (unformat (line_input, "src %U",
- unformat_ip46_address, &src_addr))
+ else if (unformat (line_input, "src %U", unformat_ip46_address,
+ &src_addr))
{
;
}
@@ -461,9 +454,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))
+ else if (unformat (line_input, "name %U/%d", unformat_ip46_address,
+ &prefix->fp_addr, IP46_TYPE_ANY, &prefix->fp_len))
{
;
}
@@ -481,9 +473,8 @@ hicn_cli_pgen_client_set_command_fn (vlib_main_t * vm,
}
else
{
- return (clib_error_return
- (0, "Unknown input '%U'", format_unformat_error,
- line_input));
+ return (clib_error_return (0, "Unknown input '%U'",
+ format_unformat_error, line_input));
break;
}
}
@@ -495,7 +486,7 @@ hicn_cli_pgen_client_set_command_fn (vlib_main_t * vm,
return (clib_error_return (0, "Packet generator interface missing"));
}
- //Remove bits that are out of the subnet
+ // Remove bits that are out of the subnet
if (ip46_address_is_ip4 (&prefix->fp_addr))
{
ip4_address_t mask;
@@ -517,34 +508,32 @@ hicn_cli_pgen_client_set_command_fn (vlib_main_t * vm,
/*
* 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.
+ * 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;
- vnet_feature_enable_disable ("ip4-unicast", "hicnpg-data",
- sw_if_index, 1, 0, 0);
+ 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);
-
+ vlib_node_add_next (vm, pg_input_node.index,
+ hicn_pg_interest_node.index);
pg_node_t *pn;
pn = pg_get_node (hicn_pg_interest_node.index);
pn->unformat_edit = unformat_pg_ip4_header;
-
}
- else if (!ip46_address_is_ip4 (&src_addr)
- && !ip46_address_is_ip4 (&prefix->fp_addr))
+ else if (!ip46_address_is_ip4 (&src_addr) &&
+ !ip46_address_is_ip4 (&prefix->fp_addr))
{
prefix->fp_proto = FIB_PROTOCOL_IP6;
- vnet_feature_enable_disable ("ip6-unicast", "hicnpg-data",
- sw_if_index, 1, 0, 0);
+ 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,
@@ -556,12 +545,11 @@ hicn_cli_pgen_client_set_command_fn (vlib_main_t * vm,
}
else
{
- return (clib_error_return
- (0,
- "pg interface source address, source address and hicn name must be of the same type IPv4 or IPv6"));
+ return (clib_error_return (
+ 0, "pg interface source address, source address and hicn name must be "
+ "of the same type IPv4 or IPv6"));
}
-
hpgm->pgen_clt_src_addr = src_addr;
hpgm->pgen_clt_hicn_name = prefix;
hpgm->max_seq_number = max_seq;
@@ -591,9 +579,9 @@ hicn_cli_pgen_client_set_command_fn (vlib_main_t * vm,
* cli handler for 'pgen'
*/
static clib_error_t *
-hicn_cli_pgen_server_set_command_fn (vlib_main_t * vm,
- unformat_input_t * main_input,
- vlib_cli_command_t * cmd)
+hicn_cli_pgen_server_set_command_fn (vlib_main_t *vm,
+ unformat_input_t *main_input,
+ vlib_cli_command_t *cmd)
{
clib_error_t *cl_err;
int rv = HICN_ERROR_NONE;
@@ -610,46 +598,43 @@ 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, "name %U/%d",
- unformat_ip46_address, &prefix->fp_addr,
- IP46_TYPE_ANY, &prefix->fp_len))
- {;
+ if (unformat (line_input, "name %U/%d", unformat_ip46_address,
+ &prefix->fp_addr, IP46_TYPE_ANY, &prefix->fp_len))
+ {
+ ;
}
else if (unformat (line_input, "size %d", &payload_size))
{
if (payload_size > 1440)
{
- return (clib_error_return (0,
- "Payload size must be <= 1440 bytes..."));
+ return (clib_error_return (
+ 0, "Payload size must be <= 1440 bytes..."));
}
}
- else
- if (unformat
- (line_input, "intfc %U", unformat_vnet_sw_interface, vnm,
- &sw_if_index))
+ else if (unformat (line_input, "intfc %U",
+ unformat_vnet_sw_interface, vnm, &sw_if_index))
{
;
}
else
{
- return (clib_error_return
- (0, "Unknown input '%U'", format_unformat_error,
- line_input));
+ return (clib_error_return (0, "Unknown input '%U'",
+ format_unformat_error, line_input));
break;
}
}
}
/* Attach our packet-gen node for ip4 udp local traffic */
- 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)
+ 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 hICN prefix");
+ return clib_error_return (0, "Error: must supply local port, payload "
+ "size and incoming hICN prefix");
}
- //Remove bits that are out of the subnet
+ // Remove bits that are out of the subnet
if (ip46_address_is_ip4 (&prefix->fp_addr))
{
ip4_address_t mask;
@@ -685,10 +670,10 @@ hicn_cli_pgen_server_set_command_fn (vlib_main_t * vm,
memset (rb->data, 0, payload_size);
rb->current_length = payload_size;
- 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);
+ 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)
{
@@ -708,8 +693,8 @@ hicn_cli_pgen_server_set_command_fn (vlib_main_t * vm,
}
static clib_error_t *
-hicn_enable_command_fn (vlib_main_t * vm, unformat_input_t * main_input,
- vlib_cli_command_t * cmd)
+hicn_enable_command_fn (vlib_main_t *vm, unformat_input_t *main_input,
+ vlib_cli_command_t *cmd)
{
clib_error_t *cl_err = 0;
@@ -724,13 +709,13 @@ hicn_enable_command_fn (vlib_main_t * vm, unformat_input_t * main_input,
}
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (line_input, "%U/%d",
- unformat_ip4_address, &pfx.fp_addr.ip4, &pfx.fp_len))
+ if (unformat (line_input, "%U/%d", unformat_ip4_address,
+ &pfx.fp_addr.ip4, &pfx.fp_len))
{
pfx.fp_proto = FIB_PROTOCOL_IP4;
}
- else if (unformat (line_input, "%U/%d",
- unformat_ip6_address, &pfx.fp_addr.ip6, &pfx.fp_len))
+ else if (unformat (line_input, "%U/%d", unformat_ip6_address,
+ &pfx.fp_addr.ip6, &pfx.fp_len))
{
pfx.fp_proto = FIB_PROTOCOL_IP6;
}
@@ -745,16 +730,15 @@ hicn_enable_command_fn (vlib_main_t * vm, unformat_input_t * main_input,
rv = hicn_route_enable (&pfx);
done:
- cl_err =
- (rv == HICN_ERROR_NONE) ? NULL : clib_error_return (0,
- get_error_string
- (rv));
+ cl_err = (rv == HICN_ERROR_NONE) ?
+ NULL :
+ clib_error_return (0, get_error_string (rv));
return cl_err;
}
static clib_error_t *
-hicn_disable_command_fn (vlib_main_t * vm, unformat_input_t * main_input,
- vlib_cli_command_t * cmd)
+hicn_disable_command_fn (vlib_main_t *vm, unformat_input_t *main_input,
+ vlib_cli_command_t *cmd)
{
clib_error_t *cl_err = 0;
@@ -769,13 +753,13 @@ hicn_disable_command_fn (vlib_main_t * vm, unformat_input_t * main_input,
}
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (line_input, "%U/%d",
- unformat_ip4_address, &pfx.fp_addr.ip4, &pfx.fp_len))
+ if (unformat (line_input, "%U/%d", unformat_ip4_address,
+ &pfx.fp_addr.ip4, &pfx.fp_len))
{
pfx.fp_proto = FIB_PROTOCOL_IP4;
}
- else if (unformat (line_input, "%U/%d",
- unformat_ip6_address, &pfx.fp_addr.ip6, &pfx.fp_len))
+ else if (unformat (line_input, "%U/%d", unformat_ip6_address,
+ &pfx.fp_addr.ip6, &pfx.fp_len))
{
pfx.fp_proto = FIB_PROTOCOL_IP6;
}
@@ -791,103 +775,91 @@ hicn_disable_command_fn (vlib_main_t * vm, unformat_input_t * main_input,
rv = hicn_route_disable (&pfx);
done:
- cl_err =
- (rv == HICN_ERROR_NONE) ? NULL : clib_error_return (0,
- get_error_string
- (rv));
+ cl_err = (rv == HICN_ERROR_NONE) ?
+ NULL :
+ clib_error_return (0, get_error_string (rv));
return cl_err;
}
-
/* cli declaration for 'control start' */
-/* *INDENT-OFF* */
-VLIB_CLI_COMMAND(hicn_cli_node_ctl_start_set_command, static)=
-{
- .path = "hicn control start",
- .short_help = "hicn control start",
- .function = hicn_cli_node_ctl_start_set_command_fn,
+VLIB_CLI_COMMAND (hicn_cli_node_ctl_start_set_command, static) = {
+ .path = "hicn control start",
+ .short_help = "hicn control start",
+ .function = hicn_cli_node_ctl_start_set_command_fn,
};
-
/* cli declaration for 'control stop' */
-VLIB_CLI_COMMAND(hicn_cli_node_ctl_stop_set_command, static)=
-{
- .path = "hicn control stop",
- .short_help = "hicn control stop",
- .function = hicn_cli_node_ctl_stop_set_command_fn,
+VLIB_CLI_COMMAND (hicn_cli_node_ctl_stop_set_command, static) = {
+ .path = "hicn control stop",
+ .short_help = "hicn control stop",
+ .function = hicn_cli_node_ctl_stop_set_command_fn,
};
-
/* cli declaration for 'control param' */
-VLIB_CLI_COMMAND(hicn_cli_node_ctl_param_set_command, static)=
-{
- .path = "hicn control param",
- .short_help = "hicn control param { pit { size <entries> | { dfltlife | minlife | maxlife } <seconds> } | fib size <entries> | cs {size <entries> | app <portion to reserved to app>} }\n",
- .function = hicn_cli_node_ctl_param_set_command_fn,
+VLIB_CLI_COMMAND (hicn_cli_node_ctl_param_set_command, static) = {
+ .path = "hicn control param",
+ .short_help = "hicn control param { pit { size <entries> | { dfltlife | "
+ "minlife | maxlife } <seconds> } | fib size <entries> | cs "
+ "{size <entries> | app <portion to reserved to app>} }\n",
+ .function = hicn_cli_node_ctl_param_set_command_fn,
};
/* cli declaration for 'control' (root path of multiple commands, for help) */
-VLIB_CLI_COMMAND(hicn_cli_node_ctl_command, static)=
-{
- .path = "hicn control",
- .short_help = "hicn control"
-};
+VLIB_CLI_COMMAND (hicn_cli_node_ctl_command,
+ static) = { .path = "hicn control",
+ .short_help = "hicn control" };
/* cli declaration for 'fib' */
-VLIB_CLI_COMMAND(hicn_cli_strategy_set_command, static)=
- {
- .path = "hicn strategy",
- .short_help = "hicn strategy set <strategy_id> prefix <prefix>",
- .function = hicn_cli_strategy_set_command_fn,
- };
+VLIB_CLI_COMMAND (hicn_cli_strategy_set_command, static) = {
+ .path = "hicn strategy",
+ .short_help = "hicn strategy set <strategy_id> prefix <prefix>",
+ .function = hicn_cli_strategy_set_command_fn,
+};
/* cli declaration for 'show' */
-VLIB_CLI_COMMAND(hicn_cli_show_command, static)=
-{
- .path = "hicn show",
- .short_help = "hicn show "
- "[internal]"
- "[strategies]",
- .function = hicn_cli_show_command_fn,
+VLIB_CLI_COMMAND (hicn_cli_show_command, static) = {
+ .path = "hicn show",
+ .short_help = "hicn show "
+ "[internal]"
+ "[strategies]",
+ .function = hicn_cli_show_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 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,
+VLIB_CLI_COMMAND (hicn_cli_pgen_client_set_command, static) = {
+ .path = "hicn pgen client",
+ .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,
};
/* cli declaration for 'hicn pgen client' */
-VLIB_CLI_COMMAND(hicn_cli_pgen_server_set_command, static)=
-{
- .path = "hicn pgen server",
- .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,
+VLIB_CLI_COMMAND (hicn_cli_pgen_server_set_command, static) = {
+ .path = "hicn pgen server",
+ .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,
};
/* cli declaration for 'hicn pgen client' */
-VLIB_CLI_COMMAND(hicn_enable_command, static)=
- {
- .path = "hicn enable",
- .short_help = "hicn enable <prefix>",
- .long_help = "Enable hicn for the give prefix\n",
- .function = hicn_enable_command_fn,
- };
+VLIB_CLI_COMMAND (hicn_enable_command, static) = {
+ .path = "hicn enable",
+ .short_help = "hicn enable <prefix>",
+ .long_help = "Enable hicn for the give prefix\n",
+ .function = hicn_enable_command_fn,
+};
/* cli declaration for 'hicn pgen client' */
-VLIB_CLI_COMMAND(hicn_disable_command, static)=
- {
- .path = "hicn disable",
- .short_help = "hicn disable <prefix>",
- .long_help = "Disable hicn for the give prefix\n",
- .function = hicn_disable_command_fn,
- };
-
-/* *INDENT-ON* */
+VLIB_CLI_COMMAND (hicn_disable_command, static) = {
+ .path = "hicn disable",
+ .short_help = "hicn disable <prefix>",
+ .long_help = "Disable hicn for the give prefix\n",
+ .function = hicn_disable_command_fn,
+};
/*
* fd.io coding-style-patch-verification: ON
diff --git a/hicn-plugin/src/data_input_node.c b/hicn-plugin/src/data_input_node.c
index 8d20f54a6..c94443a6b 100644
--- a/hicn-plugin/src/data_input_node.c
+++ b/hicn-plugin/src/data_input_node.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Cisco and/or its affiliates.
+ * Copyright (c) 2020-2021 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -16,8 +16,8 @@
#include <vnet/vnet.h>
#include <vnet/ip/ip.h>
#include <vnet/fib/ip6_fib.h>
-#include <vnet/fib/fib_table.h> /* for FIB table and entry creation */
-#include <vnet/fib/fib_entry.h> /* for FIB table and entry creation */
+#include <vnet/fib/fib_table.h> /* for FIB table and entry creation */
+#include <vnet/fib/fib_entry.h> /* for FIB table and entry creation */
#include <vnet/fib/ip4_fib.h>
#include <vnet/dpo/load_balance.h>
@@ -61,7 +61,7 @@ vlib_node_registration_t hicn_data_input_ip6_node;
vlib_node_registration_t hicn_data_input_ip4_node;
static __clib_unused u8 *
-format_hicn_data_input_trace (u8 * s, va_list * args)
+format_hicn_data_input_trace (u8 *s, va_list *args)
{
CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
@@ -69,16 +69,15 @@ format_hicn_data_input_trace (u8 * s, va_list * args)
u32 indent = format_get_indent (s);
u8 isv6 = (u8) va_arg (*args, int);
- s =
- format (s, "%U hicn_data_input%s: sw_if_index %d next-index %d",
- format_white_space, indent, isv6 ? "_ip6" : "_ip4",
- t->sw_if_index, t->next_index);
+ s = format (s, "%U hicn_data_input%s: sw_if_index %d next-index %d",
+ format_white_space, indent, isv6 ? "_ip6" : "_ip4",
+ t->sw_if_index, t->next_index);
return s;
}
static uword
-hicn_data_input_ip6_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node, vlib_frame_t * frame)
+hicn_data_input_ip6_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
+ vlib_frame_t *frame)
{
ip6_main_t *im = &ip6_main;
vlib_combined_counter_main_t *cm = &load_balance_main.lbm_to_counters;
@@ -146,7 +145,7 @@ hicn_data_input_ip6_fn (vlib_main_t * vm,
vnet_buffer (p0)->ip.flow_hash = vnet_buffer (p1)->ip.flow_hash = 0;
- //No vpp loadbalancing. Missing header file to exploit it
+ // No vpp loadbalancing. Missing header file to exploit it
dpo0 = load_balance_get_bucket_i (lb0, 0);
dpo1 = load_balance_get_bucket_i (lb1, 0);
@@ -180,11 +179,10 @@ hicn_data_input_ip6_fn (vlib_main_t * vm,
t->isv6 = 1;
}
-
- vlib_increment_combined_counter
- (cm, thread_index, lbi0, 1, vlib_buffer_length_in_chain (vm, p0));
- vlib_increment_combined_counter
- (cm, thread_index, lbi1, 1, vlib_buffer_length_in_chain (vm, p1));
+ vlib_increment_combined_counter (
+ cm, thread_index, lbi0, 1, vlib_buffer_length_in_chain (vm, p0));
+ vlib_increment_combined_counter (
+ cm, thread_index, lbi1, 1, vlib_buffer_length_in_chain (vm, p1));
from += 2;
to_next += 2;
@@ -253,7 +251,7 @@ hicn_data_input_ip6_fn (vlib_main_t * vm,
ASSERT (lb0->lb_n_buckets > 0);
ASSERT (is_pow2 (lb0->lb_n_buckets));
- //No vpp loadbalancing. Missing header file to exploit it
+ // No vpp loadbalancing. Missing header file to exploit it
dpo0 = load_balance_get_bucket_i (lb0, 0);
if (dpo_is_hicn (dpo0))
@@ -271,8 +269,8 @@ hicn_data_input_ip6_fn (vlib_main_t * vm,
t->isv6 = 1;
}
- vlib_increment_combined_counter
- (cm, thread_index, lbi0, 1, vlib_buffer_length_in_chain (vm, p0));
+ vlib_increment_combined_counter (
+ cm, thread_index, lbi0, 1, vlib_buffer_length_in_chain (vm, p0));
from += 1;
to_next += 1;
@@ -297,39 +295,29 @@ hicn_data_input_ip6_fn (vlib_main_t * vm,
return frame->n_vectors;
}
-/* *INDENT-OFF* */
-VLIB_REGISTER_NODE(hicn_data_input_ip6) =
- {
- .function = hicn_data_input_ip6_fn,
- .name = "hicn-data-input-ip6",
- .vector_size = sizeof(u32),
- .format_trace = format_hicn_data_input_trace,
- .type = VLIB_NODE_TYPE_INTERNAL,
- .n_errors = ARRAY_LEN(hicn_data_input_error_strings),
- .error_strings = hicn_data_input_error_strings,
- .n_next_nodes = HICN_DATA_INPUT_IP6_N_NEXT,
- .next_nodes =
- {
- [HICN_DATA_INPUT_IP6_NEXT_FACE] = "hicn6-face-input",
- [HICN_DATA_INPUT_IP6_NEXT_IP6_LOCAL] = "ip6-local-end-of-arc"
- },
- };
-/* *INDENT-ON* */
-
-/* *INDENT-OFF* */
-VNET_FEATURE_INIT(hicn_data_input_ip6_arc, static)=
- {
- .arc_name = "ip6-local",
- .node_name = "hicn-data-input-ip6",
- .runs_before = VNET_FEATURES("ip6-local-end-of-arc"),
- };
-/* *INDENT-ON* */
-
+VLIB_REGISTER_NODE (hicn_data_input_ip6) = {
+ .function = hicn_data_input_ip6_fn,
+ .name = "hicn-data-input-ip6",
+ .vector_size = sizeof (u32),
+ .format_trace = format_hicn_data_input_trace,
+ .type = VLIB_NODE_TYPE_INTERNAL,
+ .n_errors = ARRAY_LEN (hicn_data_input_error_strings),
+ .error_strings = hicn_data_input_error_strings,
+ .n_next_nodes = HICN_DATA_INPUT_IP6_N_NEXT,
+ .next_nodes = { [HICN_DATA_INPUT_IP6_NEXT_FACE] = "hicn6-face-input",
+ [HICN_DATA_INPUT_IP6_NEXT_IP6_LOCAL] =
+ "ip6-local-end-of-arc" },
+};
+VNET_FEATURE_INIT (hicn_data_input_ip6_arc, static) = {
+ .arc_name = "ip6-local",
+ .node_name = "hicn-data-input-ip6",
+ .runs_before = VNET_FEATURES ("ip6-local-end-of-arc"),
+};
always_inline uword
-hicn_data_input_ip4_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node, vlib_frame_t * frame)
+hicn_data_input_ip4_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
+ vlib_frame_t *frame)
{
ip4_main_t *im = &ip4_main;
vlib_combined_counter_main_t *cm = &load_balance_main.lbm_to_counters;
@@ -449,7 +437,6 @@ hicn_data_input_ip4_fn (vlib_main_t * vm,
else
next[3] = HICN_DATA_INPUT_IP4_NEXT_IP4_LOCAL;
-
if (PREDICT_FALSE (node->flags & VLIB_NODE_FLAG_TRACE) &&
(b[0]->flags & VLIB_BUFFER_IS_TRACED))
{
@@ -490,18 +477,14 @@ hicn_data_input_ip4_fn (vlib_main_t * vm,
t->isv6 = 0;
}
- vlib_increment_combined_counter
- (cm, thread_index, lb_index0, 1,
- vlib_buffer_length_in_chain (vm, b[0]));
- vlib_increment_combined_counter
- (cm, thread_index, lb_index1, 1,
- vlib_buffer_length_in_chain (vm, b[1]));
- vlib_increment_combined_counter
- (cm, thread_index, lb_index2, 1,
- vlib_buffer_length_in_chain (vm, b[2]));
- vlib_increment_combined_counter
- (cm, thread_index, lb_index3, 1,
- vlib_buffer_length_in_chain (vm, b[3]));
+ vlib_increment_combined_counter (cm, thread_index, lb_index0, 1,
+ vlib_buffer_length_in_chain (vm, b[0]));
+ vlib_increment_combined_counter (cm, thread_index, lb_index1, 1,
+ vlib_buffer_length_in_chain (vm, b[1]));
+ vlib_increment_combined_counter (cm, thread_index, lb_index2, 1,
+ vlib_buffer_length_in_chain (vm, b[2]));
+ vlib_increment_combined_counter (cm, thread_index, lb_index3, 1,
+ vlib_buffer_length_in_chain (vm, b[3]));
b += 4;
next += 4;
@@ -595,13 +578,10 @@ hicn_data_input_ip4_fn (vlib_main_t * vm,
t->isv6 = 0;
}
-
- vlib_increment_combined_counter
- (cm, thread_index, lb_index0, 1,
- vlib_buffer_length_in_chain (vm, b[0]));
- vlib_increment_combined_counter
- (cm, thread_index, lb_index1, 1,
- vlib_buffer_length_in_chain (vm, b[1]));
+ vlib_increment_combined_counter (cm, thread_index, lb_index0, 1,
+ vlib_buffer_length_in_chain (vm, b[0]));
+ vlib_increment_combined_counter (cm, thread_index, lb_index1, 1,
+ vlib_buffer_length_in_chain (vm, b[1]));
b += 2;
next += 2;
@@ -652,8 +632,7 @@ hicn_data_input_ip4_fn (vlib_main_t * vm,
}
vlib_increment_combined_counter (cm, thread_index, lbi0, 1,
- vlib_buffer_length_in_chain (vm,
- b[0]));
+ vlib_buffer_length_in_chain (vm, b[0]));
b += 1;
next += 1;
@@ -668,30 +647,22 @@ hicn_data_input_ip4_fn (vlib_main_t * vm,
return frame->n_vectors;
}
-/* *INDENT-OFF* */
-VLIB_REGISTER_NODE(hicn_data_input_ip4) =
- {
- .function = hicn_data_input_ip4_fn,
- .name = "hicn-data-input-ip4",
- .vector_size = sizeof(u32),
- .format_trace = format_hicn_data_input_trace,
- .type = VLIB_NODE_TYPE_INTERNAL,
- .n_errors = ARRAY_LEN(hicn_data_input_error_strings),
- .error_strings = hicn_data_input_error_strings,
- .n_next_nodes = HICN_DATA_INPUT_IP4_N_NEXT,
- .next_nodes =
- {
- [HICN_DATA_INPUT_IP4_NEXT_FACE] = "hicn4-face-input",
- [HICN_DATA_INPUT_IP4_NEXT_IP4_LOCAL] = "ip4-local-end-of-arc"
- },
- };
-/* *INDENT-ON* */
-
-/* *INDENT-OFF* */
-VNET_FEATURE_INIT(hicn_data_input_ip4_arc, static)=
- {
- .arc_name = "ip4-local",
- .node_name = "hicn-data-input-ip4",
- .runs_before = VNET_FEATURES("ip4-local-end-of-arc"),
- };
-/* *INDENT-ON* */
+VLIB_REGISTER_NODE (hicn_data_input_ip4) = {
+ .function = hicn_data_input_ip4_fn,
+ .name = "hicn-data-input-ip4",
+ .vector_size = sizeof (u32),
+ .format_trace = format_hicn_data_input_trace,
+ .type = VLIB_NODE_TYPE_INTERNAL,
+ .n_errors = ARRAY_LEN (hicn_data_input_error_strings),
+ .error_strings = hicn_data_input_error_strings,
+ .n_next_nodes = HICN_DATA_INPUT_IP4_N_NEXT,
+ .next_nodes = { [HICN_DATA_INPUT_IP4_NEXT_FACE] = "hicn4-face-input",
+ [HICN_DATA_INPUT_IP4_NEXT_IP4_LOCAL] =
+ "ip4-local-end-of-arc" },
+};
+
+VNET_FEATURE_INIT (hicn_data_input_ip4_arc, static) = {
+ .arc_name = "ip4-local",
+ .node_name = "hicn-data-input-ip4",
+ .runs_before = VNET_FEATURES ("ip4-local-end-of-arc"),
+};
diff --git a/hicn-plugin/src/data_pcslookup_node.c b/hicn-plugin/src/data_pcslookup_node.c
index 99af350b0..073d06c96 100644
--- a/hicn-plugin/src/data_pcslookup_node.c
+++ b/hicn-plugin/src/data_pcslookup_node.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Copyright (c) 2017-2021 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -29,7 +29,7 @@ static char *hicn_data_pcslookup_error_strings[] = {
};
/* packet trace format function */
-always_inline u8 *hicn_data_pcslookup_format_trace (u8 * s, va_list * args);
+always_inline u8 *hicn_data_pcslookup_format_trace (u8 *s, va_list *args);
vlib_node_registration_t hicn_data_pcslookup_node;
@@ -37,8 +37,8 @@ vlib_node_registration_t hicn_data_pcslookup_node;
* hICN node for handling data. It performs a lookup in the PIT.
*/
static uword
-hicn_data_pcslookup_node_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node, vlib_frame_t * frame)
+hicn_data_pcslookup_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
+ vlib_frame_t *frame)
{
u32 n_left_from, *from, *to_next;
hicn_data_pcslookup_next_t next_index;
@@ -107,24 +107,22 @@ hicn_data_pcslookup_node_fn (vlib_main_t * vm,
ret0 = hicn_data_parse_pkt (b0, &name, &namelen, &hicn0, &isv6);
nameptr = (u8 *) (&name);
- if (PREDICT_TRUE (ret0 == HICN_ERROR_NONE &&
- hicn_hashtb_fullhash (nameptr, namelen,
- &name_hash) ==
- HICN_ERROR_NONE))
+ if (PREDICT_TRUE (
+ ret0 == HICN_ERROR_NONE &&
+ hicn_hashtb_fullhash (nameptr, namelen, &name_hash) ==
+ HICN_ERROR_NONE))
{
- int res =
- hicn_hashtb_lookup_node (rt->pitcs->pcs_table, nameptr,
- namelen, name_hash,
- 1
- /*is_data. Do not take lock if hit CS */
- ,
- &node_id0, &dpo_ctx_id0, &vft_id0,
- &is_cs0, &hash_entry_id, &bucket_id,
- &bucket_is_overflown);
+ int res = hicn_hashtb_lookup_node (
+ rt->pitcs->pcs_table, nameptr, namelen, name_hash,
+ 1
+ /*is_data. Do not take lock if hit CS */
+ ,
+ &node_id0, &dpo_ctx_id0, &vft_id0, &is_cs0, &hash_entry_id,
+ &bucket_id, &bucket_is_overflown);
stats.pkts_data_count += 1;
- if (res == HICN_ERROR_NONE)
+ if (res == HICN_ERROR_NONE)
{
/*
* In case the result of the lookup
@@ -182,7 +180,7 @@ hicn_data_pcslookup_node_fn (vlib_main_t * vm,
/* packet trace format function */
static u8 *
-hicn_data_pcslookup_format_trace (u8 * s, va_list * args)
+hicn_data_pcslookup_format_trace (u8 *s, va_list *args)
{
CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
@@ -197,7 +195,6 @@ hicn_data_pcslookup_format_trace (u8 * s, va_list * args)
/*
* Node registration for the data forwarder node
*/
-/* *INDENT-OFF* */
VLIB_REGISTER_NODE(hicn_data_pcslookup_node) =
{
.function = hicn_data_pcslookup_node_fn,
@@ -214,7 +211,6 @@ VLIB_REGISTER_NODE(hicn_data_pcslookup_node) =
[HICN_DATA_PCSLOOKUP_NEXT_ERROR_DROP] = "error-drop",
},
};
-/* *INDENT-ON* */
/*
* fd.io coding-style-patch-verification: ON
diff --git a/hicn-plugin/src/faces/app/face_app_cli.c b/hicn-plugin/src/faces/app/face_app_cli.c
index 1aa27adc7..36f8bf3f7 100644
--- a/hicn-plugin/src/faces/app/face_app_cli.c
+++ b/hicn-plugin/src/faces/app/face_app_cli.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2020 Cisco and/or its affiliates.
+ * Copyright (c) 2017-2021 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -23,14 +23,14 @@
#include "face_prod.h"
#include "face_cons.h"
-#define HICN_FACE_NONE 0
+#define HICN_FACE_NONE 0
#define HICN_FACE_DELETE 1
-#define HICN_FACE_ADD 2
+#define HICN_FACE_ADD 2
static clib_error_t *
-hicn_face_app_cli_set_command_fn (vlib_main_t * vm,
- unformat_input_t * main_input,
- vlib_cli_command_t * cmd)
+hicn_face_app_cli_set_command_fn (vlib_main_t *vm,
+ unformat_input_t *main_input,
+ vlib_cli_command_t *cmd)
{
vnet_main_t *vnm = vnet_get_main ();
fib_prefix_t prefix;
@@ -42,7 +42,6 @@ hicn_face_app_cli_set_command_fn (vlib_main_t * vm,
int face_op = HICN_FACE_NONE;
int prod = 0;
-
/* Get a line of input. */
unformat_input_t _line_input, *line_input = &_line_input;
if (!unformat_user (main_input, unformat_line_input, line_input))
@@ -56,8 +55,8 @@ hicn_face_app_cli_set_command_fn (vlib_main_t * vm,
{
face_op = HICN_FACE_DELETE;
}
- else if (face_op == HICN_FACE_DELETE
- && unformat (line_input, "id %d", &face_id1))
+ else if (face_op == HICN_FACE_DELETE &&
+ unformat (line_input, "id %d", &face_id1))
;
else if (unformat (line_input, "add"))
{
@@ -65,13 +64,12 @@ hicn_face_app_cli_set_command_fn (vlib_main_t * vm,
}
else if (face_op == HICN_FACE_ADD)
{
- if (unformat (line_input, "intfc %U",
- unformat_vnet_sw_interface, vnm, &sw_if))
+ if (unformat (line_input, "intfc %U", unformat_vnet_sw_interface,
+ vnm, &sw_if))
;
- else
- if (unformat
- (line_input, "prod prefix %U/%d", unformat_ip46_address,
- &prefix.fp_addr, IP46_TYPE_ANY, &prefix.fp_len))
+ else if (unformat (line_input, "prod prefix %U/%d",
+ unformat_ip46_address, &prefix.fp_addr,
+ IP46_TYPE_ANY, &prefix.fp_len))
{
prod = 1;
}
@@ -81,10 +79,9 @@ hicn_face_app_cli_set_command_fn (vlib_main_t * vm,
;
else
{
- return clib_error_return (0, "%s '%U'",
- get_error_string
- (HICN_ERROR_CLI_INVAL),
- format_unformat_error, line_input);
+ return clib_error_return (
+ 0, "%s '%U'", get_error_string (HICN_ERROR_CLI_INVAL),
+ format_unformat_error, line_input);
}
}
else
@@ -116,20 +113,17 @@ hicn_face_app_cli_set_command_fn (vlib_main_t * vm,
if (prod)
{
- prefix.fp_proto =
- ip46_address_is_ip4 (&prefix.
- fp_addr) ? FIB_PROTOCOL_IP4 :
- FIB_PROTOCOL_IP6;
- rv =
- hicn_face_prod_add (&prefix, sw_if, &cs_reserved, &prod_addr,
- &face_id1);
+ prefix.fp_proto = ip46_address_is_ip4 (&prefix.fp_addr) ?
+ FIB_PROTOCOL_IP4 :
+ FIB_PROTOCOL_IP6;
+ rv = hicn_face_prod_add (&prefix, sw_if, &cs_reserved, &prod_addr,
+ &face_id1);
if (rv == HICN_ERROR_NONE)
{
u8 *sbuf = NULL;
- sbuf =
- format (sbuf, "Face id: %d, producer address %U", face_id1,
- format_ip46_address, &prod_addr,
- 0 /*IP46_ANY_TYPE */ );
+ sbuf = format (sbuf, "Face id: %d, producer address %U",
+ face_id1, format_ip46_address, &prod_addr,
+ 0 /*IP46_ANY_TYPE */);
vlib_cli_output (vm, "%s", sbuf);
}
else
@@ -139,17 +133,16 @@ hicn_face_app_cli_set_command_fn (vlib_main_t * vm,
}
else
{
- rv =
- hicn_face_cons_add (&cons_addr4, &cons_addr6, sw_if, &face_id1,
- &face_id2);
+ rv = hicn_face_cons_add (&cons_addr4, &cons_addr6, sw_if,
+ &face_id1, &face_id2);
if (rv == HICN_ERROR_NONE)
{
u8 *sbuf = NULL;
- sbuf =
- format (sbuf,
- "Face id: %d, address v4 %U, face id: %d address v6 %U",
- face_id1, format_ip4_address, &cons_addr4, face_id2,
- format_ip6_address, &cons_addr6);
+ sbuf = format (
+ sbuf,
+ "Face id: %d, address v4 %U, face id: %d address v6 %U",
+ face_id1, format_ip4_address, &cons_addr4, face_id2,
+ format_ip6_address, &cons_addr6);
vlib_cli_output (vm, "%s", sbuf);
}
else
@@ -181,20 +174,18 @@ hicn_face_app_cli_set_command_fn (vlib_main_t * vm,
return clib_error_return (0, "Operation (%d) not implemented", face_op);
break;
}
- return (rv == HICN_ERROR_NONE) ? 0 : clib_error_return (0, "%s\n",
- get_error_string
- (rv));
+ return (rv == HICN_ERROR_NONE) ?
+ 0 :
+ clib_error_return (0, "%s\n", get_error_string (rv));
}
/* cli declaration for 'cfg face' */
-/* *INDENT-OFF* */
-VLIB_CLI_COMMAND (hicn_face_app_cli_set_command, static) =
-{
+VLIB_CLI_COMMAND (hicn_face_app_cli_set_command, static) = {
.path = "hicn face app",
- .short_help = "hicn face app {add intfc <sw_if> { prod prefix <hicn_prefix> cs_size <size_in_packets>} {cons} | {del <face_id>}",
+ .short_help = "hicn face app {add intfc <sw_if> { prod prefix <hicn_prefix> "
+ "cs_size <size_in_packets>} {cons} | {del <face_id>}",
.function = hicn_face_app_cli_set_command_fn,
};
-/* *INDENT-ON* */
/*
* fd.io coding-style-patch-verification: ON
diff --git a/hicn-plugin/src/faces/app/face_prod_node.c b/hicn-plugin/src/faces/app/face_prod_node.c
index 80c3e124c..a843a01ef 100644
--- a/hicn-plugin/src/faces/app/face_prod_node.c
+++ b/hicn-plugin/src/faces/app/face_prod_node.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2020 Cisco and/or its affiliates.
+ * Copyright (c) 2017-2021 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -19,8 +19,8 @@
* @brief Application interface node
*
* This node runs after the device-input node and perfoms some safety checks in
- * order to avoid unespected interest and data (i.e., hICN packets whose name do
- * not contain the prefix associated to the application face)
+ * order to avoid unespected interest and data (i.e., hICN packets whose name
+ * do not contain the prefix associated to the application face)
*/
#include "face_prod.h"
@@ -56,7 +56,7 @@ typedef enum
vlib_node_registration_t hicn_face_prod_input_node;
static __clib_unused u8 *
-format_face_prod_input_trace (u8 * s, va_list * args)
+format_face_prod_input_trace (u8 *s, va_list *args)
{
CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
@@ -64,13 +64,13 @@ format_face_prod_input_trace (u8 * s, va_list * args)
va_arg (*args, hicn_face_prod_input_trace_t *);
CLIB_UNUSED (u32 indent) = format_get_indent (s);
- s = format (s, "prod-face: sw_if_index %d next-index %d",
- t->sw_if_index, t->next_index);
+ s = format (s, "prod-face: sw_if_index %d next-index %d", t->sw_if_index,
+ t->next_index);
return s;
}
static_always_inline int
-match_ip4_name (u32 * name, fib_prefix_t * prefix)
+match_ip4_name (u32 *name, fib_prefix_t *prefix)
{
u32 xor = 0;
@@ -80,7 +80,7 @@ match_ip4_name (u32 * name, fib_prefix_t * prefix)
}
static_always_inline int
-match_ip6_name (u8 * name, fib_prefix_t * prefix)
+match_ip6_name (u8 *name, fib_prefix_t *prefix)
{
union
{
@@ -93,12 +93,12 @@ match_ip6_name (u8 * name, fib_prefix_t * prefix)
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]);
+ (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, fib_prefix_t * prefix)
+hicn_face_prod_next_from_data_hdr (vlib_node_runtime_t *node, vlib_buffer_t *b,
+ fib_prefix_t *prefix)
{
u8 *ptr = vlib_buffer_get_current (b);
u8 v = *ptr & 0xf0;
@@ -106,21 +106,20 @@ hicn_face_prod_next_from_data_hdr (vlib_node_runtime_t * node,
if (PREDICT_TRUE (v == 0x40 && ip46_address_is_ip4 (&prefix->fp_addr)))
{
- match_res = match_ip4_name ((u32 *) & (ptr[12]), prefix);
+ match_res = match_ip4_name ((u32 *) &(ptr[12]), prefix);
}
else if (PREDICT_TRUE (v == 0x60 && !ip46_address_is_ip4 (&prefix->fp_addr)))
{
- match_res = match_ip6_name (& (ptr[8]), prefix);
+ match_res = match_ip6_name (&(ptr[8]), prefix);
}
- return match_res ? HICN_FACE_PROD_NEXT_DATA_IP4 + (v ==
- 0x60) :
- HICN_FACE_PROD_NEXT_ERROR_DROP;
+ return match_res ? HICN_FACE_PROD_NEXT_DATA_IP4 + (v == 0x60) :
+ HICN_FACE_PROD_NEXT_ERROR_DROP;
}
static_always_inline void
-hicn_face_prod_trace_buffer (vlib_main_t * vm, vlib_node_runtime_t * node,
- u32 swif, vlib_buffer_t * b, u32 next)
+hicn_face_prod_trace_buffer (vlib_main_t *vm, vlib_node_runtime_t *node,
+ u32 swif, vlib_buffer_t *b, u32 next)
{
if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) &&
(b->flags & VLIB_BUFFER_IS_TRACED)))
@@ -133,9 +132,8 @@ hicn_face_prod_trace_buffer (vlib_main_t * vm, vlib_node_runtime_t * node,
}
static uword
-hicn_face_prod_input_node_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+hicn_face_prod_input_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
+ vlib_frame_t *frame)
{
u32 n_left_from, *from, *to_next;
hicn_face_prod_next_t next_index;
@@ -192,14 +190,10 @@ hicn_face_prod_input_node_fn (vlib_main_t * vm,
b2 = vlib_get_buffer (vm, bi2);
b3 = vlib_get_buffer (vm, bi3);
- prod_face0 =
- &face_state_vec[vnet_buffer (b0)->sw_if_index[VLIB_RX]];
- prod_face1 =
- &face_state_vec[vnet_buffer (b1)->sw_if_index[VLIB_RX]];
- prod_face2 =
- &face_state_vec[vnet_buffer (b2)->sw_if_index[VLIB_RX]];
- prod_face3 =
- &face_state_vec[vnet_buffer (b3)->sw_if_index[VLIB_RX]];
+ prod_face0 = &face_state_vec[vnet_buffer (b0)->sw_if_index[VLIB_RX]];
+ prod_face1 = &face_state_vec[vnet_buffer (b1)->sw_if_index[VLIB_RX]];
+ prod_face2 = &face_state_vec[vnet_buffer (b2)->sw_if_index[VLIB_RX]];
+ prod_face3 = &face_state_vec[vnet_buffer (b3)->sw_if_index[VLIB_RX]];
next0 =
hicn_face_prod_next_from_data_hdr (node, b0, &prod_face0->prefix);
@@ -212,18 +206,14 @@ hicn_face_prod_input_node_fn (vlib_main_t * vm,
stats.pkts_data_count += 4;
/* trace */
- hicn_face_prod_trace_buffer (vm, node,
- vnet_buffer (b0)->sw_if_index[VLIB_RX],
- b0, next0);
- hicn_face_prod_trace_buffer (vm, node,
- vnet_buffer (b1)->sw_if_index[VLIB_RX],
- b1, next1);
- hicn_face_prod_trace_buffer (vm, node,
- vnet_buffer (b2)->sw_if_index[VLIB_RX],
- b2, next2);
- hicn_face_prod_trace_buffer (vm, node,
- vnet_buffer (b3)->sw_if_index[VLIB_RX],
- b3, next3);
+ hicn_face_prod_trace_buffer (
+ vm, node, vnet_buffer (b0)->sw_if_index[VLIB_RX], b0, next0);
+ hicn_face_prod_trace_buffer (
+ vm, node, vnet_buffer (b1)->sw_if_index[VLIB_RX], b1, next1);
+ hicn_face_prod_trace_buffer (
+ vm, node, vnet_buffer (b2)->sw_if_index[VLIB_RX], b2, next2);
+ hicn_face_prod_trace_buffer (
+ vm, node, vnet_buffer (b3)->sw_if_index[VLIB_RX], b3, next3);
/* enqueue */
vlib_validate_buffer_enqueue_x4 (vm, node, next_index, to_next,
@@ -231,7 +221,6 @@ hicn_face_prod_input_node_fn (vlib_main_t * vm,
next0, next1, next2, next3);
stats.pkts_processed += 4;
-
}
while (n_left_from > 0 && n_left_to_next > 0)
@@ -264,30 +253,27 @@ hicn_face_prod_input_node_fn (vlib_main_t * vm,
stats.pkts_data_count++;
/* trace */
- hicn_face_prod_trace_buffer (vm, node,
- vnet_buffer (b0)->sw_if_index[VLIB_RX],
- b0, next0);
+ hicn_face_prod_trace_buffer (
+ vm, node, vnet_buffer (b0)->sw_if_index[VLIB_RX], b0, next0);
/* enqueue */
vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
n_left_to_next, bi0, next0);
stats.pkts_processed += 1;
-
}
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}
- vlib_node_increment_counter (vm, node->node_index,
- HICNFWD_ERROR_PROCESSED, stats.pkts_processed);
+ vlib_node_increment_counter (vm, node->node_index, HICNFWD_ERROR_PROCESSED,
+ stats.pkts_processed);
vlib_node_increment_counter (vm, node->node_index, HICNFWD_ERROR_DATAS,
stats.pkts_data_count);
return (frame->n_vectors);
}
-/* *INDENT-OFF* */
VLIB_REGISTER_NODE(hicn_face_prod_input_node) =
{
.function = hicn_face_prod_input_node_fn,
@@ -305,8 +291,7 @@ VLIB_REGISTER_NODE(hicn_face_prod_input_node) =
[HICN_FACE_PROD_NEXT_ERROR_DROP] = "error-drop",
},
};
-/* *INDENT-ON* */
-
+
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/hicn-plugin/src/faces/face_node.c b/hicn-plugin/src/faces/face_node.c
index 48d97ad51..5fe682bd0 100644
--- a/hicn-plugin/src/faces/face_node.c
+++ b/hicn-plugin/src/faces/face_node.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Cisco and/or its affiliates.
+ * Copyright (c) 2020-2021 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -57,8 +57,7 @@ typedef struct
u32 sw_if_index;
u8 pkt_type;
u8 packet_data[60];
-}
-hicn4_face_input_trace_t;
+} hicn4_face_input_trace_t;
typedef enum
{
@@ -75,8 +74,7 @@ typedef struct
u32 sw_if_index;
u8 pkt_type;
u8 packet_data[60];
-}
-hicn6_face_input_trace_t;
+} hicn6_face_input_trace_t;
typedef enum
{
@@ -88,8 +86,8 @@ typedef enum
#define NEXT_MAPME_IP4 HICN4_FACE_INPUT_NEXT_MAPME
#define NEXT_MAPME_IP6 HICN6_FACE_INPUT_NEXT_MAPME
-#define NEXT_DATA_IP4 HICN4_FACE_INPUT_NEXT_DATA
-#define NEXT_DATA_IP6 HICN6_FACE_INPUT_NEXT_DATA
+#define NEXT_DATA_IP4 HICN4_FACE_INPUT_NEXT_DATA
+#define NEXT_DATA_IP6 HICN6_FACE_INPUT_NEXT_DATA
#define NEXT_ERROR_DROP_IP4 HICN4_FACE_INPUT_NEXT_ERROR_DROP
#define NEXT_ERROR_DROP_IP6 HICN6_FACE_INPUT_NEXT_ERROR_DROP
@@ -109,202 +107,185 @@ typedef enum
* followind code is pretty straighforward and most of the complexity is in
* functions that can be easily debug.
*/
-#define face_input_x1(ipv) \
- do{ \
- vlib_buffer_t *b0; \
- u32 bi0; \
- u32 next0 = NEXT_ERROR_DROP_IP##ipv; \
- IP_HEADER_##ipv * ip_hdr = NULL; \
- hicn_buffer_t * hicnb0; \
- int ret; \
- /* Prefetch for next iteration. */ \
- if (n_left_from > 1) \
- { \
- vlib_buffer_t *b1; \
- b1 = vlib_get_buffer (vm, from[1]); \
- CLIB_PREFETCH (b1, 2*CLIB_CACHE_LINE_BYTES, STORE); \
- CLIB_PREFETCH (b1->data, CLIB_CACHE_LINE_BYTES , LOAD); \
- } \
- /* Dequeue a packet buffer */ \
- bi0 = from[0]; \
- from += 1; \
- n_left_from -= 1; \
- to_next[0] = bi0; \
- to_next += 1; \
- n_left_to_next -= 1; \
- \
- b0 = vlib_get_buffer (vm, bi0); \
- hicnb0 = hicn_get_buffer(b0); \
- ip_hdr = (IP_HEADER_##ipv *) vlib_buffer_get_current(b0); \
- \
- u8 is_icmp = ip_hdr->protocol == IPPROTO_ICMPV##ipv; \
- \
- next0 = is_icmp*NEXT_MAPME_IP##ipv + \
- (1-is_icmp)*NEXT_DATA_IP##ipv; \
- \
- ret = LOCK_DPO_FACE_IP##ipv \
- (&(hicnb0->face_id), \
- &(hicnb0->in_faces_vec_id), \
- &hicnb0->flags, \
- &(ip_hdr->dst_address)); \
- \
- if ( PREDICT_FALSE(ret != HICN_ERROR_NONE) ) \
- next0 = NEXT_ERROR_DROP_IP##ipv; \
- else \
- { \
- vlib_increment_combined_counter ( \
- &counters[hicnb0->face_id \
- * HICN_N_COUNTER], thread_index, \
- HICN_FACE_COUNTERS_DATA_RX, \
- 1, \
- vlib_buffer_length_in_chain(vm, b0)); \
- stats.pkts_data_count += 1; \
- } \
- \
- if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
- (b0->flags & VLIB_BUFFER_IS_TRACED))) \
- { \
- TRACE_INPUT_PKT_IP##ipv *t = \
- vlib_add_trace (vm, node, b0, sizeof (*t)); \
- t->pkt_type = HICN_PKT_TYPE_INTEREST; \
- t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
- t->next_index = next0; \
- clib_memcpy_fast (t->packet_data, \
- vlib_buffer_get_current (b0), \
- sizeof (t->packet_data)); \
- } \
- \
- \
- /* Verify speculative enqueue, maybe switch current next frame */ \
- vlib_validate_buffer_enqueue_x1 (vm, node, next_index, \
- to_next, n_left_to_next, \
- bi0, next0); \
- }while(0)
-
-
-#define face_input_x2(ipv) \
- do{ \
- vlib_buffer_t *b0, *b1; \
- u32 bi0, bi1; \
- u32 next0 = NEXT_ERROR_DROP_IP##ipv; \
- u32 next1 = NEXT_ERROR_DROP_IP##ipv; \
- IP_HEADER_##ipv * ip_hdr0 = NULL; \
- IP_HEADER_##ipv * ip_hdr1 = NULL; \
- hicn_buffer_t * hicnb0; \
- hicn_buffer_t * hicnb1; \
- int ret0, ret1; \
- /* Prefetch for next iteration. */ \
- { \
- vlib_buffer_t *b2, *b3; \
- b2 = vlib_get_buffer (vm, from[2]); \
- b3 = vlib_get_buffer (vm, from[3]); \
- CLIB_PREFETCH (b2, 2*CLIB_CACHE_LINE_BYTES, STORE); \
- CLIB_PREFETCH (b3, 2*CLIB_CACHE_LINE_BYTES, STORE); \
- CLIB_PREFETCH (b2->data, CLIB_CACHE_LINE_BYTES , LOAD); \
- CLIB_PREFETCH (b3->data, CLIB_CACHE_LINE_BYTES , LOAD); \
- } \
- /* Dequeue a packet buffer */ \
- bi0 = from[0]; \
- bi1 = from[1]; \
- from += 2; \
- n_left_from -= 2; \
- to_next[0] = bi0; \
- to_next[1] = bi1; \
- to_next += 2; \
- n_left_to_next -= 2; \
- \
- b0 = vlib_get_buffer (vm, bi0); \
- b1 = vlib_get_buffer (vm, bi1); \
- hicnb0 = hicn_get_buffer(b0); \
- hicnb1 = hicn_get_buffer(b1); \
- ip_hdr0 = (IP_HEADER_##ipv *) vlib_buffer_get_current(b0); \
- ip_hdr1 = (IP_HEADER_##ipv *) vlib_buffer_get_current(b1); \
- \
- u8 is_icmp0 = ip_hdr0->protocol == IPPROTO_ICMPV##ipv; \
- u8 is_icmp1 = ip_hdr1->protocol == IPPROTO_ICMPV##ipv; \
- \
- next0 = is_icmp0*NEXT_MAPME_IP##ipv + \
- (1-is_icmp0)*NEXT_DATA_IP##ipv; \
- \
- next1 = is_icmp1*NEXT_MAPME_IP##ipv + \
- (1-is_icmp1)*NEXT_DATA_IP##ipv; \
- \
- \
- ret0 = LOCK_DPO_FACE_IP##ipv \
- (&(hicnb0->face_id), \
- &(hicnb0->in_faces_vec_id), \
- &hicnb0->flags, \
- &(ip_hdr0->dst_address)); \
- \
- ret1 = LOCK_DPO_FACE_IP##ipv \
- (&(hicnb1->face_id), \
- &(hicnb1->in_faces_vec_id), \
- &hicnb1->flags, \
- &(ip_hdr1->dst_address)); \
- \
- if ( PREDICT_FALSE(ret0 != HICN_ERROR_NONE) ) \
- next0 = NEXT_ERROR_DROP_IP##ipv; \
- else \
- { \
- vlib_increment_combined_counter ( \
- &counters[hicnb0->face_id \
- * HICN_N_COUNTER], thread_index, \
- HICN_FACE_COUNTERS_DATA_RX, \
- 1, \
- vlib_buffer_length_in_chain(vm, b0)); \
- stats.pkts_data_count += 1; \
- } \
- \
- if ( PREDICT_FALSE(ret1 != HICN_ERROR_NONE) ) \
- next1 = NEXT_ERROR_DROP_IP##ipv; \
- else \
- { \
- vlib_increment_combined_counter ( \
- &counters[hicnb1->face_id \
- * HICN_N_COUNTER], thread_index,\
- HICN_FACE_COUNTERS_DATA_RX, \
- 1, \
- vlib_buffer_length_in_chain(vm, b1)); \
- stats.pkts_data_count += 1; \
- } \
- \
- if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
- (b0->flags & VLIB_BUFFER_IS_TRACED))) \
- { \
- TRACE_INPUT_PKT_IP##ipv *t = \
- vlib_add_trace (vm, node, b0, sizeof (*t)); \
- t->pkt_type = HICN_PKT_TYPE_INTEREST; \
- t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
- t->next_index = next0; \
- clib_memcpy_fast (t->packet_data, \
- vlib_buffer_get_current (b0), \
- sizeof (t->packet_data)); \
- } \
- \
- if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
- (b1->flags & VLIB_BUFFER_IS_TRACED))) \
- { \
- TRACE_INPUT_PKT_IP##ipv *t = \
- vlib_add_trace (vm, node, b1, sizeof (*t)); \
- t->pkt_type = HICN_PKT_TYPE_INTEREST; \
- t->sw_if_index = vnet_buffer (b1)->sw_if_index[VLIB_RX]; \
- t->next_index = next1; \
- clib_memcpy_fast (t->packet_data, \
- vlib_buffer_get_current (b1), \
- sizeof (t->packet_data)); \
- } \
- \
- \
- /* Verify speculative enqueue, maybe switch current next frame */ \
- vlib_validate_buffer_enqueue_x2 (vm, node, next_index, \
- to_next, n_left_to_next, \
- bi0, bi1, next0, next1); \
- }while(0)
-
+#define face_input_x1(ipv) \
+ do \
+ { \
+ vlib_buffer_t *b0; \
+ u32 bi0; \
+ u32 next0 = NEXT_ERROR_DROP_IP##ipv; \
+ IP_HEADER_##ipv *ip_hdr = NULL; \
+ hicn_buffer_t *hicnb0; \
+ int ret; \
+ /* Prefetch for next iteration. */ \
+ if (n_left_from > 1) \
+ { \
+ vlib_buffer_t *b1; \
+ b1 = vlib_get_buffer (vm, from[1]); \
+ CLIB_PREFETCH (b1, 2 * CLIB_CACHE_LINE_BYTES, STORE); \
+ CLIB_PREFETCH (b1->data, CLIB_CACHE_LINE_BYTES, LOAD); \
+ } \
+ /* Dequeue a packet buffer */ \
+ bi0 = from[0]; \
+ from += 1; \
+ n_left_from -= 1; \
+ to_next[0] = bi0; \
+ to_next += 1; \
+ n_left_to_next -= 1; \
+ \
+ b0 = vlib_get_buffer (vm, bi0); \
+ hicnb0 = hicn_get_buffer (b0); \
+ ip_hdr = (IP_HEADER_##ipv *) vlib_buffer_get_current (b0); \
+ \
+ u8 is_icmp = ip_hdr->protocol == IPPROTO_ICMPV##ipv; \
+ \
+ next0 = \
+ is_icmp * NEXT_MAPME_IP##ipv + (1 - is_icmp) * NEXT_DATA_IP##ipv; \
+ \
+ ret = LOCK_DPO_FACE_IP##ipv (&(hicnb0->face_id), \
+ &(hicnb0->in_faces_vec_id), \
+ &hicnb0->flags, &(ip_hdr->dst_address)); \
+ \
+ if (PREDICT_FALSE (ret != HICN_ERROR_NONE)) \
+ next0 = NEXT_ERROR_DROP_IP##ipv; \
+ else \
+ { \
+ vlib_increment_combined_counter ( \
+ &counters[hicnb0->face_id * HICN_N_COUNTER], thread_index, \
+ HICN_FACE_COUNTERS_DATA_RX, 1, \
+ vlib_buffer_length_in_chain (vm, b0)); \
+ stats.pkts_data_count += 1; \
+ } \
+ \
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
+ (b0->flags & VLIB_BUFFER_IS_TRACED))) \
+ { \
+ TRACE_INPUT_PKT_IP##ipv *t = \
+ vlib_add_trace (vm, node, b0, sizeof (*t)); \
+ t->pkt_type = HICN_PKT_TYPE_INTEREST; \
+ t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
+ t->next_index = next0; \
+ clib_memcpy_fast (t->packet_data, vlib_buffer_get_current (b0), \
+ sizeof (t->packet_data)); \
+ } \
+ \
+ /* Verify speculative enqueue, maybe switch current next frame */ \
+ vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next, \
+ n_left_to_next, bi0, next0); \
+ } \
+ while (0)
+
+#define face_input_x2(ipv) \
+ do \
+ { \
+ vlib_buffer_t *b0, *b1; \
+ u32 bi0, bi1; \
+ u32 next0 = NEXT_ERROR_DROP_IP##ipv; \
+ u32 next1 = NEXT_ERROR_DROP_IP##ipv; \
+ IP_HEADER_##ipv *ip_hdr0 = NULL; \
+ IP_HEADER_##ipv *ip_hdr1 = NULL; \
+ hicn_buffer_t *hicnb0; \
+ hicn_buffer_t *hicnb1; \
+ int ret0, ret1; \
+ /* Prefetch for next iteration. */ \
+ { \
+ vlib_buffer_t *b2, *b3; \
+ b2 = vlib_get_buffer (vm, from[2]); \
+ b3 = vlib_get_buffer (vm, from[3]); \
+ CLIB_PREFETCH (b2, 2 * CLIB_CACHE_LINE_BYTES, STORE); \
+ CLIB_PREFETCH (b3, 2 * CLIB_CACHE_LINE_BYTES, STORE); \
+ CLIB_PREFETCH (b2->data, CLIB_CACHE_LINE_BYTES, LOAD); \
+ CLIB_PREFETCH (b3->data, CLIB_CACHE_LINE_BYTES, LOAD); \
+ } \
+ /* Dequeue a packet buffer */ \
+ bi0 = from[0]; \
+ bi1 = from[1]; \
+ from += 2; \
+ n_left_from -= 2; \
+ to_next[0] = bi0; \
+ to_next[1] = bi1; \
+ to_next += 2; \
+ n_left_to_next -= 2; \
+ \
+ b0 = vlib_get_buffer (vm, bi0); \
+ b1 = vlib_get_buffer (vm, bi1); \
+ hicnb0 = hicn_get_buffer (b0); \
+ hicnb1 = hicn_get_buffer (b1); \
+ ip_hdr0 = (IP_HEADER_##ipv *) vlib_buffer_get_current (b0); \
+ ip_hdr1 = (IP_HEADER_##ipv *) vlib_buffer_get_current (b1); \
+ \
+ u8 is_icmp0 = ip_hdr0->protocol == IPPROTO_ICMPV##ipv; \
+ u8 is_icmp1 = ip_hdr1->protocol == IPPROTO_ICMPV##ipv; \
+ \
+ next0 = \
+ is_icmp0 * NEXT_MAPME_IP##ipv + (1 - is_icmp0) * NEXT_DATA_IP##ipv; \
+ \
+ next1 = \
+ is_icmp1 * NEXT_MAPME_IP##ipv + (1 - is_icmp1) * NEXT_DATA_IP##ipv; \
+ \
+ ret0 = LOCK_DPO_FACE_IP##ipv (&(hicnb0->face_id), \
+ &(hicnb0->in_faces_vec_id), \
+ &hicnb0->flags, &(ip_hdr0->dst_address)); \
+ \
+ ret1 = LOCK_DPO_FACE_IP##ipv (&(hicnb1->face_id), \
+ &(hicnb1->in_faces_vec_id), \
+ &hicnb1->flags, &(ip_hdr1->dst_address)); \
+ \
+ if (PREDICT_FALSE (ret0 != HICN_ERROR_NONE)) \
+ next0 = NEXT_ERROR_DROP_IP##ipv; \
+ else \
+ { \
+ vlib_increment_combined_counter ( \
+ &counters[hicnb0->face_id * HICN_N_COUNTER], thread_index, \
+ HICN_FACE_COUNTERS_DATA_RX, 1, \
+ vlib_buffer_length_in_chain (vm, b0)); \
+ stats.pkts_data_count += 1; \
+ } \
+ \
+ if (PREDICT_FALSE (ret1 != HICN_ERROR_NONE)) \
+ next1 = NEXT_ERROR_DROP_IP##ipv; \
+ else \
+ { \
+ vlib_increment_combined_counter ( \
+ &counters[hicnb1->face_id * HICN_N_COUNTER], thread_index, \
+ HICN_FACE_COUNTERS_DATA_RX, 1, \
+ vlib_buffer_length_in_chain (vm, b1)); \
+ stats.pkts_data_count += 1; \
+ } \
+ \
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
+ (b0->flags & VLIB_BUFFER_IS_TRACED))) \
+ { \
+ TRACE_INPUT_PKT_IP##ipv *t = \
+ vlib_add_trace (vm, node, b0, sizeof (*t)); \
+ t->pkt_type = HICN_PKT_TYPE_INTEREST; \
+ t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
+ t->next_index = next0; \
+ clib_memcpy_fast (t->packet_data, vlib_buffer_get_current (b0), \
+ sizeof (t->packet_data)); \
+ } \
+ \
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
+ (b1->flags & VLIB_BUFFER_IS_TRACED))) \
+ { \
+ TRACE_INPUT_PKT_IP##ipv *t = \
+ vlib_add_trace (vm, node, b1, sizeof (*t)); \
+ t->pkt_type = HICN_PKT_TYPE_INTEREST; \
+ t->sw_if_index = vnet_buffer (b1)->sw_if_index[VLIB_RX]; \
+ t->next_index = next1; \
+ clib_memcpy_fast (t->packet_data, vlib_buffer_get_current (b1), \
+ sizeof (t->packet_data)); \
+ } \
+ \
+ /* Verify speculative enqueue, maybe switch current next frame */ \
+ vlib_validate_buffer_enqueue_x2 (vm, node, next_index, to_next, \
+ n_left_to_next, bi0, bi1, next0, \
+ next1); \
+ } \
+ while (0)
static uword
-hicn4_face_input_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+hicn4_face_input_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
+ vlib_frame_t *frame)
{
u32 n_left_from, *from, *to_next, next_index;
@@ -333,20 +314,19 @@ hicn4_face_input_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}
- vlib_node_increment_counter (vm, node->node_index,
- HICNFWD_ERROR_DATAS, stats.pkts_data_count);
+ vlib_node_increment_counter (vm, node->node_index, HICNFWD_ERROR_DATAS,
+ stats.pkts_data_count);
return (frame->n_vectors);
}
/* packet trace format function */
static u8 *
-hicn4_face_input_format_trace (u8 * s, va_list * args)
+hicn4_face_input_format_trace (u8 *s, va_list *args)
{
CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
- hicn4_face_input_trace_t *t =
- va_arg (*args, hicn4_face_input_trace_t *);
+ hicn4_face_input_trace_t *t = va_arg (*args, hicn4_face_input_trace_t *);
s = format (s, "FACE_IP4_INPUT: pkt: %d, sw_if_index %d, next index %d\n%U",
(int) t->pkt_type, t->sw_if_index, t->next_index,
@@ -354,11 +334,9 @@ hicn4_face_input_format_trace (u8 * s, va_list * args)
return (s);
}
-
/*
* Node registration for the interest forwarder node
*/
-/* *INDENT-OFF* */
VLIB_REGISTER_NODE(hicn4_face_input_node) =
{
.function = hicn4_face_input_node_fn,
@@ -377,15 +355,14 @@ VLIB_REGISTER_NODE(hicn4_face_input_node) =
[HICN4_FACE_INPUT_NEXT_ERROR_DROP] = "error-drop",
},
};
-/* *INDENT-ON* */
/**
* @brief IPv6 face input node function
* @see hicn6_face_input_node_fn
*/
static uword
-hicn6_face_input_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+hicn6_face_input_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
+ vlib_frame_t *frame)
{
u32 n_left_from, *from, *to_next, next_index;
@@ -414,20 +391,19 @@ hicn6_face_input_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}
- vlib_node_increment_counter (vm, node->node_index,
- HICNFWD_ERROR_DATAS, stats.pkts_data_count);
+ vlib_node_increment_counter (vm, node->node_index, HICNFWD_ERROR_DATAS,
+ stats.pkts_data_count);
return (frame->n_vectors);
}
/* packet trace format function */
static u8 *
-hicn6_face_input_format_trace (u8 * s, va_list * args)
+hicn6_face_input_format_trace (u8 *s, va_list *args)
{
CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
- hicn6_face_input_trace_t *t =
- va_arg (*args, hicn6_face_input_trace_t *);
+ hicn6_face_input_trace_t *t = va_arg (*args, hicn6_face_input_trace_t *);
s = format (s, "FACE_IP6_INPUT: pkt: %d, sw_if_index %d, next index %d\n%U",
(int) t->pkt_type, t->sw_if_index, t->next_index,
@@ -438,7 +414,6 @@ hicn6_face_input_format_trace (u8 * s, va_list * args)
/*
* Node registration for the interest forwarder node
*/
-/* *INDENT-OFF* */
VLIB_REGISTER_NODE(hicn6_face_input_node) =
{
.function = hicn6_face_input_node_fn,
@@ -457,7 +432,6 @@ VLIB_REGISTER_NODE(hicn6_face_input_node) =
[HICN6_FACE_INPUT_NEXT_ERROR_DROP] = "error-drop",
},
};
-/* *INDENT-ON* */
/**** FACE OUTPUT *****/
@@ -486,7 +460,8 @@ typedef enum
/* h0->v4.ip.daddr = face_ip->local_addr.ip4; */
/* vnet_buffer (b)->sw_if_index[VLIB_RX] = face->shared.sw_if; */
-/* u16 * dst_port_ptr = (u16 *)(((u8*)h0) + sizeof(ip4_header_t) + sizeof(u16)); */
+/* u16 * dst_port_ptr = (u16 *)(((u8*)h0) + sizeof(ip4_header_t) +
+ * sizeof(u16)); */
/* u16 dst_port = *dst_port_ptr; */
/* u16 * src_port_ptr = (u16 *)(((u8*)h0) + sizeof(ip4_header_t)); */
@@ -506,7 +481,8 @@ typedef enum
/* h0->v6.ip.daddr = face_ip->local_addr.ip6; */
/* vnet_buffer (b)->sw_if_index[VLIB_RX] = face->shared.sw_if; */
-/* u16 * dst_port_ptr = (u16 *)(((u8*)h0) + sizeof(ip6_header_t) + sizeof(u16)); */
+/* u16 * dst_port_ptr = (u16 *)(((u8*)h0) + sizeof(ip6_header_t) +
+ * sizeof(u16)); */
/* u16 dst_port = *dst_port_ptr; */
/* u16 * src_port_ptr = (u16 *)(((u8*)h0) + sizeof(ip6_header_t)); */
@@ -549,31 +525,31 @@ typedef enum
/* return res; */
/* } */
-
static inline void
-hicn_face_rewrite_interest (vlib_main_t * vm, vlib_buffer_t * b0,
- hicn_face_t * face, u32 * next)
+hicn_face_rewrite_interest (vlib_main_t *vm, vlib_buffer_t *b0,
+ hicn_face_t *face, u32 *next)
{
- /* if ((face->flags & HICN_FACE_FLAGS_APPFACE_PROD) && hicn_face_match_probe(b0, face, next)) */
+ /* if ((face->flags & HICN_FACE_FLAGS_APPFACE_PROD) &&
+ * hicn_face_match_probe(b0, face, next)) */
/* return; */
hicn_header_t *hicn = vlib_buffer_get_current (b0);
- //hicn_face_ip_t *ip_face = (hicn_face_ip_t *) face->data;
+ // hicn_face_ip_t *ip_face = (hicn_face_ip_t *) face->data;
ip46_address_t temp_addr;
ip46_address_reset (&temp_addr);
hicn_type_t type = hicn_get_buffer (b0)->type;
- int ret = hicn_ops_vft[type.l1]->rewrite_interest (type, &hicn->protocol,
- &face->nat_addr, &temp_addr);
+ int ret = hicn_ops_vft[type.l1]->rewrite_interest (
+ type, &hicn->protocol, &face->nat_addr, &temp_addr);
if (ret == HICN_LIB_ERROR_REWRITE_CKSUM_REQUIRED)
{
- ensure_offload_flags(b0, ip46_address_is_ip4(&face->nat_addr));
+ ensure_offload_flags (b0, ip46_address_is_ip4 (&face->nat_addr));
}
- ASSERT(face->flags & HICN_FACE_FLAGS_FACE);
+ ASSERT (face->flags & HICN_FACE_FLAGS_FACE);
vnet_buffer (b0)->ip.adj_index[VLIB_TX] = face->dpo.dpoi_index;
*next = face->dpo.dpoi_next_node;
@@ -591,7 +567,6 @@ static char *hicn6_face_output_error_strings[] = {
#undef _
};
-
/* Trace context struct */
typedef struct
{
@@ -599,8 +574,7 @@ typedef struct
u32 sw_if_index;
u8 pkt_type;
u8 packet_data[60];
-}
-hicn4_face_output_trace_t;
+} hicn4_face_output_trace_t;
/* Trace context struct */
typedef struct
@@ -609,175 +583,159 @@ typedef struct
u32 sw_if_index;
u8 pkt_type;
u8 packet_data[60];
-}
-hicn6_face_output_trace_t;
+} hicn6_face_output_trace_t;
#define TRACE_OUTPUT_PKT_IP4 hicn4_face_output_trace_t
#define TRACE_OUTPUT_PKT_IP6 hicn6_face_output_trace_t
-#define face_output_x1(ipv) \
- do { \
- vlib_buffer_t *b0; \
- u32 bi0; \
- u32 next0 = ~0; \
- hicn_face_t * face; \
- \
- /* Prefetch for next iteration. */ \
- if (n_left_from > 1) \
- { \
- vlib_buffer_t *b1; \
- b1 = vlib_get_buffer (vm, from[1]); \
- CLIB_PREFETCH (b1, CLIB_CACHE_LINE_BYTES, STORE); \
- CLIB_PREFETCH (b1->data, CLIB_CACHE_LINE_BYTES , STORE); \
- } \
- /* Dequeue a packet buffer */ \
- bi0 = from[0]; \
- from += 1; \
- n_left_from -= 1; \
- to_next[0] = bi0; \
- to_next += 1; \
- n_left_to_next -= 1; \
- \
- b0 = vlib_get_buffer (vm, bi0); \
- \
- hicn_face_id_t face_id = vnet_buffer (b0)->ip.adj_index[VLIB_TX]; \
- face = \
- hicn_dpoi_get_from_idx (face_id); \
- \
- if (PREDICT_TRUE(face != NULL)) \
- { \
- hicn_face_rewrite_interest \
- (vm, b0, face, &next0); \
- stats.pkts_interest_count += 1; \
- vlib_increment_combined_counter ( \
- &counters[face_id * HICN_N_COUNTER], \
- thread_index, \
- HICN_FACE_COUNTERS_INTEREST_TX, \
- 1, \
- vlib_buffer_length_in_chain(vm, b0)); \
- } \
- \
- if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
- (b0->flags & VLIB_BUFFER_IS_TRACED))) \
- { \
- TRACE_OUTPUT_PKT_IP##ipv *t = \
- vlib_add_trace (vm, node, b0, sizeof (*t)); \
- t->pkt_type = HICN_PKT_TYPE_INTEREST; \
- t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
- t->next_index = next0; \
- clib_memcpy_fast (t->packet_data, \
- vlib_buffer_get_current (b0), \
- sizeof (t->packet_data)); \
- } \
- \
- \
- /* Verify speculative enqueue, maybe switch current next frame */ \
- vlib_validate_buffer_enqueue_x1 (vm, node, next_index, \
- to_next, n_left_to_next, \
- bi0, next0); \
- }while(0)
-
-#define face_output_x2(ipv) \
- do { \
- vlib_buffer_t *b0, *b1; \
- u32 bi0, bi1; \
- u32 next0 = ~0; \
- u32 next1 = ~0; \
- hicn_face_t *face0, *face1; \
- \
- /* Prefetch for next iteration. */ \
- { \
- vlib_buffer_t *b2, *b3; \
- b2 = vlib_get_buffer (vm, from[2]); \
- b3 = vlib_get_buffer (vm, from[3]); \
- CLIB_PREFETCH (b2, CLIB_CACHE_LINE_BYTES, STORE); \
- CLIB_PREFETCH (b3, CLIB_CACHE_LINE_BYTES, STORE); \
- CLIB_PREFETCH (b2->data, CLIB_CACHE_LINE_BYTES , STORE); \
- CLIB_PREFETCH (b3->data, CLIB_CACHE_LINE_BYTES , STORE); \
- } \
- /* Dequeue a packet buffer */ \
- bi0 = from[0]; \
- bi1 = from[1]; \
- from += 2; \
- n_left_from -= 2; \
- to_next[0] = bi0; \
- to_next[1] = bi1; \
- to_next += 2; \
- n_left_to_next -= 2; \
- \
- b0 = vlib_get_buffer (vm, bi0); \
- b1 = vlib_get_buffer (vm, bi1); \
- \
- hicn_face_id_t face_id0 = vnet_buffer (b0)->ip.adj_index[VLIB_TX]; \
- hicn_face_id_t face_id1 = vnet_buffer (b1)->ip.adj_index[VLIB_TX]; \
- face0 = \
- hicn_dpoi_get_from_idx (face_id0); \
- face1 = \
- hicn_dpoi_get_from_idx (face_id1); \
- \
- if (PREDICT_TRUE(face0 != NULL)) \
- { \
- hicn_face_rewrite_interest \
- (vm, b0, face0, &next0); \
- stats.pkts_interest_count += 1; \
- vlib_increment_combined_counter ( \
- &counters[face_id0 * HICN_N_COUNTER], \
- thread_index, \
- HICN_FACE_COUNTERS_INTEREST_TX, \
- 1, \
- vlib_buffer_length_in_chain(vm, b0)); \
- } \
- \
- if (PREDICT_TRUE(face1 != NULL)) \
- { \
- hicn_face_rewrite_interest \
- (vm, b1, face1, &next1); \
- stats.pkts_interest_count += 1; \
- vlib_increment_combined_counter ( \
- &counters[face_id1 * HICN_N_COUNTER], \
- thread_index, \
- HICN_FACE_COUNTERS_INTEREST_TX, \
- 1, \
- vlib_buffer_length_in_chain(vm, b1)); \
- } \
- \
- if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
- (b0->flags & VLIB_BUFFER_IS_TRACED))) \
- { \
- TRACE_OUTPUT_PKT_IP##ipv *t = \
- vlib_add_trace (vm, node, b0, sizeof (*t)); \
- t->pkt_type = HICN_PKT_TYPE_INTEREST; \
- t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
- t->next_index = next0; \
- clib_memcpy_fast (t->packet_data, \
- vlib_buffer_get_current (b0), \
- sizeof (t->packet_data)); \
- } \
- \
- if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
- (b1->flags & VLIB_BUFFER_IS_TRACED))) \
- { \
- TRACE_OUTPUT_PKT_IP##ipv *t = \
- vlib_add_trace (vm, node, b1, sizeof (*t)); \
- t->pkt_type = HICN_PKT_TYPE_INTEREST; \
- t->sw_if_index = vnet_buffer (b1)->sw_if_index[VLIB_RX]; \
- t->next_index = next1; \
- clib_memcpy_fast (t->packet_data, \
- vlib_buffer_get_current (b1), \
- sizeof (t->packet_data)); \
- } \
- \
- \
- /* Verify speculative enqueue, maybe switch current next frame */ \
- vlib_validate_buffer_enqueue_x2 (vm, node, next_index, \
- to_next, n_left_to_next, \
- bi0, bi1, next0, next1); \
- }while(0)
-
+#define face_output_x1(ipv) \
+ do \
+ { \
+ vlib_buffer_t *b0; \
+ u32 bi0; \
+ u32 next0 = ~0; \
+ hicn_face_t *face; \
+ \
+ /* Prefetch for next iteration. */ \
+ if (n_left_from > 1) \
+ { \
+ vlib_buffer_t *b1; \
+ b1 = vlib_get_buffer (vm, from[1]); \
+ CLIB_PREFETCH (b1, CLIB_CACHE_LINE_BYTES, STORE); \
+ CLIB_PREFETCH (b1->data, CLIB_CACHE_LINE_BYTES, STORE); \
+ } \
+ /* Dequeue a packet buffer */ \
+ bi0 = from[0]; \
+ from += 1; \
+ n_left_from -= 1; \
+ to_next[0] = bi0; \
+ to_next += 1; \
+ n_left_to_next -= 1; \
+ \
+ b0 = vlib_get_buffer (vm, bi0); \
+ \
+ hicn_face_id_t face_id = vnet_buffer (b0)->ip.adj_index[VLIB_TX]; \
+ face = hicn_dpoi_get_from_idx (face_id); \
+ \
+ if (PREDICT_TRUE (face != NULL)) \
+ { \
+ hicn_face_rewrite_interest (vm, b0, face, &next0); \
+ stats.pkts_interest_count += 1; \
+ vlib_increment_combined_counter ( \
+ &counters[face_id * HICN_N_COUNTER], thread_index, \
+ HICN_FACE_COUNTERS_INTEREST_TX, 1, \
+ vlib_buffer_length_in_chain (vm, b0)); \
+ } \
+ \
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
+ (b0->flags & VLIB_BUFFER_IS_TRACED))) \
+ { \
+ TRACE_OUTPUT_PKT_IP##ipv *t = \
+ vlib_add_trace (vm, node, b0, sizeof (*t)); \
+ t->pkt_type = HICN_PKT_TYPE_INTEREST; \
+ t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
+ t->next_index = next0; \
+ clib_memcpy_fast (t->packet_data, vlib_buffer_get_current (b0), \
+ sizeof (t->packet_data)); \
+ } \
+ \
+ /* Verify speculative enqueue, maybe switch current next frame */ \
+ vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next, \
+ n_left_to_next, bi0, next0); \
+ } \
+ while (0)
+
+#define face_output_x2(ipv) \
+ do \
+ { \
+ vlib_buffer_t *b0, *b1; \
+ u32 bi0, bi1; \
+ u32 next0 = ~0; \
+ u32 next1 = ~0; \
+ hicn_face_t *face0, *face1; \
+ \
+ /* Prefetch for next iteration. */ \
+ { \
+ vlib_buffer_t *b2, *b3; \
+ b2 = vlib_get_buffer (vm, from[2]); \
+ b3 = vlib_get_buffer (vm, from[3]); \
+ CLIB_PREFETCH (b2, CLIB_CACHE_LINE_BYTES, STORE); \
+ CLIB_PREFETCH (b3, CLIB_CACHE_LINE_BYTES, STORE); \
+ CLIB_PREFETCH (b2->data, CLIB_CACHE_LINE_BYTES, STORE); \
+ CLIB_PREFETCH (b3->data, CLIB_CACHE_LINE_BYTES, STORE); \
+ } \
+ /* Dequeue a packet buffer */ \
+ bi0 = from[0]; \
+ bi1 = from[1]; \
+ from += 2; \
+ n_left_from -= 2; \
+ to_next[0] = bi0; \
+ to_next[1] = bi1; \
+ to_next += 2; \
+ n_left_to_next -= 2; \
+ \
+ b0 = vlib_get_buffer (vm, bi0); \
+ b1 = vlib_get_buffer (vm, bi1); \
+ \
+ hicn_face_id_t face_id0 = vnet_buffer (b0)->ip.adj_index[VLIB_TX]; \
+ hicn_face_id_t face_id1 = vnet_buffer (b1)->ip.adj_index[VLIB_TX]; \
+ face0 = hicn_dpoi_get_from_idx (face_id0); \
+ face1 = hicn_dpoi_get_from_idx (face_id1); \
+ \
+ if (PREDICT_TRUE (face0 != NULL)) \
+ { \
+ hicn_face_rewrite_interest (vm, b0, face0, &next0); \
+ stats.pkts_interest_count += 1; \
+ vlib_increment_combined_counter ( \
+ &counters[face_id0 * HICN_N_COUNTER], thread_index, \
+ HICN_FACE_COUNTERS_INTEREST_TX, 1, \
+ vlib_buffer_length_in_chain (vm, b0)); \
+ } \
+ \
+ if (PREDICT_TRUE (face1 != NULL)) \
+ { \
+ hicn_face_rewrite_interest (vm, b1, face1, &next1); \
+ stats.pkts_interest_count += 1; \
+ vlib_increment_combined_counter ( \
+ &counters[face_id1 * HICN_N_COUNTER], thread_index, \
+ HICN_FACE_COUNTERS_INTEREST_TX, 1, \
+ vlib_buffer_length_in_chain (vm, b1)); \
+ } \
+ \
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
+ (b0->flags & VLIB_BUFFER_IS_TRACED))) \
+ { \
+ TRACE_OUTPUT_PKT_IP##ipv *t = \
+ vlib_add_trace (vm, node, b0, sizeof (*t)); \
+ t->pkt_type = HICN_PKT_TYPE_INTEREST; \
+ t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
+ t->next_index = next0; \
+ clib_memcpy_fast (t->packet_data, vlib_buffer_get_current (b0), \
+ sizeof (t->packet_data)); \
+ } \
+ \
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
+ (b1->flags & VLIB_BUFFER_IS_TRACED))) \
+ { \
+ TRACE_OUTPUT_PKT_IP##ipv *t = \
+ vlib_add_trace (vm, node, b1, sizeof (*t)); \
+ t->pkt_type = HICN_PKT_TYPE_INTEREST; \
+ t->sw_if_index = vnet_buffer (b1)->sw_if_index[VLIB_RX]; \
+ t->next_index = next1; \
+ clib_memcpy_fast (t->packet_data, vlib_buffer_get_current (b1), \
+ sizeof (t->packet_data)); \
+ } \
+ \
+ /* Verify speculative enqueue, maybe switch current next frame */ \
+ vlib_validate_buffer_enqueue_x2 (vm, node, next_index, to_next, \
+ n_left_to_next, bi0, bi1, next0, \
+ next1); \
+ } \
+ while (0)
static uword
-hicn4_face_output_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+hicn4_face_output_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
+ vlib_frame_t *frame)
{
u32 n_left_from, *from, *to_next, next_index;
vl_api_hicn_api_node_stats_get_reply_t stats = { 0 };
@@ -806,8 +764,7 @@ hicn4_face_output_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}
- vlib_node_increment_counter (vm, node->node_index,
- HICNFWD_ERROR_INTERESTS,
+ vlib_node_increment_counter (vm, node->node_index, HICNFWD_ERROR_INTERESTS,
stats.pkts_interest_count);
return (frame->n_vectors);
@@ -815,48 +772,39 @@ hicn4_face_output_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
/* packet trace format function */
static u8 *
-hicn4_face_output_format_trace (u8 * s, va_list * args)
+hicn4_face_output_format_trace (u8 *s, va_list *args)
{
CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
- hicn4_face_output_trace_t *t =
- va_arg (*args, hicn4_face_output_trace_t *);
+ hicn4_face_output_trace_t *t = va_arg (*args, hicn4_face_output_trace_t *);
- s =
- format (s, "FACE_IP4_OUTPUT: pkt: %d, sw_if_index %d, next index %d\n%U",
- (int) t->pkt_type, t->sw_if_index, t->next_index,
- format_ip4_header, t->packet_data, sizeof (t->packet_data));
+ s = format (s, "FACE_IP4_OUTPUT: pkt: %d, sw_if_index %d, next index %d\n%U",
+ (int) t->pkt_type, t->sw_if_index, t->next_index,
+ format_ip4_header, t->packet_data, sizeof (t->packet_data));
return (s);
}
/*
* Node registration for the interest forwarder node
*/
-/* *INDENT-OFF* */
-VLIB_REGISTER_NODE(hicn4_face_output_node) =
-{
+VLIB_REGISTER_NODE (hicn4_face_output_node) = {
.function = hicn4_face_output_node_fn,
.name = "hicn4-face-output",
- .vector_size = sizeof(u32),
+ .vector_size = sizeof (u32),
.format_trace = hicn4_face_output_format_trace,
.type = VLIB_NODE_TYPE_INTERNAL,
- .n_errors = ARRAY_LEN(hicn4_face_output_error_strings),
+ .n_errors = ARRAY_LEN (hicn4_face_output_error_strings),
.error_strings = hicn4_face_output_error_strings,
.n_next_nodes = HICN4_FACE_OUTPUT_N_NEXT,
/* Reusing the list of nodes from lookup to be compatible with arp */
- .next_nodes =
- {
- [HICN4_FACE_OUTPUT_NEXT_ECHO_REPLY] = "hicn4-face-input",
- [HICN4_FACE_OUTPUT_NEXT_UDP4_ENCAP] = "udp4-encap",
- [HICN4_FACE_OUTPUT_NEXT_UDP6_ENCAP] = "udp6-encap"
- }
+ .next_nodes = { [HICN4_FACE_OUTPUT_NEXT_ECHO_REPLY] = "hicn4-face-input",
+ [HICN4_FACE_OUTPUT_NEXT_UDP4_ENCAP] = "udp4-encap",
+ [HICN4_FACE_OUTPUT_NEXT_UDP6_ENCAP] = "udp6-encap" }
};
-/* *INDENT-ON* */
-
static uword
-hicn6_face_output_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+hicn6_face_output_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
+ vlib_frame_t *frame)
{
u32 n_left_from, *from, *to_next, next_index;
vl_api_hicn_api_node_stats_get_reply_t stats = { 0 };
@@ -885,8 +833,7 @@ hicn6_face_output_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}
- vlib_node_increment_counter (vm, node->node_index,
- HICNFWD_ERROR_INTERESTS,
+ vlib_node_increment_counter (vm, node->node_index, HICNFWD_ERROR_INTERESTS,
stats.pkts_interest_count);
return (frame->n_vectors);
@@ -894,43 +841,36 @@ hicn6_face_output_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
/* packet trace format function */
static u8 *
-hicn6_face_output_format_trace (u8 * s, va_list * args)
+hicn6_face_output_format_trace (u8 *s, va_list *args)
{
CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
- hicn6_face_output_trace_t *t =
- va_arg (*args, hicn6_face_output_trace_t *);
+ hicn6_face_output_trace_t *t = va_arg (*args, hicn6_face_output_trace_t *);
- s =
- format (s, "FACE_IP6_OUTPUT: pkt: %d, sw_if_index %d, next index %d\n%U",
- (int) t->pkt_type, t->sw_if_index, t->next_index,
- format_ip6_header, t->packet_data, sizeof (t->packet_data));
+ s = format (s, "FACE_IP6_OUTPUT: pkt: %d, sw_if_index %d, next index %d\n%U",
+ (int) t->pkt_type, t->sw_if_index, t->next_index,
+ format_ip6_header, t->packet_data, sizeof (t->packet_data));
return (s);
}
/*
* Node registration for the interest forwarder node
*/
-/* *INDENT-OFF* */
-VLIB_REGISTER_NODE(hicn6_face_output_node) =
-{
+VLIB_REGISTER_NODE (hicn6_face_output_node) = {
.function = hicn6_face_output_node_fn,
.name = "hicn6-face-output",
- .vector_size = sizeof(u32),
+ .vector_size = sizeof (u32),
.format_trace = hicn6_face_output_format_trace,
.type = VLIB_NODE_TYPE_INTERNAL,
- .n_errors = ARRAY_LEN(hicn6_face_output_error_strings),
+ .n_errors = ARRAY_LEN (hicn6_face_output_error_strings),
.error_strings = hicn6_face_output_error_strings,
.n_next_nodes = HICN6_FACE_OUTPUT_N_NEXT,
- /* Reusing the list of nodes from lookup to be compatible with neighbour discovery */
- .next_nodes =
- {
- [HICN6_FACE_OUTPUT_NEXT_ECHO_REPLY] = "hicn6-face-input",
- [HICN6_FACE_OUTPUT_NEXT_UDP4_ENCAP] = "udp4-encap",
- [HICN6_FACE_OUTPUT_NEXT_UDP6_ENCAP] = "udp6-encap"
- }
+ /* Reusing the list of nodes from lookup to be compatible with neighbour
+ discovery */
+ .next_nodes = { [HICN6_FACE_OUTPUT_NEXT_ECHO_REPLY] = "hicn6-face-input",
+ [HICN6_FACE_OUTPUT_NEXT_UDP4_ENCAP] = "udp4-encap",
+ [HICN6_FACE_OUTPUT_NEXT_UDP6_ENCAP] = "udp6-encap" }
};
-/* *INDENT-ON* */
/*
* fd.io coding-style-patch-verification: ON
diff --git a/hicn-plugin/src/faces/iface_node.c b/hicn-plugin/src/faces/iface_node.c
index a4fd1885c..8d8500995 100644
--- a/hicn-plugin/src/faces/iface_node.c
+++ b/hicn-plugin/src/faces/iface_node.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Cisco and/or its affiliates.
+ * Copyright (c) 2020-2021 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -86,15 +86,26 @@ typedef enum
#define NEXT_INTEREST_IP4 HICN4_IFACE_INPUT_NEXT_INTEREST
#define NEXT_INTEREST_IP6 HICN6_IFACE_INPUT_NEXT_INTEREST
-#define ADDRESS_IP4 ip_interface_address_t *ia = 0;ip4_address_t *local_address = ip4_interface_first_address(&ip4_main, swif, &ia)
-#define ADDRESS_IP6 ip6_address_t *local_address = ip6_interface_first_address(&ip6_main, swif)
-
-#define ADDRESSX2_IP4 ip_interface_address_t *ia0, *ia1; ia0 = ia1 = 0; \
- ip4_address_t *local_address0 = ip4_interface_first_address(&ip4_main, swif0, &ia0); \
- ip4_address_t *local_address1 = ip4_interface_first_address(&ip4_main, swif1, &ia1);
-
-#define ADDRESSX2_IP6 ip6_address_t *local_address0 = ip6_interface_first_address(&ip6_main, swif0); \
- ip6_address_t *local_address1 = ip6_interface_first_address(&ip6_main, swif1);
+#define ADDRESS_IP4 \
+ ip_interface_address_t *ia = 0; \
+ ip4_address_t *local_address = \
+ ip4_interface_first_address (&ip4_main, swif, &ia)
+#define ADDRESS_IP6 \
+ ip6_address_t *local_address = ip6_interface_first_address (&ip6_main, swif)
+
+#define ADDRESSX2_IP4 \
+ ip_interface_address_t *ia0, *ia1; \
+ ia0 = ia1 = 0; \
+ ip4_address_t *local_address0 = \
+ ip4_interface_first_address (&ip4_main, swif0, &ia0); \
+ ip4_address_t *local_address1 = \
+ ip4_interface_first_address (&ip4_main, swif1, &ia1);
+
+#define ADDRESSX2_IP6 \
+ ip6_address_t *local_address0 = \
+ ip6_interface_first_address (&ip6_main, swif0); \
+ ip6_address_t *local_address1 = \
+ ip6_interface_first_address (&ip6_main, swif1);
#define DPO_ADD_LOCK_IFACE_IP4 hicn_iface_ip4_add_and_lock
#define DPO_ADD_LOCK_IFACE_IP6 hicn_iface_ip6_add_and_lock
@@ -122,7 +133,6 @@ static char *hicn6_iface_output_error_strings[] = {
#undef _
};
-
/* Trace context struct */
typedef struct
{
@@ -174,207 +184,189 @@ typedef enum
// NODES IMPLEMENTATIONS
-#define iface_input_x1(ipv) \
- do { \
- vlib_buffer_t *b0; \
- u32 bi0, next0, next_iface0; \
- IP_HEADER_##ipv * ip_hdr = NULL; \
- hicn_buffer_t * hicnb0; \
- /* Prefetch for next iteration. */ \
- if (n_left_from > 1) \
- { \
- vlib_buffer_t *b1; \
- b1 = vlib_get_buffer (vm, from[1]); \
- CLIB_PREFETCH (b1, 2*CLIB_CACHE_LINE_BYTES, STORE); \
- CLIB_PREFETCH (b1->data, CLIB_CACHE_LINE_BYTES , LOAD); \
- } \
- /* Dequeue a packet buffer */ \
- bi0 = from[0]; \
- from += 1; \
- n_left_from -= 1; \
- to_next[0] = bi0; \
- to_next += 1; \
- n_left_to_next -= 1; \
- \
- b0 = vlib_get_buffer (vm, bi0); \
- hicnb0 = hicn_get_buffer(b0); \
- ip_hdr = (IP_HEADER_##ipv *) vlib_buffer_get_current(b0); \
- \
- stats.pkts_interest_count += 1; \
- \
- u8 is_icmp = ip_hdr->protocol == IPPROTO_ICMPV##ipv; \
- \
- next0 = is_icmp*NEXT_MAPME_IP##ipv + \
- (1-is_icmp)*NEXT_INTEREST_IP##ipv; \
- \
- next_iface0 = NEXT_DATA_LOOKUP_IP##ipv; \
- \
- if (hicnb0->flags & HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL) \
- next_iface0 = NEXT_UDP_ENCAP_IP4; \
- else if(hicnb0->flags & HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL) \
- next_iface0 = NEXT_UDP_ENCAP_IP6; \
- \
- DPO_ADD_LOCK_IFACE_IP##ipv \
- (&(hicnb0->face_id), \
- &hicnb0->flags, \
- &(ip_hdr->src_address), \
- vnet_buffer(b0)->sw_if_index[VLIB_RX], \
- vnet_buffer(b0)->ip.adj_index[VLIB_RX], \
- next_iface0); \
- \
- if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
- (b0->flags & VLIB_BUFFER_IS_TRACED))) \
- { \
- TRACE_INPUT_PKT_IP##ipv *t = \
- vlib_add_trace (vm, node, b0, sizeof (*t)); \
- t->pkt_type = HICN_PKT_TYPE_INTEREST; \
- t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
- t->next_index = next0; \
- clib_memcpy_fast (t->packet_data, \
- vlib_buffer_get_current (b0), \
- sizeof (t->packet_data)); \
- \
- } \
- \
- vlib_increment_combined_counter ( \
- &counters[hicnb0->face_id \
- * HICN_N_COUNTER], thread_index, \
- HICN_FACE_COUNTERS_INTEREST_RX, \
- 1, \
- vlib_buffer_length_in_chain(vm, b0)); \
- \
- /* Verify speculative enqueue, maybe switch current next frame */ \
- vlib_validate_buffer_enqueue_x1 (vm, node, next_index, \
- to_next, n_left_to_next, \
- bi0, next0); \
- }while(0)
-
-
-#define iface_input_x2(ipv) \
- do { \
- vlib_buffer_t *b0, *b1; \
- u32 bi0, bi1, next0, next1, next_iface0, next_iface1; \
- IP_HEADER_##ipv * ip_hdr0 = NULL; \
- IP_HEADER_##ipv * ip_hdr1 = NULL; \
- hicn_buffer_t *hicnb0, *hicnb1; \
- \
- /* Prefetch for next iteration. */ \
- vlib_buffer_t *b2, *b3; \
- b2 = vlib_get_buffer (vm, from[2]); \
- b3 = vlib_get_buffer (vm, from[3]); \
- CLIB_PREFETCH (b2, 2*CLIB_CACHE_LINE_BYTES, STORE); \
- CLIB_PREFETCH (b3, 2*CLIB_CACHE_LINE_BYTES, STORE); \
- CLIB_PREFETCH (b2->data, CLIB_CACHE_LINE_BYTES , LOAD); \
- CLIB_PREFETCH (b3->data, CLIB_CACHE_LINE_BYTES , LOAD); \
- \
- /* Dequeue a packet buffer */ \
- bi0 = from[0]; \
- bi1 = from[1]; \
- from += 2; \
- n_left_from -= 2; \
- to_next[0] = bi0; \
- to_next[1] = bi1; \
- to_next += 2; \
- n_left_to_next -= 2; \
- \
- b0 = vlib_get_buffer (vm, bi0); \
- b1 = vlib_get_buffer (vm, bi1); \
- hicnb0 = hicn_get_buffer(b0); \
- hicnb1 = hicn_get_buffer(b1); \
- ip_hdr0 = (IP_HEADER_##ipv *) vlib_buffer_get_current(b0); \
- ip_hdr1 = (IP_HEADER_##ipv *) vlib_buffer_get_current(b1); \
- \
- stats.pkts_interest_count += 2; \
- \
- u8 is_icmp0 = ip_hdr0->protocol == IPPROTO_ICMPV##ipv; \
- u8 is_icmp1 = ip_hdr1->protocol == IPPROTO_ICMPV##ipv; \
- \
- next0 = is_icmp0*NEXT_MAPME_IP##ipv + \
- (1-is_icmp0)*NEXT_INTEREST_IP##ipv; \
- \
- next1 = is_icmp1*NEXT_MAPME_IP##ipv + \
- (1-is_icmp1)*NEXT_INTEREST_IP##ipv; \
- \
- next_iface0 = NEXT_DATA_LOOKUP_IP##ipv; \
- \
- if (hicnb0->flags & HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL) \
- next_iface0 = NEXT_UDP_ENCAP_IP4; \
- else if(hicnb0->flags & HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL) \
- next_iface0 = NEXT_UDP_ENCAP_IP6; \
- \
- next_iface1 = NEXT_DATA_LOOKUP_IP##ipv; \
- \
- if (hicnb1->flags & HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL) \
- next_iface1 = NEXT_UDP_ENCAP_IP4; \
- else if(hicnb1->flags & HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL) \
- next_iface1 = NEXT_UDP_ENCAP_IP6; \
- \
- DPO_ADD_LOCK_IFACE_IP##ipv \
- (&(hicnb0->face_id), \
- &hicnb0->flags, \
- &(ip_hdr0->src_address), \
- vnet_buffer(b0)->sw_if_index[VLIB_RX], \
- vnet_buffer(b0)->ip.adj_index[VLIB_RX], \
- next_iface0); \
- \
- DPO_ADD_LOCK_IFACE_IP##ipv \
- (&(hicnb1->face_id), \
- &hicnb1->flags, \
- &(ip_hdr1->src_address), \
- vnet_buffer(b1)->sw_if_index[VLIB_RX], \
- vnet_buffer(b1)->ip.adj_index[VLIB_RX], \
- next_iface1); \
- \
- if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
- (b0->flags & VLIB_BUFFER_IS_TRACED))) \
- { \
- TRACE_INPUT_PKT_IP##ipv *t = \
- vlib_add_trace (vm, node, b0, sizeof (*t)); \
- t->pkt_type = HICN_PKT_TYPE_INTEREST; \
- t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
- t->next_index = next0; \
- clib_memcpy_fast (t->packet_data, \
- vlib_buffer_get_current (b0), \
- sizeof (t->packet_data)); \
- } \
- \
- if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
- (b1->flags & VLIB_BUFFER_IS_TRACED))) \
- { \
- TRACE_INPUT_PKT_IP##ipv *t = \
- vlib_add_trace (vm, node, b1, sizeof (*t)); \
- t->pkt_type = HICN_PKT_TYPE_INTEREST; \
- t->sw_if_index = vnet_buffer (b1)->sw_if_index[VLIB_RX]; \
- t->next_index = next1; \
- clib_memcpy_fast (t->packet_data, \
- vlib_buffer_get_current (b1), \
- sizeof (t->packet_data)); \
- } \
- \
- vlib_increment_combined_counter ( \
- &counters[hicnb0->face_id \
- * HICN_N_COUNTER], thread_index, \
- HICN_FACE_COUNTERS_INTEREST_RX, \
- 1, \
- vlib_buffer_length_in_chain(vm, b0)); \
- \
- vlib_increment_combined_counter ( \
- &counters[hicnb1->face_id \
- * HICN_N_COUNTER], thread_index, \
- HICN_FACE_COUNTERS_INTEREST_RX, \
- 1, \
- vlib_buffer_length_in_chain(vm, b1)); \
- \
- /* Verify speculative enqueue, maybe switch current next frame */ \
- vlib_validate_buffer_enqueue_x2 (vm, node, next_index, \
- to_next, n_left_to_next, \
- bi0, bi1, next0, next1); \
- }while(0)
+#define iface_input_x1(ipv) \
+ do \
+ { \
+ vlib_buffer_t *b0; \
+ u32 bi0, next0, next_iface0; \
+ IP_HEADER_##ipv *ip_hdr = NULL; \
+ hicn_buffer_t *hicnb0; \
+ /* Prefetch for next iteration. */ \
+ if (n_left_from > 1) \
+ { \
+ vlib_buffer_t *b1; \
+ b1 = vlib_get_buffer (vm, from[1]); \
+ CLIB_PREFETCH (b1, 2 * CLIB_CACHE_LINE_BYTES, STORE); \
+ CLIB_PREFETCH (b1->data, CLIB_CACHE_LINE_BYTES, LOAD); \
+ } \
+ /* Dequeue a packet buffer */ \
+ bi0 = from[0]; \
+ from += 1; \
+ n_left_from -= 1; \
+ to_next[0] = bi0; \
+ to_next += 1; \
+ n_left_to_next -= 1; \
+ \
+ b0 = vlib_get_buffer (vm, bi0); \
+ hicnb0 = hicn_get_buffer (b0); \
+ ip_hdr = (IP_HEADER_##ipv *) vlib_buffer_get_current (b0); \
+ \
+ stats.pkts_interest_count += 1; \
+ \
+ u8 is_icmp = ip_hdr->protocol == IPPROTO_ICMPV##ipv; \
+ \
+ next0 = \
+ is_icmp * NEXT_MAPME_IP##ipv + (1 - is_icmp) * NEXT_INTEREST_IP##ipv; \
+ \
+ next_iface0 = NEXT_DATA_LOOKUP_IP##ipv; \
+ \
+ if (hicnb0->flags & HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL) \
+ next_iface0 = NEXT_UDP_ENCAP_IP4; \
+ else if (hicnb0->flags & HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL) \
+ next_iface0 = NEXT_UDP_ENCAP_IP6; \
+ \
+ DPO_ADD_LOCK_IFACE_IP##ipv ( \
+ &(hicnb0->face_id), &hicnb0->flags, &(ip_hdr->src_address), \
+ vnet_buffer (b0)->sw_if_index[VLIB_RX], \
+ vnet_buffer (b0)->ip.adj_index[VLIB_RX], next_iface0); \
+ \
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
+ (b0->flags & VLIB_BUFFER_IS_TRACED))) \
+ { \
+ TRACE_INPUT_PKT_IP##ipv *t = \
+ vlib_add_trace (vm, node, b0, sizeof (*t)); \
+ t->pkt_type = HICN_PKT_TYPE_INTEREST; \
+ t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
+ t->next_index = next0; \
+ clib_memcpy_fast (t->packet_data, vlib_buffer_get_current (b0), \
+ sizeof (t->packet_data)); \
+ } \
+ \
+ vlib_increment_combined_counter ( \
+ &counters[hicnb0->face_id * HICN_N_COUNTER], thread_index, \
+ HICN_FACE_COUNTERS_INTEREST_RX, 1, \
+ vlib_buffer_length_in_chain (vm, b0)); \
+ \
+ /* Verify speculative enqueue, maybe switch current next frame */ \
+ vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next, \
+ n_left_to_next, bi0, next0); \
+ } \
+ while (0)
+
+#define iface_input_x2(ipv) \
+ do \
+ { \
+ vlib_buffer_t *b0, *b1; \
+ u32 bi0, bi1, next0, next1, next_iface0, next_iface1; \
+ IP_HEADER_##ipv *ip_hdr0 = NULL; \
+ IP_HEADER_##ipv *ip_hdr1 = NULL; \
+ hicn_buffer_t *hicnb0, *hicnb1; \
+ \
+ /* Prefetch for next iteration. */ \
+ vlib_buffer_t *b2, *b3; \
+ b2 = vlib_get_buffer (vm, from[2]); \
+ b3 = vlib_get_buffer (vm, from[3]); \
+ CLIB_PREFETCH (b2, 2 * CLIB_CACHE_LINE_BYTES, STORE); \
+ CLIB_PREFETCH (b3, 2 * CLIB_CACHE_LINE_BYTES, STORE); \
+ CLIB_PREFETCH (b2->data, CLIB_CACHE_LINE_BYTES, LOAD); \
+ CLIB_PREFETCH (b3->data, CLIB_CACHE_LINE_BYTES, LOAD); \
+ \
+ /* Dequeue a packet buffer */ \
+ bi0 = from[0]; \
+ bi1 = from[1]; \
+ from += 2; \
+ n_left_from -= 2; \
+ to_next[0] = bi0; \
+ to_next[1] = bi1; \
+ to_next += 2; \
+ n_left_to_next -= 2; \
+ \
+ b0 = vlib_get_buffer (vm, bi0); \
+ b1 = vlib_get_buffer (vm, bi1); \
+ hicnb0 = hicn_get_buffer (b0); \
+ hicnb1 = hicn_get_buffer (b1); \
+ ip_hdr0 = (IP_HEADER_##ipv *) vlib_buffer_get_current (b0); \
+ ip_hdr1 = (IP_HEADER_##ipv *) vlib_buffer_get_current (b1); \
+ \
+ stats.pkts_interest_count += 2; \
+ \
+ u8 is_icmp0 = ip_hdr0->protocol == IPPROTO_ICMPV##ipv; \
+ u8 is_icmp1 = ip_hdr1->protocol == IPPROTO_ICMPV##ipv; \
+ \
+ next0 = is_icmp0 * NEXT_MAPME_IP##ipv + \
+ (1 - is_icmp0) * NEXT_INTEREST_IP##ipv; \
+ \
+ next1 = is_icmp1 * NEXT_MAPME_IP##ipv + \
+ (1 - is_icmp1) * NEXT_INTEREST_IP##ipv; \
+ \
+ next_iface0 = NEXT_DATA_LOOKUP_IP##ipv; \
+ \
+ if (hicnb0->flags & HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL) \
+ next_iface0 = NEXT_UDP_ENCAP_IP4; \
+ else if (hicnb0->flags & HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL) \
+ next_iface0 = NEXT_UDP_ENCAP_IP6; \
+ \
+ next_iface1 = NEXT_DATA_LOOKUP_IP##ipv; \
+ \
+ if (hicnb1->flags & HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL) \
+ next_iface1 = NEXT_UDP_ENCAP_IP4; \
+ else if (hicnb1->flags & HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL) \
+ next_iface1 = NEXT_UDP_ENCAP_IP6; \
+ \
+ DPO_ADD_LOCK_IFACE_IP##ipv ( \
+ &(hicnb0->face_id), &hicnb0->flags, &(ip_hdr0->src_address), \
+ vnet_buffer (b0)->sw_if_index[VLIB_RX], \
+ vnet_buffer (b0)->ip.adj_index[VLIB_RX], next_iface0); \
+ \
+ DPO_ADD_LOCK_IFACE_IP##ipv ( \
+ &(hicnb1->face_id), &hicnb1->flags, &(ip_hdr1->src_address), \
+ vnet_buffer (b1)->sw_if_index[VLIB_RX], \
+ vnet_buffer (b1)->ip.adj_index[VLIB_RX], next_iface1); \
+ \
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
+ (b0->flags & VLIB_BUFFER_IS_TRACED))) \
+ { \
+ TRACE_INPUT_PKT_IP##ipv *t = \
+ vlib_add_trace (vm, node, b0, sizeof (*t)); \
+ t->pkt_type = HICN_PKT_TYPE_INTEREST; \
+ t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
+ t->next_index = next0; \
+ clib_memcpy_fast (t->packet_data, vlib_buffer_get_current (b0), \
+ sizeof (t->packet_data)); \
+ } \
+ \
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
+ (b1->flags & VLIB_BUFFER_IS_TRACED))) \
+ { \
+ TRACE_INPUT_PKT_IP##ipv *t = \
+ vlib_add_trace (vm, node, b1, sizeof (*t)); \
+ t->pkt_type = HICN_PKT_TYPE_INTEREST; \
+ t->sw_if_index = vnet_buffer (b1)->sw_if_index[VLIB_RX]; \
+ t->next_index = next1; \
+ clib_memcpy_fast (t->packet_data, vlib_buffer_get_current (b1), \
+ sizeof (t->packet_data)); \
+ } \
+ \
+ vlib_increment_combined_counter ( \
+ &counters[hicnb0->face_id * HICN_N_COUNTER], thread_index, \
+ HICN_FACE_COUNTERS_INTEREST_RX, 1, \
+ vlib_buffer_length_in_chain (vm, b0)); \
+ \
+ vlib_increment_combined_counter ( \
+ &counters[hicnb1->face_id * HICN_N_COUNTER], thread_index, \
+ HICN_FACE_COUNTERS_INTEREST_RX, 1, \
+ vlib_buffer_length_in_chain (vm, b1)); \
+ \
+ /* Verify speculative enqueue, maybe switch current next frame */ \
+ vlib_validate_buffer_enqueue_x2 (vm, node, next_index, to_next, \
+ n_left_to_next, bi0, bi1, next0, \
+ next1); \
+ } \
+ while (0)
static uword
-hicn4_iface_input_node_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+hicn4_iface_input_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
+ vlib_frame_t *frame)
{
u32 n_left_from, *from, *to_next, next_index;
@@ -403,8 +395,7 @@ hicn4_iface_input_node_fn (vlib_main_t * vm,
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}
- vlib_node_increment_counter (vm, node->node_index,
- HICNFWD_ERROR_INTERESTS,
+ vlib_node_increment_counter (vm, node->node_index, HICNFWD_ERROR_INTERESTS,
stats.pkts_interest_count);
return (frame->n_vectors);
@@ -412,24 +403,21 @@ hicn4_iface_input_node_fn (vlib_main_t * vm,
/* packet trace format function */
static u8 *
-hicn4_iface_input_format_trace (u8 * s, va_list * args)
+hicn4_iface_input_format_trace (u8 *s, va_list *args)
{
CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
- hicn4_iface_input_trace_t *t =
- va_arg (*args, hicn4_iface_input_trace_t *);
+ hicn4_iface_input_trace_t *t = va_arg (*args, hicn4_iface_input_trace_t *);
- s =
- format (s, "IFACE_IP4_INPUT: pkt: %d, sw_if_index %d, next index %d\n%U",
- (int) t->pkt_type, t->sw_if_index, t->next_index,
- format_ip4_header, t->packet_data, sizeof (t->packet_data));
+ s = format (s, "IFACE_IP4_INPUT: pkt: %d, sw_if_index %d, next index %d\n%U",
+ (int) t->pkt_type, t->sw_if_index, t->next_index,
+ format_ip4_header, t->packet_data, sizeof (t->packet_data));
return (s);
}
/*
* Node registration for the interest forwarder node
*/
-/* *INDENT-OFF* */
VLIB_REGISTER_NODE (hicn4_iface_input_node) =
{
.function = hicn4_iface_input_node_fn,
@@ -448,12 +436,10 @@ VLIB_REGISTER_NODE (hicn4_iface_input_node) =
[HICN4_IFACE_INPUT_NEXT_ERROR_DROP] = "error-drop",
},
};
-/* *INDENT-ON* */
static uword
-hicn6_iface_input_node_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+hicn6_iface_input_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
+ vlib_frame_t *frame)
{
u32 n_left_from, *from, *to_next, next_index;
@@ -483,8 +469,7 @@ hicn6_iface_input_node_fn (vlib_main_t * vm,
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}
- vlib_node_increment_counter (vm, node->node_index,
- HICNFWD_ERROR_INTERESTS,
+ vlib_node_increment_counter (vm, node->node_index, HICNFWD_ERROR_INTERESTS,
stats.pkts_interest_count);
return (frame->n_vectors);
@@ -492,24 +477,21 @@ hicn6_iface_input_node_fn (vlib_main_t * vm,
/* packet trace format function */
static u8 *
-hicn6_iface_input_format_trace (u8 * s, va_list * args)
+hicn6_iface_input_format_trace (u8 *s, va_list *args)
{
CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
- hicn6_iface_input_trace_t *t =
- va_arg (*args, hicn6_iface_input_trace_t *);
+ hicn6_iface_input_trace_t *t = va_arg (*args, hicn6_iface_input_trace_t *);
- s =
- format (s, "IFACE_IP6_INPUT: pkt: %d, sw_if_index %d, next index %d\n%U",
- (int) t->pkt_type, t->sw_if_index, t->next_index,
- format_ip6_header, t->packet_data, sizeof (t->packet_data));
+ s = format (s, "IFACE_IP6_INPUT: pkt: %d, sw_if_index %d, next index %d\n%U",
+ (int) t->pkt_type, t->sw_if_index, t->next_index,
+ format_ip6_header, t->packet_data, sizeof (t->packet_data));
return (s);
}
/*
* Node registration for the interest forwarder node
*/
-/* *INDENT-OFF* */
VLIB_REGISTER_NODE (hicn6_iface_input_node) =
{
.function = hicn6_iface_input_node_fn,
@@ -528,14 +510,12 @@ VLIB_REGISTER_NODE (hicn6_iface_input_node) =
[HICN6_IFACE_INPUT_NEXT_ERROR_DROP] = "error-drop",
},
};
-/* *INDENT-ON* */
-
/**** IFACE OUTPUT *****/
static inline void
-hicn_rewrite_iface_data4 (vlib_main_t * vm, vlib_buffer_t * b0,
- const hicn_face_t * iface, u32 * next)
+hicn_rewrite_iface_data4 (vlib_main_t *vm, vlib_buffer_t *b0,
+ const hicn_face_t *iface, u32 *next)
{
ip4_header_t *ip0;
@@ -546,7 +526,7 @@ hicn_rewrite_iface_data4 (vlib_main_t * vm, vlib_buffer_t * b0,
/* IP4 lenght contains the size of the ip4 header too */
u16 sval = (vlib_buffer_length_in_chain (vm, b0));
ip0->length = clib_host_to_net_u16 (sval);
- ip0->ttl = 254; // FIXME TTL
+ ip0->ttl = 254; // FIXME TTL
vnet_buffer (b0)->ip.adj_index[VLIB_TX] = iface->dpo.dpoi_index;
*next = iface->dpo.dpoi_next_node;
@@ -555,18 +535,17 @@ hicn_rewrite_iface_data4 (vlib_main_t * vm, vlib_buffer_t * b0,
ip46_address_t temp_addr;
ip46_address_reset (&temp_addr);
hicn_type_t type = hicn_get_buffer (b0)->type;
- int ret = hicn_ops_vft[type.l1]->rewrite_data (type, &hicn->protocol,
- &(iface->nat_addr), &(temp_addr),
- iface->pl_id);
+ int ret = hicn_ops_vft[type.l1]->rewrite_data (
+ type, &hicn->protocol, &(iface->nat_addr), &(temp_addr), iface->pl_id);
if (ret == HICN_LIB_ERROR_REWRITE_CKSUM_REQUIRED)
{
- ensure_offload_flags(b0, 1 /* is_v4 */);
+ ensure_offload_flags (b0, 1 /* is_v4 */);
}
}
static inline void
-hicn_rewrite_iface_data6 (vlib_main_t * vm, vlib_buffer_t * b0,
- const hicn_face_t * iface, u32 * next)
+hicn_rewrite_iface_data6 (vlib_main_t *vm, vlib_buffer_t *b0,
+ const hicn_face_t *iface, u32 *next)
{
ip6_header_t *ip0;
@@ -588,183 +567,164 @@ hicn_rewrite_iface_data6 (vlib_main_t * vm, vlib_buffer_t * b0,
ip46_address_t temp_addr;
ip46_address_reset (&temp_addr);
hicn_type_t type = hicn_get_buffer (b0)->type;
- int ret = hicn_ops_vft[type.l1]->rewrite_data (type, &hicn->protocol,
- &(iface->nat_addr), &(temp_addr),
- iface->pl_id);
+ int ret = hicn_ops_vft[type.l1]->rewrite_data (
+ type, &hicn->protocol, &(iface->nat_addr), &(temp_addr), iface->pl_id);
if (ret == HICN_LIB_ERROR_REWRITE_CKSUM_REQUIRED)
{
- ensure_offload_flags(b0, 0 /* is_v4 */);
+ ensure_offload_flags (b0, 0 /* is_v4 */);
}
}
-#define iface_output_x1(ipv) \
- do { \
- vlib_buffer_t *b0; \
- u32 bi0; \
- u32 next0 = next_index; \
- hicn_face_t * face; \
- \
- /* Prefetch for next iteration. */ \
- if (n_left_from > 1) \
- { \
- vlib_buffer_t *b1; \
- b1 = vlib_get_buffer (vm, from[1]); \
- CLIB_PREFETCH (b1, CLIB_CACHE_LINE_BYTES, STORE); \
- CLIB_PREFETCH (b1->data, CLIB_CACHE_LINE_BYTES , STORE); \
- } \
- /* Dequeue a packet buffer */ \
- bi0 = from[0]; \
- from += 1; \
- n_left_from -= 1; \
- to_next[0] = bi0; \
- to_next += 1; \
- n_left_to_next -= 1; \
- \
- b0 = vlib_get_buffer (vm, bi0); \
- \
- hicn_face_id_t face_id = vnet_buffer (b0)->ip.adj_index[VLIB_TX]; \
- face = \
- hicn_dpoi_get_from_idx (face_id); \
- \
- if (PREDICT_TRUE(face != NULL)) \
- { \
- HICN_REWRITE_DATA_IP##ipv \
- (vm, b0, face, &next0); \
- stats.pkts_data_count += 1; \
- vlib_increment_combined_counter ( \
- &counters[face_id * HICN_N_COUNTER], \
- thread_index, \
- HICN_FACE_COUNTERS_DATA_TX, \
- 1, \
- vlib_buffer_length_in_chain(vm, b0));\
- } \
- \
- if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
- (b0->flags & VLIB_BUFFER_IS_TRACED))) \
- { \
- TRACE_OUTPUT_PKT_IP##ipv *t = \
- vlib_add_trace (vm, node, b0, sizeof (*t)); \
- t->pkt_type = HICN_PKT_TYPE_INTEREST; \
- t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
- t->next_index = next0; \
- clib_memcpy_fast (t->packet_data, \
- vlib_buffer_get_current (b0), \
- sizeof (t->packet_data)); \
- } \
- \
- \
- /* Verify speculative enqueue, maybe switch current next frame */ \
- vlib_validate_buffer_enqueue_x1 (vm, node, next_index, \
- to_next, n_left_to_next, \
- bi0, next0); \
- }while(0); \
-
-
-#define iface_output_x2(ipv) \
- do { \
- vlib_buffer_t *b0, *b1; \
- u32 bi0, bi1; \
- u32 next0 = next_index; \
- u32 next1 = next_index; \
- hicn_face_t *face0, *face1; \
- \
- /* Prefetch for next iteration. */ \
- { \
- vlib_buffer_t *b2, *b3; \
- b2 = vlib_get_buffer (vm, from[2]); \
- b3 = vlib_get_buffer (vm, from[3]); \
- CLIB_PREFETCH (b2, CLIB_CACHE_LINE_BYTES, STORE); \
- CLIB_PREFETCH (b3, CLIB_CACHE_LINE_BYTES, STORE); \
- CLIB_PREFETCH (b2->data, CLIB_CACHE_LINE_BYTES , STORE); \
- CLIB_PREFETCH (b3->data, CLIB_CACHE_LINE_BYTES , STORE); \
- } \
- \
- /* Dequeue a packet buffer */ \
- bi0 = from[0]; \
- bi1 = from[1]; \
- from += 2; \
- n_left_from -= 2; \
- to_next[0] = bi0; \
- to_next[1] = bi1; \
- to_next += 2; \
- n_left_to_next -= 2; \
- \
- b0 = vlib_get_buffer (vm, bi0); \
- b1 = vlib_get_buffer (vm, bi1); \
- \
- hicn_face_id_t face_id0 = vnet_buffer (b0)->ip.adj_index[VLIB_TX]; \
- hicn_face_id_t face_id1 = vnet_buffer (b1)->ip.adj_index[VLIB_TX]; \
- face0 = \
- hicn_dpoi_get_from_idx (face_id0); \
- face1 = \
- hicn_dpoi_get_from_idx (face_id1); \
- \
- if (PREDICT_TRUE(face0 != NULL)) \
- { \
- HICN_REWRITE_DATA_IP##ipv \
- (vm, b0, face0, &next0); \
- stats.pkts_data_count += 1; \
- vlib_increment_combined_counter ( \
- &counters[face_id0 * HICN_N_COUNTER], \
- thread_index, \
- HICN_FACE_COUNTERS_DATA_TX, \
- 1, \
- vlib_buffer_length_in_chain(vm, b0));\
- } \
- \
- if (PREDICT_TRUE(face1 != NULL)) \
- { \
- HICN_REWRITE_DATA_IP##ipv \
- (vm, b1, face1, &next1); \
- stats.pkts_data_count += 1; \
- vlib_increment_combined_counter ( \
- &counters[face_id1 * HICN_N_COUNTER], \
- thread_index, \
- HICN_FACE_COUNTERS_DATA_TX, \
- 1, \
- vlib_buffer_length_in_chain(vm, b1)); \
- } \
- \
- if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
- (b0->flags & VLIB_BUFFER_IS_TRACED))) \
- { \
- TRACE_OUTPUT_PKT_IP##ipv *t = \
- vlib_add_trace (vm, node, b0, sizeof (*t)); \
- t->pkt_type = HICN_PKT_TYPE_INTEREST; \
- t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
- t->next_index = next0; \
- clib_memcpy_fast (t->packet_data, \
- vlib_buffer_get_current (b0), \
- sizeof (t->packet_data)); \
- } \
- \
- if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
- (b1->flags & VLIB_BUFFER_IS_TRACED))) \
- { \
- TRACE_OUTPUT_PKT_IP##ipv *t = \
- vlib_add_trace (vm, node, b1, sizeof (*t)); \
- t->pkt_type = HICN_PKT_TYPE_INTEREST; \
- t->sw_if_index = vnet_buffer (b1)->sw_if_index[VLIB_RX]; \
- t->next_index = next1; \
- clib_memcpy_fast (t->packet_data, \
- vlib_buffer_get_current (b1), \
- sizeof (t->packet_data)); \
- } \
- \
- \
- /* Verify speculative enqueue, maybe switch current next frame */ \
- vlib_validate_buffer_enqueue_x2 (vm, node, next_index, \
- to_next, n_left_to_next, \
- bi0, bi1, next0, next1); \
- }while(0); \
-
-
+#define iface_output_x1(ipv) \
+ do \
+ { \
+ vlib_buffer_t *b0; \
+ u32 bi0; \
+ u32 next0 = next_index; \
+ hicn_face_t *face; \
+ \
+ /* Prefetch for next iteration. */ \
+ if (n_left_from > 1) \
+ { \
+ vlib_buffer_t *b1; \
+ b1 = vlib_get_buffer (vm, from[1]); \
+ CLIB_PREFETCH (b1, CLIB_CACHE_LINE_BYTES, STORE); \
+ CLIB_PREFETCH (b1->data, CLIB_CACHE_LINE_BYTES, STORE); \
+ } \
+ /* Dequeue a packet buffer */ \
+ bi0 = from[0]; \
+ from += 1; \
+ n_left_from -= 1; \
+ to_next[0] = bi0; \
+ to_next += 1; \
+ n_left_to_next -= 1; \
+ \
+ b0 = vlib_get_buffer (vm, bi0); \
+ \
+ hicn_face_id_t face_id = vnet_buffer (b0)->ip.adj_index[VLIB_TX]; \
+ face = hicn_dpoi_get_from_idx (face_id); \
+ \
+ if (PREDICT_TRUE (face != NULL)) \
+ { \
+ HICN_REWRITE_DATA_IP##ipv (vm, b0, face, &next0); \
+ stats.pkts_data_count += 1; \
+ vlib_increment_combined_counter ( \
+ &counters[face_id * HICN_N_COUNTER], thread_index, \
+ HICN_FACE_COUNTERS_DATA_TX, 1, \
+ vlib_buffer_length_in_chain (vm, b0)); \
+ } \
+ \
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
+ (b0->flags & VLIB_BUFFER_IS_TRACED))) \
+ { \
+ TRACE_OUTPUT_PKT_IP##ipv *t = \
+ vlib_add_trace (vm, node, b0, sizeof (*t)); \
+ t->pkt_type = HICN_PKT_TYPE_INTEREST; \
+ t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
+ t->next_index = next0; \
+ clib_memcpy_fast (t->packet_data, vlib_buffer_get_current (b0), \
+ sizeof (t->packet_data)); \
+ } \
+ \
+ /* Verify speculative enqueue, maybe switch current next frame */ \
+ vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next, \
+ n_left_to_next, bi0, next0); \
+ } \
+ while (0);
+
+#define iface_output_x2(ipv) \
+ do \
+ { \
+ vlib_buffer_t *b0, *b1; \
+ u32 bi0, bi1; \
+ u32 next0 = next_index; \
+ u32 next1 = next_index; \
+ hicn_face_t *face0, *face1; \
+ \
+ /* Prefetch for next iteration. */ \
+ { \
+ vlib_buffer_t *b2, *b3; \
+ b2 = vlib_get_buffer (vm, from[2]); \
+ b3 = vlib_get_buffer (vm, from[3]); \
+ CLIB_PREFETCH (b2, CLIB_CACHE_LINE_BYTES, STORE); \
+ CLIB_PREFETCH (b3, CLIB_CACHE_LINE_BYTES, STORE); \
+ CLIB_PREFETCH (b2->data, CLIB_CACHE_LINE_BYTES, STORE); \
+ CLIB_PREFETCH (b3->data, CLIB_CACHE_LINE_BYTES, STORE); \
+ } \
+ \
+ /* Dequeue a packet buffer */ \
+ bi0 = from[0]; \
+ bi1 = from[1]; \
+ from += 2; \
+ n_left_from -= 2; \
+ to_next[0] = bi0; \
+ to_next[1] = bi1; \
+ to_next += 2; \
+ n_left_to_next -= 2; \
+ \
+ b0 = vlib_get_buffer (vm, bi0); \
+ b1 = vlib_get_buffer (vm, bi1); \
+ \
+ hicn_face_id_t face_id0 = vnet_buffer (b0)->ip.adj_index[VLIB_TX]; \
+ hicn_face_id_t face_id1 = vnet_buffer (b1)->ip.adj_index[VLIB_TX]; \
+ face0 = hicn_dpoi_get_from_idx (face_id0); \
+ face1 = hicn_dpoi_get_from_idx (face_id1); \
+ \
+ if (PREDICT_TRUE (face0 != NULL)) \
+ { \
+ HICN_REWRITE_DATA_IP##ipv (vm, b0, face0, &next0); \
+ stats.pkts_data_count += 1; \
+ vlib_increment_combined_counter ( \
+ &counters[face_id0 * HICN_N_COUNTER], thread_index, \
+ HICN_FACE_COUNTERS_DATA_TX, 1, \
+ vlib_buffer_length_in_chain (vm, b0)); \
+ } \
+ \
+ if (PREDICT_TRUE (face1 != NULL)) \
+ { \
+ HICN_REWRITE_DATA_IP##ipv (vm, b1, face1, &next1); \
+ stats.pkts_data_count += 1; \
+ vlib_increment_combined_counter ( \
+ &counters[face_id1 * HICN_N_COUNTER], thread_index, \
+ HICN_FACE_COUNTERS_DATA_TX, 1, \
+ vlib_buffer_length_in_chain (vm, b1)); \
+ } \
+ \
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
+ (b0->flags & VLIB_BUFFER_IS_TRACED))) \
+ { \
+ TRACE_OUTPUT_PKT_IP##ipv *t = \
+ vlib_add_trace (vm, node, b0, sizeof (*t)); \
+ t->pkt_type = HICN_PKT_TYPE_INTEREST; \
+ t->sw_if_index = vnet_buffer (b0)->sw_if_index[VLIB_RX]; \
+ t->next_index = next0; \
+ clib_memcpy_fast (t->packet_data, vlib_buffer_get_current (b0), \
+ sizeof (t->packet_data)); \
+ } \
+ \
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) && \
+ (b1->flags & VLIB_BUFFER_IS_TRACED))) \
+ { \
+ TRACE_OUTPUT_PKT_IP##ipv *t = \
+ vlib_add_trace (vm, node, b1, sizeof (*t)); \
+ t->pkt_type = HICN_PKT_TYPE_INTEREST; \
+ t->sw_if_index = vnet_buffer (b1)->sw_if_index[VLIB_RX]; \
+ t->next_index = next1; \
+ clib_memcpy_fast (t->packet_data, vlib_buffer_get_current (b1), \
+ sizeof (t->packet_data)); \
+ } \
+ \
+ /* Verify speculative enqueue, maybe switch current next frame */ \
+ vlib_validate_buffer_enqueue_x2 (vm, node, next_index, to_next, \
+ n_left_to_next, bi0, bi1, next0, \
+ next1); \
+ } \
+ while (0);
static uword
-hicn4_iface_output_node_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+hicn4_iface_output_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
+ vlib_frame_t *frame)
{
u32 n_left_from, *from, *to_next, next_index;
vl_api_hicn_api_node_stats_get_reply_t stats = { 0 };
@@ -792,20 +752,19 @@ hicn4_iface_output_node_fn (vlib_main_t * vm,
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}
- vlib_node_increment_counter (vm, node->node_index,
- HICNFWD_ERROR_DATAS, stats.pkts_data_count);
+ vlib_node_increment_counter (vm, node->node_index, HICNFWD_ERROR_DATAS,
+ stats.pkts_data_count);
return (frame->n_vectors);
}
/* packet trace format function */
static u8 *
-hicn4_iface_output_format_trace (u8 * s, va_list * args)
+hicn4_iface_output_format_trace (u8 *s, va_list *args)
{
CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
- hicn4_iface_output_trace_t *t =
- va_arg (*args, hicn4_iface_output_trace_t *);
+ hicn4_iface_output_trace_t *t = va_arg (*args, hicn4_iface_output_trace_t *);
s =
format (s, "IFACE_IP4_OUTPUT: pkt: %d, sw_if_index %d, next index %d\n%U",
@@ -817,32 +776,24 @@ hicn4_iface_output_format_trace (u8 * s, va_list * args)
/*
* Node registration for the interest forwarder node
*/
-/* *INDENT-OFF* */
-VLIB_REGISTER_NODE (hicn4_iface_output_node) =
-{
+VLIB_REGISTER_NODE (hicn4_iface_output_node) = {
.function = hicn4_iface_output_node_fn,
.name = "hicn4-iface-output",
- .vector_size = sizeof (u32),
+ .vector_size = sizeof (u32),
.format_trace = hicn4_iface_output_format_trace,
.type = VLIB_NODE_TYPE_INTERNAL,
.n_errors = ARRAY_LEN (hicn4_iface_output_error_strings),
.error_strings = hicn4_iface_output_error_strings,
.n_next_nodes = HICN4_IFACE_OUTPUT_N_NEXT,
/* edit / add dispositions here */
- .next_nodes =
- {
- [HICN4_IFACE_OUTPUT_NEXT_LOOKUP] = "ip4-lookup",
- [HICN4_IFACE_OUTPUT_NEXT_UDP4_ENCAP] = "udp4-encap",
- [HICN4_IFACE_OUTPUT_NEXT_UDP6_ENCAP] = "udp6-encap"
- },
+ .next_nodes = { [HICN4_IFACE_OUTPUT_NEXT_LOOKUP] = "ip4-lookup",
+ [HICN4_IFACE_OUTPUT_NEXT_UDP4_ENCAP] = "udp4-encap",
+ [HICN4_IFACE_OUTPUT_NEXT_UDP6_ENCAP] = "udp6-encap" },
};
-/* *INDENT-ON* */
-
static uword
-hicn6_iface_output_node_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+hicn6_iface_output_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
+ vlib_frame_t *frame)
{
u32 n_left_from, *from, *to_next, next_index;
vl_api_hicn_api_node_stats_get_reply_t stats = { 0 };
@@ -869,20 +820,19 @@ hicn6_iface_output_node_fn (vlib_main_t * vm,
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}
- vlib_node_increment_counter (vm, node->node_index,
- HICNFWD_ERROR_DATAS, stats.pkts_data_count);
+ vlib_node_increment_counter (vm, node->node_index, HICNFWD_ERROR_DATAS,
+ stats.pkts_data_count);
return (frame->n_vectors);
}
/* packet trace format function */
static u8 *
-hicn6_iface_output_format_trace (u8 * s, va_list * args)
+hicn6_iface_output_format_trace (u8 *s, va_list *args)
{
CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
- hicn6_iface_output_trace_t *t =
- va_arg (*args, hicn6_iface_output_trace_t *);
+ hicn6_iface_output_trace_t *t = va_arg (*args, hicn6_iface_output_trace_t *);
s =
format (s, "IFACE_IP6_OUTPUT: pkt: %d, sw_if_index %d, next index %d\n%U",
@@ -894,27 +844,22 @@ hicn6_iface_output_format_trace (u8 * s, va_list * args)
/*
* Node registration for the interest forwarder node
*/
-/* *INDENT-OFF* */
-VLIB_REGISTER_NODE (hicn6_iface_output_node) =
-{
+VLIB_REGISTER_NODE (hicn6_iface_output_node) = {
.function = hicn6_iface_output_node_fn,
.name = "hicn6-iface-output",
- .vector_size = sizeof (u32),
+ .vector_size = sizeof (u32),
.format_trace = hicn6_iface_output_format_trace,
.type = VLIB_NODE_TYPE_INTERNAL,
.n_errors = ARRAY_LEN (hicn6_iface_output_error_strings),
.error_strings = hicn6_iface_output_error_strings,
.n_next_nodes = HICN6_IFACE_OUTPUT_N_NEXT,
/* edit / add dispositions here */
- .next_nodes =
- {
- [HICN6_IFACE_OUTPUT_NEXT_LOOKUP] = "ip6-lookup",
- [HICN6_IFACE_OUTPUT_NEXT_UDP4_ENCAP] = "udp4-encap",
- [HICN6_IFACE_OUTPUT_NEXT_UDP6_ENCAP] = "udp6-encap"
+ .next_nodes = { [HICN6_IFACE_OUTPUT_NEXT_LOOKUP] = "ip6-lookup",
+ [HICN6_IFACE_OUTPUT_NEXT_UDP4_ENCAP] = "udp4-encap",
+ [HICN6_IFACE_OUTPUT_NEXT_UDP6_ENCAP] = "udp6-encap"
},
};
-/* *INDENT-ON* */
/*
* fd.io coding-style-patch-verification: ON
diff --git a/hicn-plugin/src/hicn.c b/hicn-plugin/src/hicn.c
index 43a717f80..f66514dbf 100644
--- a/hicn-plugin/src/hicn.c
+++ b/hicn-plugin/src/hicn.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2020 Cisco and/or its affiliates.
+ * Copyright (c) 2017-2021 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -37,8 +37,8 @@ int hicn_infra_fwdr_initialized = 0;
* Global time counters we're trying out for opportunistic hashtable
* expiration.
*/
-uint16_t hicn_infra_fast_timer; /* Counts at 1 second intervals */
-uint16_t hicn_infra_slow_timer; /* Counts at 1 minute intervals */
+uint16_t hicn_infra_fast_timer; /* Counts at 1 second intervals */
+uint16_t hicn_infra_slow_timer; /* Counts at 1 minute intervals */
hicn_face_bucket_t *hicn_face_bucket_pool;
@@ -78,11 +78,9 @@ done:
* only 'enabling' now
*/
int
-hicn_infra_plugin_enable_disable (int enable_disable,
- int pit_size_req,
+hicn_infra_plugin_enable_disable (int enable_disable, int pit_size_req,
f64 pit_max_lifetime_sec_req,
- int cs_size_req,
- vnet_link_t link)
+ int cs_size_req, vnet_link_t link)
{
int ret = 0;
@@ -148,18 +146,19 @@ hicn_infra_plugin_enable_disable (int enable_disable,
vec_foreach (bp, bm->buffer_pools)
n_buffers = n_buffers < bp->n_buffers ? bp->n_buffers : n_buffers;
- // check if CS is bugger tha PIT or bigger than the available vlib_buffers
- uword cs_buffers =
- (n_buffers >
- HICN_PARAM_CS_MIN_MBUF) ? n_buffers - HICN_PARAM_CS_MIN_MBUF : 0;
+ // check if CS is bugger tha PIT or bigger than the available
+ // vlib_buffers
+ uword cs_buffers = (n_buffers > HICN_PARAM_CS_MIN_MBUF) ?
+ n_buffers - HICN_PARAM_CS_MIN_MBUF :
+ 0;
if (cs_size_req > (pit_size_req / 2) || cs_size_req > cs_buffers)
{
cs_size_req =
((pit_size_req / 2) > cs_buffers) ? cs_buffers : pit_size_req / 2;
vlib_cli_output (vm,
- "WARNING!! CS too large. Please check size of PIT or the number of buffers available in VPP\n");
-
+ "WARNING!! CS too large. Please check size of PIT "
+ "or the number of buffers available in VPP\n");
}
cs_size = (uint32_t) cs_size_req;
}
@@ -174,7 +173,7 @@ hicn_infra_plugin_enable_disable (int enable_disable,
}
sm->is_enabled = 1;
sm->link = link;
- //hicn_face_udp_init_internal ();
+ // hicn_face_udp_init_internal ();
done:
@@ -182,7 +181,7 @@ done:
}
static clib_error_t *
-hicn_configure (vlib_main_t * vm, unformat_input_t * input)
+hicn_configure (vlib_main_t *vm, unformat_input_t *input)
{
u32 pit_size = HICN_PARAM_PIT_ENTRIES_DFLT;
u32 cs_size = HICN_PARAM_CS_ENTRIES_DFLT;
@@ -190,7 +189,6 @@ hicn_configure (vlib_main_t * vm, unformat_input_t * input)
vnet_link_t link;
-
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
if (unformat (input, "pit-size %u", &pit_size))
@@ -207,10 +205,8 @@ hicn_configure (vlib_main_t * vm, unformat_input_t * input)
unformat_free (input);
- hicn_infra_plugin_enable_disable (1, pit_size,
- pit_lifetime_max_sec,
- cs_size, link);
-
+ hicn_infra_plugin_enable_disable (1, pit_size, pit_lifetime_max_sec, cs_size,
+ link);
return 0;
}
@@ -221,7 +217,7 @@ VLIB_CONFIG_FUNCTION (hicn_configure, "hicn");
* Init entry-point for the icn plugin
*/
static clib_error_t *
-hicn_init (vlib_main_t * vm)
+hicn_init (vlib_main_t *vm)
{
clib_error_t *error = 0;
@@ -250,12 +246,7 @@ hicn_init (vlib_main_t * vm)
VLIB_INIT_FUNCTION (hicn_init);
-/* *INDENT-OFF* */
-VLIB_PLUGIN_REGISTER() =
-{
- .description = "hICN forwarder"
-};
-/* *INDENT-ON* */
+VLIB_PLUGIN_REGISTER () = { .description = "hICN forwarder" };
/*
* fd.io coding-style-patch-verification: ON
diff --git a/hicn-plugin/src/interest_pcslookup_node.c b/hicn-plugin/src/interest_pcslookup_node.c
index 6ac2aa3a0..d3f6c7bca 100644
--- a/hicn-plugin/src/interest_pcslookup_node.c
+++ b/hicn-plugin/src/interest_pcslookup_node.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Copyright (c) 2017-2021 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -24,7 +24,8 @@
#include "state.h"
/**
- * @FILE This node performs a lookup in the PIT and CS for a received interest packet.
+ * @FILE This node performs a lookup in the PIT and CS for a received interest
+ * packet.
*
* This node passes the packet to the interest-hitpit and interest-hitcs nodes
* when there is a hit in the pit or content store, respectively.
@@ -33,8 +34,7 @@
/* Functions declarations */
/* packet trace format function */
-static u8 *hicn_interest_pcslookup_format_trace (u8 * s, va_list * args);
-
+static u8 *hicn_interest_pcslookup_format_trace (u8 *s, va_list *args);
/* Stats string values */
static char *hicn_interest_pcslookup_error_strings[] = {
@@ -50,8 +50,8 @@ vlib_node_registration_t hicn_interest_pcslookup_node;
* ACL. - 1 packet at a time - ipv4/tcp ipv6/tcp
*/
static uword
-hicn_interest_pcslookup_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+hicn_interest_pcslookup_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
+ vlib_frame_t *frame)
{
u32 n_left_from, *from, *to_next;
hicn_interest_pcslookup_next_t next_index;
@@ -118,22 +118,20 @@ hicn_interest_pcslookup_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
nameptr = (u8 *) (&name);
stats.pkts_processed++;
- if (PREDICT_FALSE (ret != HICN_ERROR_NONE ||
- hicn_hashtb_fullhash (nameptr, namelen,
- &name_hash) !=
- HICN_ERROR_NONE))
+ if (PREDICT_FALSE (
+ ret != HICN_ERROR_NONE ||
+ hicn_hashtb_fullhash (nameptr, namelen, &name_hash) !=
+ HICN_ERROR_NONE))
{
next0 = HICN_INTEREST_PCSLOOKUP_NEXT_ERROR_DROP;
}
else
{
- if (hicn_hashtb_lookup_node (rt->pitcs->pcs_table, nameptr,
- namelen, name_hash,
- 0 /* is_data */ , &node_id0,
- &dpo_ctx_id0, &vft_id0, &is_cs0,
- &hash_entry_id, &bucket_id,
- &bucket_is_overflown) ==
- HICN_ERROR_NONE)
+ if (hicn_hashtb_lookup_node (
+ rt->pitcs->pcs_table, nameptr, namelen, name_hash,
+ 0 /* is_data */, &node_id0, &dpo_ctx_id0, &vft_id0,
+ &is_cs0, &hash_entry_id, &bucket_id,
+ &bucket_is_overflown) == HICN_ERROR_NONE)
{
next0 =
HICN_INTEREST_PCSLOOKUP_NEXT_INTEREST_HITPIT + is_cs0;
@@ -159,10 +157,8 @@ hicn_interest_pcslookup_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
* Verify speculative enqueue, maybe switch current
* next frame
*/
- vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
- to_next, n_left_to_next,
- bi0, next0);
-
+ vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
+ n_left_to_next, bi0, next0);
}
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}
@@ -170,7 +166,6 @@ hicn_interest_pcslookup_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
u32 pit_cs_count = hicn_pit_get_cs_count (rt->pitcs);
u32 pcs_ntw_count = hicn_pcs_get_ntw_count (rt->pitcs);
-
vlib_node_increment_counter (vm, hicn_interest_pcslookup_node.index,
HICNFWD_ERROR_PROCESSED, stats.pkts_processed);
@@ -192,7 +187,7 @@ hicn_interest_pcslookup_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
/* packet trace format function */
static u8 *
-hicn_interest_pcslookup_format_trace (u8 * s, va_list * args)
+hicn_interest_pcslookup_format_trace (u8 *s, va_list *args)
{
CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
@@ -204,11 +199,9 @@ hicn_interest_pcslookup_format_trace (u8 * s, va_list * args)
return (s);
}
-
/*
* Node registration for the interest forwarder node
*/
-/* *INDENT-OFF* */
VLIB_REGISTER_NODE(hicn_interest_pcslookup_node) =
{
.function = hicn_interest_pcslookup_node_fn,
@@ -228,7 +221,6 @@ VLIB_REGISTER_NODE(hicn_interest_pcslookup_node) =
[HICN_INTEREST_PCSLOOKUP_NEXT_ERROR_DROP] = "error-drop",
},
};
-/* *INDENT-ON* */
/*
* fd.io coding-style-patch-verification: ON
diff --git a/hicn-plugin/src/mapme_ack_node.c b/hicn-plugin/src/mapme_ack_node.c
index f26895d20..fad344b73 100644
--- a/hicn-plugin/src/mapme_ack_node.c
+++ b/hicn-plugin/src/mapme_ack_node.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2020 Cisco and/or its affiliates.
+ * Copyright (c) 2017-2021 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -30,8 +30,7 @@
extern hicn_mapme_main_t mapme_main;
/* packet trace format function */
-static u8 *hicn_mapme_ack_format_trace (u8 * s, va_list * args);
-
+static u8 *hicn_mapme_ack_format_trace (u8 *s, va_list *args);
/* Stats string values */
static char *hicn_mapme_ack_error_strings[] = {
@@ -47,7 +46,7 @@ static char *hicn_mapme_ack_error_strings[] = {
* @param face_id Ingress face id
*/
bool
-hicn_mapme_process_ack (vlib_main_t * vm, vlib_buffer_t * b,
+hicn_mapme_process_ack (vlib_main_t *vm, vlib_buffer_t *b,
hicn_face_id_t in_face)
{
seq_t fib_seq;
@@ -57,8 +56,7 @@ hicn_mapme_process_ack (vlib_main_t * vm, vlib_buffer_t * b,
int rc;
/* Parse incoming message */
- rc =
- hicn_mapme_parse_packet (vlib_buffer_get_current (b), &prefix, &params);
+ rc = hicn_mapme_parse_packet (vlib_buffer_get_current (b), &prefix, &params);
if (rc < 0)
goto ERR_PARSE;
@@ -73,14 +71,12 @@ hicn_mapme_process_ack (vlib_main_t * vm, vlib_buffer_t * b,
{
DEBUG ("Ignored ACK for non-existing FIB entry. Ignored.");
return true;
-
}
/* We are only expecting ACKs for hICN DPOs */
ASSERT (dpo_is_hicn (dpo));
- hicn_mapme_tfib_t *tfib =
- TFIB (hicn_strategy_dpo_ctx_get (dpo->dpoi_index));
+ hicn_mapme_tfib_t *tfib = TFIB (hicn_strategy_dpo_ctx_get (dpo->dpoi_index));
if (tfib == NULL)
{
@@ -106,17 +102,10 @@ hicn_mapme_process_ack (vlib_main_t * vm, vlib_buffer_t * b,
* Is the ingress face in TFIB ? if so, remove it, otherwise it might be a
* duplicate
*/
- retx_t *retx = vlib_process_signal_event_data (vm,
- hicn_mapme_eventmgr_process_node.
- index,
- HICN_MAPME_EVENT_FACE_PH_DEL,
- 1,
- sizeof (retx_t));
- *retx = (retx_t)
- {
- .prefix = prefix,
- .dpo = *dpo
- };
+ retx_t *retx = vlib_process_signal_event_data (
+ vm, hicn_mapme_eventmgr_process_node.index, HICN_MAPME_EVENT_FACE_PH_DEL,
+ 1, sizeof (retx_t));
+ *retx = (retx_t){ .prefix = prefix, .dpo = *dpo };
return true;
@@ -127,8 +116,8 @@ ERR_PARSE:
vlib_node_registration_t hicn_mapme_ack_node;
static uword
-hicn_mapme_ack_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+hicn_mapme_ack_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
+ vlib_frame_t *frame)
{
hicn_buffer_t *hb;
hicn_mapme_ack_next_t next_index;
@@ -139,12 +128,11 @@ hicn_mapme_ack_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
n_left_from = frame->n_vectors;
next_index = node->cached_next_index;
- while (n_left_from > 0) // buffers in the current frame
+ while (n_left_from > 0) // buffers in the current frame
{
u32 n_left_to_next;
vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
-
while (n_left_from > 0 && n_left_to_next > 0)
{
u32 bi0;
@@ -167,8 +155,8 @@ hicn_mapme_ack_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
/* Single loop: process 1 packet here */
sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
- if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)
- && (b0->flags & VLIB_BUFFER_IS_TRACED)))
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) &&
+ (b0->flags & VLIB_BUFFER_IS_TRACED)))
{
hicn_mapme_ack_trace_t *t =
vlib_add_trace (vm, node, b0, sizeof (*t));
@@ -178,20 +166,19 @@ hicn_mapme_ack_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
/* $$$$$ Done processing 1 packet here $$$$$ */
/* verify speculative enqueue, maybe switch current next frame */
- vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
- to_next, n_left_to_next,
- bi0, next0);
+ vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
+ n_left_to_next, bi0, next0);
}
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}
-// vlib_node_increment_counter (vm, hicn_mapme_ack_node.index,
-// HICN_MAPME_ACK_ERROR_SWAPPED, pkts_swapped);
+ // vlib_node_increment_counter (vm, hicn_mapme_ack_node.index,
+ // HICN_MAPME_ACK_ERROR_SWAPPED, pkts_swapped);
return (frame->n_vectors);
}
/* packet trace format function */
static u8 *
-hicn_mapme_ack_format_trace (u8 * s, va_list * args)
+hicn_mapme_ack_format_trace (u8 *s, va_list *args)
{
CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
@@ -202,11 +189,9 @@ hicn_mapme_ack_format_trace (u8 * s, va_list * args)
return (s);
}
-
/*
* Node registration for the MAP-Me node processing special interests
*/
-/* *INDENT-OFF* */
VLIB_REGISTER_NODE (hicn_mapme_ack_node) =
{
.function = hicn_mapme_ack_node_fn,
@@ -223,7 +208,6 @@ VLIB_REGISTER_NODE (hicn_mapme_ack_node) =
[HICN_MAPME_ACK_NEXT_ERROR_DROP] = "error-drop",
},
};
-/* *INDENT-ON* */
/*
* fd.io coding-style-patch-verification: ON
diff --git a/hicn-plugin/src/mapme_ctrl_node.c b/hicn-plugin/src/mapme_ctrl_node.c
index a0be2be1d..613958d9c 100644
--- a/hicn-plugin/src/mapme_ctrl_node.c
+++ b/hicn-plugin/src/mapme_ctrl_node.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2020 Cisco and/or its affiliates.
+ * Copyright (c) 2017-2021 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -38,8 +38,7 @@ extern hicn_mapme_main_t mapme_main;
/* Functions declarations */
/* packet trace format function */
-static u8 *hicn_mapme_ctrl_format_trace (u8 * s, va_list * args);
-
+static u8 *hicn_mapme_ctrl_format_trace (u8 *s, va_list *args);
/* Stats string values */
static char *hicn_mapme_ctrl_error_strings[] = {
@@ -57,11 +56,11 @@ static char *hicn_mapme_ctrl_error_strings[] = {
* NOTE:
* - this function answers locally to the IU interest by replying with a Ack
* (Data) packet, unless in case of outdated information, in which we can
- * consider the interest is dropped, and another IU (aka ICMP error) is sent so
- * that retransmissions stop.
+ * consider the interest is dropped, and another IU (aka ICMP error) is sent
+ * so that retransmissions stop.
*/
static_always_inline bool
-hicn_mapme_process_ctrl (vlib_main_t * vm, vlib_buffer_t * b,
+hicn_mapme_process_ctrl (vlib_main_t *vm, vlib_buffer_t *b,
hicn_face_id_t in_face_id)
{
seq_t fib_seq;
@@ -71,8 +70,7 @@ hicn_mapme_process_ctrl (vlib_main_t * vm, vlib_buffer_t * b,
int rc;
/* Parse incoming message */
- rc =
- hicn_mapme_parse_packet (vlib_buffer_get_current (b), &prefix, &params);
+ rc = hicn_mapme_parse_packet (vlib_buffer_get_current (b), &prefix, &params);
if (rc < 0)
goto ERR_PARSE;
@@ -102,10 +100,9 @@ hicn_mapme_process_ctrl (vlib_main_t * vm, vlib_buffer_t * b,
DEBUG ("Re-creating FIB entry with next hop on connection")
#error "not implemented"
#else
- //ERROR("Received IU for non-existing FIB entry");
+ // ERROR("Received IU for non-existing FIB entry");
return false;
#endif /* HICN_MAPME_ALLOW_NONEXISTING_FIB_ENTRY */
-
}
#ifdef HICN_MAPME_ALLOW_LOCATORS
@@ -118,8 +115,7 @@ hicn_mapme_process_ctrl (vlib_main_t * vm, vlib_buffer_t * b,
#endif
/* Process the hICN DPO */
- hicn_mapme_tfib_t *tfib =
- TFIB (hicn_strategy_dpo_ctx_get (dpo->dpoi_index));
+ hicn_mapme_tfib_t *tfib = TFIB (hicn_strategy_dpo_ctx_get (dpo->dpoi_index));
if (tfib == NULL)
{
@@ -131,9 +127,9 @@ hicn_mapme_process_ctrl (vlib_main_t * vm, vlib_buffer_t * b,
if (params.seq > fib_seq)
{
- DEBUG
- ("Higher sequence number than FIB %d > %d, updating seq and next hops",
- params.seq, fib_seq);
+ DEBUG (
+ "Higher sequence number than FIB %d > %d, updating seq and next hops",
+ params.seq, fib_seq);
/* This has to be done first to allow processing ack */
tfib->seq = params.seq;
@@ -146,35 +142,29 @@ hicn_mapme_process_ctrl (vlib_main_t * vm, vlib_buffer_t * b,
/* Move next hops to TFIB... but in_face... */
for (u8 pos = 0; pos < tfib->entry_count; pos++)
{
- hicn_face_t * face = hicn_dpoi_get_from_idx(tfib->next_hops[pos]);
- hicn_face_t * in_face = hicn_dpoi_get_from_idx(in_face_id);
- if (dpo_is_adj(&face->dpo))
- {
- ip_adjacency_t * adj = adj_get (dpo->dpoi_index);
- if (ip46_address_cmp(&(adj->sub_type.nbr.next_hop), &(in_face->nat_addr))== 0)
- break;
- }
- DEBUG
- ("Adding nexthop to the tfib, dpo index in_face %d, dpo index tfib %d",
- in_face_id, tfib->next_hops[pos]);
+ hicn_face_t *face = hicn_dpoi_get_from_idx (tfib->next_hops[pos]);
+ hicn_face_t *in_face = hicn_dpoi_get_from_idx (in_face_id);
+ if (dpo_is_adj (&face->dpo))
+ {
+ ip_adjacency_t *adj = adj_get (dpo->dpoi_index);
+ if (ip46_address_cmp (&(adj->sub_type.nbr.next_hop),
+ &(in_face->nat_addr)) == 0)
+ break;
+ }
+ DEBUG ("Adding nexthop to the tfib, dpo index in_face %d, dpo index "
+ "tfib %d",
+ in_face_id, tfib->next_hops[pos]);
hicn_mapme_tfib_add (tfib, tfib->next_hops[pos]);
}
hicn_mapme_nh_set (tfib, in_face_id);
- /* 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 = (retx_t)
- {
- .prefix = prefix,
- .dpo = *dpo
- };
-
+ /* 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 = (retx_t){ .prefix = prefix, .dpo = *dpo };
}
else if (params.seq == fib_seq)
{
@@ -188,19 +178,12 @@ hicn_mapme_process_ctrl (vlib_main_t * vm, vlib_buffer_t * b,
hicn_mapme_nh_add (tfib, in_face_id);
/* 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 = (retx_t)
- {
- .prefix = prefix,
- .dpo = *dpo
- };
+ 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 };
}
- else // params.seq < fib_seq
+ else // params.seq < fib_seq
{
/*
* face is propagating outdated information, we can just consider it as a
@@ -208,24 +191,17 @@ hicn_mapme_process_ctrl (vlib_main_t * vm, vlib_buffer_t * b,
*/
hicn_mapme_tfib_add (tfib, in_face_id);
- 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
- };
+ 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 };
}
/* We just raise events, the event_mgr is in charge of forging packet. */
return true;
-//ERR_ACK_CREATE:
+// ERR_ACK_CREATE:
ERR_PARSE:
return false;
}
@@ -233,25 +209,24 @@ ERR_PARSE:
vlib_node_registration_t hicn_mapme_ctrl_node;
static uword
-hicn_mapme_ctrl_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+hicn_mapme_ctrl_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
+ vlib_frame_t *frame)
{
hicn_buffer_t *hb;
hicn_mapme_ctrl_next_t next_index;
u32 n_left_from, *from, *to_next;
n_left_from = frame->n_vectors;
- //hicn_face_id_t in_face;
+ // hicn_face_id_t in_face;
from = vlib_frame_vector_args (frame);
n_left_from = frame->n_vectors;
next_index = node->cached_next_index;
- while (n_left_from > 0) // buffers in the current frame
+ while (n_left_from > 0) // buffers in the current frame
{
u32 n_left_to_next;
vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
-
while (n_left_from > 0 && n_left_to_next > 0)
{
u32 bi0;
@@ -267,7 +242,8 @@ hicn_mapme_ctrl_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
b0 = vlib_get_buffer (vm, bi0);
hb = hicn_get_buffer (b0);
- /* This determines the next node on which the ack will be sent back */
+ /* This determines the next node on which the ack will be sent back
+ */
u32 next0 = hicn_mapme_ctrl_get_iface_node (hb->face_id);
hicn_mapme_process_ctrl (vm, b0, hb->face_id);
@@ -276,18 +252,18 @@ hicn_mapme_ctrl_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
n_left_to_next, bi0, next0);
-
}
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}
// vlib_node_increment_counter (vm, hicn_mapme_ctrl_node.index,
- // HICN_MAPME_CTRL_ERROR_SWAPPED, pkts_swapped);
+ // HICN_MAPME_CTRL_ERROR_SWAPPED,
+ // pkts_swapped);
return frame->n_vectors;
}
/* packet trace format function */
static u8 *
-hicn_mapme_ctrl_format_trace (u8 * s, va_list * args)
+hicn_mapme_ctrl_format_trace (u8 *s, va_list *args)
{
CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
@@ -298,11 +274,9 @@ hicn_mapme_ctrl_format_trace (u8 * s, va_list * args)
return (s);
}
-
/*
* Node registration for the MAP-Me node processing special interests
*/
-/* *INDENT-OFF* */
VLIB_REGISTER_NODE (hicn_mapme_ctrl_node) =
{
.function = hicn_mapme_ctrl_node_fn,
@@ -326,7 +300,6 @@ VLIB_REGISTER_NODE (hicn_mapme_ctrl_node) =
[HICN_MAPME_CTRL_NEXT_ERROR_DROP] = "error-drop",
},
};
-/* *INDENT-ON* */
/*
* fd.io coding-style-patch-verification: ON
diff --git a/hicn-plugin/src/pg.c b/hicn-plugin/src/pg.c
index 9938e85ba..972bedc59 100644
--- a/hicn-plugin/src/pg.c
+++ b/hicn-plugin/src/pg.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Copyright (c) 2017-2021 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -29,22 +29,22 @@ vlib_node_registration_t hicn_pg_interest_node;
vlib_node_registration_t hicn_pg_data_node;
/* Stats, which end up called "error" even though they aren't... */
-#define foreach_hicnpg_error \
- _(PROCESSED, "hICN PG packets processed") \
- _(DROPPED, "hICN PG packets dropped") \
- _(INTEREST_MSGS_GENERATED, "hICN PG Interests generated") \
- _(CONTENT_MSGS_RECEIVED, "hICN PG Content msgs received")
+#define foreach_hicnpg_error \
+ _ (PROCESSED, "hICN PG packets processed") \
+ _ (DROPPED, "hICN PG packets dropped") \
+ _ (INTEREST_MSGS_GENERATED, "hICN PG Interests generated") \
+ _ (CONTENT_MSGS_RECEIVED, "hICN PG Content msgs received")
typedef enum
{
-#define _(sym,str) HICNPG_ERROR_##sym,
+#define _(sym, str) HICNPG_ERROR_##sym,
foreach_hicnpg_error
#undef _
HICNPG_N_ERROR,
} hicnpg_error_t;
static char *hicnpg_error_strings[] = {
-#define _(sym,string) string,
+#define _(sym, string) string,
foreach_hicnpg_error
#undef _
};
@@ -70,15 +70,13 @@ typedef struct
u16 msg_type;
} hicnpg_trace_t;
-hicnpg_main_t hicnpg_main = {
- .index = (u32) 0,
- .index_ifaces = (u32) 1,
- .max_seq_number = (u32) ~ 0,
- .interest_lifetime = 4,
- .n_flows = (u32) 0,
- .n_ifaces = (u32) 1,
- .sw_if = (u32) 0
-};
+hicnpg_main_t hicnpg_main = { .index = (u32) 0,
+ .index_ifaces = (u32) 1,
+ .max_seq_number = (u32) ~0,
+ .interest_lifetime = 4,
+ .n_flows = (u32) 0,
+ .n_ifaces = (u32) 1,
+ .sw_if = (u32) 0 };
hicnpg_server_main_t hicnpg_server_main = {
.node_index = 0,
@@ -86,47 +84,47 @@ hicnpg_server_main_t hicnpg_server_main = {
/* packet trace format function */
static u8 *
-format_hicnpg_trace (u8 * s, va_list * args)
+format_hicnpg_trace (u8 *s, va_list *args)
{
CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
hicnpg_trace_t *t = va_arg (*args, hicnpg_trace_t *);
s = format (s, "HICNPG: pkt: %d, msg %d, sw_if_index %d, next index %d",
- (int) t->pkt_type, (int) t->msg_type,
- t->sw_if_index, t->next_index);
+ (int) t->pkt_type, (int) t->msg_type, t->sw_if_index,
+ t->next_index);
return (s);
}
-always_inline void
-hicn_rewrite_interestv4 (vlib_main_t * vm, vlib_buffer_t * b0, u32 seq_number,
- u16 lifetime, u32 next_flow, u32 iface);
+always_inline void hicn_rewrite_interestv4 (vlib_main_t *vm, vlib_buffer_t *b0,
+ u32 seq_number, u16 lifetime,
+ u32 next_flow, u32 iface);
-always_inline void
-hicn_rewrite_interestv6 (vlib_main_t * vm, vlib_buffer_t * b0, u32 seq_number,
- u16 lifetime, u32 next_flow, u32 iface);
+always_inline void hicn_rewrite_interestv6 (vlib_main_t *vm, vlib_buffer_t *b0,
+ u32 seq_number, u16 lifetime,
+ u32 next_flow, u32 iface);
-always_inline void
-convert_interest_to_data_v4 (vlib_main_t * vm, vlib_buffer_t * b0,
- vlib_buffer_t * rb, u32 bi0);
+always_inline void convert_interest_to_data_v4 (vlib_main_t *vm,
+ vlib_buffer_t *b0,
+ vlib_buffer_t *rb, u32 bi0);
-always_inline void
-convert_interest_to_data_v6 (vlib_main_t * vm, vlib_buffer_t * b0,
- vlib_buffer_t * rb, u32 bi0);
+always_inline void convert_interest_to_data_v6 (vlib_main_t *vm,
+ vlib_buffer_t *b0,
+ vlib_buffer_t *rb, u32 bi0);
-always_inline void
-calculate_tcp_checksum_v4 (vlib_main_t * vm, vlib_buffer_t * b0);
+always_inline void calculate_tcp_checksum_v4 (vlib_main_t *vm,
+ vlib_buffer_t *b0);
-always_inline void
-calculate_tcp_checksum_v6 (vlib_main_t * vm, vlib_buffer_t * b0);
+always_inline void calculate_tcp_checksum_v6 (vlib_main_t *vm,
+ vlib_buffer_t *b0);
/*
* 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
* packet generator to generate icn request traffic.
*/
static uword
-hicnpg_client_interest_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+hicnpg_client_interest_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
+ vlib_frame_t *frame)
{
u32 n_left_from, *from, *to_next;
hicnpg_interest_next_t next_index;
@@ -194,8 +192,8 @@ hicnpg_client_interest_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
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)
- == HICN_ERROR_NONE)
+ if (hicn_interest_parse_pkt (b0, &name0, &namelen0, &hicn0,
+ &isv6_0) == HICN_ERROR_NONE)
{
/* this node grabs only interests */
@@ -204,29 +202,24 @@ hicnpg_client_interest_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
iface = (hpgm->index_ifaces % hpgm->n_ifaces);
/* Rewrite and send */
- isv6_0 ? hicn_rewrite_interestv6 (vm, b0,
- (hpgm->index /
- hpgm->n_flows) %
- hpgm->max_seq_number,
- hpgm->interest_lifetime,
- hpgm->index % hpgm->n_flows,
- iface) :
- hicn_rewrite_interestv4 (vm, b0,
- (hpgm->index / hpgm->n_flows) %
- hpgm->max_seq_number,
- hpgm->interest_lifetime,
- hpgm->index % hpgm->n_flows, iface);
+ isv6_0 ?
+ hicn_rewrite_interestv6 (
+ vm, b0, (hpgm->index / hpgm->n_flows) % hpgm->max_seq_number,
+ hpgm->interest_lifetime, hpgm->index % hpgm->n_flows,
+ iface) :
+ hicn_rewrite_interestv4 (
+ vm, b0, (hpgm->index / hpgm->n_flows) % hpgm->max_seq_number,
+ hpgm->interest_lifetime, hpgm->index % hpgm->n_flows, iface);
hpgm->index_ifaces++;
if (iface == (hpgm->n_ifaces - 1))
hpgm->index++;
- next0 =
- isv6_0 ? HICNPG_INTEREST_NEXT_V6_LOOKUP :
- HICNPG_INTEREST_NEXT_V4_LOOKUP;
+ next0 = isv6_0 ? HICNPG_INTEREST_NEXT_V6_LOOKUP :
+ HICNPG_INTEREST_NEXT_V4_LOOKUP;
}
- if (hicn_interest_parse_pkt (b1, &name1, &namelen1, &hicn1, &isv6_1)
- == HICN_ERROR_NONE)
+ if (hicn_interest_parse_pkt (b1, &name1, &namelen1, &hicn1,
+ &isv6_1) == HICN_ERROR_NONE)
{
/* this node grabs only interests */
@@ -235,26 +228,21 @@ hicnpg_client_interest_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
iface = (hpgm->index_ifaces % hpgm->n_ifaces);
/* Rewrite and send */
- isv6_1 ? hicn_rewrite_interestv6 (vm, b1,
- (hpgm->index /
- hpgm->n_flows) %
- hpgm->max_seq_number,
- hpgm->interest_lifetime,
- hpgm->index % hpgm->n_flows,
- iface) :
- hicn_rewrite_interestv4 (vm, b1,
- (hpgm->index / hpgm->n_flows) %
- hpgm->max_seq_number,
- hpgm->interest_lifetime,
- hpgm->index % hpgm->n_flows, iface);
+ isv6_1 ?
+ hicn_rewrite_interestv6 (
+ vm, b1, (hpgm->index / hpgm->n_flows) % hpgm->max_seq_number,
+ hpgm->interest_lifetime, hpgm->index % hpgm->n_flows,
+ iface) :
+ hicn_rewrite_interestv4 (
+ vm, b1, (hpgm->index / hpgm->n_flows) % hpgm->max_seq_number,
+ hpgm->interest_lifetime, hpgm->index % hpgm->n_flows, iface);
hpgm->index_ifaces++;
if (iface == (hpgm->n_ifaces - 1))
hpgm->index++;
- next1 =
- isv6_1 ? HICNPG_INTEREST_NEXT_V6_LOOKUP :
- HICNPG_INTEREST_NEXT_V4_LOOKUP;
+ next1 = isv6_1 ? HICNPG_INTEREST_NEXT_V6_LOOKUP :
+ HICNPG_INTEREST_NEXT_V4_LOOKUP;
}
/* Send pkt to next node */
vnet_buffer (b0)->sw_if_index[VLIB_TX] = ~0;
@@ -295,9 +283,9 @@ hicnpg_client_interest_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
* verify speculative enqueues, maybe switch current
* next frame
*/
- vlib_validate_buffer_enqueue_x2 (vm, node, next_index,
- to_next, n_left_to_next,
- bi0, bi1, next0, next1);
+ vlib_validate_buffer_enqueue_x2 (vm, node, next_index, to_next,
+ n_left_to_next, bi0, bi1, next0,
+ next1);
}
while (n_left_from > 0 && n_left_to_next > 0)
@@ -320,8 +308,8 @@ hicnpg_client_interest_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
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)
- == HICN_ERROR_NONE)
+ if (hicn_interest_parse_pkt (b0, &name0, &namelen0, &hicn0,
+ &isv6_0) == HICN_ERROR_NONE)
{
/* this node grabs only interests */
@@ -331,32 +319,27 @@ hicnpg_client_interest_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
iface = (hpgm->index_ifaces % hpgm->n_ifaces);
/* Rewrite and send */
- isv6_0 ? hicn_rewrite_interestv6 (vm, b0,
- (hpgm->index /
- hpgm->n_flows) %
- hpgm->max_seq_number,
- hpgm->interest_lifetime,
- hpgm->index % hpgm->n_flows,
- iface) :
- hicn_rewrite_interestv4 (vm, b0,
- (hpgm->index / hpgm->n_flows) %
- hpgm->max_seq_number,
- hpgm->interest_lifetime,
- hpgm->index % hpgm->n_flows, iface);
+ isv6_0 ?
+ hicn_rewrite_interestv6 (
+ vm, b0, (hpgm->index / hpgm->n_flows) % hpgm->max_seq_number,
+ hpgm->interest_lifetime, hpgm->index % hpgm->n_flows,
+ iface) :
+ hicn_rewrite_interestv4 (
+ vm, b0, (hpgm->index / hpgm->n_flows) % hpgm->max_seq_number,
+ hpgm->interest_lifetime, hpgm->index % hpgm->n_flows, iface);
hpgm->index_ifaces++;
if (iface == (hpgm->n_ifaces - 1))
hpgm->index++;
- next0 =
- isv6_0 ? HICNPG_INTEREST_NEXT_V6_LOOKUP :
- HICNPG_INTEREST_NEXT_V4_LOOKUP;
+ next0 = isv6_0 ? HICNPG_INTEREST_NEXT_V6_LOOKUP :
+ HICNPG_INTEREST_NEXT_V4_LOOKUP;
}
/* Send pkt to ip lookup */
vnet_buffer (b0)->sw_if_index[VLIB_TX] = ~0;
- if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)
- && (b0->flags & VLIB_BUFFER_IS_TRACED)))
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) &&
+ (b0->flags & VLIB_BUFFER_IS_TRACED)))
{
hicnpg_trace_t *t = vlib_add_trace (vm, node, b0, sizeof (*t));
t->pkt_type = pkt_type0;
@@ -374,9 +357,8 @@ hicnpg_client_interest_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
* verify speculative enqueue, maybe switch current
* next frame
*/
- vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
- to_next, n_left_to_next,
- bi0, next0);
+ vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
+ n_left_to_next, bi0, next0);
}
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
@@ -394,7 +376,7 @@ hicnpg_client_interest_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
}
void
-hicn_rewrite_interestv4 (vlib_main_t * vm, vlib_buffer_t * b0, u32 seq_number,
+hicn_rewrite_interestv4 (vlib_main_t *vm, vlib_buffer_t *b0, u32 seq_number,
u16 interest_lifetime, u32 next_flow, u32 iface)
{
hicn_header_t *h0 = vlib_buffer_get_current (b0);
@@ -440,7 +422,7 @@ hicn_rewrite_interestv4 (vlib_main_t * vm, vlib_buffer_t * b0, u32 seq_number,
* Destination is used to iterate on the content.
*/
void
-hicn_rewrite_interestv6 (vlib_main_t * vm, vlib_buffer_t * b0, u32 seq_number,
+hicn_rewrite_interestv6 (vlib_main_t *vm, vlib_buffer_t *b0, u32 seq_number,
u16 interest_lifetime, u32 next_flow, u32 iface)
{
hicn_header_t *h0 = vlib_buffer_get_current (b0);
@@ -468,10 +450,8 @@ hicn_rewrite_interestv6 (vlib_main_t * vm, vlib_buffer_t * b0, u32 seq_number,
calculate_tcp_checksum_v6 (vm, b0);
}
-
-
void
-calculate_tcp_checksum_v4 (vlib_main_t * vm, vlib_buffer_t * b0)
+calculate_tcp_checksum_v4 (vlib_main_t *vm, vlib_buffer_t *b0)
{
ip4_header_t *ip0;
tcp_header_t *tcp0;
@@ -488,14 +468,13 @@ calculate_tcp_checksum_v4 (vlib_main_t * vm, vlib_buffer_t * b0)
{
sum0 = clib_mem_unaligned (&ip0->src_address, u32);
sum0 =
- ip_csum_with_carry (sum0,
- clib_mem_unaligned (&ip0->dst_address, u32));
+ ip_csum_with_carry (sum0, clib_mem_unaligned (&ip0->dst_address, u32));
}
else
sum0 = clib_mem_unaligned (&ip0->src_address, u64);
- sum0 = ip_csum_with_carry
- (sum0, clib_host_to_net_u32 (tcp_len0 + (ip0->protocol << 16)));
+ sum0 = ip_csum_with_carry (
+ sum0, clib_host_to_net_u32 (tcp_len0 + (ip0->protocol << 16)));
/* Invalidate possibly old checksum. */
tcp0->checksum = 0;
@@ -507,7 +486,7 @@ calculate_tcp_checksum_v4 (vlib_main_t * vm, vlib_buffer_t * b0)
}
void
-calculate_tcp_checksum_v6 (vlib_main_t * vm, vlib_buffer_t * b0)
+calculate_tcp_checksum_v6 (vlib_main_t *vm, vlib_buffer_t *b0)
{
ip6_header_t *ip0;
tcp_header_t *tcp0;
@@ -524,14 +503,13 @@ calculate_tcp_checksum_v6 (vlib_main_t * vm, vlib_buffer_t * b0)
{
sum0 = clib_mem_unaligned (&ip0->src_address, u32);
sum0 =
- ip_csum_with_carry (sum0,
- clib_mem_unaligned (&ip0->dst_address, u32));
+ ip_csum_with_carry (sum0, clib_mem_unaligned (&ip0->dst_address, u32));
}
else
sum0 = clib_mem_unaligned (&ip0->src_address, u64);
- sum0 = ip_csum_with_carry
- (sum0, clib_host_to_net_u32 (tcp_len0 + (ip0->protocol << 16)));
+ sum0 = ip_csum_with_carry (
+ sum0, clib_host_to_net_u32 (tcp_len0 + (ip0->protocol << 16)));
/* Invalidate possibly old checksum. */
tcp0->checksum = 0;
@@ -542,24 +520,19 @@ calculate_tcp_checksum_v6 (vlib_main_t * vm, vlib_buffer_t * b0)
tcp0->checksum = ~ip_csum_fold (sum0);
}
-/* *INDENT-OFF* */
-VLIB_REGISTER_NODE(hicn_pg_interest_node) ={
+VLIB_REGISTER_NODE (hicn_pg_interest_node) = {
.function = hicnpg_client_interest_node_fn,
.name = "hicnpg-interest",
- .vector_size = sizeof(u32),
+ .vector_size = sizeof (u32),
.format_trace = format_hicnpg_trace,
.type = VLIB_NODE_TYPE_INTERNAL,
- .n_errors = ARRAY_LEN(hicnpg_error_strings),
+ .n_errors = ARRAY_LEN (hicnpg_error_strings),
.error_strings = hicnpg_error_strings,
.n_next_nodes = HICNPG_N_NEXT,
- .next_nodes =
- {
- [HICNPG_INTEREST_NEXT_V4_LOOKUP] = "ip4-lookup",
- [HICNPG_INTEREST_NEXT_V6_LOOKUP] = "ip6-lookup",
- [HICNPG_INTEREST_NEXT_DROP] = "error-drop"
- },
+ .next_nodes = { [HICNPG_INTEREST_NEXT_V4_LOOKUP] = "ip4-lookup",
+ [HICNPG_INTEREST_NEXT_V6_LOOKUP] = "ip6-lookup",
+ [HICNPG_INTEREST_NEXT_DROP] = "error-drop" },
};
-/* *INDENT-ON* */
/*
* Next graph nodes, which reference the list in the actual registration
@@ -584,21 +557,20 @@ typedef struct
/* packet trace format function */
static u8 *
-format_hicnpg_data_trace (u8 * s, va_list * args)
+format_hicnpg_data_trace (u8 *s, va_list *args)
{
CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
hicnpg_trace_t *t = va_arg (*args, hicnpg_trace_t *);
s = format (s, "HICNPG: pkt: %d, msg %d, sw_if_index %d, next index %d",
- (int) t->pkt_type, (int) t->msg_type,
- t->sw_if_index, t->next_index);
+ (int) t->pkt_type, (int) t->msg_type, t->sw_if_index,
+ t->next_index);
return (s);
}
-
static_always_inline int
-match_ip4_name (u32 * name, fib_prefix_t * prefix)
+match_ip4_name (u32 *name, fib_prefix_t *prefix)
{
u32 xor = 0;
@@ -608,7 +580,7 @@ match_ip4_name (u32 * name, fib_prefix_t * prefix)
}
static_always_inline int
-match_ip6_name (u8 * name, fib_prefix_t * prefix)
+match_ip6_name (u8 *name, fib_prefix_t *prefix)
{
union
{
@@ -621,10 +593,9 @@ match_ip6_name (u8 * name, fib_prefix_t * prefix)
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]);
+ (xor_sum.as_u64[1] == prefix->fp_addr.ip6.as_u64[1]);
}
-
/*
* Return 0,1,2.
* 0 matches
@@ -632,7 +603,7 @@ match_ip6_name (u8 * name, fib_prefix_t * prefix)
* 2 does not match and the prefix is ip6
*/
static_always_inline u32
-match_data (vlib_buffer_t * b, fib_prefix_t * prefix)
+match_data (vlib_buffer_t *b, fib_prefix_t *prefix)
{
u8 *ptr = vlib_buffer_get_current (b);
u8 v = *ptr & 0xf0;
@@ -640,11 +611,10 @@ match_data (vlib_buffer_t * b, fib_prefix_t * prefix)
if (PREDICT_TRUE (v == 0x40 && ip46_address_is_ip4 (&prefix->fp_addr)))
{
- if (!match_ip4_name ((u32 *) & (ptr[12]), prefix))
+ if (!match_ip4_name ((u32 *) &(ptr[12]), prefix))
next = 1;
}
- else
- if (PREDICT_TRUE (v == 0x60 && !ip46_address_is_ip4 (&prefix->fp_addr)))
+ else if (PREDICT_TRUE (v == 0x60 && !ip46_address_is_ip4 (&prefix->fp_addr)))
{
if (!match_ip6_name (&(ptr[8]), prefix))
next = 2;
@@ -660,7 +630,7 @@ match_data (vlib_buffer_t * b, fib_prefix_t * prefix)
* 2 does not match and the prefix is ip6
*/
static_always_inline u32
-match_interest (vlib_buffer_t * b, fib_prefix_t * prefix)
+match_interest (vlib_buffer_t *b, fib_prefix_t *prefix)
{
u8 *ptr = vlib_buffer_get_current (b);
u8 v = *ptr & 0xf0;
@@ -668,11 +638,10 @@ match_interest (vlib_buffer_t * b, fib_prefix_t * prefix)
if (PREDICT_TRUE (v == 0x40 && ip46_address_is_ip4 (&prefix->fp_addr)))
{
- if (!match_ip4_name ((u32 *) & (ptr[16]), prefix))
+ if (!match_ip4_name ((u32 *) &(ptr[16]), prefix))
next = 1;
}
- else
- if (PREDICT_TRUE (v == 0x60 && !ip46_address_is_ip4 (&prefix->fp_addr)))
+ else if (PREDICT_TRUE (v == 0x60 && !ip46_address_is_ip4 (&prefix->fp_addr)))
{
if (!match_ip6_name (&(ptr[24]), prefix))
next = 2;
@@ -681,17 +650,14 @@ match_interest (vlib_buffer_t * b, fib_prefix_t * prefix)
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
* packet generator to generate icn request traffic.
*/
static uword
-hicnpg_client_data_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+hicnpg_client_data_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
+ vlib_frame_t *frame)
{
u32 n_left_from, *from, *to_next;
hicnpg_data_next_t next_index;
@@ -754,17 +720,16 @@ hicnpg_client_data_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
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))
+ 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))
+ 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 */
@@ -799,9 +764,9 @@ hicnpg_client_data_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
}
}
- vlib_validate_buffer_enqueue_x2 (vm, node, next_index,
- to_next, n_left_to_next,
- bi0, bi1, next0, next1);
+ vlib_validate_buffer_enqueue_x2 (vm, node, next_index, to_next,
+ n_left_to_next, bi0, bi1, next0,
+ next1);
pkts_processed += 2;
}
@@ -825,9 +790,9 @@ hicnpg_client_data_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
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))
+ 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)
@@ -836,8 +801,8 @@ hicnpg_client_data_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
content_msgs_received++;
}
- if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)
- && (b0->flags & VLIB_BUFFER_IS_TRACED)))
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) &&
+ (b0->flags & VLIB_BUFFER_IS_TRACED)))
{
icnpg_data_trace_t *t =
vlib_add_trace (vm, node, b0, sizeof (*t));
@@ -863,7 +828,6 @@ hicnpg_client_data_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
return (frame->n_vectors);
}
-/* *INDENT-OFF* */
VLIB_REGISTER_NODE(hicn_pg_data_node) =
{
.function = hicnpg_client_data_node_fn,
@@ -881,27 +845,18 @@ VLIB_REGISTER_NODE(hicn_pg_data_node) =
[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* */
+VNET_FEATURE_INIT (hicn_data_input_ip4_arc, static) = {
+ .arc_name = "ip4-unicast",
+ .node_name = "hicnpg-data",
+ .runs_before = VNET_FEATURES ("ip4-inacl"),
+};
+VNET_FEATURE_INIT (hicn_data_input_ip6_arc, static) = {
+ .arc_name = "ip6-unicast",
+ .node_name = "hicnpg-data",
+ .runs_before = VNET_FEATURES ("ip6-inacl"),
+};
/*
* End of packet-generator client node
@@ -915,20 +870,20 @@ VNET_FEATURE_INIT(hicn_data_input_ip6_arc, static)=
vlib_node_registration_t hicn_pg_server_node;
/* Stats, which end up called "error" even though they aren't... */
-#define foreach_icnpg_server_error \
-_(PROCESSED, "hICN PG Server packets processed") \
-_(DROPPED, "hICN PG Server packets dropped")
+#define foreach_icnpg_server_error \
+ _ (PROCESSED, "hICN PG Server packets processed") \
+ _ (DROPPED, "hICN PG Server packets dropped")
typedef enum
{
-#define _(sym,str) HICNPG_SERVER_ERROR_##sym,
+#define _(sym, str) HICNPG_SERVER_ERROR_##sym,
foreach_icnpg_server_error
#undef _
HICNPG_SERVER_N_ERROR,
} icnpg_server_error_t;
static char *icnpg_server_error_strings[] = {
-#define _(sym,string) string,
+#define _(sym, string) string,
foreach_icnpg_server_error
#undef _
};
@@ -956,17 +911,15 @@ typedef struct
/* packet trace format function */
static u8 *
-format_icnpg_server_trace (u8 * s, va_list * args)
+format_icnpg_server_trace (u8 *s, va_list *args)
{
CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
hicnpg_server_trace_t *t = va_arg (*args, hicnpg_server_trace_t *);
- s =
- format (s,
- "HICNPG SERVER: pkt: %d, msg %d, sw_if_index %d, next index %d",
- (int) t->pkt_type, (int) t->msg_type, t->sw_if_index,
- t->next_index);
+ s = format (
+ s, "HICNPG SERVER: pkt: %d, msg %d, sw_if_index %d, next index %d",
+ (int) t->pkt_type, (int) t->msg_type, t->sw_if_index, t->next_index);
return (s);
}
@@ -974,8 +927,8 @@ format_icnpg_server_trace (u8 * s, va_list * args)
* Node function for the icn packet-generator server.
*/
static uword
-hicnpg_node_server_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node, vlib_frame_t * frame)
+hicnpg_node_server_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
+ vlib_frame_t *frame)
{
u32 n_left_from, *from, *to_next;
icnpg_server_next_t next_index;
@@ -1001,7 +954,6 @@ hicnpg_node_server_fn (vlib_main_t * vm,
vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
-
while (n_left_from >= 4 && n_left_to_next >= 2)
{
u32 next0 = HICNPG_SERVER_NEXT_DROP;
@@ -1051,42 +1003,36 @@ hicnpg_node_server_fn (vlib_main_t * vm,
{
next0 = match0 - 1;
}
- else
- if (hicn_interest_parse_pkt
- (b0, &name0, &namelen0, &hicn0, &isv6_0) == HICN_ERROR_NONE)
+ 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;
rb = vlib_get_buffer (vm, hpgsm->pgen_svr_buffer_idx);
- isv6_0 ? convert_interest_to_data_v6 (vm, b0, rb,
- bi0) :
- convert_interest_to_data_v4 (vm, b0, rb, bi0);
+ isv6_0 ? convert_interest_to_data_v6 (vm, b0, rb, bi0) :
+ convert_interest_to_data_v4 (vm, b0, rb, bi0);
- next0 =
- isv6_0 ? HICNPG_SERVER_NEXT_V6_LOOKUP :
- HICNPG_SERVER_NEXT_V4_LOOKUP;
+ next0 = isv6_0 ? HICNPG_SERVER_NEXT_V6_LOOKUP :
+ HICNPG_SERVER_NEXT_V4_LOOKUP;
}
if (match1)
{
next1 = match1 - 1;
}
- else
- if (hicn_interest_parse_pkt
- (b1, &name1, &namelen1, &hicn1, &isv6_1) == HICN_ERROR_NONE)
+ 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;
rb = vlib_get_buffer (vm, hpgsm->pgen_svr_buffer_idx);
- isv6_1 ? convert_interest_to_data_v6 (vm, b1, rb,
- bi1) :
- convert_interest_to_data_v4 (vm, b1, rb, bi1);
+ isv6_1 ? convert_interest_to_data_v6 (vm, b1, rb, bi1) :
+ convert_interest_to_data_v4 (vm, b1, rb, bi1);
- next1 =
- isv6_1 ? HICNPG_SERVER_NEXT_V6_LOOKUP :
- HICNPG_SERVER_NEXT_V4_LOOKUP;
+ next1 = isv6_1 ? HICNPG_SERVER_NEXT_V6_LOOKUP :
+ HICNPG_SERVER_NEXT_V4_LOOKUP;
}
pkts_processed += 2;
@@ -1123,9 +1069,9 @@ hicnpg_node_server_fn (vlib_main_t * vm,
* verify speculative enqueues, maybe switch current
* next frame
*/
- vlib_validate_buffer_enqueue_x2 (vm, node, next_index,
- to_next, n_left_to_next,
- bi0, bi1, next0, next1);
+ vlib_validate_buffer_enqueue_x2 (vm, node, next_index, to_next,
+ n_left_to_next, bi0, bi1, next0,
+ next1);
}
while (n_left_from > 0 && n_left_to_next > 0)
@@ -1153,24 +1099,21 @@ hicnpg_node_server_fn (vlib_main_t * vm,
{
next0 = match0 - 1;
}
- else
- if (hicn_interest_parse_pkt
- (b0, &name0, &namelen0, &hicn0, &isv6_0) == HICN_ERROR_NONE)
+ 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;
rb = vlib_get_buffer (vm, hpgsm->pgen_svr_buffer_idx);
- isv6_0 ? convert_interest_to_data_v6 (vm, b0, rb,
- bi0) :
- convert_interest_to_data_v4 (vm, b0, rb, bi0);
+ isv6_0 ? convert_interest_to_data_v6 (vm, b0, rb, bi0) :
+ convert_interest_to_data_v4 (vm, b0, rb, bi0);
- next0 =
- isv6_0 ? HICNPG_SERVER_NEXT_V6_LOOKUP :
- HICNPG_SERVER_NEXT_V4_LOOKUP;
+ next0 = isv6_0 ? HICNPG_SERVER_NEXT_V6_LOOKUP :
+ HICNPG_SERVER_NEXT_V4_LOOKUP;
}
- if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)
- && (b0->flags & VLIB_BUFFER_IS_TRACED)))
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) &&
+ (b0->flags & VLIB_BUFFER_IS_TRACED)))
{
hicnpg_server_trace_t *t =
vlib_add_trace (vm, node, b0, sizeof (*t));
@@ -1189,9 +1132,8 @@ hicnpg_node_server_fn (vlib_main_t * vm,
* verify speculative enqueue, maybe switch current
* next frame
*/
- vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
- to_next, n_left_to_next,
- bi0, next0);
+ vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
+ n_left_to_next, bi0, next0);
}
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
@@ -1206,8 +1148,8 @@ hicnpg_node_server_fn (vlib_main_t * vm,
}
void
-convert_interest_to_data_v4 (vlib_main_t * vm, vlib_buffer_t * b0,
- vlib_buffer_t * rb, u32 bi0)
+convert_interest_to_data_v4 (vlib_main_t *vm, vlib_buffer_t *b0,
+ vlib_buffer_t *rb, u32 bi0)
{
hicn_header_t *h0 = vlib_buffer_get_current (b0);
@@ -1234,13 +1176,13 @@ convert_interest_to_data_v4 (vlib_main_t * vm, vlib_buffer_t * b0,
h0->v4.ip.daddr = src_addr;
h0->v4.ip.len = clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0));
- h0->v4.ip.csum = ip4_header_checksum ((ip4_header_t *) & (h0->v4.ip));
+ h0->v4.ip.csum = ip4_header_checksum ((ip4_header_t *) &(h0->v4.ip));
calculate_tcp_checksum_v4 (vm, b0);
}
void
-convert_interest_to_data_v6 (vlib_main_t * vm, vlib_buffer_t * b0,
- vlib_buffer_t * rb, u32 bi0)
+convert_interest_to_data_v6 (vlib_main_t *vm, vlib_buffer_t *b0,
+ vlib_buffer_t *rb, u32 bi0)
{
hicn_header_t *h0 = vlib_buffer_get_current (b0);
@@ -1268,15 +1210,14 @@ convert_interest_to_data_v6 (vlib_main_t * vm, vlib_buffer_t * b0,
h0->v6.ip.saddr = h0->v6.ip.daddr;
h0->v6.ip.daddr = src_addr;
- h0->v6.ip.len = clib_host_to_net_u16 (vlib_buffer_length_in_chain
- (vm, b0) - sizeof (ip6_header_t));
+ h0->v6.ip.len = clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0) -
+ sizeof (ip6_header_t));
h0->v6.tcp.data_offset_and_reserved |= 0x0f;
h0->v6.tcp.urg_ptr = htons (0xffff);
calculate_tcp_checksum_v6 (vm, b0);
}
-/* *INDENT-OFF* */
VLIB_REGISTER_NODE(hicn_pg_server_node) =
{
.function = hicnpg_node_server_fn,
@@ -1295,25 +1236,18 @@ VLIB_REGISTER_NODE(hicn_pg_server_node) =
[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* */
+VNET_FEATURE_INIT (hicn_pg_server_ip6, static) = {
+ .arc_name = "ip6-unicast",
+ .node_name = "hicnpg-server",
+ .runs_before = VNET_FEATURES ("ip6-inacl"),
+};
-/* *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* */
+VNET_FEATURE_INIT (hicn_pg_server_ip4, static) = {
+ .arc_name = "ip4-unicast",
+ .node_name = "hicnpg-server",
+ .runs_before = VNET_FEATURES ("ip4-inacl"),
+};
/*
* End of packet-generator server node
diff --git a/hicn-plugin/src/strategies/strategy_mw.c b/hicn-plugin/src/strategies/strategy_mw.c
index 594135c1e..9409ec856 100644
--- a/hicn-plugin/src/strategies/strategy_mw.c
+++ b/hicn-plugin/src/strategies/strategy_mw.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2020 Cisco and/or its affiliates.
+ * Copyright (c) 2017-2021 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
diff --git a/hicn-plugin/src/strategies/strategy_mw_cli.c b/hicn-plugin/src/strategies/strategy_mw_cli.c
index 636d7effa..473ff0e19 100644
--- a/hicn-plugin/src/strategies/strategy_mw_cli.c
+++ b/hicn-plugin/src/strategies/strategy_mw_cli.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2020 Cisco and/or its affiliates.
+ * Copyright (c) 2017-2021 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -26,9 +26,9 @@
#include "dpo_mw.h"
static clib_error_t *
-hicn_mw_strategy_cli_set_weight_command_fn (vlib_main_t * vm,
- unformat_input_t * main_input,
- vlib_cli_command_t * cmd)
+hicn_mw_strategy_cli_set_weight_command_fn (vlib_main_t *vm,
+ unformat_input_t *main_input,
+ vlib_cli_command_t *cmd)
{
clib_error_t *cl_err = 0;
int ret = HICN_ERROR_NONE;
@@ -54,19 +54,17 @@ hicn_mw_strategy_cli_set_weight_command_fn (vlib_main_t * vm,
;
else
{
- return clib_error_return (0, "%s",
- get_error_string
- (HICN_ERROR_CLI_INVAL));
+ return clib_error_return (
+ 0, "%s", get_error_string (HICN_ERROR_CLI_INVAL));
}
-
}
}
if (((weight < 0) || (weight > HICN_PARAM_FIB_ENTRY_NHOP_WGHT_MAX)))
{
- cl_err = clib_error_return (0,
- "Next-hop weight must be between 0 and %d",
- (int) HICN_PARAM_FIB_ENTRY_NHOP_WGHT_MAX);
+ cl_err =
+ clib_error_return (0, "Next-hop weight must be between 0 and %d",
+ (int) HICN_PARAM_FIB_ENTRY_NHOP_WGHT_MAX);
goto done;
}
@@ -77,24 +75,22 @@ hicn_mw_strategy_cli_set_weight_command_fn (vlib_main_t * vm,
goto done;
}
- prefix.fp_proto =
- ip46_address_is_ip4 (&prefix.
- fp_addr) ? FIB_PROTOCOL_IP4 : FIB_PROTOCOL_IP6;
+ prefix.fp_proto = ip46_address_is_ip4 (&prefix.fp_addr) ? FIB_PROTOCOL_IP4 :
+ FIB_PROTOCOL_IP6;
ret = hicn_route_get_dpo (&prefix, &hicn_dpo_id, &fib_index);
if (ret == HICN_ERROR_NONE)
{
hicn_dpo_ctx = hicn_strategy_dpo_ctx_get (hicn_dpo_id->dpoi_index);
- if (hicn_dpo_ctx == NULL
- || hicn_dpo_id->dpoi_type != hicn_dpo_strategy_mw_get_type ())
+ if (hicn_dpo_ctx == NULL ||
+ hicn_dpo_id->dpoi_type != hicn_dpo_strategy_mw_get_type ())
{
cl_err = clib_error_return (0, get_error_string (ret));
goto done;
}
- hicn_strategy_mw_ctx_t *mw_dpo =
- (hicn_strategy_mw_ctx_t *) hicn_dpo_ctx;
+ hicn_strategy_mw_ctx_t *mw_dpo = (hicn_strategy_mw_ctx_t *) hicn_dpo_ctx;
int idx = ~0;
for (int i = 0; i < hicn_dpo_ctx->entry_count; i++)
if (hicn_dpo_ctx->next_hops[i] == faceid)
@@ -102,10 +98,8 @@ hicn_mw_strategy_cli_set_weight_command_fn (vlib_main_t * vm,
if (idx == ~0)
{
- cl_err =
- clib_error_return (0,
- get_error_string
- (HICN_ERROR_STRATEGY_NH_NOT_FOUND));
+ cl_err = clib_error_return (
+ 0, get_error_string (HICN_ERROR_STRATEGY_NH_NOT_FOUND));
goto done;
}
@@ -114,24 +108,21 @@ hicn_mw_strategy_cli_set_weight_command_fn (vlib_main_t * vm,
else
{
cl_err = clib_error_return (0, get_error_string (ret));
-
}
done:
return (cl_err);
-
}
/* cli declaration for 'strategy mw' */
-/* *INDENT-OFF* */
-VLIB_CLI_COMMAND(hicn_mw_strategy_cli_set_weight_command, static)=
-{
+
+VLIB_CLI_COMMAND (hicn_mw_strategy_cli_set_weight_command, static) = {
.path = "hicn strategy mw set",
- .short_help = "hicn strategy mw set prefix <prefix> face <face_id> weight <weight>",
+ .short_help =
+ "hicn strategy mw set prefix <prefix> face <face_id> weight <weight>",
.function = hicn_mw_strategy_cli_set_weight_command_fn,
};
-/* *INDENT-ON* */
/*
* fd.io coding-style-patch-verification: ON
diff --git a/hicn-plugin/src/strategy_node.c b/hicn-plugin/src/strategy_node.c
index 0659a871a..39232be73 100644
--- a/hicn-plugin/src/strategy_node.c
+++ b/hicn-plugin/src/strategy_node.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2020 Cisco and/or its affiliates.
+ * Copyright (c) 2017-2021 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -49,7 +49,7 @@ static char *hicn_strategy_error_strings[] = {
/* packet trace format function */
u8 *
-hicn_strategy_format_trace (u8 * s, va_list * args)
+hicn_strategy_format_trace (u8 *s, va_list *args)
{
CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
@@ -60,14 +60,12 @@ hicn_strategy_format_trace (u8 * s, va_list * args)
return vft->hicn_format_strategy_trace (s, t);
}
-
always_inline int
-hicn_new_interest (hicn_strategy_runtime_t * rt, vlib_buffer_t * b0,
- u32 * next, f64 tnow, u8 * nameptr,
- u16 namelen, hicn_face_id_t outface, int nh_idx,
- index_t dpo_ctx_id0, const hicn_strategy_vft_t * strategy,
- dpo_type_t dpo_type, u8 isv6,
- vl_api_hicn_api_node_stats_get_reply_t * stats)
+hicn_new_interest (hicn_strategy_runtime_t *rt, vlib_buffer_t *b0, u32 *next,
+ f64 tnow, u8 *nameptr, u16 namelen, hicn_face_id_t outface,
+ int nh_idx, index_t dpo_ctx_id0,
+ const hicn_strategy_vft_t *strategy, dpo_type_t dpo_type,
+ u8 isv6, vl_api_hicn_api_node_stats_get_reply_t *stats)
{
int ret;
hicn_hash_node_t *nodep;
@@ -82,7 +80,6 @@ hicn_new_interest (hicn_strategy_runtime_t * rt, vlib_buffer_t * b0,
u8 bucket_is_overflow = 0;
u32 bucket_id = ~0;
-
/* Create PIT node and init PIT entry */
nodep = hicn_hashtb_alloc_node (rt->pitcs->pcs_table);
if (PREDICT_FALSE (nodep == NULL))
@@ -98,8 +95,7 @@ hicn_new_interest (hicn_strategy_runtime_t * rt, vlib_buffer_t * b0,
hicn0 = vlib_buffer_get_current (b0);
hicn_lifetime_t imsg_lifetime;
hicn_type_t type = hicnb0->type;
- hicn_ops_vft[type.l1]->get_lifetime (type, &hicn0->protocol,
- &imsg_lifetime);
+ hicn_ops_vft[type.l1]->get_lifetime (type, &hicn0->protocol, &imsg_lifetime);
if (imsg_lifetime > sm->pit_lifetime_max_ms)
{
@@ -111,11 +107,10 @@ hicn_new_interest (hicn_strategy_runtime_t * rt, vlib_buffer_t * b0,
hicn_hash_entry_t *hash_entry;
hicn_hashtb_init_node (rt->pitcs->pcs_table, nodep, nameptr, namelen);
- ret =
- hicn_pcs_pit_insert (rt->pitcs, pitp, nodep, &hash_entry,
- hicnb0->name_hash, &node_id0, &dpo_ctx_id0, &vft_id0,
- &is_cs0, &hash_entry_id, &bucket_id,
- &bucket_is_overflow);
+ ret = hicn_pcs_pit_insert (rt->pitcs, pitp, nodep, &hash_entry,
+ hicnb0->name_hash, &node_id0, &dpo_ctx_id0,
+ &vft_id0, &is_cs0, &hash_entry_id, &bucket_id,
+ &bucket_is_overflow);
if (ret == HICN_ERROR_NONE)
{
@@ -126,7 +121,7 @@ hicn_new_interest (hicn_strategy_runtime_t * rt, vlib_buffer_t * b0,
hicn_face_db_add_face (hicnb0->face_id, &(pitp->u.pit.faces));
*next = isv6 ? HICN_STRATEGY_NEXT_INTEREST_FACE6 :
- HICN_STRATEGY_NEXT_INTEREST_FACE4;
+ HICN_STRATEGY_NEXT_INTEREST_FACE4;
vnet_buffer (b0)->ip.adj_index[VLIB_TX] = outface;
stats->pkts_interest_count++;
@@ -143,9 +138,8 @@ hicn_new_interest (hicn_strategy_runtime_t * rt, vlib_buffer_t * b0,
// We need to take a lock as the lock is not taken on the hash
// entry because it is a CS entry (hash_insert function).
hash_entry->locks++;
- *next =
- is_cs0 ? HICN_STRATEGY_NEXT_INTEREST_HITCS :
- HICN_STRATEGY_NEXT_INTEREST_HITPIT;
+ *next = is_cs0 ? HICN_STRATEGY_NEXT_INTEREST_HITCS :
+ HICN_STRATEGY_NEXT_INTEREST_HITPIT;
}
else
{
@@ -157,7 +151,6 @@ hicn_new_interest (hicn_strategy_runtime_t * rt, vlib_buffer_t * b0,
}
return (ret);
-
}
/*
@@ -165,8 +158,8 @@ hicn_new_interest (hicn_strategy_runtime_t * rt, vlib_buffer_t * b0,
* ipv6/tcp
*/
uword
-hicn_strategy_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node, vlib_frame_t * frame)
+hicn_strategy_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
+ vlib_frame_t *frame)
{
u32 n_left_from, *from, *to_next, n_left_to_next;
@@ -221,9 +214,8 @@ hicn_strategy_fn (vlib_main_t * vm,
b0 = vlib_get_buffer (vm, bi0);
next0 = HICN_STRATEGY_NEXT_ERROR_DROP;
- hicn_dpo_ctx_t *dpo_ctx =
- hicn_strategy_dpo_ctx_get (vnet_buffer (b0)->ip.
- adj_index[VLIB_TX]);
+ hicn_dpo_ctx_t *dpo_ctx = hicn_strategy_dpo_ctx_get (
+ vnet_buffer (b0)->ip.adj_index[VLIB_TX]);
const hicn_strategy_vft_t *strategy =
hicn_dpo_get_strategy_vft (dpo_ctx->dpo_type);
@@ -235,13 +227,11 @@ hicn_strategy_fn (vlib_main_t * vm,
* the interest-pcslookup node due to misconfiguration in
* the punting rules.
*/
- if (PREDICT_TRUE
- (ret == HICN_ERROR_NONE && HICN_IS_NAMEHASH_CACHED (b0)
- && strategy->hicn_select_next_hop (vnet_buffer (b0)->
- ip.adj_index[VLIB_TX],
- &nh_idx,
- &outface) ==
- HICN_ERROR_NONE))
+ if (PREDICT_TRUE (ret == HICN_ERROR_NONE &&
+ HICN_IS_NAMEHASH_CACHED (b0) &&
+ strategy->hicn_select_next_hop (
+ vnet_buffer (b0)->ip.adj_index[VLIB_TX], &nh_idx,
+ &outface) == HICN_ERROR_NONE))
{
/*
* No need to check if parsing was successful
@@ -273,9 +263,8 @@ hicn_strategy_fn (vlib_main_t * vm,
* Fix in case of a wrong speculation. Needed for
* cloning the data in the right frame
*/
- vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
- to_next, n_left_to_next,
- bi0, next0);
+ vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
+ n_left_to_next, bi0, next0);
}
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
@@ -293,7 +282,6 @@ hicn_strategy_fn (vlib_main_t * vm,
/*
* Node registration for the forwarder node
*/
-/* *INDENT-OFF* */
VLIB_REGISTER_NODE (hicn_strategy_node) =
{
.name = "hicn-strategy",
@@ -315,7 +303,6 @@ VLIB_REGISTER_NODE (hicn_strategy_node) =
},
};
-
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/hicn-plugin/src/udp_tunnels/udp_decap_node.c b/hicn-plugin/src/udp_tunnels/udp_decap_node.c
index 5603f20f9..84e4e5234 100644
--- a/hicn-plugin/src/udp_tunnels/udp_decap_node.c
+++ b/hicn-plugin/src/udp_tunnels/udp_decap_node.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Cisco and/or its affiliates.
+ * Copyright (c) 2020-2021 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -37,9 +37,9 @@ typedef enum
typedef enum
{
- UDP6_DECAP_NEXT_LOOKUP_IP4,
- UDP6_DECAP_NEXT_LOOKUP_IP6,
- UDP6_DECAP_N_NEXT,
+ UDP6_DECAP_NEXT_LOOKUP_IP4,
+ UDP6_DECAP_NEXT_LOOKUP_IP6,
+ UDP6_DECAP_N_NEXT,
} udp6_decap_next_t;
typedef struct udp4_decap_trace_t_
@@ -66,9 +66,8 @@ typedef struct udp_decap_trace_t_
u8 ishicn;
} udp_decap_trace_t;
-
static u8 *
-format_udp_decap_trace (u8 * s, va_list * args)
+format_udp_decap_trace (u8 *s, va_list *args)
{
CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
@@ -78,51 +77,55 @@ format_udp_decap_trace (u8 * s, va_list * args)
if (t->isv6)
{
- s = format (s, "%U\n %U \n %s",
- format_ip4_header, &t->udp6.ip, sizeof (t->udp6.ip),
- format_udp_header, &t->udp6.udp, sizeof (t->udp6.udp),
- t->ishicn ? "hICN udp tunnel" : "");
+ s = format (s, "%U\n %U \n %s", format_ip4_header, &t->udp6.ip,
+ sizeof (t->udp6.ip), format_udp_header, &t->udp6.udp,
+ sizeof (t->udp6.udp), t->ishicn ? "hICN udp tunnel" : "");
}
else
{
- s = format (s, "%U\n %U \n %s",
- format_ip4_header, &t->udp4.ip, sizeof (t->udp4.ip),
- format_udp_header, &t->udp4.udp, sizeof (t->udp4.udp),
- t->ishicn ? "hICN udp tunnel" : "");
+ s = format (s, "%U\n %U \n %s", format_ip4_header, &t->udp4.ip,
+ sizeof (t->udp4.ip), format_udp_header, &t->udp4.udp,
+ sizeof (t->udp4.udp), t->ishicn ? "hICN udp tunnel" : "");
}
return (s);
}
static_always_inline void
-udp_decap_trace_buffer (vlib_main_t * vm, vlib_node_runtime_t * node,
- u8 isv6, vlib_buffer_t * b)
+udp_decap_trace_buffer (vlib_main_t *vm, vlib_node_runtime_t *node, u8 isv6,
+ vlib_buffer_t *b)
{
if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) &&
(b->flags & VLIB_BUFFER_IS_TRACED)))
{
- udp_decap_trace_t *t =
- vlib_add_trace (vm, node, b, sizeof (*t));
+ udp_decap_trace_t *t = vlib_add_trace (vm, node, b, sizeof (*t));
t->isv6 = isv6;
- hicn_buffer_t *hb = hicn_get_buffer(b);
+ hicn_buffer_t *hb = hicn_get_buffer (b);
if (isv6)
- {
- clib_memcpy(&(t->udp6.udp), vlib_buffer_get_current(b) + sizeof(ip6_header_t), sizeof(udp_header_t));
- clib_memcpy(&(t->udp6.ip), vlib_buffer_get_current(b), sizeof(ip6_header_t));
- t->ishicn = hb->flags & hb->flags & HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL;
- }
+ {
+ clib_memcpy (&(t->udp6.udp),
+ vlib_buffer_get_current (b) + sizeof (ip6_header_t),
+ sizeof (udp_header_t));
+ clib_memcpy (&(t->udp6.ip), vlib_buffer_get_current (b),
+ sizeof (ip6_header_t));
+ t->ishicn =
+ hb->flags & hb->flags & HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL;
+ }
else
- {
- clib_memcpy(&(t->udp4.udp), vlib_buffer_get_current(b) + sizeof(ip4_header_t), sizeof(udp_header_t));
- clib_memcpy(&(t->udp4.ip), vlib_buffer_get_current(b), sizeof(ip4_header_t));
- t->ishicn = hb->flags & HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL;
- }
+ {
+ clib_memcpy (&(t->udp4.udp),
+ vlib_buffer_get_current (b) + sizeof (ip4_header_t),
+ sizeof (udp_header_t));
+ clib_memcpy (&(t->udp4.ip), vlib_buffer_get_current (b),
+ sizeof (ip4_header_t));
+ t->ishicn = hb->flags & HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL;
+ }
}
}
static uword
-udp4_decap_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+udp4_decap_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
+ vlib_frame_t *frame)
{
u32 n_left_from, *from, *to_next, next_index;
@@ -138,11 +141,11 @@ udp4_decap_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
/* Dual loop, X2 */
while (n_left_from >= 8 && n_left_to_next >= 4)
{
- vlib_buffer_t *b0, *b1, *b2, *b3;
+ vlib_buffer_t *b0, *b1, *b2, *b3;
u32 bi0, bi1, bi2, bi3;
u32 next0, next1, next2, next3;
- {
+ {
vlib_buffer_t *b4, *b5, *b6, *b7;
b4 = vlib_get_buffer (vm, from[4]);
b5 = vlib_get_buffer (vm, from[5]);
@@ -172,108 +175,128 @@ udp4_decap_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
b0 = vlib_get_buffer (vm, bi0);
b1 = vlib_get_buffer (vm, bi1);
b2 = vlib_get_buffer (vm, bi2);
- b3 = vlib_get_buffer (vm, bi3);
+ b3 = vlib_get_buffer (vm, bi3);
u8 *ptr0 = vlib_buffer_get_current (b0);
- u8 *ptr1 = vlib_buffer_get_current (b1);
- u8 *ptr2 = vlib_buffer_get_current (b2);
- u8 *ptr3 = vlib_buffer_get_current (b3);
+ u8 *ptr1 = vlib_buffer_get_current (b1);
+ u8 *ptr2 = vlib_buffer_get_current (b2);
+ u8 *ptr3 = vlib_buffer_get_current (b3);
u8 v0 = *ptr0 & 0xf0;
u8 v1 = *ptr1 & 0xf0;
u8 v2 = *ptr2 & 0xf0;
u8 v3 = *ptr3 & 0xf0;
- u8 advance = sizeof(ip4_header_t) + sizeof(udp_header_t);
+ u8 advance = sizeof (ip4_header_t) + sizeof (udp_header_t);
- vlib_buffer_advance(b0, -advance);
- vlib_buffer_advance(b1, -advance);
- vlib_buffer_advance(b2, -advance);
- vlib_buffer_advance(b3, -advance);
+ vlib_buffer_advance (b0, -advance);
+ vlib_buffer_advance (b1, -advance);
+ vlib_buffer_advance (b2, -advance);
+ vlib_buffer_advance (b3, -advance);
- u8 *outer_ptr0 = vlib_buffer_get_current (b0);
- u8 *outer_ptr1 = vlib_buffer_get_current (b1);
- u8 *outer_ptr2 = vlib_buffer_get_current (b2);
- u8 *outer_ptr3 = vlib_buffer_get_current (b3);
- u8 outer_v0 = *outer_ptr0 & 0xf0;
+ u8 *outer_ptr0 = vlib_buffer_get_current (b0);
+ u8 *outer_ptr1 = vlib_buffer_get_current (b1);
+ u8 *outer_ptr2 = vlib_buffer_get_current (b2);
+ u8 *outer_ptr3 = vlib_buffer_get_current (b3);
+ u8 outer_v0 = *outer_ptr0 & 0xf0;
u8 outer_v1 = *outer_ptr1 & 0xf0;
u8 outer_v2 = *outer_ptr2 & 0xf0;
u8 outer_v3 = *outer_ptr3 & 0xf0;
- ip46_address_t src0 = {0};
- ip46_address_t src1 = {0};
- ip46_address_t src2 = {0};
- ip46_address_t src3 = {0};
-
- ip46_address_t dst0 = {0};
- ip46_address_t dst1 = {0};
- ip46_address_t dst2 = {0};
- ip46_address_t dst3 = {0};
-
- udp_header_t * udp0 = NULL;
- udp_header_t * udp1 = NULL;
- udp_header_t * udp2 = NULL;
- udp_header_t * udp3 = NULL;
-
- ip46_address_set_ip4(&src0, &((ip4_header_t *)outer_ptr0)->src_address);
- ip46_address_set_ip4(&dst0, &((ip4_header_t *)outer_ptr0)->dst_address);
- udp0 = (udp_header_t *)(outer_ptr0 + sizeof(ip4_header_t));
- next0 = v0 == 0x40? UDP4_DECAP_NEXT_LOOKUP_IP4 : UDP4_DECAP_NEXT_LOOKUP_IP6;
-
- ip46_address_set_ip4(&src1, &((ip4_header_t *)outer_ptr1)->src_address);
- ip46_address_set_ip4(&dst1, &((ip4_header_t *)outer_ptr1)->dst_address);
- udp1 = (udp_header_t *)(outer_ptr1 + sizeof(ip4_header_t));
- next1 = v1 == 0x40? UDP4_DECAP_NEXT_LOOKUP_IP4 : UDP4_DECAP_NEXT_LOOKUP_IP6;
-
- ip46_address_set_ip4(&src2, &((ip4_header_t *)outer_ptr2)->src_address);
- ip46_address_set_ip4(&dst2, &((ip4_header_t *)outer_ptr2)->dst_address);
- udp2 = (udp_header_t *)(outer_ptr2 + sizeof(ip4_header_t));
- next2 = v2 == 0x40? UDP4_DECAP_NEXT_LOOKUP_IP4 : UDP4_DECAP_NEXT_LOOKUP_IP6;
-
- ip46_address_set_ip4(&src3, &((ip4_header_t *)outer_ptr3)->src_address);
- ip46_address_set_ip4(&dst3, &((ip4_header_t *)outer_ptr3)->dst_address);
- udp3 = (udp_header_t *)(outer_ptr3 + sizeof(ip4_header_t));
- next3 = v3 == 0x40? UDP4_DECAP_NEXT_LOOKUP_IP4 : UDP4_DECAP_NEXT_LOOKUP_IP6;
-
- hicn_buffer_t *hicnb0, *hicnb1, *hicnb2, *hicnb3;
- hicnb0 = hicn_get_buffer(b0);
- hicnb1 = hicn_get_buffer(b1);
- hicnb2 = hicn_get_buffer(b2);
- hicnb3 = hicn_get_buffer(b3);
-
-
- /* Udp encap-decap tunnels have dst and src addresses and port swapped */
- vnet_buffer (b0)->ip.adj_index[VLIB_RX] = udp_tunnel_get(&dst0, &src0, udp0->dst_port, udp0->src_port);
- vnet_buffer (b1)->ip.adj_index[VLIB_RX] = udp_tunnel_get(&dst1, &src1, udp1->dst_port, udp1->src_port);
- vnet_buffer (b2)->ip.adj_index[VLIB_RX] = udp_tunnel_get(&dst2, &src2, udp2->dst_port, udp2->src_port);
- vnet_buffer (b3)->ip.adj_index[VLIB_RX] = udp_tunnel_get(&dst3, &src3, udp3->dst_port, udp3->src_port);
-
- if (vnet_buffer (b0)->ip.adj_index[VLIB_RX] !=
- UDP_TUNNEL_INVALID)
- hicnb0->flags |= (outer_v0 == 0x40? HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL : HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL);
-
- if (vnet_buffer (b1)->ip.adj_index[VLIB_RX] !=
- UDP_TUNNEL_INVALID)
- hicnb1->flags |= (outer_v1 == 0x40? HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL : HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL);
-
- if (vnet_buffer (b2)->ip.adj_index[VLIB_RX] !=
- UDP_TUNNEL_INVALID)
- hicnb2->flags |= (outer_v2 == 0x40? HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL : HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL);
-
- if (vnet_buffer (b3)->ip.adj_index[VLIB_RX] !=
- UDP_TUNNEL_INVALID)
- hicnb3->flags |= (outer_v3 == 0x40? HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL : HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL);
-
- udp_decap_trace_buffer (vm, node, 1, b0);
- udp_decap_trace_buffer (vm, node, 1, b1);
- udp_decap_trace_buffer (vm, node, 1, b2);
- udp_decap_trace_buffer (vm, node, 1, b3);
-
- vlib_buffer_advance(b0, advance);
- vlib_buffer_advance(b1, advance);
- vlib_buffer_advance(b2, advance);
- vlib_buffer_advance(b3, advance);
-
- vlib_validate_buffer_enqueue_x4 (vm, node, next_index, to_next,
+ ip46_address_t src0 = { 0 };
+ ip46_address_t src1 = { 0 };
+ ip46_address_t src2 = { 0 };
+ ip46_address_t src3 = { 0 };
+
+ ip46_address_t dst0 = { 0 };
+ ip46_address_t dst1 = { 0 };
+ ip46_address_t dst2 = { 0 };
+ ip46_address_t dst3 = { 0 };
+
+ udp_header_t *udp0 = NULL;
+ udp_header_t *udp1 = NULL;
+ udp_header_t *udp2 = NULL;
+ udp_header_t *udp3 = NULL;
+
+ ip46_address_set_ip4 (&src0,
+ &((ip4_header_t *) outer_ptr0)->src_address);
+ ip46_address_set_ip4 (&dst0,
+ &((ip4_header_t *) outer_ptr0)->dst_address);
+ udp0 = (udp_header_t *) (outer_ptr0 + sizeof (ip4_header_t));
+ next0 = v0 == 0x40 ? UDP4_DECAP_NEXT_LOOKUP_IP4 :
+ UDP4_DECAP_NEXT_LOOKUP_IP6;
+
+ ip46_address_set_ip4 (&src1,
+ &((ip4_header_t *) outer_ptr1)->src_address);
+ ip46_address_set_ip4 (&dst1,
+ &((ip4_header_t *) outer_ptr1)->dst_address);
+ udp1 = (udp_header_t *) (outer_ptr1 + sizeof (ip4_header_t));
+ next1 = v1 == 0x40 ? UDP4_DECAP_NEXT_LOOKUP_IP4 :
+ UDP4_DECAP_NEXT_LOOKUP_IP6;
+
+ ip46_address_set_ip4 (&src2,
+ &((ip4_header_t *) outer_ptr2)->src_address);
+ ip46_address_set_ip4 (&dst2,
+ &((ip4_header_t *) outer_ptr2)->dst_address);
+ udp2 = (udp_header_t *) (outer_ptr2 + sizeof (ip4_header_t));
+ next2 = v2 == 0x40 ? UDP4_DECAP_NEXT_LOOKUP_IP4 :
+ UDP4_DECAP_NEXT_LOOKUP_IP6;
+
+ ip46_address_set_ip4 (&src3,
+ &((ip4_header_t *) outer_ptr3)->src_address);
+ ip46_address_set_ip4 (&dst3,
+ &((ip4_header_t *) outer_ptr3)->dst_address);
+ udp3 = (udp_header_t *) (outer_ptr3 + sizeof (ip4_header_t));
+ next3 = v3 == 0x40 ? UDP4_DECAP_NEXT_LOOKUP_IP4 :
+ UDP4_DECAP_NEXT_LOOKUP_IP6;
+
+ hicn_buffer_t *hicnb0, *hicnb1, *hicnb2, *hicnb3;
+ hicnb0 = hicn_get_buffer (b0);
+ hicnb1 = hicn_get_buffer (b1);
+ hicnb2 = hicn_get_buffer (b2);
+ hicnb3 = hicn_get_buffer (b3);
+
+ /* Udp encap-decap tunnels have dst and src addresses and port
+ * swapped */
+ vnet_buffer (b0)->ip.adj_index[VLIB_RX] =
+ udp_tunnel_get (&dst0, &src0, udp0->dst_port, udp0->src_port);
+ vnet_buffer (b1)->ip.adj_index[VLIB_RX] =
+ udp_tunnel_get (&dst1, &src1, udp1->dst_port, udp1->src_port);
+ vnet_buffer (b2)->ip.adj_index[VLIB_RX] =
+ udp_tunnel_get (&dst2, &src2, udp2->dst_port, udp2->src_port);
+ vnet_buffer (b3)->ip.adj_index[VLIB_RX] =
+ udp_tunnel_get (&dst3, &src3, udp3->dst_port, udp3->src_port);
+
+ if (vnet_buffer (b0)->ip.adj_index[VLIB_RX] != UDP_TUNNEL_INVALID)
+ hicnb0->flags |=
+ (outer_v0 == 0x40 ? HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL :
+ HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL);
+
+ if (vnet_buffer (b1)->ip.adj_index[VLIB_RX] != UDP_TUNNEL_INVALID)
+ hicnb1->flags |=
+ (outer_v1 == 0x40 ? HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL :
+ HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL);
+
+ if (vnet_buffer (b2)->ip.adj_index[VLIB_RX] != UDP_TUNNEL_INVALID)
+ hicnb2->flags |=
+ (outer_v2 == 0x40 ? HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL :
+ HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL);
+
+ if (vnet_buffer (b3)->ip.adj_index[VLIB_RX] != UDP_TUNNEL_INVALID)
+ hicnb3->flags |=
+ (outer_v3 == 0x40 ? HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL :
+ HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL);
+
+ udp_decap_trace_buffer (vm, node, 1, b0);
+ udp_decap_trace_buffer (vm, node, 1, b1);
+ udp_decap_trace_buffer (vm, node, 1, b2);
+ udp_decap_trace_buffer (vm, node, 1, b3);
+
+ vlib_buffer_advance (b0, advance);
+ vlib_buffer_advance (b1, advance);
+ vlib_buffer_advance (b2, advance);
+ vlib_buffer_advance (b3, advance);
+
+ vlib_validate_buffer_enqueue_x4 (vm, node, next_index, to_next,
n_left_to_next, bi0, bi1, bi2, bi3,
next0, next1, next2, next3);
}
@@ -283,7 +306,7 @@ udp4_decap_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
{
vlib_buffer_t *b0;
u32 bi0;
- /* udp_encap_t *udp_tunnel0 = NULL; */
+ /* udp_encap_t *udp_tunnel0 = NULL; */
u32 next0;
if (n_left_from > 1)
@@ -300,42 +323,47 @@ udp4_decap_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
to_next += 1;
n_left_to_next -= 1;
- b0 = vlib_get_buffer (vm, bi0);
+ b0 = vlib_get_buffer (vm, bi0);
u8 *ptr0 = vlib_buffer_get_current (b0);
u8 v0 = *ptr0 & 0xf0;
- u8 advance = sizeof(ip4_header_t) + sizeof(udp_header_t);;
-
- vlib_buffer_advance(b0, -advance);
+ u8 advance = sizeof (ip4_header_t) + sizeof (udp_header_t);
+ ;
- u8 *outer_ptr0 = vlib_buffer_get_current (b0);
- u8 outer_v0 = *outer_ptr0 & 0xf0;
+ vlib_buffer_advance (b0, -advance);
- ip46_address_t src0 = {0};
- ip46_address_t dst0 = {0};
- udp_header_t * udp0 = NULL;
+ u8 *outer_ptr0 = vlib_buffer_get_current (b0);
+ u8 outer_v0 = *outer_ptr0 & 0xf0;
- ip46_address_set_ip4(&src0, &((ip4_header_t *)outer_ptr0)->src_address);
- ip46_address_set_ip4(&dst0, &((ip4_header_t *)outer_ptr0)->dst_address);
- udp0 = (udp_header_t *)(outer_ptr0 + sizeof(ip4_header_t));
- next0 = v0 == 0x40 ? UDP4_DECAP_NEXT_LOOKUP_IP4: UDP4_DECAP_NEXT_LOOKUP_IP6;
+ ip46_address_t src0 = { 0 };
+ ip46_address_t dst0 = { 0 };
+ udp_header_t *udp0 = NULL;
- hicn_buffer_t *hicnb0 = hicn_get_buffer(b0);
+ ip46_address_set_ip4 (&src0,
+ &((ip4_header_t *) outer_ptr0)->src_address);
+ ip46_address_set_ip4 (&dst0,
+ &((ip4_header_t *) outer_ptr0)->dst_address);
+ udp0 = (udp_header_t *) (outer_ptr0 + sizeof (ip4_header_t));
+ next0 = v0 == 0x40 ? UDP4_DECAP_NEXT_LOOKUP_IP4 :
+ UDP4_DECAP_NEXT_LOOKUP_IP6;
- vnet_buffer (b0)->ip.adj_index[VLIB_RX] = udp_tunnel_get(&dst0, &src0, udp0->dst_port, udp0->src_port);
+ hicn_buffer_t *hicnb0 = hicn_get_buffer (b0);
- if (vnet_buffer (b0)->ip.adj_index[VLIB_RX] !=
- UDP_TUNNEL_INVALID)
- hicnb0->flags |= (outer_v0 == 0x40 ? HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL : HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL);
+ vnet_buffer (b0)->ip.adj_index[VLIB_RX] =
+ udp_tunnel_get (&dst0, &src0, udp0->dst_port, udp0->src_port);
- udp_decap_trace_buffer (vm, node, 1, b0);
+ if (vnet_buffer (b0)->ip.adj_index[VLIB_RX] != UDP_TUNNEL_INVALID)
+ hicnb0->flags |=
+ (outer_v0 == 0x40 ? HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL :
+ HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL);
- vlib_buffer_advance(b0, advance);
+ udp_decap_trace_buffer (vm, node, 1, b0);
- vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
- n_left_to_next, bi0, next0);
+ vlib_buffer_advance (b0, advance);
+ vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
+ n_left_to_next, bi0, next0);
}
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}
@@ -343,33 +371,26 @@ udp4_decap_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
return (frame->n_vectors);
}
-
/*
* Node registration for the interest forwarder node
*/
-/* *INDENT-OFF* */
-VLIB_REGISTER_NODE(udp4_decap_node) =
-{
+VLIB_REGISTER_NODE (udp4_decap_node) = {
.function = udp4_decap_node_fn,
.name = "udp4-decap",
- .vector_size = sizeof(u32),
+ .vector_size = sizeof (u32),
.format_trace = format_udp_decap_trace,
.type = VLIB_NODE_TYPE_INTERNAL,
- .n_errors = ARRAY_LEN(udp_decap_error_strings),
+ .n_errors = ARRAY_LEN (udp_decap_error_strings),
.error_strings = udp_decap_error_strings,
.n_next_nodes = UDP4_DECAP_N_NEXT,
/* edit / add dispositions here */
- .next_nodes =
- {
- [UDP4_DECAP_NEXT_LOOKUP_IP4] = "ip4-lookup",
- [UDP4_DECAP_NEXT_LOOKUP_IP6] = "ip6-lookup"
- },
+ .next_nodes = { [UDP4_DECAP_NEXT_LOOKUP_IP4] = "ip4-lookup",
+ [UDP4_DECAP_NEXT_LOOKUP_IP6] = "ip6-lookup" },
};
-/* *INDENT-ON* */
static uword
-udp6_decap_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
- vlib_frame_t * frame)
+udp6_decap_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
+ vlib_frame_t *frame)
{
u32 n_left_from, *from, *to_next, next_index;
@@ -385,11 +406,11 @@ udp6_decap_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
/* Dual loop, X2 */
while (n_left_from >= 8 && n_left_to_next >= 4)
{
- vlib_buffer_t *b0, *b1, *b2, *b3;
+ vlib_buffer_t *b0, *b1, *b2, *b3;
u32 bi0, bi1, bi2, bi3;
u32 next0, next1, next2, next3;
- {
+ {
vlib_buffer_t *b4, *b5, *b6, *b7;
b4 = vlib_get_buffer (vm, from[4]);
b5 = vlib_get_buffer (vm, from[5]);
@@ -422,105 +443,125 @@ udp6_decap_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
b3 = vlib_get_buffer (vm, bi3);
u8 *ptr0 = vlib_buffer_get_current (b0);
- u8 *ptr1 = vlib_buffer_get_current (b1);
- u8 *ptr2 = vlib_buffer_get_current (b2);
- u8 *ptr3 = vlib_buffer_get_current (b3);
+ u8 *ptr1 = vlib_buffer_get_current (b1);
+ u8 *ptr2 = vlib_buffer_get_current (b2);
+ u8 *ptr3 = vlib_buffer_get_current (b3);
u8 v0 = *ptr0 & 0xf0;
u8 v1 = *ptr1 & 0xf0;
u8 v2 = *ptr2 & 0xf0;
u8 v3 = *ptr3 & 0xf0;
- u8 advance = sizeof(ip6_header_t) + sizeof(udp_header_t);
+ u8 advance = sizeof (ip6_header_t) + sizeof (udp_header_t);
- vlib_buffer_advance(b0, -advance);
- vlib_buffer_advance(b1, -advance);
- vlib_buffer_advance(b2, -advance);
- vlib_buffer_advance(b3, -advance);
+ vlib_buffer_advance (b0, -advance);
+ vlib_buffer_advance (b1, -advance);
+ vlib_buffer_advance (b2, -advance);
+ vlib_buffer_advance (b3, -advance);
- u8 *outer_ptr0 = vlib_buffer_get_current (b0);
- u8 *outer_ptr1 = vlib_buffer_get_current (b1);
- u8 *outer_ptr2 = vlib_buffer_get_current (b2);
- u8 *outer_ptr3 = vlib_buffer_get_current (b3);
- u8 outer_v0 = *outer_ptr0 & 0xf0;
+ u8 *outer_ptr0 = vlib_buffer_get_current (b0);
+ u8 *outer_ptr1 = vlib_buffer_get_current (b1);
+ u8 *outer_ptr2 = vlib_buffer_get_current (b2);
+ u8 *outer_ptr3 = vlib_buffer_get_current (b3);
+ u8 outer_v0 = *outer_ptr0 & 0xf0;
u8 outer_v1 = *outer_ptr1 & 0xf0;
u8 outer_v2 = *outer_ptr2 & 0xf0;
u8 outer_v3 = *outer_ptr3 & 0xf0;
- ip46_address_t src0 = {0};
- ip46_address_t src1 = {0};
- ip46_address_t src2 = {0};
- ip46_address_t src3 = {0};
-
- ip46_address_t dst0 = {0};
- ip46_address_t dst1 = {0};
- ip46_address_t dst2 = {0};
- ip46_address_t dst3 = {0};
-
- udp_header_t * udp0 = NULL;
- udp_header_t * udp1 = NULL;
- udp_header_t * udp2 = NULL;
- udp_header_t * udp3 = NULL;
-
- ip46_address_set_ip6(&src0, &((ip6_header_t *)outer_ptr0)->src_address);
- ip46_address_set_ip6(&dst0, &((ip6_header_t *)outer_ptr0)->dst_address);
- udp0 = (udp_header_t *)(outer_ptr0 + sizeof(ip6_header_t));
- next0 = v0 == 0x40 ? UDP6_DECAP_NEXT_LOOKUP_IP4 : UDP6_DECAP_NEXT_LOOKUP_IP6;
-
- ip46_address_set_ip6(&src1, &((ip6_header_t *)outer_ptr1)->src_address);
- ip46_address_set_ip6(&dst1, &((ip6_header_t *)outer_ptr1)->dst_address);
- udp1 = (udp_header_t *)(outer_ptr1 + sizeof(ip6_header_t));
- next1 = v1 == 0x40 ? UDP6_DECAP_NEXT_LOOKUP_IP4 : UDP6_DECAP_NEXT_LOOKUP_IP6;
-
- ip46_address_set_ip6(&src2, &((ip6_header_t *)outer_ptr2)->src_address);
- ip46_address_set_ip6(&dst2, &((ip6_header_t *)outer_ptr2)->dst_address);
- udp2 = (udp_header_t *)(outer_ptr2 + sizeof(ip6_header_t));
- next2 = v2 == 0x40 ? UDP6_DECAP_NEXT_LOOKUP_IP4 : UDP6_DECAP_NEXT_LOOKUP_IP6;
-
- ip46_address_set_ip6(&src3, &((ip6_header_t *)outer_ptr3)->src_address);
- ip46_address_set_ip6(&dst3, &((ip6_header_t *)outer_ptr3)->dst_address);
- udp3 = (udp_header_t *)(outer_ptr3 + sizeof(ip6_header_t));
- next3 = v3 == 0x40 ? UDP6_DECAP_NEXT_LOOKUP_IP4 : UDP6_DECAP_NEXT_LOOKUP_IP6;
-
- hicn_buffer_t *hicnb0, *hicnb1, *hicnb2, *hicnb3;
- hicnb0 = hicn_get_buffer(b0);
- hicnb1 = hicn_get_buffer(b1);
- hicnb2 = hicn_get_buffer(b2);
- hicnb3 = hicn_get_buffer(b3);
-
-
- /* Udp encap-decap tunnels have dst and src addresses and port swapped */
- vnet_buffer (b0)->ip.adj_index[VLIB_RX] = udp_tunnel_get(&dst0, &src0, udp0->dst_port, udp0->src_port);
- vnet_buffer (b1)->ip.adj_index[VLIB_RX] = udp_tunnel_get(&dst1, &src1, udp1->dst_port, udp1->src_port);
- vnet_buffer (b2)->ip.adj_index[VLIB_RX] = udp_tunnel_get(&dst2, &src2, udp2->dst_port, udp2->src_port);
- vnet_buffer (b3)->ip.adj_index[VLIB_RX] = udp_tunnel_get(&dst3, &src3, udp3->dst_port, udp3->src_port);
-
- if (vnet_buffer (b0)->ip.adj_index[VLIB_RX] !=
- UDP_TUNNEL_INVALID)
- hicnb0->flags |= (outer_v0 == 0x40? HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL : HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL);
-
- if (vnet_buffer (b1)->ip.adj_index[VLIB_RX] !=
- UDP_TUNNEL_INVALID)
- hicnb1->flags |= (outer_v1 == 0x40? HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL : HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL);
-
- if (vnet_buffer (b2)->ip.adj_index[VLIB_RX] !=
- UDP_TUNNEL_INVALID)
- hicnb2->flags |= (outer_v2 == 0x40? HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL : HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL);
-
- if (vnet_buffer (b3)->ip.adj_index[VLIB_RX] !=
- UDP_TUNNEL_INVALID)
- hicnb3->flags |= (outer_v3 == 0x40? HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL : HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL);
-
- udp_decap_trace_buffer (vm, node, 0, b0);
- udp_decap_trace_buffer (vm, node, 0, b1);
- udp_decap_trace_buffer (vm, node, 0, b2);
- udp_decap_trace_buffer (vm, node, 0, b3);
-
- vlib_buffer_advance(b0, advance);
- vlib_buffer_advance(b1, advance);
- vlib_buffer_advance(b2, advance);
- vlib_buffer_advance(b3, advance);
-
- vlib_validate_buffer_enqueue_x4 (vm, node, next_index, to_next,
+ ip46_address_t src0 = { 0 };
+ ip46_address_t src1 = { 0 };
+ ip46_address_t src2 = { 0 };
+ ip46_address_t src3 = { 0 };
+
+ ip46_address_t dst0 = { 0 };
+ ip46_address_t dst1 = { 0 };
+ ip46_address_t dst2 = { 0 };
+ ip46_address_t dst3 = { 0 };
+
+ udp_header_t *udp0 = NULL;
+ udp_header_t *udp1 = NULL;
+ udp_header_t *udp2 = NULL;
+ udp_header_t *udp3 = NULL;
+
+ ip46_address_set_ip6 (&src0,
+ &((ip6_header_t *) outer_ptr0)->src_address);
+ ip46_address_set_ip6 (&dst0,
+ &((ip6_header_t *) outer_ptr0)->dst_address);
+ udp0 = (udp_header_t *) (outer_ptr0 + sizeof (ip6_header_t));
+ next0 = v0 == 0x40 ? UDP6_DECAP_NEXT_LOOKUP_IP4 :
+ UDP6_DECAP_NEXT_LOOKUP_IP6;
+
+ ip46_address_set_ip6 (&src1,
+ &((ip6_header_t *) outer_ptr1)->src_address);
+ ip46_address_set_ip6 (&dst1,
+ &((ip6_header_t *) outer_ptr1)->dst_address);
+ udp1 = (udp_header_t *) (outer_ptr1 + sizeof (ip6_header_t));
+ next1 = v1 == 0x40 ? UDP6_DECAP_NEXT_LOOKUP_IP4 :
+ UDP6_DECAP_NEXT_LOOKUP_IP6;
+
+ ip46_address_set_ip6 (&src2,
+ &((ip6_header_t *) outer_ptr2)->src_address);
+ ip46_address_set_ip6 (&dst2,
+ &((ip6_header_t *) outer_ptr2)->dst_address);
+ udp2 = (udp_header_t *) (outer_ptr2 + sizeof (ip6_header_t));
+ next2 = v2 == 0x40 ? UDP6_DECAP_NEXT_LOOKUP_IP4 :
+ UDP6_DECAP_NEXT_LOOKUP_IP6;
+
+ ip46_address_set_ip6 (&src3,
+ &((ip6_header_t *) outer_ptr3)->src_address);
+ ip46_address_set_ip6 (&dst3,
+ &((ip6_header_t *) outer_ptr3)->dst_address);
+ udp3 = (udp_header_t *) (outer_ptr3 + sizeof (ip6_header_t));
+ next3 = v3 == 0x40 ? UDP6_DECAP_NEXT_LOOKUP_IP4 :
+ UDP6_DECAP_NEXT_LOOKUP_IP6;
+
+ hicn_buffer_t *hicnb0, *hicnb1, *hicnb2, *hicnb3;
+ hicnb0 = hicn_get_buffer (b0);
+ hicnb1 = hicn_get_buffer (b1);
+ hicnb2 = hicn_get_buffer (b2);
+ hicnb3 = hicn_get_buffer (b3);
+
+ /* Udp encap-decap tunnels have dst and src addresses and port
+ * swapped */
+ vnet_buffer (b0)->ip.adj_index[VLIB_RX] =
+ udp_tunnel_get (&dst0, &src0, udp0->dst_port, udp0->src_port);
+ vnet_buffer (b1)->ip.adj_index[VLIB_RX] =
+ udp_tunnel_get (&dst1, &src1, udp1->dst_port, udp1->src_port);
+ vnet_buffer (b2)->ip.adj_index[VLIB_RX] =
+ udp_tunnel_get (&dst2, &src2, udp2->dst_port, udp2->src_port);
+ vnet_buffer (b3)->ip.adj_index[VLIB_RX] =
+ udp_tunnel_get (&dst3, &src3, udp3->dst_port, udp3->src_port);
+
+ if (vnet_buffer (b0)->ip.adj_index[VLIB_RX] != UDP_TUNNEL_INVALID)
+ hicnb0->flags |=
+ (outer_v0 == 0x40 ? HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL :
+ HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL);
+
+ if (vnet_buffer (b1)->ip.adj_index[VLIB_RX] != UDP_TUNNEL_INVALID)
+ hicnb1->flags |=
+ (outer_v1 == 0x40 ? HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL :
+ HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL);
+
+ if (vnet_buffer (b2)->ip.adj_index[VLIB_RX] != UDP_TUNNEL_INVALID)
+ hicnb2->flags |=
+ (outer_v2 == 0x40 ? HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL :
+ HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL);
+
+ if (vnet_buffer (b3)->ip.adj_index[VLIB_RX] != UDP_TUNNEL_INVALID)
+ hicnb3->flags |=
+ (outer_v3 == 0x40 ? HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL :
+ HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL);
+
+ udp_decap_trace_buffer (vm, node, 0, b0);
+ udp_decap_trace_buffer (vm, node, 0, b1);
+ udp_decap_trace_buffer (vm, node, 0, b2);
+ udp_decap_trace_buffer (vm, node, 0, b3);
+
+ vlib_buffer_advance (b0, advance);
+ vlib_buffer_advance (b1, advance);
+ vlib_buffer_advance (b2, advance);
+ vlib_buffer_advance (b3, advance);
+
+ vlib_validate_buffer_enqueue_x4 (vm, node, next_index, to_next,
n_left_to_next, bi0, bi1, bi2, bi3,
next0, next1, next2, next3);
}
@@ -530,7 +571,7 @@ udp6_decap_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
{
vlib_buffer_t *b0;
u32 bi0;
- /* udp_encap_t *udp_tunnel0 = NULL; */
+ /* udp_encap_t *udp_tunnel0 = NULL; */
u32 next0;
if (n_left_from > 1)
@@ -547,42 +588,46 @@ udp6_decap_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
to_next += 1;
n_left_to_next -= 1;
- b0 = vlib_get_buffer (vm, bi0);
+ b0 = vlib_get_buffer (vm, bi0);
u8 *ptr0 = vlib_buffer_get_current (b0);
u8 v0 = *ptr0 & 0xf0;
- u8 advance = sizeof(ip6_header_t) + sizeof(udp_header_t);
+ u8 advance = sizeof (ip6_header_t) + sizeof (udp_header_t);
- vlib_buffer_advance(b0, -advance);
+ vlib_buffer_advance (b0, -advance);
- u8 *outer_ptr0 = vlib_buffer_get_current (b0);
- u8 outer_v0 = *outer_ptr0 & 0xf0;
+ u8 *outer_ptr0 = vlib_buffer_get_current (b0);
+ u8 outer_v0 = *outer_ptr0 & 0xf0;
- ip46_address_t src0 = {0};
- ip46_address_t dst0 = {0};
- udp_header_t * udp0 = NULL;
+ ip46_address_t src0 = { 0 };
+ ip46_address_t dst0 = { 0 };
+ udp_header_t *udp0 = NULL;
- ip46_address_set_ip6(&src0, &((ip6_header_t *)outer_ptr0)->src_address);
- ip46_address_set_ip6(&dst0, &((ip6_header_t *)outer_ptr0)->dst_address);
- udp0 = (udp_header_t *)(outer_ptr0 + sizeof(ip6_header_t));
- next0 = v0 == 0x40? UDP6_DECAP_NEXT_LOOKUP_IP4 : UDP6_DECAP_NEXT_LOOKUP_IP6;
+ ip46_address_set_ip6 (&src0,
+ &((ip6_header_t *) outer_ptr0)->src_address);
+ ip46_address_set_ip6 (&dst0,
+ &((ip6_header_t *) outer_ptr0)->dst_address);
+ udp0 = (udp_header_t *) (outer_ptr0 + sizeof (ip6_header_t));
+ next0 = v0 == 0x40 ? UDP6_DECAP_NEXT_LOOKUP_IP4 :
+ UDP6_DECAP_NEXT_LOOKUP_IP6;
- hicn_buffer_t *hicnb0 = hicn_get_buffer(b0);
+ hicn_buffer_t *hicnb0 = hicn_get_buffer (b0);
- vnet_buffer (b0)->ip.adj_index[VLIB_RX] = udp_tunnel_get(&dst0, &src0, udp0->dst_port, udp0->src_port);
+ vnet_buffer (b0)->ip.adj_index[VLIB_RX] =
+ udp_tunnel_get (&dst0, &src0, udp0->dst_port, udp0->src_port);
- if (vnet_buffer (b0)->ip.adj_index[VLIB_RX] !=
- UDP_TUNNEL_INVALID)
- hicnb0->flags |= (outer_v0 == 0x40? HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL : HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL);
+ if (vnet_buffer (b0)->ip.adj_index[VLIB_RX] != UDP_TUNNEL_INVALID)
+ hicnb0->flags |=
+ (outer_v0 == 0x40 ? HICN_BUFFER_FLAGS_FROM_UDP4_TUNNEL :
+ HICN_BUFFER_FLAGS_FROM_UDP6_TUNNEL);
- udp_decap_trace_buffer (vm, node, 0, b0);
+ udp_decap_trace_buffer (vm, node, 0, b0);
- vlib_buffer_advance(b0, advance);
-
- vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
- n_left_to_next, bi0, next0);
+ vlib_buffer_advance (b0, advance);
+ vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
+ n_left_to_next, bi0, next0);
}
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}
@@ -590,29 +635,22 @@ udp6_decap_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
return (frame->n_vectors);
}
-
/*
* Node registration for the interest forwarder node
*/
-/* *INDENT-OFF* */
-VLIB_REGISTER_NODE(udp6_decap_node) =
-{
+VLIB_REGISTER_NODE (udp6_decap_node) = {
.function = udp6_decap_node_fn,
.name = "udp6-decap",
- .vector_size = sizeof(u32),
+ .vector_size = sizeof (u32),
.format_trace = format_udp_decap_trace,
.type = VLIB_NODE_TYPE_INTERNAL,
- .n_errors = ARRAY_LEN(udp_decap_error_strings),
+ .n_errors = ARRAY_LEN (udp_decap_error_strings),
.error_strings = udp_decap_error_strings,
.n_next_nodes = UDP6_DECAP_N_NEXT,
/* edit / add dispositions here */
- .next_nodes =
- {
- [UDP6_DECAP_NEXT_LOOKUP_IP4] = "ip4-lookup",
- [UDP6_DECAP_NEXT_LOOKUP_IP6] = "ip6-lookup"
- },
+ .next_nodes = { [UDP6_DECAP_NEXT_LOOKUP_IP4] = "ip4-lookup",
+ [UDP6_DECAP_NEXT_LOOKUP_IP6] = "ip6-lookup" },
};
-/* *INDENT-ON* */
/*
* fd.io coding-style-patch-verification: ON
diff --git a/hicn-plugin/src/udp_tunnels/udp_tunnel.c b/hicn-plugin/src/udp_tunnels/udp_tunnel.c
index 872e4cd82..58694d8e9 100644
--- a/hicn-plugin/src/udp_tunnels/udp_tunnel.c
+++ b/hicn-plugin/src/udp_tunnels/udp_tunnel.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020 Cisco and/or its affiliates.
+ * Copyright (c) 2020-2021 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -25,63 +25,67 @@ clib_bihash_40_8_t udp_tunnels_hashtb;
dpo_type_t dpo_type_udp_ip4;
dpo_type_t dpo_type_udp_ip6;
-u32 udp_tunnel_add (fib_protocol_t proto,
- index_t fib_index,
- const ip46_address_t * src_ip,
- const ip46_address_t * dst_ip,
- u16 src_port,
- u16 dst_port,
- udp_encap_fixup_flags_t flags)
+u32
+udp_tunnel_add (fib_protocol_t proto, index_t fib_index,
+ const ip46_address_t *src_ip, const ip46_address_t *dst_ip,
+ u16 src_port, u16 dst_port, udp_encap_fixup_flags_t flags)
{
- vlib_main_t *vm = vlib_get_main();
+ vlib_main_t *vm = vlib_get_main ();
clib_bihash_kv_40_8_t kv;
- clib_memcpy(&kv.key[0], src_ip, sizeof(ip46_address_t));
- clib_memcpy(&kv.key[2], dst_ip, sizeof(ip46_address_t));
- kv.key[4] = (clib_host_to_net_u16(src_port) << 16) + clib_host_to_net_u16(dst_port);
+ clib_memcpy (&kv.key[0], src_ip, sizeof (ip46_address_t));
+ clib_memcpy (&kv.key[2], dst_ip, sizeof (ip46_address_t));
+ kv.key[4] =
+ (clib_host_to_net_u16 (src_port) << 16) + clib_host_to_net_u16 (dst_port);
clib_bihash_kv_40_8_t value;
int rv = clib_bihash_search_40_8 (&udp_tunnels_hashtb, &kv, &value);
if (rv != 0)
{
- u32 uei = udp_encap_add_and_lock(proto, fib_index, src_ip, dst_ip, src_port, dst_port, flags);
+ u32 uei = udp_encap_add_and_lock (proto, fib_index, src_ip, dst_ip,
+ src_port, dst_port, flags);
kv.value = uei;
- clib_bihash_add_del_40_8(&udp_tunnels_hashtb, &kv, 1);
+ clib_bihash_add_del_40_8 (&udp_tunnels_hashtb, &kv, 1);
value.value = kv.value;
if (proto == FIB_PROTOCOL_IP4)
- {
- udp_register_dst_port(vm, src_port, udp4_decap_node.index, 1);
- }
+ {
+ udp_register_dst_port (vm, src_port, udp4_decap_node.index, 1);
+ }
else
- {
- udp_register_dst_port(vm, src_port, udp6_decap_node.index, 0);
- }
+ {
+ udp_register_dst_port (vm, src_port, udp6_decap_node.index, 0);
+ }
}
return value.value;
}
-void udp_tunnel_add_existing (index_t uei, dpo_proto_t proto)
+void
+udp_tunnel_add_existing (index_t uei, dpo_proto_t proto)
{
- vlib_main_t *vm = vlib_get_main();
- udp_encap_t * udp_encap = udp_encap_get(uei);
+ vlib_main_t *vm = vlib_get_main ();
+ udp_encap_t *udp_encap = udp_encap_get (uei);
clib_bihash_kv_40_8_t kv;
- ip46_address_t src = {0};
- ip46_address_t dst = {0};
+ ip46_address_t src = { 0 };
+ ip46_address_t dst = { 0 };
u16 src_port = 0, dst_port = 0;
switch (proto)
{
case DPO_PROTO_IP4:
- ip46_address_set_ip4(&src, &(udp_encap->ue_hdrs.ip4.ue_ip4.src_address));
- ip46_address_set_ip4(&dst, &(udp_encap->ue_hdrs.ip4.ue_ip4.dst_address));
+ ip46_address_set_ip4 (&src,
+ &(udp_encap->ue_hdrs.ip4.ue_ip4.src_address));
+ ip46_address_set_ip4 (&dst,
+ &(udp_encap->ue_hdrs.ip4.ue_ip4.dst_address));
src_port = udp_encap->ue_hdrs.ip4.ue_udp.src_port;
dst_port = udp_encap->ue_hdrs.ip4.ue_udp.dst_port;
break;
case DPO_PROTO_IP6:
- ip46_address_set_ip6(&src, &(udp_encap->ue_hdrs.ip6.ue_ip6.src_address));
- ip46_address_set_ip6(&dst, &(udp_encap->ue_hdrs.ip6.ue_ip6.dst_address));
+ ip46_address_set_ip6 (&src,
+ &(udp_encap->ue_hdrs.ip6.ue_ip6.src_address));
+ ip46_address_set_ip6 (&dst,
+ &(udp_encap->ue_hdrs.ip6.ue_ip6.dst_address));
src_port = udp_encap->ue_hdrs.ip6.ue_udp.src_port;
dst_port = udp_encap->ue_hdrs.ip6.ue_udp.dst_port;
break;
@@ -89,43 +93,43 @@ void udp_tunnel_add_existing (index_t uei, dpo_proto_t proto)
break;
}
- clib_memcpy(&kv.key[0], &src, sizeof(ip46_address_t));
- clib_memcpy(&kv.key[2], &dst, sizeof(ip46_address_t));
- kv.key[4] = (src_port << 16) + dst_port ;
+ clib_memcpy (&kv.key[0], &src, sizeof (ip46_address_t));
+ clib_memcpy (&kv.key[2], &dst, sizeof (ip46_address_t));
+ kv.key[4] = (src_port << 16) + dst_port;
kv.value = uei;
- clib_bihash_add_del_40_8(&udp_tunnels_hashtb, &kv, 1);
+ clib_bihash_add_del_40_8 (&udp_tunnels_hashtb, &kv, 1);
if (proto == DPO_PROTO_IP4)
{
- udp_register_dst_port(vm, clib_net_to_host_u16(src_port), udp4_decap_node.index, 1);
+ udp_register_dst_port (vm, clib_net_to_host_u16 (src_port),
+ udp4_decap_node.index, 1);
}
else
{
- udp_register_dst_port(vm, clib_net_to_host_u16(src_port), udp6_decap_node.index, 0);
+ udp_register_dst_port (vm, clib_net_to_host_u16 (src_port),
+ udp6_decap_node.index, 0);
}
}
-int udp_tunnel_del (fib_protocol_t proto,
- index_t fib_index,
- const ip46_address_t * src_ip,
- const ip46_address_t * dst_ip,
- u16 src_port,
- u16 dst_port,
- udp_encap_fixup_flags_t flags)
+int
+udp_tunnel_del (fib_protocol_t proto, index_t fib_index,
+ const ip46_address_t *src_ip, const ip46_address_t *dst_ip,
+ u16 src_port, u16 dst_port, udp_encap_fixup_flags_t flags)
{
clib_bihash_kv_40_8_t kv;
- clib_memcpy(&kv.key[0], src_ip, sizeof(ip46_address_t));
- clib_memcpy(&kv.key[2], dst_ip, sizeof(ip46_address_t));
- kv.key[4] = (clib_host_to_net_u16(src_port) << 16) + clib_host_to_net_u16(dst_port);
+ clib_memcpy (&kv.key[0], src_ip, sizeof (ip46_address_t));
+ clib_memcpy (&kv.key[2], dst_ip, sizeof (ip46_address_t));
+ kv.key[4] =
+ (clib_host_to_net_u16 (src_port) << 16) + clib_host_to_net_u16 (dst_port);
clib_bihash_kv_40_8_t value;
int ret = clib_bihash_search_40_8 (&udp_tunnels_hashtb, &kv, &value);
if (ret == 0)
{
- udp_encap_unlock((u32)value.value);
- clib_bihash_add_del_40_8(&udp_tunnels_hashtb, &kv, 0);
+ udp_encap_unlock ((u32) value.value);
+ clib_bihash_add_del_40_8 (&udp_tunnels_hashtb, &kv, 0);
ret = HICN_ERROR_NONE;
}
else
@@ -136,62 +140,62 @@ int udp_tunnel_del (fib_protocol_t proto,
return ret;
}
-u32 udp_tunnel_get(const ip46_address_t * src_ip,
- const ip46_address_t * dst_ip,
- u16 src_port,
- u16 dst_port)
+u32
+udp_tunnel_get (const ip46_address_t *src_ip, const ip46_address_t *dst_ip,
+ u16 src_port, u16 dst_port)
{
clib_bihash_kv_40_8_t kv;
- clib_memcpy(&kv.key[0], src_ip, sizeof(ip46_address_t));
- clib_memcpy(&kv.key[2], dst_ip, sizeof(ip46_address_t));
+ clib_memcpy (&kv.key[0], src_ip, sizeof (ip46_address_t));
+ clib_memcpy (&kv.key[2], dst_ip, sizeof (ip46_address_t));
kv.key[4] = (src_port << 16) + dst_port;
clib_bihash_kv_40_8_t value;
int ret = clib_bihash_search_40_8 (&udp_tunnels_hashtb, &kv, &value);
- return ret == 0 ? (u32)value.value : UDP_TUNNEL_INVALID;
+ return ret == 0 ? (u32) value.value : UDP_TUNNEL_INVALID;
}
-
-void udp_tunnel_init()
+void
+udp_tunnel_init ()
{
- clib_bihash_init_40_8(&udp_tunnels_hashtb, "udp encap table",
- 2048, 256 << 20);
+ clib_bihash_init_40_8 (&udp_tunnels_hashtb, "udp encap table", 2048,
+ 256 << 20);
/*
* Udp encap does not expose the dpo type when it registers.
* In the following we understand what is the dpo type for a udp_encap dpo.
*/
- ip46_address_t src = {0};
- ip46_address_t dst = {0};
+ ip46_address_t src = { 0 };
+ ip46_address_t dst = { 0 };
src.ip6.as_u8[15] = 1;
dst.ip6.as_u8[15] = 2;
u32 fib_index = fib_table_find (FIB_PROTOCOL_IP6, HICN_FIB_TABLE);
- u32 uei = udp_encap_add_and_lock(FIB_PROTOCOL_IP6, fib_index, &src, &dst, 4444, 4444, UDP_ENCAP_FIXUP_NONE);
+ u32 uei = udp_encap_add_and_lock (FIB_PROTOCOL_IP6, fib_index, &src, &dst,
+ 4444, 4444, UDP_ENCAP_FIXUP_NONE);
dpo_id_t temp = DPO_INVALID;
- udp_encap_contribute_forwarding(uei, DPO_PROTO_IP6, &temp);
+ udp_encap_contribute_forwarding (uei, DPO_PROTO_IP6, &temp);
dpo_type_udp_ip6 = temp.dpoi_type;
- udp_encap_unlock(uei);
+ udp_encap_unlock (uei);
dpo_id_t temp2 = DPO_INVALID;
fib_index = fib_table_find (FIB_PROTOCOL_IP4, HICN_FIB_TABLE);
- uei = udp_encap_add_and_lock(FIB_PROTOCOL_IP4, fib_index, &src, &dst, 4444, 4444, UDP_ENCAP_FIXUP_NONE);
- udp_encap_contribute_forwarding(uei, DPO_PROTO_IP4, &temp2);
+ uei = udp_encap_add_and_lock (FIB_PROTOCOL_IP4, fib_index, &src, &dst, 4444,
+ 4444, UDP_ENCAP_FIXUP_NONE);
+ udp_encap_contribute_forwarding (uei, DPO_PROTO_IP4, &temp2);
dpo_type_udp_ip4 = temp2.dpoi_type;
- udp_encap_unlock(uei);
+ udp_encap_unlock (uei);
}
static clib_error_t *
-udp_tunnel_command_fn (vlib_main_t * vm,
- unformat_input_t * main_input,
- vlib_cli_command_t * cmd)
+udp_tunnel_command_fn (vlib_main_t *vm, unformat_input_t *main_input,
+ vlib_cli_command_t *cmd)
{
unformat_input_t _line_input, *line_input = &_line_input;
clib_error_t *error = NULL;
- ip46_address_t src_ip = {0}, dst_ip = {0};
+ ip46_address_t src_ip = { 0 }, dst_ip = { 0 };
u32 table_id, src_port, dst_port;
fib_protocol_t fproto;
u8 is_del;
@@ -207,29 +211,27 @@ udp_tunnel_command_fn (vlib_main_t * vm,
{
while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
{
- if (unformat (line_input, "index %d", &uei))
- ;
- else if (unformat (line_input, "add"))
- is_del = 0;
- else if (unformat (line_input, "del"))
- is_del = 1;
- else if (unformat (line_input, "%U %U",
- unformat_ip4_address,
- &src_ip.ip4, unformat_ip4_address, &dst_ip.ip4))
- fproto = FIB_PROTOCOL_IP4;
- else if (unformat (line_input, "%U %U",
- unformat_ip6_address,
- &src_ip.ip6, unformat_ip6_address, &dst_ip.ip6))
- fproto = FIB_PROTOCOL_IP6;
- else if (unformat (line_input, "%d %d", &src_port, &dst_port))
- ;
- else if (unformat (line_input, "table-id %d", &table_id))
- ;
- else
- {
- error = unformat_parse_error (line_input);
- goto done;
- }
+ if (unformat (line_input, "index %d", &uei))
+ ;
+ else if (unformat (line_input, "add"))
+ is_del = 0;
+ else if (unformat (line_input, "del"))
+ is_del = 1;
+ else if (unformat (line_input, "%U %U", unformat_ip4_address,
+ &src_ip.ip4, unformat_ip4_address, &dst_ip.ip4))
+ fproto = FIB_PROTOCOL_IP4;
+ else if (unformat (line_input, "%U %U", unformat_ip6_address,
+ &src_ip.ip6, unformat_ip6_address, &dst_ip.ip6))
+ fproto = FIB_PROTOCOL_IP6;
+ else if (unformat (line_input, "%d %d", &src_port, &dst_port))
+ ;
+ else if (unformat (line_input, "table-id %d", &table_id))
+ ;
+ else
+ {
+ error = unformat_parse_error (line_input);
+ goto done;
+ }
}
}
@@ -242,37 +244,35 @@ udp_tunnel_command_fn (vlib_main_t * vm,
if (!is_del && fproto != FIB_PROTOCOL_MAX)
{
- uei = udp_tunnel_add(fproto, fib_index, &src_ip, &dst_ip, src_port, dst_port, UDP_ENCAP_FIXUP_NONE);
+ uei = udp_tunnel_add (fproto, fib_index, &src_ip, &dst_ip, src_port,
+ dst_port, UDP_ENCAP_FIXUP_NONE);
vlib_cli_output (vm, "udp-encap: %d\n", uei);
}
else if (is_del)
{
- int ret = udp_tunnel_del(fproto, fib_index, &src_ip, &dst_ip, src_port, dst_port, UDP_ENCAP_FIXUP_NONE);
- error = (ret == HICN_ERROR_NONE) ? 0 : clib_error_return (0, "%s\n",
- get_error_string
- (ret));
+ int ret = udp_tunnel_del (fproto, fib_index, &src_ip, &dst_ip, src_port,
+ dst_port, UDP_ENCAP_FIXUP_NONE);
+ error = (ret == HICN_ERROR_NONE) ?
+ 0 :
+ clib_error_return (0, "%s\n", get_error_string (ret));
}
else
{
error = clib_error_return (0, "specify some IP addresses");
}
- done:
+done:
unformat_free (line_input);
return error;
-
}
-/* *INDENT-OFF* */
-VLIB_CLI_COMMAND (udp_tunnel_command, static) =
- {
- .path = "udp tunnel",
- .short_help = "udp tunnel [add/del] src_address dst_address src_port dst_port",
- .function = udp_tunnel_command_fn,
- };
-/* *INDENT-ON* */
-
+VLIB_CLI_COMMAND (udp_tunnel_command, static) = {
+ .path = "udp tunnel",
+ .short_help =
+ "udp tunnel [add/del] src_address dst_address src_port dst_port",
+ .function = udp_tunnel_command_fn,
+};
/*
* fd.io coding-style-patch-verification: ON