Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1 | /* |
| 2 | * l2_output_acl.c : layer 2 output acl processing |
| 3 | * |
| 4 | * Copyright (c) 2013 Cisco and/or its affiliates. |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at: |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | #include <vlib/vlib.h> |
| 19 | #include <vnet/vnet.h> |
| 20 | #include <vnet/pg/pg.h> |
| 21 | #include <vnet/ethernet/ethernet.h> |
| 22 | #include <vnet/ethernet/packet.h> |
| 23 | #include <vnet/ip/ip_packet.h> |
| 24 | #include <vnet/ip/ip4_packet.h> |
| 25 | #include <vnet/ip/ip6_packet.h> |
| 26 | #include <vlib/cli.h> |
| 27 | #include <vnet/l2/feat_bitmap.h> |
| 28 | #include <vnet/l2/l2_output.h> |
| 29 | |
| 30 | #include <vppinfra/error.h> |
| 31 | #include <vppinfra/hash.h> |
| 32 | #include <vppinfra/cache.h> |
| 33 | |
| 34 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 35 | typedef struct |
| 36 | { |
| 37 | /* Next nodes for features and output interfaces */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 38 | l2_output_next_nodes_st next_nodes; |
| 39 | |
| 40 | /* convenience variables */ |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 41 | vlib_main_t *vlib_main; |
| 42 | vnet_main_t *vnet_main; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 43 | } l2_outacl_main_t; |
| 44 | |
| 45 | |
| 46 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 47 | typedef struct |
| 48 | { |
| 49 | /* per-pkt trace data */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 50 | u8 src[6]; |
| 51 | u8 dst[6]; |
| 52 | u32 next_index; |
| 53 | u32 sw_if_index; |
| 54 | } l2_outacl_trace_t; |
| 55 | |
| 56 | /* packet trace format function */ |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 57 | static u8 * |
| 58 | format_l2_outacl_trace (u8 * s, va_list * args) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 59 | { |
| 60 | CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *); |
| 61 | CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 62 | l2_outacl_trace_t *t = va_arg (*args, l2_outacl_trace_t *); |
| 63 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 64 | s = format (s, "l2-output-acl: sw_if_index %d dst %U src %U", |
| 65 | t->sw_if_index, |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 66 | format_ethernet_address, t->dst, |
| 67 | format_ethernet_address, t->src); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 68 | return s; |
| 69 | } |
| 70 | |
| 71 | l2_outacl_main_t l2_outacl_main; |
| 72 | |
| 73 | static vlib_node_registration_t l2_outacl_node; |
| 74 | |
| 75 | #define foreach_l2_outacl_error \ |
| 76 | _(L2_OUTACL, "L2 output ACL packets") \ |
| 77 | _(DROP, "L2 output drops") |
| 78 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 79 | typedef enum |
| 80 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 81 | #define _(sym,str) L2_OUTACL_ERROR_##sym, |
| 82 | foreach_l2_outacl_error |
| 83 | #undef _ |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 84 | L2_OUTACL_N_ERROR, |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 85 | } l2_outacl_error_t; |
| 86 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 87 | static char *l2_outacl_error_strings[] = { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 88 | #define _(sym,string) string, |
| 89 | foreach_l2_outacl_error |
| 90 | #undef _ |
| 91 | }; |
| 92 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 93 | typedef enum |
| 94 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 95 | L2_OUTACL_NEXT_DROP, |
| 96 | L2_OUTACL_N_NEXT, |
| 97 | } l2_outacl_next_t; |
| 98 | |
| 99 | |
| 100 | |
| 101 | static uword |
| 102 | l2_outacl_node_fn (vlib_main_t * vm, |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 103 | vlib_node_runtime_t * node, vlib_frame_t * frame) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 104 | { |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 105 | u32 n_left_from, *from, *to_next; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 106 | l2_outacl_next_t next_index; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 107 | l2_outacl_main_t *msm = &l2_outacl_main; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 108 | vlib_node_t *n = vlib_get_node (vm, l2_outacl_node.index); |
| 109 | u32 node_counter_base_index = n->error_heap_index; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 110 | vlib_error_main_t *em = &vm->error_main; |
| 111 | u32 cached_sw_if_index = (u32) ~ 0; |
| 112 | u32 cached_next_index = (u32) ~ 0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 113 | |
| 114 | from = vlib_frame_vector_args (frame); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 115 | n_left_from = frame->n_vectors; /* number of packets to process */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 116 | next_index = node->cached_next_index; |
| 117 | |
| 118 | while (n_left_from > 0) |
| 119 | { |
| 120 | u32 n_left_to_next; |
| 121 | |
| 122 | /* get space to enqueue frame to graph node "next_index" */ |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 123 | 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] | 124 | |
| 125 | while (0 && n_left_from >= 4 && n_left_to_next >= 2) |
| 126 | { |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 127 | u32 bi0, bi1; |
| 128 | vlib_buffer_t *b0, *b1; |
| 129 | u32 next0, next1; |
| 130 | u32 sw_if_index0, sw_if_index1; |
| 131 | ethernet_header_t *h0, *h1; |
| 132 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 133 | /* Prefetch next iteration. */ |
| 134 | { |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 135 | vlib_buffer_t *p2, *p3; |
| 136 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 137 | p2 = vlib_get_buffer (vm, from[2]); |
| 138 | p3 = vlib_get_buffer (vm, from[3]); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 139 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 140 | vlib_prefetch_buffer_header (p2, LOAD); |
| 141 | vlib_prefetch_buffer_header (p3, LOAD); |
| 142 | |
| 143 | CLIB_PREFETCH (p2->data, CLIB_CACHE_LINE_BYTES, STORE); |
| 144 | CLIB_PREFETCH (p3->data, CLIB_CACHE_LINE_BYTES, STORE); |
| 145 | } |
| 146 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 147 | /* speculatively enqueue b0 and b1 to the current next frame */ |
| 148 | /* bi is "buffer index", b is pointer to the buffer */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 149 | to_next[0] = bi0 = from[0]; |
| 150 | to_next[1] = bi1 = from[1]; |
| 151 | from += 2; |
| 152 | to_next += 2; |
| 153 | n_left_from -= 2; |
| 154 | n_left_to_next -= 2; |
| 155 | |
| 156 | b0 = vlib_get_buffer (vm, bi0); |
| 157 | b1 = vlib_get_buffer (vm, bi1); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 158 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 159 | /* TX interface handles */ |
| 160 | sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_TX]; |
| 161 | sw_if_index1 = vnet_buffer (b1)->sw_if_index[VLIB_TX]; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 162 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 163 | if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE))) |
| 164 | { |
| 165 | if (b0->flags & VLIB_BUFFER_IS_TRACED) |
| 166 | { |
| 167 | l2_outacl_trace_t *t = |
| 168 | vlib_add_trace (vm, node, b0, sizeof (*t)); |
| 169 | t->sw_if_index = sw_if_index0; |
| 170 | t->next_index = next0; |
| 171 | clib_memcpy (t->src, h0->src_address, 6); |
| 172 | clib_memcpy (t->dst, h0->dst_address, 6); |
| 173 | } |
| 174 | if (b1->flags & VLIB_BUFFER_IS_TRACED) |
| 175 | { |
| 176 | l2_outacl_trace_t *t = |
| 177 | vlib_add_trace (vm, node, b1, sizeof (*t)); |
| 178 | t->sw_if_index = sw_if_index1; |
| 179 | t->next_index = next1; |
| 180 | clib_memcpy (t->src, h1->src_address, 6); |
| 181 | clib_memcpy (t->dst, h1->dst_address, 6); |
| 182 | } |
| 183 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 184 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 185 | em->counters[node_counter_base_index + L2_OUTACL_ERROR_L2_OUTACL] += |
| 186 | 2; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 187 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 188 | /* add core loop code here */ |
| 189 | |
| 190 | /* verify speculative enqueues, maybe switch current next frame */ |
| 191 | /* if next0==next1==next_index then nothing special needs to be done */ |
| 192 | vlib_validate_buffer_enqueue_x2 (vm, node, next_index, |
| 193 | to_next, n_left_to_next, |
| 194 | bi0, bi1, next0, next1); |
| 195 | } |
| 196 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 197 | while (n_left_from > 0 && n_left_to_next > 0) |
| 198 | { |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 199 | u32 bi0; |
| 200 | vlib_buffer_t *b0; |
| 201 | u32 next0; |
| 202 | u32 sw_if_index0; |
| 203 | ethernet_header_t *h0; |
| 204 | u32 feature_bitmap0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 205 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 206 | /* speculatively enqueue b0 to the current next frame */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 207 | bi0 = from[0]; |
| 208 | to_next[0] = bi0; |
| 209 | from += 1; |
| 210 | to_next += 1; |
| 211 | n_left_from -= 1; |
| 212 | n_left_to_next -= 1; |
| 213 | |
| 214 | b0 = vlib_get_buffer (vm, bi0); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 215 | h0 = vlib_buffer_get_current (b0); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 216 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 217 | sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_TX]; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 218 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 219 | if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) |
| 220 | && (b0->flags & VLIB_BUFFER_IS_TRACED))) |
| 221 | { |
| 222 | l2_outacl_trace_t *t = |
| 223 | vlib_add_trace (vm, node, b0, sizeof (*t)); |
| 224 | t->sw_if_index = sw_if_index0; |
| 225 | clib_memcpy (t->src, h0->src_address, 6); |
| 226 | clib_memcpy (t->dst, h0->dst_address, 6); |
| 227 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 228 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 229 | em->counters[node_counter_base_index + L2_OUTACL_ERROR_L2_OUTACL] += |
| 230 | 1; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 231 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 232 | /* |
| 233 | * L2_OUTACL code |
| 234 | * Dummy for now, just go to next feature node |
| 235 | */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 236 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 237 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 238 | /* Remove ourself from the feature bitmap */ |
| 239 | feature_bitmap0 = |
| 240 | vnet_buffer (b0)->l2.feature_bitmap & ~L2OUTPUT_FEAT_ACL; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 241 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 242 | /* Determine next node */ |
| 243 | l2_output_dispatch (msm->vlib_main, |
| 244 | msm->vnet_main, |
| 245 | node, |
| 246 | l2_outacl_node.index, |
| 247 | &cached_sw_if_index, |
| 248 | &cached_next_index, |
| 249 | &msm->next_nodes, |
| 250 | b0, sw_if_index0, feature_bitmap0, &next0); |
| 251 | |
| 252 | /* verify speculative enqueue, maybe switch current next frame */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 253 | vlib_validate_buffer_enqueue_x1 (vm, node, next_index, |
| 254 | to_next, n_left_to_next, |
| 255 | bi0, next0); |
| 256 | } |
| 257 | |
| 258 | vlib_put_next_frame (vm, node, next_index, n_left_to_next); |
| 259 | } |
| 260 | |
| 261 | return frame->n_vectors; |
| 262 | } |
| 263 | |
| 264 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 265 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 266 | VLIB_REGISTER_NODE (l2_outacl_node,static) = { |
| 267 | .function = l2_outacl_node_fn, |
| 268 | .name = "l2-output-acl", |
| 269 | .vector_size = sizeof (u32), |
| 270 | .format_trace = format_l2_outacl_trace, |
| 271 | .type = VLIB_NODE_TYPE_INTERNAL, |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 272 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 273 | .n_errors = ARRAY_LEN(l2_outacl_error_strings), |
| 274 | .error_strings = l2_outacl_error_strings, |
| 275 | |
| 276 | .n_next_nodes = L2_OUTACL_N_NEXT, |
| 277 | |
| 278 | /* edit / add dispositions here */ |
| 279 | .next_nodes = { |
| 280 | [L2_OUTACL_NEXT_DROP] = "error-drop", |
| 281 | }, |
| 282 | }; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 283 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 284 | |
Damjan Marion | 1c80e83 | 2016-05-11 23:07:18 +0200 | [diff] [blame] | 285 | VLIB_NODE_FUNCTION_MULTIARCH (l2_outacl_node, l2_outacl_node_fn) |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 286 | clib_error_t *l2_outacl_init (vlib_main_t * vm) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 287 | { |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 288 | l2_outacl_main_t *mp = &l2_outacl_main; |
| 289 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 290 | mp->vlib_main = vm; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 291 | mp->vnet_main = vnet_get_main (); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 292 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 293 | /* Initialize the feature next-node indexes */ |
| 294 | feat_bitmap_init_next_nodes (vm, |
| 295 | l2_outacl_node.index, |
| 296 | L2OUTPUT_N_FEAT, |
| 297 | l2output_get_feat_names (), |
| 298 | mp->next_nodes.feat_next_node_index); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 299 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 300 | /* Initialize the output node mapping table */ |
| 301 | l2output_init_output_node_vec (&mp->next_nodes.output_node_index_vec); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 302 | |
| 303 | return 0; |
| 304 | } |
| 305 | |
| 306 | VLIB_INIT_FUNCTION (l2_outacl_init); |
| 307 | |
John Lo | bbb7682 | 2016-06-08 16:08:48 -0400 | [diff] [blame] | 308 | #if 0 |
Chris Luke | 16bcf7d | 2016-09-01 14:31:46 -0400 | [diff] [blame] | 309 | /** @todo maybe someone will add output ACL's in the future. |
| 310 | * Set subinterface outacl enable/disable. |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 311 | * The CLI format is: |
| 312 | * set interface acl output <interface> [disable] |
| 313 | */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 314 | static clib_error_t * |
| 315 | int_l2_outacl (vlib_main_t * vm, |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 316 | unformat_input_t * input, vlib_cli_command_t * cmd) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 317 | { |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 318 | vnet_main_t *vnm = vnet_get_main (); |
| 319 | clib_error_t *error = 0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 320 | u32 sw_if_index; |
| 321 | u32 enable; |
| 322 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 323 | if (!unformat_user (input, unformat_vnet_sw_interface, vnm, &sw_if_index)) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 324 | { |
| 325 | error = clib_error_return (0, "unknown interface `%U'", |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 326 | format_unformat_error, input); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 327 | goto done; |
| 328 | } |
| 329 | |
| 330 | enable = 1; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 331 | if (unformat (input, "disable")) |
| 332 | { |
| 333 | enable = 0; |
| 334 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 335 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 336 | /* set the interface flag */ |
| 337 | l2output_intf_bitmap_enable (sw_if_index, L2OUTPUT_FEAT_ACL, enable); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 338 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 339 | done: |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 340 | return error; |
| 341 | } |
| 342 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 343 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 344 | VLIB_CLI_COMMAND (int_l2_outacl_cli, static) = { |
| 345 | .path = "set interface acl output", |
| 346 | .short_help = "set interface acl output <interface> [disable]", |
| 347 | .function = int_l2_outacl, |
| 348 | }; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 349 | /* *INDENT-ON* */ |
John Lo | bbb7682 | 2016-06-08 16:08:48 -0400 | [diff] [blame] | 350 | #endif |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 351 | |
| 352 | /* |
| 353 | * fd.io coding-style-patch-verification: ON |
| 354 | * |
| 355 | * Local Variables: |
| 356 | * eval: (c-set-style "gnu") |
| 357 | * End: |
| 358 | */ |