Neale Ranns | d91c1db | 2017-07-31 02:30:50 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015 Cisco and/or its affiliates. |
| 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | * you may not use this file except in compliance with the License. |
| 5 | * You may obtain a copy of the License at: |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 9 | * Unless required by applicable law or agreed to in writing, software |
| 10 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | * See the License for the specific language governing permissions and |
| 13 | * limitations under the License. |
| 14 | */ |
| 15 | |
| 16 | #include <vnet/ip/ip.h> |
| 17 | #include <vnet/ip/ip_punt_drop.h> |
| 18 | #include <vnet/policer/policer.h> |
| 19 | #include <vnet/policer/police_inlines.h> |
| 20 | |
| 21 | /* *INDENT-OFF* */ |
| 22 | VNET_FEATURE_ARC_INIT (ip6_punt) = |
| 23 | { |
| 24 | .arc_name = "ip6-punt", |
| 25 | .start_nodes = VNET_FEATURES ("ip6-punt"), |
| 26 | }; |
| 27 | |
| 28 | VNET_FEATURE_ARC_INIT (ip6_drop) = |
| 29 | { |
| 30 | .arc_name = "ip6-drop", |
Neale Ranns | 8269d3d | 2018-01-30 09:02:20 -0800 | [diff] [blame] | 31 | .start_nodes = VNET_FEATURES ("ip6-drop", "ip6-not-enabled"), |
Neale Ranns | d91c1db | 2017-07-31 02:30:50 -0700 | [diff] [blame] | 32 | }; |
| 33 | /* *INDENT-ON* */ |
| 34 | |
Filip Tehlar | 26ea14e | 2019-03-11 05:30:21 -0700 | [diff] [blame] | 35 | extern ip_punt_policer_t ip6_punt_policer_cfg; |
| 36 | |
| 37 | #ifndef CLIB_MARCH_VARIANT |
Neale Ranns | d91c1db | 2017-07-31 02:30:50 -0700 | [diff] [blame] | 38 | ip_punt_policer_t ip6_punt_policer_cfg; |
Filip Tehlar | 26ea14e | 2019-03-11 05:30:21 -0700 | [diff] [blame] | 39 | #endif /* CLIB_MARCH_VARIANT */ |
Neale Ranns | d91c1db | 2017-07-31 02:30:50 -0700 | [diff] [blame] | 40 | |
Brian Russell | 1b2e16a | 2021-01-21 14:44:09 +0000 | [diff] [blame] | 41 | static char *ip6_punt_policer_handoff_error_strings[] = { "congestion drop" }; |
| 42 | |
| 43 | VLIB_NODE_FN (ip6_punt_policer_handoff_node) |
| 44 | (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame) |
| 45 | { |
| 46 | return policer_handoff (vm, node, frame, ip6_punt_policer_cfg.fq_index, |
| 47 | ip6_punt_policer_cfg.policer_index); |
| 48 | } |
| 49 | |
| 50 | VLIB_REGISTER_NODE (ip6_punt_policer_handoff_node) = { |
| 51 | .name = "ip6-punt-policer-handoff", |
| 52 | .vector_size = sizeof (u32), |
| 53 | .format_trace = format_policer_handoff_trace, |
| 54 | .type = VLIB_NODE_TYPE_INTERNAL, |
| 55 | .n_errors = ARRAY_LEN(ip6_punt_policer_handoff_error_strings), |
| 56 | .error_strings = ip6_punt_policer_handoff_error_strings, |
| 57 | |
| 58 | .n_next_nodes = 1, |
| 59 | .next_nodes = { |
| 60 | [0] = "error-drop", |
| 61 | }, |
| 62 | }; |
| 63 | |
Neale Ranns | d91c1db | 2017-07-31 02:30:50 -0700 | [diff] [blame] | 64 | static char *ip6_punt_policer_error_strings[] = { |
| 65 | #define _(sym,string) string, |
| 66 | foreach_ip_punt_policer_error |
| 67 | #undef _ |
| 68 | }; |
| 69 | |
Filip Tehlar | 26ea14e | 2019-03-11 05:30:21 -0700 | [diff] [blame] | 70 | VLIB_NODE_FN (ip6_punt_policer_node) (vlib_main_t * vm, |
| 71 | vlib_node_runtime_t * node, |
| 72 | vlib_frame_t * frame) |
Neale Ranns | d91c1db | 2017-07-31 02:30:50 -0700 | [diff] [blame] | 73 | { |
| 74 | return (ip_punt_policer (vm, node, frame, |
| 75 | vnet_feat_arc_ip6_punt.feature_arc_index, |
| 76 | ip6_punt_policer_cfg.policer_index)); |
| 77 | } |
| 78 | |
| 79 | |
| 80 | /* *INDENT-OFF* */ |
| 81 | |
Filip Tehlar | 26ea14e | 2019-03-11 05:30:21 -0700 | [diff] [blame] | 82 | VLIB_REGISTER_NODE (ip6_punt_policer_node) = { |
Neale Ranns | d91c1db | 2017-07-31 02:30:50 -0700 | [diff] [blame] | 83 | .name = "ip6-punt-policer", |
| 84 | .vector_size = sizeof (u32), |
| 85 | .n_next_nodes = IP_PUNT_POLICER_N_NEXT, |
| 86 | .format_trace = format_ip_punt_policer_trace, |
| 87 | .n_errors = ARRAY_LEN(ip6_punt_policer_error_strings), |
| 88 | .error_strings = ip6_punt_policer_error_strings, |
| 89 | |
| 90 | /* edit / add dispositions here */ |
| 91 | .next_nodes = { |
| 92 | [IP_PUNT_POLICER_NEXT_DROP] = "ip6-drop", |
Brian Russell | 1b2e16a | 2021-01-21 14:44:09 +0000 | [diff] [blame] | 93 | [IP_PUNT_POLICER_NEXT_HANDOFF] = "ip6-punt-policer-handoff", |
Neale Ranns | d91c1db | 2017-07-31 02:30:50 -0700 | [diff] [blame] | 94 | }, |
| 95 | }; |
| 96 | |
Neale Ranns | d91c1db | 2017-07-31 02:30:50 -0700 | [diff] [blame] | 97 | VNET_FEATURE_INIT (ip6_punt_policer_node, static) = { |
| 98 | .arc_name = "ip6-punt", |
| 99 | .node_name = "ip6-punt-policer", |
| 100 | .runs_before = VNET_FEATURES("ip6-punt-redirect") |
| 101 | }; |
| 102 | /* *INDENT-ON* */ |
| 103 | |
Filip Tehlar | 26ea14e | 2019-03-11 05:30:21 -0700 | [diff] [blame] | 104 | VLIB_NODE_FN (ip6_drop_node) (vlib_main_t * vm, vlib_node_runtime_t * node, |
| 105 | vlib_frame_t * frame) |
Neale Ranns | d91c1db | 2017-07-31 02:30:50 -0700 | [diff] [blame] | 106 | { |
| 107 | if (node->flags & VLIB_NODE_FLAG_TRACE) |
| 108 | ip6_forward_next_trace (vm, node, frame, VLIB_TX); |
| 109 | |
| 110 | return ip_drop_or_punt (vm, node, frame, |
| 111 | vnet_feat_arc_ip6_drop.feature_arc_index); |
| 112 | |
| 113 | } |
| 114 | |
Filip Tehlar | 26ea14e | 2019-03-11 05:30:21 -0700 | [diff] [blame] | 115 | VLIB_NODE_FN (ip6_not_enabled_node) (vlib_main_t * vm, |
| 116 | vlib_node_runtime_t * node, |
| 117 | vlib_frame_t * frame) |
Neale Ranns | 8269d3d | 2018-01-30 09:02:20 -0800 | [diff] [blame] | 118 | { |
| 119 | if (node->flags & VLIB_NODE_FLAG_TRACE) |
| 120 | ip6_forward_next_trace (vm, node, frame, VLIB_TX); |
| 121 | |
| 122 | return ip_drop_or_punt (vm, node, frame, |
| 123 | vnet_feat_arc_ip6_drop.feature_arc_index); |
| 124 | |
| 125 | } |
| 126 | |
Filip Tehlar | 26ea14e | 2019-03-11 05:30:21 -0700 | [diff] [blame] | 127 | VLIB_NODE_FN (ip6_punt_node) (vlib_main_t * vm, vlib_node_runtime_t * node, |
| 128 | vlib_frame_t * frame) |
Neale Ranns | d91c1db | 2017-07-31 02:30:50 -0700 | [diff] [blame] | 129 | { |
| 130 | if (node->flags & VLIB_NODE_FLAG_TRACE) |
| 131 | ip6_forward_next_trace (vm, node, frame, VLIB_TX); |
| 132 | |
| 133 | return ip_drop_or_punt (vm, node, frame, |
| 134 | vnet_feat_arc_ip6_punt.feature_arc_index); |
| 135 | } |
| 136 | |
| 137 | /* *INDENT-OFF* */ |
Filip Tehlar | 26ea14e | 2019-03-11 05:30:21 -0700 | [diff] [blame] | 138 | VLIB_REGISTER_NODE (ip6_drop_node) = |
Neale Ranns | d91c1db | 2017-07-31 02:30:50 -0700 | [diff] [blame] | 139 | { |
Neale Ranns | d91c1db | 2017-07-31 02:30:50 -0700 | [diff] [blame] | 140 | .name = "ip6-drop", |
| 141 | .vector_size = sizeof (u32), |
| 142 | .format_trace = format_ip6_forward_next_trace, |
| 143 | .n_next_nodes = 1, |
| 144 | .next_nodes = { |
| 145 | [0] = "error-drop", |
| 146 | }, |
| 147 | }; |
| 148 | |
Filip Tehlar | 26ea14e | 2019-03-11 05:30:21 -0700 | [diff] [blame] | 149 | VLIB_REGISTER_NODE (ip6_not_enabled_node) = |
Neale Ranns | 8269d3d | 2018-01-30 09:02:20 -0800 | [diff] [blame] | 150 | { |
Neale Ranns | 8269d3d | 2018-01-30 09:02:20 -0800 | [diff] [blame] | 151 | .name = "ip6-not-enabled", |
| 152 | .vector_size = sizeof (u32), |
| 153 | .format_trace = format_ip6_forward_next_trace, |
| 154 | .n_next_nodes = 1, |
| 155 | .next_nodes = { |
| 156 | [0] = "error-drop", |
| 157 | }, |
| 158 | }; |
| 159 | |
Filip Tehlar | 26ea14e | 2019-03-11 05:30:21 -0700 | [diff] [blame] | 160 | VLIB_REGISTER_NODE (ip6_punt_node) = |
Neale Ranns | d91c1db | 2017-07-31 02:30:50 -0700 | [diff] [blame] | 161 | { |
Neale Ranns | d91c1db | 2017-07-31 02:30:50 -0700 | [diff] [blame] | 162 | .name = "ip6-punt", |
| 163 | .vector_size = sizeof (u32), |
| 164 | .format_trace = format_ip6_forward_next_trace, |
| 165 | .n_next_nodes = 1, |
| 166 | .next_nodes = { |
| 167 | [0] = "error-punt", |
| 168 | }, |
| 169 | }; |
| 170 | |
Neale Ranns | d91c1db | 2017-07-31 02:30:50 -0700 | [diff] [blame] | 171 | VNET_FEATURE_INIT (ip6_punt_end_of_arc, static) = { |
| 172 | .arc_name = "ip6-punt", |
| 173 | .node_name = "error-punt", |
| 174 | .runs_before = 0, /* not before any other features */ |
| 175 | }; |
| 176 | |
| 177 | VNET_FEATURE_INIT (ip6_drop_end_of_arc, static) = { |
| 178 | .arc_name = "ip6-drop", |
| 179 | .node_name = "error-drop", |
| 180 | .runs_before = 0, /* not before any other features */ |
| 181 | }; |
| 182 | /* *INDENT-ON */ |
| 183 | |
Filip Tehlar | 26ea14e | 2019-03-11 05:30:21 -0700 | [diff] [blame] | 184 | #ifndef CLIB_MARCH_VARIANT |
Neale Ranns | d91c1db | 2017-07-31 02:30:50 -0700 | [diff] [blame] | 185 | void |
| 186 | ip6_punt_policer_add_del (u8 is_add, u32 policer_index) |
| 187 | { |
| 188 | ip6_punt_policer_cfg.policer_index = policer_index; |
| 189 | |
| 190 | vnet_feature_enable_disable ("ip6-punt", "ip6-punt-policer", |
| 191 | 0, is_add, 0, 0); |
| 192 | } |
Filip Tehlar | 26ea14e | 2019-03-11 05:30:21 -0700 | [diff] [blame] | 193 | #endif /* CLIB_MARCH_VARIANT */ |
Neale Ranns | d91c1db | 2017-07-31 02:30:50 -0700 | [diff] [blame] | 194 | |
| 195 | static clib_error_t * |
| 196 | ip6_punt_police_cmd (vlib_main_t * vm, |
| 197 | unformat_input_t * main_input, |
| 198 | vlib_cli_command_t * cmd) |
| 199 | { |
| 200 | unformat_input_t _line_input, *line_input = &_line_input; |
| 201 | clib_error_t *error = 0; |
| 202 | u32 policer_index; |
| 203 | u8 is_add = 1; |
| 204 | |
| 205 | policer_index = ~0; |
| 206 | |
| 207 | if (!unformat_user (main_input, unformat_line_input, line_input)) |
| 208 | return 0; |
| 209 | |
| 210 | while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) |
| 211 | { |
| 212 | if (unformat (line_input, "%d", &policer_index)) |
| 213 | ; |
| 214 | else if (unformat (line_input, "del")) |
| 215 | is_add = 0; |
| 216 | else if (unformat (line_input, "add")) |
| 217 | is_add = 1; |
| 218 | else |
| 219 | { |
| 220 | error = unformat_parse_error (line_input); |
| 221 | goto done; |
| 222 | } |
| 223 | } |
| 224 | |
| 225 | if (is_add && ~0 == policer_index) |
| 226 | { |
| 227 | error = clib_error_return (0, "expected policer index `%U'", |
| 228 | format_unformat_error, line_input); |
| 229 | goto done; |
| 230 | } |
| 231 | if (!is_add) |
| 232 | policer_index = ~0; |
| 233 | |
| 234 | ip6_punt_policer_add_del(is_add, policer_index); |
| 235 | |
| 236 | done: |
| 237 | unformat_free (line_input); |
| 238 | return (error); |
| 239 | } |
| 240 | |
| 241 | /*? |
| 242 | * |
| 243 | * @cliexpar |
| 244 | * @cliexcmd{set ip punt policer <INDEX>} |
| 245 | ?*/ |
| 246 | /* *INDENT-OFF* */ |
| 247 | VLIB_CLI_COMMAND (ip6_punt_policer_command, static) = |
| 248 | { |
| 249 | .path = "ip6 punt policer", |
| 250 | .function = ip6_punt_police_cmd, |
| 251 | .short_help = "ip6 punt policer [add|del] <index>", |
| 252 | }; |
Swarup Nayak | 4112e38 | 2017-12-11 17:36:54 +0530 | [diff] [blame] | 253 | |
Swarup Nayak | 4112e38 | 2017-12-11 17:36:54 +0530 | [diff] [blame] | 254 | /* *INDENT-ON* */ |
Neale Ranns | d91c1db | 2017-07-31 02:30:50 -0700 | [diff] [blame] | 255 | |
| 256 | #define foreach_ip6_punt_redirect_error \ |
| 257 | _(DROP, "ip6 punt redirect drop") |
| 258 | |
| 259 | typedef enum |
| 260 | { |
| 261 | #define _(sym,str) IP6_PUNT_REDIRECT_ERROR_##sym, |
| 262 | foreach_ip6_punt_redirect_error |
| 263 | #undef _ |
| 264 | IP6_PUNT_REDIRECT_N_ERROR, |
| 265 | } ip6_punt_redirect_error_t; |
| 266 | |
| 267 | static char *ip6_punt_redirect_error_strings[] = { |
| 268 | #define _(sym,string) string, |
| 269 | foreach_ip6_punt_redirect_error |
| 270 | #undef _ |
| 271 | }; |
| 272 | |
Filip Tehlar | 26ea14e | 2019-03-11 05:30:21 -0700 | [diff] [blame] | 273 | VLIB_NODE_FN (ip6_punt_redirect_node) (vlib_main_t * vm, |
| 274 | vlib_node_runtime_t * node, |
| 275 | vlib_frame_t * frame) |
Neale Ranns | d91c1db | 2017-07-31 02:30:50 -0700 | [diff] [blame] | 276 | { |
| 277 | return (ip_punt_redirect (vm, node, frame, |
| 278 | vnet_feat_arc_ip6_punt.feature_arc_index, |
Neale Ranns | 9220775 | 2019-06-03 13:21:40 +0000 | [diff] [blame] | 279 | FIB_PROTOCOL_IP6)); |
Neale Ranns | d91c1db | 2017-07-31 02:30:50 -0700 | [diff] [blame] | 280 | } |
| 281 | |
| 282 | /* *INDENT-OFF* */ |
Filip Tehlar | 26ea14e | 2019-03-11 05:30:21 -0700 | [diff] [blame] | 283 | VLIB_REGISTER_NODE (ip6_punt_redirect_node) = { |
Neale Ranns | d91c1db | 2017-07-31 02:30:50 -0700 | [diff] [blame] | 284 | .name = "ip6-punt-redirect", |
| 285 | .vector_size = sizeof (u32), |
| 286 | .n_next_nodes = IP_PUNT_REDIRECT_N_NEXT, |
| 287 | .format_trace = format_ip_punt_redirect_trace, |
| 288 | .n_errors = ARRAY_LEN(ip6_punt_redirect_error_strings), |
| 289 | .error_strings = ip6_punt_redirect_error_strings, |
| 290 | |
| 291 | /* edit / add dispositions here */ |
| 292 | .next_nodes = { |
| 293 | [IP_PUNT_REDIRECT_NEXT_DROP] = "ip6-drop", |
| 294 | [IP_PUNT_REDIRECT_NEXT_TX] = "ip6-rewrite", |
| 295 | [IP_PUNT_REDIRECT_NEXT_ARP] = "ip6-discover-neighbor", |
| 296 | }, |
| 297 | }; |
| 298 | |
Neale Ranns | d91c1db | 2017-07-31 02:30:50 -0700 | [diff] [blame] | 299 | VNET_FEATURE_INIT (ip6_punt_redirect_node, static) = { |
| 300 | .arc_name = "ip6-punt", |
| 301 | .node_name = "ip6-punt-redirect", |
| 302 | .runs_before = VNET_FEATURES("error-punt") |
| 303 | }; |
| 304 | /* *INDENT-ON* */ |
| 305 | |
Filip Tehlar | 26ea14e | 2019-03-11 05:30:21 -0700 | [diff] [blame] | 306 | #ifndef CLIB_MARCH_VARIANT |
Neale Ranns | 9220775 | 2019-06-03 13:21:40 +0000 | [diff] [blame] | 307 | |
Neale Ranns | d91c1db | 2017-07-31 02:30:50 -0700 | [diff] [blame] | 308 | void |
| 309 | ip6_punt_redirect_add (u32 rx_sw_if_index, |
| 310 | u32 tx_sw_if_index, ip46_address_t * nh) |
| 311 | { |
Neale Ranns | 9220775 | 2019-06-03 13:21:40 +0000 | [diff] [blame] | 312 | /* *INDENT-OFF* */ |
| 313 | fib_route_path_t *rpaths = NULL, rpath = { |
| 314 | .frp_proto = DPO_PROTO_IP6, |
| 315 | .frp_addr = *nh, |
| 316 | .frp_sw_if_index = tx_sw_if_index, |
| 317 | .frp_weight = 1, |
| 318 | .frp_fib_index = ~0, |
Neale Ranns | d91c1db | 2017-07-31 02:30:50 -0700 | [diff] [blame] | 319 | }; |
Neale Ranns | 9220775 | 2019-06-03 13:21:40 +0000 | [diff] [blame] | 320 | /* *INDENT-ON* */ |
| 321 | vec_add1 (rpaths, rpath); |
Neale Ranns | d91c1db | 2017-07-31 02:30:50 -0700 | [diff] [blame] | 322 | |
Neale Ranns | 9220775 | 2019-06-03 13:21:40 +0000 | [diff] [blame] | 323 | ip6_punt_redirect_add_paths (rx_sw_if_index, rpaths); |
| 324 | |
| 325 | vec_free (rpaths); |
| 326 | } |
| 327 | |
| 328 | void |
| 329 | ip6_punt_redirect_add_paths (u32 rx_sw_if_index, fib_route_path_t * rpaths) |
| 330 | { |
| 331 | ip_punt_redirect_add (FIB_PROTOCOL_IP6, |
| 332 | rx_sw_if_index, |
| 333 | FIB_FORW_CHAIN_TYPE_UNICAST_IP6, rpaths); |
Neale Ranns | d91c1db | 2017-07-31 02:30:50 -0700 | [diff] [blame] | 334 | |
| 335 | vnet_feature_enable_disable ("ip6-punt", "ip6-punt-redirect", 0, 1, 0, 0); |
| 336 | } |
| 337 | |
| 338 | void |
| 339 | ip6_punt_redirect_del (u32 rx_sw_if_index) |
| 340 | { |
| 341 | vnet_feature_enable_disable ("ip6-punt", "ip6-punt-redirect", 0, 0, 0, 0); |
| 342 | |
Neale Ranns | 9220775 | 2019-06-03 13:21:40 +0000 | [diff] [blame] | 343 | ip_punt_redirect_del (FIB_PROTOCOL_IP6, rx_sw_if_index); |
Neale Ranns | d91c1db | 2017-07-31 02:30:50 -0700 | [diff] [blame] | 344 | } |
Filip Tehlar | 26ea14e | 2019-03-11 05:30:21 -0700 | [diff] [blame] | 345 | #endif /* CLIB_MARCH_VARIANT */ |
Neale Ranns | d91c1db | 2017-07-31 02:30:50 -0700 | [diff] [blame] | 346 | |
| 347 | static clib_error_t * |
| 348 | ip6_punt_redirect_cmd (vlib_main_t * vm, |
| 349 | unformat_input_t * main_input, |
| 350 | vlib_cli_command_t * cmd) |
| 351 | { |
| 352 | unformat_input_t _line_input, *line_input = &_line_input; |
Neale Ranns | 9220775 | 2019-06-03 13:21:40 +0000 | [diff] [blame] | 353 | fib_route_path_t *rpaths = NULL, rpath; |
Neale Ranns | 5ca2a8a | 2019-07-29 12:59:45 +0000 | [diff] [blame] | 354 | dpo_proto_t payload_proto; |
Neale Ranns | d91c1db | 2017-07-31 02:30:50 -0700 | [diff] [blame] | 355 | clib_error_t *error = 0; |
Neale Ranns | 9220775 | 2019-06-03 13:21:40 +0000 | [diff] [blame] | 356 | u32 rx_sw_if_index = ~0; |
Neale Ranns | d91c1db | 2017-07-31 02:30:50 -0700 | [diff] [blame] | 357 | vnet_main_t *vnm; |
| 358 | u8 is_add; |
| 359 | |
| 360 | is_add = 1; |
| 361 | vnm = vnet_get_main (); |
| 362 | |
| 363 | if (!unformat_user (main_input, unformat_line_input, line_input)) |
| 364 | return 0; |
| 365 | |
| 366 | while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) |
| 367 | { |
| 368 | if (unformat (line_input, "del")) |
| 369 | is_add = 0; |
| 370 | else if (unformat (line_input, "add")) |
| 371 | is_add = 1; |
| 372 | else if (unformat (line_input, "rx all")) |
| 373 | rx_sw_if_index = ~0; |
| 374 | else if (unformat (line_input, "rx %U", |
| 375 | unformat_vnet_sw_interface, vnm, &rx_sw_if_index)) |
| 376 | ; |
Neale Ranns | d91c1db | 2017-07-31 02:30:50 -0700 | [diff] [blame] | 377 | else if (unformat (line_input, "via %U", |
Neale Ranns | 5ca2a8a | 2019-07-29 12:59:45 +0000 | [diff] [blame] | 378 | unformat_fib_route_path, &rpath, &payload_proto)) |
Neale Ranns | 9220775 | 2019-06-03 13:21:40 +0000 | [diff] [blame] | 379 | vec_add1 (rpaths, rpath); |
Neale Ranns | d91c1db | 2017-07-31 02:30:50 -0700 | [diff] [blame] | 380 | else |
| 381 | { |
| 382 | error = unformat_parse_error (line_input); |
| 383 | goto done; |
| 384 | } |
| 385 | } |
| 386 | |
Neale Ranns | 9220775 | 2019-06-03 13:21:40 +0000 | [diff] [blame] | 387 | if (~0 == rx_sw_if_index) |
| 388 | { |
| 389 | error = unformat_parse_error (line_input); |
| 390 | goto done; |
| 391 | } |
| 392 | |
Neale Ranns | d91c1db | 2017-07-31 02:30:50 -0700 | [diff] [blame] | 393 | if (is_add) |
Swarup Nayak | ecf844c | 2017-12-11 13:52:44 +0530 | [diff] [blame] | 394 | { |
Neale Ranns | 9220775 | 2019-06-03 13:21:40 +0000 | [diff] [blame] | 395 | if (vec_len (rpaths)) |
| 396 | ip6_punt_redirect_add_paths (rx_sw_if_index, rpaths); |
Swarup Nayak | ecf844c | 2017-12-11 13:52:44 +0530 | [diff] [blame] | 397 | } |
Neale Ranns | d91c1db | 2017-07-31 02:30:50 -0700 | [diff] [blame] | 398 | else |
Swarup Nayak | ecf844c | 2017-12-11 13:52:44 +0530 | [diff] [blame] | 399 | { |
Neale Ranns | 9220775 | 2019-06-03 13:21:40 +0000 | [diff] [blame] | 400 | ip6_punt_redirect_del (rx_sw_if_index); |
Swarup Nayak | ecf844c | 2017-12-11 13:52:44 +0530 | [diff] [blame] | 401 | } |
Neale Ranns | d91c1db | 2017-07-31 02:30:50 -0700 | [diff] [blame] | 402 | |
| 403 | done: |
| 404 | unformat_free (line_input); |
| 405 | return (error); |
| 406 | } |
| 407 | |
| 408 | /*? |
| 409 | * |
| 410 | * @cliexpar |
| 411 | * @cliexcmd{set ip punt policer <INDEX>} |
| 412 | ?*/ |
| 413 | /* *INDENT-OFF* */ |
| 414 | VLIB_CLI_COMMAND (ip6_punt_redirect_command, static) = |
| 415 | { |
| 416 | .path = "ip6 punt redirect", |
| 417 | .function = ip6_punt_redirect_cmd, |
| 418 | .short_help = "ip6 punt redirect [add|del] rx [<interface>|all] via [<nh>] <tx_interface>", |
| 419 | }; |
| 420 | /* *INDENT-ON* */ |
| 421 | |
Filip Tehlar | 26ea14e | 2019-03-11 05:30:21 -0700 | [diff] [blame] | 422 | #ifndef CLIB_MARCH_VARIANT |
Pavel Kotucek | 609e121 | 2018-11-27 09:59:44 +0100 | [diff] [blame] | 423 | |
Filip Tehlar | 26ea14e | 2019-03-11 05:30:21 -0700 | [diff] [blame] | 424 | #endif /* CLIB_MARCH_VARIANT */ |
Pavel Kotucek | 609e121 | 2018-11-27 09:59:44 +0100 | [diff] [blame] | 425 | |
Neale Ranns | d91c1db | 2017-07-31 02:30:50 -0700 | [diff] [blame] | 426 | static clib_error_t * |
| 427 | ip6_punt_redirect_show_cmd (vlib_main_t * vm, |
| 428 | unformat_input_t * main_input, |
| 429 | vlib_cli_command_t * cmd) |
| 430 | { |
Neale Ranns | 9220775 | 2019-06-03 13:21:40 +0000 | [diff] [blame] | 431 | vlib_cli_output (vm, "%U", format_ip_punt_redirect, FIB_PROTOCOL_IP6); |
Neale Ranns | d91c1db | 2017-07-31 02:30:50 -0700 | [diff] [blame] | 432 | |
| 433 | return (NULL); |
| 434 | } |
| 435 | |
| 436 | /*? |
| 437 | * |
| 438 | * @cliexpar |
| 439 | * @cliexcmd{set ip punt policer <INDEX>} |
| 440 | ?*/ |
| 441 | /* *INDENT-OFF* */ |
| 442 | VLIB_CLI_COMMAND (show_ip6_punt_redirect_command, static) = |
| 443 | { |
| 444 | .path = "show ip6 punt redirect", |
| 445 | .function = ip6_punt_redirect_show_cmd, |
Swarup Nayak | a3611a7 | 2017-12-06 18:55:43 +0530 | [diff] [blame] | 446 | .short_help = "show ip6 punt redirect", |
Neale Ranns | d91c1db | 2017-07-31 02:30:50 -0700 | [diff] [blame] | 447 | .is_mp_safe = 1, |
| 448 | }; |
| 449 | /* *INDENT-ON* */ |
| 450 | |
| 451 | /* |
| 452 | * fd.io coding-style-patch-verification: ON |
| 453 | * |
| 454 | * Local Variables: |
| 455 | * eval: (c-set-style "gnu") |
| 456 | * End: |
| 457 | */ |