]> The Tcpdump Group git mirrors - tcpdump/commitdiff
DSA: Correctly determine VID 889/head
authorTobias Waldekranz <[email protected]>
Tue, 5 Oct 2021 20:46:40 +0000 (22:46 +0200)
committerTobias Waldekranz <[email protected]>
Tue, 5 Oct 2021 20:52:00 +0000 (22:52 +0200)
The 4 MSBs of the VID is stored in the lower nibble of the tag's third
byte.

Previously the priority bits where folded into the VID space, e.g. a
packet with VID=1 and priority 6 was printed as having a VID of
1537 (0x601).

Add DSA test PCAPs with packets containing a high VID and non-zero
FPri values to make sure we catch any future regressions.

Signed-off-by: Tobias Waldekranz <[email protected]>
print-dsa.c
tests/TESTLIST
tests/dsa-high-vid-e.out [new file with mode: 0644]
tests/dsa-high-vid.out [new file with mode: 0644]
tests/dsa-high-vid.pcap [new file with mode: 0644]
tests/edsa-high-vid-e.out [new file with mode: 0644]
tests/edsa-high-vid.out [new file with mode: 0644]
tests/edsa-high-vid.pcap [new file with mode: 0644]

index e45dc53fbe985660fd2fb4df6fbed8d483d789c4..1ed9acf672f5a730079519fc5475499c644d9498 100644 (file)
@@ -83,7 +83,7 @@
 #define DSA_RX_SNIFF(tag) TOK(tag, 1, 0x04, 2)
 #define DSA_CFI(tag) TOK(tag, 1, 0x01, 0)
 #define DSA_PRI(tag) TOK(tag, 2, 0xe0, 5)
-#define DSA_VID(tag) ((u_short)((TOK(tag, 2, 0xe0, 5) << 8) | (TOK(tag, 3, 0xff, 0))))
+#define DSA_VID(tag) ((u_short)((TOK(tag, 2, 0x0f, 0) << 8) | (TOK(tag, 3, 0xff, 0))))
 #define DSA_CODE(tag) ((TOK(tag, 1, 0x06, 1) << 1) | TOK(tag, 2, 0x10, 4))
 
 #define EDSA_LEN 8
index 4945fe5ad9a05d7b0f8652dcc23e6bdba3653fb9..2ff6fbdd6d8e1563d21020708893079c203f6f6b 100644 (file)
@@ -70,6 +70,8 @@ bcm-li-v bcm-li.pcap bcm-li-v.out -v
 # Marvell DSA tag tests
 dsa            dsa.pcap                dsa.out
 dsa-e          dsa.pcap                dsa-e.out       -e
+dsa-high-vid   dsa-high-vid.pcap       dsa-high-vid.out
+dsa-high-vid-e dsa-high-vid.pcap       dsa-high-vid-e.out      -e
 
 # EAP tests
 # now in smb.tests
@@ -77,6 +79,8 @@ dsa-e         dsa.pcap                dsa-e.out       -e
 # Marvell DSA tag tests
 edsa           edsa.pcap               edsa.out
 edsa-e         edsa.pcap               edsa-e.out      -e
+edsa-high-vid  edsa-high-vid.pcap      edsa-high-vid.out
+edsa-high-vid-e        edsa-high-vid.pcap      edsa-high-vid-e.out     -e
 
 # ESP tests
 esp0           02-sunrise-sunset-esp.pcap      esp0.out
diff --git a/tests/dsa-high-vid-e.out b/tests/dsa-high-vid-e.out
new file mode 100644 (file)
index 0000000..a80539f
--- /dev/null
@@ -0,0 +1,4 @@
+    1  00:06:42.569821 02:f0:bb:ed:00:0f > d6:18:e2:69:ee:01, Marvell DSA mode Forward, dev 0, port 2, untagged, VID 1337, FPri 0, ethertype IPv4 (0x0800), length 102: 198.18.10.1 > 198.18.10.2: ICMP echo request, id 116, seq 1, length 64
+    2  00:06:42.569913 d6:18:e2:69:ee:01 > 02:f0:bb:ed:00:0f, Marvell DSA mode From CPU, target dev 0, port 2, untagged, VID 0, FPri 0, ethertype IPv4 (0x0800), length 102: 198.18.10.2 > 198.18.10.1: ICMP echo reply, id 116, seq 1, length 64
+    3  00:06:42.575549 02:f0:bb:ed:00:0f > d6:18:e2:69:ee:01, Marvell DSA mode Forward, dev 0, port 2, untagged, VID 1337, FPri 5, ethertype IPv4 (0x0800), length 102: 198.18.10.1 > 198.18.10.2: ICMP echo request, id 117, seq 1, length 64
+    4  00:06:42.575572 d6:18:e2:69:ee:01 > 02:f0:bb:ed:00:0f, Marvell DSA mode From CPU, target dev 0, port 2, untagged, VID 0, FPri 0, ethertype IPv4 (0x0800), length 102: 198.18.10.2 > 198.18.10.1: ICMP echo reply, id 117, seq 1, length 64
diff --git a/tests/dsa-high-vid.out b/tests/dsa-high-vid.out
new file mode 100644 (file)
index 0000000..6ce0eab
--- /dev/null
@@ -0,0 +1,4 @@
+    1  00:06:42.569821 DSA Forward port 0.2, VLAN 1337u, IP 198.18.10.1 > 198.18.10.2: ICMP echo request, id 116, seq 1, length 64
+    2  00:06:42.569913 DSA CPU > port 0.2, VLAN 0u, IP 198.18.10.2 > 198.18.10.1: ICMP echo reply, id 116, seq 1, length 64
+    3  00:06:42.575549 DSA Forward port 0.2, VLAN 1337u, IP 198.18.10.1 > 198.18.10.2: ICMP echo request, id 117, seq 1, length 64
+    4  00:06:42.575572 DSA CPU > port 0.2, VLAN 0u, IP 198.18.10.2 > 198.18.10.1: ICMP echo reply, id 117, seq 1, length 64
diff --git a/tests/dsa-high-vid.pcap b/tests/dsa-high-vid.pcap
new file mode 100644 (file)
index 0000000..9995974
Binary files /dev/null and b/tests/dsa-high-vid.pcap differ
diff --git a/tests/edsa-high-vid-e.out b/tests/edsa-high-vid-e.out
new file mode 100644 (file)
index 0000000..d6ca505
--- /dev/null
@@ -0,0 +1,4 @@
+    1  00:08:39.888043 02:f0:bb:ed:00:0f > d6:18:e2:69:ee:01, Marvell EDSA ethertype 0xdada (Unknown), rsvd 0 0, mode Forward, dev 0, port 2, untagged, VID 1337, FPri 0, ethertype IPv4 (0x0800), length 106: 198.18.10.1 > 198.18.10.2: ICMP echo request, id 120, seq 1, length 64
+    2  00:08:39.888132 d6:18:e2:69:ee:01 > 02:f0:bb:ed:00:0f, Marvell EDSA ethertype 0xdada (Unknown), rsvd 0 0, mode From CPU, target dev 0, port 2, untagged, VID 0, FPri 0, ethertype IPv4 (0x0800), length 106: 198.18.10.2 > 198.18.10.1: ICMP echo reply, id 120, seq 1, length 64
+    3  00:08:39.893713 02:f0:bb:ed:00:0f > d6:18:e2:69:ee:01, Marvell EDSA ethertype 0xdada (Unknown), rsvd 0 0, mode Forward, dev 0, port 2, untagged, VID 1337, FPri 5, ethertype IPv4 (0x0800), length 106: 198.18.10.1 > 198.18.10.2: ICMP echo request, id 121, seq 1, length 64
+    4  00:08:39.893737 d6:18:e2:69:ee:01 > 02:f0:bb:ed:00:0f, Marvell EDSA ethertype 0xdada (Unknown), rsvd 0 0, mode From CPU, target dev 0, port 2, untagged, VID 0, FPri 0, ethertype IPv4 (0x0800), length 106: 198.18.10.2 > 198.18.10.1: ICMP echo reply, id 121, seq 1, length 64
diff --git a/tests/edsa-high-vid.out b/tests/edsa-high-vid.out
new file mode 100644 (file)
index 0000000..d82bdd1
--- /dev/null
@@ -0,0 +1,4 @@
+    1  00:08:39.888043 EDSA 0xdada, Forward port 0.2, VLAN 1337u, IP 198.18.10.1 > 198.18.10.2: ICMP echo request, id 120, seq 1, length 64
+    2  00:08:39.888132 EDSA 0xdada, CPU > port 0.2, VLAN 0u, IP 198.18.10.2 > 198.18.10.1: ICMP echo reply, id 120, seq 1, length 64
+    3  00:08:39.893713 EDSA 0xdada, Forward port 0.2, VLAN 1337u, IP 198.18.10.1 > 198.18.10.2: ICMP echo request, id 121, seq 1, length 64
+    4  00:08:39.893737 EDSA 0xdada, CPU > port 0.2, VLAN 0u, IP 198.18.10.2 > 198.18.10.1: ICMP echo reply, id 121, seq 1, length 64
diff --git a/tests/edsa-high-vid.pcap b/tests/edsa-high-vid.pcap
new file mode 100644 (file)
index 0000000..492f381
Binary files /dev/null and b/tests/edsa-high-vid.pcap differ