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/classify/vnet_classify.h> |
Andrew Yourtchenko | 815d7d5 | 2018-02-07 11:37:02 +0100 | [diff] [blame] | 17 | #include <vnet/classify/in_out_acl.h> |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 18 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 19 | typedef struct |
| 20 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 21 | u32 sw_if_index; |
| 22 | u32 next_index; |
| 23 | u32 table_index; |
| 24 | u32 offset; |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 25 | } |
| 26 | ip_in_out_acl_trace_t; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 27 | |
| 28 | /* packet trace format function */ |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 29 | static u8 * |
Andrew Yourtchenko | 815d7d5 | 2018-02-07 11:37:02 +0100 | [diff] [blame] | 30 | format_ip_in_out_acl_trace (u8 * s, u32 is_output, va_list * args) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 31 | { |
| 32 | CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *); |
| 33 | CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *); |
Andrew Yourtchenko | 815d7d5 | 2018-02-07 11:37:02 +0100 | [diff] [blame] | 34 | ip_in_out_acl_trace_t *t = va_arg (*args, ip_in_out_acl_trace_t *); |
Benoît Ganne | c629f90 | 2022-06-08 10:56:33 +0200 | [diff] [blame] | 35 | const vnet_classify_main_t *vcm = &vnet_classify_main; |
| 36 | const u32 indent = format_get_indent (s); |
| 37 | vnet_classify_table_t *table; |
| 38 | vnet_classify_entry_t *e; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 39 | |
Benoît Ganne | c629f90 | 2022-06-08 10:56:33 +0200 | [diff] [blame] | 40 | s = |
| 41 | format (s, "%s: sw_if_index %d, next_index %d, table_index %d, offset %d", |
| 42 | is_output ? "OUTACL" : "INACL", t->sw_if_index, t->next_index, |
| 43 | t->table_index, t->offset); |
| 44 | |
| 45 | if (pool_is_free_index (vcm->tables, t->table_index)) |
| 46 | return format (s, "\n%Uno table", format_white_space, indent + 4); |
| 47 | |
| 48 | if (~0 == t->offset) |
| 49 | return format (s, "\n%Uno match", format_white_space, indent + 4); |
| 50 | |
| 51 | table = vnet_classify_table_get (t->table_index); |
| 52 | e = vnet_classify_get_entry (table, t->offset); |
| 53 | return format (s, "\n%U%U", format_white_space, indent + 4, |
| 54 | format_classify_entry, table, e); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 55 | } |
| 56 | |
Andrew Yourtchenko | 815d7d5 | 2018-02-07 11:37:02 +0100 | [diff] [blame] | 57 | static u8 * |
| 58 | format_ip_inacl_trace (u8 * s, va_list * args) |
| 59 | { |
| 60 | return format_ip_in_out_acl_trace (s, 0 /* is_output */ , args); |
| 61 | } |
| 62 | |
| 63 | static u8 * |
| 64 | format_ip_outacl_trace (u8 * s, va_list * args) |
| 65 | { |
| 66 | return format_ip_in_out_acl_trace (s, 1 /* is_output */ , args); |
| 67 | } |
| 68 | |
Filip Tehlar | 26ea14e | 2019-03-11 05:30:21 -0700 | [diff] [blame] | 69 | extern vlib_node_registration_t ip4_inacl_node; |
| 70 | extern vlib_node_registration_t ip4_outacl_node; |
| 71 | extern vlib_node_registration_t ip6_inacl_node; |
| 72 | extern vlib_node_registration_t ip6_outacl_node; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 73 | |
| 74 | #define foreach_ip_inacl_error \ |
| 75 | _(MISS, "input ACL misses") \ |
| 76 | _(HIT, "input ACL hits") \ |
| 77 | _(CHAIN_HIT, "input ACL hits after chain walk") |
| 78 | |
Andrew Yourtchenko | 815d7d5 | 2018-02-07 11:37:02 +0100 | [diff] [blame] | 79 | #define foreach_ip_outacl_error \ |
| 80 | _(MISS, "output ACL misses") \ |
| 81 | _(HIT, "output ACL hits") \ |
| 82 | _(CHAIN_HIT, "output ACL hits after chain walk") |
| 83 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 84 | typedef enum |
| 85 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 86 | #define _(sym,str) IP_INACL_ERROR_##sym, |
| 87 | foreach_ip_inacl_error |
| 88 | #undef _ |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 89 | IP_INACL_N_ERROR, |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 90 | } |
| 91 | ip_inacl_error_t; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 92 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 93 | static char *ip_inacl_error_strings[] = { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 94 | #define _(sym,string) string, |
| 95 | foreach_ip_inacl_error |
| 96 | #undef _ |
| 97 | }; |
| 98 | |
Andrew Yourtchenko | 815d7d5 | 2018-02-07 11:37:02 +0100 | [diff] [blame] | 99 | typedef enum |
| 100 | { |
| 101 | #define _(sym,str) IP_OUTACL_ERROR_##sym, |
| 102 | foreach_ip_outacl_error |
| 103 | #undef _ |
| 104 | IP_OUTACL_N_ERROR, |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 105 | } |
| 106 | ip_outacl_error_t; |
Andrew Yourtchenko | 815d7d5 | 2018-02-07 11:37:02 +0100 | [diff] [blame] | 107 | |
| 108 | static char *ip_outacl_error_strings[] = { |
| 109 | #define _(sym,string) string, |
| 110 | foreach_ip_outacl_error |
| 111 | #undef _ |
| 112 | }; |
| 113 | |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 114 | static_always_inline void |
Arthur de Kerhor | 1031098 | 2021-12-22 10:58:30 +0100 | [diff] [blame] | 115 | ip_in_out_acl_inline_trace ( |
| 116 | vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, |
| 117 | vlib_buffer_t **b, u16 *next, u32 n_left, u32 *hits__, u32 *misses__, |
| 118 | u32 *chain_hits__, const vlib_error_t error_none, |
| 119 | const vlib_error_t error_deny, const vlib_error_t error_miss, |
| 120 | vnet_classify_table_t *tables, const u32 *table_index_by_sw_if_index, |
| 121 | u32 *fib_index_by_sw_if_index, vnet_config_main_t *cm, |
| 122 | const vlib_rx_or_tx_t way, const int is_output, const int do_trace) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 123 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 124 | f64 now = vlib_time_now (vm); |
| 125 | u32 hits = 0; |
| 126 | u32 misses = 0; |
| 127 | u32 chain_hits = 0; |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 128 | u32 n_next_nodes = node->n_next_nodes; |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 129 | u8 *h[4]; |
| 130 | u32 sw_if_index[4]; |
| 131 | u32 table_index[4]; |
| 132 | vnet_classify_table_t *t[4] = { 0, 0 }; |
Benoît Ganne | b03eec9 | 2022-06-08 10:49:17 +0200 | [diff] [blame] | 133 | u32 hash[4]; |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 134 | |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 135 | /* calculate hashes for b[0] & b[1] */ |
| 136 | if (n_left >= 2) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 137 | { |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 138 | /* ~0 is used as a wildcard to say 'always use sw_if_index 0' |
| 139 | * aka local0. It is used when we do not care about the sw_if_index, as |
| 140 | * when punting */ |
| 141 | sw_if_index[2] = ~0 == way ? 0 : vnet_buffer (b[0])->sw_if_index[way]; |
| 142 | sw_if_index[3] = ~0 == way ? 0 : vnet_buffer (b[1])->sw_if_index[way]; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 143 | |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 144 | table_index[2] = table_index_by_sw_if_index[sw_if_index[2]]; |
| 145 | table_index[3] = table_index_by_sw_if_index[sw_if_index[3]]; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 146 | |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 147 | t[2] = pool_elt_at_index (tables, table_index[2]); |
| 148 | t[3] = pool_elt_at_index (tables, table_index[3]); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 149 | |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 150 | if (t[2]->current_data_flag == CLASSIFY_FLAG_USE_CURR_DATA) |
| 151 | h[2] = |
| 152 | (void *) vlib_buffer_get_current (b[0]) + t[2]->current_data_offset; |
Steve Shin | 25e26dc | 2016-11-08 10:47:10 -0800 | [diff] [blame] | 153 | else |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 154 | h[2] = b[0]->data; |
| 155 | |
| 156 | if (t[3]->current_data_flag == CLASSIFY_FLAG_USE_CURR_DATA) |
| 157 | h[3] = |
| 158 | (void *) vlib_buffer_get_current (b[1]) + t[3]->current_data_offset; |
| 159 | else |
| 160 | h[3] = b[1]->data; |
Steve Shin | 25e26dc | 2016-11-08 10:47:10 -0800 | [diff] [blame] | 161 | |
Andrew Yourtchenko | 815d7d5 | 2018-02-07 11:37:02 +0100 | [diff] [blame] | 162 | if (is_output) |
| 163 | { |
| 164 | /* Save the rewrite length, since we are using the l2_classify struct */ |
Benoît Ganne | b03eec9 | 2022-06-08 10:49:17 +0200 | [diff] [blame] | 165 | vnet_buffer (b[0])->l2.l2_len = |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 166 | vnet_buffer (b[0])->ip.save_rewrite_length; |
Andrew Yourtchenko | 815d7d5 | 2018-02-07 11:37:02 +0100 | [diff] [blame] | 167 | /* advance the match pointer so the matching happens on IP header */ |
Benoît Ganne | b03eec9 | 2022-06-08 10:49:17 +0200 | [diff] [blame] | 168 | h[2] += vnet_buffer (b[0])->l2.l2_len; |
Andrew Yourtchenko | 815d7d5 | 2018-02-07 11:37:02 +0100 | [diff] [blame] | 169 | |
Andrew Yourtchenko | 815d7d5 | 2018-02-07 11:37:02 +0100 | [diff] [blame] | 170 | /* Save the rewrite length, since we are using the l2_classify struct */ |
Benoît Ganne | b03eec9 | 2022-06-08 10:49:17 +0200 | [diff] [blame] | 171 | vnet_buffer (b[1])->l2.l2_len = |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 172 | vnet_buffer (b[1])->ip.save_rewrite_length; |
Andrew Yourtchenko | 815d7d5 | 2018-02-07 11:37:02 +0100 | [diff] [blame] | 173 | /* advance the match pointer so the matching happens on IP header */ |
Benoît Ganne | b03eec9 | 2022-06-08 10:49:17 +0200 | [diff] [blame] | 174 | h[3] += vnet_buffer (b[1])->l2.l2_len; |
Andrew Yourtchenko | 815d7d5 | 2018-02-07 11:37:02 +0100 | [diff] [blame] | 175 | } |
| 176 | |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 177 | hash[2] = vnet_classify_hash_packet_inline (t[2], (u8 *) h[2]); |
| 178 | hash[3] = vnet_classify_hash_packet_inline (t[3], (u8 *) h[3]); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 179 | |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 180 | vnet_buffer (b[0])->l2_classify.hash = hash[2]; |
| 181 | vnet_buffer (b[1])->l2_classify.hash = hash[3]; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 182 | |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 183 | vnet_buffer (b[0])->l2_classify.table_index = table_index[2]; |
| 184 | vnet_buffer (b[1])->l2_classify.table_index = table_index[3]; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 185 | |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 186 | vnet_buffer (b[0])->l2_classify.opaque_index = ~0; |
| 187 | vnet_buffer (b[1])->l2_classify.opaque_index = ~0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 188 | |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 189 | vnet_classify_prefetch_bucket (t[2], |
| 190 | vnet_buffer (b[0])->l2_classify.hash); |
| 191 | vnet_classify_prefetch_bucket (t[3], |
| 192 | vnet_buffer (b[1])->l2_classify.hash); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 193 | } |
| 194 | |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 195 | while (n_left >= 2) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 196 | { |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 197 | vnet_classify_entry_t *e[2] = { 0, 0 }; |
| 198 | u32 _next[2] = { ACL_NEXT_INDEX_DENY, ACL_NEXT_INDEX_DENY }; |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 199 | |
| 200 | h[0] = h[2]; |
| 201 | h[1] = h[3]; |
| 202 | t[0] = t[2]; |
| 203 | t[1] = t[3]; |
| 204 | |
| 205 | sw_if_index[0] = sw_if_index[2]; |
| 206 | sw_if_index[1] = sw_if_index[3]; |
| 207 | |
| 208 | table_index[0] = table_index[2]; |
| 209 | table_index[1] = table_index[3]; |
| 210 | |
| 211 | hash[0] = hash[2]; |
| 212 | hash[1] = hash[3]; |
| 213 | |
| 214 | /* prefetch next iteration */ |
| 215 | if (n_left >= 6) |
| 216 | { |
| 217 | vlib_prefetch_buffer_header (b[4], LOAD); |
| 218 | vlib_prefetch_buffer_header (b[5], LOAD); |
| 219 | |
Damjan Marion | af7fb04 | 2021-07-15 11:54:41 +0200 | [diff] [blame] | 220 | clib_prefetch_load (b[4]->data); |
| 221 | clib_prefetch_load (b[5]->data); |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 222 | } |
| 223 | |
| 224 | /* calculate hashes for b[2] & b[3] */ |
| 225 | if (n_left >= 4) |
| 226 | { |
| 227 | sw_if_index[2] = |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 228 | ~0 == way ? 0 : vnet_buffer (b[2])->sw_if_index[way]; |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 229 | sw_if_index[3] = |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 230 | ~0 == way ? 0 : vnet_buffer (b[3])->sw_if_index[way]; |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 231 | |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 232 | table_index[2] = table_index_by_sw_if_index[sw_if_index[2]]; |
| 233 | table_index[3] = table_index_by_sw_if_index[sw_if_index[3]]; |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 234 | |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 235 | t[2] = pool_elt_at_index (tables, table_index[2]); |
| 236 | t[3] = pool_elt_at_index (tables, table_index[3]); |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 237 | |
| 238 | if (t[2]->current_data_flag == CLASSIFY_FLAG_USE_CURR_DATA) |
| 239 | h[2] = |
| 240 | (void *) vlib_buffer_get_current (b[2]) + |
| 241 | t[2]->current_data_offset; |
| 242 | else |
| 243 | h[2] = b[2]->data; |
| 244 | |
| 245 | if (t[3]->current_data_flag == CLASSIFY_FLAG_USE_CURR_DATA) |
| 246 | h[3] = |
| 247 | (void *) vlib_buffer_get_current (b[3]) + |
| 248 | t[3]->current_data_offset; |
| 249 | else |
| 250 | h[3] = b[3]->data; |
| 251 | |
| 252 | if (is_output) |
| 253 | { |
| 254 | /* Save the rewrite length, since we are using the l2_classify struct */ |
Benoît Ganne | b03eec9 | 2022-06-08 10:49:17 +0200 | [diff] [blame] | 255 | vnet_buffer (b[2])->l2.l2_len = |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 256 | vnet_buffer (b[2])->ip.save_rewrite_length; |
| 257 | /* advance the match pointer so the matching happens on IP header */ |
Benoît Ganne | b03eec9 | 2022-06-08 10:49:17 +0200 | [diff] [blame] | 258 | h[2] += vnet_buffer (b[2])->l2.l2_len; |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 259 | |
| 260 | /* Save the rewrite length, since we are using the l2_classify struct */ |
Benoît Ganne | b03eec9 | 2022-06-08 10:49:17 +0200 | [diff] [blame] | 261 | vnet_buffer (b[3])->l2.l2_len = |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 262 | vnet_buffer (b[3])->ip.save_rewrite_length; |
| 263 | /* advance the match pointer so the matching happens on IP header */ |
Benoît Ganne | b03eec9 | 2022-06-08 10:49:17 +0200 | [diff] [blame] | 264 | h[3] += vnet_buffer (b[3])->l2.l2_len; |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 265 | } |
| 266 | |
| 267 | hash[2] = vnet_classify_hash_packet_inline (t[2], (u8 *) h[2]); |
| 268 | hash[3] = vnet_classify_hash_packet_inline (t[3], (u8 *) h[3]); |
| 269 | |
| 270 | vnet_buffer (b[2])->l2_classify.hash = hash[2]; |
| 271 | vnet_buffer (b[3])->l2_classify.hash = hash[3]; |
| 272 | |
| 273 | vnet_buffer (b[2])->l2_classify.table_index = table_index[2]; |
| 274 | vnet_buffer (b[3])->l2_classify.table_index = table_index[3]; |
| 275 | |
| 276 | vnet_buffer (b[2])->l2_classify.opaque_index = ~0; |
| 277 | vnet_buffer (b[3])->l2_classify.opaque_index = ~0; |
| 278 | |
| 279 | vnet_classify_prefetch_bucket (t[2], |
| 280 | vnet_buffer (b[2])-> |
| 281 | l2_classify.hash); |
| 282 | vnet_classify_prefetch_bucket (t[3], |
| 283 | vnet_buffer (b[3])-> |
| 284 | l2_classify.hash); |
| 285 | } |
| 286 | |
| 287 | /* find entry for b[0] & b[1] */ |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 288 | vnet_get_config_data (cm, &b[0]->current_config_index, &_next[0], |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 289 | /* # bytes of config data */ 0); |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 290 | vnet_get_config_data (cm, &b[1]->current_config_index, &_next[1], |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 291 | /* # bytes of config data */ 0); |
| 292 | |
| 293 | if (PREDICT_TRUE (table_index[0] != ~0)) |
| 294 | { |
| 295 | e[0] = |
| 296 | vnet_classify_find_entry_inline (t[0], (u8 *) h[0], hash[0], now); |
| 297 | if (e[0]) |
| 298 | { |
| 299 | vnet_buffer (b[0])->l2_classify.opaque_index |
| 300 | = e[0]->opaque_index; |
| 301 | vlib_buffer_advance (b[0], e[0]->advance); |
| 302 | |
| 303 | _next[0] = (e[0]->next_index < n_next_nodes) ? |
| 304 | e[0]->next_index : _next[0]; |
| 305 | |
| 306 | hits++; |
| 307 | |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 308 | b[0]->error = |
| 309 | (_next[0] == ACL_NEXT_INDEX_DENY) ? error_deny : error_none; |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 310 | |
| 311 | if (!is_output) |
| 312 | { |
| 313 | if (e[0]->action == CLASSIFY_ACTION_SET_IP4_FIB_INDEX || |
| 314 | e[0]->action == CLASSIFY_ACTION_SET_IP6_FIB_INDEX) |
| 315 | vnet_buffer (b[0])->sw_if_index[VLIB_TX] = e[0]->metadata; |
| 316 | else if (e[0]->action == CLASSIFY_ACTION_SET_METADATA) |
Arthur de Kerhor | 1031098 | 2021-12-22 10:58:30 +0100 | [diff] [blame] | 317 | { |
| 318 | vnet_buffer (b[0])->ip.adj_index[VLIB_TX] = |
| 319 | e[0]->metadata; |
| 320 | /* For source check in case we skip the lookup node */ |
| 321 | ip_lookup_set_buffer_fib_index (fib_index_by_sw_if_index, |
| 322 | b[0]); |
| 323 | } |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 324 | } |
| 325 | } |
| 326 | else |
| 327 | { |
| 328 | while (1) |
| 329 | { |
| 330 | if (PREDICT_TRUE (t[0]->next_table_index != ~0)) |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 331 | t[0] = pool_elt_at_index (tables, t[0]->next_table_index); |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 332 | else |
| 333 | { |
| 334 | _next[0] = (t[0]->miss_next_index < n_next_nodes) ? |
| 335 | t[0]->miss_next_index : _next[0]; |
| 336 | |
| 337 | misses++; |
| 338 | |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 339 | b[0]->error = (_next[0] == ACL_NEXT_INDEX_DENY) ? |
| 340 | error_miss : |
| 341 | error_none; |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 342 | break; |
| 343 | } |
| 344 | |
| 345 | if (t[0]->current_data_flag == CLASSIFY_FLAG_USE_CURR_DATA) |
| 346 | h[0] = |
| 347 | (void *) vlib_buffer_get_current (b[0]) + |
| 348 | t[0]->current_data_offset; |
| 349 | else |
| 350 | h[0] = b[0]->data; |
| 351 | |
| 352 | /* advance the match pointer so the matching happens on IP header */ |
| 353 | if (is_output) |
Benoît Ganne | b03eec9 | 2022-06-08 10:49:17 +0200 | [diff] [blame] | 354 | h[0] += vnet_buffer (b[0])->l2.l2_len; |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 355 | |
| 356 | hash[0] = |
| 357 | vnet_classify_hash_packet_inline (t[0], (u8 *) h[0]); |
| 358 | e[0] = |
| 359 | vnet_classify_find_entry_inline (t[0], (u8 *) h[0], |
| 360 | hash[0], now); |
| 361 | if (e[0]) |
| 362 | { |
| 363 | vnet_buffer (b[0])->l2_classify.opaque_index |
| 364 | = e[0]->opaque_index; |
| 365 | vlib_buffer_advance (b[0], e[0]->advance); |
| 366 | _next[0] = (e[0]->next_index < n_next_nodes) ? |
| 367 | e[0]->next_index : _next[0]; |
| 368 | hits++; |
| 369 | chain_hits++; |
| 370 | |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 371 | b[0]->error = (_next[0] == ACL_NEXT_INDEX_DENY) ? |
| 372 | error_deny : |
| 373 | error_none; |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 374 | |
| 375 | if (!is_output) |
| 376 | { |
| 377 | if (e[0]->action == |
| 378 | CLASSIFY_ACTION_SET_IP4_FIB_INDEX |
| 379 | || e[0]->action == |
| 380 | CLASSIFY_ACTION_SET_IP6_FIB_INDEX) |
| 381 | vnet_buffer (b[0])->sw_if_index[VLIB_TX] = |
| 382 | e[0]->metadata; |
| 383 | else if (e[0]->action == |
| 384 | CLASSIFY_ACTION_SET_METADATA) |
Arthur de Kerhor | 1031098 | 2021-12-22 10:58:30 +0100 | [diff] [blame] | 385 | { |
| 386 | vnet_buffer (b[0])->ip.adj_index[VLIB_TX] = |
| 387 | e[0]->metadata; |
| 388 | /* For source check in case we skip the lookup |
| 389 | * node */ |
| 390 | ip_lookup_set_buffer_fib_index ( |
| 391 | fib_index_by_sw_if_index, b[0]); |
| 392 | } |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 393 | } |
| 394 | break; |
| 395 | } |
| 396 | } |
| 397 | } |
| 398 | } |
| 399 | |
| 400 | if (PREDICT_TRUE (table_index[1] != ~0)) |
| 401 | { |
| 402 | e[1] = |
| 403 | vnet_classify_find_entry_inline (t[1], (u8 *) h[1], hash[1], now); |
| 404 | if (e[1]) |
| 405 | { |
| 406 | vnet_buffer (b[1])->l2_classify.opaque_index |
| 407 | = e[1]->opaque_index; |
| 408 | vlib_buffer_advance (b[1], e[1]->advance); |
| 409 | |
| 410 | _next[1] = (e[1]->next_index < n_next_nodes) ? |
| 411 | e[1]->next_index : _next[1]; |
| 412 | |
| 413 | hits++; |
| 414 | |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 415 | b[1]->error = |
| 416 | (_next[1] == ACL_NEXT_INDEX_DENY) ? error_deny : error_none; |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 417 | |
| 418 | if (!is_output) |
| 419 | { |
| 420 | if (e[1]->action == CLASSIFY_ACTION_SET_IP4_FIB_INDEX || |
| 421 | e[1]->action == CLASSIFY_ACTION_SET_IP6_FIB_INDEX) |
| 422 | vnet_buffer (b[1])->sw_if_index[VLIB_TX] = e[1]->metadata; |
| 423 | else if (e[1]->action == CLASSIFY_ACTION_SET_METADATA) |
Arthur de Kerhor | 1031098 | 2021-12-22 10:58:30 +0100 | [diff] [blame] | 424 | { |
| 425 | vnet_buffer (b[1])->ip.adj_index[VLIB_TX] = |
| 426 | e[1]->metadata; |
| 427 | /* For source check in case we skip the lookup node */ |
| 428 | ip_lookup_set_buffer_fib_index (fib_index_by_sw_if_index, |
| 429 | b[1]); |
| 430 | } |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 431 | } |
| 432 | } |
| 433 | else |
| 434 | { |
| 435 | while (1) |
| 436 | { |
| 437 | if (PREDICT_TRUE (t[1]->next_table_index != ~0)) |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 438 | t[1] = pool_elt_at_index (tables, t[1]->next_table_index); |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 439 | else |
| 440 | { |
| 441 | _next[1] = (t[1]->miss_next_index < n_next_nodes) ? |
| 442 | t[1]->miss_next_index : _next[1]; |
| 443 | |
| 444 | misses++; |
| 445 | |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 446 | b[1]->error = (_next[1] == ACL_NEXT_INDEX_DENY) ? |
| 447 | error_miss : |
| 448 | error_none; |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 449 | break; |
| 450 | } |
| 451 | |
| 452 | if (t[1]->current_data_flag == CLASSIFY_FLAG_USE_CURR_DATA) |
| 453 | h[1] = |
| 454 | (void *) vlib_buffer_get_current (b[1]) + |
| 455 | t[1]->current_data_offset; |
| 456 | else |
| 457 | h[1] = b[1]->data; |
| 458 | |
| 459 | /* advance the match pointer so the matching happens on IP header */ |
| 460 | if (is_output) |
Benoît Ganne | b03eec9 | 2022-06-08 10:49:17 +0200 | [diff] [blame] | 461 | h[1] += vnet_buffer (b[1])->l2.l2_len; |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 462 | |
| 463 | hash[1] = |
| 464 | vnet_classify_hash_packet_inline (t[1], (u8 *) h[1]); |
| 465 | e[1] = |
| 466 | vnet_classify_find_entry_inline (t[1], (u8 *) h[1], |
| 467 | hash[1], now); |
| 468 | if (e[1]) |
| 469 | { |
| 470 | vnet_buffer (b[1])->l2_classify.opaque_index |
| 471 | = e[1]->opaque_index; |
| 472 | vlib_buffer_advance (b[1], e[1]->advance); |
| 473 | _next[1] = (e[1]->next_index < n_next_nodes) ? |
| 474 | e[1]->next_index : _next[1]; |
| 475 | hits++; |
| 476 | chain_hits++; |
| 477 | |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 478 | b[1]->error = (_next[1] == ACL_NEXT_INDEX_DENY) ? |
| 479 | error_deny : |
| 480 | error_none; |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 481 | |
| 482 | if (!is_output) |
| 483 | { |
| 484 | if (e[1]->action == |
| 485 | CLASSIFY_ACTION_SET_IP4_FIB_INDEX |
| 486 | || e[1]->action == |
| 487 | CLASSIFY_ACTION_SET_IP6_FIB_INDEX) |
| 488 | vnet_buffer (b[1])->sw_if_index[VLIB_TX] = |
| 489 | e[1]->metadata; |
| 490 | else if (e[1]->action == |
| 491 | CLASSIFY_ACTION_SET_METADATA) |
Arthur de Kerhor | 1031098 | 2021-12-22 10:58:30 +0100 | [diff] [blame] | 492 | { |
| 493 | vnet_buffer (b[1])->ip.adj_index[VLIB_TX] = |
| 494 | e[1]->metadata; |
| 495 | /* For source check in case we skip the lookup |
| 496 | * node */ |
| 497 | ip_lookup_set_buffer_fib_index ( |
| 498 | fib_index_by_sw_if_index, b[1]); |
| 499 | } |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 500 | } |
| 501 | break; |
| 502 | } |
| 503 | } |
| 504 | } |
| 505 | } |
| 506 | |
| 507 | if (do_trace && b[0]->flags & VLIB_BUFFER_IS_TRACED) |
| 508 | { |
| 509 | ip_in_out_acl_trace_t *_t = |
| 510 | vlib_add_trace (vm, node, b[0], sizeof (*_t)); |
| 511 | _t->sw_if_index = |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 512 | ~0 == way ? 0 : vnet_buffer (b[0])->sw_if_index[way]; |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 513 | _t->next_index = _next[0]; |
Benoît Ganne | c629f90 | 2022-06-08 10:56:33 +0200 | [diff] [blame] | 514 | _t->table_index = table_index[0]; |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 515 | _t->offset = (e[0] |
| 516 | && t[0]) ? vnet_classify_get_offset (t[0], e[0]) : ~0; |
| 517 | } |
| 518 | |
| 519 | if (do_trace && b[1]->flags & VLIB_BUFFER_IS_TRACED) |
| 520 | { |
| 521 | ip_in_out_acl_trace_t *_t = |
| 522 | vlib_add_trace (vm, node, b[1], sizeof (*_t)); |
| 523 | _t->sw_if_index = |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 524 | ~0 == way ? 0 : vnet_buffer (b[1])->sw_if_index[way]; |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 525 | _t->next_index = _next[1]; |
Benoît Ganne | c629f90 | 2022-06-08 10:56:33 +0200 | [diff] [blame] | 526 | _t->table_index = table_index[1]; |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 527 | _t->offset = (e[1] |
| 528 | && t[1]) ? vnet_classify_get_offset (t[1], e[1]) : ~0; |
| 529 | } |
| 530 | |
| 531 | if ((_next[0] == ACL_NEXT_INDEX_DENY) && is_output) |
| 532 | { |
| 533 | /* on output, for the drop node to work properly, go back to ip header */ |
| 534 | vlib_buffer_advance (b[0], vnet_buffer (b[0])->l2.l2_len); |
| 535 | } |
| 536 | |
| 537 | if ((_next[1] == ACL_NEXT_INDEX_DENY) && is_output) |
| 538 | { |
| 539 | /* on output, for the drop node to work properly, go back to ip header */ |
| 540 | vlib_buffer_advance (b[1], vnet_buffer (b[1])->l2.l2_len); |
| 541 | } |
| 542 | |
| 543 | next[0] = _next[0]; |
| 544 | next[1] = _next[1]; |
| 545 | |
| 546 | /* _next */ |
| 547 | next += 2; |
| 548 | b += 2; |
| 549 | n_left -= 2; |
| 550 | } |
| 551 | |
| 552 | while (n_left > 0) |
| 553 | { |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 554 | u8 *h0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 555 | u32 sw_if_index0; |
| 556 | u32 table_index0; |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 557 | vnet_classify_table_t *t0 = 0; |
| 558 | vnet_classify_entry_t *e0 = 0; |
| 559 | u32 next0 = ACL_NEXT_INDEX_DENY; |
Benoît Ganne | b03eec9 | 2022-06-08 10:49:17 +0200 | [diff] [blame] | 560 | u32 hash0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 561 | |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 562 | sw_if_index0 = ~0 == way ? 0 : vnet_buffer (b[0])->sw_if_index[way]; |
| 563 | table_index0 = table_index_by_sw_if_index[sw_if_index0]; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 564 | |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 565 | t0 = pool_elt_at_index (tables, table_index0); |
Steve Shin | 25e26dc | 2016-11-08 10:47:10 -0800 | [diff] [blame] | 566 | |
| 567 | if (t0->current_data_flag == CLASSIFY_FLAG_USE_CURR_DATA) |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 568 | h0 = |
| 569 | (void *) vlib_buffer_get_current (b[0]) + t0->current_data_offset; |
Steve Shin | 25e26dc | 2016-11-08 10:47:10 -0800 | [diff] [blame] | 570 | else |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 571 | h0 = b[0]->data; |
Steve Shin | 25e26dc | 2016-11-08 10:47:10 -0800 | [diff] [blame] | 572 | |
Andrew Yourtchenko | 815d7d5 | 2018-02-07 11:37:02 +0100 | [diff] [blame] | 573 | if (is_output) |
| 574 | { |
| 575 | /* Save the rewrite length, since we are using the l2_classify struct */ |
Benoît Ganne | b03eec9 | 2022-06-08 10:49:17 +0200 | [diff] [blame] | 576 | vnet_buffer (b[0])->l2.l2_len = |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 577 | vnet_buffer (b[0])->ip.save_rewrite_length; |
Andrew Yourtchenko | 815d7d5 | 2018-02-07 11:37:02 +0100 | [diff] [blame] | 578 | /* advance the match pointer so the matching happens on IP header */ |
Benoît Ganne | b03eec9 | 2022-06-08 10:49:17 +0200 | [diff] [blame] | 579 | h0 += vnet_buffer (b[0])->l2.l2_len; |
Andrew Yourtchenko | 815d7d5 | 2018-02-07 11:37:02 +0100 | [diff] [blame] | 580 | } |
| 581 | |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 582 | vnet_buffer (b[0])->l2_classify.hash = |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 583 | vnet_classify_hash_packet (t0, (u8 *) h0); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 584 | |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 585 | vnet_buffer (b[0])->l2_classify.table_index = table_index0; |
| 586 | vnet_buffer (b[0])->l2_classify.opaque_index = ~0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 587 | |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 588 | vnet_get_config_data (cm, &b[0]->current_config_index, &next0, |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 589 | /* # bytes of config data */ 0); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 590 | |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 591 | if (PREDICT_TRUE (table_index0 != ~0)) |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 592 | { |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 593 | hash0 = vnet_buffer (b[0])->l2_classify.hash; |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 594 | t0 = pool_elt_at_index (tables, table_index0); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 595 | |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 596 | if (t0->current_data_flag == CLASSIFY_FLAG_USE_CURR_DATA) |
| 597 | h0 = |
| 598 | (void *) vlib_buffer_get_current (b[0]) + |
| 599 | t0->current_data_offset; |
| 600 | else |
| 601 | h0 = b[0]->data; |
| 602 | |
| 603 | /* advance the match pointer so the matching happens on IP header */ |
| 604 | if (is_output) |
Benoît Ganne | b03eec9 | 2022-06-08 10:49:17 +0200 | [diff] [blame] | 605 | h0 += vnet_buffer (b[0])->l2.l2_len; |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 606 | |
| 607 | e0 = vnet_classify_find_entry_inline (t0, (u8 *) h0, hash0, now); |
| 608 | if (e0) |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 609 | { |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 610 | vnet_buffer (b[0])->l2_classify.opaque_index = e0->opaque_index; |
| 611 | vlib_buffer_advance (b[0], e0->advance); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 612 | |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 613 | next0 = (e0->next_index < n_next_nodes) ? |
| 614 | e0->next_index : next0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 615 | |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 616 | hits++; |
| 617 | |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 618 | b[0]->error = |
| 619 | (next0 == ACL_NEXT_INDEX_DENY) ? error_deny : error_none; |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 620 | |
| 621 | if (!is_output) |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 622 | { |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 623 | if (e0->action == CLASSIFY_ACTION_SET_IP4_FIB_INDEX || |
| 624 | e0->action == CLASSIFY_ACTION_SET_IP6_FIB_INDEX) |
| 625 | vnet_buffer (b[0])->sw_if_index[VLIB_TX] = e0->metadata; |
| 626 | else if (e0->action == CLASSIFY_ACTION_SET_METADATA) |
Arthur de Kerhor | 1031098 | 2021-12-22 10:58:30 +0100 | [diff] [blame] | 627 | { |
| 628 | vnet_buffer (b[0])->ip.adj_index[VLIB_TX] = e0->metadata; |
| 629 | /* For source check in case we skip the lookup node */ |
| 630 | ip_lookup_set_buffer_fib_index (fib_index_by_sw_if_index, |
| 631 | b[0]); |
| 632 | } |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 633 | } |
| 634 | } |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 635 | else |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 636 | { |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 637 | while (1) |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 638 | { |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 639 | if (PREDICT_TRUE (t0->next_table_index != ~0)) |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 640 | t0 = pool_elt_at_index (tables, t0->next_table_index); |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 641 | else |
Andrew Yourtchenko | 815d7d5 | 2018-02-07 11:37:02 +0100 | [diff] [blame] | 642 | { |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 643 | next0 = (t0->miss_next_index < n_next_nodes) ? |
| 644 | t0->miss_next_index : next0; |
| 645 | |
| 646 | misses++; |
| 647 | |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 648 | b[0]->error = (next0 == ACL_NEXT_INDEX_DENY) ? |
| 649 | error_miss : |
| 650 | error_none; |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 651 | break; |
Andrew Yourtchenko | 815d7d5 | 2018-02-07 11:37:02 +0100 | [diff] [blame] | 652 | } |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 653 | |
| 654 | if (t0->current_data_flag == CLASSIFY_FLAG_USE_CURR_DATA) |
| 655 | h0 = |
| 656 | (void *) vlib_buffer_get_current (b[0]) + |
| 657 | t0->current_data_offset; |
| 658 | else |
| 659 | h0 = b[0]->data; |
| 660 | |
| 661 | /* advance the match pointer so the matching happens on IP header */ |
| 662 | if (is_output) |
Benoît Ganne | b03eec9 | 2022-06-08 10:49:17 +0200 | [diff] [blame] | 663 | h0 += vnet_buffer (b[0])->l2.l2_len; |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 664 | |
| 665 | hash0 = vnet_classify_hash_packet_inline (t0, (u8 *) h0); |
| 666 | e0 = vnet_classify_find_entry_inline |
| 667 | (t0, (u8 *) h0, hash0, now); |
| 668 | if (e0) |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 669 | { |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 670 | vnet_buffer (b[0])->l2_classify.opaque_index |
| 671 | = e0->opaque_index; |
| 672 | vlib_buffer_advance (b[0], e0->advance); |
| 673 | next0 = (e0->next_index < n_next_nodes) ? |
| 674 | e0->next_index : next0; |
| 675 | hits++; |
| 676 | |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 677 | b[0]->error = (next0 == ACL_NEXT_INDEX_DENY) ? |
| 678 | error_deny : |
| 679 | error_none; |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 680 | |
| 681 | if (!is_output) |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 682 | { |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 683 | if (e0->action == |
| 684 | CLASSIFY_ACTION_SET_IP4_FIB_INDEX |
| 685 | || e0->action == |
| 686 | CLASSIFY_ACTION_SET_IP6_FIB_INDEX) |
| 687 | vnet_buffer (b[0])->sw_if_index[VLIB_TX] = |
| 688 | e0->metadata; |
| 689 | else if (e0->action == CLASSIFY_ACTION_SET_METADATA) |
Arthur de Kerhor | 1031098 | 2021-12-22 10:58:30 +0100 | [diff] [blame] | 690 | { |
| 691 | vnet_buffer (b[0])->ip.adj_index[VLIB_TX] = |
| 692 | e0->metadata; |
| 693 | /* For source check in case we skip the lookup |
| 694 | * node */ |
| 695 | ip_lookup_set_buffer_fib_index ( |
| 696 | fib_index_by_sw_if_index, b[0]); |
| 697 | } |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 698 | } |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 699 | break; |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 700 | } |
| 701 | } |
| 702 | } |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 703 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 704 | |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 705 | if (do_trace && b[0]->flags & VLIB_BUFFER_IS_TRACED) |
| 706 | { |
| 707 | ip_in_out_acl_trace_t *t = |
| 708 | vlib_add_trace (vm, node, b[0], sizeof (*t)); |
| 709 | t->sw_if_index = |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 710 | ~0 == way ? 0 : vnet_buffer (b[0])->sw_if_index[way]; |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 711 | t->next_index = next0; |
Benoît Ganne | c629f90 | 2022-06-08 10:56:33 +0200 | [diff] [blame] | 712 | t->table_index = table_index0; |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 713 | t->offset = (e0 && t0) ? vnet_classify_get_offset (t0, e0) : ~0; |
| 714 | } |
| 715 | |
| 716 | if ((next0 == ACL_NEXT_INDEX_DENY) && is_output) |
| 717 | { |
| 718 | /* on output, for the drop node to work properly, go back to ip header */ |
| 719 | vlib_buffer_advance (b[0], vnet_buffer (b[0])->l2.l2_len); |
| 720 | } |
| 721 | |
| 722 | next[0] = next0; |
| 723 | |
| 724 | /* next */ |
| 725 | next++; |
| 726 | b++; |
| 727 | n_left--; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 728 | } |
| 729 | |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 730 | *hits__ = hits; |
| 731 | *misses__ = misses; |
| 732 | *chain_hits__ = chain_hits; |
| 733 | } |
| 734 | |
| 735 | static_always_inline uword |
| 736 | ip_in_out_acl_inline (vlib_main_t *vm, vlib_node_runtime_t *node, |
| 737 | vlib_frame_t *frame, const in_out_acl_table_id_t tid, |
Arthur de Kerhor | 1031098 | 2021-12-22 10:58:30 +0100 | [diff] [blame] | 738 | u32 *fib_index_by_sw_if_index, |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 739 | const vlib_node_registration_t *parent_error_node, |
| 740 | const u32 error_none_index, const u32 error_deny_index, |
| 741 | const u32 error_miss_index, const vlib_rx_or_tx_t way, |
| 742 | const int is_output) |
| 743 | { |
| 744 | const in_out_acl_main_t *am = &in_out_acl_main; |
| 745 | vnet_classify_table_t *tables = am->vnet_classify_main->tables; |
| 746 | u32 *from = vlib_frame_vector_args (frame); |
| 747 | const u32 *table_index_by_sw_if_index = |
| 748 | am->classify_table_index_by_sw_if_index[is_output][tid]; |
| 749 | vnet_config_main_t *cm = am->vnet_config_main[is_output][tid]; |
| 750 | const vlib_node_runtime_t *error_node = |
| 751 | vlib_node_get_runtime (vm, parent_error_node->index); |
| 752 | const vlib_error_t error_none = error_node->errors[error_none_index]; |
| 753 | const vlib_error_t error_deny = error_node->errors[error_deny_index]; |
| 754 | const vlib_error_t error_miss = error_node->errors[error_miss_index]; |
| 755 | vlib_buffer_t *bufs[VLIB_FRAME_SIZE]; |
| 756 | u16 nexts[VLIB_FRAME_SIZE]; |
| 757 | u32 hits, misses, chain_hits; |
| 758 | |
| 759 | vlib_get_buffers (vm, from, bufs, frame->n_vectors); |
| 760 | |
| 761 | #define ip_in_out_acl_inline_trace__(do_trace) \ |
| 762 | ip_in_out_acl_inline_trace ( \ |
| 763 | vm, node, frame, bufs, nexts, frame->n_vectors, &hits, &misses, \ |
| 764 | &chain_hits, error_deny, error_miss, error_none, tables, \ |
Arthur de Kerhor | 1031098 | 2021-12-22 10:58:30 +0100 | [diff] [blame] | 765 | table_index_by_sw_if_index, fib_index_by_sw_if_index, cm, way, is_output, \ |
| 766 | do_trace) |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 767 | |
| 768 | if (PREDICT_FALSE (node->flags & VLIB_NODE_FLAG_TRACE)) |
| 769 | ip_in_out_acl_inline_trace__ (1 /* do_trace */); |
| 770 | else |
| 771 | ip_in_out_acl_inline_trace__ (0 /* do_trace */); |
| 772 | |
| 773 | vlib_node_increment_counter ( |
| 774 | vm, node->node_index, |
| 775 | is_output ? IP_OUTACL_ERROR_MISS : IP_INACL_ERROR_MISS, misses); |
| 776 | vlib_node_increment_counter ( |
| 777 | vm, node->node_index, is_output ? IP_OUTACL_ERROR_HIT : IP_INACL_ERROR_HIT, |
| 778 | hits); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 779 | vlib_node_increment_counter (vm, node->node_index, |
Andrew Yourtchenko | 815d7d5 | 2018-02-07 11:37:02 +0100 | [diff] [blame] | 780 | is_output ? IP_OUTACL_ERROR_CHAIN_HIT : |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 781 | IP_INACL_ERROR_CHAIN_HIT, |
| 782 | chain_hits); |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 783 | |
| 784 | vlib_buffer_enqueue_to_next (vm, node, from, nexts, frame->n_vectors); |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 785 | return frame->n_vectors; |
Andrew Yourtchenko | 815d7d5 | 2018-02-07 11:37:02 +0100 | [diff] [blame] | 786 | } |
| 787 | |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 788 | VLIB_NODE_FN (ip4_inacl_node) |
| 789 | (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame) |
Andrew Yourtchenko | 815d7d5 | 2018-02-07 11:37:02 +0100 | [diff] [blame] | 790 | { |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 791 | return ip_in_out_acl_inline ( |
Arthur de Kerhor | 1031098 | 2021-12-22 10:58:30 +0100 | [diff] [blame] | 792 | vm, node, frame, IN_OUT_ACL_TABLE_IP4, ip4_main.fib_index_by_sw_if_index, |
| 793 | &ip4_input_node, IP4_ERROR_NONE, IP4_ERROR_INACL_SESSION_DENY, |
| 794 | IP4_ERROR_INACL_TABLE_MISS, VLIB_RX, 0 /* is_output */); |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 795 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 796 | |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 797 | VLIB_NODE_FN (ip4_punt_acl_node) |
| 798 | (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame) |
| 799 | { |
| 800 | return ip_in_out_acl_inline ( |
Arthur de Kerhor | 1031098 | 2021-12-22 10:58:30 +0100 | [diff] [blame] | 801 | vm, node, frame, IN_OUT_ACL_TABLE_IP4_PUNT, |
| 802 | ip4_main.fib_index_by_sw_if_index, &ip4_input_node, IP4_ERROR_NONE, |
| 803 | IP4_ERROR_INACL_SESSION_DENY, IP4_ERROR_INACL_TABLE_MISS, ~0 /* way */, |
| 804 | 0 /* is_output */); |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 805 | } |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 806 | |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 807 | VLIB_NODE_FN (ip4_outacl_node) |
| 808 | (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame) |
| 809 | { |
| 810 | return ip_in_out_acl_inline ( |
Arthur de Kerhor | 1031098 | 2021-12-22 10:58:30 +0100 | [diff] [blame] | 811 | vm, node, frame, IN_OUT_ACL_TABLE_IP4, NULL, &ip4_input_node, |
| 812 | IP4_ERROR_NONE, IP4_ERROR_INACL_SESSION_DENY, IP4_ERROR_INACL_TABLE_MISS, |
| 813 | VLIB_TX, 1 /* is_output */); |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 814 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 815 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 816 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 817 | VLIB_REGISTER_NODE (ip4_inacl_node) = { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 818 | .name = "ip4-inacl", |
| 819 | .vector_size = sizeof (u32), |
| 820 | .format_trace = format_ip_inacl_trace, |
| 821 | .n_errors = ARRAY_LEN(ip_inacl_error_strings), |
| 822 | .error_strings = ip_inacl_error_strings, |
| 823 | |
| 824 | .n_next_nodes = ACL_NEXT_INDEX_N_NEXT, |
| 825 | .next_nodes = { |
Vijayabhaskar Katamreddy | ce07412 | 2017-11-15 13:50:26 -0800 | [diff] [blame] | 826 | [ACL_NEXT_INDEX_DENY] = "ip4-drop", |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 827 | }, |
| 828 | }; |
Andrew Yourtchenko | 815d7d5 | 2018-02-07 11:37:02 +0100 | [diff] [blame] | 829 | |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 830 | VLIB_REGISTER_NODE (ip4_punt_acl_node) = { |
| 831 | .name = "ip4-punt-acl", |
| 832 | .vector_size = sizeof (u32), |
| 833 | .format_trace = format_ip_inacl_trace, |
| 834 | .n_errors = ARRAY_LEN(ip_inacl_error_strings), |
| 835 | .error_strings = ip_inacl_error_strings, |
| 836 | |
| 837 | .n_next_nodes = ACL_NEXT_INDEX_N_NEXT, |
| 838 | .next_nodes = { |
| 839 | [ACL_NEXT_INDEX_DENY] = "ip4-drop", |
| 840 | }, |
| 841 | }; |
| 842 | |
Andrew Yourtchenko | 815d7d5 | 2018-02-07 11:37:02 +0100 | [diff] [blame] | 843 | VLIB_REGISTER_NODE (ip4_outacl_node) = { |
Andrew Yourtchenko | 815d7d5 | 2018-02-07 11:37:02 +0100 | [diff] [blame] | 844 | .name = "ip4-outacl", |
| 845 | .vector_size = sizeof (u32), |
| 846 | .format_trace = format_ip_outacl_trace, |
| 847 | .n_errors = ARRAY_LEN(ip_outacl_error_strings), |
| 848 | .error_strings = ip_outacl_error_strings, |
| 849 | |
| 850 | .n_next_nodes = ACL_NEXT_INDEX_N_NEXT, |
| 851 | .next_nodes = { |
| 852 | [ACL_NEXT_INDEX_DENY] = "ip4-drop", |
| 853 | }, |
| 854 | }; |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 855 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 856 | |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 857 | VNET_FEATURE_INIT (ip4_punt_acl_feature) = { |
| 858 | .arc_name = "ip4-punt", |
| 859 | .node_name = "ip4-punt-acl", |
| 860 | .runs_after = VNET_FEATURES ("ip4-punt-policer"), |
| 861 | }; |
| 862 | |
Filip Tehlar | 26ea14e | 2019-03-11 05:30:21 -0700 | [diff] [blame] | 863 | VLIB_NODE_FN (ip6_inacl_node) (vlib_main_t * vm, vlib_node_runtime_t * node, |
| 864 | vlib_frame_t * frame) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 865 | { |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 866 | return ip_in_out_acl_inline ( |
Arthur de Kerhor | 1031098 | 2021-12-22 10:58:30 +0100 | [diff] [blame] | 867 | vm, node, frame, IN_OUT_ACL_TABLE_IP6, ip6_main.fib_index_by_sw_if_index, |
| 868 | &ip6_input_node, IP6_ERROR_NONE, IP6_ERROR_INACL_SESSION_DENY, |
| 869 | IP6_ERROR_INACL_TABLE_MISS, VLIB_RX, 0 /* is_output */); |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 870 | } |
Ray Kinsella | 8899ce0 | 2020-03-12 15:52:41 +0000 | [diff] [blame] | 871 | |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 872 | VLIB_NODE_FN (ip6_punt_acl_node) |
| 873 | (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame) |
| 874 | { |
| 875 | return ip_in_out_acl_inline ( |
Arthur de Kerhor | 1031098 | 2021-12-22 10:58:30 +0100 | [diff] [blame] | 876 | vm, node, frame, IN_OUT_ACL_TABLE_IP6_PUNT, |
| 877 | ip4_main.fib_index_by_sw_if_index, &ip6_input_node, IP6_ERROR_NONE, |
| 878 | IP6_ERROR_INACL_SESSION_DENY, IP6_ERROR_INACL_TABLE_MISS, ~0 /* way */, |
| 879 | 0 /* is_output */); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 880 | } |
| 881 | |
Filip Tehlar | 26ea14e | 2019-03-11 05:30:21 -0700 | [diff] [blame] | 882 | VLIB_NODE_FN (ip6_outacl_node) (vlib_main_t * vm, vlib_node_runtime_t * node, |
| 883 | vlib_frame_t * frame) |
Andrew Yourtchenko | 815d7d5 | 2018-02-07 11:37:02 +0100 | [diff] [blame] | 884 | { |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 885 | return ip_in_out_acl_inline ( |
Arthur de Kerhor | 1031098 | 2021-12-22 10:58:30 +0100 | [diff] [blame] | 886 | vm, node, frame, IN_OUT_ACL_TABLE_IP6, NULL, &ip6_input_node, |
| 887 | IP6_ERROR_NONE, IP6_ERROR_INACL_SESSION_DENY, IP6_ERROR_INACL_TABLE_MISS, |
| 888 | VLIB_TX, 1 /* is_output */); |
Andrew Yourtchenko | 815d7d5 | 2018-02-07 11:37:02 +0100 | [diff] [blame] | 889 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 890 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 891 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 892 | VLIB_REGISTER_NODE (ip6_inacl_node) = { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 893 | .name = "ip6-inacl", |
| 894 | .vector_size = sizeof (u32), |
| 895 | .format_trace = format_ip_inacl_trace, |
| 896 | .n_errors = ARRAY_LEN(ip_inacl_error_strings), |
| 897 | .error_strings = ip_inacl_error_strings, |
| 898 | |
| 899 | .n_next_nodes = ACL_NEXT_INDEX_N_NEXT, |
| 900 | .next_nodes = { |
Vijayabhaskar Katamreddy | ce07412 | 2017-11-15 13:50:26 -0800 | [diff] [blame] | 901 | [ACL_NEXT_INDEX_DENY] = "ip6-drop", |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 902 | }, |
| 903 | }; |
Andrew Yourtchenko | 815d7d5 | 2018-02-07 11:37:02 +0100 | [diff] [blame] | 904 | |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 905 | VLIB_REGISTER_NODE (ip6_punt_acl_node) = { |
| 906 | .name = "ip6-punt-acl", |
| 907 | .vector_size = sizeof (u32), |
| 908 | .format_trace = format_ip_inacl_trace, |
| 909 | .n_errors = ARRAY_LEN(ip_inacl_error_strings), |
| 910 | .error_strings = ip_inacl_error_strings, |
| 911 | |
| 912 | .n_next_nodes = ACL_NEXT_INDEX_N_NEXT, |
| 913 | .next_nodes = { |
| 914 | [ACL_NEXT_INDEX_DENY] = "ip6-drop", |
| 915 | }, |
| 916 | }; |
| 917 | |
Andrew Yourtchenko | 815d7d5 | 2018-02-07 11:37:02 +0100 | [diff] [blame] | 918 | VLIB_REGISTER_NODE (ip6_outacl_node) = { |
Andrew Yourtchenko | 815d7d5 | 2018-02-07 11:37:02 +0100 | [diff] [blame] | 919 | .name = "ip6-outacl", |
| 920 | .vector_size = sizeof (u32), |
| 921 | .format_trace = format_ip_outacl_trace, |
| 922 | .n_errors = ARRAY_LEN(ip_outacl_error_strings), |
| 923 | .error_strings = ip_outacl_error_strings, |
| 924 | |
| 925 | .n_next_nodes = ACL_NEXT_INDEX_N_NEXT, |
| 926 | .next_nodes = { |
| 927 | [ACL_NEXT_INDEX_DENY] = "ip6-drop", |
| 928 | }, |
| 929 | }; |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 930 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 931 | |
Benoît Ganne | abb2a42 | 2021-09-30 13:41:00 +0200 | [diff] [blame] | 932 | VNET_FEATURE_INIT (ip6_punt_acl_feature) = { |
| 933 | .arc_name = "ip6-punt", |
| 934 | .node_name = "ip6-punt-acl", |
| 935 | .runs_after = VNET_FEATURES ("ip6-punt-policer"), |
| 936 | }; |
| 937 | |
Filip Tehlar | 26ea14e | 2019-03-11 05:30:21 -0700 | [diff] [blame] | 938 | #ifndef CLIB_MARCH_VARIANT |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 939 | static clib_error_t * |
Andrew Yourtchenko | 815d7d5 | 2018-02-07 11:37:02 +0100 | [diff] [blame] | 940 | ip_in_out_acl_init (vlib_main_t * vm) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 941 | { |
| 942 | return 0; |
| 943 | } |
| 944 | |
Andrew Yourtchenko | 815d7d5 | 2018-02-07 11:37:02 +0100 | [diff] [blame] | 945 | VLIB_INIT_FUNCTION (ip_in_out_acl_init); |
Filip Tehlar | 26ea14e | 2019-03-11 05:30:21 -0700 | [diff] [blame] | 946 | #endif /* CLIB_MARCH_VARIANT */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 947 | |
Dave Barach | d7cb1b5 | 2016-12-09 09:52:16 -0500 | [diff] [blame] | 948 | |
| 949 | /* |
| 950 | * fd.io coding-style-patch-verification: ON |
| 951 | * |
| 952 | * Local Variables: |
| 953 | * eval: (c-set-style "gnu") |
| 954 | * End: |
| 955 | */ |