Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1 | /* |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 2 | * Copyright (c) 2016 Cisco and/or its affiliates. |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 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 | #include <vlib/vlib.h> |
| 16 | #include <vnet/vnet.h> |
| 17 | #include <vnet/pg/pg.h> |
| 18 | #include <vppinfra/error.h> |
| 19 | |
| 20 | #include <vnet/ip/ip.h> |
| 21 | |
| 22 | #include <vppinfra/hash.h> |
| 23 | #include <vppinfra/error.h> |
| 24 | #include <vppinfra/elog.h> |
| 25 | |
| 26 | #include <vnet/ip/ip6_hop_by_hop.h> |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 27 | #include <vnet/fib/ip6_fib.h> |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 28 | #include <vnet/classify/vnet_classify.h> |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 29 | |
Billy McFall | 0683c9c | 2016-10-13 08:27:31 -0400 | [diff] [blame] | 30 | /** |
| 31 | * @file |
| 32 | * @brief In-band OAM (iOAM). |
| 33 | * |
| 34 | * In-band OAM (iOAM) is an implementation study to record operational |
| 35 | * information in the packet while the packet traverses a path between |
| 36 | * two points in the network. |
| 37 | * |
| 38 | * VPP can function as in-band OAM encapsulating, transit and |
| 39 | * decapsulating node. In this version of VPP in-band OAM data is |
| 40 | * transported as options in an IPv6 hop-by-hop extension header. Hence |
| 41 | * in-band OAM can be enabled for IPv6 traffic. |
| 42 | */ |
| 43 | |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 44 | ip6_hop_by_hop_ioam_main_t ip6_hop_by_hop_ioam_main; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 45 | |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 46 | #define foreach_ip6_hbyh_ioam_input_next \ |
| 47 | _(IP6_REWRITE, "ip6-rewrite") \ |
| 48 | _(IP6_LOOKUP, "ip6-lookup") \ |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 49 | _(DROP, "error-drop") |
rangan | f5bf6dd | 2016-04-15 17:31:46 +0530 | [diff] [blame] | 50 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 51 | typedef enum |
| 52 | { |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 53 | #define _(s,n) IP6_HBYH_IOAM_INPUT_NEXT_##s, |
| 54 | foreach_ip6_hbyh_ioam_input_next |
rangan | f5bf6dd | 2016-04-15 17:31:46 +0530 | [diff] [blame] | 55 | #undef _ |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 56 | IP6_HBYH_IOAM_INPUT_N_NEXT, |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 57 | } ip6_hbyh_ioam_input_next_t; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 58 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 59 | |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 60 | u32 |
| 61 | ioam_flow_add (u8 encap, u8 * flow_name) |
| 62 | { |
| 63 | ip6_hop_by_hop_ioam_main_t *hm = &ip6_hop_by_hop_ioam_main; |
| 64 | flow_data_t *flow = 0; |
| 65 | u32 index = 0; |
| 66 | u8 i; |
| 67 | |
| 68 | pool_get (hm->flows, flow); |
| 69 | memset (flow, 0, sizeof (flow_data_t)); |
| 70 | |
| 71 | index = flow - hm->flows; |
| 72 | strncpy ((char *) flow->flow_name, (char *) flow_name, 31); |
| 73 | |
| 74 | if (!encap) |
| 75 | IOAM_SET_DECAP (index); |
| 76 | |
| 77 | for (i = 0; i < 255; i++) |
| 78 | { |
| 79 | if (hm->flow_handler[i]) |
| 80 | flow->ctx[i] = hm->flow_handler[i] (index, 1); |
| 81 | } |
| 82 | return (index); |
| 83 | } |
| 84 | |
| 85 | static uword |
| 86 | unformat_opaque_ioam (unformat_input_t * input, va_list * args) |
| 87 | { |
| 88 | u64 *opaquep = va_arg (*args, u64 *); |
| 89 | u8 *flow_name = NULL; |
| 90 | uword ret = 0; |
| 91 | |
| 92 | if (unformat (input, "ioam-encap %s", &flow_name)) |
| 93 | { |
| 94 | *opaquep = ioam_flow_add (1, flow_name); |
| 95 | ret = 1; |
| 96 | } |
| 97 | else if (unformat (input, "ioam-decap %s", &flow_name)) |
| 98 | { |
| 99 | *opaquep = ioam_flow_add (0, flow_name); |
| 100 | ret = 1; |
| 101 | } |
| 102 | |
| 103 | vec_free (flow_name); |
| 104 | return ret; |
| 105 | } |
| 106 | |
| 107 | u8 * |
| 108 | get_flow_name_from_flow_ctx (u32 flow_ctx) |
| 109 | { |
| 110 | flow_data_t *flow = NULL; |
| 111 | ip6_hop_by_hop_ioam_main_t *hm = &ip6_hop_by_hop_ioam_main; |
| 112 | u32 index; |
| 113 | |
| 114 | index = IOAM_MASK_DECAP_BIT (flow_ctx); |
| 115 | |
| 116 | if (pool_is_free_index (hm->flows, index)) |
| 117 | return NULL; |
| 118 | |
| 119 | flow = pool_elt_at_index (hm->flows, index); |
| 120 | return (flow->flow_name); |
| 121 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 122 | |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 123 | /* The main h-b-h tracer will be invoked, no need to do much here */ |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 124 | int |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 125 | ip6_hbh_add_register_option (u8 option, |
| 126 | u8 size, |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 127 | int rewrite_options (u8 * rewrite_string, |
| 128 | u8 * rewrite_size)) |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 129 | { |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 130 | ip6_hop_by_hop_ioam_main_t *hm = &ip6_hop_by_hop_ioam_main; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 131 | |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 132 | ASSERT (option < ARRAY_LEN (hm->add_options)); |
| 133 | |
| 134 | /* Already registered */ |
| 135 | if (hm->add_options[option]) |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 136 | return (-1); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 137 | |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 138 | hm->add_options[option] = rewrite_options; |
| 139 | hm->options_size[option] = size; |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 140 | |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 141 | return (0); |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 142 | } |
Damjan Marion | 1c80e83 | 2016-05-11 23:07:18 +0200 | [diff] [blame] | 143 | |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 144 | int |
| 145 | ip6_hbh_add_unregister_option (u8 option) |
| 146 | { |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 147 | ip6_hop_by_hop_ioam_main_t *hm = &ip6_hop_by_hop_ioam_main; |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 148 | |
| 149 | ASSERT (option < ARRAY_LEN (hm->add_options)); |
| 150 | |
| 151 | /* Not registered */ |
| 152 | if (!hm->add_options[option]) |
| 153 | return (-1); |
| 154 | |
| 155 | hm->add_options[option] = NULL; |
| 156 | hm->options_size[option] = 0; |
| 157 | return (0); |
| 158 | } |
| 159 | |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 160 | /* Config handler registration */ |
| 161 | int |
| 162 | ip6_hbh_config_handler_register (u8 option, |
| 163 | int config_handler (void *data, u8 disable)) |
| 164 | { |
| 165 | ip6_hop_by_hop_ioam_main_t *hm = &ip6_hop_by_hop_ioam_main; |
| 166 | |
| 167 | ASSERT (option < ARRAY_LEN (hm->config_handler)); |
| 168 | |
| 169 | /* Already registered */ |
| 170 | if (hm->config_handler[option]) |
| 171 | return (VNET_API_ERROR_INVALID_REGISTRATION); |
| 172 | |
| 173 | hm->config_handler[option] = config_handler; |
| 174 | |
| 175 | return (0); |
| 176 | } |
| 177 | |
| 178 | int |
| 179 | ip6_hbh_config_handler_unregister (u8 option) |
| 180 | { |
| 181 | ip6_hop_by_hop_ioam_main_t *hm = &ip6_hop_by_hop_ioam_main; |
| 182 | |
| 183 | ASSERT (option < ARRAY_LEN (hm->config_handler)); |
| 184 | |
| 185 | /* Not registered */ |
| 186 | if (!hm->config_handler[option]) |
| 187 | return (VNET_API_ERROR_INVALID_REGISTRATION); |
| 188 | |
| 189 | hm->config_handler[option] = NULL; |
| 190 | return (0); |
| 191 | } |
| 192 | |
| 193 | /* Flow handler registration */ |
| 194 | int |
| 195 | ip6_hbh_flow_handler_register (u8 option, |
| 196 | u32 ioam_flow_handler (u32 flow_ctx, u8 add)) |
| 197 | { |
| 198 | ip6_hop_by_hop_ioam_main_t *hm = &ip6_hop_by_hop_ioam_main; |
| 199 | |
| 200 | ASSERT (option < ARRAY_LEN (hm->flow_handler)); |
| 201 | |
| 202 | /* Already registered */ |
| 203 | if (hm->flow_handler[option]) |
| 204 | return (VNET_API_ERROR_INVALID_REGISTRATION); |
| 205 | |
| 206 | hm->flow_handler[option] = ioam_flow_handler; |
| 207 | |
| 208 | return (0); |
| 209 | } |
| 210 | |
| 211 | int |
| 212 | ip6_hbh_flow_handler_unregister (u8 option) |
| 213 | { |
| 214 | ip6_hop_by_hop_ioam_main_t *hm = &ip6_hop_by_hop_ioam_main; |
| 215 | |
| 216 | ASSERT (option < ARRAY_LEN (hm->flow_handler)); |
| 217 | |
| 218 | /* Not registered */ |
| 219 | if (!hm->flow_handler[option]) |
| 220 | return (VNET_API_ERROR_INVALID_REGISTRATION); |
| 221 | |
| 222 | hm->flow_handler[option] = NULL; |
| 223 | return (0); |
| 224 | } |
| 225 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 226 | typedef struct |
| 227 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 228 | u32 next_index; |
| 229 | } ip6_add_hop_by_hop_trace_t; |
| 230 | |
| 231 | /* packet trace format function */ |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 232 | static u8 * |
| 233 | format_ip6_add_hop_by_hop_trace (u8 * s, va_list * args) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 234 | { |
| 235 | CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *); |
| 236 | CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *); |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 237 | ip6_add_hop_by_hop_trace_t *t = va_arg (*args, |
| 238 | ip6_add_hop_by_hop_trace_t *); |
| 239 | |
| 240 | s = format (s, "IP6_ADD_HOP_BY_HOP: next index %d", t->next_index); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 241 | return s; |
| 242 | } |
| 243 | |
| 244 | vlib_node_registration_t ip6_add_hop_by_hop_node; |
| 245 | |
| 246 | #define foreach_ip6_add_hop_by_hop_error \ |
| 247 | _(PROCESSED, "Pkts w/ added ip6 hop-by-hop options") |
| 248 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 249 | typedef enum |
| 250 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 251 | #define _(sym,str) IP6_ADD_HOP_BY_HOP_ERROR_##sym, |
| 252 | foreach_ip6_add_hop_by_hop_error |
| 253 | #undef _ |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 254 | IP6_ADD_HOP_BY_HOP_N_ERROR, |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 255 | } ip6_add_hop_by_hop_error_t; |
| 256 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 257 | static char *ip6_add_hop_by_hop_error_strings[] = { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 258 | #define _(sym,string) string, |
| 259 | foreach_ip6_add_hop_by_hop_error |
| 260 | #undef _ |
| 261 | }; |
| 262 | |
| 263 | static uword |
| 264 | ip6_add_hop_by_hop_node_fn (vlib_main_t * vm, |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 265 | vlib_node_runtime_t * node, vlib_frame_t * frame) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 266 | { |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 267 | ip6_hop_by_hop_ioam_main_t *hm = &ip6_hop_by_hop_ioam_main; |
| 268 | u32 n_left_from, *from, *to_next; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 269 | ip_lookup_next_t next_index; |
| 270 | u32 processed = 0; |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 271 | u8 *rewrite = hm->rewrite; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 272 | u32 rewrite_length = vec_len (rewrite); |
| 273 | |
| 274 | from = vlib_frame_vector_args (frame); |
| 275 | n_left_from = frame->n_vectors; |
| 276 | next_index = node->cached_next_index; |
| 277 | |
| 278 | while (n_left_from > 0) |
| 279 | { |
| 280 | u32 n_left_to_next; |
| 281 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 282 | vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 283 | while (n_left_from >= 4 && n_left_to_next >= 2) |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 284 | { |
| 285 | u32 bi0, bi1; |
| 286 | vlib_buffer_t *b0, *b1; |
| 287 | u32 next0, next1; |
| 288 | ip6_header_t *ip0, *ip1; |
| 289 | ip6_hop_by_hop_header_t *hbh0, *hbh1; |
| 290 | u64 *copy_src0, *copy_dst0, *copy_src1, *copy_dst1; |
| 291 | u16 new_l0, new_l1; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 292 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 293 | /* Prefetch next iteration. */ |
| 294 | { |
| 295 | vlib_buffer_t *p2, *p3; |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 296 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 297 | p2 = vlib_get_buffer (vm, from[2]); |
| 298 | p3 = vlib_get_buffer (vm, from[3]); |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 299 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 300 | vlib_prefetch_buffer_header (p2, LOAD); |
| 301 | vlib_prefetch_buffer_header (p3, LOAD); |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 302 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 303 | CLIB_PREFETCH (p2->data - rewrite_length, |
| 304 | 2 * CLIB_CACHE_LINE_BYTES, STORE); |
| 305 | CLIB_PREFETCH (p3->data - rewrite_length, |
| 306 | 2 * CLIB_CACHE_LINE_BYTES, STORE); |
| 307 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 308 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 309 | /* speculatively enqueue b0 and b1 to the current next frame */ |
| 310 | to_next[0] = bi0 = from[0]; |
| 311 | to_next[1] = bi1 = from[1]; |
| 312 | from += 2; |
| 313 | to_next += 2; |
| 314 | n_left_from -= 2; |
| 315 | n_left_to_next -= 2; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 316 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 317 | b0 = vlib_get_buffer (vm, bi0); |
| 318 | b1 = vlib_get_buffer (vm, bi1); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 319 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 320 | /* $$$$$ Dual loop: process 2 x packets here $$$$$ */ |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 321 | ip0 = vlib_buffer_get_current (b0); |
| 322 | ip1 = vlib_buffer_get_current (b1); |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 323 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 324 | /* Copy the ip header left by the required amount */ |
| 325 | copy_dst0 = (u64 *) (((u8 *) ip0) - rewrite_length); |
| 326 | copy_dst1 = (u64 *) (((u8 *) ip1) - rewrite_length); |
| 327 | copy_src0 = (u64 *) ip0; |
| 328 | copy_src1 = (u64 *) ip1; |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 329 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 330 | copy_dst0[0] = copy_src0[0]; |
| 331 | copy_dst0[1] = copy_src0[1]; |
| 332 | copy_dst0[2] = copy_src0[2]; |
| 333 | copy_dst0[3] = copy_src0[3]; |
| 334 | copy_dst0[4] = copy_src0[4]; |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 335 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 336 | copy_dst1[0] = copy_src1[0]; |
| 337 | copy_dst1[1] = copy_src1[1]; |
| 338 | copy_dst1[2] = copy_src1[2]; |
| 339 | copy_dst1[3] = copy_src1[3]; |
| 340 | copy_dst1[4] = copy_src1[4]; |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 341 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 342 | vlib_buffer_advance (b0, -(word) rewrite_length); |
| 343 | vlib_buffer_advance (b1, -(word) rewrite_length); |
| 344 | ip0 = vlib_buffer_get_current (b0); |
| 345 | ip1 = vlib_buffer_get_current (b1); |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 346 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 347 | hbh0 = (ip6_hop_by_hop_header_t *) (ip0 + 1); |
| 348 | hbh1 = (ip6_hop_by_hop_header_t *) (ip1 + 1); |
| 349 | /* $$$ tune, rewrite_length is a multiple of 8 */ |
| 350 | clib_memcpy (hbh0, rewrite, rewrite_length); |
| 351 | clib_memcpy (hbh1, rewrite, rewrite_length); |
| 352 | /* Patch the protocol chain, insert the h-b-h (type 0) header */ |
| 353 | hbh0->protocol = ip0->protocol; |
| 354 | hbh1->protocol = ip1->protocol; |
| 355 | ip0->protocol = 0; |
| 356 | ip1->protocol = 0; |
| 357 | new_l0 = |
| 358 | clib_net_to_host_u16 (ip0->payload_length) + rewrite_length; |
| 359 | new_l1 = |
| 360 | clib_net_to_host_u16 (ip1->payload_length) + rewrite_length; |
| 361 | ip0->payload_length = clib_host_to_net_u16 (new_l0); |
| 362 | ip1->payload_length = clib_host_to_net_u16 (new_l1); |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 363 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 364 | /* Populate the (first) h-b-h list elt */ |
| 365 | next0 = IP6_HBYH_IOAM_INPUT_NEXT_IP6_LOOKUP; |
| 366 | next1 = IP6_HBYH_IOAM_INPUT_NEXT_IP6_LOOKUP; |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 367 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 368 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 369 | /* $$$$$ End of processing 2 x packets $$$$$ */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 370 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 371 | if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE))) |
| 372 | { |
| 373 | if (b0->flags & VLIB_BUFFER_IS_TRACED) |
| 374 | { |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 375 | ip6_add_hop_by_hop_trace_t *t = |
| 376 | vlib_add_trace (vm, node, b0, sizeof (*t)); |
| 377 | t->next_index = next0; |
| 378 | } |
| 379 | if (b1->flags & VLIB_BUFFER_IS_TRACED) |
| 380 | { |
| 381 | ip6_add_hop_by_hop_trace_t *t = |
| 382 | vlib_add_trace (vm, node, b1, sizeof (*t)); |
| 383 | t->next_index = next1; |
| 384 | } |
| 385 | } |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 386 | processed += 2; |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 387 | /* verify speculative enqueues, maybe switch current next frame */ |
| 388 | vlib_validate_buffer_enqueue_x2 (vm, node, next_index, |
| 389 | to_next, n_left_to_next, |
| 390 | bi0, bi1, next0, next1); |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 391 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 392 | while (n_left_from > 0 && n_left_to_next > 0) |
| 393 | { |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 394 | u32 bi0; |
| 395 | vlib_buffer_t *b0; |
| 396 | u32 next0; |
| 397 | ip6_header_t *ip0; |
| 398 | ip6_hop_by_hop_header_t *hbh0; |
| 399 | u64 *copy_src0, *copy_dst0; |
| 400 | u16 new_l0; |
| 401 | |
| 402 | /* speculatively enqueue b0 to the current next frame */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 403 | bi0 = from[0]; |
| 404 | to_next[0] = bi0; |
| 405 | from += 1; |
| 406 | to_next += 1; |
| 407 | n_left_from -= 1; |
| 408 | n_left_to_next -= 1; |
| 409 | |
| 410 | b0 = vlib_get_buffer (vm, bi0); |
| 411 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 412 | ip0 = vlib_buffer_get_current (b0); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 413 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 414 | /* Copy the ip header left by the required amount */ |
| 415 | copy_dst0 = (u64 *) (((u8 *) ip0) - rewrite_length); |
| 416 | copy_src0 = (u64 *) ip0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 417 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 418 | copy_dst0[0] = copy_src0[0]; |
| 419 | copy_dst0[1] = copy_src0[1]; |
| 420 | copy_dst0[2] = copy_src0[2]; |
| 421 | copy_dst0[3] = copy_src0[3]; |
| 422 | copy_dst0[4] = copy_src0[4]; |
| 423 | vlib_buffer_advance (b0, -(word) rewrite_length); |
| 424 | ip0 = vlib_buffer_get_current (b0); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 425 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 426 | hbh0 = (ip6_hop_by_hop_header_t *) (ip0 + 1); |
| 427 | /* $$$ tune, rewrite_length is a multiple of 8 */ |
| 428 | clib_memcpy (hbh0, rewrite, rewrite_length); |
| 429 | /* Patch the protocol chain, insert the h-b-h (type 0) header */ |
| 430 | hbh0->protocol = ip0->protocol; |
| 431 | ip0->protocol = 0; |
| 432 | new_l0 = |
| 433 | clib_net_to_host_u16 (ip0->payload_length) + rewrite_length; |
| 434 | ip0->payload_length = clib_host_to_net_u16 (new_l0); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 435 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 436 | /* Populate the (first) h-b-h list elt */ |
| 437 | next0 = IP6_HBYH_IOAM_INPUT_NEXT_IP6_LOOKUP; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 438 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 439 | if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) |
| 440 | && (b0->flags & VLIB_BUFFER_IS_TRACED))) |
| 441 | { |
| 442 | ip6_add_hop_by_hop_trace_t *t = |
| 443 | vlib_add_trace (vm, node, b0, sizeof (*t)); |
| 444 | t->next_index = next0; |
| 445 | } |
| 446 | |
| 447 | processed++; |
| 448 | |
| 449 | /* verify speculative enqueue, maybe switch current next frame */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 450 | vlib_validate_buffer_enqueue_x1 (vm, node, next_index, |
| 451 | to_next, n_left_to_next, |
| 452 | bi0, next0); |
| 453 | } |
| 454 | |
| 455 | vlib_put_next_frame (vm, node, next_index, n_left_to_next); |
| 456 | } |
| 457 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 458 | vlib_node_increment_counter (vm, ip6_add_hop_by_hop_node.index, |
| 459 | IP6_ADD_HOP_BY_HOP_ERROR_PROCESSED, processed); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 460 | return frame->n_vectors; |
| 461 | } |
| 462 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 463 | /* *INDENT-OFF* */ |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 464 | VLIB_REGISTER_NODE (ip6_add_hop_by_hop_node) = /* *INDENT-OFF* */ |
| 465 | { |
| 466 | .function = ip6_add_hop_by_hop_node_fn,.name = |
| 467 | "ip6-add-hop-by-hop",.vector_size = sizeof (u32),.format_trace = |
| 468 | format_ip6_add_hop_by_hop_trace,.type = |
| 469 | VLIB_NODE_TYPE_INTERNAL,.n_errors = |
| 470 | ARRAY_LEN (ip6_add_hop_by_hop_error_strings),.error_strings = |
| 471 | ip6_add_hop_by_hop_error_strings, |
| 472 | /* See ip/lookup.h */ |
| 473 | .n_next_nodes = IP6_HBYH_IOAM_INPUT_N_NEXT,.next_nodes = |
| 474 | { |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 475 | #define _(s,n) [IP6_HBYH_IOAM_INPUT_NEXT_##s] = n, |
| 476 | foreach_ip6_hbyh_ioam_input_next |
rangan | f5bf6dd | 2016-04-15 17:31:46 +0530 | [diff] [blame] | 477 | #undef _ |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 478 | } |
| 479 | ,}; |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 480 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 481 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 482 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 483 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 484 | VLIB_NODE_FUNCTION_MULTIARCH (ip6_add_hop_by_hop_node, |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 485 | ip6_add_hop_by_hop_node_fn); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 486 | /* The main h-b-h tracer was already invoked, no need to do much here */ |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 487 | typedef struct |
| 488 | { |
| 489 | u32 next_index; |
| 490 | } ip6_pop_hop_by_hop_trace_t; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 491 | |
| 492 | /* packet trace format function */ |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 493 | static u8 * |
| 494 | format_ip6_pop_hop_by_hop_trace (u8 * s, va_list * args) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 495 | { |
| 496 | CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *); |
| 497 | CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *); |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 498 | ip6_pop_hop_by_hop_trace_t *t = |
| 499 | va_arg (*args, ip6_pop_hop_by_hop_trace_t *); |
| 500 | |
| 501 | s = format (s, "IP6_POP_HOP_BY_HOP: next index %d", t->next_index); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 502 | return s; |
| 503 | } |
| 504 | |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 505 | int |
| 506 | ip6_hbh_pop_register_option (u8 option, |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 507 | int options (vlib_buffer_t * b, |
| 508 | ip6_header_t * ip, |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 509 | ip6_hop_by_hop_option_t * opt)) |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 510 | { |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 511 | ip6_hop_by_hop_ioam_main_t *hm = &ip6_hop_by_hop_ioam_main; |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 512 | |
| 513 | ASSERT (option < ARRAY_LEN (hm->pop_options)); |
| 514 | |
| 515 | /* Already registered */ |
| 516 | if (hm->pop_options[option]) |
| 517 | return (-1); |
| 518 | |
| 519 | hm->pop_options[option] = options; |
| 520 | |
| 521 | return (0); |
| 522 | } |
| 523 | |
| 524 | int |
| 525 | ip6_hbh_pop_unregister_option (u8 option) |
| 526 | { |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 527 | ip6_hop_by_hop_ioam_main_t *hm = &ip6_hop_by_hop_ioam_main; |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 528 | |
| 529 | ASSERT (option < ARRAY_LEN (hm->pop_options)); |
| 530 | |
| 531 | /* Not registered */ |
| 532 | if (!hm->pop_options[option]) |
| 533 | return (-1); |
| 534 | |
| 535 | hm->pop_options[option] = NULL; |
| 536 | return (0); |
| 537 | } |
| 538 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 539 | vlib_node_registration_t ip6_pop_hop_by_hop_node; |
| 540 | |
| 541 | #define foreach_ip6_pop_hop_by_hop_error \ |
| 542 | _(PROCESSED, "Pkts w/ removed ip6 hop-by-hop options") \ |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 543 | _(NO_HOHO, "Pkts w/ no ip6 hop-by-hop options") \ |
| 544 | _(OPTION_FAILED, "ip6 pop hop-by-hop failed to process") |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 545 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 546 | typedef enum |
| 547 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 548 | #define _(sym,str) IP6_POP_HOP_BY_HOP_ERROR_##sym, |
| 549 | foreach_ip6_pop_hop_by_hop_error |
| 550 | #undef _ |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 551 | IP6_POP_HOP_BY_HOP_N_ERROR, |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 552 | } ip6_pop_hop_by_hop_error_t; |
| 553 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 554 | static char *ip6_pop_hop_by_hop_error_strings[] = { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 555 | #define _(sym,string) string, |
| 556 | foreach_ip6_pop_hop_by_hop_error |
| 557 | #undef _ |
| 558 | }; |
| 559 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 560 | static inline void |
| 561 | ioam_pop_hop_by_hop_processing (vlib_main_t * vm, |
| 562 | ip6_header_t * ip0, |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 563 | ip6_hop_by_hop_header_t * hbh0, |
| 564 | vlib_buffer_t * b) |
Shwetha Bhandari | 05866a1 | 2016-05-04 08:12:57 +0200 | [diff] [blame] | 565 | { |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 566 | ip6_hop_by_hop_ioam_main_t *hm = &ip6_hop_by_hop_ioam_main; |
Shwetha Bhandari | 05866a1 | 2016-05-04 08:12:57 +0200 | [diff] [blame] | 567 | ip6_hop_by_hop_option_t *opt0, *limit0; |
Shwetha Bhandari | 05866a1 | 2016-05-04 08:12:57 +0200 | [diff] [blame] | 568 | u8 type0; |
Shwetha Bhandari | 05866a1 | 2016-05-04 08:12:57 +0200 | [diff] [blame] | 569 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 570 | if (!hbh0 || !ip0) |
| 571 | return; |
Shwetha Bhandari | 05866a1 | 2016-05-04 08:12:57 +0200 | [diff] [blame] | 572 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 573 | opt0 = (ip6_hop_by_hop_option_t *) (hbh0 + 1); |
Shwetha Bhandari | 05866a1 | 2016-05-04 08:12:57 +0200 | [diff] [blame] | 574 | limit0 = (ip6_hop_by_hop_option_t *) |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 575 | ((u8 *) hbh0 + ((hbh0->length + 1) << 3)); |
Shwetha Bhandari | 05866a1 | 2016-05-04 08:12:57 +0200 | [diff] [blame] | 576 | |
| 577 | /* Scan the set of h-b-h options, process ones that we understand */ |
| 578 | while (opt0 < limit0) |
| 579 | { |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 580 | type0 = opt0->type; |
Shwetha Bhandari | 05866a1 | 2016-05-04 08:12:57 +0200 | [diff] [blame] | 581 | switch (type0) |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 582 | { |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 583 | case 0: /* Pad1 */ |
| 584 | opt0 = (ip6_hop_by_hop_option_t *) ((u8 *) opt0) + 1; |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 585 | continue; |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 586 | case 1: /* PadN */ |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 587 | break; |
| 588 | default: |
| 589 | if (hm->pop_options[type0]) |
| 590 | { |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 591 | if ((*hm->pop_options[type0]) (b, ip0, opt0) < 0) |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 592 | { |
| 593 | vlib_node_increment_counter (vm, |
| 594 | ip6_pop_hop_by_hop_node.index, |
| 595 | IP6_POP_HOP_BY_HOP_ERROR_OPTION_FAILED, |
| 596 | 1); |
| 597 | } |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 598 | } |
| 599 | } |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 600 | opt0 = |
| 601 | (ip6_hop_by_hop_option_t *) (((u8 *) opt0) + opt0->length + |
| 602 | sizeof (ip6_hop_by_hop_option_t)); |
Shwetha Bhandari | 05866a1 | 2016-05-04 08:12:57 +0200 | [diff] [blame] | 603 | } |
| 604 | } |
| 605 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 606 | static uword |
| 607 | ip6_pop_hop_by_hop_node_fn (vlib_main_t * vm, |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 608 | vlib_node_runtime_t * node, vlib_frame_t * frame) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 609 | { |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 610 | ip6_main_t *im = &ip6_main; |
| 611 | ip_lookup_main_t *lm = &im->lookup_main; |
| 612 | u32 n_left_from, *from, *to_next; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 613 | ip_lookup_next_t next_index; |
| 614 | u32 processed = 0; |
| 615 | u32 no_header = 0; |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 616 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 617 | from = vlib_frame_vector_args (frame); |
| 618 | n_left_from = frame->n_vectors; |
| 619 | next_index = node->cached_next_index; |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 620 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 621 | while (n_left_from > 0) |
| 622 | { |
| 623 | u32 n_left_to_next; |
| 624 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 625 | vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 626 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 627 | while (n_left_from >= 4 && n_left_to_next >= 2) |
| 628 | { |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 629 | u32 bi0, bi1; |
| 630 | vlib_buffer_t *b0, *b1; |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 631 | u32 next0, next1; |
| 632 | u32 adj_index0, adj_index1; |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 633 | ip6_header_t *ip0, *ip1; |
| 634 | ip_adjacency_t *adj0, *adj1; |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 635 | ip6_hop_by_hop_header_t *hbh0, *hbh1; |
| 636 | u64 *copy_dst0, *copy_src0, *copy_dst1, *copy_src1; |
| 637 | u16 new_l0, new_l1; |
| 638 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 639 | /* Prefetch next iteration. */ |
| 640 | { |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 641 | vlib_buffer_t *p2, *p3; |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 642 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 643 | p2 = vlib_get_buffer (vm, from[2]); |
| 644 | p3 = vlib_get_buffer (vm, from[3]); |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 645 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 646 | vlib_prefetch_buffer_header (p2, LOAD); |
| 647 | vlib_prefetch_buffer_header (p3, LOAD); |
| 648 | |
| 649 | CLIB_PREFETCH (p2->data, CLIB_CACHE_LINE_BYTES, STORE); |
| 650 | CLIB_PREFETCH (p3->data, CLIB_CACHE_LINE_BYTES, STORE); |
| 651 | } |
| 652 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 653 | /* speculatively enqueue b0 and b1 to the current next frame */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 654 | to_next[0] = bi0 = from[0]; |
| 655 | to_next[1] = bi1 = from[1]; |
| 656 | from += 2; |
| 657 | to_next += 2; |
| 658 | n_left_from -= 2; |
| 659 | n_left_to_next -= 2; |
| 660 | |
| 661 | b0 = vlib_get_buffer (vm, bi0); |
| 662 | b1 = vlib_get_buffer (vm, bi1); |
| 663 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 664 | /* $$$$$ Dual loop: process 2 x packets here $$$$$ */ |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 665 | ip0 = vlib_buffer_get_current (b0); |
| 666 | ip1 = vlib_buffer_get_current (b1); |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 667 | adj_index0 = vnet_buffer (b0)->ip.adj_index[VLIB_TX]; |
| 668 | adj_index1 = vnet_buffer (b1)->ip.adj_index[VLIB_TX]; |
| 669 | adj0 = ip_get_adjacency (lm, adj_index0); |
| 670 | adj1 = ip_get_adjacency (lm, adj_index1); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 671 | |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 672 | next0 = adj0->lookup_next_index; |
| 673 | next1 = adj1->lookup_next_index; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 674 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 675 | hbh0 = (ip6_hop_by_hop_header_t *) (ip0 + 1); |
| 676 | hbh1 = (ip6_hop_by_hop_header_t *) (ip1 + 1); |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 677 | |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 678 | ioam_pop_hop_by_hop_processing (vm, ip0, hbh0, b0); |
| 679 | ioam_pop_hop_by_hop_processing (vm, ip1, hbh1, b1); |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 680 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 681 | vlib_buffer_advance (b0, (hbh0->length + 1) << 3); |
| 682 | vlib_buffer_advance (b1, (hbh1->length + 1) << 3); |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 683 | |
| 684 | new_l0 = clib_net_to_host_u16 (ip0->payload_length) - |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 685 | ((hbh0->length + 1) << 3); |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 686 | new_l1 = clib_net_to_host_u16 (ip1->payload_length) - |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 687 | ((hbh1->length + 1) << 3); |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 688 | |
| 689 | ip0->payload_length = clib_host_to_net_u16 (new_l0); |
| 690 | ip1->payload_length = clib_host_to_net_u16 (new_l1); |
| 691 | |
| 692 | ip0->protocol = hbh0->protocol; |
| 693 | ip1->protocol = hbh1->protocol; |
| 694 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 695 | copy_src0 = (u64 *) ip0; |
| 696 | copy_src1 = (u64 *) ip1; |
| 697 | copy_dst0 = copy_src0 + (hbh0->length + 1); |
| 698 | copy_dst0[4] = copy_src0[4]; |
| 699 | copy_dst0[3] = copy_src0[3]; |
| 700 | copy_dst0[2] = copy_src0[2]; |
| 701 | copy_dst0[1] = copy_src0[1]; |
| 702 | copy_dst0[0] = copy_src0[0]; |
| 703 | copy_dst1 = copy_src1 + (hbh1->length + 1); |
| 704 | copy_dst1[4] = copy_src1[4]; |
| 705 | copy_dst1[3] = copy_src1[3]; |
| 706 | copy_dst1[2] = copy_src1[2]; |
| 707 | copy_dst1[1] = copy_src1[1]; |
| 708 | copy_dst1[0] = copy_src1[0]; |
| 709 | processed += 2; |
| 710 | /* $$$$$ End of processing 2 x packets $$$$$ */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 711 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 712 | if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE))) |
| 713 | { |
| 714 | if (b0->flags & VLIB_BUFFER_IS_TRACED) |
| 715 | { |
| 716 | ip6_pop_hop_by_hop_trace_t *t = |
| 717 | vlib_add_trace (vm, node, b0, sizeof (*t)); |
| 718 | t->next_index = next0; |
| 719 | } |
| 720 | if (b1->flags & VLIB_BUFFER_IS_TRACED) |
| 721 | { |
| 722 | ip6_pop_hop_by_hop_trace_t *t = |
| 723 | vlib_add_trace (vm, node, b1, sizeof (*t)); |
| 724 | t->next_index = next1; |
| 725 | } |
| 726 | } |
Shwetha | a91cbe6 | 2016-08-08 15:51:04 +0100 | [diff] [blame] | 727 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 728 | /* verify speculative enqueues, maybe switch current next frame */ |
| 729 | vlib_validate_buffer_enqueue_x2 (vm, node, next_index, |
| 730 | to_next, n_left_to_next, |
| 731 | bi0, bi1, next0, next1); |
| 732 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 733 | |
| 734 | while (n_left_from > 0 && n_left_to_next > 0) |
| 735 | { |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 736 | u32 bi0; |
| 737 | vlib_buffer_t *b0; |
| 738 | u32 next0; |
| 739 | u32 adj_index0; |
| 740 | ip6_header_t *ip0; |
| 741 | ip_adjacency_t *adj0; |
| 742 | ip6_hop_by_hop_header_t *hbh0; |
| 743 | u64 *copy_dst0, *copy_src0; |
| 744 | u16 new_l0; |
| 745 | |
| 746 | /* speculatively enqueue b0 to the current next frame */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 747 | bi0 = from[0]; |
| 748 | to_next[0] = bi0; |
| 749 | from += 1; |
| 750 | to_next += 1; |
| 751 | n_left_from -= 1; |
| 752 | n_left_to_next -= 1; |
| 753 | |
| 754 | b0 = vlib_get_buffer (vm, bi0); |
| 755 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 756 | ip0 = vlib_buffer_get_current (b0); |
| 757 | adj_index0 = vnet_buffer (b0)->ip.adj_index[VLIB_TX]; |
| 758 | adj0 = ip_get_adjacency (lm, adj_index0); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 759 | |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 760 | /* Default use the next_index from the adjacency. */ |
| 761 | next0 = adj0->lookup_next_index; |
| 762 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 763 | /* Perfectly normal to end up here w/ out h-b-h header */ |
| 764 | hbh0 = (ip6_hop_by_hop_header_t *) (ip0 + 1); |
| 765 | |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 766 | /* TODO:Temporarily doing it here.. do this validation in end_of_path_cb */ |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 767 | ioam_pop_hop_by_hop_processing (vm, ip0, hbh0, b0); |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 768 | /* Pop the trace data */ |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 769 | vlib_buffer_advance (b0, (hbh0->length + 1) << 3); |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 770 | new_l0 = clib_net_to_host_u16 (ip0->payload_length) - |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 771 | ((hbh0->length + 1) << 3); |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 772 | ip0->payload_length = clib_host_to_net_u16 (new_l0); |
| 773 | ip0->protocol = hbh0->protocol; |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 774 | copy_src0 = (u64 *) ip0; |
| 775 | copy_dst0 = copy_src0 + (hbh0->length + 1); |
| 776 | copy_dst0[4] = copy_src0[4]; |
| 777 | copy_dst0[3] = copy_src0[3]; |
| 778 | copy_dst0[2] = copy_src0[2]; |
| 779 | copy_dst0[1] = copy_src0[1]; |
| 780 | copy_dst0[0] = copy_src0[0]; |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 781 | processed++; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 782 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 783 | if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) |
| 784 | && (b0->flags & VLIB_BUFFER_IS_TRACED))) |
| 785 | { |
| 786 | ip6_pop_hop_by_hop_trace_t *t = |
| 787 | vlib_add_trace (vm, node, b0, sizeof (*t)); |
| 788 | t->next_index = next0; |
| 789 | } |
| 790 | |
| 791 | /* verify speculative enqueue, maybe switch current next frame */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 792 | vlib_validate_buffer_enqueue_x1 (vm, node, next_index, |
| 793 | to_next, n_left_to_next, |
| 794 | bi0, next0); |
| 795 | } |
| 796 | |
| 797 | vlib_put_next_frame (vm, node, next_index, n_left_to_next); |
| 798 | } |
| 799 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 800 | vlib_node_increment_counter (vm, ip6_pop_hop_by_hop_node.index, |
| 801 | IP6_POP_HOP_BY_HOP_ERROR_PROCESSED, processed); |
| 802 | vlib_node_increment_counter (vm, ip6_pop_hop_by_hop_node.index, |
| 803 | IP6_POP_HOP_BY_HOP_ERROR_NO_HOHO, no_header); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 804 | return frame->n_vectors; |
| 805 | } |
| 806 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 807 | /* *INDENT-OFF* */ |
| 808 | VLIB_REGISTER_NODE (ip6_pop_hop_by_hop_node) = |
| 809 | { |
| 810 | .function = ip6_pop_hop_by_hop_node_fn,.name = |
| 811 | "ip6-pop-hop-by-hop",.vector_size = sizeof (u32),.format_trace = |
| 812 | format_ip6_pop_hop_by_hop_trace,.type = |
| 813 | VLIB_NODE_TYPE_INTERNAL,.sibling_of = "ip6-lookup",.n_errors = |
| 814 | ARRAY_LEN (ip6_pop_hop_by_hop_error_strings),.error_strings = |
| 815 | ip6_pop_hop_by_hop_error_strings, |
| 816 | /* See ip/lookup.h */ |
| 817 | .n_next_nodes = 0,}; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 818 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 819 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 820 | |
Damjan Marion | 1c80e83 | 2016-05-11 23:07:18 +0200 | [diff] [blame] | 821 | VLIB_NODE_FUNCTION_MULTIARCH (ip6_pop_hop_by_hop_node, |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 822 | ip6_pop_hop_by_hop_node_fn); |
| 823 | static clib_error_t * |
| 824 | ip6_hop_by_hop_ioam_init (vlib_main_t * vm) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 825 | { |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 826 | clib_error_t *error; |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 827 | ip6_hop_by_hop_ioam_main_t *hm = &ip6_hop_by_hop_ioam_main; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 828 | |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 829 | if ((error = vlib_call_init_function (vm, ip_main_init))) |
| 830 | return (error); |
| 831 | |
| 832 | if ((error = vlib_call_init_function (vm, ip6_lookup_init))) |
| 833 | return error; |
| 834 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 835 | hm->vlib_main = vm; |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 836 | hm->vnet_main = vnet_get_main (); |
| 837 | hm->unix_time_0 = (u32) time (0); /* Store starting time */ |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 838 | hm->vlib_time_0 = vlib_time_now (vm); |
| 839 | hm->ioam_flag = IOAM_HBYH_MOD; |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 840 | memset (hm->add_options, 0, sizeof (hm->add_options)); |
| 841 | memset (hm->pop_options, 0, sizeof (hm->pop_options)); |
| 842 | memset (hm->options_size, 0, sizeof (hm->options_size)); |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 843 | |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 844 | vnet_classify_register_unformat_opaque_index_fn (unformat_opaque_ioam); |
| 845 | |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 846 | return (0); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 847 | } |
| 848 | |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 849 | VLIB_INIT_FUNCTION (ip6_hop_by_hop_ioam_init); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 850 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 851 | int |
| 852 | ip6_ioam_set_rewrite (u8 ** rwp, int has_trace_option, |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 853 | int has_pot_option, int has_seqno_option) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 854 | { |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 855 | ip6_hop_by_hop_ioam_main_t *hm = &ip6_hop_by_hop_ioam_main; |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 856 | u8 *rewrite = NULL; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 857 | u32 size, rnd_size; |
| 858 | ip6_hop_by_hop_header_t *hbh; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 859 | u8 *current; |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 860 | u8 *trace_data_size = NULL; |
| 861 | u8 *pot_data_size = NULL; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 862 | |
| 863 | vec_free (*rwp); |
| 864 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 865 | if (has_trace_option == 0 && has_pot_option == 0) |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 866 | return -1; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 867 | |
| 868 | /* Work out how much space we need */ |
| 869 | size = sizeof (ip6_hop_by_hop_header_t); |
| 870 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 871 | //if (has_trace_option && hm->get_sizeof_options[HBH_OPTION_TYPE_IOAM_TRACE_DATA_LIST] != 0) |
| 872 | if (has_trace_option |
| 873 | && hm->options_size[HBH_OPTION_TYPE_IOAM_TRACE_DATA_LIST] != 0) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 874 | { |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 875 | size += hm->options_size[HBH_OPTION_TYPE_IOAM_TRACE_DATA_LIST]; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 876 | } |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 877 | if (has_pot_option |
| 878 | && hm->add_options[HBH_OPTION_TYPE_IOAM_PROOF_OF_TRANSIT] != 0) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 879 | { |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 880 | size += hm->options_size[HBH_OPTION_TYPE_IOAM_PROOF_OF_TRANSIT]; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 881 | } |
| 882 | |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 883 | if (has_seqno_option) |
| 884 | { |
| 885 | size += hm->options_size[HBH_OPTION_TYPE_IOAM_EDGE_TO_EDGE]; |
| 886 | } |
| 887 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 888 | /* Round to a multiple of 8 octets */ |
| 889 | rnd_size = (size + 7) & ~7; |
| 890 | |
| 891 | /* allocate it, zero-fill / pad by construction */ |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 892 | vec_validate (rewrite, rnd_size - 1); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 893 | |
| 894 | hbh = (ip6_hop_by_hop_header_t *) rewrite; |
| 895 | /* Length of header in 8 octet units, not incl first 8 octets */ |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 896 | hbh->length = (rnd_size >> 3) - 1; |
| 897 | current = (u8 *) (hbh + 1); |
| 898 | |
| 899 | if (has_trace_option |
| 900 | && hm->add_options[HBH_OPTION_TYPE_IOAM_TRACE_DATA_LIST] != 0) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 901 | { |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 902 | if (0 != (hm->options_size[HBH_OPTION_TYPE_IOAM_TRACE_DATA_LIST])) |
| 903 | { |
| 904 | trace_data_size = |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 905 | &hm->options_size[HBH_OPTION_TYPE_IOAM_TRACE_DATA_LIST]; |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 906 | if (0 == |
| 907 | hm->add_options[HBH_OPTION_TYPE_IOAM_TRACE_DATA_LIST] (current, |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 908 | trace_data_size)) |
| 909 | current += *trace_data_size; |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 910 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 911 | } |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 912 | if (has_pot_option |
| 913 | && hm->add_options[HBH_OPTION_TYPE_IOAM_PROOF_OF_TRANSIT] != 0) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 914 | { |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 915 | pot_data_size = |
| 916 | &hm->options_size[HBH_OPTION_TYPE_IOAM_PROOF_OF_TRANSIT]; |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 917 | if (0 == |
| 918 | hm->add_options[HBH_OPTION_TYPE_IOAM_PROOF_OF_TRANSIT] (current, |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 919 | pot_data_size)) |
| 920 | current += *pot_data_size; |
| 921 | } |
| 922 | |
| 923 | if (has_seqno_option && |
| 924 | (hm->add_options[HBH_OPTION_TYPE_IOAM_EDGE_TO_EDGE] != 0)) |
| 925 | { |
| 926 | if (0 == hm->add_options[HBH_OPTION_TYPE_IOAM_EDGE_TO_EDGE] (current, |
| 927 | & |
| 928 | (hm->options_size |
| 929 | [HBH_OPTION_TYPE_IOAM_EDGE_TO_EDGE]))) |
| 930 | current += hm->options_size[HBH_OPTION_TYPE_IOAM_EDGE_TO_EDGE]; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 931 | } |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 932 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 933 | *rwp = rewrite; |
| 934 | return 0; |
| 935 | } |
| 936 | |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 937 | clib_error_t * |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 938 | clear_ioam_rewrite_fn (void) |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 939 | { |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 940 | ip6_hop_by_hop_ioam_main_t *hm = &ip6_hop_by_hop_ioam_main; |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 941 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 942 | vec_free (hm->rewrite); |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 943 | hm->rewrite = 0; |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 944 | hm->has_trace_option = 0; |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 945 | hm->has_pot_option = 0; |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 946 | hm->has_seqno_option = 0; |
| 947 | hm->has_analyse_option = 0; |
| 948 | if (hm->config_handler[HBH_OPTION_TYPE_IOAM_TRACE_DATA_LIST]) |
| 949 | hm->config_handler[HBH_OPTION_TYPE_IOAM_TRACE_DATA_LIST] (NULL, 1); |
| 950 | |
| 951 | if (hm->config_handler[HBH_OPTION_TYPE_IOAM_PROOF_OF_TRANSIT]) |
| 952 | hm->config_handler[HBH_OPTION_TYPE_IOAM_PROOF_OF_TRANSIT] (NULL, 1); |
| 953 | |
| 954 | if (hm->config_handler[HBH_OPTION_TYPE_IOAM_EDGE_TO_EDGE]) |
| 955 | { |
| 956 | hm->config_handler[HBH_OPTION_TYPE_IOAM_EDGE_TO_EDGE] ((void *) |
| 957 | &hm->has_analyse_option, |
| 958 | 1); |
| 959 | } |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 960 | |
| 961 | return 0; |
| 962 | } |
Shwetha | 20a64f5 | 2016-03-25 10:55:01 +0000 | [diff] [blame] | 963 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 964 | clib_error_t * |
| 965 | clear_ioam_rewrite_command_fn (vlib_main_t * vm, |
| 966 | unformat_input_t * input, |
| 967 | vlib_cli_command_t * cmd) |
Shwetha | 20a64f5 | 2016-03-25 10:55:01 +0000 | [diff] [blame] | 968 | { |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 969 | return (clear_ioam_rewrite_fn ()); |
Shwetha | 20a64f5 | 2016-03-25 10:55:01 +0000 | [diff] [blame] | 970 | } |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 971 | |
Billy McFall | 0683c9c | 2016-10-13 08:27:31 -0400 | [diff] [blame] | 972 | /*? |
| 973 | * This command clears all the In-band OAM (iOAM) features enabled by |
| 974 | * the '<em>set ioam rewrite</em>' command. Use '<em>show ioam summary</em>' to |
| 975 | * verify the configured settings cleared. |
| 976 | * |
| 977 | * @cliexpar |
| 978 | * Example of how to clear iOAM features: |
| 979 | * @cliexcmd{clear ioam rewrite} |
| 980 | ?*/ |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 981 | /* *INDENT-OFF* */ |
Billy McFall | 0683c9c | 2016-10-13 08:27:31 -0400 | [diff] [blame] | 982 | VLIB_CLI_COMMAND (ip6_clear_ioam_rewrite_cmd, static) = { |
| 983 | .path = "clear ioam rewrite", |
| 984 | .short_help = "clear ioam rewrite", |
| 985 | .function = clear_ioam_rewrite_command_fn, |
| 986 | }; |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 987 | /* *INDENT-ON* */ |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 988 | |
| 989 | clib_error_t * |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 990 | ip6_ioam_enable (int has_trace_option, int has_pot_option, |
| 991 | int has_seqno_option, int has_analyse_option) |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 992 | { |
| 993 | int rv; |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 994 | ip6_hop_by_hop_ioam_main_t *hm = &ip6_hop_by_hop_ioam_main; |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 995 | rv = ip6_ioam_set_rewrite (&hm->rewrite, has_trace_option, |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 996 | has_pot_option, has_seqno_option); |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 997 | |
| 998 | switch (rv) |
| 999 | { |
| 1000 | case 0: |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 1001 | if (has_trace_option) |
| 1002 | { |
| 1003 | hm->has_trace_option = has_trace_option; |
| 1004 | if (hm->config_handler[HBH_OPTION_TYPE_IOAM_TRACE_DATA_LIST]) |
| 1005 | hm->config_handler[HBH_OPTION_TYPE_IOAM_TRACE_DATA_LIST] (NULL, |
| 1006 | 0); |
| 1007 | } |
| 1008 | |
| 1009 | if (has_pot_option) |
| 1010 | { |
| 1011 | hm->has_pot_option = has_pot_option; |
| 1012 | if (hm->config_handler[HBH_OPTION_TYPE_IOAM_PROOF_OF_TRANSIT]) |
| 1013 | hm->config_handler[HBH_OPTION_TYPE_IOAM_PROOF_OF_TRANSIT] (NULL, |
| 1014 | 0); |
| 1015 | } |
| 1016 | hm->has_analyse_option = has_analyse_option; |
| 1017 | if (has_seqno_option) |
| 1018 | { |
| 1019 | hm->has_seqno_option = has_seqno_option; |
| 1020 | if (hm->config_handler[HBH_OPTION_TYPE_IOAM_EDGE_TO_EDGE]) |
| 1021 | { |
| 1022 | hm->config_handler[HBH_OPTION_TYPE_IOAM_EDGE_TO_EDGE] ((void *) |
| 1023 | &has_analyse_option, |
| 1024 | 0); |
| 1025 | } |
| 1026 | } |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 1027 | break; |
| 1028 | |
| 1029 | default: |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1030 | return clib_error_return_code (0, rv, 0, |
| 1031 | "ip6_ioam_set_rewrite returned %d", rv); |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 1032 | } |
| 1033 | |
| 1034 | return 0; |
| 1035 | } |
| 1036 | |
| 1037 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1038 | static clib_error_t * |
rangan | 2375fbd | 2016-03-04 22:23:25 +0530 | [diff] [blame] | 1039 | ip6_set_ioam_rewrite_command_fn (vlib_main_t * vm, |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1040 | unformat_input_t * input, |
| 1041 | vlib_cli_command_t * cmd) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1042 | { |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1043 | int has_trace_option = 0; |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 1044 | int has_pot_option = 0; |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 1045 | int has_seqno_option = 0; |
| 1046 | int has_analyse_option = 0; |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1047 | clib_error_t *rv = 0; |
| 1048 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1049 | while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) |
| 1050 | { |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1051 | if (unformat (input, "trace")) |
| 1052 | has_trace_option = 1; |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 1053 | else if (unformat (input, "pot")) |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1054 | has_pot_option = 1; |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 1055 | else if (unformat (input, "seqno")) |
| 1056 | has_seqno_option = 1; |
| 1057 | else if (unformat (input, "analyse")) |
| 1058 | has_analyse_option = 1; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1059 | else |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1060 | break; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1061 | } |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 1062 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1063 | |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 1064 | rv = ip6_ioam_enable (has_trace_option, has_pot_option, |
| 1065 | has_seqno_option, has_analyse_option); |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1066 | |
| 1067 | return rv; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1068 | } |
| 1069 | |
Billy McFall | 0683c9c | 2016-10-13 08:27:31 -0400 | [diff] [blame] | 1070 | /*? |
| 1071 | * This command is used to enable In-band OAM (iOAM) features on IPv6. |
| 1072 | * '<em>trace</em>' is used to enable iOAM trace feature. '<em>pot</em>' is used to |
| 1073 | * enable the Proof Of Transit feature. '<em>ppc</em>' is used to indicate the |
| 1074 | * Per Packet Counter feature for Edge to Edge processing. '<em>ppc</em>' is |
| 1075 | * used to indicate if this node is an '<em>encap</em>' node (iOAM edge node |
| 1076 | * where packet enters iOAM domain), a '<em>decap</em>' node (iOAM edge node |
| 1077 | * where packet leaves iOAM domain) or '<em>none</em>' (iOAM node where packet |
| 1078 | * is in-transit through the iOAM domain). '<em>ppc</em>' can only be set if |
| 1079 | * '<em>trace</em>' or '<em>pot</em>' is enabled. |
| 1080 | * |
| 1081 | * Use '<em>clear ioam rewrite</em>' to disable all features enabled by this |
| 1082 | * command. Use '<em>show ioam summary</em>' to verify the configured settings. |
| 1083 | * |
| 1084 | * @cliexpar |
| 1085 | * Example of how to enable trace and pot with ppc set to encap: |
| 1086 | * @cliexcmd{set ioam rewrite trace pot ppc encap} |
| 1087 | ?*/ |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1088 | /* *INDENT-OFF* */ |
Billy McFall | 0683c9c | 2016-10-13 08:27:31 -0400 | [diff] [blame] | 1089 | VLIB_CLI_COMMAND (ip6_set_ioam_rewrite_cmd, static) = { |
| 1090 | .path = "set ioam rewrite", |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 1091 | .short_help = "set ioam [trace] [pot] [seqno] [analyse]", |
Billy McFall | 0683c9c | 2016-10-13 08:27:31 -0400 | [diff] [blame] | 1092 | .function = ip6_set_ioam_rewrite_command_fn, |
| 1093 | }; |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1094 | /* *INDENT-ON* */ |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 1095 | |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 1096 | static clib_error_t * |
| 1097 | ip6_show_ioam_summary_cmd_fn (vlib_main_t * vm, |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1098 | unformat_input_t * input, |
| 1099 | vlib_cli_command_t * cmd) |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 1100 | { |
Ole Troan | 944f548 | 2016-05-24 11:56:58 +0200 | [diff] [blame] | 1101 | ip6_hop_by_hop_ioam_main_t *hm = &ip6_hop_by_hop_ioam_main; |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 1102 | u8 *s = 0; |
| 1103 | |
| 1104 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1105 | if (!is_zero_ip6_address (&hm->adj)) |
| 1106 | { |
| 1107 | s = format (s, " REWRITE FLOW CONFIGS - \n"); |
| 1108 | s = format (s, " Destination Address : %U\n", |
| 1109 | format_ip6_address, &hm->adj, sizeof (ip6_address_t)); |
| 1110 | s = |
| 1111 | format (s, " Flow operation : %d (%s)\n", |
| 1112 | hm->ioam_flag, |
| 1113 | (hm->ioam_flag == |
| 1114 | IOAM_HBYH_ADD) ? "Add" : ((hm->ioam_flag == |
| 1115 | IOAM_HBYH_MOD) ? "Mod" : "Pop")); |
| 1116 | } |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 1117 | else |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1118 | { |
| 1119 | s = format (s, " REWRITE FLOW CONFIGS - Not configured\n"); |
| 1120 | } |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 1121 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1122 | |
| 1123 | s = format (s, " TRACE OPTION - %d (%s)\n", |
| 1124 | hm->has_trace_option, |
| 1125 | (hm->has_trace_option ? "Enabled" : "Disabled")); |
| 1126 | if (hm->has_trace_option) |
| 1127 | s = |
| 1128 | format (s, |
| 1129 | "Try 'show ioam trace and show ioam-trace profile' for more information\n"); |
| 1130 | |
| 1131 | |
| 1132 | s = format (s, " POT OPTION - %d (%s)\n", |
| 1133 | hm->has_pot_option, |
| 1134 | (hm->has_pot_option ? "Enabled" : "Disabled")); |
Shwetha | 85b528e | 2016-06-15 16:34:16 +0100 | [diff] [blame] | 1135 | if (hm->has_pot_option) |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1136 | s = |
| 1137 | format (s, |
| 1138 | "Try 'show ioam pot and show pot profile' for more information\n"); |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 1139 | |
AkshayaNadahalli | ed4a2fd | 2016-08-09 13:38:04 +0530 | [diff] [blame] | 1140 | s = format (s, " EDGE TO EDGE - SeqNo OPTION - %d (%s)\n", |
| 1141 | hm->has_seqno_option, |
| 1142 | hm->has_seqno_option ? "Enabled" : "Disabled"); |
| 1143 | if (hm->has_seqno_option) |
| 1144 | s = format (s, "Try 'show ioam e2e' for more information\n"); |
| 1145 | |
| 1146 | s = format (s, " iOAM Analyse OPTION - %d (%s)\n", |
| 1147 | hm->has_analyse_option, |
| 1148 | hm->has_analyse_option ? "Enabled" : "Disabled"); |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 1149 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1150 | vlib_cli_output (vm, "%v", s); |
| 1151 | vec_free (s); |
rangan | 4f81085 | 2016-03-18 03:31:17 +0530 | [diff] [blame] | 1152 | return 0; |
| 1153 | } |
| 1154 | |
Billy McFall | 0683c9c | 2016-10-13 08:27:31 -0400 | [diff] [blame] | 1155 | /*? |
| 1156 | * This command displays the current configuration data for In-band |
| 1157 | * OAM (iOAM). |
| 1158 | * |
| 1159 | * @cliexpar |
| 1160 | * Example to show the iOAM configuration: |
| 1161 | * @cliexstart{show ioam summary} |
| 1162 | * REWRITE FLOW CONFIGS - |
| 1163 | * Destination Address : ff02::1 |
| 1164 | * Flow operation : 2 (Pop) |
| 1165 | * TRACE OPTION - 1 (Enabled) |
| 1166 | * Try 'show ioam trace and show ioam-trace profile' for more information |
| 1167 | * POT OPTION - 1 (Enabled) |
| 1168 | * Try 'show ioam pot and show pot profile' for more information |
| 1169 | * EDGE TO EDGE - PPC OPTION - 1 (Encap) |
| 1170 | * @cliexend |
| 1171 | ?*/ |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1172 | /* *INDENT-OFF* */ |
Billy McFall | 0683c9c | 2016-10-13 08:27:31 -0400 | [diff] [blame] | 1173 | VLIB_CLI_COMMAND (ip6_show_ioam_run_cmd, static) = { |
| 1174 | .path = "show ioam summary", |
| 1175 | .short_help = "show ioam summary", |
| 1176 | .function = ip6_show_ioam_summary_cmd_fn, |
| 1177 | }; |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1178 | /* *INDENT-ON* */ |
| 1179 | |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1180 | void |
| 1181 | vnet_register_ioam_end_of_path_callback (void *cb) |
| 1182 | { |
| 1183 | ip6_hop_by_hop_ioam_main_t *hm = &ip6_hop_by_hop_ioam_main; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1184 | |
| 1185 | hm->ioam_end_of_path_cb = cb; |
| 1186 | } |
Vengada Govindan | 07d2f84 | 2016-08-25 10:34:34 -0700 | [diff] [blame] | 1187 | |
| 1188 | /* |
| 1189 | * fd.io coding-style-patch-verification: ON |
| 1190 | * |
| 1191 | * Local Variables: |
| 1192 | * eval: (c-set-style "gnu") |
| 1193 | * End: |
| 1194 | */ |