-/* 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);
- }
- }
-}
-
-/* Returns the type of network device that 'iface' should have. (This is
- * ordinarily the same type as the interface, but the network devices for
- * "internal" ports have type "system".) */
-static const char *
-iface_get_netdev_type(const struct iface *iface)
-{
- return !strcmp(iface->type, "internal") ? "system" : iface->type;
-}
-
-/* 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;
- netdev_options.type = iface_get_netdev_type(iface);
- 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) {
- iface->enabled = netdev_get_carrier(iface->netdev);
- }
-
- 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_get_netdev_type(iface);
- 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;
-}
-