Skip to content

Commit

Permalink
bridge: open_type should be used for netdev_open
Browse files Browse the repository at this point in the history
ofproto_port_open_type should be used for netdev_open, but not for other tests.
For example, STP/RSTP check for interfaces of internal type, but that check will
fail when the netdev datapath is used.

The same thing goes for setting MAC address of internal Interfaces. That fails
for the netdev datapath because the interface type is set to "tap", but they are
still interfaces of type "internal", just their netdev implementation is
different.

Use a netdev_type for the type that needs to be used for netdev_open and
ofproto_port, while we still keep the type as the normalized configured type in
the database.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@redhat.com>
Signed-off-by: Jesse Gross <jesse@kernel.org>
  • Loading branch information
Thadeu Lima de Souza Cascardo authored and jessegross committed Jul 6, 2016
1 parent 624818b commit ae72675
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
1 change: 1 addition & 0 deletions tests/automake.mk
Expand Up @@ -60,6 +60,7 @@ TESTSUITE_AT = \
tests/bridge.at \
tests/vlan-splinters.at \
tests/ofproto.at \
tests/netdev-type.at \
tests/ovsdb.at \
tests/ovsdb-log.at \
tests/ovsdb-types.at \
Expand Down
24 changes: 24 additions & 0 deletions tests/netdev-type.at
@@ -0,0 +1,24 @@
AT_BANNER([netdev-type])

dnl Setting MAC address of netdev internal port fails
AT_SETUP([bridge - set MAC address of internal port])
OVS_VSWITCHD_START

# Add an internal port and make sure that it shows up in the datapath.
ADD_OF_PORTS([br0], [1])
AT_CHECK([ovs-appctl dpif/show], [0], [dnl
dummy@ovs-dummy: hit:0 missed:0
br0:
br0 65534/100: (dummy)
p1 1/1: (dummy)
])
#
# Set MAC address of dummy device and check that it has been set
AT_CHECK([ovs-vsctl set Interface p1 type=internal mac=\"aa:55:c0:ff:ee:00\"])
AT_CHECK([ovs-vsctl get Interface p1 mac_in_use], [0], [dnl
"aa:55:c0:ff:ee:00"
])

OVS_APP_EXIT_AND_WAIT([ovs-vswitchd])
OVS_APP_EXIT_AND_WAIT([ovsdb-server])
AT_CLEANUP
1 change: 1 addition & 0 deletions tests/testsuite.at
Expand Up @@ -58,6 +58,7 @@ m4_include([tests/dpctl.at])
m4_include([tests/ofproto-dpif.at])
m4_include([tests/bridge.at])
m4_include([tests/vlan-splinters.at])
m4_include([tests/netdev-type.at])
m4_include([tests/ovsdb.at])
m4_include([tests/ovs-vsctl.at])
m4_include([tests/ovs-monitor-ipsec.at])
Expand Down
16 changes: 12 additions & 4 deletions vswitchd/bridge.c
Expand Up @@ -89,6 +89,7 @@ struct iface {

/* These members are valid only within bridge_reconfigure(). */
const char *type; /* Usually same as cfg->type. */
const char *netdev_type; /* type that should be used for netdev_open. */
const struct ovsrec_interface *cfg;
};

Expand Down Expand Up @@ -786,7 +787,7 @@ bridge_delete_or_reconfigure_ports(struct bridge *br)
goto delete;
}

if (strcmp(ofproto_port.type, iface->type)
if (strcmp(ofproto_port.type, iface->netdev_type)
|| netdev_set_config(iface->netdev, &iface->cfg->options, NULL)) {
/* The interface is the wrong type or can't be configured.
* Delete it. */
Expand Down Expand Up @@ -1751,6 +1752,7 @@ iface_do_create(const struct bridge *br,
{
struct netdev *netdev = NULL;
int error;
const char *type;

if (netdev_is_reserved_name(iface_cfg->name)) {
VLOG_WARN("could not create interface %s, name is reserved",
Expand All @@ -1759,8 +1761,9 @@ iface_do_create(const struct bridge *br,
goto error;
}

error = netdev_open(iface_cfg->name,
iface_get_type(iface_cfg, br->cfg), &netdev);
type = ofproto_port_open_type(br->cfg->datapath_type,
iface_get_type(iface_cfg, br->cfg));
error = netdev_open(iface_cfg->name, type, &netdev);
if (error) {
VLOG_WARN_BUF(errp, "could not open network device %s (%s)",
iface_cfg->name, ovs_strerror(error));
Expand Down Expand Up @@ -1836,6 +1839,8 @@ iface_create(struct bridge *br, const struct ovsrec_interface *iface_cfg,
iface->ofp_port = ofp_port;
iface->netdev = netdev;
iface->type = iface_get_type(iface_cfg, br->cfg);
iface->netdev_type = ofproto_port_open_type(br->cfg->datapath_type,
iface->type);
iface->cfg = iface_cfg;
hmap_insert(&br->ifaces, &iface->ofp_port_node,
hash_ofp_port(ofp_port));
Expand Down Expand Up @@ -3373,10 +3378,13 @@ bridge_del_ports(struct bridge *br, const struct shash *wanted_ports)
const struct ovsrec_interface *cfg = port->interfaces[i];
struct iface *iface = iface_lookup(br, cfg->name);
const char *type = iface_get_type(cfg, br->cfg);
const char *dp_type = br->cfg->datapath_type;
const char *netdev_type = ofproto_port_open_type(dp_type, type);

if (iface) {
iface->cfg = cfg;
iface->type = type;
iface->netdev_type = netdev_type;
} else if (!strcmp(type, "null")) {
VLOG_WARN_ONCE("%s: The null interface type is deprecated and"
" may be removed in February 2013. Please email"
Expand Down Expand Up @@ -4256,7 +4264,7 @@ iface_get_type(const struct ovsrec_interface *iface,
type = iface->type[0] ? iface->type : "system";
}

return ofproto_port_open_type(br->datapath_type, type);
return type;
}

static void
Expand Down

0 comments on commit ae72675

Please sign in to comment.