Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1 | /* |
| 2 | * l2_bd.c : layer 2 bridge domain |
| 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 <vlib/cli.h> |
| 21 | #include <vnet/ethernet/ethernet.h> |
| 22 | #include <vnet/ip/format.h> |
| 23 | #include <vnet/l2/l2_input.h> |
| 24 | #include <vnet/l2/feat_bitmap.h> |
| 25 | #include <vnet/l2/l2_bd.h> |
Damjan Marion | d171d48 | 2016-12-05 14:16:38 +0100 | [diff] [blame] | 26 | #include <vnet/l2/l2_learn.h> |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 27 | #include <vnet/l2/l2_fib.h> |
| 28 | #include <vnet/l2/l2_vtr.h> |
| 29 | #include <vnet/ip/ip4_packet.h> |
| 30 | #include <vnet/ip/ip6_packet.h> |
| 31 | |
| 32 | #include <vppinfra/error.h> |
| 33 | #include <vppinfra/hash.h> |
| 34 | #include <vppinfra/vec.h> |
| 35 | |
Billy McFall | 22aa3e9 | 2016-09-09 08:46:40 -0400 | [diff] [blame] | 36 | /** |
| 37 | * @file |
| 38 | * @brief Ethernet Bridge Domain. |
| 39 | * |
| 40 | * Code in this file manages Layer 2 bridge domains. |
| 41 | * |
| 42 | */ |
| 43 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 44 | bd_main_t bd_main; |
| 45 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 46 | /** |
Chris Luke | 16bcf7d | 2016-09-01 14:31:46 -0400 | [diff] [blame] | 47 | Init bridge domain if not done already. |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 48 | For feature bitmap, set all bits except ARP termination |
| 49 | */ |
Damjan Marion | 99d8c76 | 2015-12-14 15:01:56 +0100 | [diff] [blame] | 50 | void |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 51 | bd_validate (l2_bridge_domain_t * bd_config) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 52 | { |
Eyal Bari | b1352ed | 2017-04-07 23:14:17 +0300 | [diff] [blame] | 53 | if (bd_is_valid (bd_config)) |
| 54 | return; |
| 55 | bd_config->feature_bitmap = ~L2INPUT_FEAT_ARP_TERM; |
| 56 | bd_config->bvi_sw_if_index = ~0; |
| 57 | bd_config->members = 0; |
| 58 | bd_config->flood_count = 0; |
| 59 | bd_config->tun_master_count = 0; |
| 60 | bd_config->tun_normal_count = 0; |
| 61 | bd_config->mac_by_ip4 = 0; |
| 62 | bd_config->mac_by_ip6 = hash_create_mem (0, sizeof (ip6_address_t), |
| 63 | sizeof (uword)); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 64 | } |
| 65 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 66 | u32 |
Eyal Bari | b1352ed | 2017-04-07 23:14:17 +0300 | [diff] [blame] | 67 | bd_find_index (bd_main_t * bdm, u32 bd_id) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 68 | { |
Eyal Bari | b1352ed | 2017-04-07 23:14:17 +0300 | [diff] [blame] | 69 | u32 *p = (u32 *) hash_get (bdm->bd_index_by_bd_id, bd_id); |
| 70 | if (!p) |
| 71 | return ~0; |
| 72 | return p[0]; |
| 73 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 74 | |
Eyal Bari | b1352ed | 2017-04-07 23:14:17 +0300 | [diff] [blame] | 75 | u32 |
| 76 | bd_add_bd_index (bd_main_t * bdm, u32 bd_id) |
| 77 | { |
| 78 | ASSERT (!hash_get (bdm->bd_index_by_bd_id, bd_id)); |
| 79 | u32 rv = clib_bitmap_first_clear (bdm->bd_index_bitmap); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 80 | |
Eyal Bari | b1352ed | 2017-04-07 23:14:17 +0300 | [diff] [blame] | 81 | /* mark this index taken */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 82 | bdm->bd_index_bitmap = clib_bitmap_set (bdm->bd_index_bitmap, rv, 1); |
| 83 | |
| 84 | hash_set (bdm->bd_index_by_bd_id, bd_id, rv); |
| 85 | |
| 86 | vec_validate (l2input_main.bd_configs, rv); |
| 87 | l2input_main.bd_configs[rv].bd_id = bd_id; |
| 88 | |
| 89 | return rv; |
| 90 | } |
| 91 | |
Eyal Bari | b1352ed | 2017-04-07 23:14:17 +0300 | [diff] [blame] | 92 | static int |
| 93 | bd_delete (bd_main_t * bdm, u32 bd_index) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 94 | { |
John Lo | d77630a | 2017-04-28 00:33:36 -0400 | [diff] [blame] | 95 | l2_bridge_domain_t *bd = &l2input_main.bd_configs[bd_index]; |
| 96 | u32 bd_id = bd->bd_id; |
Eyal Bari | b1352ed | 2017-04-07 23:14:17 +0300 | [diff] [blame] | 97 | hash_unset (bdm->bd_index_by_bd_id, bd_id); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 98 | |
| 99 | /* mark this index clear */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 100 | bdm->bd_index_bitmap = clib_bitmap_set (bdm->bd_index_bitmap, bd_index, 0); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 101 | |
John Lo | d77630a | 2017-04-28 00:33:36 -0400 | [diff] [blame] | 102 | /* clear BD config for reuse: bd_id to -1 and clear feature_bitmap */ |
| 103 | bd->bd_id = ~0; |
| 104 | bd->feature_bitmap = 0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 105 | |
John Lo | d77630a | 2017-04-28 00:33:36 -0400 | [diff] [blame] | 106 | /* free memory used by BD and flush non-static MACs in BD */ |
| 107 | vec_free (bd->members); |
| 108 | hash_free (bd->mac_by_ip4); |
| 109 | hash_free (bd->mac_by_ip6); |
John Lo | da1f2c7 | 2017-03-24 20:11:15 -0400 | [diff] [blame] | 110 | l2fib_flush_bd_mac (vlib_get_main (), bd_index); |
| 111 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 112 | return 0; |
| 113 | } |
| 114 | |
Eyal Bari | c5b1360 | 2016-11-24 19:42:43 +0200 | [diff] [blame] | 115 | static void |
| 116 | update_flood_count (l2_bridge_domain_t * bd_config) |
| 117 | { |
| 118 | bd_config->flood_count = vec_len (bd_config->members) - |
| 119 | (bd_config->tun_master_count ? bd_config->tun_normal_count : 0); |
| 120 | } |
| 121 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 122 | void |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 123 | bd_add_member (l2_bridge_domain_t * bd_config, l2_flood_member_t * member) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 124 | { |
Eyal Bari | c5b1360 | 2016-11-24 19:42:43 +0200 | [diff] [blame] | 125 | u32 ix; |
| 126 | vnet_sw_interface_t *sw_if = vnet_get_sw_interface |
| 127 | (vnet_get_main (), member->sw_if_index); |
| 128 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 129 | /* |
| 130 | * Add one element to the vector |
Eyal Bari | c5b1360 | 2016-11-24 19:42:43 +0200 | [diff] [blame] | 131 | * vector is ordered [ bvi, normal/tun_masters..., tun_normals... ] |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 132 | * When flooding, the bvi interface (if present) must be the last member |
| 133 | * processed due to how BVI processing can change the packet. To enable |
| 134 | * this order, we make the bvi interface the first in the vector and |
| 135 | * flooding walks the vector in reverse. |
| 136 | */ |
Eyal Bari | c5b1360 | 2016-11-24 19:42:43 +0200 | [diff] [blame] | 137 | switch (sw_if->flood_class) |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 138 | { |
Eyal Bari | c5b1360 | 2016-11-24 19:42:43 +0200 | [diff] [blame] | 139 | case VNET_FLOOD_CLASS_TUNNEL_MASTER: |
| 140 | bd_config->tun_master_count++; |
| 141 | /* Fall through */ |
| 142 | default: |
| 143 | /* Fall through */ |
| 144 | case VNET_FLOOD_CLASS_NORMAL: |
| 145 | ix = (member->flags & L2_FLOOD_MEMBER_BVI) ? 0 : |
| 146 | vec_len (bd_config->members) - bd_config->tun_normal_count; |
| 147 | break; |
| 148 | case VNET_FLOOD_CLASS_TUNNEL_NORMAL: |
| 149 | ix = vec_len (bd_config->members); |
| 150 | bd_config->tun_normal_count++; |
| 151 | break; |
| 152 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 153 | |
Eyal Bari | c5b1360 | 2016-11-24 19:42:43 +0200 | [diff] [blame] | 154 | vec_insert_elts (bd_config->members, member, 1, ix); |
| 155 | update_flood_count (bd_config); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 156 | } |
| 157 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 158 | #define BD_REMOVE_ERROR_OK 0 |
| 159 | #define BD_REMOVE_ERROR_NOT_FOUND 1 |
| 160 | |
| 161 | u32 |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 162 | bd_remove_member (l2_bridge_domain_t * bd_config, u32 sw_if_index) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 163 | { |
| 164 | u32 ix; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 165 | |
| 166 | /* Find and delete the member */ |
| 167 | vec_foreach_index (ix, bd_config->members) |
| 168 | { |
Eyal Bari | c5b1360 | 2016-11-24 19:42:43 +0200 | [diff] [blame] | 169 | l2_flood_member_t *m = vec_elt_at_index (bd_config->members, ix); |
| 170 | if (m->sw_if_index == sw_if_index) |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 171 | { |
Eyal Bari | c5b1360 | 2016-11-24 19:42:43 +0200 | [diff] [blame] | 172 | vnet_sw_interface_t *sw_if = vnet_get_sw_interface |
| 173 | (vnet_get_main (), sw_if_index); |
| 174 | |
| 175 | if (sw_if->flood_class != VNET_FLOOD_CLASS_NORMAL) |
| 176 | { |
| 177 | if (sw_if->flood_class == VNET_FLOOD_CLASS_TUNNEL_MASTER) |
| 178 | bd_config->tun_master_count--; |
| 179 | else if (sw_if->flood_class == VNET_FLOOD_CLASS_TUNNEL_NORMAL) |
| 180 | bd_config->tun_normal_count--; |
| 181 | } |
Eyal Bari | 25b3667 | 2017-03-02 10:43:19 +0200 | [diff] [blame] | 182 | vec_delete (bd_config->members, 1, ix); |
Eyal Bari | c5b1360 | 2016-11-24 19:42:43 +0200 | [diff] [blame] | 183 | update_flood_count (bd_config); |
| 184 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 185 | return BD_REMOVE_ERROR_OK; |
| 186 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 187 | } |
| 188 | |
| 189 | return BD_REMOVE_ERROR_NOT_FOUND; |
| 190 | } |
| 191 | |
| 192 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 193 | clib_error_t * |
| 194 | l2bd_init (vlib_main_t * vm) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 195 | { |
| 196 | bd_main_t *bdm = &bd_main; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 197 | bdm->bd_index_by_bd_id = hash_create (0, sizeof (uword)); |
| 198 | /* |
| 199 | * create a dummy bd with bd_id of 0 and bd_index of 0 with feature set |
| 200 | * to packet drop only. Thus, packets received from any L2 interface with |
| 201 | * uninitialized bd_index of 0 can be dropped safely. |
| 202 | */ |
Eyal Bari | b1352ed | 2017-04-07 23:14:17 +0300 | [diff] [blame] | 203 | u32 bd_index = bd_add_bd_index (bdm, 0); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 204 | ASSERT (bd_index == 0); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 205 | l2input_main.bd_configs[0].feature_bitmap = L2INPUT_FEAT_DROP; |
Choonho Son | 0548079 | 2017-03-29 20:07:45 +0900 | [diff] [blame] | 206 | |
| 207 | bdm->vlib_main = vm; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 208 | return 0; |
| 209 | } |
| 210 | |
| 211 | VLIB_INIT_FUNCTION (l2bd_init); |
| 212 | |
| 213 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 214 | /** |
Chris Luke | 16bcf7d | 2016-09-01 14:31:46 -0400 | [diff] [blame] | 215 | Set the learn/forward/flood flags for the bridge domain. |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 216 | Return 0 if ok, non-zero if for an error. |
| 217 | */ |
| 218 | u32 |
| 219 | bd_set_flags (vlib_main_t * vm, u32 bd_index, u32 flags, u32 enable) |
| 220 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 221 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 222 | l2_bridge_domain_t *bd_config; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 223 | u32 feature_bitmap = 0; |
| 224 | |
| 225 | vec_validate (l2input_main.bd_configs, bd_index); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 226 | bd_config = vec_elt_at_index (l2input_main.bd_configs, bd_index); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 227 | |
| 228 | bd_validate (bd_config); |
| 229 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 230 | if (flags & L2_LEARN) |
| 231 | { |
| 232 | feature_bitmap |= L2INPUT_FEAT_LEARN; |
| 233 | } |
| 234 | if (flags & L2_FWD) |
| 235 | { |
| 236 | feature_bitmap |= L2INPUT_FEAT_FWD; |
| 237 | } |
| 238 | if (flags & L2_FLOOD) |
| 239 | { |
| 240 | feature_bitmap |= L2INPUT_FEAT_FLOOD; |
| 241 | } |
| 242 | if (flags & L2_UU_FLOOD) |
| 243 | { |
| 244 | feature_bitmap |= L2INPUT_FEAT_UU_FLOOD; |
| 245 | } |
| 246 | if (flags & L2_ARP_TERM) |
| 247 | { |
| 248 | feature_bitmap |= L2INPUT_FEAT_ARP_TERM; |
| 249 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 250 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 251 | if (enable) |
| 252 | { |
| 253 | bd_config->feature_bitmap |= feature_bitmap; |
| 254 | } |
| 255 | else |
| 256 | { |
| 257 | bd_config->feature_bitmap &= ~feature_bitmap; |
| 258 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 259 | |
| 260 | return 0; |
| 261 | } |
| 262 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 263 | /** |
Damjan Marion | d171d48 | 2016-12-05 14:16:38 +0100 | [diff] [blame] | 264 | Set the mac age for the bridge domain. |
| 265 | */ |
| 266 | void |
| 267 | bd_set_mac_age (vlib_main_t * vm, u32 bd_index, u8 age) |
| 268 | { |
| 269 | l2_bridge_domain_t *bd_config; |
| 270 | int enable = 0; |
| 271 | |
| 272 | vec_validate (l2input_main.bd_configs, bd_index); |
| 273 | bd_config = vec_elt_at_index (l2input_main.bd_configs, bd_index); |
| 274 | bd_config->mac_age = age; |
| 275 | |
| 276 | /* check if there is at least one bd with mac aging enabled */ |
| 277 | vec_foreach (bd_config, l2input_main.bd_configs) |
Eyal Bari | fead670 | 2017-04-04 04:46:32 +0300 | [diff] [blame] | 278 | enable |= bd_config->bd_id != ~0 && bd_config->mac_age != 0; |
Damjan Marion | d171d48 | 2016-12-05 14:16:38 +0100 | [diff] [blame] | 279 | |
| 280 | vlib_process_signal_event (vm, l2fib_mac_age_scanner_process_node.index, |
| 281 | enable ? L2_MAC_AGE_PROCESS_EVENT_START : |
| 282 | L2_MAC_AGE_PROCESS_EVENT_STOP, 0); |
| 283 | } |
| 284 | |
| 285 | /** |
Chris Luke | 16bcf7d | 2016-09-01 14:31:46 -0400 | [diff] [blame] | 286 | Set bridge-domain learn enable/disable. |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 287 | The CLI format is: |
| 288 | set bridge-domain learn <bd_id> [disable] |
| 289 | */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 290 | static clib_error_t * |
| 291 | bd_learn (vlib_main_t * vm, |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 292 | unformat_input_t * input, vlib_cli_command_t * cmd) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 293 | { |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 294 | bd_main_t *bdm = &bd_main; |
| 295 | clib_error_t *error = 0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 296 | u32 bd_index, bd_id; |
| 297 | u32 enable; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 298 | uword *p; |
| 299 | |
| 300 | if (!unformat (input, "%d", &bd_id)) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 301 | { |
| 302 | error = clib_error_return (0, "expecting bridge-domain id but got `%U'", |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 303 | format_unformat_error, input); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 304 | goto done; |
| 305 | } |
| 306 | |
Jon Loeliger | 1c7d485 | 2017-05-02 11:06:23 -0500 | [diff] [blame] | 307 | if (bd_id == 0) |
| 308 | return clib_error_return (0, |
| 309 | "No operations on the default bridge domain are supported"); |
| 310 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 311 | p = hash_get (bdm->bd_index_by_bd_id, bd_id); |
| 312 | |
| 313 | if (p == 0) |
| 314 | return clib_error_return (0, "No such bridge domain %d", bd_id); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 315 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 316 | bd_index = p[0]; |
| 317 | |
| 318 | enable = 1; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 319 | if (unformat (input, "disable")) |
| 320 | { |
| 321 | enable = 0; |
| 322 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 323 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 324 | /* set the bridge domain flag */ |
| 325 | if (bd_set_flags (vm, bd_index, L2_LEARN, enable)) |
| 326 | { |
| 327 | error = |
| 328 | clib_error_return (0, "bridge-domain id %d out of range", bd_index); |
| 329 | goto done; |
| 330 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 331 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 332 | done: |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 333 | return error; |
| 334 | } |
| 335 | |
Billy McFall | 22aa3e9 | 2016-09-09 08:46:40 -0400 | [diff] [blame] | 336 | /*? |
| 337 | * Layer 2 learning can be enabled and disabled on each |
| 338 | * interface and on each bridge-domain. Use this command to |
| 339 | * manage bridge-domains. It is enabled by default. |
| 340 | * |
| 341 | * @cliexpar |
| 342 | * Example of how to enable learning (where 200 is the bridge-domain-id): |
| 343 | * @cliexcmd{set bridge-domain learn 200} |
| 344 | * Example of how to disable learning (where 200 is the bridge-domain-id): |
| 345 | * @cliexcmd{set bridge-domain learn 200 disable} |
| 346 | ?*/ |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 347 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 348 | VLIB_CLI_COMMAND (bd_learn_cli, static) = { |
| 349 | .path = "set bridge-domain learn", |
| 350 | .short_help = "set bridge-domain learn <bridge-domain-id> [disable]", |
| 351 | .function = bd_learn, |
| 352 | }; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 353 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 354 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 355 | /** |
Chris Luke | 16bcf7d | 2016-09-01 14:31:46 -0400 | [diff] [blame] | 356 | Set bridge-domain forward enable/disable. |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 357 | The CLI format is: |
| 358 | set bridge-domain forward <bd_index> [disable] |
| 359 | */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 360 | static clib_error_t * |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 361 | bd_fwd (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 362 | { |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 363 | bd_main_t *bdm = &bd_main; |
| 364 | clib_error_t *error = 0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 365 | u32 bd_index, bd_id; |
| 366 | u32 enable; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 367 | uword *p; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 368 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 369 | if (!unformat (input, "%d", &bd_id)) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 370 | { |
| 371 | error = clib_error_return (0, "expecting bridge-domain id but got `%U'", |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 372 | format_unformat_error, input); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 373 | goto done; |
| 374 | } |
| 375 | |
Jon Loeliger | 1c7d485 | 2017-05-02 11:06:23 -0500 | [diff] [blame] | 376 | if (bd_id == 0) |
| 377 | return clib_error_return (0, |
| 378 | "No operations on the default bridge domain are supported"); |
| 379 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 380 | p = hash_get (bdm->bd_index_by_bd_id, bd_id); |
| 381 | |
| 382 | if (p == 0) |
| 383 | return clib_error_return (0, "No such bridge domain %d", bd_id); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 384 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 385 | bd_index = p[0]; |
| 386 | |
| 387 | enable = 1; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 388 | if (unformat (input, "disable")) |
| 389 | { |
| 390 | enable = 0; |
| 391 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 392 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 393 | /* set the bridge domain flag */ |
| 394 | if (bd_set_flags (vm, bd_index, L2_FWD, enable)) |
| 395 | { |
| 396 | error = |
| 397 | clib_error_return (0, "bridge-domain id %d out of range", bd_index); |
| 398 | goto done; |
| 399 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 400 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 401 | done: |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 402 | return error; |
| 403 | } |
| 404 | |
Billy McFall | 22aa3e9 | 2016-09-09 08:46:40 -0400 | [diff] [blame] | 405 | |
| 406 | /*? |
| 407 | * Layer 2 unicast forwarding can be enabled and disabled on each |
| 408 | * interface and on each bridge-domain. Use this command to |
| 409 | * manage bridge-domains. It is enabled by default. |
| 410 | * |
| 411 | * @cliexpar |
| 412 | * Example of how to enable forwarding (where 200 is the bridge-domain-id): |
| 413 | * @cliexcmd{set bridge-domain forward 200} |
| 414 | * Example of how to disable forwarding (where 200 is the bridge-domain-id): |
| 415 | * @cliexcmd{set bridge-domain forward 200 disable} |
| 416 | ?*/ |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 417 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 418 | VLIB_CLI_COMMAND (bd_fwd_cli, static) = { |
| 419 | .path = "set bridge-domain forward", |
| 420 | .short_help = "set bridge-domain forward <bridge-domain-id> [disable]", |
| 421 | .function = bd_fwd, |
| 422 | }; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 423 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 424 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 425 | /** |
Chris Luke | 16bcf7d | 2016-09-01 14:31:46 -0400 | [diff] [blame] | 426 | Set bridge-domain flood enable/disable. |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 427 | The CLI format is: |
| 428 | set bridge-domain flood <bd_index> [disable] |
| 429 | */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 430 | static clib_error_t * |
| 431 | bd_flood (vlib_main_t * vm, |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 432 | unformat_input_t * input, vlib_cli_command_t * cmd) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 433 | { |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 434 | bd_main_t *bdm = &bd_main; |
| 435 | clib_error_t *error = 0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 436 | u32 bd_index, bd_id; |
| 437 | u32 enable; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 438 | uword *p; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 439 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 440 | if (!unformat (input, "%d", &bd_id)) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 441 | { |
| 442 | error = clib_error_return (0, "expecting bridge-domain id but got `%U'", |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 443 | format_unformat_error, input); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 444 | goto done; |
| 445 | } |
| 446 | |
Jon Loeliger | 1c7d485 | 2017-05-02 11:06:23 -0500 | [diff] [blame] | 447 | if (bd_id == 0) |
| 448 | return clib_error_return (0, |
| 449 | "No operations on the default bridge domain are supported"); |
| 450 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 451 | p = hash_get (bdm->bd_index_by_bd_id, bd_id); |
| 452 | |
| 453 | if (p == 0) |
| 454 | return clib_error_return (0, "No such bridge domain %d", bd_id); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 455 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 456 | bd_index = p[0]; |
| 457 | |
| 458 | enable = 1; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 459 | if (unformat (input, "disable")) |
| 460 | { |
| 461 | enable = 0; |
| 462 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 463 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 464 | /* set the bridge domain flag */ |
| 465 | if (bd_set_flags (vm, bd_index, L2_FLOOD, enable)) |
| 466 | { |
| 467 | error = |
| 468 | clib_error_return (0, "bridge-domain id %d out of range", bd_index); |
| 469 | goto done; |
| 470 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 471 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 472 | done: |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 473 | return error; |
| 474 | } |
| 475 | |
Billy McFall | 22aa3e9 | 2016-09-09 08:46:40 -0400 | [diff] [blame] | 476 | /*? |
| 477 | * Layer 2 flooding can be enabled and disabled on each |
| 478 | * interface and on each bridge-domain. Use this command to |
| 479 | * manage bridge-domains. It is enabled by default. |
| 480 | * |
| 481 | * @cliexpar |
| 482 | * Example of how to enable flooding (where 200 is the bridge-domain-id): |
| 483 | * @cliexcmd{set bridge-domain flood 200} |
| 484 | * Example of how to disable flooding (where 200 is the bridge-domain-id): |
| 485 | * @cliexcmd{set bridge-domain flood 200 disable} |
| 486 | ?*/ |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 487 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 488 | VLIB_CLI_COMMAND (bd_flood_cli, static) = { |
| 489 | .path = "set bridge-domain flood", |
| 490 | .short_help = "set bridge-domain flood <bridge-domain-id> [disable]", |
| 491 | .function = bd_flood, |
| 492 | }; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 493 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 494 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 495 | /** |
Chris Luke | 16bcf7d | 2016-09-01 14:31:46 -0400 | [diff] [blame] | 496 | Set bridge-domain unkown-unicast flood enable/disable. |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 497 | The CLI format is: |
| 498 | set bridge-domain uu-flood <bd_index> [disable] |
| 499 | */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 500 | static clib_error_t * |
| 501 | bd_uu_flood (vlib_main_t * vm, |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 502 | unformat_input_t * input, vlib_cli_command_t * cmd) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 503 | { |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 504 | bd_main_t *bdm = &bd_main; |
| 505 | clib_error_t *error = 0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 506 | u32 bd_index, bd_id; |
| 507 | u32 enable; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 508 | uword *p; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 509 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 510 | if (!unformat (input, "%d", &bd_id)) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 511 | { |
| 512 | error = clib_error_return (0, "expecting bridge-domain id but got `%U'", |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 513 | format_unformat_error, input); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 514 | goto done; |
| 515 | } |
| 516 | |
Jon Loeliger | 1c7d485 | 2017-05-02 11:06:23 -0500 | [diff] [blame] | 517 | if (bd_id == 0) |
| 518 | return clib_error_return (0, |
| 519 | "No operations on the default bridge domain are supported"); |
| 520 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 521 | p = hash_get (bdm->bd_index_by_bd_id, bd_id); |
| 522 | |
| 523 | if (p == 0) |
| 524 | return clib_error_return (0, "No such bridge domain %d", bd_id); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 525 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 526 | bd_index = p[0]; |
| 527 | |
| 528 | enable = 1; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 529 | if (unformat (input, "disable")) |
| 530 | { |
| 531 | enable = 0; |
| 532 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 533 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 534 | /* set the bridge domain flag */ |
| 535 | if (bd_set_flags (vm, bd_index, L2_UU_FLOOD, enable)) |
| 536 | { |
| 537 | error = |
| 538 | clib_error_return (0, "bridge-domain id %d out of range", bd_index); |
| 539 | goto done; |
| 540 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 541 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 542 | done: |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 543 | return error; |
| 544 | } |
| 545 | |
Billy McFall | 22aa3e9 | 2016-09-09 08:46:40 -0400 | [diff] [blame] | 546 | /*? |
| 547 | * Layer 2 unknown-unicast flooding can be enabled and disabled on each |
| 548 | * bridge-domain. It is enabled by default. |
| 549 | * |
| 550 | * @cliexpar |
| 551 | * Example of how to enable unknown-unicast flooding (where 200 is the |
| 552 | * bridge-domain-id): |
| 553 | * @cliexcmd{set bridge-domain uu-flood 200} |
| 554 | * Example of how to disable unknown-unicast flooding (where 200 is the bridge-domain-id): |
| 555 | * @cliexcmd{set bridge-domain uu-flood 200 disable} |
| 556 | ?*/ |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 557 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 558 | VLIB_CLI_COMMAND (bd_uu_flood_cli, static) = { |
| 559 | .path = "set bridge-domain uu-flood", |
| 560 | .short_help = "set bridge-domain uu-flood <bridge-domain-id> [disable]", |
| 561 | .function = bd_uu_flood, |
| 562 | }; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 563 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 564 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 565 | /** |
Chris Luke | 16bcf7d | 2016-09-01 14:31:46 -0400 | [diff] [blame] | 566 | Set bridge-domain arp term enable/disable. |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 567 | The CLI format is: |
| 568 | set bridge-domain arp term <bridge-domain-id> [disable] |
| 569 | */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 570 | static clib_error_t * |
| 571 | bd_arp_term (vlib_main_t * vm, |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 572 | unformat_input_t * input, vlib_cli_command_t * cmd) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 573 | { |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 574 | bd_main_t *bdm = &bd_main; |
| 575 | clib_error_t *error = 0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 576 | u32 bd_index, bd_id; |
| 577 | u32 enable; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 578 | uword *p; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 579 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 580 | if (!unformat (input, "%d", &bd_id)) |
| 581 | { |
| 582 | error = clib_error_return (0, "expecting bridge-domain id but got `%U'", |
| 583 | format_unformat_error, input); |
| 584 | goto done; |
| 585 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 586 | |
Jon Loeliger | 1c7d485 | 2017-05-02 11:06:23 -0500 | [diff] [blame] | 587 | if (bd_id == 0) |
| 588 | return clib_error_return (0, |
| 589 | "No operations on the default bridge domain are supported"); |
| 590 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 591 | p = hash_get (bdm->bd_index_by_bd_id, bd_id); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 592 | if (p) |
| 593 | bd_index = *p; |
| 594 | else |
| 595 | return clib_error_return (0, "No such bridge domain %d", bd_id); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 596 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 597 | enable = 1; |
| 598 | if (unformat (input, "disable")) |
| 599 | enable = 0; |
| 600 | |
| 601 | /* set the bridge domain flag */ |
| 602 | if (bd_set_flags (vm, bd_index, L2_ARP_TERM, enable)) |
| 603 | { |
| 604 | error = |
| 605 | clib_error_return (0, "bridge-domain id %d out of range", bd_index); |
| 606 | goto done; |
| 607 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 608 | |
| 609 | done: |
| 610 | return error; |
| 611 | } |
| 612 | |
Damjan Marion | d171d48 | 2016-12-05 14:16:38 +0100 | [diff] [blame] | 613 | static clib_error_t * |
| 614 | bd_mac_age (vlib_main_t * vm, |
| 615 | unformat_input_t * input, vlib_cli_command_t * cmd) |
| 616 | { |
| 617 | bd_main_t *bdm = &bd_main; |
| 618 | clib_error_t *error = 0; |
| 619 | u32 bd_index, bd_id; |
| 620 | u32 age; |
| 621 | uword *p; |
| 622 | |
| 623 | if (!unformat (input, "%d", &bd_id)) |
| 624 | { |
| 625 | error = clib_error_return (0, "expecting bridge-domain id but got `%U'", |
| 626 | format_unformat_error, input); |
| 627 | goto done; |
| 628 | } |
| 629 | |
Jon Loeliger | 1c7d485 | 2017-05-02 11:06:23 -0500 | [diff] [blame] | 630 | if (bd_id == 0) |
| 631 | return clib_error_return (0, |
| 632 | "No operations on the default bridge domain are supported"); |
| 633 | |
Damjan Marion | d171d48 | 2016-12-05 14:16:38 +0100 | [diff] [blame] | 634 | p = hash_get (bdm->bd_index_by_bd_id, bd_id); |
| 635 | |
| 636 | if (p == 0) |
| 637 | return clib_error_return (0, "No such bridge domain %d", bd_id); |
| 638 | |
| 639 | bd_index = p[0]; |
| 640 | |
| 641 | if (!unformat (input, "%u", &age)) |
| 642 | { |
| 643 | error = |
| 644 | clib_error_return (0, "expecting ageing time in minutes but got `%U'", |
| 645 | format_unformat_error, input); |
| 646 | goto done; |
| 647 | } |
| 648 | |
| 649 | /* set the bridge domain flag */ |
| 650 | if (age > 255) |
| 651 | { |
| 652 | error = |
| 653 | clib_error_return (0, "mac aging time cannot be bigger than 255"); |
| 654 | goto done; |
| 655 | } |
| 656 | bd_set_mac_age (vm, bd_index, (u8) age); |
| 657 | |
| 658 | done: |
| 659 | return error; |
| 660 | } |
| 661 | |
| 662 | /*? |
| 663 | * Layer 2 mac aging can be enabled and disabled on each |
| 664 | * bridge-domain. Use this command to set or disable mac aging |
| 665 | * on specific bridge-domains. It is disabled by default. |
| 666 | * |
| 667 | * @cliexpar |
| 668 | * Example of how to set mac aging (where 200 is the bridge-domain-id and |
| 669 | * 5 is aging time in minutes): |
| 670 | * @cliexcmd{set bridge-domain mac-age 200 5} |
| 671 | * Example of how to disable mac aging (where 200 is the bridge-domain-id): |
| 672 | * @cliexcmd{set bridge-domain flood 200 0} |
| 673 | ?*/ |
| 674 | /* *INDENT-OFF* */ |
| 675 | VLIB_CLI_COMMAND (bd_mac_age_cli, static) = { |
| 676 | .path = "set bridge-domain mac-age", |
| 677 | .short_help = "set bridge-domain mac-age <bridge-domain-id> <mins>", |
| 678 | .function = bd_mac_age, |
| 679 | }; |
| 680 | /* *INDENT-ON* */ |
| 681 | |
Billy McFall | 22aa3e9 | 2016-09-09 08:46:40 -0400 | [diff] [blame] | 682 | /*? |
| 683 | * Modify whether or not an existing bridge-domain should terminate and respond |
| 684 | * to ARP Requests. ARP Termination is disabled by default. |
| 685 | * |
| 686 | * @cliexpar |
| 687 | * Example of how to enable ARP termination (where 200 is the bridge-domain-id): |
| 688 | * @cliexcmd{set bridge-domain arp term 200} |
| 689 | * Example of how to disable ARP termination (where 200 is the bridge-domain-id): |
| 690 | * @cliexcmd{set bridge-domain arp term 200 disable} |
| 691 | ?*/ |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 692 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 693 | VLIB_CLI_COMMAND (bd_arp_term_cli, static) = { |
| 694 | .path = "set bridge-domain arp term", |
| 695 | .short_help = "set bridge-domain arp term <bridge-domain-id> [disable]", |
| 696 | .function = bd_arp_term, |
| 697 | }; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 698 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 699 | |
| 700 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 701 | /** |
Chris Luke | 16bcf7d | 2016-09-01 14:31:46 -0400 | [diff] [blame] | 702 | * Add/delete IP address to MAC address mapping. |
| 703 | * |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 704 | * The clib hash implementation stores uword entries in the hash table. |
| 705 | * The hash table mac_by_ip4 is keyed via IP4 address and store the |
| 706 | * 6-byte MAC address directly in the hash table entry uword. |
Chris Luke | 16bcf7d | 2016-09-01 14:31:46 -0400 | [diff] [blame] | 707 | * |
| 708 | * @warning This only works for 64-bit processor with 8-byte uword; |
| 709 | * which means this code *WILL NOT WORK* for a 32-bit prcessor with |
| 710 | * 4-byte uword. |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 711 | */ |
| 712 | u32 |
| 713 | bd_add_del_ip_mac (u32 bd_index, |
| 714 | u8 * ip_addr, u8 * mac_addr, u8 is_ip6, u8 is_add) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 715 | { |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 716 | l2input_main_t *l2im = &l2input_main; |
| 717 | l2_bridge_domain_t *bd_cfg = l2input_bd_config_from_index (l2im, bd_index); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 718 | u64 new_mac = *(u64 *) mac_addr; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 719 | u64 *old_mac; |
| 720 | u16 *mac16 = (u16 *) & new_mac; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 721 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 722 | ASSERT (sizeof (uword) == sizeof (u64)); /* make sure uword is 8 bytes */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 723 | |
John Lo | 1edfba9 | 2016-08-27 01:11:57 -0400 | [diff] [blame] | 724 | mac16[3] = 0; /* Clear last 2 unsed bytes of the 8-byte MAC address */ |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 725 | if (is_ip6) |
| 726 | { |
John Lo | 1edfba9 | 2016-08-27 01:11:57 -0400 | [diff] [blame] | 727 | ip6_address_t *ip6_addr_key; |
| 728 | hash_pair_t *hp; |
| 729 | old_mac = (u64 *) hash_get_mem (bd_cfg->mac_by_ip6, ip_addr); |
| 730 | if (is_add) |
| 731 | { |
| 732 | if (old_mac == 0) |
| 733 | { /* new entry - allocate and craete ip6 address key */ |
| 734 | ip6_addr_key = clib_mem_alloc (sizeof (ip6_address_t)); |
| 735 | clib_memcpy (ip6_addr_key, ip_addr, sizeof (ip6_address_t)); |
| 736 | } |
| 737 | else if (*old_mac == new_mac) |
| 738 | { /* same mac entry already exist for ip6 address */ |
| 739 | return 0; |
| 740 | } |
| 741 | else |
| 742 | { /* updat mac for ip6 address */ |
| 743 | hp = hash_get_pair (bd_cfg->mac_by_ip6, ip_addr); |
| 744 | ip6_addr_key = (ip6_address_t *) hp->key; |
| 745 | } |
| 746 | hash_set_mem (bd_cfg->mac_by_ip6, ip6_addr_key, new_mac); |
| 747 | } |
| 748 | else |
| 749 | { |
| 750 | if (old_mac && (*old_mac == new_mac)) |
| 751 | { |
| 752 | hp = hash_get_pair (bd_cfg->mac_by_ip6, ip_addr); |
| 753 | ip6_addr_key = (ip6_address_t *) hp->key; |
| 754 | hash_unset_mem (bd_cfg->mac_by_ip6, ip_addr); |
| 755 | clib_mem_free (ip6_addr_key); |
| 756 | } |
| 757 | else |
| 758 | return 1; |
| 759 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 760 | } |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 761 | else |
| 762 | { |
| 763 | ip4_address_t ip4_addr = *(ip4_address_t *) ip_addr; |
| 764 | old_mac = (u64 *) hash_get (bd_cfg->mac_by_ip4, ip4_addr.as_u32); |
| 765 | if (is_add) |
| 766 | { |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 767 | if (old_mac && (*old_mac == new_mac)) |
John Lo | 1edfba9 | 2016-08-27 01:11:57 -0400 | [diff] [blame] | 768 | return 0; /* mac entry already exist */ |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 769 | hash_set (bd_cfg->mac_by_ip4, ip4_addr.as_u32, new_mac); |
| 770 | } |
| 771 | else |
| 772 | { |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 773 | if (old_mac && (*old_mac == new_mac)) |
John Lo | 1edfba9 | 2016-08-27 01:11:57 -0400 | [diff] [blame] | 774 | hash_unset (bd_cfg->mac_by_ip4, ip4_addr.as_u32); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 775 | else |
John Lo | 1edfba9 | 2016-08-27 01:11:57 -0400 | [diff] [blame] | 776 | return 1; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 777 | } |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 778 | } |
John Lo | 1edfba9 | 2016-08-27 01:11:57 -0400 | [diff] [blame] | 779 | return 0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 780 | } |
| 781 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 782 | /** |
Chris Luke | 16bcf7d | 2016-09-01 14:31:46 -0400 | [diff] [blame] | 783 | Set bridge-domain arp entry add/delete. |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 784 | The CLI format is: |
Billy McFall | 22aa3e9 | 2016-09-09 08:46:40 -0400 | [diff] [blame] | 785 | set bridge-domain arp entry <bridge-domain-id> <ip-addr> <mac-addr> [del] |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 786 | */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 787 | static clib_error_t * |
| 788 | bd_arp_entry (vlib_main_t * vm, |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 789 | unformat_input_t * input, vlib_cli_command_t * cmd) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 790 | { |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 791 | bd_main_t *bdm = &bd_main; |
| 792 | clib_error_t *error = 0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 793 | u32 bd_index, bd_id; |
| 794 | u8 is_add = 1; |
| 795 | u8 is_ip6 = 0; |
| 796 | u8 ip_addr[16]; |
| 797 | u8 mac_addr[6]; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 798 | uword *p; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 799 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 800 | if (!unformat (input, "%d", &bd_id)) |
| 801 | { |
| 802 | error = clib_error_return (0, "expecting bridge-domain id but got `%U'", |
| 803 | format_unformat_error, input); |
| 804 | goto done; |
| 805 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 806 | |
Jon Loeliger | 1c7d485 | 2017-05-02 11:06:23 -0500 | [diff] [blame] | 807 | if (bd_id == 0) |
| 808 | return clib_error_return (0, |
| 809 | "No operations on the default bridge domain are supported"); |
| 810 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 811 | p = hash_get (bdm->bd_index_by_bd_id, bd_id); |
| 812 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 813 | if (p) |
| 814 | bd_index = *p; |
| 815 | else |
| 816 | return clib_error_return (0, "No such bridge domain %d", bd_id); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 817 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 818 | if (unformat (input, "%U", unformat_ip4_address, ip_addr)) |
| 819 | { |
| 820 | is_ip6 = 0; |
| 821 | } |
| 822 | else if (unformat (input, "%U", unformat_ip6_address, ip_addr)) |
| 823 | { |
| 824 | is_ip6 = 1; |
| 825 | } |
| 826 | else |
| 827 | { |
| 828 | error = clib_error_return (0, "expecting IP address but got `%U'", |
| 829 | format_unformat_error, input); |
| 830 | goto done; |
| 831 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 832 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 833 | if (!unformat (input, "%U", unformat_ethernet_address, mac_addr)) |
| 834 | { |
| 835 | error = clib_error_return (0, "expecting MAC address but got `%U'", |
| 836 | format_unformat_error, input); |
| 837 | goto done; |
| 838 | } |
| 839 | |
| 840 | if (unformat (input, "del")) |
| 841 | { |
| 842 | is_add = 0; |
| 843 | } |
| 844 | |
| 845 | /* set the bridge domain flagAdd IP-MAC entry into bridge domain */ |
| 846 | if (bd_add_del_ip_mac (bd_index, ip_addr, mac_addr, is_ip6, is_add)) |
| 847 | { |
| 848 | error = clib_error_return (0, "MAC %s for IP %U and MAC %U failed", |
| 849 | is_add ? "add" : "del", |
John Lo | 1edfba9 | 2016-08-27 01:11:57 -0400 | [diff] [blame] | 850 | is_ip6 ? |
| 851 | format_ip4_address : format_ip6_address, |
| 852 | ip_addr, format_ethernet_address, mac_addr); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 853 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 854 | |
| 855 | done: |
| 856 | return error; |
| 857 | } |
| 858 | |
Billy McFall | 22aa3e9 | 2016-09-09 08:46:40 -0400 | [diff] [blame] | 859 | /*? |
| 860 | * Add an ARP entry to an existing bridge-domain. |
| 861 | * |
| 862 | * @cliexpar |
| 863 | * Example of how to add an ARP entry (where 200 is the bridge-domain-id): |
| 864 | * @cliexcmd{set bridge-domain arp entry 200 192.168.72.45 52:54:00:3b:83:1a} |
| 865 | * Example of how to delete an ARP entry (where 200 is the bridge-domain-id): |
| 866 | * @cliexcmd{set bridge-domain arp entry 200 192.168.72.45 52:54:00:3b:83:1a del} |
| 867 | ?*/ |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 868 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 869 | VLIB_CLI_COMMAND (bd_arp_entry_cli, static) = { |
| 870 | .path = "set bridge-domain arp entry", |
Billy McFall | 22aa3e9 | 2016-09-09 08:46:40 -0400 | [diff] [blame] | 871 | .short_help = "set bridge-domain arp entry <bridge-domain-id> <ip-addr> <mac-addr> [del]", |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 872 | .function = bd_arp_entry, |
| 873 | }; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 874 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 875 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 876 | u8 * |
| 877 | format_vtr (u8 * s, va_list * args) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 878 | { |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 879 | u32 vtr_op = va_arg (*args, u32); |
| 880 | u32 dot1q = va_arg (*args, u32); |
| 881 | u32 tag1 = va_arg (*args, u32); |
| 882 | u32 tag2 = va_arg (*args, u32); |
| 883 | switch (vtr_op) |
| 884 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 885 | case L2_VTR_DISABLED: |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 886 | return format (s, "none"); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 887 | case L2_VTR_PUSH_1: |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 888 | return format (s, "push-1 %s %d", dot1q ? "dot1q" : "dot1ad", tag1); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 889 | case L2_VTR_PUSH_2: |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 890 | return format (s, "push-2 %s %d %d", dot1q ? "dot1q" : "dot1ad", tag1, |
| 891 | tag2); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 892 | case L2_VTR_POP_1: |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 893 | return format (s, "pop-1"); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 894 | case L2_VTR_POP_2: |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 895 | return format (s, "pop-2"); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 896 | case L2_VTR_TRANSLATE_1_1: |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 897 | return format (s, "trans-1-1 %s %d", dot1q ? "dot1q" : "dot1ad", tag1); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 898 | case L2_VTR_TRANSLATE_1_2: |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 899 | return format (s, "trans-1-2 %s %d %d", dot1q ? "dot1q" : "dot1ad", |
| 900 | tag1, tag2); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 901 | case L2_VTR_TRANSLATE_2_1: |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 902 | return format (s, "trans-2-1 %s %d", dot1q ? "dot1q" : "dot1ad", tag1); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 903 | case L2_VTR_TRANSLATE_2_2: |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 904 | return format (s, "trans-2-2 %s %d %d", dot1q ? "dot1q" : "dot1ad", |
| 905 | tag1, tag2); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 906 | default: |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 907 | return format (s, "none"); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 908 | } |
| 909 | } |
| 910 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 911 | /** |
Chris Luke | 16bcf7d | 2016-09-01 14:31:46 -0400 | [diff] [blame] | 912 | Show bridge-domain state. |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 913 | The CLI format is: |
| 914 | show bridge-domain [<bd_index>] |
| 915 | */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 916 | static clib_error_t * |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 917 | bd_show (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 918 | { |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 919 | vnet_main_t *vnm = vnet_get_main (); |
| 920 | bd_main_t *bdm = &bd_main; |
| 921 | clib_error_t *error = 0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 922 | u32 bd_index = ~0; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 923 | l2_bridge_domain_t *bd_config; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 924 | u32 start, end; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 925 | u32 detail = 0; |
| 926 | u32 intf = 0; |
| 927 | u32 arp = 0; |
| 928 | u32 bd_id = ~0; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 929 | uword *p; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 930 | |
Jon Loeliger | 1c7d485 | 2017-05-02 11:06:23 -0500 | [diff] [blame] | 931 | start = 1; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 932 | end = vec_len (l2input_main.bd_configs); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 933 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 934 | if (unformat (input, "%d", &bd_id)) |
| 935 | { |
| 936 | if (unformat (input, "detail")) |
| 937 | detail = 1; |
| 938 | else if (unformat (input, "det")) |
| 939 | detail = 1; |
| 940 | if (unformat (input, "int")) |
| 941 | intf = 1; |
| 942 | if (unformat (input, "arp")) |
| 943 | arp = 1; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 944 | |
Jon Loeliger | 1c7d485 | 2017-05-02 11:06:23 -0500 | [diff] [blame] | 945 | if (bd_id == 0) |
| 946 | return clib_error_return (0, |
| 947 | "No operations on the default bridge domain are supported"); |
| 948 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 949 | p = hash_get (bdm->bd_index_by_bd_id, bd_id); |
| 950 | if (p) |
| 951 | bd_index = *p; |
| 952 | else |
| 953 | return clib_error_return (0, "No such bridge domain %d", bd_id); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 954 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 955 | vec_validate (l2input_main.bd_configs, bd_index); |
| 956 | bd_config = vec_elt_at_index (l2input_main.bd_configs, bd_index); |
| 957 | if (bd_is_valid (bd_config)) |
| 958 | { |
| 959 | start = bd_index; |
| 960 | end = start + 1; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 961 | } |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 962 | else |
| 963 | { |
| 964 | vlib_cli_output (vm, "bridge-domain %d not in use", bd_id); |
| 965 | goto done; |
| 966 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 967 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 968 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 969 | /* Show all bridge-domains that have been initialized */ |
John Lo | da1f2c7 | 2017-03-24 20:11:15 -0400 | [diff] [blame] | 970 | u32 printed = 0; |
| 971 | u8 *as = 0; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 972 | for (bd_index = start; bd_index < end; bd_index++) |
| 973 | { |
| 974 | bd_config = vec_elt_at_index (l2input_main.bd_configs, bd_index); |
| 975 | if (bd_is_valid (bd_config)) |
| 976 | { |
| 977 | if (!printed) |
| 978 | { |
| 979 | printed = 1; |
| 980 | vlib_cli_output (vm, |
John Lo | da1f2c7 | 2017-03-24 20:11:15 -0400 | [diff] [blame] | 981 | "%=5s %=7s %=4s %=9s %=9s %=9s %=9s %=9s %=9s %=9s", |
| 982 | "ID", "Index", "BSN", "Age(min)", "Learning", |
| 983 | "U-Forwrd", "UU-Flood", "Flooding", "ARP-Term", |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 984 | "BVI-Intf"); |
| 985 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 986 | |
John Lo | da1f2c7 | 2017-03-24 20:11:15 -0400 | [diff] [blame] | 987 | if (bd_config->mac_age) |
| 988 | as = format (as, "%d", bd_config->mac_age); |
| 989 | else |
| 990 | as = format (as, "off"); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 991 | vlib_cli_output (vm, |
John Lo | da1f2c7 | 2017-03-24 20:11:15 -0400 | [diff] [blame] | 992 | "%=5d %=7d %=4d %=9v %=9s %=9s %=9s %=9s %=9s %=9U", |
| 993 | bd_config->bd_id, bd_index, bd_config->seq_num, as, |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 994 | bd_config->feature_bitmap & L2INPUT_FEAT_LEARN ? |
| 995 | "on" : "off", |
John Lo | da1f2c7 | 2017-03-24 20:11:15 -0400 | [diff] [blame] | 996 | bd_config->feature_bitmap & L2INPUT_FEAT_FWD ? |
| 997 | "on" : "off", |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 998 | bd_config->feature_bitmap & L2INPUT_FEAT_UU_FLOOD ? |
| 999 | "on" : "off", |
| 1000 | bd_config->feature_bitmap & L2INPUT_FEAT_FLOOD ? |
| 1001 | "on" : "off", |
| 1002 | bd_config->feature_bitmap & L2INPUT_FEAT_ARP_TERM ? |
John Lo | da1f2c7 | 2017-03-24 20:11:15 -0400 | [diff] [blame] | 1003 | "on" : "off", |
| 1004 | format_vnet_sw_if_index_name_with_NA, |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1005 | vnm, bd_config->bvi_sw_if_index); |
John Lo | da1f2c7 | 2017-03-24 20:11:15 -0400 | [diff] [blame] | 1006 | vec_reset_length (as); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1007 | |
| 1008 | if (detail || intf) |
| 1009 | { |
| 1010 | /* Show all member interfaces */ |
Eyal Bari | c5b1360 | 2016-11-24 19:42:43 +0200 | [diff] [blame] | 1011 | int i; |
| 1012 | vec_foreach_index (i, bd_config->members) |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1013 | { |
Eyal Bari | c5b1360 | 2016-11-24 19:42:43 +0200 | [diff] [blame] | 1014 | l2_flood_member_t *member = |
| 1015 | vec_elt_at_index (bd_config->members, i); |
John Lo | da1f2c7 | 2017-03-24 20:11:15 -0400 | [diff] [blame] | 1016 | l2_input_config_t *int_config = |
| 1017 | l2input_intf_config (member->sw_if_index); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1018 | u32 vtr_opr, dot1q, tag1, tag2; |
Eyal Bari | c5b1360 | 2016-11-24 19:42:43 +0200 | [diff] [blame] | 1019 | if (i == 0) |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1020 | { |
John Lo | da1f2c7 | 2017-03-24 20:11:15 -0400 | [diff] [blame] | 1021 | vlib_cli_output (vm, "\n%=30s%=7s%=5s%=5s%=5s%=9s%=30s", |
| 1022 | "Interface", "If-idx", "ISN", "SHG", |
| 1023 | "BVI", "TxFlood", "VLAN-Tag-Rewrite"); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1024 | } |
| 1025 | l2vtr_get (vm, vnm, member->sw_if_index, &vtr_opr, &dot1q, |
| 1026 | &tag1, &tag2); |
John Lo | da1f2c7 | 2017-03-24 20:11:15 -0400 | [diff] [blame] | 1027 | vlib_cli_output (vm, "%=30U%=7d%=5d%=5d%=5s%=9s%=30U", |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1028 | format_vnet_sw_if_index_name, vnm, |
| 1029 | member->sw_if_index, member->sw_if_index, |
John Lo | da1f2c7 | 2017-03-24 20:11:15 -0400 | [diff] [blame] | 1030 | int_config->seq_num, member->shg, |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1031 | member->flags & L2_FLOOD_MEMBER_BVI ? "*" : |
Eyal Bari | c5b1360 | 2016-11-24 19:42:43 +0200 | [diff] [blame] | 1032 | "-", i < bd_config->flood_count ? "*" : "-", |
| 1033 | format_vtr, vtr_opr, dot1q, tag1, tag2); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1034 | } |
| 1035 | } |
| 1036 | |
| 1037 | if ((detail || arp) && |
| 1038 | (bd_config->feature_bitmap & L2INPUT_FEAT_ARP_TERM)) |
| 1039 | { |
| 1040 | u32 ip4_addr; |
John Lo | 1edfba9 | 2016-08-27 01:11:57 -0400 | [diff] [blame] | 1041 | ip6_address_t *ip6_addr; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1042 | u64 mac_addr; |
| 1043 | vlib_cli_output (vm, |
John Lo | 1edfba9 | 2016-08-27 01:11:57 -0400 | [diff] [blame] | 1044 | "\n IP4/IP6 to MAC table for ARP Termination"); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1045 | |
| 1046 | /* *INDENT-OFF* */ |
| 1047 | hash_foreach (ip4_addr, mac_addr, bd_config->mac_by_ip4, |
| 1048 | ({ |
John Lo | 1edfba9 | 2016-08-27 01:11:57 -0400 | [diff] [blame] | 1049 | vlib_cli_output (vm, "%=40U => %=20U", |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1050 | format_ip4_address, &ip4_addr, |
| 1051 | format_ethernet_address, &mac_addr); |
| 1052 | })); |
John Lo | 1edfba9 | 2016-08-27 01:11:57 -0400 | [diff] [blame] | 1053 | |
| 1054 | hash_foreach_mem (ip6_addr, mac_addr, bd_config->mac_by_ip6, |
| 1055 | ({ |
| 1056 | vlib_cli_output (vm, "%=40U => %=20U", |
| 1057 | format_ip6_address, ip6_addr, |
| 1058 | format_ethernet_address, &mac_addr); |
| 1059 | })); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1060 | /* *INDENT-ON* */ |
| 1061 | } |
| 1062 | } |
| 1063 | } |
John Lo | da1f2c7 | 2017-03-24 20:11:15 -0400 | [diff] [blame] | 1064 | vec_free (as); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1065 | |
| 1066 | if (!printed) |
| 1067 | { |
| 1068 | vlib_cli_output (vm, "no bridge-domains in use"); |
| 1069 | } |
| 1070 | |
| 1071 | done: |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1072 | return error; |
| 1073 | } |
| 1074 | |
Billy McFall | 22aa3e9 | 2016-09-09 08:46:40 -0400 | [diff] [blame] | 1075 | /*? |
| 1076 | * Show a summary of all the bridge-domain instances or detailed view of a |
| 1077 | * single bridge-domain. Bridge-domains are created by adding an interface |
| 1078 | * to a bridge using the '<em>set interface l2 bridge</em>' command. |
| 1079 | * |
| 1080 | * @cliexpar |
| 1081 | * @parblock |
| 1082 | * Example of displaying all bridge-domains: |
| 1083 | * @cliexstart{show bridge-domain} |
| 1084 | * ID Index Learning U-Forwrd UU-Flood Flooding ARP-Term BVI-Intf |
| 1085 | * 0 0 off off off off off local0 |
| 1086 | * 200 1 on on on on off N/A |
| 1087 | * @cliexend |
| 1088 | * |
| 1089 | * Example of displaying details of a single bridge-domains: |
| 1090 | * @cliexstart{show bridge-domain 200 detail} |
| 1091 | * ID Index Learning U-Forwrd UU-Flood Flooding ARP-Term BVI-Intf |
| 1092 | * 200 1 on on on on off N/A |
| 1093 | * |
| 1094 | * Interface Index SHG BVI VLAN-Tag-Rewrite |
| 1095 | * GigabitEthernet0/8/0.200 3 0 - none |
| 1096 | * GigabitEthernet0/9/0.200 4 0 - none |
| 1097 | * @cliexend |
| 1098 | * @endparblock |
| 1099 | ?*/ |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1100 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1101 | VLIB_CLI_COMMAND (bd_show_cli, static) = { |
| 1102 | .path = "show bridge-domain", |
| 1103 | .short_help = "show bridge-domain [bridge-domain-id [detail|int|arp]]", |
| 1104 | .function = bd_show, |
| 1105 | }; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1106 | /* *INDENT-ON* */ |
| 1107 | |
Choonho Son | 0548079 | 2017-03-29 20:07:45 +0900 | [diff] [blame] | 1108 | int |
| 1109 | bd_add_del (l2_bridge_domain_add_del_args_t * a) |
| 1110 | { |
| 1111 | bd_main_t *bdm = &bd_main; |
| 1112 | vlib_main_t *vm = bdm->vlib_main; |
Choonho Son | 0548079 | 2017-03-29 20:07:45 +0900 | [diff] [blame] | 1113 | int rv = 0; |
| 1114 | |
Eyal Bari | b1352ed | 2017-04-07 23:14:17 +0300 | [diff] [blame] | 1115 | u32 bd_index = bd_find_index (bdm, a->bd_id); |
Choonho Son | 0548079 | 2017-03-29 20:07:45 +0900 | [diff] [blame] | 1116 | if (a->is_add) |
| 1117 | { |
Eyal Bari | b1352ed | 2017-04-07 23:14:17 +0300 | [diff] [blame] | 1118 | if (bd_index != ~0) |
| 1119 | return VNET_API_ERROR_BD_ALREADY_EXISTS; |
| 1120 | bd_index = bd_add_bd_index (bdm, a->bd_id); |
Choonho Son | 0548079 | 2017-03-29 20:07:45 +0900 | [diff] [blame] | 1121 | |
Eyal Bari | b1352ed | 2017-04-07 23:14:17 +0300 | [diff] [blame] | 1122 | u32 enable_flags = 0, disable_flags = 0; |
Choonho Son | 0548079 | 2017-03-29 20:07:45 +0900 | [diff] [blame] | 1123 | if (a->flood) |
| 1124 | enable_flags |= L2_FLOOD; |
| 1125 | else |
| 1126 | disable_flags |= L2_FLOOD; |
| 1127 | |
| 1128 | if (a->uu_flood) |
| 1129 | enable_flags |= L2_UU_FLOOD; |
| 1130 | else |
| 1131 | disable_flags |= L2_UU_FLOOD; |
| 1132 | |
| 1133 | if (a->forward) |
| 1134 | enable_flags |= L2_FWD; |
| 1135 | else |
| 1136 | disable_flags |= L2_FWD; |
| 1137 | |
| 1138 | if (a->learn) |
| 1139 | enable_flags |= L2_LEARN; |
| 1140 | else |
| 1141 | disable_flags |= L2_LEARN; |
| 1142 | |
| 1143 | if (a->arp_term) |
| 1144 | enable_flags |= L2_ARP_TERM; |
| 1145 | else |
| 1146 | disable_flags |= L2_ARP_TERM; |
| 1147 | |
| 1148 | if (enable_flags) |
| 1149 | bd_set_flags (vm, bd_index, enable_flags, 1 /* enable */ ); |
| 1150 | |
| 1151 | if (disable_flags) |
| 1152 | bd_set_flags (vm, bd_index, disable_flags, 0 /* disable */ ); |
| 1153 | |
| 1154 | bd_set_mac_age (vm, bd_index, a->mac_age); |
| 1155 | } |
| 1156 | else |
Eyal Bari | b1352ed | 2017-04-07 23:14:17 +0300 | [diff] [blame] | 1157 | { |
| 1158 | if (bd_index == ~0) |
| 1159 | return VNET_API_ERROR_NO_SUCH_ENTRY; |
Jon Loeliger | 1c7d485 | 2017-05-02 11:06:23 -0500 | [diff] [blame] | 1160 | if (bd_index == 0) |
| 1161 | return VNET_API_ERROR_BD_NOT_MODIFIABLE; |
Eyal Bari | b1352ed | 2017-04-07 23:14:17 +0300 | [diff] [blame] | 1162 | if (vec_len (l2input_main.bd_configs[bd_index].members)) |
| 1163 | return VNET_API_ERROR_BD_IN_USE; |
| 1164 | rv = bd_delete (bdm, bd_index); |
| 1165 | } |
Choonho Son | 0548079 | 2017-03-29 20:07:45 +0900 | [diff] [blame] | 1166 | |
| 1167 | return rv; |
| 1168 | } |
| 1169 | |
| 1170 | /** |
| 1171 | Create or delete bridge-domain. |
Choonho Son | 5ee51f8 | 2017-04-05 19:09:52 +0900 | [diff] [blame] | 1172 | The CLI format: |
Choonho Son | 0548079 | 2017-03-29 20:07:45 +0900 | [diff] [blame] | 1173 | create bridge-domain <bd_index> [learn <0|1>] [forward <0|1>] [uu-flood <0|1>] |
| 1174 | [flood <0|1>] [arp-term <0|1>] [mac-age <nn>] [del] |
| 1175 | */ |
| 1176 | |
| 1177 | static clib_error_t * |
| 1178 | bd_add_del_command_fn (vlib_main_t * vm, unformat_input_t * input, |
| 1179 | vlib_cli_command_t * cmd) |
| 1180 | { |
| 1181 | unformat_input_t _line_input, *line_input = &_line_input; |
| 1182 | clib_error_t *error = 0; |
| 1183 | u8 is_add = 1; |
| 1184 | u32 bd_id = ~0; |
Choonho Son | 5ee51f8 | 2017-04-05 19:09:52 +0900 | [diff] [blame] | 1185 | u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0; |
Choonho Son | 0548079 | 2017-03-29 20:07:45 +0900 | [diff] [blame] | 1186 | u32 mac_age = 0; |
| 1187 | l2_bridge_domain_add_del_args_t _a, *a = &_a; |
| 1188 | int rv; |
| 1189 | |
| 1190 | /* Get a line of input. */ |
| 1191 | if (!unformat_user (input, unformat_line_input, line_input)) |
| 1192 | return 0; |
| 1193 | |
| 1194 | while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) |
| 1195 | { |
| 1196 | if (unformat (line_input, "%d", &bd_id)) |
| 1197 | ; |
| 1198 | else if (unformat (line_input, "flood %d", &flood)) |
| 1199 | ; |
| 1200 | else if (unformat (line_input, "uu-flood %d", &uu_flood)) |
| 1201 | ; |
| 1202 | else if (unformat (line_input, "forward %d", &forward)) |
| 1203 | ; |
Choonho Son | 5ee51f8 | 2017-04-05 19:09:52 +0900 | [diff] [blame] | 1204 | else if (unformat (line_input, "learn %d", &learn)) |
| 1205 | ; |
Choonho Son | 0548079 | 2017-03-29 20:07:45 +0900 | [diff] [blame] | 1206 | else if (unformat (line_input, "arp-term %d", &arp_term)) |
| 1207 | ; |
| 1208 | else if (unformat (line_input, "mac-age %d", &mac_age)) |
| 1209 | ; |
| 1210 | else if (unformat (line_input, "del")) |
| 1211 | { |
| 1212 | is_add = 0; |
| 1213 | flood = uu_flood = forward = learn = 0; |
| 1214 | } |
| 1215 | else |
| 1216 | break; |
| 1217 | } |
| 1218 | |
| 1219 | if (bd_id == ~0) |
| 1220 | { |
| 1221 | error = clib_error_return (0, "bridge-domain-id not specified"); |
| 1222 | goto done; |
| 1223 | } |
| 1224 | |
Jon Loeliger | 1c7d485 | 2017-05-02 11:06:23 -0500 | [diff] [blame] | 1225 | if (bd_id == 0) |
| 1226 | { |
| 1227 | error = clib_error_return (0, "bridge domain 0 can not be modified"); |
| 1228 | goto done; |
| 1229 | } |
| 1230 | |
Choonho Son | 0548079 | 2017-03-29 20:07:45 +0900 | [diff] [blame] | 1231 | if (mac_age > 255) |
| 1232 | { |
| 1233 | error = clib_error_return (0, "mac age must be less than 256"); |
| 1234 | goto done; |
| 1235 | } |
| 1236 | |
| 1237 | memset (a, 0, sizeof (*a)); |
| 1238 | a->is_add = is_add; |
| 1239 | a->bd_id = bd_id; |
| 1240 | a->flood = (u8) flood; |
| 1241 | a->uu_flood = (u8) uu_flood; |
| 1242 | a->forward = (u8) forward; |
| 1243 | a->learn = (u8) learn; |
| 1244 | a->arp_term = (u8) arp_term; |
| 1245 | a->mac_age = (u8) mac_age; |
| 1246 | |
| 1247 | rv = bd_add_del (a); |
| 1248 | |
| 1249 | switch (rv) |
| 1250 | { |
| 1251 | case 0: |
| 1252 | if (is_add) |
| 1253 | vlib_cli_output (vm, "bridge-domain %d", bd_id); |
| 1254 | break; |
Eyal Bari | b1352ed | 2017-04-07 23:14:17 +0300 | [diff] [blame] | 1255 | case VNET_API_ERROR_BD_IN_USE: |
| 1256 | error = clib_error_return (0, "bridge domain in use - remove members"); |
| 1257 | goto done; |
Choonho Son | 0548079 | 2017-03-29 20:07:45 +0900 | [diff] [blame] | 1258 | case VNET_API_ERROR_NO_SUCH_ENTRY: |
| 1259 | error = clib_error_return (0, "bridge domain id does not exist"); |
| 1260 | goto done; |
Jon Loeliger | 1c7d485 | 2017-05-02 11:06:23 -0500 | [diff] [blame] | 1261 | case VNET_API_ERROR_BD_NOT_MODIFIABLE: |
| 1262 | error = clib_error_return (0, "bridge domain 0 can not be modified"); |
| 1263 | goto done; |
Choonho Son | 0548079 | 2017-03-29 20:07:45 +0900 | [diff] [blame] | 1264 | default: |
| 1265 | error = clib_error_return (0, "bd_add_del returned %d", rv); |
| 1266 | goto done; |
| 1267 | } |
| 1268 | |
| 1269 | done: |
| 1270 | unformat_free (line_input); |
| 1271 | |
| 1272 | return error; |
| 1273 | } |
| 1274 | |
| 1275 | |
| 1276 | /*? |
| 1277 | * Create/Delete bridge-domain instance |
| 1278 | * |
| 1279 | * @cliexpar |
| 1280 | * @parblock |
| 1281 | * Example of creating bridge-domain 1: |
| 1282 | * @cliexstart{create bridge-domain 1} |
| 1283 | * bridge-domain 1 |
| 1284 | * @cliexend |
| 1285 | * |
| 1286 | * Example of creating bridge-domain 2 with enabling arp-term, mac-age 60: |
| 1287 | * @cliexstart{create bridge-domain 2 arp-term 1 mac-age 60} |
| 1288 | * bridge-domain 2 |
| 1289 | * |
| 1290 | * vpp# show bridge-domain |
| 1291 | * ID Index BSN Age(min) Learning U-Forwrd UU-Flood Flooding ARP-Term BVI-Intf |
| 1292 | * 0 0 0 off off off off off off local0 |
| 1293 | * 1 1 0 off on on off on off N/A |
| 1294 | * 2 2 0 60 on on off on on N/A |
| 1295 | * |
| 1296 | * @cliexend |
| 1297 | * |
| 1298 | * Example of delete bridge-domain 1: |
| 1299 | * @cliexstart{create bridge-domain 1 del} |
| 1300 | * @cliexend |
| 1301 | * @endparblock |
| 1302 | ?*/ |
| 1303 | |
| 1304 | /* *INDENT-OFF* */ |
| 1305 | VLIB_CLI_COMMAND (bd_create_cli, static) = { |
| 1306 | .path = "create bridge-domain", |
| 1307 | .short_help = "create bridge-domain <bridge-domain-id>" |
| 1308 | " [learn <0|1>] [forward <0|1>] [uu-flood <0|1>] [flood <0|1>] [arp-term <0|1>]" |
| 1309 | " [mac-age <nn>] [del]", |
| 1310 | .function = bd_add_del_command_fn, |
| 1311 | }; |
| 1312 | /* *INDENT-ON* */ |
| 1313 | |
| 1314 | |
| 1315 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1316 | /* |
| 1317 | * fd.io coding-style-patch-verification: ON |
| 1318 | * |
| 1319 | * Local Variables: |
| 1320 | * eval: (c-set-style "gnu") |
| 1321 | * End: |
| 1322 | */ |