2 * Copyright (c) 2017 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
17 #include <vlib/vlib.h>
18 #include <vlib/unix/unix.h>
19 #include <vnet/bonding/node.h>
20 #include <lacp/node.h>
23 lacp_set_port_selected (vlib_main_t * vm, member_if_t * mif)
25 /* Handle loopback port */
26 if (!memcmp (mif->partner.system, mif->actor.system, 6) &&
27 (mif->partner.key == mif->actor.key))
29 mif->loopback_port = 1;
30 mif->actor.state &= ~LACP_STATE_AGGREGATION;
32 mif->selected = LACP_PORT_SELECTED;
34 switch (mif->mux_state)
36 case LACP_MUX_STATE_DETACHED:
38 case LACP_MUX_STATE_WAITING:
42 case LACP_MUX_STATE_ATTACHED:
43 if (!(mif->partner.state & LACP_STATE_SYNCHRONIZATION))
46 case LACP_MUX_STATE_COLLECTING_DISTRIBUTING:
51 lacp_machine_dispatch (&lacp_mux_machine, vm, mif, LACP_MUX_EVENT_SELECTED,
56 lacp_selection_logic (vlib_main_t * vm, member_if_t * mif)
62 bif = bond_get_bond_if_by_dev_instance (mif->bif_dev_instance);
63 vec_foreach (sw_if_index, bif->members)
65 mif2 = bond_get_member_by_sw_if_index (*sw_if_index);
66 if (mif2 && (mif2->actor.state & LACP_STATE_SYNCHRONIZATION) &&
71 vec_foreach (sw_if_index, bif->members)
73 mif2 = bond_get_member_by_sw_if_index (*sw_if_index);
77 if (mif2->selected == LACP_PORT_SELECTED)
78 lacp_machine_dispatch (&lacp_mux_machine, vm, mif2,
79 LACP_MUX_EVENT_READY, &mif2->mux_state);
83 lacp_set_port_selected (vm, mif);
87 * fd.io coding-style-patch-verification: ON
90 * eval: (c-set-style "gnu")