summaryrefslogtreecommitdiff
path: root/ofproto
diff options
context:
space:
mode:
authorZoltán Balogh <zoltan.balogh@ericsson.com>2017-07-14 21:24:29 +0200
committerBen Pfaff <blp@ovn.org>2017-07-14 15:59:20 -0700
commit5dbfe23979856400f3b746d8917c7e829aaec446 (patch)
treee0ccd227b50261bd87bf6a6ad3ab7b8e6e8cd062 /ofproto
parentbb1f4da092e0b44ab0f41a31b5e811c08afa7d83 (diff)
downloadopenvswitch-5dbfe23979856400f3b746d8917c7e829aaec446.tar.gz
ofproto-dpif-xlate: drop L3 packets on L2 legacy port
This commit drops packet during xlate if it is a L3 packet and output port packet_type is legacy_l2. New PTAP unit test is added. Signed-off-by: Zoltán Balogh <zoltan.balogh@ericsson.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'ofproto')
-rw-r--r--ofproto/ofproto-dpif-xlate.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index c4158dfb6..01f5f8d69 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -3312,6 +3312,14 @@ check_output_prerequisites(struct xlate_ctx *ctx,
return false;
}
}
+
+ if (xport->pt_mode == NETDEV_PT_LEGACY_L2 &&
+ flow->packet_type != htonl(PT_ETH)) {
+ xlate_report(ctx, OFT_WARN, "Trying to send non-Ethernet packet "
+ "through legacy L2 port. Dropping packet.");
+ return false;
+ }
+
return true;
}
@@ -3345,6 +3353,10 @@ compose_output_action__(struct xlate_ctx *ctx, ofp_port_t ofp_port,
odp_port_t out_port, odp_port, odp_tnl_port;
bool is_native_tunnel = false;
uint8_t dscp;
+ struct eth_addr flow_dl_dst = flow->dl_dst;
+ struct eth_addr flow_dl_src = flow->dl_src;
+ ovs_be32 flow_packet_type = flow->packet_type;
+ ovs_be16 flow_dl_type = flow->dl_type;
/* If 'struct flow' gets additional metadata, we'll need to zero it out
* before traversing a patch port. */
@@ -3361,13 +3373,6 @@ compose_output_action__(struct xlate_ctx *ctx, ofp_port_t ofp_port,
flow->packet_type = PACKET_TYPE_BE(OFPHTN_ETHERTYPE,
ntohs(flow->dl_type));
}
- } else {
- /* Add dummy Ethernet header for legacy L2 port. */
- if (xport->pt_mode == NETDEV_PT_LEGACY_L2) {
- flow->packet_type = htonl(PT_ETH);
- flow->dl_dst = eth_addr_zero;
- flow->dl_src = eth_addr_zero;
- }
}
if (xport->peer) {
@@ -3627,6 +3632,10 @@ compose_output_action__(struct xlate_ctx *ctx, ofp_port_t ofp_port,
/* Restore flow */
memcpy(flow->vlans, flow_vlans, sizeof flow->vlans);
flow->nw_tos = flow_nw_tos;
+ flow->dl_dst = flow_dl_dst;
+ flow->dl_src = flow_dl_src;
+ flow->packet_type = flow_packet_type;
+ flow->dl_type = flow_dl_type;
}
static void