Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1 | /* |
| 2 | * decap.c : IPSec tunnel support |
| 3 | * |
| 4 | * Copyright (c) 2015 Cisco and/or its affiliates. |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at: |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | #include <vnet/vnet.h> |
| 19 | #include <vnet/api_errno.h> |
| 20 | #include <vnet/ip/ip.h> |
| 21 | #include <vnet/interface.h> |
| 22 | |
| 23 | #include <vnet/ipsec/ipsec.h> |
| 24 | |
| 25 | static clib_error_t * |
| 26 | set_interface_spd_command_fn (vlib_main_t * vm, |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 27 | unformat_input_t * input, |
| 28 | vlib_cli_command_t * cmd) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 29 | { |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 30 | unformat_input_t _line_input, *line_input = &_line_input; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 31 | ipsec_main_t *im = &ipsec_main; |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 32 | u32 sw_if_index = (u32) ~ 0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 33 | u32 spd_id; |
| 34 | int is_add = 1; |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 35 | clib_error_t *error = NULL; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 36 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 37 | if (!unformat_user (input, unformat_line_input, line_input)) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 38 | return 0; |
| 39 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 40 | if (unformat |
| 41 | (line_input, "%U %u", unformat_vnet_sw_interface, im->vnet_main, |
| 42 | &sw_if_index, &spd_id)) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 43 | ; |
| 44 | else if (unformat (line_input, "del")) |
| 45 | is_add = 0; |
| 46 | else |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 47 | { |
| 48 | error = clib_error_return (0, "parse error: '%U'", |
| 49 | format_unformat_error, line_input); |
| 50 | goto done; |
| 51 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 52 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 53 | ipsec_set_interface_spd (vm, sw_if_index, spd_id, is_add); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 54 | |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 55 | done: |
| 56 | unformat_free (line_input); |
| 57 | |
| 58 | return error; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 59 | } |
| 60 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 61 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 62 | VLIB_CLI_COMMAND (set_interface_spd_command, static) = { |
| 63 | .path = "set interface ipsec spd", |
| 64 | .short_help = |
| 65 | "set interface ipsec spd <int> <id>", |
| 66 | .function = set_interface_spd_command_fn, |
| 67 | }; |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 68 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 69 | |
| 70 | static clib_error_t * |
| 71 | ipsec_sa_add_del_command_fn (vlib_main_t * vm, |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 72 | unformat_input_t * input, |
| 73 | vlib_cli_command_t * cmd) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 74 | { |
Sergio Gonzalez Monroy | d04b60b | 2017-01-20 15:35:23 +0000 | [diff] [blame] | 75 | ipsec_main_t *im = &ipsec_main; |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 76 | unformat_input_t _line_input, *line_input = &_line_input; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 77 | ipsec_sa_t sa; |
| 78 | int is_add = ~0; |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 79 | u8 *ck = 0, *ik = 0; |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 80 | clib_error_t *error = NULL; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 81 | |
Dave Barach | b7b9299 | 2018-10-17 10:38:51 -0400 | [diff] [blame] | 82 | clib_memset (&sa, 0, sizeof (sa)); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 83 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 84 | if (!unformat_user (input, unformat_line_input, line_input)) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 85 | return 0; |
| 86 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 87 | while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) |
| 88 | { |
| 89 | if (unformat (line_input, "add %u", &sa.id)) |
| 90 | is_add = 1; |
| 91 | else if (unformat (line_input, "del %u", &sa.id)) |
| 92 | is_add = 0; |
| 93 | else if (unformat (line_input, "spi %u", &sa.spi)) |
| 94 | ; |
| 95 | else if (unformat (line_input, "esp")) |
| 96 | sa.protocol = IPSEC_PROTOCOL_ESP; |
| 97 | else if (unformat (line_input, "ah")) |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 98 | { |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 99 | sa.protocol = IPSEC_PROTOCOL_AH; |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 100 | } |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 101 | else |
| 102 | if (unformat (line_input, "crypto-key %U", unformat_hex_string, &ck)) |
| 103 | sa.crypto_key_len = vec_len (ck); |
| 104 | else |
| 105 | if (unformat |
| 106 | (line_input, "crypto-alg %U", unformat_ipsec_crypto_alg, |
| 107 | &sa.crypto_alg)) |
| 108 | { |
Radu Nicolau | 89c2781 | 2018-05-04 12:51:53 +0100 | [diff] [blame] | 109 | if (sa.crypto_alg < IPSEC_CRYPTO_ALG_NONE || |
Radu Nicolau | 6929ea9 | 2016-11-29 11:00:30 +0000 | [diff] [blame] | 110 | sa.crypto_alg >= IPSEC_CRYPTO_N_ALG) |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 111 | { |
| 112 | error = clib_error_return (0, "unsupported crypto-alg: '%U'", |
| 113 | format_ipsec_crypto_alg, |
| 114 | sa.crypto_alg); |
| 115 | goto done; |
| 116 | } |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 117 | } |
| 118 | else |
| 119 | if (unformat (line_input, "integ-key %U", unformat_hex_string, &ik)) |
| 120 | sa.integ_key_len = vec_len (ik); |
| 121 | else if (unformat (line_input, "integ-alg %U", unformat_ipsec_integ_alg, |
| 122 | &sa.integ_alg)) |
| 123 | { |
Radu Nicolau | 89c2781 | 2018-05-04 12:51:53 +0100 | [diff] [blame] | 124 | if (sa.integ_alg < IPSEC_INTEG_ALG_NONE || |
Radu Nicolau | 6929ea9 | 2016-11-29 11:00:30 +0000 | [diff] [blame] | 125 | sa.integ_alg >= IPSEC_INTEG_N_ALG) |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 126 | { |
| 127 | error = clib_error_return (0, "unsupported integ-alg: '%U'", |
| 128 | format_ipsec_integ_alg, |
| 129 | sa.integ_alg); |
| 130 | goto done; |
| 131 | } |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 132 | } |
| 133 | else if (unformat (line_input, "tunnel-src %U", |
| 134 | unformat_ip4_address, &sa.tunnel_src_addr.ip4)) |
| 135 | sa.is_tunnel = 1; |
| 136 | else if (unformat (line_input, "tunnel-dst %U", |
| 137 | unformat_ip4_address, &sa.tunnel_dst_addr.ip4)) |
| 138 | sa.is_tunnel = 1; |
| 139 | else if (unformat (line_input, "tunnel-src %U", |
| 140 | unformat_ip6_address, &sa.tunnel_src_addr.ip6)) |
| 141 | { |
| 142 | sa.is_tunnel = 1; |
| 143 | sa.is_tunnel_ip6 = 1; |
| 144 | } |
| 145 | else if (unformat (line_input, "tunnel-dst %U", |
| 146 | unformat_ip6_address, &sa.tunnel_dst_addr.ip6)) |
| 147 | { |
| 148 | sa.is_tunnel = 1; |
| 149 | sa.is_tunnel_ip6 = 1; |
| 150 | } |
Radu Nicolau | 717de09 | 2018-08-03 10:37:24 +0100 | [diff] [blame] | 151 | else if (unformat (line_input, "udp-encap")) |
| 152 | { |
| 153 | sa.udp_encap = 1; |
| 154 | } |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 155 | else |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 156 | { |
| 157 | error = clib_error_return (0, "parse error: '%U'", |
| 158 | format_unformat_error, line_input); |
| 159 | goto done; |
| 160 | } |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 161 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 162 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 163 | if (sa.crypto_key_len > sizeof (sa.crypto_key)) |
| 164 | sa.crypto_key_len = sizeof (sa.crypto_key); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 165 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 166 | if (sa.integ_key_len > sizeof (sa.integ_key)) |
| 167 | sa.integ_key_len = sizeof (sa.integ_key); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 168 | |
| 169 | if (ck) |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 170 | strncpy ((char *) sa.crypto_key, (char *) ck, sa.crypto_key_len); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 171 | |
| 172 | if (ik) |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 173 | strncpy ((char *) sa.integ_key, (char *) ik, sa.integ_key_len); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 174 | |
Sergio Gonzalez Monroy | d04b60b | 2017-01-20 15:35:23 +0000 | [diff] [blame] | 175 | if (is_add) |
| 176 | { |
| 177 | ASSERT (im->cb.check_support_cb); |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 178 | error = im->cb.check_support_cb (&sa); |
| 179 | if (error) |
| 180 | goto done; |
Sergio Gonzalez Monroy | d04b60b | 2017-01-20 15:35:23 +0000 | [diff] [blame] | 181 | } |
| 182 | |
Radu Nicolau | 717de09 | 2018-08-03 10:37:24 +0100 | [diff] [blame] | 183 | ipsec_add_del_sa (vm, &sa, is_add); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 184 | |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 185 | done: |
| 186 | unformat_free (line_input); |
| 187 | |
| 188 | return error; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 189 | } |
| 190 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 191 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 192 | VLIB_CLI_COMMAND (ipsec_sa_add_del_command, static) = { |
| 193 | .path = "ipsec sa", |
| 194 | .short_help = |
| 195 | "ipsec sa [add|del]", |
| 196 | .function = ipsec_sa_add_del_command_fn, |
| 197 | }; |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 198 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 199 | |
| 200 | static clib_error_t * |
| 201 | ipsec_spd_add_del_command_fn (vlib_main_t * vm, |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 202 | unformat_input_t * input, |
| 203 | vlib_cli_command_t * cmd) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 204 | { |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 205 | unformat_input_t _line_input, *line_input = &_line_input; |
Damjan Marion | 3f54b18 | 2016-08-16 11:27:02 +0200 | [diff] [blame] | 206 | u32 spd_id = ~0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 207 | int is_add = ~0; |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 208 | clib_error_t *error = NULL; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 209 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 210 | if (!unformat_user (input, unformat_line_input, line_input)) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 211 | return 0; |
| 212 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 213 | while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) |
| 214 | { |
| 215 | if (unformat (line_input, "add")) |
| 216 | is_add = 1; |
| 217 | else if (unformat (line_input, "del")) |
| 218 | is_add = 0; |
| 219 | else if (unformat (line_input, "%u", &spd_id)) |
| 220 | ; |
| 221 | else |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 222 | { |
| 223 | error = clib_error_return (0, "parse error: '%U'", |
| 224 | format_unformat_error, line_input); |
| 225 | goto done; |
| 226 | } |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 227 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 228 | |
Damjan Marion | 3f54b18 | 2016-08-16 11:27:02 +0200 | [diff] [blame] | 229 | if (spd_id == ~0) |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 230 | { |
| 231 | error = clib_error_return (0, "please specify SPD ID"); |
| 232 | goto done; |
| 233 | } |
Damjan Marion | 3f54b18 | 2016-08-16 11:27:02 +0200 | [diff] [blame] | 234 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 235 | ipsec_add_del_spd (vm, spd_id, is_add); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 236 | |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 237 | done: |
| 238 | unformat_free (line_input); |
| 239 | |
| 240 | return error; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 241 | } |
| 242 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 243 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 244 | VLIB_CLI_COMMAND (ipsec_spd_add_del_command, static) = { |
| 245 | .path = "ipsec spd", |
| 246 | .short_help = |
| 247 | "ipsec spd [add|del] <id>", |
| 248 | .function = ipsec_spd_add_del_command_fn, |
| 249 | }; |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 250 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 251 | |
| 252 | |
| 253 | static clib_error_t * |
| 254 | ipsec_policy_add_del_command_fn (vlib_main_t * vm, |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 255 | unformat_input_t * input, |
| 256 | vlib_cli_command_t * cmd) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 257 | { |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 258 | unformat_input_t _line_input, *line_input = &_line_input; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 259 | ipsec_policy_t p; |
| 260 | int is_add = 0; |
| 261 | int is_ip_any = 1; |
| 262 | u32 tmp, tmp2; |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 263 | clib_error_t *error = NULL; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 264 | |
Dave Barach | b7b9299 | 2018-10-17 10:38:51 -0400 | [diff] [blame] | 265 | clib_memset (&p, 0, sizeof (p)); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 266 | p.lport.stop = p.rport.stop = ~0; |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 267 | p.laddr.stop.ip4.as_u32 = p.raddr.stop.ip4.as_u32 = (u32) ~ 0; |
| 268 | p.laddr.stop.ip6.as_u64[0] = p.laddr.stop.ip6.as_u64[1] = (u64) ~ 0; |
| 269 | p.raddr.stop.ip6.as_u64[0] = p.raddr.stop.ip6.as_u64[1] = (u64) ~ 0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 270 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 271 | if (!unformat_user (input, unformat_line_input, line_input)) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 272 | return 0; |
| 273 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 274 | while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) |
| 275 | { |
| 276 | if (unformat (line_input, "add")) |
| 277 | is_add = 1; |
| 278 | else if (unformat (line_input, "del")) |
| 279 | is_add = 0; |
| 280 | else if (unformat (line_input, "spd %u", &p.id)) |
| 281 | ; |
| 282 | else if (unformat (line_input, "inbound")) |
| 283 | p.is_outbound = 0; |
| 284 | else if (unformat (line_input, "outbound")) |
| 285 | p.is_outbound = 1; |
| 286 | else if (unformat (line_input, "priority %d", &p.priority)) |
| 287 | ; |
| 288 | else if (unformat (line_input, "protocol %u", &tmp)) |
| 289 | p.protocol = (u8) tmp; |
| 290 | else |
| 291 | if (unformat |
| 292 | (line_input, "action %U", unformat_ipsec_policy_action, |
| 293 | &p.policy)) |
| 294 | { |
| 295 | if (p.policy == IPSEC_POLICY_ACTION_RESOLVE) |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 296 | { |
| 297 | error = clib_error_return (0, "unsupported action: 'resolve'"); |
| 298 | goto done; |
| 299 | } |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 300 | } |
| 301 | else if (unformat (line_input, "sa %u", &p.sa_id)) |
| 302 | ; |
| 303 | else if (unformat (line_input, "local-ip-range %U - %U", |
| 304 | unformat_ip4_address, &p.laddr.start.ip4, |
| 305 | unformat_ip4_address, &p.laddr.stop.ip4)) |
| 306 | is_ip_any = 0; |
| 307 | else if (unformat (line_input, "remote-ip-range %U - %U", |
| 308 | unformat_ip4_address, &p.raddr.start.ip4, |
| 309 | unformat_ip4_address, &p.raddr.stop.ip4)) |
| 310 | is_ip_any = 0; |
| 311 | else if (unformat (line_input, "local-ip-range %U - %U", |
| 312 | unformat_ip6_address, &p.laddr.start.ip6, |
| 313 | unformat_ip6_address, &p.laddr.stop.ip6)) |
| 314 | { |
| 315 | p.is_ipv6 = 1; |
| 316 | is_ip_any = 0; |
| 317 | } |
| 318 | else if (unformat (line_input, "remote-ip-range %U - %U", |
| 319 | unformat_ip6_address, &p.raddr.start.ip6, |
| 320 | unformat_ip6_address, &p.raddr.stop.ip6)) |
| 321 | { |
| 322 | p.is_ipv6 = 1; |
| 323 | is_ip_any = 0; |
| 324 | } |
| 325 | else if (unformat (line_input, "local-port-range %u - %u", &tmp, &tmp2)) |
| 326 | { |
| 327 | p.lport.start = tmp; |
| 328 | p.lport.stop = tmp2; |
| 329 | } |
| 330 | else |
| 331 | if (unformat (line_input, "remote-port-range %u - %u", &tmp, &tmp2)) |
| 332 | { |
| 333 | p.rport.start = tmp; |
| 334 | p.rport.stop = tmp2; |
| 335 | } |
| 336 | else |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 337 | { |
| 338 | error = clib_error_return (0, "parse error: '%U'", |
| 339 | format_unformat_error, line_input); |
| 340 | goto done; |
| 341 | } |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 342 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 343 | |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 344 | /* Check if SA is for IPv6/AH which is not supported. Return error if TRUE. */ |
| 345 | if (p.sa_id) |
| 346 | { |
| 347 | uword *p1; |
| 348 | ipsec_main_t *im = &ipsec_main; |
| 349 | ipsec_sa_t *sa = 0; |
| 350 | p1 = hash_get (im->sa_index_by_sa_id, p.sa_id); |
Klement Sekera | c2fc57e | 2018-06-28 14:20:12 +0200 | [diff] [blame] | 351 | if (!p1) |
| 352 | { |
| 353 | error = |
| 354 | clib_error_return (0, "SA with index %u not found", p.sa_id); |
| 355 | goto done; |
| 356 | } |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 357 | sa = pool_elt_at_index (im->sad, p1[0]); |
| 358 | if (sa && sa->protocol == IPSEC_PROTOCOL_AH && is_add && p.is_ipv6) |
| 359 | { |
| 360 | error = clib_error_return (0, "AH not supported for IPV6: '%U'", |
| 361 | format_unformat_error, line_input); |
| 362 | goto done; |
| 363 | } |
| 364 | } |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 365 | ipsec_add_del_policy (vm, &p, is_add); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 366 | if (is_ip_any) |
| 367 | { |
| 368 | p.is_ipv6 = 1; |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 369 | ipsec_add_del_policy (vm, &p, is_add); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 370 | } |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 371 | |
| 372 | done: |
| 373 | unformat_free (line_input); |
| 374 | |
| 375 | return error; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 376 | } |
| 377 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 378 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 379 | VLIB_CLI_COMMAND (ipsec_policy_add_del_command, static) = { |
| 380 | .path = "ipsec policy", |
| 381 | .short_help = |
| 382 | "ipsec policy [add|del] spd <id> priority <n> ", |
| 383 | .function = ipsec_policy_add_del_command_fn, |
| 384 | }; |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 385 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 386 | |
| 387 | static clib_error_t * |
| 388 | set_ipsec_sa_key_command_fn (vlib_main_t * vm, |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 389 | unformat_input_t * input, |
| 390 | vlib_cli_command_t * cmd) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 391 | { |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 392 | unformat_input_t _line_input, *line_input = &_line_input; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 393 | ipsec_sa_t sa; |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 394 | u8 *ck = 0, *ik = 0; |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 395 | clib_error_t *error = NULL; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 396 | |
Dave Barach | b7b9299 | 2018-10-17 10:38:51 -0400 | [diff] [blame] | 397 | clib_memset (&sa, 0, sizeof (sa)); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 398 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 399 | if (!unformat_user (input, unformat_line_input, line_input)) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 400 | return 0; |
| 401 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 402 | while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) |
| 403 | { |
| 404 | if (unformat (line_input, "%u", &sa.id)) |
| 405 | ; |
| 406 | else |
| 407 | if (unformat (line_input, "crypto-key %U", unformat_hex_string, &ck)) |
| 408 | sa.crypto_key_len = vec_len (ck); |
| 409 | else |
| 410 | if (unformat (line_input, "integ-key %U", unformat_hex_string, &ik)) |
| 411 | sa.integ_key_len = vec_len (ik); |
| 412 | else |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 413 | { |
| 414 | error = clib_error_return (0, "parse error: '%U'", |
| 415 | format_unformat_error, line_input); |
| 416 | goto done; |
| 417 | } |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 418 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 419 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 420 | if (sa.crypto_key_len > sizeof (sa.crypto_key)) |
| 421 | sa.crypto_key_len = sizeof (sa.crypto_key); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 422 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 423 | if (sa.integ_key_len > sizeof (sa.integ_key)) |
| 424 | sa.integ_key_len = sizeof (sa.integ_key); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 425 | |
| 426 | if (ck) |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 427 | strncpy ((char *) sa.crypto_key, (char *) ck, sa.crypto_key_len); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 428 | |
| 429 | if (ik) |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 430 | strncpy ((char *) sa.integ_key, (char *) ik, sa.integ_key_len); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 431 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 432 | ipsec_set_sa_key (vm, &sa); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 433 | |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 434 | done: |
| 435 | unformat_free (line_input); |
| 436 | |
| 437 | return error; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 438 | } |
| 439 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 440 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 441 | VLIB_CLI_COMMAND (set_ipsec_sa_key_command, static) = { |
| 442 | .path = "set ipsec sa", |
| 443 | .short_help = |
| 444 | "set ipsec sa <id> crypto-key <key> integ-key <key>", |
| 445 | .function = set_ipsec_sa_key_command_fn, |
| 446 | }; |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 447 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 448 | |
| 449 | static clib_error_t * |
| 450 | show_ipsec_command_fn (vlib_main_t * vm, |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 451 | unformat_input_t * input, vlib_cli_command_t * cmd) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 452 | { |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 453 | ipsec_spd_t *spd; |
| 454 | ipsec_sa_t *sa; |
| 455 | ipsec_policy_t *p; |
| 456 | ipsec_main_t *im = &ipsec_main; |
| 457 | u32 *i; |
| 458 | ipsec_tunnel_if_t *t; |
| 459 | vnet_hw_interface_t *hi; |
Klement Sekera | ea84130 | 2018-05-11 12:59:05 +0200 | [diff] [blame] | 460 | u8 *protocol = NULL; |
| 461 | u8 *policy = NULL; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 462 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 463 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 464 | pool_foreach (sa, im->sad, ({ |
| 465 | if (sa->id) { |
Klement Sekera | 4b089f2 | 2018-04-17 18:04:57 +0200 | [diff] [blame] | 466 | vlib_cli_output(vm, "sa %u spi %u mode %s protocol %s%s", sa->id, sa->spi, |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 467 | sa->is_tunnel ? "tunnel" : "transport", |
Klement Sekera | 4b089f2 | 2018-04-17 18:04:57 +0200 | [diff] [blame] | 468 | sa->protocol ? "esp" : "ah", |
| 469 | sa->udp_encap ? " udp-encap-enabled" : ""); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 470 | if (sa->protocol == IPSEC_PROTOCOL_ESP) { |
| 471 | vlib_cli_output(vm, " crypto alg %U%s%U integrity alg %U%s%U", |
| 472 | format_ipsec_crypto_alg, sa->crypto_alg, |
| 473 | sa->crypto_alg ? " key " : "", |
| 474 | format_hex_bytes, sa->crypto_key, sa->crypto_key_len, |
| 475 | format_ipsec_integ_alg, sa->integ_alg, |
| 476 | sa->integ_alg ? " key " : "", |
| 477 | format_hex_bytes, sa->integ_key, sa->integ_key_len); |
| 478 | } |
| 479 | if (sa->is_tunnel && sa->is_tunnel_ip6) { |
| 480 | vlib_cli_output(vm, " tunnel src %U dst %U", |
| 481 | format_ip6_address, &sa->tunnel_src_addr.ip6, |
| 482 | format_ip6_address, &sa->tunnel_dst_addr.ip6); |
| 483 | } else if (sa->is_tunnel) { |
| 484 | vlib_cli_output(vm, " tunnel src %U dst %U", |
| 485 | format_ip4_address, &sa->tunnel_src_addr.ip4, |
| 486 | format_ip4_address, &sa->tunnel_dst_addr.ip4); |
| 487 | } |
| 488 | } |
| 489 | })); |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 490 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 491 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 492 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 493 | pool_foreach (spd, im->spds, ({ |
| 494 | vlib_cli_output(vm, "spd %u", spd->id); |
| 495 | |
| 496 | vlib_cli_output(vm, " outbound policies"); |
| 497 | vec_foreach(i, spd->ipv4_outbound_policies) |
| 498 | { |
| 499 | p = pool_elt_at_index(spd->policies, *i); |
Klement Sekera | ea84130 | 2018-05-11 12:59:05 +0200 | [diff] [blame] | 500 | vec_reset_length(protocol); |
| 501 | vec_reset_length(policy); |
| 502 | if (p->protocol) { |
| 503 | protocol = format(protocol, "%U", format_ip_protocol, p->protocol); |
| 504 | } else { |
| 505 | protocol = format(protocol, "any"); |
| 506 | } |
| 507 | if (p->policy == IPSEC_POLICY_ACTION_PROTECT) { |
| 508 | policy = format(policy, " sa %u", p->sa_id); |
| 509 | } |
| 510 | |
| 511 | vlib_cli_output(vm, " priority %d action %U protocol %v%v", |
| 512 | p->priority, format_ipsec_policy_action, p->policy, |
| 513 | protocol, policy); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 514 | vlib_cli_output(vm, " local addr range %U - %U port range %u - %u", |
| 515 | format_ip4_address, &p->laddr.start.ip4, |
| 516 | format_ip4_address, &p->laddr.stop.ip4, |
| 517 | p->lport.start, p->lport.stop); |
Paul Vinciguerra | bdc0e6b | 2018-09-22 05:32:50 -0700 | [diff] [blame] | 518 | vlib_cli_output(vm, " remote addr range %U - %U port range %u - %u", |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 519 | format_ip4_address, &p->raddr.start.ip4, |
| 520 | format_ip4_address, &p->raddr.stop.ip4, |
| 521 | p->rport.start, p->rport.stop); |
| 522 | vlib_cli_output(vm, " packets %u bytes %u", p->counter.packets, |
| 523 | p->counter.bytes); |
| 524 | }; |
| 525 | vec_foreach(i, spd->ipv6_outbound_policies) |
| 526 | { |
| 527 | p = pool_elt_at_index(spd->policies, *i); |
Klement Sekera | ea84130 | 2018-05-11 12:59:05 +0200 | [diff] [blame] | 528 | vec_reset_length(protocol); |
| 529 | vec_reset_length(policy); |
| 530 | if (p->protocol) { |
| 531 | protocol = format(protocol, "%U", format_ip_protocol, p->protocol); |
| 532 | } else { |
| 533 | protocol = format(protocol, "any"); |
| 534 | } |
| 535 | if (p->policy == IPSEC_POLICY_ACTION_PROTECT) { |
| 536 | policy = format(policy, " sa %u", p->sa_id); |
| 537 | } |
| 538 | vlib_cli_output(vm, " priority %d action %U protocol %v%v", |
| 539 | p->priority, format_ipsec_policy_action, p->policy, |
| 540 | protocol, policy); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 541 | vlib_cli_output(vm, " local addr range %U - %U port range %u - %u", |
| 542 | format_ip6_address, &p->laddr.start.ip6, |
| 543 | format_ip6_address, &p->laddr.stop.ip6, |
| 544 | p->lport.start, p->lport.stop); |
| 545 | vlib_cli_output(vm, " remote addr range %U - %U port range %u - %u", |
| 546 | format_ip6_address, &p->raddr.start.ip6, |
| 547 | format_ip6_address, &p->raddr.stop.ip6, |
| 548 | p->rport.start, p->rport.stop); |
| 549 | vlib_cli_output(vm, " packets %u bytes %u", p->counter.packets, |
| 550 | p->counter.bytes); |
| 551 | }; |
| 552 | vlib_cli_output(vm, " inbound policies"); |
| 553 | vec_foreach(i, spd->ipv4_inbound_protect_policy_indices) |
| 554 | { |
| 555 | p = pool_elt_at_index(spd->policies, *i); |
Klement Sekera | ea84130 | 2018-05-11 12:59:05 +0200 | [diff] [blame] | 556 | vec_reset_length(protocol); |
| 557 | vec_reset_length(policy); |
| 558 | if (p->protocol) { |
| 559 | protocol = format(protocol, "%U", format_ip_protocol, p->protocol); |
| 560 | } else { |
| 561 | protocol = format(protocol, "any"); |
| 562 | } |
| 563 | if (p->policy == IPSEC_POLICY_ACTION_PROTECT) { |
| 564 | policy = format(policy, " sa %u", p->sa_id); |
| 565 | } |
| 566 | vlib_cli_output(vm, " priority %d action %U protocol %v%v", |
| 567 | p->priority, format_ipsec_policy_action, p->policy, |
| 568 | protocol, policy); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 569 | vlib_cli_output(vm, " local addr range %U - %U port range %u - %u", |
| 570 | format_ip4_address, &p->laddr.start.ip4, |
| 571 | format_ip4_address, &p->laddr.stop.ip4, |
| 572 | p->lport.start, p->lport.stop); |
Paul Vinciguerra | bdc0e6b | 2018-09-22 05:32:50 -0700 | [diff] [blame] | 573 | vlib_cli_output(vm, " remote addr range %U - %U port range %u - %u", |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 574 | format_ip4_address, &p->raddr.start.ip4, |
| 575 | format_ip4_address, &p->raddr.stop.ip4, |
| 576 | p->rport.start, p->rport.stop); |
| 577 | vlib_cli_output(vm, " packets %u bytes %u", p->counter.packets, |
| 578 | p->counter.bytes); |
| 579 | }; |
| 580 | vec_foreach(i, spd->ipv4_inbound_policy_discard_and_bypass_indices) |
| 581 | { |
| 582 | p = pool_elt_at_index(spd->policies, *i); |
Klement Sekera | ea84130 | 2018-05-11 12:59:05 +0200 | [diff] [blame] | 583 | vec_reset_length(protocol); |
| 584 | vec_reset_length(policy); |
| 585 | if (p->protocol) { |
| 586 | protocol = format(protocol, "%U", format_ip_protocol, p->protocol); |
| 587 | } else { |
| 588 | protocol = format(protocol, "any"); |
| 589 | } |
| 590 | if (p->policy == IPSEC_POLICY_ACTION_PROTECT) { |
| 591 | policy = format(policy, " sa %u", p->sa_id); |
| 592 | } |
| 593 | vlib_cli_output(vm, " priority %d action %U protocol %v%v", |
| 594 | p->priority, format_ipsec_policy_action, p->policy, |
| 595 | protocol, policy); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 596 | vlib_cli_output(vm, " local addr range %U - %U port range %u - %u", |
| 597 | format_ip4_address, &p->laddr.start.ip4, |
| 598 | format_ip4_address, &p->laddr.stop.ip4, |
| 599 | p->lport.start, p->lport.stop); |
Paul Vinciguerra | bdc0e6b | 2018-09-22 05:32:50 -0700 | [diff] [blame] | 600 | vlib_cli_output(vm, " remote addr range %U - %U port range %u - %u", |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 601 | format_ip4_address, &p->raddr.start.ip4, |
| 602 | format_ip4_address, &p->raddr.stop.ip4, |
| 603 | p->rport.start, p->rport.stop); |
| 604 | vlib_cli_output(vm, " packets %u bytes %u", p->counter.packets, |
| 605 | p->counter.bytes); |
| 606 | }; |
| 607 | vec_foreach(i, spd->ipv6_inbound_protect_policy_indices) |
| 608 | { |
| 609 | p = pool_elt_at_index(spd->policies, *i); |
Klement Sekera | ea84130 | 2018-05-11 12:59:05 +0200 | [diff] [blame] | 610 | vec_reset_length(protocol); |
| 611 | vec_reset_length(policy); |
| 612 | if (p->protocol) { |
| 613 | protocol = format(protocol, "%U", format_ip_protocol, p->protocol); |
| 614 | } else { |
| 615 | protocol = format(protocol, "any"); |
| 616 | } |
| 617 | if (p->policy == IPSEC_POLICY_ACTION_PROTECT) { |
| 618 | policy = format(policy, " sa %u", p->sa_id); |
| 619 | } |
| 620 | vlib_cli_output(vm, " priority %d action %U protocol %v%v", |
| 621 | p->priority, format_ipsec_policy_action, p->policy, |
| 622 | protocol, policy); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 623 | vlib_cli_output(vm, " local addr range %U - %U port range %u - %u", |
| 624 | format_ip6_address, &p->laddr.start.ip6, |
| 625 | format_ip6_address, &p->laddr.stop.ip6, |
| 626 | p->lport.start, p->lport.stop); |
| 627 | vlib_cli_output(vm, " remote addr range %U - %U port range %u - %u", |
| 628 | format_ip6_address, &p->raddr.start.ip6, |
| 629 | format_ip6_address, &p->raddr.stop.ip6, |
| 630 | p->rport.start, p->rport.stop); |
| 631 | vlib_cli_output(vm, " packets %u bytes %u", p->counter.packets, |
| 632 | p->counter.bytes); |
| 633 | }; |
| 634 | vec_foreach(i, spd->ipv6_inbound_policy_discard_and_bypass_indices) |
| 635 | { |
| 636 | p = pool_elt_at_index(spd->policies, *i); |
Klement Sekera | ea84130 | 2018-05-11 12:59:05 +0200 | [diff] [blame] | 637 | vec_reset_length(protocol); |
| 638 | vec_reset_length(policy); |
| 639 | if (p->protocol) { |
| 640 | protocol = format(protocol, "%U", format_ip_protocol, p->protocol); |
| 641 | } else { |
| 642 | protocol = format(protocol, "any"); |
| 643 | } |
| 644 | if (p->policy == IPSEC_POLICY_ACTION_PROTECT) { |
| 645 | policy = format(policy, " sa %u", p->sa_id); |
| 646 | } |
| 647 | vlib_cli_output(vm, " priority %d action %U protocol %v%v", |
| 648 | p->priority, format_ipsec_policy_action, p->policy, |
| 649 | protocol, policy); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 650 | vlib_cli_output(vm, " local addr range %U - %U port range %u - %u", |
| 651 | format_ip6_address, &p->laddr.start.ip6, |
| 652 | format_ip6_address, &p->laddr.stop.ip6, |
| 653 | p->lport.start, p->lport.stop); |
| 654 | vlib_cli_output(vm, " remote addr range %U - %U port range %u - %u", |
| 655 | format_ip6_address, &p->raddr.start.ip6, |
| 656 | format_ip6_address, &p->raddr.stop.ip6, |
| 657 | p->rport.start, p->rport.stop); |
| 658 | vlib_cli_output(vm, " packets %u bytes %u", p->counter.packets, |
| 659 | p->counter.bytes); |
| 660 | }; |
| 661 | })); |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 662 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 663 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 664 | vlib_cli_output (vm, "tunnel interfaces"); |
| 665 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 666 | pool_foreach (t, im->tunnel_interfaces, ({ |
Matus Fabian | 694265d | 2016-08-10 01:55:36 -0700 | [diff] [blame] | 667 | if (t->hw_if_index == ~0) |
| 668 | continue; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 669 | hi = vnet_get_hw_interface (im->vnet_main, t->hw_if_index); |
| 670 | vlib_cli_output(vm, " %s seq", hi->name); |
| 671 | sa = pool_elt_at_index(im->sad, t->output_sa_index); |
Radu Nicolau | 717de09 | 2018-08-03 10:37:24 +0100 | [diff] [blame] | 672 | vlib_cli_output(vm, " seq %u seq-hi %u esn %u anti-replay %u udp-encap %u", |
| 673 | sa->seq, sa->seq_hi, sa->use_esn, sa->use_anti_replay, sa->udp_encap); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 674 | vlib_cli_output(vm, " local-spi %u local-ip %U", sa->spi, |
| 675 | format_ip4_address, &sa->tunnel_src_addr.ip4); |
| 676 | vlib_cli_output(vm, " local-crypto %U %U", |
| 677 | format_ipsec_crypto_alg, sa->crypto_alg, |
| 678 | format_hex_bytes, sa->crypto_key, sa->crypto_key_len); |
| 679 | vlib_cli_output(vm, " local-integrity %U %U", |
| 680 | format_ipsec_integ_alg, sa->integ_alg, |
| 681 | format_hex_bytes, sa->integ_key, sa->integ_key_len); |
| 682 | sa = pool_elt_at_index(im->sad, t->input_sa_index); |
| 683 | vlib_cli_output(vm, " last-seq %u last-seq-hi %u esn %u anti-replay %u window %U", |
| 684 | sa->last_seq, sa->last_seq_hi, sa->use_esn, |
| 685 | sa->use_anti_replay, |
| 686 | format_ipsec_replay_window, sa->replay_window); |
| 687 | vlib_cli_output(vm, " remote-spi %u remote-ip %U", sa->spi, |
| 688 | format_ip4_address, &sa->tunnel_src_addr.ip4); |
| 689 | vlib_cli_output(vm, " remote-crypto %U %U", |
| 690 | format_ipsec_crypto_alg, sa->crypto_alg, |
| 691 | format_hex_bytes, sa->crypto_key, sa->crypto_key_len); |
| 692 | vlib_cli_output(vm, " remote-integrity %U %U", |
| 693 | format_ipsec_integ_alg, sa->integ_alg, |
| 694 | format_hex_bytes, sa->integ_key, sa->integ_key_len); |
| 695 | })); |
Klement Sekera | ea84130 | 2018-05-11 12:59:05 +0200 | [diff] [blame] | 696 | vec_free(policy); |
| 697 | vec_free(protocol); |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 698 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 699 | return 0; |
| 700 | } |
| 701 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 702 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 703 | VLIB_CLI_COMMAND (show_ipsec_command, static) = { |
| 704 | .path = "show ipsec", |
| 705 | .short_help = "show ipsec", |
| 706 | .function = show_ipsec_command_fn, |
| 707 | }; |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 708 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 709 | |
| 710 | static clib_error_t * |
| 711 | clear_ipsec_counters_command_fn (vlib_main_t * vm, |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 712 | unformat_input_t * input, |
| 713 | vlib_cli_command_t * cmd) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 714 | { |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 715 | ipsec_main_t *im = &ipsec_main; |
| 716 | ipsec_spd_t *spd; |
| 717 | ipsec_policy_t *p; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 718 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 719 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 720 | pool_foreach (spd, im->spds, ({ |
| 721 | pool_foreach(p, spd->policies, ({ |
| 722 | p->counter.packets = p->counter.bytes = 0; |
| 723 | })); |
| 724 | })); |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 725 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 726 | |
| 727 | return 0; |
| 728 | } |
| 729 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 730 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 731 | VLIB_CLI_COMMAND (clear_ipsec_counters_command, static) = { |
| 732 | .path = "clear ipsec counters", |
| 733 | .short_help = "clear ipsec counters", |
| 734 | .function = clear_ipsec_counters_command_fn, |
| 735 | }; |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 736 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 737 | |
| 738 | static clib_error_t * |
| 739 | create_ipsec_tunnel_command_fn (vlib_main_t * vm, |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 740 | unformat_input_t * input, |
| 741 | vlib_cli_command_t * cmd) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 742 | { |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 743 | unformat_input_t _line_input, *line_input = &_line_input; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 744 | ipsec_add_del_tunnel_args_t a; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 745 | int rv; |
| 746 | u32 num_m_args = 0; |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 747 | clib_error_t *error = NULL; |
Matthew Smith | 2838a23 | 2016-06-21 16:05:09 -0500 | [diff] [blame] | 748 | |
Dave Barach | b7b9299 | 2018-10-17 10:38:51 -0400 | [diff] [blame] | 749 | clib_memset (&a, 0, sizeof (a)); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 750 | a.is_add = 1; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 751 | |
| 752 | /* Get a line of input. */ |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 753 | if (!unformat_user (input, unformat_line_input, line_input)) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 754 | return 0; |
| 755 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 756 | while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) |
| 757 | { |
| 758 | if (unformat |
| 759 | (line_input, "local-ip %U", unformat_ip4_address, &a.local_ip)) |
| 760 | num_m_args++; |
| 761 | else |
| 762 | if (unformat |
| 763 | (line_input, "remote-ip %U", unformat_ip4_address, &a.remote_ip)) |
| 764 | num_m_args++; |
| 765 | else if (unformat (line_input, "local-spi %u", &a.local_spi)) |
| 766 | num_m_args++; |
| 767 | else if (unformat (line_input, "remote-spi %u", &a.remote_spi)) |
| 768 | num_m_args++; |
Matthew Smith | 8e1039a | 2018-04-12 07:32:56 -0500 | [diff] [blame] | 769 | else if (unformat (line_input, "instance %u", &a.show_instance)) |
| 770 | a.renumber = 1; |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 771 | else if (unformat (line_input, "del")) |
| 772 | a.is_add = 0; |
Radu Nicolau | 717de09 | 2018-08-03 10:37:24 +0100 | [diff] [blame] | 773 | else if (unformat (line_input, "udp-encap")) |
| 774 | a.udp_encap = 1; |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 775 | else |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 776 | { |
| 777 | error = clib_error_return (0, "unknown input `%U'", |
| 778 | format_unformat_error, line_input); |
| 779 | goto done; |
| 780 | } |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 781 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 782 | |
| 783 | if (num_m_args < 4) |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 784 | { |
| 785 | error = clib_error_return (0, "mandatory argument(s) missing"); |
| 786 | goto done; |
| 787 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 788 | |
Matthew Smith | 2838a23 | 2016-06-21 16:05:09 -0500 | [diff] [blame] | 789 | rv = ipsec_add_del_tunnel_if (&a); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 790 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 791 | switch (rv) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 792 | { |
| 793 | case 0: |
| 794 | break; |
| 795 | case VNET_API_ERROR_INVALID_VALUE: |
| 796 | if (a.is_add) |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 797 | error = clib_error_return (0, |
| 798 | "IPSec tunnel interface already exists..."); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 799 | else |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 800 | error = clib_error_return (0, "IPSec tunnel interface not exists..."); |
| 801 | goto done; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 802 | default: |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 803 | error = clib_error_return (0, "ipsec_register_interface returned %d", |
| 804 | rv); |
| 805 | goto done; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 806 | } |
| 807 | |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 808 | done: |
| 809 | unformat_free (line_input); |
| 810 | |
| 811 | return error; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 812 | } |
| 813 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 814 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 815 | VLIB_CLI_COMMAND (create_ipsec_tunnel_command, static) = { |
| 816 | .path = "create ipsec tunnel", |
Radu Nicolau | 717de09 | 2018-08-03 10:37:24 +0100 | [diff] [blame] | 817 | .short_help = "create ipsec tunnel local-ip <addr> local-spi <spi> remote-ip <addr> remote-spi <spi> [instance <inst_num>] [udp-encap]", |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 818 | .function = create_ipsec_tunnel_command_fn, |
| 819 | }; |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 820 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 821 | |
| 822 | static clib_error_t * |
| 823 | set_interface_key_command_fn (vlib_main_t * vm, |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 824 | unformat_input_t * input, |
| 825 | vlib_cli_command_t * cmd) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 826 | { |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 827 | unformat_input_t _line_input, *line_input = &_line_input; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 828 | ipsec_main_t *im = &ipsec_main; |
| 829 | ipsec_if_set_key_type_t type = IPSEC_IF_SET_KEY_TYPE_NONE; |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 830 | u32 hw_if_index = (u32) ~ 0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 831 | u32 alg; |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 832 | u8 *key = 0; |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 833 | clib_error_t *error = NULL; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 834 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 835 | if (!unformat_user (input, unformat_line_input, line_input)) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 836 | return 0; |
| 837 | |
| 838 | while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) |
| 839 | { |
| 840 | if (unformat (line_input, "%U", |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 841 | unformat_vnet_hw_interface, im->vnet_main, &hw_if_index)) |
| 842 | ; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 843 | else |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 844 | if (unformat |
| 845 | (line_input, "local crypto %U", unformat_ipsec_crypto_alg, &alg)) |
| 846 | type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO; |
| 847 | else |
| 848 | if (unformat |
| 849 | (line_input, "remote crypto %U", unformat_ipsec_crypto_alg, &alg)) |
| 850 | type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO; |
| 851 | else |
| 852 | if (unformat |
| 853 | (line_input, "local integ %U", unformat_ipsec_integ_alg, &alg)) |
| 854 | type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG; |
| 855 | else |
| 856 | if (unformat |
| 857 | (line_input, "remote integ %U", unformat_ipsec_integ_alg, &alg)) |
| 858 | type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG; |
| 859 | else if (unformat (line_input, "%U", unformat_hex_string, &key)) |
| 860 | ; |
| 861 | else |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 862 | { |
| 863 | error = clib_error_return (0, "parse error: '%U'", |
| 864 | format_unformat_error, line_input); |
| 865 | goto done; |
| 866 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 867 | } |
| 868 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 869 | if (type == IPSEC_IF_SET_KEY_TYPE_NONE) |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 870 | { |
| 871 | error = clib_error_return (0, "unknown key type"); |
| 872 | goto done; |
| 873 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 874 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 875 | if (alg > 0 && vec_len (key) == 0) |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 876 | { |
| 877 | error = clib_error_return (0, "key is not specified"); |
| 878 | goto done; |
| 879 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 880 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 881 | if (hw_if_index == (u32) ~ 0) |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 882 | { |
| 883 | error = clib_error_return (0, "interface not specified"); |
| 884 | goto done; |
| 885 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 886 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 887 | ipsec_set_interface_key (im->vnet_main, hw_if_index, type, alg, key); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 888 | |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 889 | done: |
| 890 | vec_free (key); |
| 891 | unformat_free (line_input); |
| 892 | |
| 893 | return error; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 894 | } |
| 895 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 896 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 897 | VLIB_CLI_COMMAND (set_interface_key_command, static) = { |
| 898 | .path = "set interface ipsec key", |
| 899 | .short_help = |
| 900 | "set interface ipsec key <int> <local|remote> <crypto|integ> <key type> <key>", |
| 901 | .function = set_interface_key_command_fn, |
| 902 | }; |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 903 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 904 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 905 | clib_error_t * |
| 906 | ipsec_cli_init (vlib_main_t * vm) |
| 907 | { |
| 908 | return 0; |
| 909 | } |
| 910 | |
| 911 | VLIB_INIT_FUNCTION (ipsec_cli_init); |
| 912 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 913 | |
| 914 | /* |
| 915 | * fd.io coding-style-patch-verification: ON |
| 916 | * |
| 917 | * Local Variables: |
| 918 | * eval: (c-set-style "gnu") |
| 919 | * End: |
| 920 | */ |