/* An ordinary bridge port has 1 interface.
* A bridge port for bonding has at least 2 interfaces. */
struct list ifaces; /* List of "struct iface"s. */
- size_t n_ifaces; /* list_size(ifaces). */
/* Bonding info. */
struct bond *bond;
}
}
- if (!port->n_ifaces) {
+ if (list_is_empty(&port->ifaces)) {
VLOG_WARN("%s port has no interfaces, dropping", port->name);
port_destroy(port);
}
}
port_reconfigure(port, node->data);
- if (!port->n_ifaces) {
+ if (list_is_empty(&port->ifaces)) {
VLOG_WARN("bridge %s: port %s has no interfaces, dropping",
br->name, port->name);
port_destroy(port);
LIST_FOR_EACH (iface, port_elem, &port->ifaces) {
shash_add_once(ifaces, iface->name, iface);
}
- if (port->n_ifaces > 1 && port->cfg->bond_fake_iface) {
+ if (!list_is_short(&port->ifaces) && port->cfg->bond_fake_iface) {
shash_add_once(ifaces, port->name, NULL);
}
}
if (is_gratuitous_arp(flow)) {
/* We don't want to learn from gratuitous ARP packets that are
* reflected back over bond slaves so we lock the learning table. */
- if (in_port->n_ifaces == 1) {
+ if (!in_port->bond) {
mac_entry_set_grat_arp_lock(mac);
} else if (mac_entry_is_grat_arp_locked(mac)) {
return;
/* Get VLAN tag. */
vlan = -1;
if (cfg->tag) {
- if (port->n_ifaces < 2) {
+ if (list_is_short(&port->ifaces)) {
vlan = *cfg->tag;
if (vlan >= 0 && vlan <= 4095) {
VLOG_DBG("port %s: assigning VLAN tag %d", port->name, vlan);
if (s->priority <= 0 || s->priority > UINT16_MAX) {
/* Prefer bondable links if unspecified. */
- s->priority = UINT16_MAX - (port->n_ifaces > 1);
+ s->priority = UINT16_MAX - !list_is_short(&port->ifaces);
}
return s;
}
const char *detect_s;
struct iface *iface;
- if (port->n_ifaces < 2) {
+ if (list_is_short(&port->ifaces)) {
/* Not a bonded port. */
bond_destroy(port->bond);
port->bond = NULL;
shash_add_assert(&br->iface_by_name, iface->name, iface);
list_push_back(&port->ifaces, &iface->port_elem);
- port->n_ifaces++;
VLOG_DBG("attached network device %s to port %s", iface->name, port->name);
}
list_remove(&iface->port_elem);
- port->n_ifaces--;
netdev_close(iface->netdev);