Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -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 | #include <vnet/ip/ip.h> |
| 16 | #include <vnet/ethernet/ethernet.h> /* for ethernet_header_t */ |
| 17 | #include <vnet/classify/vnet_classify.h> |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 18 | #include <vnet/dpo/classify_dpo.h> |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 19 | |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 20 | typedef struct |
| 21 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 22 | u32 next_index; |
| 23 | u32 table_index; |
| 24 | u32 entry_index; |
| 25 | } ip_classify_trace_t; |
| 26 | |
| 27 | /* packet trace format function */ |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 28 | static u8 * |
| 29 | format_ip_classify_trace (u8 * s, va_list * args) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 30 | { |
| 31 | CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *); |
| 32 | CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *); |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 33 | ip_classify_trace_t *t = va_arg (*args, ip_classify_trace_t *); |
| 34 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 35 | s = format (s, "IP_CLASSIFY: next_index %d, table %d, entry %d", |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 36 | t->next_index, t->table_index, t->entry_index); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 37 | return s; |
| 38 | } |
| 39 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 40 | #define foreach_ip_classify_error \ |
| 41 | _(MISS, "Classify misses") \ |
| 42 | _(HIT, "Classify hits") \ |
| 43 | _(CHAIN_HIT, "Classify hits after chain walk") |
| 44 | |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 45 | typedef enum |
| 46 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 47 | #define _(sym,str) IP_CLASSIFY_ERROR_##sym, |
| 48 | foreach_ip_classify_error |
| 49 | #undef _ |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 50 | IP_CLASSIFY_N_ERROR, |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 51 | } ip_classify_error_t; |
| 52 | |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 53 | static char *ip_classify_error_strings[] = { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 54 | #define _(sym,string) string, |
| 55 | foreach_ip_classify_error |
| 56 | #undef _ |
| 57 | }; |
| 58 | |
| 59 | static inline uword |
| 60 | ip_classify_inline (vlib_main_t * vm, |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 61 | vlib_node_runtime_t * node, |
| 62 | vlib_frame_t * frame, int is_ip4) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 63 | { |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 64 | u32 n_left_from, *from, *to_next; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 65 | ip_lookup_next_t next_index; |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 66 | vnet_classify_main_t *vcm = &vnet_classify_main; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 67 | f64 now = vlib_time_now (vm); |
| 68 | u32 hits = 0; |
| 69 | u32 misses = 0; |
| 70 | u32 chain_hits = 0; |
Ole Troan | f0f8522 | 2016-06-14 21:12:32 +0200 | [diff] [blame] | 71 | u32 n_next; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 72 | |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 73 | if (is_ip4) |
| 74 | { |
| 75 | n_next = IP4_LOOKUP_N_NEXT; |
| 76 | } |
| 77 | else |
| 78 | { |
| 79 | n_next = IP6_LOOKUP_N_NEXT; |
| 80 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 81 | |
| 82 | from = vlib_frame_vector_args (frame); |
| 83 | n_left_from = frame->n_vectors; |
| 84 | |
| 85 | /* First pass: compute hashes */ |
| 86 | |
| 87 | while (n_left_from > 2) |
| 88 | { |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 89 | vlib_buffer_t *b0, *b1; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 90 | u32 bi0, bi1; |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 91 | u8 *h0, *h1; |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 92 | u32 cd_index0, cd_index1; |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 93 | classify_dpo_t *cd0, *cd1; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 94 | u32 table_index0, table_index1; |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 95 | vnet_classify_table_t *t0, *t1; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 96 | |
| 97 | /* prefetch next iteration */ |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 98 | { |
| 99 | vlib_buffer_t *p1, *p2; |
| 100 | |
| 101 | p1 = vlib_get_buffer (vm, from[1]); |
| 102 | p2 = vlib_get_buffer (vm, from[2]); |
| 103 | |
| 104 | vlib_prefetch_buffer_header (p1, STORE); |
| 105 | CLIB_PREFETCH (p1->data, CLIB_CACHE_LINE_BYTES, STORE); |
| 106 | vlib_prefetch_buffer_header (p2, STORE); |
| 107 | CLIB_PREFETCH (p2->data, CLIB_CACHE_LINE_BYTES, STORE); |
| 108 | } |
| 109 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 110 | bi0 = from[0]; |
| 111 | b0 = vlib_get_buffer (vm, bi0); |
Zhiyong Yang | 1f5a606 | 2019-07-25 22:44:01 -0400 | [diff] [blame] | 112 | h0 = vlib_buffer_get_current (b0) - ethernet_buffer_header_size (b0); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 113 | |
| 114 | bi1 = from[1]; |
| 115 | b1 = vlib_get_buffer (vm, bi1); |
Zhiyong Yang | 1f5a606 | 2019-07-25 22:44:01 -0400 | [diff] [blame] | 116 | h1 = vlib_buffer_get_current (b1) - ethernet_buffer_header_size (b1); |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 117 | |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 118 | cd_index0 = vnet_buffer (b0)->ip.adj_index[VLIB_TX]; |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 119 | cd0 = classify_dpo_get (cd_index0); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 120 | table_index0 = cd0->cd_table_index; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 121 | |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 122 | cd_index1 = vnet_buffer (b1)->ip.adj_index[VLIB_TX]; |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 123 | cd1 = classify_dpo_get (cd_index1); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 124 | table_index1 = cd1->cd_table_index; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 125 | |
| 126 | t0 = pool_elt_at_index (vcm->tables, table_index0); |
| 127 | |
| 128 | t1 = pool_elt_at_index (vcm->tables, table_index1); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 129 | |
Zhiyong Yang | 1f5a606 | 2019-07-25 22:44:01 -0400 | [diff] [blame] | 130 | vnet_buffer (b0)->l2_classify.hash = vnet_classify_hash_packet (t0, h0); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 131 | |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 132 | vnet_classify_prefetch_bucket (t0, vnet_buffer (b0)->l2_classify.hash); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 133 | |
Zhiyong Yang | 1f5a606 | 2019-07-25 22:44:01 -0400 | [diff] [blame] | 134 | vnet_buffer (b1)->l2_classify.hash = vnet_classify_hash_packet (t1, h1); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 135 | |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 136 | vnet_classify_prefetch_bucket (t1, vnet_buffer (b1)->l2_classify.hash); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 137 | |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 138 | vnet_buffer (b0)->l2_classify.table_index = table_index0; |
| 139 | |
| 140 | vnet_buffer (b1)->l2_classify.table_index = table_index1; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 141 | |
| 142 | from += 2; |
| 143 | n_left_from -= 2; |
| 144 | } |
| 145 | |
| 146 | while (n_left_from > 0) |
| 147 | { |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 148 | vlib_buffer_t *b0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 149 | u32 bi0; |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 150 | u8 *h0; |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 151 | u32 cd_index0; |
| 152 | classify_dpo_t *cd0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 153 | u32 table_index0; |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 154 | vnet_classify_table_t *t0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 155 | |
| 156 | bi0 = from[0]; |
| 157 | b0 = vlib_get_buffer (vm, bi0); |
Zhiyong Yang | 1f5a606 | 2019-07-25 22:44:01 -0400 | [diff] [blame] | 158 | h0 = vlib_buffer_get_current (b0) - ethernet_buffer_header_size (b0); |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 159 | |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 160 | cd_index0 = vnet_buffer (b0)->ip.adj_index[VLIB_TX]; |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 161 | cd0 = classify_dpo_get (cd_index0); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 162 | table_index0 = cd0->cd_table_index; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 163 | |
| 164 | t0 = pool_elt_at_index (vcm->tables, table_index0); |
Zhiyong Yang | 1f5a606 | 2019-07-25 22:44:01 -0400 | [diff] [blame] | 165 | vnet_buffer (b0)->l2_classify.hash = vnet_classify_hash_packet (t0, h0); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 166 | |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 167 | vnet_buffer (b0)->l2_classify.table_index = table_index0; |
| 168 | vnet_classify_prefetch_bucket (t0, vnet_buffer (b0)->l2_classify.hash); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 169 | |
| 170 | from++; |
| 171 | n_left_from--; |
| 172 | } |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 173 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 174 | next_index = node->cached_next_index; |
| 175 | from = vlib_frame_vector_args (frame); |
| 176 | n_left_from = frame->n_vectors; |
| 177 | |
| 178 | while (n_left_from > 0) |
| 179 | { |
| 180 | u32 n_left_to_next; |
| 181 | |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 182 | 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] | 183 | |
| 184 | /* Not enough load/store slots to dual loop... */ |
| 185 | while (n_left_from > 0 && n_left_to_next > 0) |
| 186 | { |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 187 | u32 bi0; |
| 188 | vlib_buffer_t *b0; |
| 189 | u32 next0 = IP_LOOKUP_NEXT_DROP; |
| 190 | u32 table_index0; |
| 191 | vnet_classify_table_t *t0; |
| 192 | vnet_classify_entry_t *e0; |
| 193 | u64 hash0; |
| 194 | u8 *h0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 195 | |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 196 | /* Stride 3 seems to work best */ |
| 197 | if (PREDICT_TRUE (n_left_from > 3)) |
| 198 | { |
| 199 | vlib_buffer_t *p1 = vlib_get_buffer (vm, from[3]); |
| 200 | vnet_classify_table_t *tp1; |
| 201 | u32 table_index1; |
| 202 | u64 phash1; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 203 | |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 204 | table_index1 = vnet_buffer (p1)->l2_classify.table_index; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 205 | |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 206 | if (PREDICT_TRUE (table_index1 != ~0)) |
| 207 | { |
| 208 | tp1 = pool_elt_at_index (vcm->tables, table_index1); |
| 209 | phash1 = vnet_buffer (p1)->l2_classify.hash; |
| 210 | vnet_classify_prefetch_entry (tp1, phash1); |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | /* speculatively enqueue b0 to the current next frame */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 215 | bi0 = from[0]; |
| 216 | to_next[0] = bi0; |
| 217 | from += 1; |
| 218 | to_next += 1; |
| 219 | n_left_from -= 1; |
| 220 | n_left_to_next -= 1; |
| 221 | |
| 222 | b0 = vlib_get_buffer (vm, bi0); |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 223 | h0 = b0->data; |
| 224 | table_index0 = vnet_buffer (b0)->l2_classify.table_index; |
| 225 | e0 = 0; |
| 226 | t0 = 0; |
| 227 | vnet_buffer (b0)->l2_classify.opaque_index = ~0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 228 | |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 229 | if (PREDICT_TRUE (table_index0 != ~0)) |
| 230 | { |
| 231 | hash0 = vnet_buffer (b0)->l2_classify.hash; |
| 232 | t0 = pool_elt_at_index (vcm->tables, table_index0); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 233 | |
Zhiyong Yang | 1f5a606 | 2019-07-25 22:44:01 -0400 | [diff] [blame] | 234 | e0 = vnet_classify_find_entry (t0, h0, hash0, now); |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 235 | if (e0) |
| 236 | { |
| 237 | vnet_buffer (b0)->l2_classify.opaque_index |
| 238 | = e0->opaque_index; |
| 239 | vlib_buffer_advance (b0, e0->advance); |
| 240 | next0 = (e0->next_index < node->n_next_nodes) ? |
| 241 | e0->next_index : next0; |
| 242 | hits++; |
| 243 | } |
| 244 | else |
| 245 | { |
| 246 | while (1) |
| 247 | { |
| 248 | if (t0->next_table_index != ~0) |
| 249 | t0 = pool_elt_at_index (vcm->tables, |
| 250 | t0->next_table_index); |
| 251 | else |
| 252 | { |
| 253 | next0 = (t0->miss_next_index < n_next) ? |
| 254 | t0->miss_next_index : next0; |
| 255 | misses++; |
| 256 | break; |
| 257 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 258 | |
Zhiyong Yang | 1f5a606 | 2019-07-25 22:44:01 -0400 | [diff] [blame] | 259 | hash0 = vnet_classify_hash_packet (t0, h0); |
| 260 | e0 = vnet_classify_find_entry (t0, h0, hash0, now); |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 261 | if (e0) |
| 262 | { |
| 263 | vnet_buffer (b0)->l2_classify.opaque_index |
| 264 | = e0->opaque_index; |
| 265 | vlib_buffer_advance (b0, e0->advance); |
| 266 | next0 = (e0->next_index < node->n_next_nodes) ? |
| 267 | e0->next_index : next0; |
| 268 | hits++; |
| 269 | chain_hits++; |
| 270 | break; |
| 271 | } |
| 272 | } |
| 273 | } |
| 274 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 275 | |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 276 | if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) |
| 277 | && (b0->flags & VLIB_BUFFER_IS_TRACED))) |
| 278 | { |
| 279 | ip_classify_trace_t *t = |
| 280 | vlib_add_trace (vm, node, b0, sizeof (*t)); |
| 281 | t->next_index = next0; |
| 282 | t->table_index = t0 ? t0 - vcm->tables : ~0; |
Neale Ranns | 1441a6c | 2020-12-14 16:02:17 +0000 | [diff] [blame] | 283 | t->entry_index = e0 ? e0->opaque_index : ~0; |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 284 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 285 | |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 286 | /* verify speculative enqueue, maybe switch current next frame */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 287 | vlib_validate_buffer_enqueue_x1 (vm, node, next_index, |
| 288 | to_next, n_left_to_next, |
| 289 | bi0, next0); |
| 290 | } |
| 291 | |
| 292 | vlib_put_next_frame (vm, node, next_index, n_left_to_next); |
| 293 | } |
| 294 | |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 295 | vlib_node_increment_counter (vm, node->node_index, |
| 296 | IP_CLASSIFY_ERROR_MISS, misses); |
| 297 | vlib_node_increment_counter (vm, node->node_index, |
| 298 | IP_CLASSIFY_ERROR_HIT, hits); |
| 299 | vlib_node_increment_counter (vm, node->node_index, |
| 300 | IP_CLASSIFY_ERROR_CHAIN_HIT, chain_hits); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 301 | return frame->n_vectors; |
| 302 | } |
| 303 | |
Filip Tehlar | e8cb521 | 2019-03-06 04:50:34 -0800 | [diff] [blame] | 304 | VLIB_NODE_FN (ip4_classify_node) (vlib_main_t * vm, |
| 305 | vlib_node_runtime_t * node, |
| 306 | vlib_frame_t * frame) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 307 | { |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 308 | return ip_classify_inline (vm, node, frame, 1 /* is_ip4 */ ); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 309 | } |
| 310 | |
| 311 | |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 312 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 313 | VLIB_REGISTER_NODE (ip4_classify_node) = { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 314 | .name = "ip4-classify", |
| 315 | .vector_size = sizeof (u32), |
Ole Troan | f0f8522 | 2016-06-14 21:12:32 +0200 | [diff] [blame] | 316 | .sibling_of = "ip4-lookup", |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 317 | .format_trace = format_ip_classify_trace, |
| 318 | .n_errors = ARRAY_LEN(ip_classify_error_strings), |
| 319 | .error_strings = ip_classify_error_strings, |
| 320 | |
Ole Troan | f0f8522 | 2016-06-14 21:12:32 +0200 | [diff] [blame] | 321 | .n_next_nodes = 0, |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 322 | }; |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 323 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 324 | |
Filip Tehlar | e8cb521 | 2019-03-06 04:50:34 -0800 | [diff] [blame] | 325 | VLIB_NODE_FN (ip6_classify_node) (vlib_main_t * vm, |
| 326 | vlib_node_runtime_t * node, |
| 327 | vlib_frame_t * frame) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 328 | { |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 329 | return ip_classify_inline (vm, node, frame, 0 /* is_ip4 */ ); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 330 | } |
| 331 | |
| 332 | |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 333 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 334 | VLIB_REGISTER_NODE (ip6_classify_node) = { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 335 | .name = "ip6-classify", |
| 336 | .vector_size = sizeof (u32), |
Ole Troan | f0f8522 | 2016-06-14 21:12:32 +0200 | [diff] [blame] | 337 | .sibling_of = "ip6-lookup", |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 338 | .format_trace = format_ip_classify_trace, |
| 339 | .n_errors = ARRAY_LEN(ip_classify_error_strings), |
| 340 | .error_strings = ip_classify_error_strings, |
| 341 | |
Ole Troan | f0f8522 | 2016-06-14 21:12:32 +0200 | [diff] [blame] | 342 | .n_next_nodes = 0, |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 343 | }; |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 344 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 345 | |
Filip Tehlar | e8cb521 | 2019-03-06 04:50:34 -0800 | [diff] [blame] | 346 | #ifndef CLIB_MARCH_VARIANT |
| 347 | static clib_error_t * |
| 348 | ip_classify_init (vlib_main_t * vm) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 349 | { |
| 350 | return 0; |
| 351 | } |
| 352 | |
| 353 | VLIB_INIT_FUNCTION (ip_classify_init); |
Filip Tehlar | e8cb521 | 2019-03-06 04:50:34 -0800 | [diff] [blame] | 354 | #endif /* CLIB_MARCH_VARIANT */ |
khemendra kumar | d7bfa0e | 2017-11-27 15:15:53 +0530 | [diff] [blame] | 355 | |
| 356 | /* |
| 357 | * fd.io coding-style-patch-verification: ON |
| 358 | * |
| 359 | * Local Variables: |
| 360 | * eval: (c-set-style "gnu") |
| 361 | * End: |
| 362 | */ |