From 2f4ca41b9c771dc09e6130e0ff5ecf64acd79c0f Mon Sep 17 00:00:00 2001 From: Ethan Jackson Date: Tue, 3 Jan 2012 10:42:56 -0800 Subject: [PATCH] packets: Mask out CFI bit in eth_push_vlan(). We should never push a VLAN tag with the CFI bit set. This patch defensively enforces this invariant. Signed-off-by: Ethan Jackson --- lib/dpif-netdev.c | 2 +- lib/flow.c | 2 +- lib/packets.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 742d00c6..4ef2e3b4 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -1315,7 +1315,7 @@ dp_netdev_execute_actions(struct dp_netdev *dp, case OVS_ACTION_ATTR_PUSH_VLAN: vlan = nl_attr_get(a); - eth_push_vlan(packet, vlan->vlan_tci & ~htons(VLAN_CFI)); + eth_push_vlan(packet, vlan->vlan_tci); break; case OVS_ACTION_ATTR_POP_VLAN: diff --git a/lib/flow.c b/lib/flow.c index 5d18212f..cffb59fb 100644 --- a/lib/flow.c +++ b/lib/flow.c @@ -995,7 +995,7 @@ flow_compose(struct ofpbuf *b, const struct flow *flow) } if (flow->vlan_tci & htons(VLAN_CFI)) { - eth_push_vlan(b, flow->vlan_tci & ~htons(VLAN_CFI)); + eth_push_vlan(b, flow->vlan_tci); } if (flow->dl_type == htons(ETH_TYPE_IP)) { diff --git a/lib/packets.c b/lib/packets.c index b9f37bbb..25481742 100644 --- a/lib/packets.c +++ b/lib/packets.c @@ -77,7 +77,7 @@ compose_benign_packet(struct ofpbuf *b, const char *tag, uint16_t snap_type, } /* Insert VLAN header according to given TCI. Packet passed must be Ethernet - * packet. + * packet. Ignores the CFI bit of 'tci' using 0 instead. * * Also sets 'packet->l2' to point to the new Ethernet header. */ void @@ -91,7 +91,7 @@ eth_push_vlan(struct ofpbuf *packet, ovs_be16 tci) memcpy(tmp.veth_dst, eh->eth_dst, ETH_ADDR_LEN); memcpy(tmp.veth_src, eh->eth_src, ETH_ADDR_LEN); tmp.veth_type = htons(ETH_TYPE_VLAN); - tmp.veth_tci = tci; + tmp.veth_tci = tci & htons(~VLAN_CFI); tmp.veth_next_type = eh->eth_type; veh = ofpbuf_push_uninit(packet, VLAN_HEADER_LEN); -- 2.30.2