diff options
author | Justin Pettit <jpettit@nicira.com> | 2012-11-14 15:50:20 -0800 |
---|---|---|
committer | Justin Pettit <jpettit@nicira.com> | 2012-11-16 12:35:55 -0800 |
commit | 0aeaabc8dbccef7593dc19e891a3f5bbef1991cd (patch) | |
tree | 4d787178ca17caa89ea41d6f99b8383a22784bf6 /lib/dpif-netdev.c | |
parent | 78a2d59c1c7fd057e1ca888c92f2f86efcf8b53a (diff) |
Add functions to determine how port should be opened based on type.
Depending on the port and type of datapath, a port may need to be opened
as a different type of device than it's configured. For example, an
"internal" port on a "dummy" datapath should opened as a "dummy" port.
This commit adds the ability for a dpif to provide this information to a
caller. It will be used in a future commit.
Signed-off-by: Justin Pettit <jpettit@nicira.com>
Diffstat (limited to 'lib/dpif-netdev.c')
-rw-r--r-- | lib/dpif-netdev.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index a294ffc8..cd4ab282 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) { @@ -369,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; @@ -1282,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, |