-static bool
-bond_is_link_up(struct bond *bond, struct netdev *netdev)
-{
- return (bond->detect == BLSM_CARRIER
- ? netdev_get_carrier(netdev)
- : netdev_get_miimon(netdev));
-}
-
-static int
-bond_stb_sort_cmp__(const void *a_, const void *b_)
-{
- const struct bond_slave *const *ap = a_;
- const struct bond_slave *const *bp = b_;
- const struct bond_slave *a = *ap;
- const struct bond_slave *b = *bp;
- uint16_t aid = a->stb_id;
- uint16_t bid = b->stb_id;
-
- return aid < bid ? -1 : aid > bid;
-}
-
-static bool
-bond_stb_sort(struct bond *bond)
-{
- size_t i;
-
- if (!bond->stb_slaves || !bond->stb_need_sort) {
- return false;
- }
- bond->stb_need_sort = false;
-
- qsort(bond->stb_slaves, bond->n_stb_slaves, sizeof *bond->stb_slaves,
- bond_stb_sort_cmp__);
-
- for (i = 0; i < bond->n_stb_slaves; i++) {
- bond->stb_slaves[i]->stb_idx = i;
- }
-
- return true;
-}
-
-static void
-bond_stb_enable_slave(struct bond_slave *slave)
-{
- struct bond *bond = slave->bond;
-
- if (!bond->stb_slaves) {
- return;
- }
-
- bond->stb_need_sort = true;
-
- if (slave->enabled) {
- if (bond->len_stb_slaves <= bond->n_stb_slaves) {
- bond->stb_slaves = x2nrealloc(bond->stb_slaves,
- &bond->len_stb_slaves,
- sizeof *bond->stb_slaves);
- }
-
- slave->stb_idx = bond->n_stb_slaves++;
- bond->stb_slaves[slave->stb_idx] = slave;
- } else {
- size_t index = slave->stb_idx;
- bond->stb_slaves[index] = bond->stb_slaves[--bond->n_stb_slaves];
- bond->stb_slaves[index]->stb_idx = index;
- }
-}
-