2
0
mirror of https://github.com/openvswitch/ovs synced 2025-10-21 14:49:41 +00:00

vswitchd: Refactor iface_refresh_type() into iface_get_type().

The calculation that this function does will need to be used in a
context where no "struct iface" is available in an upcoming commit.

Signed-off-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
Ben Pfaff
2012-04-24 15:59:42 -07:00
parent 7f81a52a98
commit b54441b366

View File

@@ -228,7 +228,8 @@ static void mirror_refresh_stats(struct mirror *);
static void iface_configure_lacp(struct iface *, struct lacp_slave_settings *); static void iface_configure_lacp(struct iface *, struct lacp_slave_settings *);
static void iface_create(struct bridge *, struct if_cfg *, int ofp_port); static void iface_create(struct bridge *, struct if_cfg *, int ofp_port);
static void iface_refresh_type(struct iface *); static const char *iface_get_type(const struct ovsrec_interface *,
const struct ovsrec_bridge *);
static void iface_destroy(struct iface *); static void iface_destroy(struct iface *);
static struct iface *iface_lookup(const struct bridge *, const char *name); static struct iface *iface_lookup(const struct bridge *, const char *name);
static struct iface *iface_find(const char *name); static struct iface *iface_find(const char *name);
@@ -1255,7 +1256,7 @@ iface_create(struct bridge *br, struct if_cfg *if_cfg, int ofp_port)
hmap_insert(&br->iface_by_name, &iface->name_node, hmap_insert(&br->iface_by_name, &iface->name_node,
hash_string(iface->name, 0)); hash_string(iface->name, 0));
list_push_back(&port->ifaces, &iface->port_elem); list_push_back(&port->ifaces, &iface->port_elem);
iface_refresh_type(iface); iface->type = iface_get_type(iface->cfg, br->cfg);
if (ofp_port >= 0) { if (ofp_port >= 0) {
iface_set_ofp_port(iface, ofp_port); iface_set_ofp_port(iface, ofp_port);
} }
@@ -2494,6 +2495,8 @@ bridge_add_del_ports(struct bridge *br,
} }
} }
/* Update iface->cfg and iface->type in interfaces that still exist.
* Add new interfaces to creation queue. */
SHASH_FOR_EACH (port_node, &new_ports) { SHASH_FOR_EACH (port_node, &new_ports) {
const struct ovsrec_port *port = port_node->data; const struct ovsrec_port *port = port_node->data;
size_t i; size_t i;
@@ -2504,7 +2507,7 @@ bridge_add_del_ports(struct bridge *br,
if (iface) { if (iface) {
iface->cfg = cfg; iface->cfg = cfg;
iface_refresh_type(iface); iface->type = iface_get_type(cfg, br->cfg);
} else { } else {
bridge_queue_if_cfg(br, cfg, port); bridge_queue_if_cfg(br, cfg, port);
} }
@@ -3060,15 +3063,17 @@ port_is_synthetic(const struct port *port)
/* Interface functions. */ /* Interface functions. */
static void /* Returns the correct network device type for interface 'iface' in bridge
iface_refresh_type(struct iface *iface) * 'br'. */
static const char *
iface_get_type(const struct ovsrec_interface *iface,
const struct ovsrec_bridge *br)
{ {
/* Determine interface type. The local port always has type /* The local port always has type "internal". Other ports take their type
* "internal". Other ports take their type from the database and * from the database and default to "system" if none is specified. */
* default to "system" if none is specified. */ return (!strcmp(iface->name, br->name) ? "internal"
iface->type = (!strcmp(iface->name, iface->port->bridge->name) ? "internal" : iface->type[0] ? iface->type
: iface->cfg->type[0] ? iface->cfg->type : "system");
: "system");
} }
static void static void