From 40aa27ef7cf63daa11974d0b06ea9ee1a102cb32 Mon Sep 17 00:00:00 2001 From: Benoît Ganne Date: Fri, 6 Nov 2020 14:14:23 +0100 Subject: ipsec: add support for tx-table-id in cli + example MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Type: improvement Change-Id: I840741dfe040718b682935cdbcb0ba958d45a591 Signed-off-by: Benoît Ganne --- src/vnet/ipsec/ipsec_cli.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/vnet/ipsec/ipsec_cli.c') diff --git a/src/vnet/ipsec/ipsec_cli.c b/src/vnet/ipsec/ipsec_cli.c index fc79c4ca347..e0a271db87d 100644 --- a/src/vnet/ipsec/ipsec_cli.c +++ b/src/vnet/ipsec/ipsec_cli.c @@ -36,6 +36,7 @@ set_interface_spd_command_fn (vlib_main_t * vm, u32 spd_id; int is_add = 1; clib_error_t *error = NULL; + int err; if (!unformat_user (input, unformat_line_input, line_input)) return 0; @@ -53,7 +54,16 @@ set_interface_spd_command_fn (vlib_main_t * vm, goto done; } - ipsec_set_interface_spd (vm, sw_if_index, spd_id, is_add); + err = ipsec_set_interface_spd (vm, sw_if_index, spd_id, is_add); + switch (err) + { + case VNET_API_ERROR_SYSCALL_ERROR_1: + error = clib_error_return (0, "no such spd-id"); + break; + case VNET_API_ERROR_SYSCALL_ERROR_2: + error = clib_error_return (0, "spd already assigned"); + break; + } done: unformat_free (line_input); @@ -91,6 +101,7 @@ ipsec_sa_add_del_command_fn (vlib_main_t * vm, int is_add, rv; u32 m_args = 0; ip_dscp_t dscp; + u32 tx_table_id; salt = 0; error = NULL; @@ -101,6 +112,7 @@ ipsec_sa_add_del_command_fn (vlib_main_t * vm, crypto_alg = IPSEC_CRYPTO_ALG_NONE; udp_src = udp_dst = IPSEC_UDP_PORT_NONE; dscp = IP_DSCP_CS0; + tx_table_id = 0; if (!unformat_user (input, unformat_line_input, line_input)) return 0; @@ -146,6 +158,8 @@ ipsec_sa_add_del_command_fn (vlib_main_t * vm, else if (unformat (line_input, "tunnel-dst %U", unformat_ip46_address, &tun_dst, IP46_TYPE_ANY)) ; + else if (unformat (line_input, "tx-table-id %d", &tx_table_id)) + ; else if (unformat (line_input, "inbound")) flags |= IPSEC_SA_FLAG_IS_INBOUND; else if (unformat (line_input, "use-anti-replay")) @@ -183,7 +197,7 @@ ipsec_sa_add_del_command_fn (vlib_main_t * vm, } rv = ipsec_sa_add_and_lock (id, spi, proto, crypto_alg, &ck, integ_alg, &ik, flags, - 0, clib_host_to_net_u32 (salt), + tx_table_id, clib_host_to_net_u32 (salt), &tun_src, &tun_dst, TUNNEL_ENCAP_DECAP_FLAG_NONE, dscp, &sai, udp_src, udp_dst); -- cgit 1.2.3-korg