aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEthan Jackson <ethan@nicira.com>2012-12-16 17:08:50 -0800
committerEthan Jackson <ethan@nicira.com>2013-01-28 19:09:58 -0800
commitde281153654c7fa9e41f579076941ebb9dfeec4d (patch)
tree900f40a948081d95e07c9d4f2808419af9549195 /lib
parent48cecbdc39ccf29e7ea98a348cd2f4664272500b (diff)
netdev: New function netdev_get_dpif_port().
In future patches, a netdev's datapath port name may not necessarily be the same as its device name. This patch prepares for this by making the distinction in the netdev and dpif layers. Signed-off-by: Ethan Jackson <ethan@nicira.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/dpif-linux.c4
-rw-r--r--lib/dpif-netdev.c18
-rw-r--r--lib/netdev-vport.c6
-rw-r--r--lib/netdev-vport.h2
4 files changed, 20 insertions, 10 deletions
diff --git a/lib/dpif-linux.c b/lib/dpif-linux.c
index 6863e08d..3dc94c21 100644
--- a/lib/dpif-linux.c
+++ b/lib/dpif-linux.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -426,7 +426,7 @@ dpif_linux_port_add(struct dpif *dpif_, struct netdev *netdev,
uint32_t *port_nop)
{
struct dpif_linux *dpif = dpif_linux_cast(dpif_);
- const char *name = netdev_get_name(netdev);
+ const char *name = netdev_vport_get_dpif_port(netdev);
const char *type = netdev_get_type(netdev);
struct dpif_linux_vport request, reply;
const struct ofpbuf *options;
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 2cf22656..038dfdc9 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2010, 2011, 2012 Nicira, Inc.
+ * Copyright (c) 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,6 +40,7 @@
#include "hmap.h"
#include "list.h"
#include "netdev.h"
+#include "netdev-vport.h"
#include "netlink.h"
#include "odp-util.h"
#include "ofp-print.h"
@@ -437,11 +438,11 @@ dpif_netdev_port_add(struct dpif *dpif, struct netdev *netdev,
}
port_no = *port_nop;
} else {
- port_no = choose_port(dp, netdev_get_name(netdev));
+ port_no = choose_port(dp, netdev_vport_get_dpif_port(netdev));
}
if (port_no >= 0) {
*port_nop = port_no;
- return do_add_port(dp, netdev_get_name(netdev),
+ return do_add_port(dp, netdev_vport_get_dpif_port(netdev),
netdev_get_type(netdev), port_no);
}
return EFBIG;
@@ -480,7 +481,7 @@ get_port_by_name(struct dp_netdev *dp,
struct dp_netdev_port *port;
LIST_FOR_EACH (port, node, &dp->port_list) {
- if (!strcmp(netdev_get_name(port->netdev), devname)) {
+ if (!strcmp(netdev_vport_get_dpif_port(port->netdev), devname)) {
*portp = port;
return 0;
}
@@ -504,7 +505,7 @@ do_del_port(struct dp_netdev *dp, uint32_t port_no)
dp->ports[port->port_no] = NULL;
dp->serial++;
- name = xstrdup(netdev_get_name(port->netdev));
+ name = xstrdup(netdev_vport_get_dpif_port(port->netdev));
netdev_close(port->netdev);
free(port->type);
@@ -518,7 +519,7 @@ static void
answer_port_query(const struct dp_netdev_port *port,
struct dpif_port *dpif_port)
{
- dpif_port->name = xstrdup(netdev_get_name(port->netdev));
+ dpif_port->name = xstrdup(netdev_vport_get_dpif_port(port->netdev));
dpif_port->type = xstrdup(port->type);
dpif_port->port_no = port->port_no;
}
@@ -609,7 +610,7 @@ dpif_netdev_port_dump_next(const struct dpif *dpif, void *state_,
struct dp_netdev_port *port = dp->ports[port_no];
if (port) {
free(state->name);
- state->name = xstrdup(netdev_get_name(port->netdev));
+ state->name = xstrdup(netdev_vport_get_dpif_port(port->netdev));
dpif_port->name = state->name;
dpif_port->type = port->type;
dpif_port->port_no = port->port_no;
@@ -1068,7 +1069,8 @@ dpif_netdev_run(struct dpif *dpif)
} else if (error != EAGAIN && error != EOPNOTSUPP) {
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
VLOG_ERR_RL(&rl, "error receiving data from %s: %s",
- netdev_get_name(port->netdev), strerror(error));
+ netdev_vport_get_dpif_port(port->netdev),
+ strerror(error));
}
}
ofpbuf_uninit(&packet);
diff --git a/lib/netdev-vport.c b/lib/netdev-vport.c
index 94f1110c..95cffd2a 100644
--- a/lib/netdev-vport.c
+++ b/lib/netdev-vport.c
@@ -151,6 +151,12 @@ netdev_vport_is_patch(const struct netdev *netdev)
return class->get_config == get_patch_config;
}
+const char *
+netdev_vport_get_dpif_port(const struct netdev *netdev)
+{
+ return netdev_get_name(netdev);
+}
+
static uint32_t
get_u32_or_zero(const struct nlattr *a)
{
diff --git a/lib/netdev-vport.h b/lib/netdev-vport.h
index b372a744..8c81d7a9 100644
--- a/lib/netdev-vport.h
+++ b/lib/netdev-vport.h
@@ -41,4 +41,6 @@ void netdev_vport_patch_inc_rx(const struct netdev *,
void netdev_vport_patch_inc_tx(const struct netdev *,
const struct dpif_flow_stats *);
+const char *netdev_vport_get_dpif_port(const struct netdev *);
+
#endif /* netdev-vport.h */