}
iter->odp_port = node ? u32_to_odp(node->data) : ODPP_NONE;
- if (tnl_port_reconfigure(&iter->up, iter->odp_port,
+ if (tnl_port_reconfigure(iter, iter->up.netdev, iter->odp_port,
&iter->tnl_port)) {
backer->need_revalidate = REV_RECONFIGURE;
}
port->odp_port = dpif_port.port_no;
if (netdev_get_tunnel_config(netdev)) {
- port->tnl_port = tnl_port_add(&port->up, port->odp_port);
+ port->tnl_port = tnl_port_add(port, port->up.netdev, port->odp_port);
} else {
/* Sanity-check that a mapping doesn't already exist. This
* shouldn't happen for non-tunnel ports. */
cfm_set_netdev(port->cfm, port->up.netdev);
}
- if (port->tnl_port && tnl_port_reconfigure(&port->up, port->odp_port,
+ if (port->tnl_port && tnl_port_reconfigure(port, port->up.netdev,
+ port->odp_port,
&port->tnl_port)) {
ofproto_dpif_cast(port->up.ofproto)->backer->need_revalidate =
REV_RECONFIGURE;
}
port = (tnl_port_should_receive(flow)
- ? ofport_dpif_cast(tnl_port_receive(flow))
+ ? tnl_port_receive(flow)
: odp_port_to_ofport(backer, flow->in_port.odp_port));
flow->in_port.ofp_port = port ? port->up.ofp_port : OFPP_NONE;
if (!port) {
#include <errno.h>
-#include "ofproto/ofproto-provider.h"
#include "byte-order.h"
#include "dynamic-string.h"
#include "hash.h"
#include "hmap.h"
-#include "netdev-vport.h"
+#include "netdev.h"
#include "odp-util.h"
#include "packets.h"
#include "smap.h"
struct tnl_port {
struct hmap_node match_node;
- const struct ofport *ofport;
+ const struct ofport_dpif *ofport;
unsigned int netdev_seq;
+ struct netdev *netdev;
+
struct tnl_match match;
};
static const char *tnl_port_get_name(const struct tnl_port *);
static struct tnl_port *
-tnl_port_add__(const struct ofport *ofport, odp_port_t odp_port,
- bool warn)
+tnl_port_add__(const struct ofport_dpif *ofport, const struct netdev *netdev,
+ odp_port_t odp_port, bool warn)
{
const struct netdev_tunnel_config *cfg;
struct tnl_port *existing_port;
struct tnl_port *tnl_port;
- cfg = netdev_get_tunnel_config(ofport->netdev);
+ cfg = netdev_get_tunnel_config(netdev);
ovs_assert(cfg);
tnl_port = xzalloc(sizeof *tnl_port);
tnl_port->ofport = ofport;
- tnl_port->netdev_seq = netdev_change_seq(tnl_port->ofport->netdev);
+ tnl_port->netdev = netdev_ref(netdev);
+ tnl_port->netdev_seq = netdev_change_seq(tnl_port->netdev);
tnl_port->match.in_key = cfg->in_key;
tnl_port->match.ip_src = cfg->ip_src;
* must be added before they can be used by the module. 'ofport' must be a
* tunnel. */
struct tnl_port *
-tnl_port_add(const struct ofport *ofport, odp_port_t odp_port)
+tnl_port_add(const struct ofport_dpif *ofport, const struct netdev *netdev,
+ odp_port_t odp_port)
{
- return tnl_port_add__(ofport, odp_port, true);
+ return tnl_port_add__(ofport, netdev, odp_port, true);
}
/* Checks if the tnl_port pointed to by 'tnl_portp' needs reconfiguration due
* 'ofport' and 'odp_port' should be the same as would be passed to
* tnl_port_add(). */
bool
-tnl_port_reconfigure(const struct ofport *ofport, odp_port_t odp_port,
+tnl_port_reconfigure(const struct ofport_dpif *ofport,
+ const struct netdev *netdev, odp_port_t odp_port,
struct tnl_port **tnl_portp)
{
struct tnl_port *tnl_port = *tnl_portp;
if (tnl_port == &void_tnl_port) {
- *tnl_portp = tnl_port_add__(ofport, odp_port, false);
+ *tnl_portp = tnl_port_add__(ofport, netdev, odp_port, false);
return *tnl_portp != &void_tnl_port;
} else if (tnl_port->ofport != ofport
+ || tnl_port->netdev != netdev
|| tnl_port->match.odp_port != odp_port
- || tnl_port->netdev_seq != netdev_change_seq(ofport->netdev)) {
+ || tnl_port->netdev_seq != netdev_change_seq(netdev)) {
VLOG_DBG("reconfiguring %s", tnl_port_get_name(tnl_port));
tnl_port_del(tnl_port);
- *tnl_portp = tnl_port_add(ofport, odp_port);
+ *tnl_portp = tnl_port_add(ofport, netdev, odp_port);
return true;
}
return false;
if (tnl_port && tnl_port != &void_tnl_port) {
tnl_port_mod_log(tnl_port, "removing");
hmap_remove(&tnl_match_map, &tnl_port->match_node);
+ netdev_close(tnl_port->netdev);
free(tnl_port);
}
}
*
* Callers should verify that 'flow' needs to be received by calling
* tnl_port_should_receive() before this function. */
-const struct ofport *
+const struct ofport_dpif *
tnl_port_receive(const struct flow *flow)
{
char *pre_flow_str = NULL;
return ODPP_NONE;
}
- cfg = netdev_get_tunnel_config(tnl_port->ofport->netdev);
+ cfg = netdev_get_tunnel_config(tnl_port->netdev);
ovs_assert(cfg);
if (!VLOG_DROP_DBG(&dbg_rl)) {
tnl_port_fmt(const struct tnl_port *tnl_port)
{
const struct netdev_tunnel_config *cfg =
- netdev_get_tunnel_config(tnl_port->ofport->netdev);
+ netdev_get_tunnel_config(tnl_port->netdev);
struct ds ds = DS_EMPTY_INITIALIZER;
ds_put_format(&ds, "port %"PRIu32": %s (%s: ", tnl_port->match.odp_port,
tnl_port_get_name(tnl_port),
- netdev_get_type(tnl_port->ofport->netdev));
+ netdev_get_type(tnl_port->netdev));
tnl_match_fmt(&tnl_port->match, &ds);
if (cfg->out_key != cfg->in_key ||
static const char *
tnl_port_get_name(const struct tnl_port *tnl_port)
{
- return netdev_get_name(tnl_port->ofport->netdev);
+ return netdev_get_name(tnl_port->netdev);
}
* These functions emulate tunnel virtual ports based on the outer
* header information from the kernel. */
-struct ofport;
+struct ofport_dpif;
+struct netdev;
struct tnl_port;
-bool tnl_port_reconfigure(const struct ofport *, odp_port_t odp_port,
- struct tnl_port **);
+bool tnl_port_reconfigure(const struct ofport_dpif *, const struct netdev *,
+ odp_port_t, struct tnl_port **);
-struct tnl_port *tnl_port_add(const struct ofport *, odp_port_t odp_port);
+struct tnl_port *tnl_port_add(const struct ofport_dpif *, const struct netdev *,
+ odp_port_t);
void tnl_port_del(struct tnl_port *);
-const struct ofport *tnl_port_receive(const struct flow *);
+const struct ofport_dpif *tnl_port_receive(const struct flow *);
odp_port_t tnl_port_send(const struct tnl_port *, struct flow *,
struct flow_wildcards *wc);