blob: 3198d323d60626708bb67582ec525cf6b318848a [file] [log] [blame]
Ed Warnickecb9cada2015-12-08 15:45:58 -07001/*
Dave Barach97d8dc22016-08-15 15:31:15 -04002 * l2_flood.c : layer 2 flooding
Ed Warnickecb9cada2015-12-08 15:45:58 -07003 *
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 <vlib/cli.h>
23#include <vnet/l2/l2_input.h>
24#include <vnet/l2/feat_bitmap.h>
25#include <vnet/l2/l2_bvi.h>
Ed Warnickecb9cada2015-12-08 15:45:58 -070026#include <vnet/l2/l2_fib.h>
27
28#include <vppinfra/error.h>
29#include <vppinfra/hash.h>
30
31
Billy McFall22aa3e92016-09-09 08:46:40 -040032/**
33 * @file
34 * @brief Ethernet Flooding.
35 *
Ed Warnickecb9cada2015-12-08 15:45:58 -070036 * Flooding uses the packet replication infrastructure to send a copy of the
37 * packet to each member interface. Logically the replication infrastructure
38 * expects two graph nodes: a prep node that initiates replication and sends the
39 * packet to the first destination, and a recycle node that is passed the packet
40 * after it has been transmitted.
41 *
42 * To decrease the amount of code, l2 flooding implements both functions in
43 * the same graph node. This node can tell if is it being called as the "prep"
44 * or "recycle" using replication_is_recycled().
45 */
46
47
Dave Barach97d8dc22016-08-15 15:31:15 -040048typedef struct
49{
Ed Warnickecb9cada2015-12-08 15:45:58 -070050
Dave Barach97d8dc22016-08-15 15:31:15 -040051 /* Next nodes for each feature */
Ed Warnickecb9cada2015-12-08 15:45:58 -070052 u32 feat_next_node_index[32];
Dave Barach97d8dc22016-08-15 15:31:15 -040053
54 /* next node index for the L3 input node of each ethertype */
Ed Warnickecb9cada2015-12-08 15:45:58 -070055 next_by_ethertype_t l3_next;
56
57 /* convenience variables */
Dave Barach97d8dc22016-08-15 15:31:15 -040058 vlib_main_t *vlib_main;
59 vnet_main_t *vnet_main;
Neale Ranns055b2312018-07-20 01:16:04 -070060
61 /* per-cpu vector of cloned packets */
62 u32 **clones;
63 l2_flood_member_t ***members;
Ed Warnickecb9cada2015-12-08 15:45:58 -070064} l2flood_main_t;
65
Dave Barach97d8dc22016-08-15 15:31:15 -040066typedef struct
67{
Ed Warnickecb9cada2015-12-08 15:45:58 -070068 u8 src[6];
69 u8 dst[6];
70 u32 sw_if_index;
71 u16 bd_index;
72} l2flood_trace_t;
73
74
75/* packet trace format function */
Dave Barach97d8dc22016-08-15 15:31:15 -040076static u8 *
77format_l2flood_trace (u8 * s, va_list * args)
Ed Warnickecb9cada2015-12-08 15:45:58 -070078{
79 CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
80 CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
Dave Barach97d8dc22016-08-15 15:31:15 -040081 l2flood_trace_t *t = va_arg (*args, l2flood_trace_t *);
82
Ed Warnickecb9cada2015-12-08 15:45:58 -070083 s = format (s, "l2-flood: sw_if_index %d dst %U src %U bd_index %d",
Dave Barach97d8dc22016-08-15 15:31:15 -040084 t->sw_if_index,
85 format_ethernet_address, t->dst,
86 format_ethernet_address, t->src, t->bd_index);
Ed Warnickecb9cada2015-12-08 15:45:58 -070087 return s;
88}
89
90l2flood_main_t l2flood_main;
91
92static vlib_node_registration_t l2flood_node;
93
94#define foreach_l2flood_error \
95_(L2FLOOD, "L2 flood packets") \
96_(REPL_FAIL, "L2 replication failures") \
97_(NO_MEMBERS, "L2 replication complete") \
John Lo7185c3b2016-06-04 00:02:37 -040098_(BVI_BAD_MAC, "BVI L3 mac mismatch") \
Ed Warnickecb9cada2015-12-08 15:45:58 -070099_(BVI_ETHERTYPE, "BVI packet with unhandled ethertype")
100
Dave Barach97d8dc22016-08-15 15:31:15 -0400101typedef enum
102{
Ed Warnickecb9cada2015-12-08 15:45:58 -0700103#define _(sym,str) L2FLOOD_ERROR_##sym,
104 foreach_l2flood_error
105#undef _
Dave Barach97d8dc22016-08-15 15:31:15 -0400106 L2FLOOD_N_ERROR,
Ed Warnickecb9cada2015-12-08 15:45:58 -0700107} l2flood_error_t;
108
Dave Barach97d8dc22016-08-15 15:31:15 -0400109static char *l2flood_error_strings[] = {
Ed Warnickecb9cada2015-12-08 15:45:58 -0700110#define _(sym,string) string,
111 foreach_l2flood_error
112#undef _
113};
114
Dave Barach97d8dc22016-08-15 15:31:15 -0400115typedef enum
116{
Ed Warnickecb9cada2015-12-08 15:45:58 -0700117 L2FLOOD_NEXT_L2_OUTPUT,
118 L2FLOOD_NEXT_DROP,
119 L2FLOOD_N_NEXT,
120} l2flood_next_t;
121
122/*
123 * Perform flooding on one packet
124 *
125 * Due to the way BVI processing can modify the packet, the BVI interface
126 * (if present) must be processed last in the replication. The member vector
Dave Barach97d8dc22016-08-15 15:31:15 -0400127 * is arranged so that the BVI interface is always the first element.
Ed Warnickecb9cada2015-12-08 15:45:58 -0700128 * Flooding walks the vector in reverse.
129 *
130 * BVI processing causes the packet to go to L3 processing. This strips the
131 * L2 header, which is fine because the replication infrastructure restores
132 * it. However L3 processing can trigger larger changes to the packet. For
133 * example, an ARP request could be turned into an ARP reply, an ICMP request
Dave Barach97d8dc22016-08-15 15:31:15 -0400134 * could be turned into an ICMP reply. If BVI processing is not performed
135 * last, the modified packet would be replicated to the remaining members.
Ed Warnickecb9cada2015-12-08 15:45:58 -0700136 */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700137static uword
138l2flood_node_fn (vlib_main_t * vm,
Dave Barach97d8dc22016-08-15 15:31:15 -0400139 vlib_node_runtime_t * node, vlib_frame_t * frame)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700140{
Dave Barach97d8dc22016-08-15 15:31:15 -0400141 u32 n_left_from, *from, *to_next;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700142 l2flood_next_t next_index;
Dave Barach97d8dc22016-08-15 15:31:15 -0400143 l2flood_main_t *msm = &l2flood_main;
Neale Ranns055b2312018-07-20 01:16:04 -0700144 u32 thread_index = vm->thread_index;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700145
146 from = vlib_frame_vector_args (frame);
Neale Ranns055b2312018-07-20 01:16:04 -0700147 n_left_from = frame->n_vectors;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700148 next_index = node->cached_next_index;
Dave Barach97d8dc22016-08-15 15:31:15 -0400149
Ed Warnickecb9cada2015-12-08 15:45:58 -0700150 while (n_left_from > 0)
151 {
152 u32 n_left_to_next;
153
Dave Barach97d8dc22016-08-15 15:31:15 -0400154 vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700155
Ed Warnickecb9cada2015-12-08 15:45:58 -0700156 while (n_left_from > 0 && n_left_to_next > 0)
157 {
Neale Ranns055b2312018-07-20 01:16:04 -0700158 u16 n_clones, n_cloned, clone0;
159 l2_bridge_domain_t *bd_config;
Neale Rannsc25eb452018-09-12 06:53:03 -0400160 u32 sw_if_index0, bi0, ci0;
Neale Ranns055b2312018-07-20 01:16:04 -0700161 l2_flood_member_t *member;
162 vlib_buffer_t *b0, *c0;
Neale Rannsc25eb452018-09-12 06:53:03 -0400163 u16 next0;
Neale Ranns055b2312018-07-20 01:16:04 -0700164 u8 in_shg;
165 i32 mi;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700166
Dave Barach97d8dc22016-08-15 15:31:15 -0400167 /* speculatively enqueue b0 to the current next frame */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700168 bi0 = from[0];
Ed Warnickecb9cada2015-12-08 15:45:58 -0700169 from += 1;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700170 n_left_from -= 1;
John Lofe80c492018-08-09 11:03:21 -0400171 next0 = L2FLOOD_NEXT_L2_OUTPUT;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700172
173 b0 = vlib_get_buffer (vm, bi0);
174
Neale Ranns055b2312018-07-20 01:16:04 -0700175 /* Get config for the bridge domain interface */
176 bd_config = vec_elt_at_index (l2input_main.bd_configs,
177 vnet_buffer (b0)->l2.bd_index);
178 in_shg = vnet_buffer (b0)->l2.shg;
Dave Barach97d8dc22016-08-15 15:31:15 -0400179 sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
Ed Warnickecb9cada2015-12-08 15:45:58 -0700180
Neale Ranns055b2312018-07-20 01:16:04 -0700181 vec_validate (msm->members[thread_index],
182 vec_len (bd_config->members));
Ed Warnickecb9cada2015-12-08 15:45:58 -0700183
Neale Ranns055b2312018-07-20 01:16:04 -0700184 vec_reset_length (msm->members[thread_index]);
185
186 /* Find first members that passes the reflection and SHG checks */
187 for (mi = bd_config->flood_count - 1; mi >= 0; mi--)
188 {
189 member = &bd_config->members[mi];
190 if ((member->sw_if_index != sw_if_index0) &&
191 (!in_shg || (member->shg != in_shg)))
192 {
193 vec_add1 (msm->members[thread_index], member);
194 }
195 }
196
197 n_clones = vec_len (msm->members[thread_index]);
198
199 if (0 == n_clones)
200 {
201 /* No members to flood to */
202 to_next[0] = bi0;
203 to_next += 1;
204 n_left_to_next -= 1;
205
206 b0->error = node->errors[L2FLOOD_ERROR_NO_MEMBERS];
207 vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
208 to_next, n_left_to_next,
209 bi0, L2FLOOD_NEXT_DROP);
210 continue;
211 }
Neale Rannsb9fa29d2018-10-02 07:27:02 -0700212 else if (n_clones > 1)
Neale Ranns055b2312018-07-20 01:16:04 -0700213 {
Neale Rannsb9fa29d2018-10-02 07:27:02 -0700214 vec_validate (msm->clones[thread_index], n_clones);
215 vec_reset_length (msm->clones[thread_index]);
Neale Ranns055b2312018-07-20 01:16:04 -0700216
Neale Rannsb9fa29d2018-10-02 07:27:02 -0700217 /*
218 * the header offset needs to be large enough to incorporate
219 * all the L3 headers that could be touched when doing BVI
220 * processing. So take the current l2 length plus 2 * IPv6
221 * headers (for tunnel encap)
222 */
223 n_cloned = vlib_buffer_clone (vm, bi0,
224 msm->clones[thread_index],
225 n_clones,
Damjan Marionbd0da972018-10-31 10:59:02 +0100226 VLIB_BUFFER_CLONE_HEAD_SIZE);
Neale Rannsb9fa29d2018-10-02 07:27:02 -0700227
228 if (PREDICT_FALSE (n_cloned != n_clones))
229 {
230 b0->error = node->errors[L2FLOOD_ERROR_REPL_FAIL];
231 }
232
233 /*
234 * for all but the last clone, these are not BVI bound
235 */
236 for (clone0 = 0; clone0 < n_cloned - 1; clone0++)
237 {
238 member = msm->members[thread_index][clone0];
239 ci0 = msm->clones[thread_index][clone0];
240 c0 = vlib_get_buffer (vm, ci0);
241
242 to_next[0] = ci0;
243 to_next += 1;
244 n_left_to_next -= 1;
245
246 if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) &&
247 (b0->flags & VLIB_BUFFER_IS_TRACED)))
248 {
249 ethernet_header_t *h0;
250 l2flood_trace_t *t;
251
252 if (c0 != b0)
253 vlib_buffer_copy_trace_flag (vm, b0, ci0);
254
255 t = vlib_add_trace (vm, node, c0, sizeof (*t));
256 h0 = vlib_buffer_get_current (c0);
257 t->sw_if_index = sw_if_index0;
258 t->bd_index = vnet_buffer (c0)->l2.bd_index;
Dave Barach178cf492018-11-13 16:34:13 -0500259 clib_memcpy_fast (t->src, h0->src_address, 6);
260 clib_memcpy_fast (t->dst, h0->dst_address, 6);
Neale Rannsb9fa29d2018-10-02 07:27:02 -0700261 }
262
263 /* Do normal L2 forwarding */
264 vnet_buffer (c0)->sw_if_index[VLIB_TX] =
265 member->sw_if_index;
266
267 vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
268 to_next, n_left_to_next,
269 ci0, next0);
270 if (PREDICT_FALSE (0 == n_left_to_next))
271 {
272 vlib_put_next_frame (vm, node, next_index,
273 n_left_to_next);
274 vlib_get_next_frame (vm, node, next_index, to_next,
275 n_left_to_next);
276 }
277 }
Neale Ranns055b2312018-07-20 01:16:04 -0700278 member = msm->members[thread_index][clone0];
279 ci0 = msm->clones[thread_index][clone0];
Neale Rannsb9fa29d2018-10-02 07:27:02 -0700280 }
281 else
282 {
283 /* one clone */
284 ci0 = bi0;
285 member = msm->members[thread_index][0];
Neale Ranns055b2312018-07-20 01:16:04 -0700286 }
287
288 /*
289 * the last clone that might go to a BVI
290 */
Neale Ranns055b2312018-07-20 01:16:04 -0700291 c0 = vlib_get_buffer (vm, ci0);
292
293 to_next[0] = ci0;
294 to_next += 1;
295 n_left_to_next -= 1;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700296
Dave Barach97d8dc22016-08-15 15:31:15 -0400297 if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE) &&
298 (b0->flags & VLIB_BUFFER_IS_TRACED)))
299 {
Neale Ranns055b2312018-07-20 01:16:04 -0700300 ethernet_header_t *h0;
301 l2flood_trace_t *t;
302
303 if (c0 != b0)
304 vlib_buffer_copy_trace_flag (vm, b0, ci0);
305
306 t = vlib_add_trace (vm, node, c0, sizeof (*t));
307 h0 = vlib_buffer_get_current (c0);
Dave Barach97d8dc22016-08-15 15:31:15 -0400308 t->sw_if_index = sw_if_index0;
Neale Ranns055b2312018-07-20 01:16:04 -0700309 t->bd_index = vnet_buffer (c0)->l2.bd_index;
Dave Barach178cf492018-11-13 16:34:13 -0500310 clib_memcpy_fast (t->src, h0->src_address, 6);
311 clib_memcpy_fast (t->dst, h0->dst_address, 6);
Dave Barach97d8dc22016-08-15 15:31:15 -0400312 }
313
Neale Ranns055b2312018-07-20 01:16:04 -0700314
315 /* Forward packet to the current member */
316 if (PREDICT_FALSE (member->flags & L2_FLOOD_MEMBER_BVI))
317 {
318 /* Do BVI processing */
319 u32 rc;
320 rc = l2_to_bvi (vm,
321 msm->vnet_main,
322 c0, member->sw_if_index, &msm->l3_next, &next0);
323
John Lofe80c492018-08-09 11:03:21 -0400324 if (PREDICT_FALSE (rc != TO_BVI_ERR_OK))
Neale Ranns055b2312018-07-20 01:16:04 -0700325 {
326 if (rc == TO_BVI_ERR_BAD_MAC)
327 {
328 c0->error = node->errors[L2FLOOD_ERROR_BVI_BAD_MAC];
329 }
330 else if (rc == TO_BVI_ERR_ETHERTYPE)
331 {
332 c0->error = node->errors[L2FLOOD_ERROR_BVI_ETHERTYPE];
333 }
John Lofe80c492018-08-09 11:03:21 -0400334 next0 = L2FLOOD_NEXT_DROP;
Neale Ranns055b2312018-07-20 01:16:04 -0700335 }
336 }
337 else
338 {
339 /* Do normal L2 forwarding */
340 vnet_buffer (c0)->sw_if_index[VLIB_TX] = member->sw_if_index;
Neale Ranns055b2312018-07-20 01:16:04 -0700341 }
342
Ed Warnickecb9cada2015-12-08 15:45:58 -0700343 vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
344 to_next, n_left_to_next,
Neale Ranns055b2312018-07-20 01:16:04 -0700345 ci0, next0);
346 if (PREDICT_FALSE (0 == n_left_to_next))
347 {
348 vlib_put_next_frame (vm, node, next_index, n_left_to_next);
349 vlib_get_next_frame (vm, node, next_index,
350 to_next, n_left_to_next);
351 }
Ed Warnickecb9cada2015-12-08 15:45:58 -0700352 }
353
354 vlib_put_next_frame (vm, node, next_index, n_left_to_next);
355 }
356
Neale Ranns055b2312018-07-20 01:16:04 -0700357 vlib_node_increment_counter (vm, node->node_index,
358 L2FLOOD_ERROR_L2FLOOD, frame->n_vectors);
359
Ed Warnickecb9cada2015-12-08 15:45:58 -0700360 return frame->n_vectors;
361}
362
363
Dave Barach97d8dc22016-08-15 15:31:15 -0400364/* *INDENT-OFF* */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700365VLIB_REGISTER_NODE (l2flood_node,static) = {
366 .function = l2flood_node_fn,
367 .name = "l2-flood",
368 .vector_size = sizeof (u32),
369 .format_trace = format_l2flood_trace,
370 .type = VLIB_NODE_TYPE_INTERNAL,
Dave Barach97d8dc22016-08-15 15:31:15 -0400371
Ed Warnickecb9cada2015-12-08 15:45:58 -0700372 .n_errors = ARRAY_LEN(l2flood_error_strings),
373 .error_strings = l2flood_error_strings,
374
375 .n_next_nodes = L2FLOOD_N_NEXT,
376
377 /* edit / add dispositions here */
378 .next_nodes = {
379 [L2FLOOD_NEXT_L2_OUTPUT] = "l2-output",
380 [L2FLOOD_NEXT_DROP] = "error-drop",
381 },
382};
383
Damjan Marion1c80e832016-05-11 23:07:18 +0200384VLIB_NODE_FUNCTION_MULTIARCH (l2flood_node, l2flood_node_fn)
Neale Rannsb4743802018-09-05 09:13:57 -0700385/* *INDENT-ON* */
386
387clib_error_t *
388l2flood_init (vlib_main_t * vm)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700389{
Dave Barach97d8dc22016-08-15 15:31:15 -0400390 l2flood_main_t *mp = &l2flood_main;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700391
Dave Barach97d8dc22016-08-15 15:31:15 -0400392 mp->vlib_main = vm;
393 mp->vnet_main = vnet_get_main ();
394
Neale Ranns055b2312018-07-20 01:16:04 -0700395 vec_validate (mp->clones, vlib_num_workers ());
396 vec_validate (mp->members, vlib_num_workers ());
397
Dave Barach97d8dc22016-08-15 15:31:15 -0400398 /* Initialize the feature next-node indexes */
399 feat_bitmap_init_next_nodes (vm,
400 l2flood_node.index,
401 L2INPUT_N_FEAT,
402 l2input_get_feat_names (),
403 mp->feat_next_node_index);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700404
Neale Ranns055b2312018-07-20 01:16:04 -0700405 return NULL;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700406}
407
408VLIB_INIT_FUNCTION (l2flood_init);
409
410
411
Chris Luke16bcf7d2016-09-01 14:31:46 -0400412/** Add the L3 input node for this ethertype to the next nodes structure. */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700413void
414l2flood_register_input_type (vlib_main_t * vm,
Dave Barach97d8dc22016-08-15 15:31:15 -0400415 ethernet_type_t type, u32 node_index)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700416{
Dave Barach97d8dc22016-08-15 15:31:15 -0400417 l2flood_main_t *mp = &l2flood_main;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700418 u32 next_index;
419
Dave Barach97d8dc22016-08-15 15:31:15 -0400420 next_index = vlib_node_add_next (vm, l2flood_node.index, node_index);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700421
422 next_by_ethertype_register (&mp->l3_next, type, next_index);
423}
424
425
Dave Barach97d8dc22016-08-15 15:31:15 -0400426/**
Chris Luke16bcf7d2016-09-01 14:31:46 -0400427 * Set subinterface flood enable/disable.
Dave Barach97d8dc22016-08-15 15:31:15 -0400428 * The CLI format is:
429 * set interface l2 flood <interface> [disable]
430 */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700431static clib_error_t *
432int_flood (vlib_main_t * vm,
Dave Barach97d8dc22016-08-15 15:31:15 -0400433 unformat_input_t * input, vlib_cli_command_t * cmd)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700434{
Dave Barach97d8dc22016-08-15 15:31:15 -0400435 vnet_main_t *vnm = vnet_get_main ();
436 clib_error_t *error = 0;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700437 u32 sw_if_index;
438 u32 enable;
439
Dave Barach97d8dc22016-08-15 15:31:15 -0400440 if (!unformat_user (input, unformat_vnet_sw_interface, vnm, &sw_if_index))
Ed Warnickecb9cada2015-12-08 15:45:58 -0700441 {
442 error = clib_error_return (0, "unknown interface `%U'",
Dave Barach97d8dc22016-08-15 15:31:15 -0400443 format_unformat_error, input);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700444 goto done;
445 }
446
447 enable = 1;
Dave Barach97d8dc22016-08-15 15:31:15 -0400448 if (unformat (input, "disable"))
449 {
450 enable = 0;
451 }
Ed Warnickecb9cada2015-12-08 15:45:58 -0700452
Dave Barach97d8dc22016-08-15 15:31:15 -0400453 /* set the interface flag */
454 l2input_intf_bitmap_enable (sw_if_index, L2INPUT_FEAT_FLOOD, enable);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700455
Dave Barach97d8dc22016-08-15 15:31:15 -0400456done:
Ed Warnickecb9cada2015-12-08 15:45:58 -0700457 return error;
458}
459
Billy McFall22aa3e92016-09-09 08:46:40 -0400460/*?
461 * Layer 2 flooding can be enabled and disabled on each
462 * interface and on each bridge-domain. Use this command to
463 * manage interfaces. It is enabled by default.
464 *
465 * @cliexpar
466 * Example of how to enable flooding:
467 * @cliexcmd{set interface l2 flood GigabitEthernet0/8/0}
468 * Example of how to disable flooding:
469 * @cliexcmd{set interface l2 flood GigabitEthernet0/8/0 disable}
470?*/
Dave Barach97d8dc22016-08-15 15:31:15 -0400471/* *INDENT-OFF* */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700472VLIB_CLI_COMMAND (int_flood_cli, static) = {
473 .path = "set interface l2 flood",
474 .short_help = "set interface l2 flood <interface> [disable]",
475 .function = int_flood,
476};
Dave Barach97d8dc22016-08-15 15:31:15 -0400477/* *INDENT-ON* */
478
479/*
480 * fd.io coding-style-patch-verification: ON
481 *
482 * Local Variables:
483 * eval: (c-set-style "gnu")
484 * End:
485 */