This is used to map a tunnel or VLAN realdevs to tundev and vlandevs respectively. This is used on transmit to map fromt the interface used in user-space to the interface used in the datapath.
In the case where an interface is not a tunnel and does not have VLAN splinters configured a identity map is made. Cc: Kyle Mestery <kmest...@cisco.com> Signed-off-by: Simon Horman <ho...@verge.net.au> --- ofproto/ofproto-dpif.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index 3f03d45..b31a21c 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -538,8 +538,6 @@ struct vlan_splinter { int vid; }; -static uint32_t vsp_realdev_to_vlandev(const struct ofproto_dpif *, - uint32_t realdev, ovs_be16 vlan_tci); static bool vsp_adjust_flow(const struct ofproto_dpif *, struct flow *); static void vsp_remove(struct ofport_dpif *); static void vsp_add(struct ofport_dpif *, uint16_t realdev_ofp_port, int vid); @@ -554,6 +552,10 @@ static unsigned multicast_ports; static int set_tunnelling(struct ofport *ofport_, uint16_t realdev_ofp_port, const struct tunnel_settings *s); +static uint32_t +realdev_to_txdev(const struct ofproto_dpif *ofproto, + const struct ofport_dpif *ofport, ovs_be16 vlan_tci); + static struct ofport_dpif * ofport_dpif_cast(const struct ofport *ofport) { @@ -4690,9 +4692,8 @@ send_packet(const struct ofport_dpif *ofport, struct ofpbuf *packet) int error; flow_extract((struct ofpbuf *) packet, 0, 0, 0, &flow); - odp_port = vsp_realdev_to_vlandev(ofproto, ofport->odp_port, - flow.vlan_tci); - if (odp_port != ofport->odp_port) { + odp_port = realdev_to_txdev(ofproto, ofport, flow.vlan_tci); + if (odp_port != ofport->odp_port && !ofport->tun) { eth_pop_vlan(packet); flow.vlan_tci = htons(0); } @@ -4899,9 +4900,8 @@ compose_output_action__(struct action_xlate_ctx *ctx, uint16_t ofp_port, * later and we're pre-populating the flow table. */ } - out_port = vsp_realdev_to_vlandev(ctx->ofproto, odp_port, - ctx->flow.vlan_tci); - if (out_port != odp_port) { + out_port = realdev_to_txdev(ctx->ofproto, ofport, ctx->flow.vlan_tci); + if (out_port != odp_port && !ofport->tun) { ctx->flow.vlan_tci = htons(0); } commit_odp_actions(&ctx->flow, &ctx->base_flow, ctx->odp_actions); @@ -7201,6 +7201,21 @@ set_tunnelling(struct ofport *ofport_, uint16_t tundev_ofp_port, return 0; } + +/* Maps a port to the port that it should be transmitted on. + * If tunneling is enabled then the associated tunnel port is returned. + * If VLAN splintering is enabled then the ofp_port of the vlandev is + * returned. + * Otherwise no mapping is in effect and ofport->odp_port is returned. */ +static uint32_t +realdev_to_txdev(const struct ofproto_dpif *ofproto, + const struct ofport_dpif *ofport, ovs_be16 vlan_tci) +{ + if (ofport->tun) { + return ofp_port_to_odp_port(ofport->tun->tundev_ofp_port); + } + return vsp_realdev_to_vlandev(ofproto, ofport->odp_port, vlan_tci); +} const struct ofproto_class ofproto_dpif_class = { enumerate_types, -- 1.7.10 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev