]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Moved source port equal BCM_LI_PORT to bottom of long if else chain
authorJonas Chianu <[email protected]>
Fri, 31 Mar 2023 16:24:22 +0000 (12:24 -0400)
committerFrancois-Xavier Le Bail <[email protected]>
Tue, 15 Aug 2023 12:44:20 +0000 (14:44 +0200)
BCM_LI_SHIM (BCM_LI_PORT) value is set to 49152, therefore when the
source port is 49152, it does not matter what the true destination is,
it defaults to Broadcom. So tcpdump interprets any packet with source
UDP port of 49152 as BCM_LI_SHIM (Broadcom). Ports 49152+, by
definition are ephemeral ports so it's totally reasonable that, for
example, BFD is using that source port for their packets. To prevent,
for example, BFD packets from being wrongly identified as BCM_LI_SHIM
packets, the "else if" statement has been moved to bottom of long chain.

Add a test file.

(backported from commit 10f7dff0c64e8ebb480cf48f5a09871e0d431761)

print-udp.c
tests/TESTLIST
tests/bfd_source_port_49152.out [new file with mode: 0644]
tests/bfd_source_port_49152.pcap [new file with mode: 0644]

index 4ce0082c5763d099ce270b12590b62bc288b6527..5f9151b737f07ce4ed0636437942bdea7e84d1f3 100644 (file)
@@ -673,8 +673,6 @@ udp_print(netdissect_options *ndo, const u_char *bp, u_int length,
                                        (IP_V(ip) == 6) ? 1 : 0);
                else if (IS_SRC_OR_DST_PORT(MPLS_LSP_PING_PORT))
                        lspping_print(ndo, cp, length);
-               else if (sport == BCM_LI_PORT)
-                       bcm_li_print(ndo, cp, length);
                else if (dport == BFD_CONTROL_PORT ||
                         dport == BFD_MULTIHOP_PORT ||
                         dport == BFD_LAG_PORT ||
@@ -721,6 +719,8 @@ udp_print(netdissect_options *ndo, const u_char *bp, u_int length,
                        ptp_print(ndo, cp, length);
                } else if (IS_SRC_OR_DST_PORT(SOMEIP_PORT))
                        someip_print(ndo, cp, length);
+               else if (sport == BCM_LI_PORT)
+                       bcm_li_print(ndo, cp, length);
                else {
                        if (ulen > length && !fragmented)
                                ND_PRINT("UDP, bad length %u > %u",
index 6538aa80bb0ff4b7accddb0b4b39a1b4a2719c07..59554016244caab588f192bae0fc04308a697838 100644 (file)
@@ -812,6 +812,8 @@ bfd-multihop        bfd-multihop.pcap       bfd-multihop.out
 bfd-multihop-v bfd-multihop.pcap       bfd-multihop-v.out      -v
 bfd-lag                bfd-lag.pcap            bfd-lag.out
 bfd-lag-v      bfd-lag.pcap            bfd-lag-v.out           -v
+# BFD with source port 49152
+bfd_source_port_49152 bfd_source_port_49152.pcap bfd_source_port_49152.out -v
 
 # Arista Vendor Specific Tests
 arista-ether             arista_ether.pcap        arista_ether.out
diff --git a/tests/bfd_source_port_49152.out b/tests/bfd_source_port_49152.out
new file mode 100644 (file)
index 0000000..f9c3bdd
--- /dev/null
@@ -0,0 +1,8 @@
+    1  09:58:19.559328 IP (tos 0xe0, ttl 255, id 40257, offset 0, flags [DF], proto UDP (17), length 52)
+    11.11.11.2.49152 > 11.11.11.1.3784: BFDv1, length: 24
+       Control, State Up, Flags: [Control Plane Independent], Diagnostic: No Diagnostic (0x00)
+       Detection Timer Multiplier: 3 (300 ms Detection time), BFD Length: 24
+       My Discriminator: 0x80000001, Your Discriminator: 0x80000001
+         Desired min Tx Interval:     100 ms
+         Required min Rx Interval:    100 ms
+         Required min Echo Interval:    0 ms
diff --git a/tests/bfd_source_port_49152.pcap b/tests/bfd_source_port_49152.pcap
new file mode 100644 (file)
index 0000000..bae9da1
Binary files /dev/null and b/tests/bfd_source_port_49152.pcap differ