diff --git a/tests/automake.mk b/tests/automake.mk index dc0ad8bd326..4dd6598f6f4 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -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 \ diff --git a/tests/netdev-type.at b/tests/netdev-type.at new file mode 100644 index 00000000000..3edd9fb46e4 --- /dev/null +++ b/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 diff --git a/tests/testsuite.at b/tests/testsuite.at index 7e3f193fc1b..28f22951001 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -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]) diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index 566e7e0f6e3..4ff77c1a825 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -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; }; @@ -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. */ @@ -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", @@ -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)); @@ -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)); @@ -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" @@ -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