-/* Initializes 'options' and fills it with the options for 'if_cfg'. Merges
- * keys from "options" and "other_config", preferring "options" keys over
- * "other_config" keys.
- *
- * The value strings in '*options' are taken directly from if_cfg, not copied,
- * so the caller should not modify or free them. */
-static void
-iface_get_options(const struct ovsrec_interface *if_cfg, struct shash *options)
-{
- size_t i;
-
- shash_from_ovs_idl_map(if_cfg->key_options, if_cfg->value_options,
- if_cfg->n_options, options);
-
- for (i = 0; i < if_cfg->n_other_config; i++) {
- char *key = if_cfg->key_other_config[i];
- char *value = if_cfg->value_other_config[i];
-
- if (!shash_find_data(options, key)) {
- shash_add(options, key, value);
- } else {
- VLOG_WARN("%s: ignoring \"other_config\" key %s that conflicts "
- "with \"options\" key %s", if_cfg->name, key, key);
- }
- }
-}
-
-/* Attempt to create the network device for 'iface' through the netdev
- * library. */
-static int
-create_iface_netdev(struct iface *iface)
-{
- struct netdev_options netdev_options;
- struct shash options;
- int error;
-
- memset(&netdev_options, 0, sizeof netdev_options);
- netdev_options.name = iface->cfg->name;
- if (!strcmp(iface->cfg->type, "internal")) {
- /* An "internal" config type maps to a netdev "system" type. */
- netdev_options.type = "system";
- } else {
- netdev_options.type = iface->cfg->type;
- }
- netdev_options.args = &options;
- netdev_options.ethertype = NETDEV_ETH_TYPE_NONE;
-
- iface_get_options(iface->cfg, &options);
-
- error = netdev_open(&netdev_options, &iface->netdev);
-
- if (iface->netdev) {
- netdev_get_carrier(iface->netdev, &iface->enabled);
- }
-
- shash_destroy(&options);
-
- return error;
-}
-
-static int
-reconfigure_iface_netdev(struct iface *iface)
-{
- const char *netdev_type, *iface_type;
- struct shash options;
- int error;
-
- /* Skip reconfiguration if the device has the wrong type. This shouldn't
- * happen, but... */
- iface_type = (!iface->cfg->type[0] ? NULL
- : !strcmp(iface->cfg->type, "internal") ? "system"
- : iface->cfg->type);
- netdev_type = netdev_get_type(iface->netdev);
- if (iface_type && strcmp(netdev_type, iface_type)) {
- VLOG_WARN("%s: attempting change device type from %s to %s",
- iface->cfg->name, netdev_type, iface_type);
- return EINVAL;
- }
-
- /* Reconfigure device. */
- iface_get_options(iface->cfg, &options);
- error = netdev_reconfigure(iface->netdev, &options);
- shash_destroy(&options);
-
- return error;
-}
-