- const struct vport_class *vport_class = vport_class_cast(netdev_class);
- struct ofpbuf *options = NULL;
- struct shash fetched_args;
- int error;
-
- shash_init(&fetched_args);
-
- if (!shash_is_empty(args)) {
- /* Parse the provided configuration. */
- options = ofpbuf_new(64);
- error = vport_class->parse_config(name, netdev_class->type,
- args, options);
- } else {
- /* Fetch an existing configuration from the kernel.
- *
- * This case could be ambiguous with initializing a new vport with an
- * empty configuration, but none of the existing vport classes accept
- * an empty configuration. */
- struct dpif_linux_vport reply;
- struct ofpbuf *buf;
-
- error = dpif_linux_vport_get(name, &reply, &buf);
- if (!error) {
- /* XXX verify correct type */
- error = vport_class->unparse_config(name, netdev_class->type,
- reply.options,
- reply.options_len,
- &fetched_args);
- if (error) {
- VLOG_ERR_RL(&rl, "%s: failed to parse kernel config (%s)",
- name, strerror(error));
- } else {
- options = ofpbuf_clone_data(reply.options, reply.options_len);
- }
- ofpbuf_delete(buf);
- } else {
- VLOG_ERR_RL(&rl, "%s: vport query failed (%s)",
- name, strerror(error));
- }
- }
-
- if (!error) {
- struct netdev_dev_vport *dev;