X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fdpif-netdev.c;h=92108df1c4614f3f602e91a4f727f9977ec75892;hb=0135dc8b4e91886b0e9f5c3e1c3e973d9ee575c7;hp=4ce4147c06c483e19b606cf4cb9688413c57301d;hpb=bc7a5acdff087b7e7a162da42ae608a83f3cf902;p=openvswitch diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 4ce4147c..92108df1 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -181,6 +181,14 @@ dpif_netdev_enumerate(struct sset *all_dps) return 0; } +static const char * +dpif_netdev_port_open_type(const struct dpif_class *class, const char *type) +{ + return strcmp(type, "internal") ? type + : class != &dpif_netdev_class ? "dummy" + : "tap"; +} + static struct dpif * create_dpif_netdev(struct dp_netdev *dp) { @@ -241,7 +249,6 @@ create_dp_netdev(const char *name, const struct dpif_class *class, struct dp_netdev **dpp) { struct dp_netdev *dp; - int port_no; int error; int i; @@ -255,8 +262,7 @@ create_dp_netdev(const char *name, const struct dpif_class *class, hmap_init(&dp->flow_table); list_init(&dp->port_list); - port_no = !strncmp(name, "br", 2) ? choose_port(dp, name) : OVSP_LOCAL; - error = do_add_port(dp, name, "internal", port_no); + error = do_add_port(dp, name, "internal", OVSP_LOCAL); if (error) { dp_netdev_free(dp); return error; @@ -371,9 +377,7 @@ do_add_port(struct dp_netdev *dp, const char *devname, const char *type, /* XXX reject devices already in some dp_netdev. */ /* Open and validate network device. */ - open_type = (strcmp(type, "internal") ? type - : dp->class != &dpif_netdev_class ? "dummy" - : "tap"); + open_type = dpif_netdev_port_open_type(dp->class, type); error = netdev_open(devname, open_type, &netdev); if (error) { return error; @@ -666,7 +670,7 @@ static int dpif_netdev_flow_from_nlattrs(const struct nlattr *key, uint32_t key_len, struct flow *flow) { - if (odp_flow_key_to_flow(key, key_len, flow)) { + if (odp_flow_key_to_flow(key, key_len, flow) != ODP_FIT_PERFECT) { /* This should not happen: it indicates that odp_flow_key_from_flow() * and odp_flow_key_to_flow() disagree on the acceptable form of a * flow. Log the problem as an error, with enough details to enable @@ -1284,6 +1288,7 @@ dp_netdev_execute_actions(struct dp_netdev *dp, const struct dpif_class dpif_netdev_class = { "netdev", dpif_netdev_enumerate, + dpif_netdev_port_open_type, dpif_netdev_open, dpif_netdev_close, dpif_netdev_destroy,