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; |
Mohsin Kazmi | 5e6f734 | 2019-04-05 17:40:20 +0200 | [diff] [blame] | 55 | bd_config->feature_bitmap = |
| 56 | ~(L2INPUT_FEAT_ARP_TERM | L2INPUT_FEAT_UU_FWD | L2INPUT_FEAT_ARP_UFWD); |
Eyal Bari | b1352ed | 2017-04-07 23:14:17 +0300 | [diff] [blame] | 57 | bd_config->bvi_sw_if_index = ~0; |
Neale Ranns | b474380 | 2018-09-05 09:13:57 -0700 | [diff] [blame] | 58 | bd_config->uu_fwd_sw_if_index = ~0; |
Eyal Bari | b1352ed | 2017-04-07 23:14:17 +0300 | [diff] [blame] | 59 | bd_config->members = 0; |
| 60 | bd_config->flood_count = 0; |
| 61 | bd_config->tun_master_count = 0; |
| 62 | bd_config->tun_normal_count = 0; |
Eyal Bari | b6b04f0 | 2018-07-11 14:01:36 +0300 | [diff] [blame] | 63 | bd_config->no_flood_count = 0; |
Eyal Bari | b1352ed | 2017-04-07 23:14:17 +0300 | [diff] [blame] | 64 | bd_config->mac_by_ip4 = 0; |
| 65 | bd_config->mac_by_ip6 = hash_create_mem (0, sizeof (ip6_address_t), |
| 66 | sizeof (uword)); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 67 | } |
| 68 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 69 | u32 |
Eyal Bari | b1352ed | 2017-04-07 23:14:17 +0300 | [diff] [blame] | 70 | bd_find_index (bd_main_t * bdm, u32 bd_id) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 71 | { |
Eyal Bari | b1352ed | 2017-04-07 23:14:17 +0300 | [diff] [blame] | 72 | u32 *p = (u32 *) hash_get (bdm->bd_index_by_bd_id, bd_id); |
| 73 | if (!p) |
| 74 | return ~0; |
| 75 | return p[0]; |
| 76 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 77 | |
Eyal Bari | b1352ed | 2017-04-07 23:14:17 +0300 | [diff] [blame] | 78 | u32 |
| 79 | bd_add_bd_index (bd_main_t * bdm, u32 bd_id) |
| 80 | { |
| 81 | ASSERT (!hash_get (bdm->bd_index_by_bd_id, bd_id)); |
| 82 | u32 rv = clib_bitmap_first_clear (bdm->bd_index_bitmap); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 83 | |
Eyal Bari | b1352ed | 2017-04-07 23:14:17 +0300 | [diff] [blame] | 84 | /* mark this index taken */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 85 | bdm->bd_index_bitmap = clib_bitmap_set (bdm->bd_index_bitmap, rv, 1); |
| 86 | |
| 87 | hash_set (bdm->bd_index_by_bd_id, bd_id, rv); |
| 88 | |
| 89 | vec_validate (l2input_main.bd_configs, rv); |
| 90 | l2input_main.bd_configs[rv].bd_id = bd_id; |
Jerome Tollet | 5f93e3b | 2020-12-18 09:44:24 +0100 | [diff] [blame] | 91 | l2input_main.bd_configs[rv].learn_limit = |
| 92 | l2learn_main.bd_default_learn_limit; |
| 93 | l2input_main.bd_configs[rv].learn_count = 0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 94 | |
| 95 | return rv; |
| 96 | } |
| 97 | |
John Lo | e26c81f | 2019-01-07 15:16:33 -0500 | [diff] [blame] | 98 | static inline void |
| 99 | bd_free_ip_mac_tables (l2_bridge_domain_t * bd) |
| 100 | { |
| 101 | u64 mac_addr; |
| 102 | ip6_address_t *ip6_addr_key; |
| 103 | |
| 104 | hash_free (bd->mac_by_ip4); |
| 105 | /* *INDENT-OFF* */ |
| 106 | hash_foreach_mem (ip6_addr_key, mac_addr, bd->mac_by_ip6, |
| 107 | ({ |
| 108 | clib_mem_free (ip6_addr_key); /* free memory used for ip6 addr key */ |
| 109 | })); |
| 110 | /* *INDENT-ON* */ |
| 111 | hash_free (bd->mac_by_ip6); |
| 112 | } |
| 113 | |
Eyal Bari | b1352ed | 2017-04-07 23:14:17 +0300 | [diff] [blame] | 114 | static int |
| 115 | bd_delete (bd_main_t * bdm, u32 bd_index) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 116 | { |
John Lo | d77630a | 2017-04-28 00:33:36 -0400 | [diff] [blame] | 117 | l2_bridge_domain_t *bd = &l2input_main.bd_configs[bd_index]; |
| 118 | u32 bd_id = bd->bd_id; |
Eyal Bari | afc47aa | 2017-04-20 14:45:17 +0300 | [diff] [blame] | 119 | |
John Lo | d48c8eb | 2017-05-05 12:35:25 -0400 | [diff] [blame] | 120 | /* flush non-static MACs in BD and removed bd_id from hash table */ |
| 121 | l2fib_flush_bd_mac (vlib_get_main (), bd_index); |
Eyal Bari | b1352ed | 2017-04-07 23:14:17 +0300 | [diff] [blame] | 122 | hash_unset (bdm->bd_index_by_bd_id, bd_id); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 123 | |
| 124 | /* mark this index clear */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 125 | 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] | 126 | |
John Lo | d77630a | 2017-04-28 00:33:36 -0400 | [diff] [blame] | 127 | /* clear BD config for reuse: bd_id to -1 and clear feature_bitmap */ |
| 128 | bd->bd_id = ~0; |
| 129 | bd->feature_bitmap = 0; |
Jerome Tollet | 5f93e3b | 2020-12-18 09:44:24 +0100 | [diff] [blame] | 130 | bd->learn_limit = 0; |
| 131 | bd->learn_count = ~0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 132 | |
Jerome Tollet | 4830414 | 2017-09-05 12:13:22 +0100 | [diff] [blame] | 133 | /* free BD tag */ |
| 134 | vec_free (bd->bd_tag); |
| 135 | |
John Lo | d48c8eb | 2017-05-05 12:35:25 -0400 | [diff] [blame] | 136 | /* free memory used by BD */ |
John Lo | d77630a | 2017-04-28 00:33:36 -0400 | [diff] [blame] | 137 | vec_free (bd->members); |
John Lo | e26c81f | 2019-01-07 15:16:33 -0500 | [diff] [blame] | 138 | bd_free_ip_mac_tables (bd); |
John Lo | da1f2c7 | 2017-03-24 20:11:15 -0400 | [diff] [blame] | 139 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 140 | return 0; |
| 141 | } |
| 142 | |
Eyal Bari | c5b1360 | 2016-11-24 19:42:43 +0200 | [diff] [blame] | 143 | static void |
| 144 | update_flood_count (l2_bridge_domain_t * bd_config) |
| 145 | { |
Neale Ranns | 87dad11 | 2018-04-09 01:53:01 -0700 | [diff] [blame] | 146 | bd_config->flood_count = (vec_len (bd_config->members) - |
| 147 | (bd_config->tun_master_count ? |
| 148 | bd_config->tun_normal_count : 0)); |
| 149 | bd_config->flood_count -= bd_config->no_flood_count; |
Eyal Bari | c5b1360 | 2016-11-24 19:42:43 +0200 | [diff] [blame] | 150 | } |
| 151 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 152 | void |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 153 | 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] | 154 | { |
Neale Ranns | 87dad11 | 2018-04-09 01:53:01 -0700 | [diff] [blame] | 155 | u32 ix = 0; |
Eyal Bari | c5b1360 | 2016-11-24 19:42:43 +0200 | [diff] [blame] | 156 | vnet_sw_interface_t *sw_if = vnet_get_sw_interface |
| 157 | (vnet_get_main (), member->sw_if_index); |
| 158 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 159 | /* |
| 160 | * Add one element to the vector |
Neale Ranns | 87dad11 | 2018-04-09 01:53:01 -0700 | [diff] [blame] | 161 | * vector is ordered [ bvi, normal/tun_masters..., tun_normals... no_flood] |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 162 | * When flooding, the bvi interface (if present) must be the last member |
| 163 | * processed due to how BVI processing can change the packet. To enable |
| 164 | * this order, we make the bvi interface the first in the vector and |
Neale Ranns | 87dad11 | 2018-04-09 01:53:01 -0700 | [diff] [blame] | 165 | * flooding walks the vector in reverse. The flood-count determines where |
| 166 | * in the member list to start the walk from. |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 167 | */ |
Eyal Bari | c5b1360 | 2016-11-24 19:42:43 +0200 | [diff] [blame] | 168 | switch (sw_if->flood_class) |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 169 | { |
Neale Ranns | 87dad11 | 2018-04-09 01:53:01 -0700 | [diff] [blame] | 170 | case VNET_FLOOD_CLASS_NO_FLOOD: |
| 171 | bd_config->no_flood_count++; |
| 172 | ix = vec_len (bd_config->members); |
| 173 | break; |
| 174 | case VNET_FLOOD_CLASS_BVI: |
| 175 | ix = 0; |
| 176 | break; |
Eyal Bari | c5b1360 | 2016-11-24 19:42:43 +0200 | [diff] [blame] | 177 | case VNET_FLOOD_CLASS_TUNNEL_MASTER: |
| 178 | bd_config->tun_master_count++; |
| 179 | /* Fall through */ |
Eyal Bari | c5b1360 | 2016-11-24 19:42:43 +0200 | [diff] [blame] | 180 | case VNET_FLOOD_CLASS_NORMAL: |
Neale Ranns | 87dad11 | 2018-04-09 01:53:01 -0700 | [diff] [blame] | 181 | ix = (vec_len (bd_config->members) - |
| 182 | bd_config->tun_normal_count - bd_config->no_flood_count); |
Eyal Bari | c5b1360 | 2016-11-24 19:42:43 +0200 | [diff] [blame] | 183 | break; |
| 184 | case VNET_FLOOD_CLASS_TUNNEL_NORMAL: |
Neale Ranns | 87dad11 | 2018-04-09 01:53:01 -0700 | [diff] [blame] | 185 | ix = (vec_len (bd_config->members) - bd_config->no_flood_count); |
Eyal Bari | c5b1360 | 2016-11-24 19:42:43 +0200 | [diff] [blame] | 186 | bd_config->tun_normal_count++; |
| 187 | break; |
| 188 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 189 | |
Eyal Bari | c5b1360 | 2016-11-24 19:42:43 +0200 | [diff] [blame] | 190 | vec_insert_elts (bd_config->members, member, 1, ix); |
| 191 | update_flood_count (bd_config); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 192 | } |
| 193 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 194 | #define BD_REMOVE_ERROR_OK 0 |
| 195 | #define BD_REMOVE_ERROR_NOT_FOUND 1 |
| 196 | |
| 197 | u32 |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 198 | 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] | 199 | { |
| 200 | u32 ix; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 201 | |
| 202 | /* Find and delete the member */ |
| 203 | vec_foreach_index (ix, bd_config->members) |
| 204 | { |
Eyal Bari | c5b1360 | 2016-11-24 19:42:43 +0200 | [diff] [blame] | 205 | l2_flood_member_t *m = vec_elt_at_index (bd_config->members, ix); |
| 206 | if (m->sw_if_index == sw_if_index) |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 207 | { |
Eyal Bari | c5b1360 | 2016-11-24 19:42:43 +0200 | [diff] [blame] | 208 | vnet_sw_interface_t *sw_if = vnet_get_sw_interface |
| 209 | (vnet_get_main (), sw_if_index); |
| 210 | |
| 211 | if (sw_if->flood_class != VNET_FLOOD_CLASS_NORMAL) |
| 212 | { |
| 213 | if (sw_if->flood_class == VNET_FLOOD_CLASS_TUNNEL_MASTER) |
| 214 | bd_config->tun_master_count--; |
| 215 | else if (sw_if->flood_class == VNET_FLOOD_CLASS_TUNNEL_NORMAL) |
| 216 | bd_config->tun_normal_count--; |
Eyal Bari | b6b04f0 | 2018-07-11 14:01:36 +0300 | [diff] [blame] | 217 | else if (sw_if->flood_class == VNET_FLOOD_CLASS_NO_FLOOD) |
| 218 | bd_config->no_flood_count--; |
Eyal Bari | c5b1360 | 2016-11-24 19:42:43 +0200 | [diff] [blame] | 219 | } |
Eyal Bari | 25b3667 | 2017-03-02 10:43:19 +0200 | [diff] [blame] | 220 | vec_delete (bd_config->members, 1, ix); |
Eyal Bari | c5b1360 | 2016-11-24 19:42:43 +0200 | [diff] [blame] | 221 | update_flood_count (bd_config); |
| 222 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 223 | return BD_REMOVE_ERROR_OK; |
| 224 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 225 | } |
| 226 | |
| 227 | return BD_REMOVE_ERROR_NOT_FOUND; |
| 228 | } |
| 229 | |
| 230 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 231 | clib_error_t * |
| 232 | l2bd_init (vlib_main_t * vm) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 233 | { |
| 234 | bd_main_t *bdm = &bd_main; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 235 | bdm->bd_index_by_bd_id = hash_create (0, sizeof (uword)); |
| 236 | /* |
Dave Barach | 11fb09e | 2020-08-06 12:10:09 -0400 | [diff] [blame] | 237 | * create a placeholder bd with bd_id of 0 and bd_index of 0 with feature set |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 238 | * to packet drop only. Thus, packets received from any L2 interface with |
| 239 | * uninitialized bd_index of 0 can be dropped safely. |
| 240 | */ |
Eyal Bari | b1352ed | 2017-04-07 23:14:17 +0300 | [diff] [blame] | 241 | u32 bd_index = bd_add_bd_index (bdm, 0); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 242 | ASSERT (bd_index == 0); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 243 | l2input_main.bd_configs[0].feature_bitmap = L2INPUT_FEAT_DROP; |
Choonho Son | 0548079 | 2017-03-29 20:07:45 +0900 | [diff] [blame] | 244 | |
| 245 | bdm->vlib_main = vm; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 246 | return 0; |
| 247 | } |
| 248 | |
| 249 | VLIB_INIT_FUNCTION (l2bd_init); |
| 250 | |
Neale Ranns | 47a3d99 | 2020-09-29 15:38:51 +0000 | [diff] [blame] | 251 | l2_bridge_domain_t * |
| 252 | bd_get (u32 bd_index) |
| 253 | { |
| 254 | if (bd_index < vec_len (l2input_main.bd_configs)) |
| 255 | return (vec_elt_at_index (l2input_main.bd_configs, bd_index)); |
| 256 | return (NULL); |
| 257 | } |
| 258 | |
| 259 | u32 |
| 260 | bd_input_walk (u32 bd_index, bd_input_walk_fn_t fn, void *data) |
| 261 | { |
| 262 | l2_flood_member_t *member; |
| 263 | l2_bridge_domain_t *bd; |
| 264 | u32 sw_if_index; |
| 265 | |
| 266 | sw_if_index = ~0; |
| 267 | bd = bd_get (bd_index); |
| 268 | |
| 269 | ASSERT (bd); |
| 270 | |
| 271 | vec_foreach (member, bd->members) |
| 272 | { |
| 273 | if (WALK_STOP == fn (bd_index, member->sw_if_index)) |
| 274 | { |
| 275 | sw_if_index = member->sw_if_index; |
| 276 | break; |
| 277 | } |
| 278 | } |
| 279 | |
| 280 | return (sw_if_index); |
| 281 | } |
| 282 | |
| 283 | static void |
| 284 | b2_input_recache (u32 bd_index) |
| 285 | { |
| 286 | bd_input_walk (bd_index, l2input_recache, NULL); |
| 287 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 288 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 289 | /** |
Chris Luke | 16bcf7d | 2016-09-01 14:31:46 -0400 | [diff] [blame] | 290 | Set the learn/forward/flood flags for the bridge domain. |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 291 | Return 0 if ok, non-zero if for an error. |
| 292 | */ |
| 293 | u32 |
Neale Ranns | b474380 | 2018-09-05 09:13:57 -0700 | [diff] [blame] | 294 | bd_set_flags (vlib_main_t * vm, u32 bd_index, bd_flags_t flags, u32 enable) |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 295 | { |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 296 | |
Eyal Bari | afc47aa | 2017-04-20 14:45:17 +0300 | [diff] [blame] | 297 | l2_bridge_domain_t *bd_config = l2input_bd_config (bd_index); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 298 | bd_validate (bd_config); |
Eyal Bari | afc47aa | 2017-04-20 14:45:17 +0300 | [diff] [blame] | 299 | u32 feature_bitmap = 0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 300 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 301 | if (flags & L2_LEARN) |
| 302 | { |
| 303 | feature_bitmap |= L2INPUT_FEAT_LEARN; |
| 304 | } |
| 305 | if (flags & L2_FWD) |
| 306 | { |
| 307 | feature_bitmap |= L2INPUT_FEAT_FWD; |
| 308 | } |
| 309 | if (flags & L2_FLOOD) |
| 310 | { |
| 311 | feature_bitmap |= L2INPUT_FEAT_FLOOD; |
| 312 | } |
| 313 | if (flags & L2_UU_FLOOD) |
| 314 | { |
| 315 | feature_bitmap |= L2INPUT_FEAT_UU_FLOOD; |
| 316 | } |
| 317 | if (flags & L2_ARP_TERM) |
| 318 | { |
| 319 | feature_bitmap |= L2INPUT_FEAT_ARP_TERM; |
| 320 | } |
Mohsin Kazmi | 5e6f734 | 2019-04-05 17:40:20 +0200 | [diff] [blame] | 321 | if (flags & L2_ARP_UFWD) |
| 322 | { |
| 323 | feature_bitmap |= L2INPUT_FEAT_ARP_UFWD; |
| 324 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 325 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 326 | if (enable) |
| 327 | { |
| 328 | bd_config->feature_bitmap |= feature_bitmap; |
| 329 | } |
| 330 | else |
| 331 | { |
| 332 | bd_config->feature_bitmap &= ~feature_bitmap; |
| 333 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 334 | |
Neale Ranns | 47a3d99 | 2020-09-29 15:38:51 +0000 | [diff] [blame] | 335 | b2_input_recache (bd_index); |
| 336 | |
John Lo | 8d00fff | 2017-08-03 00:35:36 -0400 | [diff] [blame] | 337 | return bd_config->feature_bitmap; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 338 | } |
| 339 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 340 | /** |
Damjan Marion | d171d48 | 2016-12-05 14:16:38 +0100 | [diff] [blame] | 341 | Set the mac age for the bridge domain. |
| 342 | */ |
| 343 | void |
| 344 | bd_set_mac_age (vlib_main_t * vm, u32 bd_index, u8 age) |
| 345 | { |
| 346 | l2_bridge_domain_t *bd_config; |
| 347 | int enable = 0; |
| 348 | |
| 349 | vec_validate (l2input_main.bd_configs, bd_index); |
| 350 | bd_config = vec_elt_at_index (l2input_main.bd_configs, bd_index); |
| 351 | bd_config->mac_age = age; |
Neale Ranns | 47a3d99 | 2020-09-29 15:38:51 +0000 | [diff] [blame] | 352 | b2_input_recache (bd_index); |
Damjan Marion | d171d48 | 2016-12-05 14:16:38 +0100 | [diff] [blame] | 353 | |
| 354 | /* check if there is at least one bd with mac aging enabled */ |
| 355 | vec_foreach (bd_config, l2input_main.bd_configs) |
Eyal Bari | fead670 | 2017-04-04 04:46:32 +0300 | [diff] [blame] | 356 | enable |= bd_config->bd_id != ~0 && bd_config->mac_age != 0; |
Damjan Marion | d171d48 | 2016-12-05 14:16:38 +0100 | [diff] [blame] | 357 | |
| 358 | vlib_process_signal_event (vm, l2fib_mac_age_scanner_process_node.index, |
| 359 | enable ? L2_MAC_AGE_PROCESS_EVENT_START : |
| 360 | L2_MAC_AGE_PROCESS_EVENT_STOP, 0); |
| 361 | } |
| 362 | |
Jerome Tollet | 50570ec | 2017-09-14 12:53:56 +0100 | [diff] [blame] | 363 | /** |
Jerome Tollet | 5f93e3b | 2020-12-18 09:44:24 +0100 | [diff] [blame] | 364 | Set learn limit for the bridge domain. |
| 365 | */ |
| 366 | void |
| 367 | bd_set_learn_limit (vlib_main_t *vm, u32 bd_index, u32 learn_limit) |
| 368 | { |
| 369 | l2_bridge_domain_t *bd_config; |
| 370 | vec_validate (l2input_main.bd_configs, bd_index); |
| 371 | bd_config = vec_elt_at_index (l2input_main.bd_configs, bd_index); |
| 372 | bd_config->learn_limit = learn_limit; |
| 373 | } |
| 374 | |
| 375 | /** |
Jerome Tollet | 50570ec | 2017-09-14 12:53:56 +0100 | [diff] [blame] | 376 | Set the tag for the bridge domain. |
| 377 | */ |
Jerome Tollet | 50570ec | 2017-09-14 12:53:56 +0100 | [diff] [blame] | 378 | static void |
Jerome Tollet | 4830414 | 2017-09-05 12:13:22 +0100 | [diff] [blame] | 379 | bd_set_bd_tag (vlib_main_t * vm, u32 bd_index, u8 * bd_tag) |
| 380 | { |
| 381 | u8 *old; |
| 382 | l2_bridge_domain_t *bd_config; |
| 383 | vec_validate (l2input_main.bd_configs, bd_index); |
| 384 | bd_config = vec_elt_at_index (l2input_main.bd_configs, bd_index); |
| 385 | |
| 386 | old = bd_config->bd_tag; |
| 387 | |
| 388 | if (bd_tag[0]) |
| 389 | { |
| 390 | bd_config->bd_tag = format (0, "%s%c", bd_tag, 0); |
| 391 | } |
| 392 | else |
| 393 | { |
| 394 | bd_config->bd_tag = NULL; |
| 395 | } |
| 396 | |
| 397 | vec_free (old); |
| 398 | } |
| 399 | |
Damjan Marion | d171d48 | 2016-12-05 14:16:38 +0100 | [diff] [blame] | 400 | /** |
Chris Luke | 16bcf7d | 2016-09-01 14:31:46 -0400 | [diff] [blame] | 401 | Set bridge-domain learn enable/disable. |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 402 | The CLI format is: |
| 403 | set bridge-domain learn <bd_id> [disable] |
| 404 | */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 405 | static clib_error_t * |
| 406 | bd_learn (vlib_main_t * vm, |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 407 | unformat_input_t * input, vlib_cli_command_t * cmd) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 408 | { |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 409 | bd_main_t *bdm = &bd_main; |
| 410 | clib_error_t *error = 0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 411 | u32 bd_index, bd_id; |
| 412 | u32 enable; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 413 | uword *p; |
| 414 | |
| 415 | if (!unformat (input, "%d", &bd_id)) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 416 | { |
| 417 | error = clib_error_return (0, "expecting bridge-domain id but got `%U'", |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 418 | format_unformat_error, input); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 419 | goto done; |
| 420 | } |
| 421 | |
Jon Loeliger | 1c7d485 | 2017-05-02 11:06:23 -0500 | [diff] [blame] | 422 | if (bd_id == 0) |
| 423 | return clib_error_return (0, |
| 424 | "No operations on the default bridge domain are supported"); |
| 425 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 426 | p = hash_get (bdm->bd_index_by_bd_id, bd_id); |
| 427 | |
| 428 | if (p == 0) |
| 429 | return clib_error_return (0, "No such bridge domain %d", bd_id); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 430 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 431 | bd_index = p[0]; |
| 432 | |
| 433 | enable = 1; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 434 | if (unformat (input, "disable")) |
| 435 | { |
| 436 | enable = 0; |
| 437 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 438 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 439 | /* set the bridge domain flag */ |
John Lo | 8d00fff | 2017-08-03 00:35:36 -0400 | [diff] [blame] | 440 | bd_set_flags (vm, bd_index, L2_LEARN, enable); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 441 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 442 | done: |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 443 | return error; |
| 444 | } |
| 445 | |
Billy McFall | 22aa3e9 | 2016-09-09 08:46:40 -0400 | [diff] [blame] | 446 | /*? |
| 447 | * Layer 2 learning can be enabled and disabled on each |
| 448 | * interface and on each bridge-domain. Use this command to |
| 449 | * manage bridge-domains. It is enabled by default. |
| 450 | * |
| 451 | * @cliexpar |
| 452 | * Example of how to enable learning (where 200 is the bridge-domain-id): |
| 453 | * @cliexcmd{set bridge-domain learn 200} |
| 454 | * Example of how to disable learning (where 200 is the bridge-domain-id): |
| 455 | * @cliexcmd{set bridge-domain learn 200 disable} |
| 456 | ?*/ |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 457 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 458 | VLIB_CLI_COMMAND (bd_learn_cli, static) = { |
| 459 | .path = "set bridge-domain learn", |
| 460 | .short_help = "set bridge-domain learn <bridge-domain-id> [disable]", |
| 461 | .function = bd_learn, |
| 462 | }; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 463 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 464 | |
Jerome Tollet | 5f93e3b | 2020-12-18 09:44:24 +0100 | [diff] [blame] | 465 | static clib_error_t * |
| 466 | bd_default_learn_limit (vlib_main_t *vm, unformat_input_t *input, |
| 467 | vlib_cli_command_t *cmd) |
| 468 | { |
| 469 | l2learn_main_t *l2m = &l2learn_main; |
| 470 | clib_error_t *error = 0; |
| 471 | u32 learn_limit; |
| 472 | |
| 473 | if (!unformat (input, "%d", &learn_limit)) |
| 474 | { |
| 475 | error = clib_error_return ( |
| 476 | 0, "expecting per bridge-domain max entry number got`%U'", |
| 477 | format_unformat_error, input); |
| 478 | goto done; |
| 479 | } |
| 480 | |
| 481 | l2m->bd_default_learn_limit = learn_limit; |
| 482 | |
| 483 | done: |
| 484 | return error; |
| 485 | } |
| 486 | |
| 487 | VLIB_CLI_COMMAND (bd_default_learn_limit_cli, static) = { |
| 488 | .path = "set bridge-domain default-learn-limit", |
| 489 | .short_help = "set bridge-domain default-learn-limit <maxentries>", |
| 490 | .function = bd_default_learn_limit, |
| 491 | }; |
| 492 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 493 | /** |
Chris Luke | 16bcf7d | 2016-09-01 14:31:46 -0400 | [diff] [blame] | 494 | Set bridge-domain forward enable/disable. |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 495 | The CLI format is: |
| 496 | set bridge-domain forward <bd_index> [disable] |
| 497 | */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 498 | static clib_error_t * |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 499 | 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] | 500 | { |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 501 | bd_main_t *bdm = &bd_main; |
| 502 | clib_error_t *error = 0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 503 | u32 bd_index, bd_id; |
| 504 | u32 enable; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 505 | uword *p; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 506 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 507 | if (!unformat (input, "%d", &bd_id)) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 508 | { |
| 509 | error = clib_error_return (0, "expecting bridge-domain id but got `%U'", |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 510 | format_unformat_error, input); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 511 | goto done; |
| 512 | } |
| 513 | |
Jon Loeliger | 1c7d485 | 2017-05-02 11:06:23 -0500 | [diff] [blame] | 514 | if (bd_id == 0) |
| 515 | return clib_error_return (0, |
| 516 | "No operations on the default bridge domain are supported"); |
| 517 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 518 | p = hash_get (bdm->bd_index_by_bd_id, bd_id); |
| 519 | |
| 520 | if (p == 0) |
| 521 | return clib_error_return (0, "No such bridge domain %d", bd_id); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 522 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 523 | bd_index = p[0]; |
| 524 | |
| 525 | enable = 1; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 526 | if (unformat (input, "disable")) |
| 527 | { |
| 528 | enable = 0; |
| 529 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 530 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 531 | /* set the bridge domain flag */ |
John Lo | 8d00fff | 2017-08-03 00:35:36 -0400 | [diff] [blame] | 532 | bd_set_flags (vm, bd_index, L2_FWD, enable); |
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 | done: |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 535 | return error; |
| 536 | } |
| 537 | |
Billy McFall | 22aa3e9 | 2016-09-09 08:46:40 -0400 | [diff] [blame] | 538 | |
| 539 | /*? |
| 540 | * Layer 2 unicast forwarding can be enabled and disabled on each |
| 541 | * interface and on each bridge-domain. Use this command to |
| 542 | * manage bridge-domains. It is enabled by default. |
| 543 | * |
| 544 | * @cliexpar |
| 545 | * Example of how to enable forwarding (where 200 is the bridge-domain-id): |
| 546 | * @cliexcmd{set bridge-domain forward 200} |
| 547 | * Example of how to disable forwarding (where 200 is the bridge-domain-id): |
| 548 | * @cliexcmd{set bridge-domain forward 200 disable} |
| 549 | ?*/ |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 550 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 551 | VLIB_CLI_COMMAND (bd_fwd_cli, static) = { |
| 552 | .path = "set bridge-domain forward", |
| 553 | .short_help = "set bridge-domain forward <bridge-domain-id> [disable]", |
| 554 | .function = bd_fwd, |
| 555 | }; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 556 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 557 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 558 | /** |
Chris Luke | 16bcf7d | 2016-09-01 14:31:46 -0400 | [diff] [blame] | 559 | Set bridge-domain flood enable/disable. |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 560 | The CLI format is: |
| 561 | set bridge-domain flood <bd_index> [disable] |
| 562 | */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 563 | static clib_error_t * |
| 564 | bd_flood (vlib_main_t * vm, |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 565 | unformat_input_t * input, vlib_cli_command_t * cmd) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 566 | { |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 567 | bd_main_t *bdm = &bd_main; |
| 568 | clib_error_t *error = 0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 569 | u32 bd_index, bd_id; |
| 570 | u32 enable; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 571 | uword *p; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 572 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 573 | if (!unformat (input, "%d", &bd_id)) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 574 | { |
| 575 | error = clib_error_return (0, "expecting bridge-domain id but got `%U'", |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 576 | format_unformat_error, input); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 577 | goto done; |
| 578 | } |
| 579 | |
Jon Loeliger | 1c7d485 | 2017-05-02 11:06:23 -0500 | [diff] [blame] | 580 | if (bd_id == 0) |
| 581 | return clib_error_return (0, |
| 582 | "No operations on the default bridge domain are supported"); |
| 583 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 584 | p = hash_get (bdm->bd_index_by_bd_id, bd_id); |
| 585 | |
| 586 | if (p == 0) |
| 587 | return clib_error_return (0, "No such bridge domain %d", bd_id); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 588 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 589 | bd_index = p[0]; |
| 590 | |
| 591 | enable = 1; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 592 | if (unformat (input, "disable")) |
| 593 | { |
| 594 | enable = 0; |
| 595 | } |
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 | /* set the bridge domain flag */ |
John Lo | 8d00fff | 2017-08-03 00:35:36 -0400 | [diff] [blame] | 598 | bd_set_flags (vm, bd_index, L2_FLOOD, enable); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 599 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 600 | done: |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 601 | return error; |
| 602 | } |
| 603 | |
Billy McFall | 22aa3e9 | 2016-09-09 08:46:40 -0400 | [diff] [blame] | 604 | /*? |
| 605 | * Layer 2 flooding can be enabled and disabled on each |
| 606 | * interface and on each bridge-domain. Use this command to |
| 607 | * manage bridge-domains. It is enabled by default. |
| 608 | * |
| 609 | * @cliexpar |
| 610 | * Example of how to enable flooding (where 200 is the bridge-domain-id): |
| 611 | * @cliexcmd{set bridge-domain flood 200} |
| 612 | * Example of how to disable flooding (where 200 is the bridge-domain-id): |
| 613 | * @cliexcmd{set bridge-domain flood 200 disable} |
| 614 | ?*/ |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 615 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 616 | VLIB_CLI_COMMAND (bd_flood_cli, static) = { |
| 617 | .path = "set bridge-domain flood", |
| 618 | .short_help = "set bridge-domain flood <bridge-domain-id> [disable]", |
| 619 | .function = bd_flood, |
| 620 | }; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 621 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 622 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 623 | /** |
Andrey "Zed" Zaikin | 701625b | 2018-04-18 17:07:07 +0300 | [diff] [blame] | 624 | Set bridge-domain unknown-unicast flood enable/disable. |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 625 | The CLI format is: |
| 626 | set bridge-domain uu-flood <bd_index> [disable] |
| 627 | */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 628 | static clib_error_t * |
| 629 | bd_uu_flood (vlib_main_t * vm, |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 630 | unformat_input_t * input, vlib_cli_command_t * cmd) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 631 | { |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 632 | bd_main_t *bdm = &bd_main; |
| 633 | clib_error_t *error = 0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 634 | u32 bd_index, bd_id; |
| 635 | u32 enable; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 636 | uword *p; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 637 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 638 | if (!unformat (input, "%d", &bd_id)) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 639 | { |
| 640 | error = clib_error_return (0, "expecting bridge-domain id but got `%U'", |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 641 | format_unformat_error, input); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 642 | goto done; |
| 643 | } |
| 644 | |
Jon Loeliger | 1c7d485 | 2017-05-02 11:06:23 -0500 | [diff] [blame] | 645 | if (bd_id == 0) |
| 646 | return clib_error_return (0, |
| 647 | "No operations on the default bridge domain are supported"); |
| 648 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 649 | p = hash_get (bdm->bd_index_by_bd_id, bd_id); |
| 650 | |
| 651 | if (p == 0) |
| 652 | return clib_error_return (0, "No such bridge domain %d", bd_id); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 653 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 654 | bd_index = p[0]; |
| 655 | |
| 656 | enable = 1; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 657 | if (unformat (input, "disable")) |
| 658 | { |
| 659 | enable = 0; |
| 660 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 661 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 662 | /* set the bridge domain flag */ |
John Lo | 8d00fff | 2017-08-03 00:35:36 -0400 | [diff] [blame] | 663 | bd_set_flags (vm, bd_index, L2_UU_FLOOD, enable); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 664 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 665 | done: |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 666 | return error; |
| 667 | } |
| 668 | |
Billy McFall | 22aa3e9 | 2016-09-09 08:46:40 -0400 | [diff] [blame] | 669 | /*? |
| 670 | * Layer 2 unknown-unicast flooding can be enabled and disabled on each |
| 671 | * bridge-domain. It is enabled by default. |
| 672 | * |
| 673 | * @cliexpar |
| 674 | * Example of how to enable unknown-unicast flooding (where 200 is the |
| 675 | * bridge-domain-id): |
| 676 | * @cliexcmd{set bridge-domain uu-flood 200} |
| 677 | * Example of how to disable unknown-unicast flooding (where 200 is the bridge-domain-id): |
| 678 | * @cliexcmd{set bridge-domain uu-flood 200 disable} |
| 679 | ?*/ |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 680 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 681 | VLIB_CLI_COMMAND (bd_uu_flood_cli, static) = { |
| 682 | .path = "set bridge-domain uu-flood", |
| 683 | .short_help = "set bridge-domain uu-flood <bridge-domain-id> [disable]", |
| 684 | .function = bd_uu_flood, |
| 685 | }; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 686 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 687 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 688 | /** |
Mohsin Kazmi | 5e6f734 | 2019-04-05 17:40:20 +0200 | [diff] [blame] | 689 | Set bridge-domain arp-unicast forward enable/disable. |
| 690 | The CLI format is: |
| 691 | set bridge-domain arp-ufwd <bd_index> [disable] |
| 692 | */ |
| 693 | static clib_error_t * |
| 694 | bd_arp_ufwd (vlib_main_t * vm, |
| 695 | unformat_input_t * input, vlib_cli_command_t * cmd) |
| 696 | { |
| 697 | bd_main_t *bdm = &bd_main; |
| 698 | clib_error_t *error = 0; |
| 699 | u32 bd_index, bd_id; |
| 700 | u32 enable; |
| 701 | uword *p; |
| 702 | |
| 703 | if (!unformat (input, "%d", &bd_id)) |
| 704 | { |
| 705 | error = clib_error_return (0, "expecting bridge-domain id but got `%U'", |
| 706 | format_unformat_error, input); |
| 707 | goto done; |
| 708 | } |
| 709 | |
| 710 | if (bd_id == 0) |
| 711 | return clib_error_return (0, |
| 712 | "No operations on the default bridge domain are supported"); |
| 713 | |
| 714 | p = hash_get (bdm->bd_index_by_bd_id, bd_id); |
| 715 | |
| 716 | if (p == 0) |
| 717 | return clib_error_return (0, "No such bridge domain %d", bd_id); |
| 718 | |
| 719 | bd_index = p[0]; |
| 720 | |
| 721 | enable = 1; |
| 722 | if (unformat (input, "disable")) |
| 723 | { |
| 724 | enable = 0; |
| 725 | } |
| 726 | |
| 727 | /* set the bridge domain flag */ |
| 728 | bd_set_flags (vm, bd_index, L2_ARP_UFWD, enable); |
| 729 | |
| 730 | done: |
| 731 | return error; |
| 732 | } |
| 733 | |
| 734 | /*? |
| 735 | * Layer 2 arp-unicast forwarding can be enabled and disabled on each |
| 736 | * bridge-domain. It is disabled by default. |
| 737 | * |
| 738 | * @cliexpar |
| 739 | * Example of how to enable arp-unicast forwarding (where 200 is the |
| 740 | * bridge-domain-id): |
| 741 | * @cliexcmd{set bridge-domain arp-ufwd 200} |
| 742 | * Example of how to disable arp-unicast forwarding (where 200 is the bridge-domain-id): |
| 743 | * @cliexcmd{set bridge-domain arp-ufwd 200 disable} |
| 744 | ?*/ |
| 745 | /* *INDENT-OFF* */ |
| 746 | VLIB_CLI_COMMAND (bd_arp_ufwd_cli, static) = { |
| 747 | .path = "set bridge-domain arp-ufwd", |
| 748 | .short_help = "set bridge-domain arp-ufwd <bridge-domain-id> [disable]", |
| 749 | .function = bd_arp_ufwd, |
| 750 | }; |
| 751 | /* *INDENT-ON* */ |
| 752 | |
| 753 | /** |
Chris Luke | 16bcf7d | 2016-09-01 14:31:46 -0400 | [diff] [blame] | 754 | Set bridge-domain arp term enable/disable. |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 755 | The CLI format is: |
| 756 | set bridge-domain arp term <bridge-domain-id> [disable] |
| 757 | */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 758 | static clib_error_t * |
| 759 | bd_arp_term (vlib_main_t * vm, |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 760 | unformat_input_t * input, vlib_cli_command_t * cmd) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 761 | { |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 762 | bd_main_t *bdm = &bd_main; |
| 763 | clib_error_t *error = 0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 764 | u32 bd_index, bd_id; |
| 765 | u32 enable; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 766 | uword *p; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 767 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 768 | if (!unformat (input, "%d", &bd_id)) |
| 769 | { |
| 770 | error = clib_error_return (0, "expecting bridge-domain id but got `%U'", |
| 771 | format_unformat_error, input); |
| 772 | goto done; |
| 773 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 774 | |
Jon Loeliger | 1c7d485 | 2017-05-02 11:06:23 -0500 | [diff] [blame] | 775 | if (bd_id == 0) |
| 776 | return clib_error_return (0, |
| 777 | "No operations on the default bridge domain are supported"); |
| 778 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 779 | p = hash_get (bdm->bd_index_by_bd_id, bd_id); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 780 | if (p) |
| 781 | bd_index = *p; |
| 782 | else |
| 783 | return clib_error_return (0, "No such bridge domain %d", bd_id); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 784 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 785 | enable = 1; |
| 786 | if (unformat (input, "disable")) |
| 787 | enable = 0; |
| 788 | |
| 789 | /* set the bridge domain flag */ |
John Lo | 8d00fff | 2017-08-03 00:35:36 -0400 | [diff] [blame] | 790 | bd_set_flags (vm, bd_index, L2_ARP_TERM, enable); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 791 | |
| 792 | done: |
| 793 | return error; |
| 794 | } |
| 795 | |
Damjan Marion | d171d48 | 2016-12-05 14:16:38 +0100 | [diff] [blame] | 796 | static clib_error_t * |
| 797 | bd_mac_age (vlib_main_t * vm, |
| 798 | unformat_input_t * input, vlib_cli_command_t * cmd) |
| 799 | { |
| 800 | bd_main_t *bdm = &bd_main; |
| 801 | clib_error_t *error = 0; |
| 802 | u32 bd_index, bd_id; |
| 803 | u32 age; |
| 804 | uword *p; |
| 805 | |
| 806 | if (!unformat (input, "%d", &bd_id)) |
| 807 | { |
| 808 | error = clib_error_return (0, "expecting bridge-domain id but got `%U'", |
| 809 | format_unformat_error, input); |
| 810 | goto done; |
| 811 | } |
| 812 | |
Jon Loeliger | 1c7d485 | 2017-05-02 11:06:23 -0500 | [diff] [blame] | 813 | if (bd_id == 0) |
| 814 | return clib_error_return (0, |
| 815 | "No operations on the default bridge domain are supported"); |
| 816 | |
Damjan Marion | d171d48 | 2016-12-05 14:16:38 +0100 | [diff] [blame] | 817 | p = hash_get (bdm->bd_index_by_bd_id, bd_id); |
| 818 | |
| 819 | if (p == 0) |
| 820 | return clib_error_return (0, "No such bridge domain %d", bd_id); |
| 821 | |
| 822 | bd_index = p[0]; |
| 823 | |
| 824 | if (!unformat (input, "%u", &age)) |
| 825 | { |
| 826 | error = |
| 827 | clib_error_return (0, "expecting ageing time in minutes but got `%U'", |
| 828 | format_unformat_error, input); |
| 829 | goto done; |
| 830 | } |
| 831 | |
| 832 | /* set the bridge domain flag */ |
| 833 | if (age > 255) |
| 834 | { |
| 835 | error = |
| 836 | clib_error_return (0, "mac aging time cannot be bigger than 255"); |
| 837 | goto done; |
| 838 | } |
| 839 | bd_set_mac_age (vm, bd_index, (u8) age); |
| 840 | |
| 841 | done: |
| 842 | return error; |
| 843 | } |
| 844 | |
| 845 | /*? |
| 846 | * Layer 2 mac aging can be enabled and disabled on each |
| 847 | * bridge-domain. Use this command to set or disable mac aging |
| 848 | * on specific bridge-domains. It is disabled by default. |
| 849 | * |
| 850 | * @cliexpar |
| 851 | * Example of how to set mac aging (where 200 is the bridge-domain-id and |
| 852 | * 5 is aging time in minutes): |
| 853 | * @cliexcmd{set bridge-domain mac-age 200 5} |
| 854 | * Example of how to disable mac aging (where 200 is the bridge-domain-id): |
| 855 | * @cliexcmd{set bridge-domain flood 200 0} |
| 856 | ?*/ |
| 857 | /* *INDENT-OFF* */ |
| 858 | VLIB_CLI_COMMAND (bd_mac_age_cli, static) = { |
| 859 | .path = "set bridge-domain mac-age", |
| 860 | .short_help = "set bridge-domain mac-age <bridge-domain-id> <mins>", |
| 861 | .function = bd_mac_age, |
| 862 | }; |
| 863 | /* *INDENT-ON* */ |
| 864 | |
Jerome Tollet | 5f93e3b | 2020-12-18 09:44:24 +0100 | [diff] [blame] | 865 | static clib_error_t * |
| 866 | bd_learn_limit (vlib_main_t *vm, unformat_input_t *input, |
| 867 | vlib_cli_command_t *cmd) |
| 868 | { |
| 869 | bd_main_t *bdm = &bd_main; |
| 870 | clib_error_t *error = 0; |
| 871 | u32 bd_index, bd_id; |
| 872 | u32 learn_limit; |
| 873 | uword *p; |
| 874 | |
| 875 | if (!unformat (input, "%d", &bd_id)) |
| 876 | { |
| 877 | error = clib_error_return (0, "expecting bridge-domain id but got `%U'", |
| 878 | format_unformat_error, input); |
| 879 | goto done; |
| 880 | } |
| 881 | |
| 882 | if (bd_id == 0) |
| 883 | return clib_error_return ( |
| 884 | 0, "No operations on the default bridge domain are supported"); |
| 885 | |
| 886 | p = hash_get (bdm->bd_index_by_bd_id, bd_id); |
| 887 | |
| 888 | if (p == 0) |
| 889 | return clib_error_return (0, "No such bridge domain %d", bd_id); |
| 890 | |
| 891 | bd_index = p[0]; |
| 892 | |
| 893 | if (!unformat (input, "%u", &learn_limit)) |
| 894 | { |
| 895 | error = clib_error_return ( |
| 896 | 0, "expecting maxium number of learned entries but got `%U'", |
| 897 | format_unformat_error, input); |
| 898 | goto done; |
| 899 | } |
| 900 | |
| 901 | bd_set_learn_limit (vm, bd_index, learn_limit); |
| 902 | |
| 903 | done: |
| 904 | return error; |
| 905 | } |
| 906 | |
| 907 | VLIB_CLI_COMMAND (bd_learn_limit_cli, static) = { |
| 908 | .path = "set bridge-domain learn-limit", |
| 909 | .short_help = |
| 910 | "set bridge-domain learn-limit <bridge-domain-id> <learn-limit>", |
| 911 | .function = bd_learn_limit, |
| 912 | }; |
| 913 | |
Billy McFall | 22aa3e9 | 2016-09-09 08:46:40 -0400 | [diff] [blame] | 914 | /*? |
| 915 | * Modify whether or not an existing bridge-domain should terminate and respond |
| 916 | * to ARP Requests. ARP Termination is disabled by default. |
| 917 | * |
| 918 | * @cliexpar |
| 919 | * Example of how to enable ARP termination (where 200 is the bridge-domain-id): |
| 920 | * @cliexcmd{set bridge-domain arp term 200} |
| 921 | * Example of how to disable ARP termination (where 200 is the bridge-domain-id): |
| 922 | * @cliexcmd{set bridge-domain arp term 200 disable} |
| 923 | ?*/ |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 924 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 925 | VLIB_CLI_COMMAND (bd_arp_term_cli, static) = { |
| 926 | .path = "set bridge-domain arp term", |
| 927 | .short_help = "set bridge-domain arp term <bridge-domain-id> [disable]", |
| 928 | .function = bd_arp_term, |
| 929 | }; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 930 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 931 | |
| 932 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 933 | /** |
Chris Luke | 16bcf7d | 2016-09-01 14:31:46 -0400 | [diff] [blame] | 934 | * Add/delete IP address to MAC address mapping. |
| 935 | * |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 936 | * The clib hash implementation stores uword entries in the hash table. |
| 937 | * The hash table mac_by_ip4 is keyed via IP4 address and store the |
| 938 | * 6-byte MAC address directly in the hash table entry uword. |
Chris Luke | 16bcf7d | 2016-09-01 14:31:46 -0400 | [diff] [blame] | 939 | * |
| 940 | * @warning This only works for 64-bit processor with 8-byte uword; |
Paul Vinciguerra | bdc0e6b | 2018-09-22 05:32:50 -0700 | [diff] [blame] | 941 | * which means this code *WILL NOT WORK* for a 32-bit processor with |
Chris Luke | 16bcf7d | 2016-09-01 14:31:46 -0400 | [diff] [blame] | 942 | * 4-byte uword. |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 943 | */ |
| 944 | u32 |
| 945 | bd_add_del_ip_mac (u32 bd_index, |
Neale Ranns | 4d5b917 | 2018-10-24 02:57:49 -0700 | [diff] [blame] | 946 | ip46_type_t type, |
| 947 | const ip46_address_t * ip, |
| 948 | const mac_address_t * mac, u8 is_add) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 949 | { |
Eyal Bari | afc47aa | 2017-04-20 14:45:17 +0300 | [diff] [blame] | 950 | l2_bridge_domain_t *bd_cfg = l2input_bd_config (bd_index); |
Neale Ranns | 4d5b917 | 2018-10-24 02:57:49 -0700 | [diff] [blame] | 951 | u64 new_mac = mac_address_as_u64 (mac); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 952 | u64 *old_mac; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 953 | |
Neale Ranns | 4d5b917 | 2018-10-24 02:57:49 -0700 | [diff] [blame] | 954 | /* make sure uword is 8 bytes */ |
| 955 | ASSERT (sizeof (uword) == sizeof (u64)); |
Eyal Bari | afc47aa | 2017-04-20 14:45:17 +0300 | [diff] [blame] | 956 | ASSERT (bd_is_valid (bd_cfg)); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 957 | |
Neale Ranns | 4d5b917 | 2018-10-24 02:57:49 -0700 | [diff] [blame] | 958 | if (IP46_TYPE_IP6 == type) |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 959 | { |
John Lo | 1edfba9 | 2016-08-27 01:11:57 -0400 | [diff] [blame] | 960 | ip6_address_t *ip6_addr_key; |
| 961 | hash_pair_t *hp; |
Neale Ranns | 4d5b917 | 2018-10-24 02:57:49 -0700 | [diff] [blame] | 962 | old_mac = (u64 *) hash_get_mem (bd_cfg->mac_by_ip6, &ip->ip6); |
John Lo | 1edfba9 | 2016-08-27 01:11:57 -0400 | [diff] [blame] | 963 | if (is_add) |
| 964 | { |
Neale Ranns | 4d5b917 | 2018-10-24 02:57:49 -0700 | [diff] [blame] | 965 | if (old_mac == NULL) |
| 966 | { |
| 967 | /* new entry - allocate and create ip6 address key */ |
John Lo | 1edfba9 | 2016-08-27 01:11:57 -0400 | [diff] [blame] | 968 | ip6_addr_key = clib_mem_alloc (sizeof (ip6_address_t)); |
Neale Ranns | 4d5b917 | 2018-10-24 02:57:49 -0700 | [diff] [blame] | 969 | clib_memcpy (ip6_addr_key, &ip->ip6, sizeof (ip6_address_t)); |
John Lo | 1edfba9 | 2016-08-27 01:11:57 -0400 | [diff] [blame] | 970 | } |
| 971 | else if (*old_mac == new_mac) |
Neale Ranns | 4d5b917 | 2018-10-24 02:57:49 -0700 | [diff] [blame] | 972 | { |
| 973 | /* same mac entry already exist for ip6 address */ |
John Lo | 1edfba9 | 2016-08-27 01:11:57 -0400 | [diff] [blame] | 974 | return 0; |
| 975 | } |
| 976 | else |
Neale Ranns | 4d5b917 | 2018-10-24 02:57:49 -0700 | [diff] [blame] | 977 | { |
| 978 | /* update mac for ip6 address */ |
| 979 | hp = hash_get_pair (bd_cfg->mac_by_ip6, &ip->ip6); |
John Lo | 1edfba9 | 2016-08-27 01:11:57 -0400 | [diff] [blame] | 980 | ip6_addr_key = (ip6_address_t *) hp->key; |
| 981 | } |
| 982 | hash_set_mem (bd_cfg->mac_by_ip6, ip6_addr_key, new_mac); |
| 983 | } |
| 984 | else |
| 985 | { |
| 986 | if (old_mac && (*old_mac == new_mac)) |
| 987 | { |
Neale Ranns | 4d5b917 | 2018-10-24 02:57:49 -0700 | [diff] [blame] | 988 | hp = hash_get_pair (bd_cfg->mac_by_ip6, &ip->ip6); |
John Lo | 1edfba9 | 2016-08-27 01:11:57 -0400 | [diff] [blame] | 989 | ip6_addr_key = (ip6_address_t *) hp->key; |
Neale Ranns | 4d5b917 | 2018-10-24 02:57:49 -0700 | [diff] [blame] | 990 | hash_unset_mem (bd_cfg->mac_by_ip6, &ip->ip6); |
John Lo | 1edfba9 | 2016-08-27 01:11:57 -0400 | [diff] [blame] | 991 | clib_mem_free (ip6_addr_key); |
| 992 | } |
| 993 | else |
| 994 | return 1; |
| 995 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 996 | } |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 997 | else |
| 998 | { |
Neale Ranns | 4d5b917 | 2018-10-24 02:57:49 -0700 | [diff] [blame] | 999 | old_mac = (u64 *) hash_get (bd_cfg->mac_by_ip4, ip->ip4.as_u32); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1000 | if (is_add) |
| 1001 | { |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1002 | if (old_mac && (*old_mac == new_mac)) |
Neale Ranns | 4d5b917 | 2018-10-24 02:57:49 -0700 | [diff] [blame] | 1003 | /* mac entry already exist */ |
| 1004 | return 0; |
| 1005 | hash_set (bd_cfg->mac_by_ip4, ip->ip4.as_u32, new_mac); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1006 | } |
| 1007 | else |
| 1008 | { |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1009 | if (old_mac && (*old_mac == new_mac)) |
Neale Ranns | 4d5b917 | 2018-10-24 02:57:49 -0700 | [diff] [blame] | 1010 | hash_unset (bd_cfg->mac_by_ip4, ip->ip4.as_u32); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1011 | else |
John Lo | 1edfba9 | 2016-08-27 01:11:57 -0400 | [diff] [blame] | 1012 | return 1; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1013 | } |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1014 | } |
John Lo | 1edfba9 | 2016-08-27 01:11:57 -0400 | [diff] [blame] | 1015 | return 0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1016 | } |
| 1017 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1018 | /** |
John Lo | e26c81f | 2019-01-07 15:16:33 -0500 | [diff] [blame] | 1019 | * Flush IP address to MAC address mapping tables in a BD. |
| 1020 | */ |
| 1021 | void |
| 1022 | bd_flush_ip_mac (u32 bd_index) |
| 1023 | { |
| 1024 | l2_bridge_domain_t *bd = l2input_bd_config (bd_index); |
| 1025 | ASSERT (bd_is_valid (bd)); |
| 1026 | bd_free_ip_mac_tables (bd); |
| 1027 | bd->mac_by_ip4 = 0; |
| 1028 | bd->mac_by_ip6 = |
| 1029 | hash_create_mem (0, sizeof (ip6_address_t), sizeof (uword)); |
| 1030 | } |
| 1031 | |
| 1032 | /** |
Chris Luke | 16bcf7d | 2016-09-01 14:31:46 -0400 | [diff] [blame] | 1033 | Set bridge-domain arp entry add/delete. |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1034 | The CLI format is: |
Billy McFall | 22aa3e9 | 2016-09-09 08:46:40 -0400 | [diff] [blame] | 1035 | 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] | 1036 | */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1037 | static clib_error_t * |
| 1038 | bd_arp_entry (vlib_main_t * vm, |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1039 | unformat_input_t * input, vlib_cli_command_t * cmd) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1040 | { |
Neale Ranns | 4d5b917 | 2018-10-24 02:57:49 -0700 | [diff] [blame] | 1041 | ip46_address_t ip_addr = ip46_address_initializer; |
| 1042 | ip46_type_t type = IP46_TYPE_IP4; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1043 | bd_main_t *bdm = &bd_main; |
| 1044 | clib_error_t *error = 0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1045 | u32 bd_index, bd_id; |
Neale Ranns | 4d5b917 | 2018-10-24 02:57:49 -0700 | [diff] [blame] | 1046 | mac_address_t mac; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1047 | u8 is_add = 1; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1048 | uword *p; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1049 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1050 | if (!unformat (input, "%d", &bd_id)) |
| 1051 | { |
| 1052 | error = clib_error_return (0, "expecting bridge-domain id but got `%U'", |
| 1053 | format_unformat_error, input); |
| 1054 | goto done; |
| 1055 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1056 | |
Jon Loeliger | 1c7d485 | 2017-05-02 11:06:23 -0500 | [diff] [blame] | 1057 | if (bd_id == 0) |
| 1058 | return clib_error_return (0, |
| 1059 | "No operations on the default bridge domain are supported"); |
| 1060 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1061 | p = hash_get (bdm->bd_index_by_bd_id, bd_id); |
| 1062 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1063 | if (p) |
| 1064 | bd_index = *p; |
| 1065 | else |
| 1066 | return clib_error_return (0, "No such bridge domain %d", bd_id); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1067 | |
Neale Ranns | 4d5b917 | 2018-10-24 02:57:49 -0700 | [diff] [blame] | 1068 | if (unformat (input, "%U", unformat_ip4_address, &ip_addr.ip4)) |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1069 | { |
Neale Ranns | 4d5b917 | 2018-10-24 02:57:49 -0700 | [diff] [blame] | 1070 | type = IP46_TYPE_IP4; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1071 | } |
Neale Ranns | 4d5b917 | 2018-10-24 02:57:49 -0700 | [diff] [blame] | 1072 | else if (unformat (input, "%U", unformat_ip6_address, &ip_addr.ip6)) |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1073 | { |
Neale Ranns | 4d5b917 | 2018-10-24 02:57:49 -0700 | [diff] [blame] | 1074 | type = IP46_TYPE_IP6; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1075 | } |
John Lo | e26c81f | 2019-01-07 15:16:33 -0500 | [diff] [blame] | 1076 | else if (unformat (input, "del-all")) |
| 1077 | { |
| 1078 | bd_flush_ip_mac (bd_index); |
| 1079 | goto done; |
| 1080 | } |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1081 | else |
| 1082 | { |
| 1083 | error = clib_error_return (0, "expecting IP address but got `%U'", |
| 1084 | format_unformat_error, input); |
| 1085 | goto done; |
| 1086 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1087 | |
Neale Ranns | 4d5b917 | 2018-10-24 02:57:49 -0700 | [diff] [blame] | 1088 | if (!unformat (input, "%U", unformat_mac_address_t, &mac)) |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1089 | { |
| 1090 | error = clib_error_return (0, "expecting MAC address but got `%U'", |
| 1091 | format_unformat_error, input); |
| 1092 | goto done; |
| 1093 | } |
| 1094 | |
| 1095 | if (unformat (input, "del")) |
| 1096 | { |
| 1097 | is_add = 0; |
| 1098 | } |
| 1099 | |
| 1100 | /* set the bridge domain flagAdd IP-MAC entry into bridge domain */ |
Neale Ranns | 4d5b917 | 2018-10-24 02:57:49 -0700 | [diff] [blame] | 1101 | if (bd_add_del_ip_mac (bd_index, type, &ip_addr, &mac, is_add)) |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1102 | { |
| 1103 | error = clib_error_return (0, "MAC %s for IP %U and MAC %U failed", |
| 1104 | is_add ? "add" : "del", |
Neale Ranns | 4d5b917 | 2018-10-24 02:57:49 -0700 | [diff] [blame] | 1105 | format_ip46_address, &ip_addr, IP46_TYPE_ANY, |
| 1106 | format_mac_address_t, &mac); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1107 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1108 | |
| 1109 | done: |
| 1110 | return error; |
| 1111 | } |
| 1112 | |
Billy McFall | 22aa3e9 | 2016-09-09 08:46:40 -0400 | [diff] [blame] | 1113 | /*? |
| 1114 | * Add an ARP entry to an existing bridge-domain. |
| 1115 | * |
| 1116 | * @cliexpar |
| 1117 | * Example of how to add an ARP entry (where 200 is the bridge-domain-id): |
| 1118 | * @cliexcmd{set bridge-domain arp entry 200 192.168.72.45 52:54:00:3b:83:1a} |
| 1119 | * Example of how to delete an ARP entry (where 200 is the bridge-domain-id): |
| 1120 | * @cliexcmd{set bridge-domain arp entry 200 192.168.72.45 52:54:00:3b:83:1a del} |
| 1121 | ?*/ |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1122 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1123 | VLIB_CLI_COMMAND (bd_arp_entry_cli, static) = { |
| 1124 | .path = "set bridge-domain arp entry", |
John Lo | e26c81f | 2019-01-07 15:16:33 -0500 | [diff] [blame] | 1125 | .short_help = "set bridge-domain arp entry <bridge-domain-id> [<ip-addr> <mac-addr> [del] | del-all]", |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1126 | .function = bd_arp_entry, |
| 1127 | }; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1128 | /* *INDENT-ON* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1129 | |
Neale Ranns | b474380 | 2018-09-05 09:13:57 -0700 | [diff] [blame] | 1130 | static u8 * |
Neale Ranns | b474380 | 2018-09-05 09:13:57 -0700 | [diff] [blame] | 1131 | format_uu_cfg (u8 * s, va_list * args) |
| 1132 | { |
| 1133 | l2_bridge_domain_t *bd_config = va_arg (*args, l2_bridge_domain_t *); |
| 1134 | |
| 1135 | if (bd_config->feature_bitmap & L2INPUT_FEAT_UU_FWD) |
| 1136 | return (format (s, "%U", format_vnet_sw_if_index_name_with_NA, |
| 1137 | vnet_get_main (), bd_config->uu_fwd_sw_if_index)); |
| 1138 | else if (bd_config->feature_bitmap & L2INPUT_FEAT_UU_FLOOD) |
| 1139 | return (format (s, "flood")); |
| 1140 | else |
| 1141 | return (format (s, "drop")); |
| 1142 | } |
| 1143 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1144 | /** |
Chris Luke | 16bcf7d | 2016-09-01 14:31:46 -0400 | [diff] [blame] | 1145 | Show bridge-domain state. |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1146 | The CLI format is: |
| 1147 | show bridge-domain [<bd_index>] |
| 1148 | */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1149 | static clib_error_t * |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1150 | 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] | 1151 | { |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1152 | vnet_main_t *vnm = vnet_get_main (); |
| 1153 | bd_main_t *bdm = &bd_main; |
| 1154 | clib_error_t *error = 0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1155 | u32 bd_index = ~0; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1156 | l2_bridge_domain_t *bd_config; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1157 | u32 start, end; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1158 | u32 detail = 0; |
| 1159 | u32 intf = 0; |
| 1160 | u32 arp = 0; |
Jerome Tollet | 4830414 | 2017-09-05 12:13:22 +0100 | [diff] [blame] | 1161 | u32 bd_tag = 0; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1162 | u32 bd_id = ~0; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1163 | uword *p; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1164 | |
Jon Loeliger | 1c7d485 | 2017-05-02 11:06:23 -0500 | [diff] [blame] | 1165 | start = 1; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1166 | end = vec_len (l2input_main.bd_configs); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1167 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1168 | if (unformat (input, "%d", &bd_id)) |
| 1169 | { |
| 1170 | if (unformat (input, "detail")) |
| 1171 | detail = 1; |
| 1172 | else if (unformat (input, "det")) |
| 1173 | detail = 1; |
| 1174 | if (unformat (input, "int")) |
| 1175 | intf = 1; |
| 1176 | if (unformat (input, "arp")) |
| 1177 | arp = 1; |
Jerome Tollet | 4830414 | 2017-09-05 12:13:22 +0100 | [diff] [blame] | 1178 | if (unformat (input, "bd-tag")) |
| 1179 | bd_tag = 1; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1180 | |
Jon Loeliger | 1c7d485 | 2017-05-02 11:06:23 -0500 | [diff] [blame] | 1181 | if (bd_id == 0) |
| 1182 | return clib_error_return (0, |
| 1183 | "No operations on the default bridge domain are supported"); |
| 1184 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1185 | p = hash_get (bdm->bd_index_by_bd_id, bd_id); |
| 1186 | if (p) |
| 1187 | bd_index = *p; |
| 1188 | else |
| 1189 | return clib_error_return (0, "No such bridge domain %d", bd_id); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1190 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1191 | vec_validate (l2input_main.bd_configs, bd_index); |
| 1192 | bd_config = vec_elt_at_index (l2input_main.bd_configs, bd_index); |
| 1193 | if (bd_is_valid (bd_config)) |
| 1194 | { |
| 1195 | start = bd_index; |
| 1196 | end = start + 1; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1197 | } |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1198 | else |
| 1199 | { |
| 1200 | vlib_cli_output (vm, "bridge-domain %d not in use", bd_id); |
| 1201 | goto done; |
| 1202 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1203 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1204 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1205 | /* Show all bridge-domains that have been initialized */ |
John Lo | da1f2c7 | 2017-03-24 20:11:15 -0400 | [diff] [blame] | 1206 | u32 printed = 0; |
| 1207 | u8 *as = 0; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1208 | for (bd_index = start; bd_index < end; bd_index++) |
| 1209 | { |
| 1210 | bd_config = vec_elt_at_index (l2input_main.bd_configs, bd_index); |
| 1211 | if (bd_is_valid (bd_config)) |
| 1212 | { |
| 1213 | if (!printed) |
| 1214 | { |
| 1215 | printed = 1; |
| 1216 | vlib_cli_output (vm, |
Jerome Tollet | 5f93e3b | 2020-12-18 09:44:24 +0100 | [diff] [blame] | 1217 | "%=8s %=7s %=4s %=9s %=9s %=9s %=11s %=9s %=9s " |
| 1218 | "%=9s %=8s %=8s %=11s", |
| 1219 | "BD-ID", "Index", "BSN", "Age(min)", "Learning", |
| 1220 | "U-Forwrd", "UU-Flood", "Flooding", "ARP-Term", |
| 1221 | "arp-ufwd", "Learn-count", "Learn-limit", |
Mohsin Kazmi | 5e6f734 | 2019-04-05 17:40:20 +0200 | [diff] [blame] | 1222 | "BVI-Intf"); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1223 | } |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1224 | |
John Lo | da1f2c7 | 2017-03-24 20:11:15 -0400 | [diff] [blame] | 1225 | if (bd_config->mac_age) |
| 1226 | as = format (as, "%d", bd_config->mac_age); |
| 1227 | else |
| 1228 | as = format (as, "off"); |
Jerome Tollet | 5f93e3b | 2020-12-18 09:44:24 +0100 | [diff] [blame] | 1229 | vlib_cli_output ( |
| 1230 | vm, |
| 1231 | "%=8d %=7d %=4d %=9v %=9s %=9s %=11U %=9s %=9s %=9s %=8d %=8d " |
| 1232 | "%=11U", |
| 1233 | bd_config->bd_id, bd_index, bd_config->seq_num, as, |
| 1234 | bd_config->feature_bitmap & L2INPUT_FEAT_LEARN ? "on" : "off", |
| 1235 | bd_config->feature_bitmap & L2INPUT_FEAT_FWD ? "on" : "off", |
| 1236 | format_uu_cfg, bd_config, |
| 1237 | bd_config->feature_bitmap & L2INPUT_FEAT_FLOOD ? "on" : "off", |
| 1238 | bd_config->feature_bitmap & L2INPUT_FEAT_ARP_TERM ? "on" : "off", |
| 1239 | bd_config->feature_bitmap & L2INPUT_FEAT_ARP_UFWD ? "on" : "off", |
| 1240 | bd_config->learn_count, bd_config->learn_limit, |
| 1241 | format_vnet_sw_if_index_name_with_NA, vnm, |
| 1242 | bd_config->bvi_sw_if_index); |
| 1243 | if (detail) |
| 1244 | vlib_cli_output (vm, "%U", format_l2_input_feature_bitmap, |
| 1245 | bd_config->feature_bitmap); |
John Lo | da1f2c7 | 2017-03-24 20:11:15 -0400 | [diff] [blame] | 1246 | vec_reset_length (as); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1247 | |
| 1248 | if (detail || intf) |
| 1249 | { |
| 1250 | /* Show all member interfaces */ |
Eyal Bari | c5b1360 | 2016-11-24 19:42:43 +0200 | [diff] [blame] | 1251 | int i; |
| 1252 | vec_foreach_index (i, bd_config->members) |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1253 | { |
Eyal Bari | c5b1360 | 2016-11-24 19:42:43 +0200 | [diff] [blame] | 1254 | l2_flood_member_t *member = |
| 1255 | vec_elt_at_index (bd_config->members, i); |
Neale Ranns | 47a3d99 | 2020-09-29 15:38:51 +0000 | [diff] [blame] | 1256 | u8 swif_seq_num = l2_input_seq_num (member->sw_if_index); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1257 | u32 vtr_opr, dot1q, tag1, tag2; |
Eyal Bari | c5b1360 | 2016-11-24 19:42:43 +0200 | [diff] [blame] | 1258 | if (i == 0) |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1259 | { |
John Lo | da1f2c7 | 2017-03-24 20:11:15 -0400 | [diff] [blame] | 1260 | vlib_cli_output (vm, "\n%=30s%=7s%=5s%=5s%=5s%=9s%=30s", |
| 1261 | "Interface", "If-idx", "ISN", "SHG", |
| 1262 | "BVI", "TxFlood", "VLAN-Tag-Rewrite"); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1263 | } |
| 1264 | l2vtr_get (vm, vnm, member->sw_if_index, &vtr_opr, &dot1q, |
| 1265 | &tag1, &tag2); |
John Lo | da1f2c7 | 2017-03-24 20:11:15 -0400 | [diff] [blame] | 1266 | vlib_cli_output (vm, "%=30U%=7d%=5d%=5d%=5s%=9s%=30U", |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1267 | format_vnet_sw_if_index_name, vnm, |
| 1268 | member->sw_if_index, member->sw_if_index, |
Eyal Bari | 0f360dc | 2017-06-14 13:11:20 +0300 | [diff] [blame] | 1269 | swif_seq_num, member->shg, |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1270 | member->flags & L2_FLOOD_MEMBER_BVI ? "*" : |
Eyal Bari | c5b1360 | 2016-11-24 19:42:43 +0200 | [diff] [blame] | 1271 | "-", i < bd_config->flood_count ? "*" : "-", |
| 1272 | format_vtr, vtr_opr, dot1q, tag1, tag2); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1273 | } |
Neale Ranns | b474380 | 2018-09-05 09:13:57 -0700 | [diff] [blame] | 1274 | if (~0 != bd_config->uu_fwd_sw_if_index) |
| 1275 | vlib_cli_output (vm, "%=30U%=7d%=5d%=5d%=5s%=9s%=30s", |
| 1276 | format_vnet_sw_if_index_name, vnm, |
| 1277 | bd_config->uu_fwd_sw_if_index, |
| 1278 | bd_config->uu_fwd_sw_if_index, |
| 1279 | 0, 0, "uu", "-", "None"); |
| 1280 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1281 | } |
| 1282 | |
| 1283 | if ((detail || arp) && |
| 1284 | (bd_config->feature_bitmap & L2INPUT_FEAT_ARP_TERM)) |
| 1285 | { |
| 1286 | u32 ip4_addr; |
John Lo | 1edfba9 | 2016-08-27 01:11:57 -0400 | [diff] [blame] | 1287 | ip6_address_t *ip6_addr; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1288 | u64 mac_addr; |
| 1289 | vlib_cli_output (vm, |
John Lo | 1edfba9 | 2016-08-27 01:11:57 -0400 | [diff] [blame] | 1290 | "\n IP4/IP6 to MAC table for ARP Termination"); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1291 | |
| 1292 | /* *INDENT-OFF* */ |
| 1293 | hash_foreach (ip4_addr, mac_addr, bd_config->mac_by_ip4, |
| 1294 | ({ |
John Lo | 1edfba9 | 2016-08-27 01:11:57 -0400 | [diff] [blame] | 1295 | vlib_cli_output (vm, "%=40U => %=20U", |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1296 | format_ip4_address, &ip4_addr, |
| 1297 | format_ethernet_address, &mac_addr); |
| 1298 | })); |
John Lo | 1edfba9 | 2016-08-27 01:11:57 -0400 | [diff] [blame] | 1299 | |
| 1300 | hash_foreach_mem (ip6_addr, mac_addr, bd_config->mac_by_ip6, |
| 1301 | ({ |
| 1302 | vlib_cli_output (vm, "%=40U => %=20U", |
| 1303 | format_ip6_address, ip6_addr, |
| 1304 | format_ethernet_address, &mac_addr); |
| 1305 | })); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1306 | /* *INDENT-ON* */ |
| 1307 | } |
Jerome Tollet | 4830414 | 2017-09-05 12:13:22 +0100 | [diff] [blame] | 1308 | |
| 1309 | if ((detail || bd_tag) && (bd_config->bd_tag)) |
| 1310 | { |
| 1311 | vlib_cli_output (vm, "\n BD-Tag: %s", bd_config->bd_tag); |
| 1312 | |
| 1313 | } |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1314 | } |
| 1315 | } |
John Lo | da1f2c7 | 2017-03-24 20:11:15 -0400 | [diff] [blame] | 1316 | vec_free (as); |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1317 | |
| 1318 | if (!printed) |
| 1319 | { |
| 1320 | vlib_cli_output (vm, "no bridge-domains in use"); |
| 1321 | } |
| 1322 | |
| 1323 | done: |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1324 | return error; |
| 1325 | } |
| 1326 | |
Billy McFall | 22aa3e9 | 2016-09-09 08:46:40 -0400 | [diff] [blame] | 1327 | /*? |
| 1328 | * Show a summary of all the bridge-domain instances or detailed view of a |
| 1329 | * single bridge-domain. Bridge-domains are created by adding an interface |
| 1330 | * to a bridge using the '<em>set interface l2 bridge</em>' command. |
| 1331 | * |
| 1332 | * @cliexpar |
| 1333 | * @parblock |
| 1334 | * Example of displaying all bridge-domains: |
| 1335 | * @cliexstart{show bridge-domain} |
| 1336 | * ID Index Learning U-Forwrd UU-Flood Flooding ARP-Term BVI-Intf |
| 1337 | * 0 0 off off off off off local0 |
| 1338 | * 200 1 on on on on off N/A |
| 1339 | * @cliexend |
| 1340 | * |
| 1341 | * Example of displaying details of a single bridge-domains: |
| 1342 | * @cliexstart{show bridge-domain 200 detail} |
| 1343 | * ID Index Learning U-Forwrd UU-Flood Flooding ARP-Term BVI-Intf |
| 1344 | * 200 1 on on on on off N/A |
| 1345 | * |
| 1346 | * Interface Index SHG BVI VLAN-Tag-Rewrite |
| 1347 | * GigabitEthernet0/8/0.200 3 0 - none |
| 1348 | * GigabitEthernet0/9/0.200 4 0 - none |
| 1349 | * @cliexend |
| 1350 | * @endparblock |
| 1351 | ?*/ |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1352 | /* *INDENT-OFF* */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1353 | VLIB_CLI_COMMAND (bd_show_cli, static) = { |
| 1354 | .path = "show bridge-domain", |
Jerome Tollet | 4830414 | 2017-09-05 12:13:22 +0100 | [diff] [blame] | 1355 | .short_help = "show bridge-domain [bridge-domain-id [detail|int|arp|bd-tag]]", |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1356 | .function = bd_show, |
| 1357 | }; |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1358 | /* *INDENT-ON* */ |
| 1359 | |
Choonho Son | 0548079 | 2017-03-29 20:07:45 +0900 | [diff] [blame] | 1360 | int |
| 1361 | bd_add_del (l2_bridge_domain_add_del_args_t * a) |
| 1362 | { |
| 1363 | bd_main_t *bdm = &bd_main; |
Damjan Marion | 9514781 | 2020-09-14 12:18:44 +0200 | [diff] [blame] | 1364 | l2fib_main_t *fm = &l2fib_main; |
Choonho Son | 0548079 | 2017-03-29 20:07:45 +0900 | [diff] [blame] | 1365 | vlib_main_t *vm = bdm->vlib_main; |
Choonho Son | 0548079 | 2017-03-29 20:07:45 +0900 | [diff] [blame] | 1366 | int rv = 0; |
| 1367 | |
Damjan Marion | 9514781 | 2020-09-14 12:18:44 +0200 | [diff] [blame] | 1368 | if (fm->mac_table_initialized == 0) |
| 1369 | l2fib_table_init (); |
| 1370 | |
Eyal Bari | b1352ed | 2017-04-07 23:14:17 +0300 | [diff] [blame] | 1371 | u32 bd_index = bd_find_index (bdm, a->bd_id); |
Choonho Son | 0548079 | 2017-03-29 20:07:45 +0900 | [diff] [blame] | 1372 | if (a->is_add) |
| 1373 | { |
Eyal Bari | b1352ed | 2017-04-07 23:14:17 +0300 | [diff] [blame] | 1374 | if (bd_index != ~0) |
| 1375 | return VNET_API_ERROR_BD_ALREADY_EXISTS; |
John Lo | 9793477 | 2017-05-18 22:26:47 -0400 | [diff] [blame] | 1376 | if (a->bd_id > L2_BD_ID_MAX) |
| 1377 | return VNET_API_ERROR_BD_ID_EXCEED_MAX; |
Eyal Bari | b1352ed | 2017-04-07 23:14:17 +0300 | [diff] [blame] | 1378 | bd_index = bd_add_bd_index (bdm, a->bd_id); |
Choonho Son | 0548079 | 2017-03-29 20:07:45 +0900 | [diff] [blame] | 1379 | |
Neale Ranns | b474380 | 2018-09-05 09:13:57 -0700 | [diff] [blame] | 1380 | bd_flags_t enable_flags = 0, disable_flags = 0; |
Choonho Son | 0548079 | 2017-03-29 20:07:45 +0900 | [diff] [blame] | 1381 | if (a->flood) |
| 1382 | enable_flags |= L2_FLOOD; |
| 1383 | else |
| 1384 | disable_flags |= L2_FLOOD; |
| 1385 | |
| 1386 | if (a->uu_flood) |
| 1387 | enable_flags |= L2_UU_FLOOD; |
| 1388 | else |
| 1389 | disable_flags |= L2_UU_FLOOD; |
| 1390 | |
| 1391 | if (a->forward) |
| 1392 | enable_flags |= L2_FWD; |
| 1393 | else |
| 1394 | disable_flags |= L2_FWD; |
| 1395 | |
| 1396 | if (a->learn) |
| 1397 | enable_flags |= L2_LEARN; |
| 1398 | else |
| 1399 | disable_flags |= L2_LEARN; |
| 1400 | |
| 1401 | if (a->arp_term) |
| 1402 | enable_flags |= L2_ARP_TERM; |
| 1403 | else |
| 1404 | disable_flags |= L2_ARP_TERM; |
| 1405 | |
Mohsin Kazmi | 5e6f734 | 2019-04-05 17:40:20 +0200 | [diff] [blame] | 1406 | if (a->arp_ufwd) |
| 1407 | enable_flags |= L2_ARP_UFWD; |
| 1408 | else |
| 1409 | disable_flags |= L2_ARP_UFWD; |
| 1410 | |
Choonho Son | 0548079 | 2017-03-29 20:07:45 +0900 | [diff] [blame] | 1411 | if (enable_flags) |
| 1412 | bd_set_flags (vm, bd_index, enable_flags, 1 /* enable */ ); |
| 1413 | |
| 1414 | if (disable_flags) |
| 1415 | bd_set_flags (vm, bd_index, disable_flags, 0 /* disable */ ); |
| 1416 | |
| 1417 | bd_set_mac_age (vm, bd_index, a->mac_age); |
Jerome Tollet | 4830414 | 2017-09-05 12:13:22 +0100 | [diff] [blame] | 1418 | |
| 1419 | if (a->bd_tag) |
| 1420 | bd_set_bd_tag (vm, bd_index, a->bd_tag); |
| 1421 | |
Jerome Tollet | 5f93e3b | 2020-12-18 09:44:24 +0100 | [diff] [blame] | 1422 | bd_set_learn_limit (vm, bd_index, l2learn_main.bd_default_learn_limit); |
| 1423 | vec_elt_at_index (l2input_main.bd_configs, bd_index)->learn_count = 0; |
Choonho Son | 0548079 | 2017-03-29 20:07:45 +0900 | [diff] [blame] | 1424 | } |
| 1425 | else |
Eyal Bari | b1352ed | 2017-04-07 23:14:17 +0300 | [diff] [blame] | 1426 | { |
| 1427 | if (bd_index == ~0) |
| 1428 | return VNET_API_ERROR_NO_SUCH_ENTRY; |
Jon Loeliger | 1c7d485 | 2017-05-02 11:06:23 -0500 | [diff] [blame] | 1429 | if (bd_index == 0) |
| 1430 | return VNET_API_ERROR_BD_NOT_MODIFIABLE; |
Eyal Bari | b1352ed | 2017-04-07 23:14:17 +0300 | [diff] [blame] | 1431 | if (vec_len (l2input_main.bd_configs[bd_index].members)) |
| 1432 | return VNET_API_ERROR_BD_IN_USE; |
| 1433 | rv = bd_delete (bdm, bd_index); |
| 1434 | } |
Choonho Son | 0548079 | 2017-03-29 20:07:45 +0900 | [diff] [blame] | 1435 | |
| 1436 | return rv; |
| 1437 | } |
| 1438 | |
| 1439 | /** |
| 1440 | Create or delete bridge-domain. |
Choonho Son | 5ee51f8 | 2017-04-05 19:09:52 +0900 | [diff] [blame] | 1441 | The CLI format: |
Jerome Tollet | 50570ec | 2017-09-14 12:53:56 +0100 | [diff] [blame] | 1442 | create bridge-domain <bd_index> [learn <0|1>] [forward <0|1>] [uu-flood <0|1>] [flood <0|1>] |
| 1443 | [arp-term <0|1>] [mac-age <nn>] [bd-tag <tag>] [del] |
Choonho Son | 0548079 | 2017-03-29 20:07:45 +0900 | [diff] [blame] | 1444 | */ |
| 1445 | |
| 1446 | static clib_error_t * |
| 1447 | bd_add_del_command_fn (vlib_main_t * vm, unformat_input_t * input, |
| 1448 | vlib_cli_command_t * cmd) |
| 1449 | { |
| 1450 | unformat_input_t _line_input, *line_input = &_line_input; |
| 1451 | clib_error_t *error = 0; |
| 1452 | u8 is_add = 1; |
| 1453 | u32 bd_id = ~0; |
Mohsin Kazmi | 5e6f734 | 2019-04-05 17:40:20 +0200 | [diff] [blame] | 1454 | u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = |
| 1455 | 0, arp_ufwd = 0; |
Choonho Son | 0548079 | 2017-03-29 20:07:45 +0900 | [diff] [blame] | 1456 | u32 mac_age = 0; |
Jerome Tollet | 4830414 | 2017-09-05 12:13:22 +0100 | [diff] [blame] | 1457 | u8 *bd_tag = NULL; |
Choonho Son | 0548079 | 2017-03-29 20:07:45 +0900 | [diff] [blame] | 1458 | l2_bridge_domain_add_del_args_t _a, *a = &_a; |
| 1459 | int rv; |
| 1460 | |
| 1461 | /* Get a line of input. */ |
| 1462 | if (!unformat_user (input, unformat_line_input, line_input)) |
| 1463 | return 0; |
| 1464 | |
| 1465 | while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) |
| 1466 | { |
| 1467 | if (unformat (line_input, "%d", &bd_id)) |
| 1468 | ; |
| 1469 | else if (unformat (line_input, "flood %d", &flood)) |
| 1470 | ; |
| 1471 | else if (unformat (line_input, "uu-flood %d", &uu_flood)) |
| 1472 | ; |
| 1473 | else if (unformat (line_input, "forward %d", &forward)) |
| 1474 | ; |
Choonho Son | 5ee51f8 | 2017-04-05 19:09:52 +0900 | [diff] [blame] | 1475 | else if (unformat (line_input, "learn %d", &learn)) |
| 1476 | ; |
Choonho Son | 0548079 | 2017-03-29 20:07:45 +0900 | [diff] [blame] | 1477 | else if (unformat (line_input, "arp-term %d", &arp_term)) |
| 1478 | ; |
Mohsin Kazmi | 5e6f734 | 2019-04-05 17:40:20 +0200 | [diff] [blame] | 1479 | else if (unformat (line_input, "arp-ufwd %d", &arp_ufwd)) |
| 1480 | ; |
Choonho Son | 0548079 | 2017-03-29 20:07:45 +0900 | [diff] [blame] | 1481 | else if (unformat (line_input, "mac-age %d", &mac_age)) |
| 1482 | ; |
Jerome Tollet | 4830414 | 2017-09-05 12:13:22 +0100 | [diff] [blame] | 1483 | else if (unformat (line_input, "bd-tag %s", &bd_tag)) |
| 1484 | ; |
Choonho Son | 0548079 | 2017-03-29 20:07:45 +0900 | [diff] [blame] | 1485 | else if (unformat (line_input, "del")) |
| 1486 | { |
| 1487 | is_add = 0; |
| 1488 | flood = uu_flood = forward = learn = 0; |
| 1489 | } |
| 1490 | else |
| 1491 | break; |
| 1492 | } |
| 1493 | |
| 1494 | if (bd_id == ~0) |
| 1495 | { |
| 1496 | error = clib_error_return (0, "bridge-domain-id not specified"); |
| 1497 | goto done; |
| 1498 | } |
| 1499 | |
Jon Loeliger | 1c7d485 | 2017-05-02 11:06:23 -0500 | [diff] [blame] | 1500 | if (bd_id == 0) |
| 1501 | { |
| 1502 | error = clib_error_return (0, "bridge domain 0 can not be modified"); |
| 1503 | goto done; |
| 1504 | } |
| 1505 | |
Choonho Son | 0548079 | 2017-03-29 20:07:45 +0900 | [diff] [blame] | 1506 | if (mac_age > 255) |
| 1507 | { |
| 1508 | error = clib_error_return (0, "mac age must be less than 256"); |
| 1509 | goto done; |
| 1510 | } |
Jerome Tollet | 4830414 | 2017-09-05 12:13:22 +0100 | [diff] [blame] | 1511 | if ((bd_tag) && (strlen ((char *) bd_tag) > 63)) |
| 1512 | { |
| 1513 | error = clib_error_return (0, "bd-tag cannot be longer than 63"); |
| 1514 | goto done; |
| 1515 | } |
Choonho Son | 0548079 | 2017-03-29 20:07:45 +0900 | [diff] [blame] | 1516 | |
Dave Barach | b7b9299 | 2018-10-17 10:38:51 -0400 | [diff] [blame] | 1517 | clib_memset (a, 0, sizeof (*a)); |
Choonho Son | 0548079 | 2017-03-29 20:07:45 +0900 | [diff] [blame] | 1518 | a->is_add = is_add; |
| 1519 | a->bd_id = bd_id; |
| 1520 | a->flood = (u8) flood; |
| 1521 | a->uu_flood = (u8) uu_flood; |
| 1522 | a->forward = (u8) forward; |
| 1523 | a->learn = (u8) learn; |
| 1524 | a->arp_term = (u8) arp_term; |
Mohsin Kazmi | 5e6f734 | 2019-04-05 17:40:20 +0200 | [diff] [blame] | 1525 | a->arp_ufwd = (u8) arp_ufwd; |
Choonho Son | 0548079 | 2017-03-29 20:07:45 +0900 | [diff] [blame] | 1526 | a->mac_age = (u8) mac_age; |
Jerome Tollet | 4830414 | 2017-09-05 12:13:22 +0100 | [diff] [blame] | 1527 | a->bd_tag = bd_tag; |
Choonho Son | 0548079 | 2017-03-29 20:07:45 +0900 | [diff] [blame] | 1528 | |
| 1529 | rv = bd_add_del (a); |
| 1530 | |
| 1531 | switch (rv) |
| 1532 | { |
| 1533 | case 0: |
| 1534 | if (is_add) |
| 1535 | vlib_cli_output (vm, "bridge-domain %d", bd_id); |
| 1536 | break; |
Eyal Bari | b1352ed | 2017-04-07 23:14:17 +0300 | [diff] [blame] | 1537 | case VNET_API_ERROR_BD_IN_USE: |
| 1538 | error = clib_error_return (0, "bridge domain in use - remove members"); |
| 1539 | goto done; |
Choonho Son | 0548079 | 2017-03-29 20:07:45 +0900 | [diff] [blame] | 1540 | case VNET_API_ERROR_NO_SUCH_ENTRY: |
John Lo | 9793477 | 2017-05-18 22:26:47 -0400 | [diff] [blame] | 1541 | error = clib_error_return (0, "bridge domain ID does not exist"); |
Choonho Son | 0548079 | 2017-03-29 20:07:45 +0900 | [diff] [blame] | 1542 | goto done; |
Jon Loeliger | 1c7d485 | 2017-05-02 11:06:23 -0500 | [diff] [blame] | 1543 | case VNET_API_ERROR_BD_NOT_MODIFIABLE: |
| 1544 | error = clib_error_return (0, "bridge domain 0 can not be modified"); |
| 1545 | goto done; |
John Lo | 9793477 | 2017-05-18 22:26:47 -0400 | [diff] [blame] | 1546 | case VNET_API_ERROR_BD_ID_EXCEED_MAX: |
| 1547 | error = clib_error_return (0, "bridge domain ID exceed 16M limit"); |
| 1548 | goto done; |
Choonho Son | 0548079 | 2017-03-29 20:07:45 +0900 | [diff] [blame] | 1549 | default: |
| 1550 | error = clib_error_return (0, "bd_add_del returned %d", rv); |
| 1551 | goto done; |
| 1552 | } |
| 1553 | |
| 1554 | done: |
Jerome Tollet | 4830414 | 2017-09-05 12:13:22 +0100 | [diff] [blame] | 1555 | vec_free (bd_tag); |
Choonho Son | 0548079 | 2017-03-29 20:07:45 +0900 | [diff] [blame] | 1556 | unformat_free (line_input); |
| 1557 | |
| 1558 | return error; |
| 1559 | } |
| 1560 | |
| 1561 | |
| 1562 | /*? |
| 1563 | * Create/Delete bridge-domain instance |
| 1564 | * |
| 1565 | * @cliexpar |
| 1566 | * @parblock |
| 1567 | * Example of creating bridge-domain 1: |
| 1568 | * @cliexstart{create bridge-domain 1} |
| 1569 | * bridge-domain 1 |
| 1570 | * @cliexend |
| 1571 | * |
| 1572 | * Example of creating bridge-domain 2 with enabling arp-term, mac-age 60: |
| 1573 | * @cliexstart{create bridge-domain 2 arp-term 1 mac-age 60} |
| 1574 | * bridge-domain 2 |
| 1575 | * |
| 1576 | * vpp# show bridge-domain |
| 1577 | * ID Index BSN Age(min) Learning U-Forwrd UU-Flood Flooding ARP-Term BVI-Intf |
| 1578 | * 0 0 0 off off off off off off local0 |
| 1579 | * 1 1 0 off on on off on off N/A |
| 1580 | * 2 2 0 60 on on off on on N/A |
| 1581 | * |
| 1582 | * @cliexend |
| 1583 | * |
| 1584 | * Example of delete bridge-domain 1: |
| 1585 | * @cliexstart{create bridge-domain 1 del} |
| 1586 | * @cliexend |
| 1587 | * @endparblock |
| 1588 | ?*/ |
| 1589 | |
| 1590 | /* *INDENT-OFF* */ |
| 1591 | VLIB_CLI_COMMAND (bd_create_cli, static) = { |
| 1592 | .path = "create bridge-domain", |
| 1593 | .short_help = "create bridge-domain <bridge-domain-id>" |
| 1594 | " [learn <0|1>] [forward <0|1>] [uu-flood <0|1>] [flood <0|1>] [arp-term <0|1>]" |
Mohsin Kazmi | 5e6f734 | 2019-04-05 17:40:20 +0200 | [diff] [blame] | 1595 | " [arp-ufwd <0|1>] [mac-age <nn>] [bd-tag <tag>] [del]", |
Choonho Son | 0548079 | 2017-03-29 20:07:45 +0900 | [diff] [blame] | 1596 | .function = bd_add_del_command_fn, |
| 1597 | }; |
| 1598 | /* *INDENT-ON* */ |
| 1599 | |
| 1600 | |
| 1601 | |
Dave Barach | 97d8dc2 | 2016-08-15 15:31:15 -0400 | [diff] [blame] | 1602 | /* |
| 1603 | * fd.io coding-style-patch-verification: ON |
| 1604 | * |
| 1605 | * Local Variables: |
| 1606 | * eval: (c-set-style "gnu") |
| 1607 | * End: |
| 1608 | */ |