+ if (shash_count(args) != dev->n_args) {
+ return false;
+ }
+
+ new_args = shash_sort(args);
+ for (i = 0; i < dev->n_args; i++) {
+ if (strcmp(dev->args[i].key, new_args[i]->name) ||
+ strcmp(dev->args[i].value, new_args[i]->data)) {
+ result = false;
+ goto finish;
+ }
+ }
+
+finish:
+ free(new_args);
+ return result;
+}
+
+static int
+compare_args(const void *a_, const void *b_)
+{
+ const struct arg *a = a_;
+ const struct arg *b = b_;
+ return strcmp(a->key, b->key);
+}
+
+void
+update_device_args(struct netdev_dev *dev, const struct shash *args)
+{
+ struct shash_node *node;
+ int i;
+
+ if (dev->n_args) {
+ for (i = 0; i < dev->n_args; i++) {
+ free(dev->args[i].key);
+ free(dev->args[i].value);
+ }
+
+ free(dev->args);
+ dev->n_args = 0;
+ }
+
+ if (!args || shash_is_empty(args)) {
+ return;
+ }
+
+ dev->n_args = shash_count(args);
+ dev->args = xmalloc(dev->n_args * sizeof *dev->args);
+
+ i = 0;
+ SHASH_FOR_EACH(node, args) {
+ dev->args[i].key = xstrdup(node->name);
+ dev->args[i].value = xstrdup(node->data);
+ i++;
+ }
+
+ qsort(dev->args, dev->n_args, sizeof *dev->args, compare_args);
+}
+
+static int
+create_device(struct netdev_options *options, struct netdev_dev **netdev_devp)
+{
+ struct netdev_class *netdev_class;
+
+ if (!options->may_create) {
+ VLOG_WARN("attempted to create a device that may not be created: %s",
+ options->name);
+ return ENODEV;
+ }
+
+ if (!options->type || strlen(options->type) == 0) {
+ /* Default to system. */
+ options->type = "system";
+ }
+
+ netdev_class = shash_find_data(&netdev_classes, options->type);
+ if (!netdev_class) {
+ VLOG_WARN("could not create netdev %s of unknown type %s",
+ options->name, options->type);
+ return EAFNOSUPPORT;
+ }
+
+ return netdev_class->create(options->name, options->type, options->args,
+ netdev_devp);