Skip to content

Commit

Permalink
netdev: New function netdev_get_dpif_port().
Browse files Browse the repository at this point in the history
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 <[email protected]>
ejj committed Jan 29, 2013
1 parent 48cecbd commit de28115
Showing 4 changed files with 20 additions and 10 deletions.
4 changes: 2 additions & 2 deletions lib/dpif-linux.c
Original file line number Diff line number Diff line change
@@ -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;
18 changes: 10 additions & 8 deletions lib/dpif-netdev.c
Original file line number Diff line number Diff line change
@@ -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);
6 changes: 6 additions & 0 deletions lib/netdev-vport.c
Original file line number Diff line number Diff line change
@@ -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)
{
2 changes: 2 additions & 0 deletions lib/netdev-vport.h
Original file line number Diff line number Diff line change
@@ -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 */

0 comments on commit de28115

Please sign in to comment.