ethernet: change to mark the CFI bit in the L2 header. 85/20985/9
authorPrashant Maheshwari <pmahesh2@cisco.com>
Wed, 31 Jul 2019 16:07:33 +0000 (21:37 +0530)
committerNeale Ranns <nranns@cisco.com>
Tue, 6 Aug 2019 08:13:33 +0000 (08:13 +0000)
Type: fix
Fixes: 039cbfe2

Signed-off-by: Prashant Maheshwari <pmahesh2@cisco.com>
Change-Id: Idca91c73758824688dd6ce61df994be66753d838

src/vnet/ethernet/packet.h
test/test_dhcp.py
test/test_qos.py

index d70960b..13d7daf 100644 (file)
@@ -142,8 +142,8 @@ ethernet_vlan_header_set_priority_net_order (ethernet_vlan_header_t * h,
 {
   u8 *bytes = (u8 *) (&h->priority_cfi_and_id);
 
-  bytes[0] &= 0x1f;
-  bytes[0] |= (prio & 0x7) << 5;
+  bytes[0] &= 0x0f;
+  bytes[0] |= (prio & 0xf) << 4;
 }
 
 always_inline u8
@@ -151,7 +151,7 @@ ethernet_vlan_header_get_priority_net_order (ethernet_vlan_header_t * h)
 {
   u8 *bytes = (u8 *) (&h->priority_cfi_and_id);
 
-  return (bytes[0] >> 5);
+  return (bytes[0] >> 4);
 }
 
 /* VLAN with ethertype first and vlan id second */
index 16b0f47..175f649 100644 (file)
@@ -1653,7 +1653,7 @@ class TestDHCP(VppTestCase):
         rx = self.pg3.get_capture(1)
 
         self.assertEqual(rx[0][Dot1Q].vlan, 100)
-        self.assertEqual(rx[0][Dot1Q].prio, 4)
+        self.assertEqual(rx[0][Dot1Q].prio, 2)
 
         self.verify_orig_dhcp_discover(rx[0], self.pg3, hostname,
                                        dscp=vdscp.IP_API_DSCP_EF)
index 149a9eb..ef4e495 100644 (file)
@@ -515,15 +515,27 @@ class TestQOS(VppTestCase):
                 UDP(sport=1234, dport=1234) /
                 Raw(scapy.compat.chb(100) * NUM_PKTS))
 
+        p_v3 = (Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) /
+                Dot1Q(vlan=11, prio=1, id=1) /
+                IP(src="1.1.1.1", dst="10.0.0.2", tos=2) /
+                UDP(sport=1234, dport=1234) /
+                Raw(scapy.compat.chb(100) * NUM_PKTS))
+
         rx = self.send_and_expect(self.pg1, p_v2 * NUM_PKTS, self.pg0)
 
         for p in rx:
-            self.assertEqual(p[Dot1Q].prio, 6)
+            self.assertEqual(p[Dot1Q].prio, 7)
+            self.assertEqual(p[Dot1Q].id, 0)
+
+        rx = self.send_and_expect(self.pg0, p_v3 * NUM_PKTS, self.pg1)
+
+        for p in rx:
+            self.assertEqual(p[IP].tos, 252)
 
         rx = self.send_and_expect(self.pg0, p_v1 * NUM_PKTS, self.pg1)
 
         for p in rx:
-            self.assertEqual(p[IP].tos, 254)
+            self.assertEqual(p[IP].tos, 253)
 
         p_v1 = (Ether(src=self.pg0.remote_mac, dst=self.pg0.local_mac) /
                 Dot1Q(vlan=11, prio=2) /
@@ -539,12 +551,13 @@ class TestQOS(VppTestCase):
         rx = self.send_and_expect(self.pg1, p_v2 * NUM_PKTS, self.pg0)
 
         for p in rx:
-            self.assertEqual(p[Dot1Q].prio, 6)
+            self.assertEqual(p[Dot1Q].prio, 7)
+            self.assertEqual(p[Dot1Q].id, 0)
 
         rx = self.send_and_expect(self.pg0, p_v1 * NUM_PKTS, self.pg1)
 
         for p in rx:
-            self.assertEqual(p[IPv6].tc, 253)
+            self.assertEqual(p[IPv6].tc, 251)
 
         #
         # cleanup