aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEthan Jackson <ethan@nicira.com>2012-01-03 10:42:56 -0800
committerEthan Jackson <ethan@nicira.com>2012-01-10 14:30:01 -0800
commit2f4ca41b9c771dc09e6130e0ff5ecf64acd79c0f (patch)
treeeae2cff4cff732b95b536026376ada2e0400a92b /lib
parentec14ac26857f49968e48fa7b1ad85a07c1bfcc8d (diff)
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 <ethan@nicira.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/dpif-netdev.c2
-rw-r--r--lib/flow.c2
-rw-r--r--lib/packets.c4
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);