From: Ben Pfaff Date: Fri, 2 Oct 2009 17:41:05 +0000 (-0700) Subject: vswitch: Factor out detection of internal interfaces into a new function. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=557d8e6cbf2b013ff565458f183df29949729a9b;p=openvswitch vswitch: Factor out detection of internal interfaces into a new function. The following commit needs to use this same logic, so break it out into a function to avoid redundancy. --- diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index b525f3d6..2d788ae0 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -242,6 +242,7 @@ static void iface_destroy(struct iface *); static struct iface *iface_lookup(const struct bridge *, const char *name); static struct iface *iface_from_dp_ifidx(const struct bridge *, uint16_t dp_ifidx); +static bool iface_is_internal(const struct bridge *, const char *name); /* Hooks into ofproto processing. */ static struct ofhooks bridge_ofhooks; @@ -464,18 +465,8 @@ bridge_reconfigure(void) bool internal; int error; - /* It's an internal interface if it's marked that way, or if - * it's a bonded interface for which we're faking up a network - * device. */ - internal = cfg_get_bool(0, "iface.%s.internal", if_name); - if (cfg_get_bool(0, "bonding.%s.fake-iface", if_name)) { - struct port *port = port_lookup(br, if_name); - if (port && port->n_ifaces > 1) { - internal = true; - } - } - /* Add to datapath. */ + internal = iface_is_internal(br, if_name); error = dpif_port_add(&br->dpif, if_name, next_port_no++, internal ? ODP_PORT_INTERNAL : 0); if (error != EEXIST) { @@ -3116,6 +3107,34 @@ iface_from_dp_ifidx(const struct bridge *br, uint16_t dp_ifidx) { return port_array_get(&br->ifaces, dp_ifidx); } + +/* Returns true if 'iface' is the name of an "internal" interface on bridge + * 'br', that is, an interface that is entirely simulated within the datapath. + * The local port (ODPP_LOCAL) is always an internal interface. Other local + * interfaces are created by setting "iface..internal = true". + * + * In addition, we have a kluge-y feature that creates an internal port with + * the name of a bonded port if "bonding..fake-iface = true" is set. + * This feature needs to go away in the long term. Until then, this is one + * reason why this function takes a name instead of a struct iface: the fake + * interfaces created this way do not have a struct iface. */ +static bool +iface_is_internal(const struct bridge *br, const char *iface) +{ + if (!strcmp(iface, br->name) + || cfg_get_bool(0, "iface.%s.internal", iface)) { + return true; + } + + if (cfg_get_bool(0, "bonding.%s.fake-iface", iface)) { + struct port *port = port_lookup(br, iface); + if (port && port->n_ifaces > 1) { + return true; + } + } + + return false; +} /* Port mirroring. */