If it doesn't exist then it can't have the wrong value. --- vswitchd/bridge.c | 17 +++++++---------- 1 files changed, 7 insertions(+), 10 deletions(-)
diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index b6f30fd..222ed41 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -145,7 +145,6 @@ struct port { /* 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; @@ -423,7 +422,7 @@ iterate_and_prune_ifaces(struct bridge *br, } } - if (!port->n_ifaces) { + if (list_is_empty(&port->ifaces)) { VLOG_WARN("%s port has no interfaces, dropping", port->name); port_destroy(port); } @@ -1791,7 +1790,7 @@ bridge_reconfigure_one(struct bridge *br) } 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); @@ -2007,7 +2006,7 @@ bridge_get_all_ifaces(const struct bridge *br, struct shash *ifaces) 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); } } @@ -2413,7 +2412,7 @@ update_learning_table(struct bridge *br, const struct flow *flow, int vlan, 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; @@ -2834,7 +2833,7 @@ port_reconfigure(struct port *port, const struct ovsrec_port *cfg) /* 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); @@ -2985,7 +2984,7 @@ port_reconfigure_bond_lacp(struct port *port, struct lacp_settings *s) 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; } @@ -3013,7 +3012,7 @@ port_reconfigure_bond(struct port *port) 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; @@ -3116,7 +3115,6 @@ iface_create(struct port *port, const struct ovsrec_interface *if_cfg) 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); @@ -3143,7 +3141,6 @@ iface_destroy(struct iface *iface) } list_remove(&iface->port_elem); - port->n_ifaces--; netdev_close(iface->netdev); -- 1.7.1 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev