#include <vnet/pg/pg.h>
#include <vppinfra/error.h>
#include <vnet/udp/udp.h>
+#include <vnet/ipsec/ipsec_sa.h>
#include <plugins/ikev2/ikev2.h>
#include <plugins/ikev2/ikev2_priv.h>
vlib_cli_output(vm, " SK_e i:%U\n r:%U",
format_hex_bytes, child->sk_ei, vec_len(child->sk_ei),
format_hex_bytes, child->sk_er, vec_len(child->sk_er));
- vlib_cli_output(vm, " SK_a i:%U\n r:%U",
- format_hex_bytes, child->sk_ai, vec_len(child->sk_ai),
- format_hex_bytes, child->sk_ar, vec_len(child->sk_ar));
- vlib_cli_output(vm, " traffic selectors (i):");
+ if (child->sk_ai)
+ {
+ vlib_cli_output(vm, " SK_a i:%U\n r:%U",
+ format_hex_bytes, child->sk_ai, vec_len(child->sk_ai),
+ format_hex_bytes, child->sk_ar, vec_len(child->sk_ar));
+ vlib_cli_output(vm, " traffic selectors (i):");
+ }
vec_foreach(ts, child->tsi)
{
vlib_cli_output(vm, " %u type %u protocol_id %u addr "
ip4_address_t ip4;
ip4_address_t end_addr;
u32 responder_sw_if_index = (u32) ~ 0;
+ u32 tun_sw_if_index = (u32) ~ 0;
ip4_address_t responder_ip4;
ikev2_transform_encr_type_t crypto_alg;
ikev2_transform_integ_type_t integ_alg;
responder_ip4);
goto done;
}
+ else if (unformat (line_input, "set %U tunnel %U",
+ unformat_token, valid_chars, &name,
+ unformat_vnet_sw_interface, vnm, &tun_sw_if_index))
+ {
+ r = ikev2_set_profile_tunnel_interface (vm, name, tun_sw_if_index);
+ goto done;
+ }
else
if (unformat
(line_input,
else
if (unformat
(line_input,
- "set %U esp-crypto-alg %U %u esp-integ-alg %U esp-dh %U",
+ "set %U esp-crypto-alg %U %u esp-integ-alg %U",
unformat_token, valid_chars, &name,
unformat_ikev2_transform_encr_type, &crypto_alg, &tmp1,
- unformat_ikev2_transform_integ_type, &integ_alg,
- unformat_ikev2_transform_dh_type, &dh_type))
+ unformat_ikev2_transform_integ_type, &integ_alg))
{
r =
ikev2_set_profile_esp_transforms (vm, name, crypto_alg, integ_alg,
- dh_type, tmp1);
+ IKEV2_TRANSFORM_DH_TYPE_NONE,
+ tmp1);
+ goto done;
+ }
+ else if (unformat
+ (line_input,
+ "set %U esp-crypto-alg %U %u",
+ unformat_token, valid_chars, &name,
+ unformat_ikev2_transform_encr_type, &crypto_alg, &tmp1))
+ {
+ r =
+ ikev2_set_profile_esp_transforms (vm, name, crypto_alg, 0,
+ IKEV2_TRANSFORM_DH_TYPE_NONE,
+ tmp1);
goto done;
}
else if (unformat (line_input, "set %U sa-lifetime %lu %u %u %lu",
ikev2_set_profile_sa_lifetime (vm, name, tmp4, tmp1, tmp2, tmp5);
goto done;
}
+ else if (unformat (line_input, "set %U udp-encap",
+ unformat_token, valid_chars, &name))
+ {
+ r = ikev2_set_profile_udp_encap (vm, name);
+ goto done;
+ }
+ else if (unformat (line_input, "set %U ipsec-over-udp port %u",
+ unformat_token, valid_chars, &name, &tmp1))
+ {
+ int rv = ikev2_set_profile_ipsec_udp_port (vm, name, tmp1, 1);
+ if (rv)
+ r = clib_error_return (0, "Error: %U", format_vnet_api_errno, rv);
+ goto done;
+ }
else
break;
}
"ikev2 profile set <id> auth [rsa-sig|shared-key-mic] [cert-file|string|hex]"
" <data>\n"
"ikev2 profile set <id> id <local|remote> <type> <data>\n"
+ "ikev2 profile set <id> tunnel <interface>\n"
+ "ikev2 profile set <id> udp-encap\n"
"ikev2 profile set <id> traffic-selector <local|remote> ip-range "
"<start-addr> - <end-addr> port-range <start-port> - <end-port> "
"protocol <protocol-number>\n"
"ikev2 profile set <id> responder <interface> <addr>\n"
"ikev2 profile set <id> ike-crypto-alg <crypto alg> <key size> ike-integ-alg <integ alg> ike-dh <dh type>\n"
- "ikev2 profile set <id> esp-crypto-alg <crypto alg> <key size> esp-integ-alg <integ alg> esp-dh <dh type>\n"
+ "ikev2 profile set <id> esp-crypto-alg <crypto alg> <key size> "
+ "[esp-integ-alg <integ alg>]\n"
"ikev2 profile set <id> sa-lifetime <seconds> <jitter> <handover> <max bytes>",
.function = ikev2_profile_add_del_command_fn,
};
format_ip4_address, &p->rem_ts.end_addr,
p->rem_ts.start_port, p->rem_ts.end_port,
p->rem_ts.protocol_id);
+ if (~0 != p->tun_itf)
+ vlib_cli_output(vm, " protected tunnel %U",
+ format_vnet_sw_if_index_name, vnet_get_main(), p->tun_itf);
+ if (~0 != p->responder.sw_if_index)
+ vlib_cli_output(vm, " responder %U %U",
+ format_vnet_sw_if_index_name, vnet_get_main(), p->responder.sw_if_index,
+ format_ip4_address, &p->responder.ip4);
+ if (p->udp_encap)
+ vlib_cli_output(vm, " udp-encap");
+
+ if (p->ipsec_over_udp_port != IPSEC_UDP_PORT_NONE)
+ vlib_cli_output(vm, " ipsec-over-udp port %d", p->ipsec_over_udp_port);
+
+ if (p->ike_ts.crypto_alg || p->ike_ts.integ_alg || p->ike_ts.dh_type || p->ike_ts.crypto_key_size)
+ vlib_cli_output(vm, " ike-crypto-alg %U %u ike-integ-alg %U ike-dh %U",
+ format_ikev2_transform_encr_type, p->ike_ts.crypto_alg, p->ike_ts.crypto_key_size,
+ format_ikev2_transform_integ_type, p->ike_ts.integ_alg,
+ format_ikev2_transform_dh_type, p->ike_ts.dh_type);
+
+ if (p->esp_ts.crypto_alg || p->esp_ts.integ_alg || p->esp_ts.dh_type)
+ vlib_cli_output(vm, " esp-crypto-alg %U %u esp-integ-alg %U",
+ format_ikev2_transform_encr_type, p->esp_ts.crypto_alg, p->esp_ts.crypto_key_size,
+ format_ikev2_transform_integ_type, p->esp_ts.integ_alg);
+
+ vlib_cli_output(vm, " lifetime %d jitter %d handover %d maxdata %d",
+ p->lifetime, p->lifetime_jitter, p->handover, p->lifetime_maxdata);
}));
/* *INDENT-ON* */
};
/* *INDENT-ON* */
+static clib_error_t *
+set_ikev2_liveness_period_fn (vlib_main_t * vm,
+ unformat_input_t * input,
+ vlib_cli_command_t * cmd)
+{
+ unformat_input_t _line_input, *line_input = &_line_input;
+ clib_error_t *r = 0;
+ u32 period = 0, max_retries = 0;
+
+ if (!unformat_user (input, unformat_line_input, line_input))
+ return 0;
+
+ while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (line_input, "%d %d", &period, &max_retries))
+ {
+ r = ikev2_set_liveness_params (period, max_retries);
+ goto done;
+ }
+ else
+ break;
+ }
+
+ r = clib_error_return (0, "parse error: '%U'",
+ format_unformat_error, line_input);
+
+done:
+ unformat_free (line_input);
+ return r;
+}
+
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (set_ikev2_liveness_command, static) = {
+ .path = "ikev2 set liveness",
+ .short_help = "ikev2 set liveness <period> <max-retires>",
+ .function = set_ikev2_liveness_period_fn,
+};
+/* *INDENT-ON* */
+
static clib_error_t *
set_ikev2_local_key_command_fn (vlib_main_t * vm,
unformat_input_t * input,
};
/* *INDENT-ON* */
+void
+ikev2_cli_reference (void)
+{
+}
-clib_error_t *
-ikev2_cli_init (vlib_main_t * vm)
+static clib_error_t *
+ikev2_set_log_level_command_fn (vlib_main_t * vm,
+ unformat_input_t * input,
+ vlib_cli_command_t * cmd)
{
- return 0;
+ unformat_input_t _line_input, *line_input = &_line_input;
+ u32 log_level = IKEV2_LOG_NONE;
+ clib_error_t *error = 0;
+
+ /* Get a line of input. */
+ if (!unformat_user (input, unformat_line_input, line_input))
+ return 0;
+
+ if (!unformat (line_input, "%d", &log_level))
+ {
+ error = clib_error_return (0, "unknown input '%U'",
+ format_unformat_error, line_input);
+ goto done;
+ }
+ int rc = ikev2_set_log_level (log_level);
+ if (rc < 0)
+ error = clib_error_return (0, "setting log level failed!");
+
+done:
+ unformat_free (line_input);
+ return error;
}
-VLIB_INIT_FUNCTION (ikev2_cli_init);
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (ikev2_set_log_level_command, static) = {
+ .path = "ikev2 set logging level",
+ .function = ikev2_set_log_level_command_fn,
+ .short_help = "ikev2 set logging level <0-5>",
+};
+/* *INDENT-ON* */
/*
* fd.io coding-style-patch-verification: ON