From: Ethan Jackson Date: Tue, 18 Jun 2013 21:40:30 +0000 (-0700) Subject: tunnel: Use ofport_dpif instead of ofport. X-Git-Tag: sliver-openvswitch-1.10.90-3~6^2~6 X-Git-Url: http://git.onelab.eu/?p=sliver-openvswitch.git;a=commitdiff_plain;h=e1939dbf92a60d0f235621f4d79661f47c5aed0c tunnel: Use ofport_dpif instead of ofport. Necessary in a future patch. Signed-off-by: Ethan Jackson Acked-by: Ben Pfaff --- diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index 420bfde0c..95371724d 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -597,7 +597,7 @@ type_run(const char *type) } 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; } @@ -1486,7 +1486,7 @@ port_construct(struct ofport *port_) 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. */ @@ -1568,7 +1568,8 @@ port_modified(struct ofport *port_) 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; @@ -3641,7 +3642,7 @@ ofproto_receive(const struct dpif_backer *backer, struct ofpbuf *packet, } 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) { diff --git a/ofproto/tunnel.c b/ofproto/tunnel.c index 1a39aeac3..0f95527be 100644 --- a/ofproto/tunnel.c +++ b/ofproto/tunnel.c @@ -17,12 +17,11 @@ #include -#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" @@ -46,8 +45,10 @@ struct tnl_match { 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; }; @@ -71,19 +72,20 @@ static void tnl_port_mod_log(const struct tnl_port *, const char *action); 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; @@ -118,9 +120,10 @@ tnl_port_add__(const struct ofport *ofport, odp_port_t odp_port, * 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 @@ -129,20 +132,22 @@ tnl_port_add(const struct ofport *ofport, odp_port_t odp_port) * '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; @@ -155,6 +160,7 @@ tnl_port_del(struct tnl_port *tnl_port) 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); } } @@ -165,7 +171,7 @@ tnl_port_del(struct tnl_port *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; @@ -223,7 +229,7 @@ tnl_port_send(const struct tnl_port *tnl_port, struct flow *flow, 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)) { @@ -401,12 +407,12 @@ static char * 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 || @@ -450,5 +456,5 @@ tnl_port_fmt(const struct tnl_port *tnl_port) 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); } diff --git a/ofproto/tunnel.h b/ofproto/tunnel.h index 343eb9697..19035c3ef 100644 --- a/ofproto/tunnel.h +++ b/ofproto/tunnel.h @@ -28,16 +28,18 @@ * 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);