summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2011-04-20 13:03:45 -0700
committerBen Pfaff <blp@nicira.com>2011-04-29 14:32:00 -0700
commitf64503041d96729427b8d882e3b7fd3552b43a6a (patch)
tree2ed1c27da13a740b8915ee0aae7b6114c9a1e089
parent66105f0e2cbd40d64bb80d77fff9c65014577050 (diff)
downloadopenvswitch-f64503041d96729427b8d882e3b7fd3552b43a6a.tar.gz
ofproto: Consistently use netdev's name instead of ofp_phy_port name.
There are at least two ways to get an ofport's name: from the netdev using netdev_get_name() or from the ofp_phy_port's 'name' member. Some code used one, some used the other. This switches all relevant code to use only netdev_get_name(), because the 'name' member in ofp_phy_port is fixed-length and thus a long name could be truncated. This isn't a problem under Linux since the maximum length of a network device's name under Linux is the same as the field width in ofp_phy_port.
-rw-r--r--ofproto/ofproto.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index 652ded056..02f55f551 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -912,7 +912,7 @@ int
ofproto_port_del(struct ofproto *ofproto, uint16_t odp_port)
{
struct ofport *ofport = get_port(ofproto, odp_port);
- const char *name = ofport ? ofport->opp.name : "<unknown>";
+ const char *name = ofport ? netdev_get_name(ofport->netdev) : "<unknown>";
int error;
error = dpif_port_del(ofproto->dpif, odp_port);
@@ -920,8 +920,8 @@ ofproto_port_del(struct ofproto *ofproto, uint16_t odp_port)
VLOG_ERR("%s: failed to remove port %"PRIu16" (%s) interface (%s)",
dpif_name(ofproto->dpif), odp_port, name, strerror(error));
} else if (ofport) {
- /* 'name' is ofport->opp.name and update_port() is going to destroy
- * 'ofport'. Just in case update_port() refers to 'name' after it
+ /* 'name' is the netdev's name and update_port() is going to close the
+ * netdev. Just in case update_port() refers to 'name' after it
* destroys 'ofport', make a copy of it around the update_port()
* call. */
char *devname = xstrdup(name);
@@ -1048,7 +1048,7 @@ reinit_ports(struct ofproto *p)
sset_init(&devnames);
HMAP_FOR_EACH (ofport, hmap_node, &p->ports) {
- sset_add(&devnames, ofport->opp.name);
+ sset_add(&devnames, netdev_get_name(ofport->netdev));
}
DPIF_PORT_FOR_EACH (&dpif_port, &dump, p->dpif) {
sset_add(&devnames, dpif_port.name);
@@ -1138,7 +1138,7 @@ ofport_equal(const struct ofport *a_, const struct ofport *b_)
static void
ofport_install(struct ofproto *p, struct ofport *ofport)
{
- const char *netdev_name = ofport->opp.name;
+ const char *netdev_name = netdev_get_name(ofport->netdev);
netdev_monitor_add(p->netdev_monitor, ofport->netdev);
hmap_insert(&p->ports, &ofport->hmap_node, hash_int(ofport->odp_port, 0));
@@ -1154,7 +1154,8 @@ ofport_remove(struct ofproto *p, struct ofport *ofport)
netdev_monitor_remove(p->netdev_monitor, ofport->netdev);
hmap_remove(&p->ports, &ofport->hmap_node);
shash_delete(&p->port_by_name,
- shash_find(&p->port_by_name, ofport->opp.name));
+ shash_find(&p->port_by_name,
+ netdev_get_name(ofport->netdev)));
if (p->sflow) {
ofproto_sflow_del_port(p->sflow, ofport->odp_port);
}