[ovs-dev] [packet_in v2 06/18] packets: Mask out CFI bit in eth_push_vlan().

Ethan Jackson ethan at nicira.com
Sat Jan 7 11:11:47 PST 2012


We should never push a VLAN tag with the CFI bit set.  This patch
defensively enforces this invariant.
---
 lib/packets.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/packets.c b/lib/packets.c
index b9f37bb..2548174 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);
-- 
1.7.7.1




More information about the dev mailing list