Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 1 | /* |
| 2 | *------------------------------------------------------------------ |
| 3 | * Copyright (c) 2017 Cisco and/or its affiliates. |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at: |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | *------------------------------------------------------------------ |
| 16 | */ |
| 17 | |
| 18 | #define _GNU_SOURCE |
| 19 | #include <stdint.h> |
Neale Ranns | dc617b8 | 2020-08-20 08:22:56 +0000 | [diff] [blame] | 20 | #include <vnet/ip-neighbor/ip4_neighbor.h> |
| 21 | #include <vnet/ip-neighbor/ip6_neighbor.h> |
Steven Luong | 05a68d6 | 2021-12-03 12:05:45 -0800 | [diff] [blame] | 22 | #include <vnet/bonding/node.h> |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 23 | |
Steven Luong | 8d46219 | 2021-03-03 19:03:38 -0800 | [diff] [blame] | 24 | #define foreach_bond_tx_error \ |
| 25 | _ (NONE, "no error") \ |
| 26 | _ (IF_DOWN, "interface down") \ |
| 27 | _ (BAD_LB_MODE, "bad load balance mode") \ |
| 28 | _ (NO_MEMBER, "no member") |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 29 | |
| 30 | typedef enum |
| 31 | { |
| 32 | #define _(f,s) BOND_TX_ERROR_##f, |
| 33 | foreach_bond_tx_error |
| 34 | #undef _ |
| 35 | BOND_TX_N_ERROR, |
| 36 | } bond_tx_error_t; |
| 37 | |
| 38 | static char *bond_tx_error_strings[] = { |
| 39 | #define _(n,s) s, |
| 40 | foreach_bond_tx_error |
| 41 | #undef _ |
| 42 | }; |
| 43 | |
| 44 | static u8 * |
| 45 | format_bond_tx_trace (u8 * s, va_list * args) |
| 46 | { |
| 47 | CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *); |
| 48 | CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *); |
| 49 | bond_packet_trace_t *t = va_arg (*args, bond_packet_trace_t *); |
| 50 | vnet_hw_interface_t *hw, *hw1; |
| 51 | vnet_main_t *vnm = vnet_get_main (); |
| 52 | |
| 53 | hw = vnet_get_sup_hw_interface (vnm, t->sw_if_index); |
| 54 | hw1 = vnet_get_sup_hw_interface (vnm, t->bond_sw_if_index); |
| 55 | s = format (s, "src %U, dst %U, %s -> %s", |
| 56 | format_ethernet_address, t->ethernet.src_address, |
| 57 | format_ethernet_address, t->ethernet.dst_address, |
| 58 | hw->name, hw1->name); |
| 59 | |
| 60 | return s; |
| 61 | } |
| 62 | |
Damjan Marion | cefe134 | 2018-09-21 18:11:33 +0200 | [diff] [blame] | 63 | #ifndef CLIB_MARCH_VARIANT |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 64 | u8 * |
| 65 | format_bond_interface_name (u8 * s, va_list * args) |
| 66 | { |
| 67 | u32 dev_instance = va_arg (*args, u32); |
| 68 | bond_main_t *bm = &bond_main; |
| 69 | bond_if_t *bif = pool_elt_at_index (bm->interfaces, dev_instance); |
| 70 | |
Alexander Chernavin | ad9d528 | 2018-12-13 09:08:09 -0500 | [diff] [blame] | 71 | s = format (s, "BondEthernet%lu", bif->id); |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 72 | |
| 73 | return s; |
| 74 | } |
Damjan Marion | cefe134 | 2018-09-21 18:11:33 +0200 | [diff] [blame] | 75 | #endif |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 76 | |
| 77 | static __clib_unused clib_error_t * |
Steven | 4f8863b | 2018-04-12 19:36:19 -0700 | [diff] [blame] | 78 | bond_set_l2_mode_function (vnet_main_t * vnm, |
| 79 | struct vnet_hw_interface_t *bif_hw, |
| 80 | i32 l2_if_adjust) |
| 81 | { |
| 82 | bond_if_t *bif; |
| 83 | u32 *sw_if_index; |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 84 | struct vnet_hw_interface_t *mif_hw; |
Steven | 4f8863b | 2018-04-12 19:36:19 -0700 | [diff] [blame] | 85 | |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 86 | bif = bond_get_bond_if_by_sw_if_index (bif_hw->sw_if_index); |
Steven | 4f8863b | 2018-04-12 19:36:19 -0700 | [diff] [blame] | 87 | if (!bif) |
| 88 | return 0; |
| 89 | |
| 90 | if ((bif_hw->l2_if_count == 1) && (l2_if_adjust == 1)) |
| 91 | { |
| 92 | /* Just added first L2 interface on this port */ |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 93 | vec_foreach (sw_if_index, bif->members) |
Steven | 4f8863b | 2018-04-12 19:36:19 -0700 | [diff] [blame] | 94 | { |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 95 | mif_hw = vnet_get_sup_hw_interface (vnm, *sw_if_index); |
| 96 | ethernet_set_flags (vnm, mif_hw->hw_if_index, |
Steven | 4f8863b | 2018-04-12 19:36:19 -0700 | [diff] [blame] | 97 | ETHERNET_INTERFACE_FLAG_ACCEPT_ALL); |
Steven | 4f8863b | 2018-04-12 19:36:19 -0700 | [diff] [blame] | 98 | } |
| 99 | } |
Steven Luong | a1f9ee8 | 2019-04-09 12:18:46 -0700 | [diff] [blame] | 100 | else if ((bif_hw->l2_if_count == 0) && (l2_if_adjust == -1)) |
| 101 | { |
| 102 | /* Just removed last L2 subinterface on this port */ |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 103 | vec_foreach (sw_if_index, bif->members) |
Steven Luong | a1f9ee8 | 2019-04-09 12:18:46 -0700 | [diff] [blame] | 104 | { |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 105 | mif_hw = vnet_get_sup_hw_interface (vnm, *sw_if_index); |
| 106 | ethernet_set_flags (vnm, mif_hw->hw_if_index, |
John Lo | f415a3b | 2020-05-14 15:02:16 -0400 | [diff] [blame] | 107 | /*ETHERNET_INTERFACE_FLAG_DEFAULT_L3 */ 0); |
Steven Luong | a1f9ee8 | 2019-04-09 12:18:46 -0700 | [diff] [blame] | 108 | } |
| 109 | } |
Steven | 4f8863b | 2018-04-12 19:36:19 -0700 | [diff] [blame] | 110 | |
| 111 | return 0; |
| 112 | } |
| 113 | |
| 114 | static __clib_unused clib_error_t * |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 115 | bond_subif_add_del_function (vnet_main_t * vnm, u32 hw_if_index, |
| 116 | struct vnet_sw_interface_t *st, int is_add) |
| 117 | { |
| 118 | /* Nothing for now */ |
| 119 | return 0; |
| 120 | } |
| 121 | |
| 122 | static clib_error_t * |
| 123 | bond_interface_admin_up_down (vnet_main_t * vnm, u32 hw_if_index, u32 flags) |
| 124 | { |
| 125 | vnet_hw_interface_t *hif = vnet_get_hw_interface (vnm, hw_if_index); |
| 126 | uword is_up = (flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) != 0; |
| 127 | bond_main_t *bm = &bond_main; |
| 128 | bond_if_t *bif = pool_elt_at_index (bm->interfaces, hif->dev_instance); |
| 129 | |
| 130 | bif->admin_up = is_up; |
Steven Luong | dc2abbe | 2020-07-28 12:28:03 -0700 | [diff] [blame] | 131 | if (is_up) |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 132 | vnet_hw_interface_set_flags (vnm, bif->hw_if_index, |
| 133 | VNET_HW_INTERFACE_FLAG_LINK_UP); |
| 134 | return 0; |
| 135 | } |
| 136 | |
Matthew Smith | e83aa45 | 2019-11-14 10:36:02 -0600 | [diff] [blame] | 137 | static clib_error_t * |
| 138 | bond_add_del_mac_address (vnet_hw_interface_t * hi, const u8 * address, |
| 139 | u8 is_add) |
| 140 | { |
| 141 | vnet_main_t *vnm = vnet_get_main (); |
| 142 | bond_if_t *bif; |
| 143 | clib_error_t *error = 0; |
| 144 | vnet_hw_interface_t *s_hi; |
| 145 | int i; |
| 146 | |
| 147 | |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 148 | bif = bond_get_bond_if_by_sw_if_index (hi->sw_if_index); |
Matthew Smith | e83aa45 | 2019-11-14 10:36:02 -0600 | [diff] [blame] | 149 | if (!bif) |
| 150 | { |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 151 | return clib_error_return (0, |
| 152 | "No bond interface found for sw_if_index %u", |
Matthew Smith | e83aa45 | 2019-11-14 10:36:02 -0600 | [diff] [blame] | 153 | hi->sw_if_index); |
| 154 | } |
| 155 | |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 156 | /* Add/del address on each member hw intf, they control the hardware */ |
| 157 | vec_foreach_index (i, bif->members) |
Matthew Smith | e83aa45 | 2019-11-14 10:36:02 -0600 | [diff] [blame] | 158 | { |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 159 | s_hi = vnet_get_sup_hw_interface (vnm, vec_elt (bif->members, i)); |
Matthew Smith | e83aa45 | 2019-11-14 10:36:02 -0600 | [diff] [blame] | 160 | error = vnet_hw_interface_add_del_mac_address (vnm, s_hi->hw_if_index, |
| 161 | address, is_add); |
| 162 | |
| 163 | if (error) |
| 164 | { |
| 165 | int j; |
| 166 | |
| 167 | /* undo any that were completed before the failure */ |
| 168 | for (j = i - 1; j > -1; j--) |
| 169 | { |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 170 | s_hi = vnet_get_sup_hw_interface (vnm, vec_elt (bif->members, j)); |
Matthew Smith | e83aa45 | 2019-11-14 10:36:02 -0600 | [diff] [blame] | 171 | vnet_hw_interface_add_del_mac_address (vnm, s_hi->hw_if_index, |
| 172 | address, !(is_add)); |
| 173 | } |
| 174 | |
| 175 | return error; |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | return 0; |
| 180 | } |
| 181 | |
Damjan Marion | 69fdfee | 2018-10-06 14:33:18 +0200 | [diff] [blame] | 182 | static_always_inline void |
| 183 | bond_tx_add_to_queue (bond_per_thread_data_t * ptd, u32 port, u32 bi) |
| 184 | { |
| 185 | u32 idx = ptd->per_port_queue[port].n_buffers++; |
| 186 | ptd->per_port_queue[port].buffers[idx] = bi; |
| 187 | } |
| 188 | |
Steven | 0d88301 | 2018-05-11 11:06:23 -0700 | [diff] [blame] | 189 | static_always_inline u32 |
Steven Luong | 05a68d6 | 2021-12-03 12:05:45 -0800 | [diff] [blame] | 190 | bond_lb_broadcast (vlib_main_t *vm, bond_if_t *bif, vlib_buffer_t *b0, |
| 191 | uword n_members) |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 192 | { |
Steven | c4e99c5 | 2018-09-27 20:06:26 -0700 | [diff] [blame] | 193 | bond_main_t *bm = &bond_main; |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 194 | vlib_buffer_t *c0; |
Steven | 22b5be0 | 2018-04-11 15:32:15 -0700 | [diff] [blame] | 195 | int port; |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 196 | u32 sw_if_index; |
Damjan Marion | 067cd62 | 2018-07-11 12:47:43 +0200 | [diff] [blame] | 197 | u16 thread_index = vm->thread_index; |
Steven | c4e99c5 | 2018-09-27 20:06:26 -0700 | [diff] [blame] | 198 | bond_per_thread_data_t *ptd = vec_elt_at_index (bm->per_thread_data, |
| 199 | thread_index); |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 200 | |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 201 | for (port = 1; port < n_members; port++) |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 202 | { |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 203 | sw_if_index = *vec_elt_at_index (bif->active_members, port); |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 204 | c0 = vlib_buffer_copy (vm, b0); |
| 205 | if (PREDICT_TRUE (c0 != 0)) |
| 206 | { |
| 207 | vnet_buffer (c0)->sw_if_index[VLIB_TX] = sw_if_index; |
Damjan Marion | 69fdfee | 2018-10-06 14:33:18 +0200 | [diff] [blame] | 208 | bond_tx_add_to_queue (ptd, port, vlib_get_buffer_index (vm, c0)); |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 209 | } |
| 210 | } |
| 211 | |
| 212 | return 0; |
| 213 | } |
| 214 | |
Steven | 0d88301 | 2018-05-11 11:06:23 -0700 | [diff] [blame] | 215 | static_always_inline u32 |
Steven Luong | 05a68d6 | 2021-12-03 12:05:45 -0800 | [diff] [blame] | 216 | bond_lb_round_robin (bond_if_t *bif, vlib_buffer_t *b0, uword n_members) |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 217 | { |
| 218 | bif->lb_rr_last_index++; |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 219 | if (bif->lb_rr_last_index >= n_members) |
Damjan Marion | 69fdfee | 2018-10-06 14:33:18 +0200 | [diff] [blame] | 220 | bif->lb_rr_last_index = 0; |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 221 | |
| 222 | return bif->lb_rr_last_index; |
| 223 | } |
| 224 | |
Damjan Marion | 16de39e | 2018-09-26 10:15:41 +0200 | [diff] [blame] | 225 | static_always_inline void |
Steven Luong | 05a68d6 | 2021-12-03 12:05:45 -0800 | [diff] [blame] | 226 | bond_tx_hash (vlib_main_t *vm, bond_per_thread_data_t *ptd, bond_if_t *bif, |
| 227 | vlib_buffer_t **b, u32 *h, u32 n_left) |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 228 | { |
Steven Luong | 05a68d6 | 2021-12-03 12:05:45 -0800 | [diff] [blame] | 229 | u32 n_left_from = n_left; |
| 230 | void **data; |
| 231 | |
| 232 | ASSERT (bif->hash_func != 0); |
| 233 | |
| 234 | vec_validate_aligned (ptd->data, n_left - 1, CLIB_CACHE_LINE_BYTES); |
| 235 | data = ptd->data; |
| 236 | while (n_left >= 8) |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 237 | { |
Damjan Marion | cefe134 | 2018-09-21 18:11:33 +0200 | [diff] [blame] | 238 | // Prefetch next iteration |
Steven Luong | 05a68d6 | 2021-12-03 12:05:45 -0800 | [diff] [blame] | 239 | vlib_prefetch_buffer_header (b[4], LOAD); |
| 240 | vlib_prefetch_buffer_header (b[5], LOAD); |
| 241 | vlib_prefetch_buffer_header (b[6], LOAD); |
| 242 | vlib_prefetch_buffer_header (b[7], LOAD); |
Steven | 0d88301 | 2018-05-11 11:06:23 -0700 | [diff] [blame] | 243 | |
Steven Luong | 05a68d6 | 2021-12-03 12:05:45 -0800 | [diff] [blame] | 244 | data[0] = vlib_buffer_get_current (b[0]); |
| 245 | data[1] = vlib_buffer_get_current (b[1]); |
| 246 | data[2] = vlib_buffer_get_current (b[2]); |
| 247 | data[3] = vlib_buffer_get_current (b[3]); |
Damjan Marion | cefe134 | 2018-09-21 18:11:33 +0200 | [diff] [blame] | 248 | |
Steven Luong | 05a68d6 | 2021-12-03 12:05:45 -0800 | [diff] [blame] | 249 | n_left -= 4; |
| 250 | b += 4; |
| 251 | data += 4; |
| 252 | } |
Damjan Marion | cefe134 | 2018-09-21 18:11:33 +0200 | [diff] [blame] | 253 | |
Steven Luong | 05a68d6 | 2021-12-03 12:05:45 -0800 | [diff] [blame] | 254 | while (n_left > 0) |
| 255 | { |
| 256 | data[0] = vlib_buffer_get_current (b[0]); |
| 257 | |
| 258 | n_left -= 1; |
| 259 | b += 1; |
| 260 | data += 1; |
| 261 | } |
| 262 | |
| 263 | bif->hash_func (ptd->data, h, n_left_from); |
| 264 | vec_reset_length (ptd->data); |
| 265 | } |
| 266 | |
| 267 | static_always_inline void |
| 268 | bond_tx_no_hash (vlib_main_t *vm, bond_if_t *bif, vlib_buffer_t **b, u32 *h, |
| 269 | u32 n_left, uword n_members, u32 lb_alg) |
| 270 | { |
| 271 | while (n_left >= 8) |
| 272 | { |
| 273 | // Prefetch next iteration |
| 274 | vlib_prefetch_buffer_header (b[4], LOAD); |
| 275 | vlib_prefetch_buffer_header (b[5], LOAD); |
| 276 | vlib_prefetch_buffer_header (b[6], LOAD); |
| 277 | vlib_prefetch_buffer_header (b[7], LOAD); |
| 278 | |
| 279 | clib_prefetch_load (b[4]->data); |
| 280 | clib_prefetch_load (b[5]->data); |
| 281 | clib_prefetch_load (b[6]->data); |
| 282 | clib_prefetch_load (b[7]->data); |
| 283 | |
| 284 | if (lb_alg == BOND_LB_RR) |
Damjan Marion | 69fdfee | 2018-10-06 14:33:18 +0200 | [diff] [blame] | 285 | { |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 286 | h[0] = bond_lb_round_robin (bif, b[0], n_members); |
| 287 | h[1] = bond_lb_round_robin (bif, b[1], n_members); |
| 288 | h[2] = bond_lb_round_robin (bif, b[2], n_members); |
| 289 | h[3] = bond_lb_round_robin (bif, b[3], n_members); |
Damjan Marion | 69fdfee | 2018-10-06 14:33:18 +0200 | [diff] [blame] | 290 | } |
| 291 | else if (lb_alg == BOND_LB_BC) |
| 292 | { |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 293 | h[0] = bond_lb_broadcast (vm, bif, b[0], n_members); |
| 294 | h[1] = bond_lb_broadcast (vm, bif, b[1], n_members); |
| 295 | h[2] = bond_lb_broadcast (vm, bif, b[2], n_members); |
| 296 | h[3] = bond_lb_broadcast (vm, bif, b[3], n_members); |
Damjan Marion | 69fdfee | 2018-10-06 14:33:18 +0200 | [diff] [blame] | 297 | } |
| 298 | else |
| 299 | { |
| 300 | ASSERT (0); |
| 301 | } |
Steven | c4e99c5 | 2018-09-27 20:06:26 -0700 | [diff] [blame] | 302 | |
Damjan Marion | cefe134 | 2018-09-21 18:11:33 +0200 | [diff] [blame] | 303 | n_left -= 4; |
| 304 | b += 4; |
Damjan Marion | 69fdfee | 2018-10-06 14:33:18 +0200 | [diff] [blame] | 305 | h += 4; |
Damjan Marion | cefe134 | 2018-09-21 18:11:33 +0200 | [diff] [blame] | 306 | } |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 307 | |
Damjan Marion | cefe134 | 2018-09-21 18:11:33 +0200 | [diff] [blame] | 308 | while (n_left > 0) |
| 309 | { |
Steven Luong | 05a68d6 | 2021-12-03 12:05:45 -0800 | [diff] [blame] | 310 | if (bif->lb == BOND_LB_RR) |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 311 | h[0] = bond_lb_round_robin (bif, b[0], n_members); |
Damjan Marion | 69fdfee | 2018-10-06 14:33:18 +0200 | [diff] [blame] | 312 | else if (bif->lb == BOND_LB_BC) |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 313 | h[0] = bond_lb_broadcast (vm, bif, b[0], n_members); |
Damjan Marion | 69fdfee | 2018-10-06 14:33:18 +0200 | [diff] [blame] | 314 | else |
Damjan Marion | 16de39e | 2018-09-26 10:15:41 +0200 | [diff] [blame] | 315 | { |
Damjan Marion | 69fdfee | 2018-10-06 14:33:18 +0200 | [diff] [blame] | 316 | ASSERT (0); |
Damjan Marion | 16de39e | 2018-09-26 10:15:41 +0200 | [diff] [blame] | 317 | } |
| 318 | |
Damjan Marion | cefe134 | 2018-09-21 18:11:33 +0200 | [diff] [blame] | 319 | n_left -= 1; |
| 320 | b += 1; |
Steven Luong | de0302c | 2019-10-04 14:18:37 -0700 | [diff] [blame] | 321 | h += 1; |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 322 | } |
Damjan Marion | 69fdfee | 2018-10-06 14:33:18 +0200 | [diff] [blame] | 323 | } |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 324 | |
Damjan Marion | 69fdfee | 2018-10-06 14:33:18 +0200 | [diff] [blame] | 325 | static_always_inline void |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 326 | bond_hash_to_port (u32 * h, u32 n_left, u32 n_members, |
| 327 | int use_modulo_shortcut) |
Damjan Marion | 69fdfee | 2018-10-06 14:33:18 +0200 | [diff] [blame] | 328 | { |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 329 | u32 mask = n_members - 1; |
Damjan Marion | 69fdfee | 2018-10-06 14:33:18 +0200 | [diff] [blame] | 330 | |
Damjan Marion | 69fdfee | 2018-10-06 14:33:18 +0200 | [diff] [blame] | 331 | while (n_left > 4) |
| 332 | { |
| 333 | if (use_modulo_shortcut) |
| 334 | { |
| 335 | h[0] &= mask; |
| 336 | h[1] &= mask; |
| 337 | h[2] &= mask; |
| 338 | h[3] &= mask; |
| 339 | } |
| 340 | else |
| 341 | { |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 342 | h[0] %= n_members; |
| 343 | h[1] %= n_members; |
| 344 | h[2] %= n_members; |
| 345 | h[3] %= n_members; |
Damjan Marion | 69fdfee | 2018-10-06 14:33:18 +0200 | [diff] [blame] | 346 | } |
| 347 | n_left -= 4; |
| 348 | h += 4; |
| 349 | } |
| 350 | while (n_left) |
| 351 | { |
| 352 | if (use_modulo_shortcut) |
| 353 | h[0] &= mask; |
| 354 | else |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 355 | h[0] %= n_members; |
Damjan Marion | 69fdfee | 2018-10-06 14:33:18 +0200 | [diff] [blame] | 356 | n_left -= 1; |
| 357 | h += 1; |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | static_always_inline void |
| 362 | bond_update_sw_if_index (bond_per_thread_data_t * ptd, bond_if_t * bif, |
| 363 | u32 * bi, vlib_buffer_t ** b, u32 * data, u32 n_left, |
| 364 | int single_sw_if_index) |
| 365 | { |
| 366 | u32 sw_if_index = data[0]; |
| 367 | u32 *h = data; |
| 368 | |
Steven Luong | 05a68d6 | 2021-12-03 12:05:45 -0800 | [diff] [blame] | 369 | while (n_left >= 8) |
Damjan Marion | 69fdfee | 2018-10-06 14:33:18 +0200 | [diff] [blame] | 370 | { |
| 371 | // Prefetch next iteration |
Steven Luong | 05a68d6 | 2021-12-03 12:05:45 -0800 | [diff] [blame] | 372 | vlib_prefetch_buffer_header (b[4], LOAD); |
| 373 | vlib_prefetch_buffer_header (b[5], LOAD); |
| 374 | vlib_prefetch_buffer_header (b[6], LOAD); |
| 375 | vlib_prefetch_buffer_header (b[7], LOAD); |
Damjan Marion | 69fdfee | 2018-10-06 14:33:18 +0200 | [diff] [blame] | 376 | |
| 377 | if (PREDICT_FALSE (single_sw_if_index)) |
| 378 | { |
| 379 | vnet_buffer (b[0])->sw_if_index[VLIB_TX] = sw_if_index; |
| 380 | vnet_buffer (b[1])->sw_if_index[VLIB_TX] = sw_if_index; |
| 381 | vnet_buffer (b[2])->sw_if_index[VLIB_TX] = sw_if_index; |
| 382 | vnet_buffer (b[3])->sw_if_index[VLIB_TX] = sw_if_index; |
| 383 | |
| 384 | bond_tx_add_to_queue (ptd, 0, bi[0]); |
| 385 | bond_tx_add_to_queue (ptd, 0, bi[1]); |
| 386 | bond_tx_add_to_queue (ptd, 0, bi[2]); |
| 387 | bond_tx_add_to_queue (ptd, 0, bi[3]); |
| 388 | } |
| 389 | else |
| 390 | { |
Steven Luong | 05a68d6 | 2021-12-03 12:05:45 -0800 | [diff] [blame] | 391 | vnet_buffer (b[0])->sw_if_index[VLIB_TX] = |
| 392 | *vec_elt_at_index (bif->active_members, h[0]); |
| 393 | vnet_buffer (b[1])->sw_if_index[VLIB_TX] = |
| 394 | *vec_elt_at_index (bif->active_members, h[1]); |
| 395 | vnet_buffer (b[2])->sw_if_index[VLIB_TX] = |
| 396 | *vec_elt_at_index (bif->active_members, h[2]); |
| 397 | vnet_buffer (b[3])->sw_if_index[VLIB_TX] = |
| 398 | *vec_elt_at_index (bif->active_members, h[3]); |
Damjan Marion | 69fdfee | 2018-10-06 14:33:18 +0200 | [diff] [blame] | 399 | |
| 400 | bond_tx_add_to_queue (ptd, h[0], bi[0]); |
| 401 | bond_tx_add_to_queue (ptd, h[1], bi[1]); |
| 402 | bond_tx_add_to_queue (ptd, h[2], bi[2]); |
| 403 | bond_tx_add_to_queue (ptd, h[3], bi[3]); |
| 404 | } |
| 405 | |
| 406 | bi += 4; |
| 407 | h += 4; |
| 408 | b += 4; |
| 409 | n_left -= 4; |
| 410 | } |
| 411 | while (n_left) |
| 412 | { |
| 413 | if (PREDICT_FALSE (single_sw_if_index)) |
| 414 | { |
| 415 | vnet_buffer (b[0])->sw_if_index[VLIB_TX] = sw_if_index; |
| 416 | bond_tx_add_to_queue (ptd, 0, bi[0]); |
| 417 | } |
| 418 | else |
| 419 | { |
Steven Luong | 05a68d6 | 2021-12-03 12:05:45 -0800 | [diff] [blame] | 420 | vnet_buffer (b[0])->sw_if_index[VLIB_TX] = |
| 421 | *vec_elt_at_index (bif->active_members, h[0]); |
Damjan Marion | 69fdfee | 2018-10-06 14:33:18 +0200 | [diff] [blame] | 422 | bond_tx_add_to_queue (ptd, h[0], bi[0]); |
| 423 | } |
| 424 | |
| 425 | bi += 1; |
| 426 | h += 1; |
| 427 | b += 1; |
| 428 | n_left -= 1; |
| 429 | } |
| 430 | } |
| 431 | |
| 432 | static_always_inline void |
| 433 | bond_tx_trace (vlib_main_t * vm, vlib_node_runtime_t * node, bond_if_t * bif, |
| 434 | vlib_buffer_t ** b, u32 n_left, u32 * h) |
| 435 | { |
| 436 | uword n_trace = vlib_get_trace_count (vm, node); |
| 437 | |
| 438 | while (n_trace > 0 && n_left > 0) |
| 439 | { |
Benoît Ganne | 9a3973e | 2020-10-02 19:36:57 +0200 | [diff] [blame] | 440 | if (PREDICT_TRUE |
| 441 | (vlib_trace_buffer (vm, node, 0, b[0], 0 /* follow_chain */ ))) |
| 442 | { |
| 443 | bond_packet_trace_t *t0; |
| 444 | ethernet_header_t *eth; |
Damjan Marion | 69fdfee | 2018-10-06 14:33:18 +0200 | [diff] [blame] | 445 | |
Benoît Ganne | 9a3973e | 2020-10-02 19:36:57 +0200 | [diff] [blame] | 446 | vlib_set_trace_count (vm, node, --n_trace); |
| 447 | t0 = vlib_add_trace (vm, node, b[0], sizeof (*t0)); |
| 448 | eth = vlib_buffer_get_current (b[0]); |
| 449 | t0->ethernet = *eth; |
| 450 | t0->sw_if_index = vnet_buffer (b[0])->sw_if_index[VLIB_TX]; |
| 451 | if (!h) |
| 452 | { |
| 453 | t0->bond_sw_if_index = |
| 454 | *vec_elt_at_index (bif->active_members, 0); |
| 455 | } |
| 456 | else |
| 457 | { |
| 458 | t0->bond_sw_if_index = |
| 459 | *vec_elt_at_index (bif->active_members, h[0]); |
| 460 | h++; |
| 461 | } |
Damjan Marion | 69fdfee | 2018-10-06 14:33:18 +0200 | [diff] [blame] | 462 | } |
| 463 | b++; |
| 464 | n_left--; |
| 465 | } |
Damjan Marion | 16de39e | 2018-09-26 10:15:41 +0200 | [diff] [blame] | 466 | } |
| 467 | |
| 468 | VNET_DEVICE_CLASS_TX_FN (bond_dev_class) (vlib_main_t * vm, |
| 469 | vlib_node_runtime_t * node, |
| 470 | vlib_frame_t * frame) |
| 471 | { |
| 472 | vnet_interface_output_runtime_t *rund = (void *) node->runtime_data; |
| 473 | bond_main_t *bm = &bond_main; |
| 474 | u16 thread_index = vm->thread_index; |
| 475 | bond_if_t *bif = pool_elt_at_index (bm->interfaces, rund->dev_instance); |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 476 | uword n_members; |
Damjan Marion | 69fdfee | 2018-10-06 14:33:18 +0200 | [diff] [blame] | 477 | vlib_buffer_t *bufs[VLIB_FRAME_SIZE]; |
| 478 | u32 *from = vlib_frame_vector_args (frame); |
| 479 | u32 n_left = frame->n_vectors; |
| 480 | u32 hashes[VLIB_FRAME_SIZE], *h; |
| 481 | vnet_main_t *vnm = vnet_get_main (); |
| 482 | bond_per_thread_data_t *ptd = vec_elt_at_index (bm->per_thread_data, |
| 483 | thread_index); |
| 484 | u32 p, sw_if_index; |
Damjan Marion | 16de39e | 2018-09-26 10:15:41 +0200 | [diff] [blame] | 485 | |
| 486 | if (PREDICT_FALSE (bif->admin_up == 0)) |
| 487 | { |
Damjan Marion | a3d5986 | 2018-11-10 10:23:00 +0100 | [diff] [blame] | 488 | vlib_buffer_free (vm, vlib_frame_vector_args (frame), frame->n_vectors); |
Damjan Marion | 16de39e | 2018-09-26 10:15:41 +0200 | [diff] [blame] | 489 | vlib_increment_simple_counter (vnet_main.interface_main.sw_if_counters + |
| 490 | VNET_INTERFACE_COUNTER_DROP, |
| 491 | thread_index, bif->sw_if_index, |
| 492 | frame->n_vectors); |
| 493 | vlib_error_count (vm, node->node_index, BOND_TX_ERROR_IF_DOWN, |
| 494 | frame->n_vectors); |
| 495 | return frame->n_vectors; |
| 496 | } |
| 497 | |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 498 | n_members = vec_len (bif->active_members); |
| 499 | if (PREDICT_FALSE (n_members == 0)) |
Damjan Marion | 16de39e | 2018-09-26 10:15:41 +0200 | [diff] [blame] | 500 | { |
Damjan Marion | a3d5986 | 2018-11-10 10:23:00 +0100 | [diff] [blame] | 501 | vlib_buffer_free (vm, vlib_frame_vector_args (frame), frame->n_vectors); |
Damjan Marion | 16de39e | 2018-09-26 10:15:41 +0200 | [diff] [blame] | 502 | vlib_increment_simple_counter (vnet_main.interface_main.sw_if_counters + |
| 503 | VNET_INTERFACE_COUNTER_DROP, |
| 504 | thread_index, bif->sw_if_index, |
| 505 | frame->n_vectors); |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 506 | vlib_error_count (vm, node->node_index, BOND_TX_ERROR_NO_MEMBER, |
Damjan Marion | 16de39e | 2018-09-26 10:15:41 +0200 | [diff] [blame] | 507 | frame->n_vectors); |
| 508 | return frame->n_vectors; |
| 509 | } |
| 510 | |
Damjan Marion | 69fdfee | 2018-10-06 14:33:18 +0200 | [diff] [blame] | 511 | vlib_get_buffers (vm, from, bufs, n_left); |
| 512 | |
Paul Vinciguerra | 8feeaff | 2019-03-27 11:25:48 -0700 | [diff] [blame] | 513 | /* active-backup mode, ship everything to first sw if index */ |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 514 | if ((bif->lb == BOND_LB_AB) || PREDICT_FALSE (n_members == 1)) |
Damjan Marion | 69fdfee | 2018-10-06 14:33:18 +0200 | [diff] [blame] | 515 | { |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 516 | sw_if_index = *vec_elt_at_index (bif->active_members, 0); |
Damjan Marion | 69fdfee | 2018-10-06 14:33:18 +0200 | [diff] [blame] | 517 | |
| 518 | bond_tx_trace (vm, node, bif, bufs, frame->n_vectors, 0); |
| 519 | bond_update_sw_if_index (ptd, bif, from, bufs, &sw_if_index, n_left, |
| 520 | /* single_sw_if_index */ 1); |
| 521 | goto done; |
| 522 | } |
| 523 | |
| 524 | if (bif->lb == BOND_LB_BC) |
| 525 | { |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 526 | sw_if_index = *vec_elt_at_index (bif->active_members, 0); |
Damjan Marion | 69fdfee | 2018-10-06 14:33:18 +0200 | [diff] [blame] | 527 | |
Steven Luong | 05a68d6 | 2021-12-03 12:05:45 -0800 | [diff] [blame] | 528 | bond_tx_no_hash (vm, bif, bufs, hashes, n_left, n_members, BOND_LB_BC); |
Damjan Marion | 69fdfee | 2018-10-06 14:33:18 +0200 | [diff] [blame] | 529 | bond_tx_trace (vm, node, bif, bufs, frame->n_vectors, 0); |
| 530 | bond_update_sw_if_index (ptd, bif, from, bufs, &sw_if_index, n_left, |
| 531 | /* single_sw_if_index */ 1); |
| 532 | goto done; |
| 533 | } |
| 534 | |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 535 | /* if have at least one member on local numa node, only members on local numa |
Zhiyong Yang | 751e3f3 | 2019-06-26 05:49:14 -0400 | [diff] [blame] | 536 | node will transmit pkts when bif->local_numa_only is enabled */ |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 537 | if (bif->n_numa_members >= 1) |
| 538 | n_members = bif->n_numa_members; |
Zhiyong Yang | 751e3f3 | 2019-06-26 05:49:14 -0400 | [diff] [blame] | 539 | |
Steven Luong | 05a68d6 | 2021-12-03 12:05:45 -0800 | [diff] [blame] | 540 | if (bif->lb == BOND_LB_RR) |
| 541 | bond_tx_no_hash (vm, bif, bufs, hashes, n_left, n_members, BOND_LB_RR); |
Damjan Marion | 16de39e | 2018-09-26 10:15:41 +0200 | [diff] [blame] | 542 | else |
Steven Luong | 05a68d6 | 2021-12-03 12:05:45 -0800 | [diff] [blame] | 543 | bond_tx_hash (vm, ptd, bif, bufs, hashes, n_left); |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 544 | |
Damjan Marion | 69fdfee | 2018-10-06 14:33:18 +0200 | [diff] [blame] | 545 | /* calculate port out of hash */ |
| 546 | h = hashes; |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 547 | if (BOND_MODULO_SHORTCUT (n_members)) |
| 548 | bond_hash_to_port (h, frame->n_vectors, n_members, 1); |
Damjan Marion | 69fdfee | 2018-10-06 14:33:18 +0200 | [diff] [blame] | 549 | else |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 550 | bond_hash_to_port (h, frame->n_vectors, n_members, 0); |
Damjan Marion | 69fdfee | 2018-10-06 14:33:18 +0200 | [diff] [blame] | 551 | |
| 552 | bond_tx_trace (vm, node, bif, bufs, frame->n_vectors, h); |
| 553 | |
| 554 | bond_update_sw_if_index (ptd, bif, from, bufs, hashes, frame->n_vectors, |
| 555 | /* single_sw_if_index */ 0); |
| 556 | |
| 557 | done: |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 558 | for (p = 0; p < n_members; p++) |
Damjan Marion | 69fdfee | 2018-10-06 14:33:18 +0200 | [diff] [blame] | 559 | { |
| 560 | vlib_frame_t *f; |
| 561 | u32 *to_next; |
| 562 | |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 563 | sw_if_index = *vec_elt_at_index (bif->active_members, p); |
Damjan Marion | 69fdfee | 2018-10-06 14:33:18 +0200 | [diff] [blame] | 564 | if (PREDICT_TRUE (ptd->per_port_queue[p].n_buffers)) |
| 565 | { |
| 566 | f = vnet_get_frame_to_sw_interface (vnm, sw_if_index); |
| 567 | f->n_vectors = ptd->per_port_queue[p].n_buffers; |
| 568 | to_next = vlib_frame_vector_args (f); |
Dave Barach | 178cf49 | 2018-11-13 16:34:13 -0500 | [diff] [blame] | 569 | clib_memcpy_fast (to_next, ptd->per_port_queue[p].buffers, |
| 570 | f->n_vectors * sizeof (u32)); |
Damjan Marion | 69fdfee | 2018-10-06 14:33:18 +0200 | [diff] [blame] | 571 | vnet_put_frame_to_sw_interface (vnm, sw_if_index, f); |
| 572 | ptd->per_port_queue[p].n_buffers = 0; |
| 573 | } |
| 574 | } |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 575 | return frame->n_vectors; |
| 576 | } |
| 577 | |
Steven | 9f781d8 | 2018-06-05 11:09:32 -0700 | [diff] [blame] | 578 | static walk_rc_t |
| 579 | bond_active_interface_switch_cb (vnet_main_t * vnm, u32 sw_if_index, |
| 580 | void *arg) |
| 581 | { |
| 582 | bond_main_t *bm = &bond_main; |
| 583 | |
Neale Ranns | dc617b8 | 2020-08-20 08:22:56 +0000 | [diff] [blame] | 584 | ip4_neighbor_advertise (bm->vlib_main, bm->vnet_main, sw_if_index, NULL); |
| 585 | ip6_neighbor_advertise (bm->vlib_main, bm->vnet_main, sw_if_index, NULL); |
Steven | 9f781d8 | 2018-06-05 11:09:32 -0700 | [diff] [blame] | 586 | |
| 587 | return (WALK_CONTINUE); |
| 588 | } |
| 589 | |
| 590 | static uword |
| 591 | bond_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f) |
| 592 | { |
| 593 | vnet_main_t *vnm = vnet_get_main (); |
| 594 | uword event_type, *event_data = 0; |
| 595 | |
| 596 | while (1) |
| 597 | { |
| 598 | u32 i; |
| 599 | u32 hw_if_index; |
| 600 | |
| 601 | vlib_process_wait_for_event (vm); |
| 602 | event_type = vlib_process_get_events (vm, &event_data); |
| 603 | ASSERT (event_type == BOND_SEND_GARP_NA); |
| 604 | for (i = 0; i < vec_len (event_data); i++) |
| 605 | { |
| 606 | hw_if_index = event_data[i]; |
Steven Luong | bac326c | 2019-08-05 09:47:58 -0700 | [diff] [blame] | 607 | if (vnet_get_hw_interface_or_null (vnm, hw_if_index)) |
| 608 | /* walk hw interface to process all subinterfaces */ |
| 609 | vnet_hw_interface_walk_sw (vnm, hw_if_index, |
| 610 | bond_active_interface_switch_cb, 0); |
Steven | 9f781d8 | 2018-06-05 11:09:32 -0700 | [diff] [blame] | 611 | } |
| 612 | vec_reset_length (event_data); |
| 613 | } |
| 614 | return 0; |
| 615 | } |
| 616 | |
| 617 | /* *INDENT-OFF* */ |
| 618 | VLIB_REGISTER_NODE (bond_process_node) = { |
| 619 | .function = bond_process, |
Damjan Marion | 7ca5aaa | 2019-09-24 18:10:49 +0200 | [diff] [blame] | 620 | .flags = VLIB_NODE_FLAG_TRACE_SUPPORTED, |
Steven | 9f781d8 | 2018-06-05 11:09:32 -0700 | [diff] [blame] | 621 | .type = VLIB_NODE_TYPE_PROCESS, |
| 622 | .name = "bond-process", |
| 623 | }; |
| 624 | /* *INDENT-ON* */ |
| 625 | |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 626 | /* *INDENT-OFF* */ |
| 627 | VNET_DEVICE_CLASS (bond_dev_class) = { |
| 628 | .name = "bond", |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 629 | .tx_function_n_errors = BOND_TX_N_ERROR, |
| 630 | .tx_function_error_strings = bond_tx_error_strings, |
| 631 | .format_device_name = format_bond_interface_name, |
Steven | 4f8863b | 2018-04-12 19:36:19 -0700 | [diff] [blame] | 632 | .set_l2_mode_function = bond_set_l2_mode_function, |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 633 | .admin_up_down_function = bond_interface_admin_up_down, |
| 634 | .subif_add_del_function = bond_subif_add_del_function, |
| 635 | .format_tx_trace = format_bond_tx_trace, |
Matthew Smith | e83aa45 | 2019-11-14 10:36:02 -0600 | [diff] [blame] | 636 | .mac_addr_add_del_function = bond_add_del_mac_address, |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 637 | }; |
| 638 | |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 639 | /* *INDENT-ON* */ |
| 640 | |
Steven Luong | bac326c | 2019-08-05 09:47:58 -0700 | [diff] [blame] | 641 | static clib_error_t * |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 642 | bond_member_interface_add_del (vnet_main_t * vnm, u32 sw_if_index, u32 is_add) |
Steven Luong | bac326c | 2019-08-05 09:47:58 -0700 | [diff] [blame] | 643 | { |
| 644 | bond_main_t *bm = &bond_main; |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 645 | member_if_t *mif; |
| 646 | bond_detach_member_args_t args = { 0 }; |
Steven Luong | bac326c | 2019-08-05 09:47:58 -0700 | [diff] [blame] | 647 | |
| 648 | if (is_add) |
| 649 | return 0; |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 650 | mif = bond_get_member_by_sw_if_index (sw_if_index); |
| 651 | if (!mif) |
Steven Luong | bac326c | 2019-08-05 09:47:58 -0700 | [diff] [blame] | 652 | return 0; |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 653 | args.member = sw_if_index; |
| 654 | bond_detach_member (bm->vlib_main, &args); |
Steven Luong | bac326c | 2019-08-05 09:47:58 -0700 | [diff] [blame] | 655 | return args.error; |
| 656 | } |
| 657 | |
Steven Luong | 4c4223e | 2020-07-15 08:44:54 -0700 | [diff] [blame] | 658 | VNET_SW_INTERFACE_ADD_DEL_FUNCTION (bond_member_interface_add_del); |
Steven Luong | bac326c | 2019-08-05 09:47:58 -0700 | [diff] [blame] | 659 | |
Steven | 9cd2d7a | 2017-12-20 12:43:01 -0800 | [diff] [blame] | 660 | /* |
| 661 | * fd.io coding-style-patch-verification: ON |
| 662 | * |
| 663 | * Local Variables: |
| 664 | * eval: (c-set-style "gnu") |
| 665 | * End: |
| 666 | */ |