summaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorKlement Sekera <ksekera@cisco.com>2018-11-30 14:37:03 +0100
committerDave Barach <openvpp@barachs.net>2018-12-04 21:46:13 +0000
commit2e02ba0ddaa8fecbd4b6397787658bd29fcca749 (patch)
tree6b99899860249d2add26424274db3bd7b56099f2 /src/vnet
parent01f3f894fc180060ef8ee1c8b4acb4421d12ebe3 (diff)
ipsec: simplify bumping counters - cosmetic change
Change-Id: Ibb55427ed49d0277854a352922c6c4bb007bf072 Signed-off-by: Klement Sekera <ksekera@cisco.com>
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/ipsec/ah_decrypt.c46
-rw-r--r--src/vnet/ipsec/ah_encrypt.c19
-rw-r--r--src/vnet/ipsec/esp_decrypt.c57
-rw-r--r--src/vnet/ipsec/esp_encrypt.c29
4 files changed, 35 insertions, 116 deletions
diff --git a/src/vnet/ipsec/ah_decrypt.c b/src/vnet/ipsec/ah_decrypt.c
index a2fc07faebf..c8c89028f9d 100644
--- a/src/vnet/ipsec/ah_decrypt.c
+++ b/src/vnet/ipsec/ah_decrypt.c
@@ -158,14 +158,8 @@ ah_decrypt_inline (vlib_main_t * vm,
if (PREDICT_FALSE (rv))
{
- if (is_ip6)
- vlib_node_increment_counter (vm,
- ah6_decrypt_node.index,
- AH_DECRYPT_ERROR_REPLAY, 1);
- else
- vlib_node_increment_counter (vm,
- ah4_decrypt_node.index,
- AH_DECRYPT_ERROR_REPLAY, 1);
+ vlib_node_increment_counter (vm, node->node_index,
+ AH_DECRYPT_ERROR_REPLAY, 1);
goto trace;
}
}
@@ -212,16 +206,9 @@ ah_decrypt_inline (vlib_main_t * vm,
if (PREDICT_FALSE (memcmp (digest, sig, icv_size)))
{
- if (is_ip6)
- vlib_node_increment_counter (vm,
- ah6_decrypt_node.index,
- AH_DECRYPT_ERROR_INTEG_ERROR,
- 1);
- else
- vlib_node_increment_counter (vm,
- ah4_decrypt_node.index,
- AH_DECRYPT_ERROR_INTEG_ERROR,
- 1);
+ vlib_node_increment_counter (vm, node->node_index,
+ AH_DECRYPT_ERROR_INTEG_ERROR,
+ 1);
goto trace;
}
@@ -248,16 +235,9 @@ ah_decrypt_inline (vlib_main_t * vm,
next0 = AH_DECRYPT_NEXT_IP6_INPUT;
else
{
- if (is_ip6)
- vlib_node_increment_counter (vm,
- ah6_decrypt_node.index,
- AH_DECRYPT_ERROR_DECRYPTION_FAILED,
- 1);
- else
- vlib_node_increment_counter (vm,
- ah4_decrypt_node.index,
- AH_DECRYPT_ERROR_DECRYPTION_FAILED,
- 1);
+ vlib_node_increment_counter (vm, node->node_index,
+ AH_DECRYPT_ERROR_DECRYPTION_FAILED,
+ 1);
goto trace;
}
}
@@ -320,14 +300,8 @@ ah_decrypt_inline (vlib_main_t * vm,
}
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}
- if (is_ip6)
- vlib_node_increment_counter (vm, ah6_decrypt_node.index,
- AH_DECRYPT_ERROR_RX_PKTS,
- from_frame->n_vectors);
- else
- vlib_node_increment_counter (vm, ah4_decrypt_node.index,
- AH_DECRYPT_ERROR_RX_PKTS,
- from_frame->n_vectors);
+ vlib_node_increment_counter (vm, node->node_index, AH_DECRYPT_ERROR_RX_PKTS,
+ from_frame->n_vectors);
return from_frame->n_vectors;
}
diff --git a/src/vnet/ipsec/ah_encrypt.c b/src/vnet/ipsec/ah_encrypt.c
index 6529828f0e9..0dc1612db5e 100644
--- a/src/vnet/ipsec/ah_encrypt.c
+++ b/src/vnet/ipsec/ah_encrypt.c
@@ -127,12 +127,8 @@ ah_encrypt_inline (vlib_main_t * vm,
{
clib_warning ("sequence number counter has cycled SPI %u",
sa0->spi);
- if (is_ip6)
- vlib_node_increment_counter (vm, ah6_encrypt_node.index,
- AH_ENCRYPT_ERROR_SEQ_CYCLED, 1);
- else
- vlib_node_increment_counter (vm, ah4_encrypt_node.index,
- AH_ENCRYPT_ERROR_SEQ_CYCLED, 1);
+ vlib_node_increment_counter (vm, node->node_index,
+ AH_ENCRYPT_ERROR_SEQ_CYCLED, 1);
//TODO need to confirm if below is needed
to_next[0] = i_bi0;
to_next += 1;
@@ -314,14 +310,9 @@ ah_encrypt_inline (vlib_main_t * vm,
}
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}
- if (is_ip6)
- vlib_node_increment_counter (vm, ah6_encrypt_node.index,
- AH_ENCRYPT_ERROR_RX_PKTS,
- from_frame->n_vectors);
- else
- vlib_node_increment_counter (vm, ah4_encrypt_node.index,
- AH_ENCRYPT_ERROR_RX_PKTS,
- from_frame->n_vectors);
+ vlib_node_increment_counter (vm, node->node_index,
+ AH_ENCRYPT_ERROR_RX_PKTS,
+ from_frame->n_vectors);
return from_frame->n_vectors;
}
diff --git a/src/vnet/ipsec/esp_decrypt.c b/src/vnet/ipsec/esp_decrypt.c
index 8ef160a4b32..68cb825f23b 100644
--- a/src/vnet/ipsec/esp_decrypt.c
+++ b/src/vnet/ipsec/esp_decrypt.c
@@ -131,14 +131,8 @@ esp_decrypt_inline (vlib_main_t * vm,
if (PREDICT_FALSE (vec_len (empty_buffers) < n_left_from))
{
- if (is_ip6)
- vlib_node_increment_counter (vm, esp6_decrypt_node.index,
- ESP_DECRYPT_ERROR_NO_BUFFER,
- n_left_from);
- else
- vlib_node_increment_counter (vm, esp4_decrypt_node.index,
- ESP_DECRYPT_ERROR_NO_BUFFER,
- n_left_from);
+ vlib_node_increment_counter (vm, node->node_index,
+ ESP_DECRYPT_ERROR_NO_BUFFER, n_left_from);
goto free_buffers_and_exit;
}
@@ -190,14 +184,8 @@ esp_decrypt_inline (vlib_main_t * vm,
if (PREDICT_FALSE (rv))
{
- if (is_ip6)
- vlib_node_increment_counter (vm,
- esp6_decrypt_node.index,
- ESP_DECRYPT_ERROR_REPLAY, 1);
- else
- vlib_node_increment_counter (vm,
- esp4_decrypt_node.index,
- ESP_DECRYPT_ERROR_REPLAY, 1);
+ vlib_node_increment_counter (vm, node->node_index,
+ ESP_DECRYPT_ERROR_REPLAY, 1);
o_bi0 = i_bi0;
to_next[0] = o_bi0;
to_next += 1;
@@ -224,16 +212,9 @@ esp_decrypt_inline (vlib_main_t * vm,
if (PREDICT_FALSE (memcmp (icv, sig, icv_size)))
{
- if (is_ip6)
- vlib_node_increment_counter (vm,
- esp6_decrypt_node.index,
- ESP_DECRYPT_ERROR_INTEG_ERROR,
- 1);
- else
- vlib_node_increment_counter (vm,
- esp4_decrypt_node.index,
- ESP_DECRYPT_ERROR_INTEG_ERROR,
- 1);
+ vlib_node_increment_counter (vm, node->node_index,
+ ESP_DECRYPT_ERROR_INTEG_ERROR,
+ 1);
o_bi0 = i_bi0;
to_next[0] = o_bi0;
to_next += 1;
@@ -329,16 +310,9 @@ esp_decrypt_inline (vlib_main_t * vm,
next0 = ESP_DECRYPT_NEXT_IP6_INPUT;
else
{
- if (is_ip6)
- vlib_node_increment_counter (vm,
- esp6_decrypt_node.index,
- ESP_DECRYPT_ERROR_DECRYPTION_FAILED,
- 1);
- else
- vlib_node_increment_counter (vm,
- esp4_decrypt_node.index,
- ESP_DECRYPT_ERROR_DECRYPTION_FAILED,
- 1);
+ vlib_node_increment_counter (vm, node->node_index,
+ ESP_DECRYPT_ERROR_DECRYPTION_FAILED,
+ 1);
o_b0 = 0;
goto trace;
}
@@ -410,14 +384,9 @@ esp_decrypt_inline (vlib_main_t * vm,
}
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}
- if (is_ip6)
- vlib_node_increment_counter (vm, esp6_decrypt_node.index,
- ESP_DECRYPT_ERROR_RX_PKTS,
- from_frame->n_vectors);
- else
- vlib_node_increment_counter (vm, esp4_decrypt_node.index,
- ESP_DECRYPT_ERROR_RX_PKTS,
- from_frame->n_vectors);
+ vlib_node_increment_counter (vm, node->node_index,
+ ESP_DECRYPT_ERROR_RX_PKTS,
+ from_frame->n_vectors);
free_buffers_and_exit:
diff --git a/src/vnet/ipsec/esp_encrypt.c b/src/vnet/ipsec/esp_encrypt.c
index 101c5efbfc8..4f2d7707395 100644
--- a/src/vnet/ipsec/esp_encrypt.c
+++ b/src/vnet/ipsec/esp_encrypt.c
@@ -137,14 +137,8 @@ esp_encrypt_inline (vlib_main_t * vm,
if (PREDICT_FALSE (vec_len (empty_buffers) < n_left_from))
{
- if (is_ip6)
- vlib_node_increment_counter (vm, esp6_encrypt_node.index,
- ESP_ENCRYPT_ERROR_NO_BUFFER,
- n_left_from);
- else
- vlib_node_increment_counter (vm, esp4_encrypt_node.index,
- ESP_ENCRYPT_ERROR_NO_BUFFER,
- n_left_from);
+ vlib_node_increment_counter (vm, node->node_index,
+ ESP_ENCRYPT_ERROR_NO_BUFFER, n_left_from);
clib_warning ("not enough empty buffers. discarding frame");
goto free_buffers_and_exit;
}
@@ -189,12 +183,8 @@ esp_encrypt_inline (vlib_main_t * vm,
{
clib_warning ("sequence number counter has cycled SPI %u",
sa0->spi);
- if (is_ip6)
- vlib_node_increment_counter (vm, esp6_encrypt_node.index,
- ESP_ENCRYPT_ERROR_SEQ_CYCLED, 1);
- else
- vlib_node_increment_counter (vm, esp4_encrypt_node.index,
- ESP_ENCRYPT_ERROR_SEQ_CYCLED, 1);
+ vlib_node_increment_counter (vm, node->node_index,
+ ESP_ENCRYPT_ERROR_SEQ_CYCLED, 1);
//TODO: rekey SA
o_bi0 = i_bi0;
to_next[0] = o_bi0;
@@ -428,14 +418,9 @@ esp_encrypt_inline (vlib_main_t * vm,
}
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}
- if (is_ip6)
- vlib_node_increment_counter (vm, esp6_encrypt_node.index,
- ESP_ENCRYPT_ERROR_RX_PKTS,
- from_frame->n_vectors);
- else
- vlib_node_increment_counter (vm, esp4_encrypt_node.index,
- ESP_ENCRYPT_ERROR_RX_PKTS,
- from_frame->n_vectors);
+ vlib_node_increment_counter (vm, node->node_index,
+ ESP_ENCRYPT_ERROR_RX_PKTS,
+ from_frame->n_vectors);
free_buffers_and_exit:
if (recycle)
_address, &ip46->ip4)) { ip46_address_mask_ip4(ip46); return 1; } else if ((type != IP46_TYPE_IP4) && unformat(input, "%U", unformat_ip6_address, &ip46->ip6)) { return 1; } return 0; } uword unformat_ip46_prefix (unformat_input_t * input, va_list * args) { ip46_address_t *ip46 = va_arg (*args, ip46_address_t *); u8 *len = va_arg (*args, u8 *); ip46_type_t type = va_arg (*args, ip46_type_t); u32 l; if ((type != IP46_TYPE_IP6) && unformat(input, "%U/%u", unformat_ip4_address, &ip46->ip4, &l)) { if (l > 32) return 0; *len = l + 96; ip46->pad[0] = ip46->pad[1] = ip46->pad[2] = 0; } else if ((type != IP46_TYPE_IP4) && unformat(input, "%U/%u", unformat_ip6_address, &ip46->ip6, &l)) { if (l > 128) return 0; *len = l; } else { return 0; } return 1; } ///////////////////////// #define vl_msg_id(n,h) n, typedef enum { #include <kubeproxy/kp.api.h> /* We'll want to know how many messages IDs we need... */ VL_MSG_FIRST_AVAILABLE, } vl_msg_id_t; #undef vl_msg_id /* define message structures */ #define vl_typedefs #include <kubeproxy/kp.api.h> #undef vl_typedefs /* declare message handlers for each api */ #define vl_endianfun /* define message structures */ #include <kubeproxy/kp.api.h> #undef vl_endianfun /* instantiate all the print functions we know about */ #define vl_print(handle, ...) #define vl_printfun #include <kubeproxy/kp.api.h> #undef vl_printfun /* Get the API version number. */ #define vl_api_version(n,v) static u32 api_version=(v); #include <kubeproxy/kp.api.h> #undef vl_api_version typedef struct { /* API message ID base */ u16 msg_id_base; vat_main_t *vat_main; } kp_test_main_t; kp_test_main_t kp_test_main; #define foreach_standard_reply_retval_handler \ _(kp_conf_reply) \ _(kp_add_del_vip_reply) \ _(kp_add_del_pod_reply) #define _(n) \ static void vl_api_##n##_t_handler \ (vl_api_##n##_t * mp) \ { \ vat_main_t * vam = kp_test_main.vat_main; \ i32 retval = ntohl(mp->retval); \ if (vam->async_mode) { \ vam->async_errors += (retval < 0); \ } else { \ vam->retval = retval; \ vam->result_ready = 1; \ } \ } foreach_standard_reply_retval_handler; #undef _ /* * Table of message reply handlers, must include boilerplate handlers * we just generated */ #define foreach_vpe_api_reply_msg \ _(KP_CONF_REPLY, kp_conf_reply) \ _(KP_ADD_DEL_VIP_REPLY, kp_add_del_vip_reply) \ _(KP_ADD_DEL_POD_REPLY, kp_add_del_pod_reply) static int api_kp_conf (vat_main_t * vam) { unformat_input_t *i = vam->input; vl_api_kp_conf_t mps, *mp; int ret; if (!unformat(i, "%u %u", &mps.sticky_buckets_per_core, &mps.flow_timeout)) { errmsg ("invalid arguments\n"); return -99; } M(KP_CONF, mp); S(mp); W (ret); return ret; } static int api_kp_add_del_vip (vat_main_t * vam) { unformat_input_t * i = vam->input; vl_api_kp_add_del_vip_t mps, *mp; int ret; mps.is_del = 0; mps.is_nat4 = 0; if (!unformat(i, "%U", unformat_ip46_prefix, mps.ip_prefix, &mps.prefix_length, IP46_TYPE_ANY)) { errmsg ("invalid prefix\n"); return -99; } if (unformat(i, "nat4")) { mps.is_nat4 = 1; } else if (unformat(i, "nat6")) { mps.is_nat4 = 0; } else { errmsg ("no nat\n"); return -99; } if (!unformat(i, "%d", &mps.new_flows_table_length)) { errmsg ("no table lentgh\n"); return -99; } if (unformat(i, "del")) { mps.is_del = 1; } M(KP_ADD_DEL_VIP, mp); S(mp); W (ret); return ret; } static int api_kp_add_del_pod (vat_main_t * vam) { unformat_input_t * i = vam->input; vl_api_kp_add_del_pod_t mps, *mp; int ret; mps.is_del = 0; if (!unformat(i, "%U %U", unformat_ip46_prefix, mps.vip_ip_prefix, &mps.vip_prefix_length, IP46_TYPE_ANY, unformat_ip46_address, mps.pod_address)) { errmsg ("invalid prefix or address\n"); return -99; } if (unformat(i, "del")) { mps.is_del = 1; } M(KP_ADD_DEL_POD, mp); S(mp); W (ret); return ret; } /* * List of messages that the api test plugin sends, * and that the data plane plugin processes */ #define foreach_vpe_api_msg \ _(kp_conf, "<sticky_buckets_per_core> <flow_timeout>") \ _(kp_add_del_vip, "<ip-prefix> <port> <target_port> <node_port> " \ "[nat4|nat6] <new_table_len> [del]") \ _(kp_add_del_pod, "<vip-ip-prefix> <address> [del]") static void kp_vat_api_hookup (vat_main_t *vam) { kp_test_main_t * kptm = &kp_test_main; /* Hook up handlers for replies from the data plane plug-in */ #define _(N,n) \ vl_msg_api_set_handlers((VL_API_##N + kptm->msg_id_base), \ #n, \ vl_api_##n##_t_handler, \ vl_noop_handler, \ vl_api_##n##_t_endian, \ vl_api_##n##_t_print, \ sizeof(vl_api_##n##_t), 1); foreach_vpe_api_reply_msg; #undef _ /* API messages we can send */ #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n); foreach_vpe_api_msg; #undef _ /* Help strings */ #define _(n,h) hash_set_mem (vam->help_by_name, #n, h); foreach_vpe_api_msg; #undef _ } clib_error_t * vat_plugin_register (vat_main_t *vam) { kp_test_main_t * kptm = &kp_test_main; u8 * name; kptm->vat_main = vam; /* Ask the vpp engine for the first assigned message-id */ name = format (0, "kp_%08x%c", api_version, 0); kptm->msg_id_base = vl_client_get_first_plugin_msg_id ((char *) name); if (kptm->msg_id_base != (u16) ~0) kp_vat_api_hookup (vam); vec_free(name); return 0; }