X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=vswitchd%2Fbridge.c;h=94668a733f9a316912bbf70205f3fa49fae06399;hb=18812dff32ce650440b9f1eac1bb00afe08c621a;hp=bd369eb7e4d8054b6fda80fc476572bc312d82d5;hpb=8cea3c07718d55c6eea288be87b3ea9e4d3b88cd;p=sliver-openvswitch.git diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index bd369eb7e..94668a733 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -846,29 +846,36 @@ bridge_add_ofproto_ports(struct bridge *br) struct ofproto_port ofproto_port; LIST_FOR_EACH_SAFE (iface, next_iface, port_elem, &port->ifaces) { - struct shash args; int error; - /* Open the netdev or reconfigure it. */ - shash_init(&args); - shash_from_ovs_idl_map(iface->cfg->key_options, - iface->cfg->value_options, - iface->cfg->n_options, &args); + /* Open the netdev. */ if (!iface->netdev) { - struct netdev_options options; - options.name = iface->name; - options.type = iface->type; - options.args = &args; - options.ethertype = NETDEV_ETH_TYPE_NONE; - error = netdev_open(&options, &iface->netdev); + error = netdev_open(iface->name, iface->type, &iface->netdev); + if (error) { + VLOG_WARN("could not open network device %s (%s)", + iface->name, strerror(error)); + } } else { - error = netdev_set_config(iface->netdev, &args); + error = 0; } - shash_destroy(&args); - if (error) { - VLOG_WARN("could not %s network device %s (%s)", - iface->netdev ? "reconfigure" : "open", - iface->name, strerror(error)); + + /* Configure the netdev. */ + if (iface->netdev) { + struct shash args; + + shash_init(&args); + shash_from_ovs_idl_map(iface->cfg->key_options, + iface->cfg->value_options, + iface->cfg->n_options, &args); + error = netdev_set_config(iface->netdev, &args); + shash_destroy(&args); + + if (error) { + VLOG_WARN("could not configure network device %s (%s)", + iface->name, strerror(error)); + netdev_close(iface->netdev); + iface->netdev = NULL; + } } /* Add the port, if necessary. */ @@ -892,7 +899,7 @@ bridge_add_ofproto_ports(struct bridge *br) iface_refresh_status(iface); } - /* Delete the iface if */ + /* Delete the iface if we failed. */ if (iface->netdev && iface->ofp_port >= 0) { VLOG_DBG("bridge %s: interface %s is on port %d", br->name, iface->name, iface->ofp_port); @@ -918,15 +925,10 @@ bridge_add_ofproto_ports(struct bridge *br) if (port_is_bond_fake_iface(port)) { if (ofproto_port_query_by_name(br->ofproto, port->name, &ofproto_port)) { - struct netdev_options options; struct netdev *netdev; int error; - options.name = port->name; - options.type = "internal"; - options.args = NULL; - options.ethertype = NETDEV_ETH_TYPE_NONE; - error = netdev_open(&options, &netdev); + error = netdev_open(port->name, "internal", &netdev); if (!error) { ofproto_port_add(br->ofproto, netdev, NULL); netdev_close(netdev);