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> |
Pierre Pfister | 4c422f9 | 2018-12-10 11:19:08 +0100 | [diff] [blame] | 22 | #include <vnet/fib/fib.h> |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 23 | |
| 24 | #include <vnet/ipsec/ipsec.h> |
Neale Ranns | c87b66c | 2019-02-07 07:26:12 -0800 | [diff] [blame] | 25 | #include <vnet/ipsec/ipsec_tun.h> |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 26 | |
| 27 | static clib_error_t * |
| 28 | set_interface_spd_command_fn (vlib_main_t * vm, |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 29 | unformat_input_t * input, |
| 30 | vlib_cli_command_t * cmd) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 31 | { |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 32 | unformat_input_t _line_input, *line_input = &_line_input; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 33 | ipsec_main_t *im = &ipsec_main; |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 34 | u32 sw_if_index = (u32) ~ 0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 35 | u32 spd_id; |
| 36 | int is_add = 1; |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 37 | clib_error_t *error = NULL; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 38 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 39 | if (!unformat_user (input, unformat_line_input, line_input)) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 40 | return 0; |
| 41 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 42 | if (unformat |
| 43 | (line_input, "%U %u", unformat_vnet_sw_interface, im->vnet_main, |
| 44 | &sw_if_index, &spd_id)) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 45 | ; |
| 46 | else if (unformat (line_input, "del")) |
| 47 | is_add = 0; |
| 48 | else |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 49 | { |
| 50 | error = clib_error_return (0, "parse error: '%U'", |
| 51 | format_unformat_error, line_input); |
| 52 | goto done; |
| 53 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 54 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 55 | ipsec_set_interface_spd (vm, sw_if_index, spd_id, is_add); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 56 | |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 57 | done: |
| 58 | unformat_free (line_input); |
| 59 | |
| 60 | return error; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 61 | } |
| 62 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 63 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 64 | VLIB_CLI_COMMAND (set_interface_spd_command, static) = { |
| 65 | .path = "set interface ipsec spd", |
| 66 | .short_help = |
| 67 | "set interface ipsec spd <int> <id>", |
| 68 | .function = set_interface_spd_command_fn, |
| 69 | }; |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 70 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 71 | |
| 72 | static clib_error_t * |
| 73 | ipsec_sa_add_del_command_fn (vlib_main_t * vm, |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 74 | unformat_input_t * input, |
| 75 | vlib_cli_command_t * cmd) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 76 | { |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 77 | unformat_input_t _line_input, *line_input = &_line_input; |
Neale Ranns | 8d7c502 | 2019-02-06 01:41:05 -0800 | [diff] [blame] | 78 | ip46_address_t tun_src = { }, tun_dst = |
| 79 | { |
| 80 | }; |
| 81 | ipsec_crypto_alg_t crypto_alg; |
| 82 | ipsec_integ_alg_t integ_alg; |
| 83 | ipsec_protocol_t proto; |
| 84 | ipsec_sa_flags_t flags; |
| 85 | clib_error_t *error; |
Kingwel Xie | d3d1205 | 2019-03-07 06:34:30 -0500 | [diff] [blame] | 86 | ipsec_key_t ck = { 0 }; |
| 87 | ipsec_key_t ik = { 0 }; |
Neale Ranns | 80f6fd5 | 2019-04-16 02:41:34 +0000 | [diff] [blame] | 88 | u32 id, spi, salt; |
Neale Ranns | 8d7c502 | 2019-02-06 01:41:05 -0800 | [diff] [blame] | 89 | int is_add, rv; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 90 | |
Neale Ranns | 8d7c502 | 2019-02-06 01:41:05 -0800 | [diff] [blame] | 91 | error = NULL; |
| 92 | is_add = 0; |
| 93 | flags = IPSEC_SA_FLAG_NONE; |
| 94 | proto = IPSEC_PROTOCOL_ESP; |
Neale Ranns | e6be702 | 2019-06-04 15:37:34 +0000 | [diff] [blame] | 95 | integ_alg = IPSEC_INTEG_ALG_NONE; |
| 96 | crypto_alg = IPSEC_CRYPTO_ALG_NONE; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 97 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 98 | if (!unformat_user (input, unformat_line_input, line_input)) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 99 | return 0; |
| 100 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 101 | while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) |
| 102 | { |
Neale Ranns | 8d7c502 | 2019-02-06 01:41:05 -0800 | [diff] [blame] | 103 | if (unformat (line_input, "add %u", &id)) |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 104 | is_add = 1; |
Neale Ranns | 8d7c502 | 2019-02-06 01:41:05 -0800 | [diff] [blame] | 105 | else if (unformat (line_input, "del %u", &id)) |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 106 | is_add = 0; |
Neale Ranns | 8d7c502 | 2019-02-06 01:41:05 -0800 | [diff] [blame] | 107 | else if (unformat (line_input, "spi %u", &spi)) |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 108 | ; |
Neale Ranns | c87b66c | 2019-02-07 07:26:12 -0800 | [diff] [blame] | 109 | else if (unformat (line_input, "salt 0x%x", &salt)) |
Neale Ranns | 80f6fd5 | 2019-04-16 02:41:34 +0000 | [diff] [blame] | 110 | ; |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 111 | else if (unformat (line_input, "esp")) |
Neale Ranns | 8d7c502 | 2019-02-06 01:41:05 -0800 | [diff] [blame] | 112 | proto = IPSEC_PROTOCOL_ESP; |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 113 | else if (unformat (line_input, "ah")) |
Neale Ranns | 8d7c502 | 2019-02-06 01:41:05 -0800 | [diff] [blame] | 114 | proto = IPSEC_PROTOCOL_AH; |
| 115 | else if (unformat (line_input, "crypto-key %U", |
| 116 | unformat_ipsec_key, &ck)) |
| 117 | ; |
| 118 | else if (unformat (line_input, "crypto-alg %U", |
| 119 | unformat_ipsec_crypto_alg, &crypto_alg)) |
| 120 | ; |
| 121 | else if (unformat (line_input, "integ-key %U", unformat_ipsec_key, &ik)) |
| 122 | ; |
| 123 | else if (unformat (line_input, "integ-alg %U", |
| 124 | unformat_ipsec_integ_alg, &integ_alg)) |
| 125 | ; |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 126 | else if (unformat (line_input, "tunnel-src %U", |
Kingwel Xie | 72b3bce | 2019-02-12 06:45:08 -0500 | [diff] [blame] | 127 | unformat_ip46_address, &tun_src, IP46_TYPE_ANY)) |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 128 | { |
Neale Ranns | 8d7c502 | 2019-02-06 01:41:05 -0800 | [diff] [blame] | 129 | flags |= IPSEC_SA_FLAG_IS_TUNNEL; |
| 130 | if (!ip46_address_is_ip4 (&tun_src)) |
| 131 | flags |= IPSEC_SA_FLAG_IS_TUNNEL_V6; |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 132 | } |
| 133 | else if (unformat (line_input, "tunnel-dst %U", |
Kingwel Xie | 72b3bce | 2019-02-12 06:45:08 -0500 | [diff] [blame] | 134 | unformat_ip46_address, &tun_dst, IP46_TYPE_ANY)) |
Neale Ranns | 8d7c502 | 2019-02-06 01:41:05 -0800 | [diff] [blame] | 135 | ; |
Radu Nicolau | 717de09 | 2018-08-03 10:37:24 +0100 | [diff] [blame] | 136 | else if (unformat (line_input, "udp-encap")) |
Neale Ranns | 8d7c502 | 2019-02-06 01:41:05 -0800 | [diff] [blame] | 137 | flags |= IPSEC_SA_FLAG_UDP_ENCAP; |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 138 | else |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 139 | { |
| 140 | error = clib_error_return (0, "parse error: '%U'", |
| 141 | format_unformat_error, line_input); |
| 142 | goto done; |
| 143 | } |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 144 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 145 | |
Sergio Gonzalez Monroy | d04b60b | 2017-01-20 15:35:23 +0000 | [diff] [blame] | 146 | if (is_add) |
Neale Ranns | 495d7ff | 2019-07-12 09:15:26 +0000 | [diff] [blame] | 147 | rv = ipsec_sa_add_and_lock (id, spi, proto, crypto_alg, |
| 148 | &ck, integ_alg, &ik, flags, |
| 149 | 0, clib_host_to_net_u32 (salt), |
| 150 | &tun_src, &tun_dst, NULL); |
Neale Ranns | 8d7c502 | 2019-02-06 01:41:05 -0800 | [diff] [blame] | 151 | else |
Neale Ranns | 495d7ff | 2019-07-12 09:15:26 +0000 | [diff] [blame] | 152 | rv = ipsec_sa_unlock_id (id); |
Sergio Gonzalez Monroy | d04b60b | 2017-01-20 15:35:23 +0000 | [diff] [blame] | 153 | |
Neale Ranns | 8d7c502 | 2019-02-06 01:41:05 -0800 | [diff] [blame] | 154 | if (rv) |
Neale Ranns | e6be702 | 2019-06-04 15:37:34 +0000 | [diff] [blame] | 155 | error = clib_error_return (0, "failed"); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 156 | |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 157 | done: |
| 158 | unformat_free (line_input); |
| 159 | |
| 160 | return error; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 161 | } |
| 162 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 163 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 164 | VLIB_CLI_COMMAND (ipsec_sa_add_del_command, static) = { |
| 165 | .path = "ipsec sa", |
| 166 | .short_help = |
| 167 | "ipsec sa [add|del]", |
| 168 | .function = ipsec_sa_add_del_command_fn, |
| 169 | }; |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 170 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 171 | |
| 172 | static clib_error_t * |
| 173 | ipsec_spd_add_del_command_fn (vlib_main_t * vm, |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 174 | unformat_input_t * input, |
| 175 | vlib_cli_command_t * cmd) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 176 | { |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 177 | unformat_input_t _line_input, *line_input = &_line_input; |
Damjan Marion | 3f54b18 | 2016-08-16 11:27:02 +0200 | [diff] [blame] | 178 | u32 spd_id = ~0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 179 | int is_add = ~0; |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 180 | clib_error_t *error = NULL; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 181 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 182 | if (!unformat_user (input, unformat_line_input, line_input)) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 183 | return 0; |
| 184 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 185 | while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) |
| 186 | { |
| 187 | if (unformat (line_input, "add")) |
| 188 | is_add = 1; |
| 189 | else if (unformat (line_input, "del")) |
| 190 | is_add = 0; |
| 191 | else if (unformat (line_input, "%u", &spd_id)) |
| 192 | ; |
| 193 | else |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 194 | { |
| 195 | error = clib_error_return (0, "parse error: '%U'", |
| 196 | format_unformat_error, line_input); |
| 197 | goto done; |
| 198 | } |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 199 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 200 | |
Damjan Marion | 3f54b18 | 2016-08-16 11:27:02 +0200 | [diff] [blame] | 201 | if (spd_id == ~0) |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 202 | { |
| 203 | error = clib_error_return (0, "please specify SPD ID"); |
| 204 | goto done; |
| 205 | } |
Damjan Marion | 3f54b18 | 2016-08-16 11:27:02 +0200 | [diff] [blame] | 206 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 207 | ipsec_add_del_spd (vm, spd_id, is_add); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 208 | |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 209 | done: |
| 210 | unformat_free (line_input); |
| 211 | |
| 212 | return error; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 213 | } |
| 214 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 215 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 216 | VLIB_CLI_COMMAND (ipsec_spd_add_del_command, static) = { |
| 217 | .path = "ipsec spd", |
| 218 | .short_help = |
| 219 | "ipsec spd [add|del] <id>", |
| 220 | .function = ipsec_spd_add_del_command_fn, |
| 221 | }; |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 222 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 223 | |
| 224 | |
| 225 | static clib_error_t * |
| 226 | ipsec_policy_add_del_command_fn (vlib_main_t * vm, |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 227 | unformat_input_t * input, |
| 228 | vlib_cli_command_t * cmd) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 229 | { |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 230 | unformat_input_t _line_input, *line_input = &_line_input; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 231 | ipsec_policy_t p; |
Neale Ranns | a09c1ff | 2019-02-04 01:10:30 -0800 | [diff] [blame] | 232 | int rv, is_add = 0; |
| 233 | u32 tmp, tmp2, stat_index; |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 234 | clib_error_t *error = NULL; |
Neale Ranns | 9f231d4 | 2019-03-19 10:06:00 +0000 | [diff] [blame] | 235 | u32 is_outbound; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 236 | |
Dave Barach | b7b9299 | 2018-10-17 10:38:51 -0400 | [diff] [blame] | 237 | clib_memset (&p, 0, sizeof (p)); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 238 | p.lport.stop = p.rport.stop = ~0; |
Neale Ranns | 9f231d4 | 2019-03-19 10:06:00 +0000 | [diff] [blame] | 239 | is_outbound = 0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 240 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 241 | if (!unformat_user (input, unformat_line_input, line_input)) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 242 | return 0; |
| 243 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 244 | while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) |
| 245 | { |
| 246 | if (unformat (line_input, "add")) |
| 247 | is_add = 1; |
| 248 | else if (unformat (line_input, "del")) |
| 249 | is_add = 0; |
| 250 | else if (unformat (line_input, "spd %u", &p.id)) |
| 251 | ; |
| 252 | else if (unformat (line_input, "inbound")) |
Neale Ranns | 9f231d4 | 2019-03-19 10:06:00 +0000 | [diff] [blame] | 253 | is_outbound = 0; |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 254 | else if (unformat (line_input, "outbound")) |
Neale Ranns | 9f231d4 | 2019-03-19 10:06:00 +0000 | [diff] [blame] | 255 | is_outbound = 1; |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 256 | else if (unformat (line_input, "priority %d", &p.priority)) |
| 257 | ; |
| 258 | else if (unformat (line_input, "protocol %u", &tmp)) |
| 259 | p.protocol = (u8) tmp; |
| 260 | else |
| 261 | if (unformat |
| 262 | (line_input, "action %U", unformat_ipsec_policy_action, |
| 263 | &p.policy)) |
| 264 | { |
| 265 | if (p.policy == IPSEC_POLICY_ACTION_RESOLVE) |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 266 | { |
| 267 | error = clib_error_return (0, "unsupported action: 'resolve'"); |
| 268 | goto done; |
| 269 | } |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 270 | } |
| 271 | else if (unformat (line_input, "sa %u", &p.sa_id)) |
| 272 | ; |
| 273 | else if (unformat (line_input, "local-ip-range %U - %U", |
| 274 | unformat_ip4_address, &p.laddr.start.ip4, |
| 275 | unformat_ip4_address, &p.laddr.stop.ip4)) |
Neale Ranns | a09c1ff | 2019-02-04 01:10:30 -0800 | [diff] [blame] | 276 | ; |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 277 | else if (unformat (line_input, "remote-ip-range %U - %U", |
| 278 | unformat_ip4_address, &p.raddr.start.ip4, |
| 279 | unformat_ip4_address, &p.raddr.stop.ip4)) |
Neale Ranns | a09c1ff | 2019-02-04 01:10:30 -0800 | [diff] [blame] | 280 | ; |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 281 | else if (unformat (line_input, "local-ip-range %U - %U", |
| 282 | unformat_ip6_address, &p.laddr.start.ip6, |
| 283 | unformat_ip6_address, &p.laddr.stop.ip6)) |
| 284 | { |
| 285 | p.is_ipv6 = 1; |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 286 | } |
| 287 | else if (unformat (line_input, "remote-ip-range %U - %U", |
| 288 | unformat_ip6_address, &p.raddr.start.ip6, |
| 289 | unformat_ip6_address, &p.raddr.stop.ip6)) |
| 290 | { |
| 291 | p.is_ipv6 = 1; |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 292 | } |
| 293 | else if (unformat (line_input, "local-port-range %u - %u", &tmp, &tmp2)) |
| 294 | { |
| 295 | p.lport.start = tmp; |
| 296 | p.lport.stop = tmp2; |
| 297 | } |
| 298 | else |
| 299 | if (unformat (line_input, "remote-port-range %u - %u", &tmp, &tmp2)) |
| 300 | { |
| 301 | p.rport.start = tmp; |
| 302 | p.rport.stop = tmp2; |
| 303 | } |
| 304 | else |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 305 | { |
| 306 | error = clib_error_return (0, "parse error: '%U'", |
| 307 | format_unformat_error, line_input); |
| 308 | goto done; |
| 309 | } |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 310 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 311 | |
Neale Ranns | 9f231d4 | 2019-03-19 10:06:00 +0000 | [diff] [blame] | 312 | rv = ipsec_policy_mk_type (is_outbound, p.is_ipv6, p.policy, &p.type); |
| 313 | |
| 314 | if (rv) |
| 315 | { |
| 316 | error = clib_error_return (0, "unsupported policy type for:", |
| 317 | " outboud:%s %s action:%U", |
| 318 | (is_outbound ? "yes" : "no"), |
| 319 | (p.is_ipv6 ? "IPv4" : "IPv6"), |
| 320 | format_ipsec_policy_action, p.policy); |
| 321 | goto done; |
| 322 | } |
| 323 | |
Neale Ranns | a09c1ff | 2019-02-04 01:10:30 -0800 | [diff] [blame] | 324 | rv = ipsec_add_del_policy (vm, &p, is_add, &stat_index); |
| 325 | |
| 326 | if (!rv) |
| 327 | vlib_cli_output (vm, "policy-index:%d", stat_index); |
| 328 | else |
| 329 | vlib_cli_output (vm, "error:%d", rv); |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 330 | |
| 331 | done: |
| 332 | unformat_free (line_input); |
| 333 | |
| 334 | return error; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 335 | } |
| 336 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 337 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 338 | VLIB_CLI_COMMAND (ipsec_policy_add_del_command, static) = { |
| 339 | .path = "ipsec policy", |
| 340 | .short_help = |
| 341 | "ipsec policy [add|del] spd <id> priority <n> ", |
| 342 | .function = ipsec_policy_add_del_command_fn, |
| 343 | }; |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 344 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 345 | |
Neale Ranns | b294f10 | 2019-04-03 13:17:50 +0000 | [diff] [blame] | 346 | static void |
Neale Ranns | 670027a | 2019-08-27 12:47:17 +0000 | [diff] [blame] | 347 | ipsec_sa_show_all (vlib_main_t * vm, ipsec_main_t * im, u8 detail) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 348 | { |
Neale Ranns | b294f10 | 2019-04-03 13:17:50 +0000 | [diff] [blame] | 349 | u32 sai; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 350 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 351 | /* *INDENT-OFF* */ |
Neale Ranns | 8d7c502 | 2019-02-06 01:41:05 -0800 | [diff] [blame] | 352 | pool_foreach_index (sai, im->sad, ({ |
Neale Ranns | 670027a | 2019-08-27 12:47:17 +0000 | [diff] [blame] | 353 | vlib_cli_output(vm, "%U", format_ipsec_sa, sai, |
| 354 | (detail ? IPSEC_FORMAT_DETAIL : IPSEC_FORMAT_BRIEF)); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 355 | })); |
Neale Ranns | b294f10 | 2019-04-03 13:17:50 +0000 | [diff] [blame] | 356 | /* *INDENT-ON* */ |
| 357 | } |
| 358 | |
| 359 | static void |
| 360 | ipsec_spd_show_all (vlib_main_t * vm, ipsec_main_t * im) |
| 361 | { |
| 362 | u32 spdi; |
| 363 | |
| 364 | /* *INDENT-OFF* */ |
| 365 | pool_foreach_index (spdi, im->spds, ({ |
| 366 | vlib_cli_output(vm, "%U", format_ipsec_spd, spdi); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 367 | })); |
Neale Ranns | b294f10 | 2019-04-03 13:17:50 +0000 | [diff] [blame] | 368 | /* *INDENT-ON* */ |
| 369 | } |
| 370 | |
| 371 | static void |
| 372 | ipsec_spd_bindings_show_all (vlib_main_t * vm, ipsec_main_t * im) |
| 373 | { |
| 374 | u32 spd_id, sw_if_index; |
Neale Ranns | d83c4a8 | 2019-06-14 06:48:27 -0700 | [diff] [blame] | 375 | ipsec_spd_t *spd; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 376 | |
Neale Ranns | 311124e | 2019-01-24 04:52:25 -0800 | [diff] [blame] | 377 | vlib_cli_output (vm, "SPD Bindings:"); |
Neale Ranns | 8d7c502 | 2019-02-06 01:41:05 -0800 | [diff] [blame] | 378 | |
Neale Ranns | b294f10 | 2019-04-03 13:17:50 +0000 | [diff] [blame] | 379 | /* *INDENT-OFF* */ |
Neale Ranns | 311124e | 2019-01-24 04:52:25 -0800 | [diff] [blame] | 380 | hash_foreach(sw_if_index, spd_id, im->spd_index_by_sw_if_index, ({ |
Neale Ranns | d83c4a8 | 2019-06-14 06:48:27 -0700 | [diff] [blame] | 381 | spd = pool_elt_at_index (im->spds, spd_id); |
| 382 | vlib_cli_output (vm, " %d -> %U", spd->id, |
Neale Ranns | 8d7c502 | 2019-02-06 01:41:05 -0800 | [diff] [blame] | 383 | format_vnet_sw_if_index_name, im->vnet_main, |
| 384 | sw_if_index); |
Neale Ranns | 311124e | 2019-01-24 04:52:25 -0800 | [diff] [blame] | 385 | })); |
| 386 | /* *INDENT-ON* */ |
Neale Ranns | b294f10 | 2019-04-03 13:17:50 +0000 | [diff] [blame] | 387 | } |
Neale Ranns | 311124e | 2019-01-24 04:52:25 -0800 | [diff] [blame] | 388 | |
Neale Ranns | b294f10 | 2019-04-03 13:17:50 +0000 | [diff] [blame] | 389 | static void |
| 390 | ipsec_tunnel_show_all (vlib_main_t * vm, ipsec_main_t * im) |
| 391 | { |
| 392 | u32 ti; |
| 393 | |
| 394 | vlib_cli_output (vm, "Tunnel interfaces"); |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 395 | /* *INDENT-OFF* */ |
Neale Ranns | b294f10 | 2019-04-03 13:17:50 +0000 | [diff] [blame] | 396 | pool_foreach_index (ti, im->tunnel_interfaces, ({ |
| 397 | vlib_cli_output(vm, " %U", format_ipsec_tunnel, ti); |
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 | /* *INDENT-ON* */ |
Neale Ranns | b294f10 | 2019-04-03 13:17:50 +0000 | [diff] [blame] | 400 | } |
| 401 | |
| 402 | static clib_error_t * |
| 403 | show_ipsec_command_fn (vlib_main_t * vm, |
| 404 | unformat_input_t * input, vlib_cli_command_t * cmd) |
| 405 | { |
| 406 | ipsec_main_t *im = &ipsec_main; |
| 407 | |
Neale Ranns | 670027a | 2019-08-27 12:47:17 +0000 | [diff] [blame] | 408 | ipsec_sa_show_all (vm, im, 0); |
Neale Ranns | b294f10 | 2019-04-03 13:17:50 +0000 | [diff] [blame] | 409 | ipsec_spd_show_all (vm, im); |
| 410 | ipsec_spd_bindings_show_all (vm, im); |
| 411 | ipsec_tunnel_show_all (vm, im); |
| 412 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 413 | return 0; |
| 414 | } |
| 415 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 416 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 417 | VLIB_CLI_COMMAND (show_ipsec_command, static) = { |
Neale Ranns | b294f10 | 2019-04-03 13:17:50 +0000 | [diff] [blame] | 418 | .path = "show ipsec all", |
| 419 | .short_help = "show ipsec all", |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 420 | .function = show_ipsec_command_fn, |
| 421 | }; |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 422 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 423 | |
| 424 | static clib_error_t * |
Neale Ranns | b294f10 | 2019-04-03 13:17:50 +0000 | [diff] [blame] | 425 | show_ipsec_sa_command_fn (vlib_main_t * vm, |
| 426 | unformat_input_t * input, vlib_cli_command_t * cmd) |
| 427 | { |
| 428 | ipsec_main_t *im = &ipsec_main; |
| 429 | u32 sai = ~0; |
Neale Ranns | 670027a | 2019-08-27 12:47:17 +0000 | [diff] [blame] | 430 | u8 detail = 0; |
Neale Ranns | b294f10 | 2019-04-03 13:17:50 +0000 | [diff] [blame] | 431 | |
| 432 | while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) |
| 433 | { |
| 434 | if (unformat (input, "%u", &sai)) |
| 435 | ; |
Neale Ranns | 670027a | 2019-08-27 12:47:17 +0000 | [diff] [blame] | 436 | if (unformat (input, "detail")) |
| 437 | detail = 1; |
Neale Ranns | b294f10 | 2019-04-03 13:17:50 +0000 | [diff] [blame] | 438 | else |
| 439 | break; |
| 440 | } |
| 441 | |
| 442 | if (~0 == sai) |
Neale Ranns | 670027a | 2019-08-27 12:47:17 +0000 | [diff] [blame] | 443 | ipsec_sa_show_all (vm, im, detail); |
Neale Ranns | b294f10 | 2019-04-03 13:17:50 +0000 | [diff] [blame] | 444 | else |
Christian E. Hopps | 01d61e7 | 2019-09-27 14:43:22 -0400 | [diff] [blame^] | 445 | vlib_cli_output (vm, "%U", format_ipsec_sa, sai, |
| 446 | IPSEC_FORMAT_DETAIL | IPSEC_FORMAT_INSECURE); |
Neale Ranns | b294f10 | 2019-04-03 13:17:50 +0000 | [diff] [blame] | 447 | |
| 448 | return 0; |
| 449 | } |
| 450 | |
Neale Ranns | c87b66c | 2019-02-07 07:26:12 -0800 | [diff] [blame] | 451 | static clib_error_t * |
| 452 | clear_ipsec_sa_command_fn (vlib_main_t * vm, |
| 453 | unformat_input_t * input, vlib_cli_command_t * cmd) |
| 454 | { |
| 455 | ipsec_main_t *im = &ipsec_main; |
| 456 | u32 sai = ~0; |
| 457 | |
| 458 | while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) |
| 459 | { |
| 460 | if (unformat (input, "%u", &sai)) |
| 461 | ; |
| 462 | else |
| 463 | break; |
| 464 | } |
| 465 | |
| 466 | if (~0 == sai) |
| 467 | { |
| 468 | /* *INDENT-OFF* */ |
| 469 | pool_foreach_index (sai, im->sad, ({ |
| 470 | ipsec_sa_clear(sai); |
| 471 | })); |
| 472 | /* *INDENT-ON* */ |
| 473 | } |
| 474 | else |
| 475 | { |
| 476 | if (pool_is_free_index (im->sad, sai)) |
| 477 | return clib_error_return (0, "unknown SA index: %d", sai); |
| 478 | else |
| 479 | ipsec_sa_clear (sai); |
| 480 | } |
| 481 | |
| 482 | return 0; |
| 483 | } |
| 484 | |
Neale Ranns | b294f10 | 2019-04-03 13:17:50 +0000 | [diff] [blame] | 485 | /* *INDENT-OFF* */ |
| 486 | VLIB_CLI_COMMAND (show_ipsec_sa_command, static) = { |
| 487 | .path = "show ipsec sa", |
| 488 | .short_help = "show ipsec sa [index]", |
| 489 | .function = show_ipsec_sa_command_fn, |
| 490 | }; |
Neale Ranns | c87b66c | 2019-02-07 07:26:12 -0800 | [diff] [blame] | 491 | |
| 492 | VLIB_CLI_COMMAND (clear_ipsec_sa_command, static) = { |
| 493 | .path = "clear ipsec sa", |
| 494 | .short_help = "clear ipsec sa [index]", |
| 495 | .function = clear_ipsec_sa_command_fn, |
| 496 | }; |
Neale Ranns | b294f10 | 2019-04-03 13:17:50 +0000 | [diff] [blame] | 497 | /* *INDENT-ON* */ |
| 498 | |
| 499 | static clib_error_t * |
| 500 | show_ipsec_spd_command_fn (vlib_main_t * vm, |
| 501 | unformat_input_t * input, vlib_cli_command_t * cmd) |
| 502 | { |
| 503 | ipsec_main_t *im = &ipsec_main; |
| 504 | u8 show_bindings = 0; |
| 505 | u32 spdi = ~0; |
| 506 | |
| 507 | while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) |
| 508 | { |
| 509 | if (unformat (input, "%u", &spdi)) |
| 510 | ; |
| 511 | else if (unformat (input, "bindings")) |
| 512 | show_bindings = 1; |
| 513 | else |
| 514 | break; |
| 515 | } |
| 516 | |
| 517 | if (show_bindings) |
| 518 | ipsec_spd_bindings_show_all (vm, im); |
| 519 | else if (~0 != spdi) |
| 520 | vlib_cli_output (vm, "%U", format_ipsec_spd, spdi); |
| 521 | else |
| 522 | ipsec_spd_show_all (vm, im); |
| 523 | |
| 524 | return 0; |
| 525 | } |
| 526 | |
| 527 | /* *INDENT-OFF* */ |
| 528 | VLIB_CLI_COMMAND (show_ipsec_spd_command, static) = { |
| 529 | .path = "show ipsec spd", |
| 530 | .short_help = "show ipsec spd [index]", |
| 531 | .function = show_ipsec_spd_command_fn, |
| 532 | }; |
| 533 | /* *INDENT-ON* */ |
| 534 | |
| 535 | static clib_error_t * |
| 536 | show_ipsec_tunnel_command_fn (vlib_main_t * vm, |
| 537 | unformat_input_t * input, |
| 538 | vlib_cli_command_t * cmd) |
| 539 | { |
| 540 | ipsec_main_t *im = &ipsec_main; |
| 541 | u32 ti = ~0; |
| 542 | |
| 543 | while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) |
| 544 | { |
| 545 | if (unformat (input, "%u", &ti)) |
| 546 | ; |
| 547 | else |
| 548 | break; |
| 549 | } |
| 550 | |
| 551 | if (~0 != ti) |
| 552 | vlib_cli_output (vm, "%U", format_ipsec_tunnel, ti); |
| 553 | else |
| 554 | ipsec_tunnel_show_all (vm, im); |
| 555 | |
| 556 | return 0; |
| 557 | } |
| 558 | |
| 559 | /* *INDENT-OFF* */ |
| 560 | VLIB_CLI_COMMAND (show_ipsec_tunnel_command, static) = { |
| 561 | .path = "show ipsec tunnel", |
| 562 | .short_help = "show ipsec tunnel [index]", |
| 563 | .function = show_ipsec_tunnel_command_fn, |
| 564 | }; |
| 565 | /* *INDENT-ON* */ |
| 566 | |
| 567 | static clib_error_t * |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 568 | ipsec_show_backends_command_fn (vlib_main_t * vm, |
| 569 | unformat_input_t * input, |
| 570 | vlib_cli_command_t * cmd) |
| 571 | { |
| 572 | ipsec_main_t *im = &ipsec_main; |
| 573 | u32 verbose = 0; |
| 574 | |
| 575 | (void) unformat (input, "verbose %u", &verbose); |
| 576 | |
| 577 | vlib_cli_output (vm, "IPsec AH backends available:"); |
| 578 | u8 *s = format (NULL, "%=25s %=25s %=10s\n", "Name", "Index", "Active"); |
| 579 | ipsec_ah_backend_t *ab; |
| 580 | /* *INDENT-OFF* */ |
| 581 | pool_foreach (ab, im->ah_backends, { |
| 582 | s = format (s, "%=25s %=25u %=10s\n", ab->name, ab - im->ah_backends, |
| 583 | ab - im->ah_backends == im->ah_current_backend ? "yes" : "no"); |
| 584 | if (verbose) { |
| 585 | vlib_node_t *n; |
| 586 | n = vlib_get_node (vm, ab->ah4_encrypt_node_index); |
| 587 | s = format (s, " enc4 %s (next %d)\n", n->name, ab->ah4_encrypt_next_index); |
| 588 | n = vlib_get_node (vm, ab->ah4_decrypt_node_index); |
| 589 | s = format (s, " dec4 %s (next %d)\n", n->name, ab->ah4_decrypt_next_index); |
| 590 | n = vlib_get_node (vm, ab->ah6_encrypt_node_index); |
| 591 | s = format (s, " enc6 %s (next %d)\n", n->name, ab->ah6_encrypt_next_index); |
| 592 | n = vlib_get_node (vm, ab->ah6_decrypt_node_index); |
| 593 | s = format (s, " dec6 %s (next %d)\n", n->name, ab->ah6_decrypt_next_index); |
| 594 | } |
| 595 | }); |
| 596 | /* *INDENT-ON* */ |
| 597 | vlib_cli_output (vm, "%v", s); |
| 598 | _vec_len (s) = 0; |
| 599 | vlib_cli_output (vm, "IPsec ESP backends available:"); |
| 600 | s = format (s, "%=25s %=25s %=10s\n", "Name", "Index", "Active"); |
| 601 | ipsec_esp_backend_t *eb; |
| 602 | /* *INDENT-OFF* */ |
| 603 | pool_foreach (eb, im->esp_backends, { |
| 604 | s = format (s, "%=25s %=25u %=10s\n", eb->name, eb - im->esp_backends, |
| 605 | eb - im->esp_backends == im->esp_current_backend ? "yes" |
| 606 | : "no"); |
| 607 | if (verbose) { |
| 608 | vlib_node_t *n; |
| 609 | n = vlib_get_node (vm, eb->esp4_encrypt_node_index); |
| 610 | s = format (s, " enc4 %s (next %d)\n", n->name, eb->esp4_encrypt_next_index); |
| 611 | n = vlib_get_node (vm, eb->esp4_decrypt_node_index); |
| 612 | s = format (s, " dec4 %s (next %d)\n", n->name, eb->esp4_decrypt_next_index); |
| 613 | n = vlib_get_node (vm, eb->esp6_encrypt_node_index); |
| 614 | s = format (s, " enc6 %s (next %d)\n", n->name, eb->esp6_encrypt_next_index); |
| 615 | n = vlib_get_node (vm, eb->esp6_decrypt_node_index); |
| 616 | s = format (s, " dec6 %s (next %d)\n", n->name, eb->esp6_decrypt_next_index); |
| 617 | } |
| 618 | }); |
| 619 | /* *INDENT-ON* */ |
| 620 | vlib_cli_output (vm, "%v", s); |
| 621 | |
| 622 | vec_free (s); |
| 623 | return 0; |
| 624 | } |
| 625 | |
| 626 | /* *INDENT-OFF* */ |
| 627 | VLIB_CLI_COMMAND (ipsec_show_backends_command, static) = { |
| 628 | .path = "show ipsec backends", |
| 629 | .short_help = "show ipsec backends", |
| 630 | .function = ipsec_show_backends_command_fn, |
| 631 | }; |
| 632 | /* *INDENT-ON* */ |
| 633 | |
| 634 | static clib_error_t * |
| 635 | ipsec_select_backend_command_fn (vlib_main_t * vm, |
| 636 | unformat_input_t * input, |
| 637 | vlib_cli_command_t * cmd) |
| 638 | { |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 639 | unformat_input_t _line_input, *line_input = &_line_input; |
Neale Ranns | e8915fc | 2019-04-23 20:57:55 -0400 | [diff] [blame] | 640 | ipsec_main_t *im = &ipsec_main; |
| 641 | clib_error_t *error; |
| 642 | u32 backend_index; |
| 643 | |
| 644 | error = ipsec_rsc_in_use (im); |
| 645 | |
| 646 | if (error) |
| 647 | return error; |
| 648 | |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 649 | /* Get a line of input. */ |
| 650 | if (!unformat_user (input, unformat_line_input, line_input)) |
| 651 | return 0; |
| 652 | |
| 653 | if (unformat (line_input, "ah")) |
| 654 | { |
| 655 | if (unformat (line_input, "%u", &backend_index)) |
| 656 | { |
| 657 | if (ipsec_select_ah_backend (im, backend_index) < 0) |
| 658 | { |
| 659 | return clib_error_return (0, "Invalid AH backend index `%u'", |
| 660 | backend_index); |
| 661 | } |
| 662 | } |
| 663 | else |
| 664 | { |
| 665 | return clib_error_return (0, "Invalid backend index `%U'", |
| 666 | format_unformat_error, line_input); |
| 667 | } |
| 668 | } |
| 669 | else if (unformat (line_input, "esp")) |
| 670 | { |
| 671 | if (unformat (line_input, "%u", &backend_index)) |
| 672 | { |
| 673 | if (ipsec_select_esp_backend (im, backend_index) < 0) |
| 674 | { |
| 675 | return clib_error_return (0, "Invalid ESP backend index `%u'", |
| 676 | backend_index); |
| 677 | } |
| 678 | } |
| 679 | else |
| 680 | { |
| 681 | return clib_error_return (0, "Invalid backend index `%U'", |
| 682 | format_unformat_error, line_input); |
| 683 | } |
| 684 | } |
| 685 | else |
| 686 | { |
| 687 | return clib_error_return (0, "Unknown input `%U'", |
| 688 | format_unformat_error, line_input); |
| 689 | } |
| 690 | |
| 691 | return 0; |
| 692 | } |
| 693 | |
| 694 | /* *INDENT-OFF* */ |
| 695 | VLIB_CLI_COMMAND (ipsec_select_backend_command, static) = { |
| 696 | .path = "ipsec select backend", |
| 697 | .short_help = "ipsec select backend <ah|esp> <backend index>", |
| 698 | .function = ipsec_select_backend_command_fn, |
| 699 | }; |
| 700 | |
| 701 | /* *INDENT-ON* */ |
| 702 | |
| 703 | static clib_error_t * |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 704 | clear_ipsec_counters_command_fn (vlib_main_t * vm, |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 705 | unformat_input_t * input, |
| 706 | vlib_cli_command_t * cmd) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 707 | { |
Neale Ranns | a09c1ff | 2019-02-04 01:10:30 -0800 | [diff] [blame] | 708 | vlib_clear_combined_counters (&ipsec_spd_policy_counters); |
Neale Ranns | eba31ec | 2019-02-17 18:04:27 +0000 | [diff] [blame] | 709 | vlib_clear_combined_counters (&ipsec_sa_counters); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 710 | |
Neale Ranns | a09c1ff | 2019-02-04 01:10:30 -0800 | [diff] [blame] | 711 | return (NULL); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 712 | } |
| 713 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 714 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 715 | VLIB_CLI_COMMAND (clear_ipsec_counters_command, static) = { |
| 716 | .path = "clear ipsec counters", |
| 717 | .short_help = "clear ipsec counters", |
| 718 | .function = clear_ipsec_counters_command_fn, |
| 719 | }; |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 720 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 721 | |
| 722 | static clib_error_t * |
| 723 | create_ipsec_tunnel_command_fn (vlib_main_t * vm, |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 724 | unformat_input_t * input, |
| 725 | vlib_cli_command_t * cmd) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 726 | { |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 727 | unformat_input_t _line_input, *line_input = &_line_input; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 728 | ipsec_add_del_tunnel_args_t a; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 729 | int rv; |
| 730 | u32 num_m_args = 0; |
Kingwel Xie | 72b3bce | 2019-02-12 06:45:08 -0500 | [diff] [blame] | 731 | u8 ipv4_set = 0; |
| 732 | u8 ipv6_set = 0; |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 733 | clib_error_t *error = NULL; |
Kingwel Xie | d3d1205 | 2019-03-07 06:34:30 -0500 | [diff] [blame] | 734 | ipsec_key_t rck = { 0 }; |
| 735 | ipsec_key_t lck = { 0 }; |
| 736 | ipsec_key_t lik = { 0 }; |
| 737 | ipsec_key_t rik = { 0 }; |
Matthew Smith | 2838a23 | 2016-06-21 16:05:09 -0500 | [diff] [blame] | 738 | |
Dave Barach | b7b9299 | 2018-10-17 10:38:51 -0400 | [diff] [blame] | 739 | clib_memset (&a, 0, sizeof (a)); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 740 | a.is_add = 1; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 741 | |
| 742 | /* Get a line of input. */ |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 743 | if (!unformat_user (input, unformat_line_input, line_input)) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 744 | return 0; |
| 745 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 746 | while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) |
| 747 | { |
| 748 | if (unformat |
Kingwel Xie | 72b3bce | 2019-02-12 06:45:08 -0500 | [diff] [blame] | 749 | (line_input, "local-ip %U", unformat_ip46_address, &a.local_ip, |
| 750 | IP46_TYPE_ANY)) |
| 751 | { |
| 752 | ip46_address_is_ip4 (&a.local_ip) ? (ipv4_set = 1) : (ipv6_set = 1); |
| 753 | num_m_args++; |
| 754 | } |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 755 | else |
| 756 | if (unformat |
Kingwel Xie | 72b3bce | 2019-02-12 06:45:08 -0500 | [diff] [blame] | 757 | (line_input, "remote-ip %U", unformat_ip46_address, &a.remote_ip, |
| 758 | IP46_TYPE_ANY)) |
| 759 | { |
| 760 | ip46_address_is_ip4 (&a.remote_ip) ? (ipv4_set = 1) : (ipv6_set = |
| 761 | 1); |
| 762 | num_m_args++; |
| 763 | } |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 764 | else if (unformat (line_input, "local-spi %u", &a.local_spi)) |
| 765 | num_m_args++; |
| 766 | else if (unformat (line_input, "remote-spi %u", &a.remote_spi)) |
| 767 | num_m_args++; |
Matthew Smith | 8e1039a | 2018-04-12 07:32:56 -0500 | [diff] [blame] | 768 | else if (unformat (line_input, "instance %u", &a.show_instance)) |
| 769 | a.renumber = 1; |
Neale Ranns | 47feb11 | 2019-04-11 15:14:07 +0000 | [diff] [blame] | 770 | else if (unformat (line_input, "salt 0x%x", &a.salt)) |
| 771 | ; |
Radu Nicolau | 717de09 | 2018-08-03 10:37:24 +0100 | [diff] [blame] | 772 | else if (unformat (line_input, "udp-encap")) |
| 773 | a.udp_encap = 1; |
Kingwel Xie | 2baf942 | 2019-02-04 02:07:06 -0800 | [diff] [blame] | 774 | else if (unformat (line_input, "use-esn")) |
| 775 | a.esn = 1; |
| 776 | else if (unformat (line_input, "use-anti-replay")) |
| 777 | a.anti_replay = 1; |
Pierre Pfister | 4c422f9 | 2018-12-10 11:19:08 +0100 | [diff] [blame] | 778 | else if (unformat (line_input, "tx-table %u", &a.tx_table_id)) |
| 779 | ; |
Neale Ranns | fd06084 | 2019-03-04 13:44:42 +0000 | [diff] [blame] | 780 | else |
| 781 | if (unformat |
| 782 | (line_input, "local-crypto-key %U", unformat_ipsec_key, &lck)) |
| 783 | ; |
| 784 | else |
| 785 | if (unformat |
| 786 | (line_input, "remote-crypto-key %U", unformat_ipsec_key, &rck)) |
| 787 | ; |
| 788 | else if (unformat (line_input, "crypto-alg %U", |
| 789 | unformat_ipsec_crypto_alg, &a.crypto_alg)) |
| 790 | ; |
| 791 | else |
| 792 | if (unformat |
| 793 | (line_input, "local-integ-key %U", unformat_ipsec_key, &lik)) |
| 794 | ; |
| 795 | else |
| 796 | if (unformat |
Simon Zhang | e8e950a | 2019-04-23 23:04:07 +0800 | [diff] [blame] | 797 | (line_input, "remote-integ-key %U", unformat_ipsec_key, &rik)) |
Neale Ranns | fd06084 | 2019-03-04 13:44:42 +0000 | [diff] [blame] | 798 | ; |
| 799 | else if (unformat (line_input, "integ-alg %U", |
| 800 | unformat_ipsec_integ_alg, &a.integ_alg)) |
| 801 | ; |
Kingwel Xie | 2baf942 | 2019-02-04 02:07:06 -0800 | [diff] [blame] | 802 | else if (unformat (line_input, "del")) |
| 803 | a.is_add = 0; |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 804 | else |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 805 | { |
| 806 | error = clib_error_return (0, "unknown input `%U'", |
| 807 | format_unformat_error, line_input); |
| 808 | goto done; |
| 809 | } |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 810 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 811 | |
| 812 | if (num_m_args < 4) |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 813 | { |
| 814 | error = clib_error_return (0, "mandatory argument(s) missing"); |
| 815 | goto done; |
| 816 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 817 | |
Kingwel Xie | 72b3bce | 2019-02-12 06:45:08 -0500 | [diff] [blame] | 818 | if (ipv4_set && ipv6_set) |
| 819 | return clib_error_return (0, "both IPv4 and IPv6 addresses specified"); |
| 820 | |
Kingwel Xie | 1ba5bc8 | 2019-03-20 07:21:58 -0400 | [diff] [blame] | 821 | a.is_ip6 = ipv6_set; |
| 822 | |
Neale Ranns | fd06084 | 2019-03-04 13:44:42 +0000 | [diff] [blame] | 823 | clib_memcpy (a.local_crypto_key, lck.data, lck.len); |
| 824 | a.local_crypto_key_len = lck.len; |
| 825 | clib_memcpy (a.remote_crypto_key, rck.data, rck.len); |
| 826 | a.remote_crypto_key_len = rck.len; |
| 827 | |
Kingwel Xie | d3d1205 | 2019-03-07 06:34:30 -0500 | [diff] [blame] | 828 | clib_memcpy (a.local_integ_key, lik.data, lik.len); |
Neale Ranns | fd06084 | 2019-03-04 13:44:42 +0000 | [diff] [blame] | 829 | a.local_integ_key_len = lck.len; |
Kingwel Xie | d3d1205 | 2019-03-07 06:34:30 -0500 | [diff] [blame] | 830 | clib_memcpy (a.remote_integ_key, rik.data, rik.len); |
Neale Ranns | fd06084 | 2019-03-04 13:44:42 +0000 | [diff] [blame] | 831 | a.remote_integ_key_len = rck.len; |
| 832 | |
Matthew Smith | 2838a23 | 2016-06-21 16:05:09 -0500 | [diff] [blame] | 833 | rv = ipsec_add_del_tunnel_if (&a); |
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 | switch (rv) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 836 | { |
| 837 | case 0: |
| 838 | break; |
| 839 | case VNET_API_ERROR_INVALID_VALUE: |
| 840 | if (a.is_add) |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 841 | error = clib_error_return (0, |
| 842 | "IPSec tunnel interface already exists..."); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 843 | else |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 844 | error = clib_error_return (0, "IPSec tunnel interface not exists..."); |
| 845 | goto done; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 846 | default: |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 847 | error = clib_error_return (0, "ipsec_register_interface returned %d", |
| 848 | rv); |
| 849 | goto done; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 850 | } |
| 851 | |
Billy McFall | a9a20e7 | 2017-02-15 11:39:12 -0500 | [diff] [blame] | 852 | done: |
| 853 | unformat_free (line_input); |
| 854 | |
| 855 | return error; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 856 | } |
| 857 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 858 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 859 | VLIB_CLI_COMMAND (create_ipsec_tunnel_command, static) = { |
| 860 | .path = "create ipsec tunnel", |
Pierre Pfister | 4c422f9 | 2018-12-10 11:19:08 +0100 | [diff] [blame] | 861 | .short_help = "create ipsec tunnel local-ip <addr> local-spi <spi> " |
Kingwel Xie | 2baf942 | 2019-02-04 02:07:06 -0800 | [diff] [blame] | 862 | "remote-ip <addr> remote-spi <spi> [instance <inst_num>] [udp-encap] [use-esn] [use-anti-replay] " |
Pierre Pfister | 4c422f9 | 2018-12-10 11:19:08 +0100 | [diff] [blame] | 863 | "[tx-table <table-id>]", |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 864 | .function = create_ipsec_tunnel_command_fn, |
| 865 | }; |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 866 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 867 | |
Neale Ranns | c87b66c | 2019-02-07 07:26:12 -0800 | [diff] [blame] | 868 | static clib_error_t * |
| 869 | ipsec_tun_protect_cmd (vlib_main_t * vm, |
| 870 | unformat_input_t * input, vlib_cli_command_t * cmd) |
| 871 | { |
| 872 | unformat_input_t _line_input, *line_input = &_line_input; |
| 873 | u32 sw_if_index, is_del, sa_in, sa_out, *sa_ins = NULL; |
| 874 | vnet_main_t *vnm; |
| 875 | |
| 876 | is_del = 0; |
| 877 | sw_if_index = ~0; |
| 878 | vnm = vnet_get_main (); |
| 879 | |
| 880 | if (!unformat_user (input, unformat_line_input, line_input)) |
| 881 | return 0; |
| 882 | |
| 883 | while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) |
| 884 | { |
| 885 | if (unformat (line_input, "del")) |
| 886 | is_del = 1; |
| 887 | else if (unformat (line_input, "add")) |
| 888 | is_del = 0; |
| 889 | else if (unformat (line_input, "sa-in %d", &sa_in)) |
| 890 | vec_add1 (sa_ins, sa_in); |
| 891 | else if (unformat (line_input, "sa-out %d", &sa_out)) |
| 892 | ; |
| 893 | else if (unformat (line_input, "%U", |
| 894 | unformat_vnet_sw_interface, vnm, &sw_if_index)) |
| 895 | ; |
| 896 | else |
| 897 | return (clib_error_return (0, "unknown input '%U'", |
| 898 | format_unformat_error, line_input)); |
| 899 | } |
| 900 | |
| 901 | if (!is_del) |
| 902 | ipsec_tun_protect_update (sw_if_index, sa_out, sa_ins); |
| 903 | |
| 904 | unformat_free (line_input); |
| 905 | return NULL; |
| 906 | } |
| 907 | |
| 908 | /** |
| 909 | * Protect tunnel with IPSEC |
| 910 | */ |
| 911 | /* *INDENT-OFF* */ |
| 912 | VLIB_CLI_COMMAND (ipsec_tun_protect_cmd_node, static) = |
| 913 | { |
| 914 | .path = "ipsec tunnel protect", |
| 915 | .function = ipsec_tun_protect_cmd, |
| 916 | .short_help = "ipsec tunnel protect <interface> input-sa <SA> output-sa <SA>", |
| 917 | // this is not MP safe |
| 918 | }; |
| 919 | /* *INDENT-ON* */ |
| 920 | |
| 921 | static walk_rc_t |
| 922 | ipsec_tun_protect_show_one (index_t itpi, void *ctx) |
| 923 | { |
| 924 | vlib_cli_output (ctx, "%U", format_ipsec_tun_protect, itpi); |
| 925 | |
| 926 | return (WALK_CONTINUE); |
| 927 | } |
| 928 | |
| 929 | static clib_error_t * |
| 930 | ipsec_tun_protect_show (vlib_main_t * vm, |
| 931 | unformat_input_t * input, vlib_cli_command_t * cmd) |
| 932 | { |
| 933 | ipsec_tun_protect_walk (ipsec_tun_protect_show_one, vm); |
| 934 | |
| 935 | return NULL; |
| 936 | } |
| 937 | |
| 938 | /** |
| 939 | * show IPSEC tunnel protection |
| 940 | */ |
| 941 | /* *INDENT-OFF* */ |
| 942 | VLIB_CLI_COMMAND (ipsec_tun_protect_show_node, static) = |
| 943 | { |
| 944 | .path = "show ipsec protect", |
| 945 | .function = ipsec_tun_protect_show, |
| 946 | .short_help = "show ipsec protect", |
| 947 | }; |
| 948 | /* *INDENT-ON* */ |
| 949 | |
Neale Ranns | 41afb33 | 2019-07-16 06:19:35 -0700 | [diff] [blame] | 950 | static clib_error_t * |
| 951 | ipsec_tun_protect_hash_show (vlib_main_t * vm, |
| 952 | unformat_input_t * input, |
| 953 | vlib_cli_command_t * cmd) |
| 954 | { |
| 955 | ipsec_main_t *im = &ipsec_main; |
| 956 | |
| 957 | { |
| 958 | ipsec_tun_lkup_result_t value; |
| 959 | ipsec4_tunnel_key_t key; |
| 960 | |
| 961 | vlib_cli_output (vm, "IPv4:"); |
| 962 | |
| 963 | /* *INDENT-OFF* */ |
| 964 | hash_foreach(key.as_u64, value.as_u64, im->tun4_protect_by_key, |
| 965 | ({ |
| 966 | vlib_cli_output (vm, " %U", format_ipsec4_tunnel_key, &key); |
| 967 | vlib_cli_output (vm, " tun:%d sa:%d", value.tun_index, value.sa_index); |
| 968 | })); |
| 969 | /* *INDENT-ON* */ |
| 970 | } |
| 971 | |
| 972 | { |
| 973 | ipsec_tun_lkup_result_t value; |
| 974 | ipsec6_tunnel_key_t *key; |
| 975 | |
| 976 | vlib_cli_output (vm, "IPv6:"); |
| 977 | |
| 978 | /* *INDENT-OFF* */ |
| 979 | hash_foreach_mem(key, value.as_u64, im->tun6_protect_by_key, |
| 980 | ({ |
| 981 | vlib_cli_output (vm, " %U", format_ipsec6_tunnel_key, key); |
| 982 | vlib_cli_output (vm, " tun:%d sa:%d", value.tun_index, value.sa_index); |
| 983 | })); |
| 984 | /* *INDENT-ON* */ |
| 985 | } |
| 986 | |
| 987 | return NULL; |
| 988 | } |
| 989 | |
| 990 | /** |
| 991 | * show IPSEC tunnel protection hash tables |
| 992 | */ |
| 993 | /* *INDENT-OFF* */ |
| 994 | VLIB_CLI_COMMAND (ipsec_tun_protect_hash_show_node, static) = |
| 995 | { |
| 996 | .path = "show ipsec protect-hash", |
| 997 | .function = ipsec_tun_protect_hash_show, |
| 998 | .short_help = "show ipsec protect-hash", |
| 999 | }; |
| 1000 | /* *INDENT-ON* */ |
| 1001 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1002 | clib_error_t * |
| 1003 | ipsec_cli_init (vlib_main_t * vm) |
| 1004 | { |
| 1005 | return 0; |
| 1006 | } |
| 1007 | |
| 1008 | VLIB_INIT_FUNCTION (ipsec_cli_init); |
| 1009 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 1010 | |
| 1011 | /* |
| 1012 | * fd.io coding-style-patch-verification: ON |
| 1013 | * |
| 1014 | * Local Variables: |
| 1015 | * eval: (c-set-style "gnu") |
| 1016 | * End: |
| 1017 | */ |