+/* Opens a network device for 'iface_cfg' and configures it. If '*ofp_portp'
+ * is negative, adds the network device to br->ofproto and stores the OpenFlow
+ * port number in '*ofp_portp'; otherwise leaves br->ofproto and '*ofp_portp'
+ * untouched.
+ *
+ * If successful, returns 0 and stores the network device in '*netdevp'. On
+ * failure, returns a positive errno value and stores NULL in '*netdevp'. */
+static int
+iface_do_create(const struct bridge *br,
+ const struct ovsrec_interface *iface_cfg,
+ const struct ovsrec_port *port_cfg,
+ int *ofp_portp, struct netdev **netdevp)
+{
+ struct netdev *netdev;
+ int error;
+
+ error = netdev_open(iface_cfg->name,
+ iface_get_type(iface_cfg, br->cfg), &netdev);
+ if (error) {
+ VLOG_WARN("could not open network device %s (%s)",
+ iface_cfg->name, strerror(error));
+ goto error;
+ }
+
+ error = iface_set_netdev_config(iface_cfg, netdev);
+ if (error) {
+ goto error;
+ }
+
+ if (*ofp_portp < 0) {
+ uint16_t ofp_port;
+
+ error = ofproto_port_add(br->ofproto, netdev, &ofp_port);
+ if (error) {
+ goto error;
+ }
+ *ofp_portp = ofp_port;
+
+ VLOG_INFO("bridge %s: added interface %s on port %d",
+ br->name, iface_cfg->name, *ofp_portp);
+ } else {
+ VLOG_DBG("bridge %s: interface %s is on port %d",
+ br->name, iface_cfg->name, *ofp_portp);
+ }
+
+ if (port_cfg->vlan_mode && !strcmp(port_cfg->vlan_mode, "splinter")) {
+ netdev_turn_flags_on(netdev, NETDEV_UP, true);
+ }
+
+ *netdevp = netdev;
+ return 0;
+
+error:
+ *netdevp = NULL;
+ netdev_close(netdev);
+ return error;
+}
+