From: Vivien Didelot Date: Sat, 6 Apr 2019 20:49:10 +0000 (-0400) Subject: Remove MEDSA ethertype printer X-Git-Tag: tcpdump-4.99-bp~836^2~1 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/d5c16b1668fef7011a239c216d07024136cc49e7 Remove MEDSA ethertype printer MEDSA (which unofficially stands for Marvell EDSA) relies on the unregistered 0xDADA ethertype value that was randomly choosen and currently used by the kernel. But with EDSA this value is programmable, hence can be changed anytime. Now that a reliable DLT parser is implemented for both DSA and EDSA tagged master interfaces, let's get rid for the MEDSA ethertype parser. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 0bac580e..4085419a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1005,7 +1005,6 @@ set(NETDISSECT_SOURCE_LIST_C print-lwapp.c print-lwres.c print-m3ua.c - print-medsa.c print-mobile.c print-mobility.c print-mpcp.c diff --git a/Makefile.in b/Makefile.in index fb9ee573..e345fe34 100644 --- a/Makefile.in +++ b/Makefile.in @@ -168,7 +168,6 @@ LIBNETDISSECT_SRC=\ print-lwapp.c \ print-lwres.c \ print-m3ua.c \ - print-medsa.c \ print-mobile.c \ print-mobility.c \ print-mpcp.c \ diff --git a/ethertype.h b/ethertype.h index 7719a6f0..2bddd734 100644 --- a/ethertype.h +++ b/ethertype.h @@ -206,8 +206,5 @@ #ifndef ETHERTYPE_GEONET #define ETHERTYPE_GEONET 0x8947 /* ETSI GeoNetworking (Official IEEE registration from Jan 2013) */ #endif -#ifndef ETHERTYPE_MEDSA -#define ETHERTYPE_MEDSA 0xdada /* Marvel Distributed Switch Architecture */ -#endif extern const struct tok ethertype_values[]; diff --git a/netdissect.h b/netdissect.h index 938c2464..b72f7ae6 100644 --- a/netdissect.h +++ b/netdissect.h @@ -621,7 +621,6 @@ extern void lwapp_control_print(netdissect_options *, const u_char *, u_int, int extern void lwapp_data_print(netdissect_options *, const u_char *, u_int); extern void lwres_print(netdissect_options *, const u_char *, u_int); extern void m3ua_print(netdissect_options *, const u_char *, const u_int); -extern void medsa_print(netdissect_options *, const u_char *, u_int, u_int, const struct lladdr_info *, const struct lladdr_info *); extern u_int mfr_print(netdissect_options *, const u_char *, u_int); extern void mobile_print(netdissect_options *, const u_char *, u_int); extern int mobility_print(netdissect_options *, const u_char *, const u_char *); diff --git a/print-ether.c b/print-ether.c index 8382e1ee..5d6fded2 100644 --- a/print-ether.c +++ b/print-ether.c @@ -100,7 +100,6 @@ const struct tok ethertype_values[] = { { ETHERTYPE_GEONET, "GeoNet"}, { ETHERTYPE_CALM_FAST, "CALM FAST"}, { ETHERTYPE_AOE, "AoE" }, - { ETHERTYPE_MEDSA, "MEDSA" }, { 0, NULL} }; @@ -493,10 +492,6 @@ ethertype_print(netdissect_options *ndo, aoe_print(ndo, p, length); return (1); - case ETHERTYPE_MEDSA: - medsa_print(ndo, p, length, caplen, src, dst); - return (1); - case ETHERTYPE_LAT: case ETHERTYPE_SCA: case ETHERTYPE_MOPRC: diff --git a/print-medsa.c b/print-medsa.c deleted file mode 100644 index aa3e7c84..00000000 --- a/print-medsa.c +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that: (1) source code distributions - * retain the above copyright notice and this paragraph in its entirety, (2) - * distributions including binary code include the above copyright notice and - * this paragraph in its entirety in the documentation or other materials - * provided with the distribution, and (3) all advertising materials mentioning - * features or use of this software display the following acknowledgement: - * ``This product includes software developed by the University of California, - * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of - * the University nor the names of its contributors may be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - */ - -/* \summary: Marvell Extended Distributed Switch Architecture (MEDSA) printer */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "netdissect-stdinc.h" - -#include "netdissect.h" -#include "ethertype.h" -#include "addrtoname.h" -#include "extract.h" - - -/* - * Marvell Extended Distributed Switch Archiecture. - * - * A Marvell proprietary header used for passing packets to/from - * specific ports of a switch. There is no open specification of this - * header, but is documented in the Marvell Switch data sheets. For - * background, see: - * - * https://lwn.net/Articles/302333/ - */ -struct medsa_pkthdr { - nd_byte reserved[2]; - nd_uint8_t tag_flags_dev; - nd_uint8_t port_trunc_codehi_cfi; - nd_uint8_t pri_vidhi_codelo; - nd_uint8_t vidlo; - nd_uint16_t ether_type; -}; - -/* Bytes 0 and 1 are reserved and should contain 0 */ -#define TAG(medsa) (GET_U_1(medsa->tag_flags_dev) >> 6) -#define TAG_TO_CPU 0 -#define TAG_FROM_CPU 1 -#define TAG_FORWARD 3 -#define SRC_TAG(medsa) ((GET_U_1(medsa->tag_flags_dev) >> 5) & 0x01) -#define SRC_DEV(medsa) (GET_U_1(medsa->tag_flags_dev) & 0x1f) -#define SRC_PORT(medsa) ((GET_U_1(medsa->port_trunc_codehi_cfi) >> 3) & 0x01f) -#define TRUNK(medsa) ((GET_U_1(medsa->port_trunc_codehi_cfi) >> 2) & 0x01) -#define CODE(medsa) ((GET_U_1(medsa->port_trunc_codehi_cfi) & 0x06) | \ - ((GET_U_1(medsa->pri_vidhi_codelo) >> 4) & 0x01)) -#define CODE_BDPU 0 -#define CODE_IGMP_MLD 2 -#define CODE_ARP_MIRROR 4 -#define CFI(medsa) (GET_U_1(medsa->port_trunc_codehi_cfi) & 0x01) -#define PRI(medsa) (GET_U_1(medsa->pri_vidhi_codelo) >> 5) -#define VID(medsa) ((u_short)(GET_U_1(medsa->pri_vidhi_codelo) & 0xf) << 8 | \ - GET_U_1(medsa->vidlo)) - -static const struct tok tag_values[] = { - { TAG_TO_CPU, "To_CPU" }, - { TAG_FROM_CPU, "From_CPU" }, - { TAG_FORWARD, "Forward" }, - { 0, NULL }, -}; - -static const struct tok code_values[] = { - { CODE_BDPU, "BDPU" }, - { CODE_IGMP_MLD, "IGMP/MLD" }, - { CODE_ARP_MIRROR, "APR_Mirror" }, - { 0, NULL }, -}; - -static void -medsa_print_full(netdissect_options *ndo, - const struct medsa_pkthdr *medsa, - u_int caplen) -{ - u_char tag = TAG(medsa); - - ND_PRINT("%s", - tok2str(tag_values, "Unknown (%u)", tag)); - - switch (tag) { - case TAG_TO_CPU: - ND_PRINT(", %stagged", SRC_TAG(medsa) ? "" : "un"); - ND_PRINT(", dev.port:vlan %u.%u:%u", - SRC_DEV(medsa), SRC_PORT(medsa), VID(medsa)); - - ND_PRINT(", %s", - tok2str(code_values, "Unknown (%u)", CODE(medsa))); - if (CFI(medsa)) - ND_PRINT(", CFI"); - - ND_PRINT(", pri %u: ", PRI(medsa)); - break; - case TAG_FROM_CPU: - ND_PRINT(", %stagged", SRC_TAG(medsa) ? "" : "un"); - ND_PRINT(", dev.port:vlan %u.%u:%u", - SRC_DEV(medsa), SRC_PORT(medsa), VID(medsa)); - - if (CFI(medsa)) - ND_PRINT(", CFI"); - - ND_PRINT(", pri %u: ", PRI(medsa)); - break; - case TAG_FORWARD: - ND_PRINT(", %stagged", SRC_TAG(medsa) ? "" : "un"); - if (TRUNK(medsa)) - ND_PRINT(", dev.trunk:vlan %u.%u:%u", - SRC_DEV(medsa), SRC_PORT(medsa), VID(medsa)); - else - ND_PRINT(", dev.port:vlan %u.%u:%u", - SRC_DEV(medsa), SRC_PORT(medsa), VID(medsa)); - - if (CFI(medsa)) - ND_PRINT(", CFI"); - - ND_PRINT(", pri %u: ", PRI(medsa)); - break; - default: - ND_DEFAULTPRINT((const u_char *)medsa, caplen); - return; - } -} - -void -medsa_print(netdissect_options *ndo, - const u_char *bp, u_int length, u_int caplen, - const struct lladdr_info *src, const struct lladdr_info *dst) -{ - const struct medsa_pkthdr *medsa; - u_short ether_type; - - ndo->ndo_protocol = "medsa"; - medsa = (const struct medsa_pkthdr *)bp; - ND_TCHECK_SIZE(medsa); - - if (!ndo->ndo_eflag) - ND_PRINT("MEDSA %u.%u:%u: ", - SRC_DEV(medsa), SRC_PORT(medsa), VID(medsa)); - else - medsa_print_full(ndo, medsa, caplen); - - bp += 8; - length -= 8; - caplen -= 8; - - ether_type = GET_BE_U_2(medsa->ether_type); - if (ether_type <= MAX_ETHERNET_LENGTH_VAL) { - /* Try to print the LLC-layer header & higher layers */ - if (llc_print(ndo, bp, length, caplen, src, dst) < 0) { - /* packet type not known, print raw packet */ - if (!ndo->ndo_suppress_default_print) - ND_DEFAULTPRINT(bp, caplen); - } - } else { - if (ndo->ndo_eflag) - ND_PRINT("ethertype %s (0x%04x) ", - tok2str(ethertype_values, "Unknown", - ether_type), - ether_type); - if (ethertype_print(ndo, ether_type, bp, length, caplen, src, dst) == 0) { - /* ether_type not known, print raw packet */ - if (!ndo->ndo_eflag) - ND_PRINT("ethertype %s (0x%04x) ", - tok2str(ethertype_values, "Unknown", - ether_type), - ether_type); - - if (!ndo->ndo_suppress_default_print) - ND_DEFAULTPRINT(bp, caplen); - } - } - return; -trunc: - nd_print_trunc(ndo); -} diff --git a/tests/TESTLIST b/tests/TESTLIST index f466a65d..e08ddfeb 100644 --- a/tests/TESTLIST +++ b/tests/TESTLIST @@ -335,10 +335,6 @@ dhcp-rfc3004 dhcp-rfc3004.pcap dhcp-rfc3004-v.out -v dhcp-rfc5859 dhcp-rfc5859.pcap dhcp-rfc5859-v.out -v dhcp-mud dhcp-mud.pcap dhcp-mud.out -vv -# MEDSA tests -medsa medsa.pcap medsa.out -medsa-e medsa.pcap medsa-e.out -e - # VXLAN tests vxlan vxlan.pcap vxlan.out -e diff --git a/tests/decnet-oobr.out b/tests/decnet-oobr.out index 66bb9af0..fb931142 100644 --- a/tests/decnet-oobr.out +++ b/tests/decnet-oobr.out @@ -1,4 +1,6 @@ 1 05:27:12.808464432 30:30:30:30:30:30 > 30:30:30:30:30:30, ethertype Unknown (0x3030), length 262144: 0x0000: 3030 3030 3030 3030 3030 3030 3030 3030 0000000000000000 0x0010: 3030 3030 0000 - 2 05:27:12.808464432 MEDSA 16.6:48: [|decnet] + 2 05:27:12.808464432 30:30:30:30:30:30 > 30:30:30:30:30:30, ethertype Unknown (0xdada), length 262144: + 0x0000: 3030 3030 3030 6003 3030 8a30 3030 3030 000000`.00.00000 + 0x0010: 3030 3030 0000 diff --git a/tests/medsa-e.out b/tests/medsa-e.out deleted file mode 100644 index 209975c1..00000000 --- a/tests/medsa-e.out +++ /dev/null @@ -1,20 +0,0 @@ - 1 12:57:38.954696 26:a1:fb:92:da:73 > 01:80:c2:00:00:00, ethertype MEDSA (0xdada), length 68: To_CPU, untagged, dev.port:vlan 0.2:0, BDPU, pri 7: LLC, dsap STP (0x42) Individual, ssap STP (0x42) Command, ctrl 0x03: STP 802.1d, Config, Flags [none], bridge-id 8000.26:a1:fb:92:da:73.8001, length 43 - 2 12:57:40.089958 94:10:3e:80:bc:f3 > 00:22:02:00:18:44, ethertype MEDSA (0xdada), length 98: From_CPU, untagged, dev.port:vlan 0.3:0, pri 0: ethertype IPv4 (0x0800) 10.0.0.12.59483 > 198.110.48.12.123: NTPv4, Client, length 48 - 3 12:57:40.129554 00:22:02:00:18:44 > 94:10:3e:80:bc:f3, ethertype MEDSA (0xdada), length 98: Forward, untagged, dev.port:vlan 0.3:0, pri 0: ethertype IPv4 (0x0800) 198.110.48.12.123 > 10.0.0.12.59483: NTPv4, Server, length 48 - 4 12:57:40.955210 26:a1:fb:92:da:73 > 01:80:c2:00:00:00, ethertype MEDSA (0xdada), length 68: To_CPU, untagged, dev.port:vlan 0.2:0, BDPU, pri 7: LLC, dsap STP (0x42) Individual, ssap STP (0x42) Command, ctrl 0x03: STP 802.1d, Config, Flags [none], bridge-id 8000.26:a1:fb:92:da:73.8001, length 43 - 5 12:57:42.956001 26:a1:fb:92:da:73 > 01:80:c2:00:00:00, ethertype MEDSA (0xdada), length 68: To_CPU, untagged, dev.port:vlan 0.2:0, BDPU, pri 7: LLC, dsap STP (0x42) Individual, ssap STP (0x42) Command, ctrl 0x03: STP 802.1d, Config, Flags [none], bridge-id 8000.26:a1:fb:92:da:73.8001, length 43 - 6 12:57:44.130355 94:10:3e:80:bc:f3 > 00:22:02:00:18:44, ethertype MEDSA (0xdada), length 98: From_CPU, untagged, dev.port:vlan 0.3:0, pri 0: ethertype IPv4 (0x0800) 10.0.0.12.59809 > 66.228.42.59.123: NTPv4, Client, length 48 - 7 12:57:44.130393 94:10:3e:80:bc:f3 > 00:22:02:00:18:44, ethertype MEDSA (0xdada), length 98: From_CPU, untagged, dev.port:vlan 0.3:0, pri 0: ethertype IPv4 (0x0800) 10.0.0.12.58880 > 199.102.46.76.123: NTPv4, Client, length 48 - 8 12:57:44.175132 00:22:02:00:18:44 > 94:10:3e:80:bc:f3, ethertype MEDSA (0xdada), length 98: Forward, untagged, dev.port:vlan 0.3:0, pri 0: ethertype IPv4 (0x0800) 199.102.46.76.123 > 10.0.0.12.58880: NTPv4, Server, length 48 - 9 12:57:44.189786 00:22:02:00:18:44 > 94:10:3e:80:bc:f3, ethertype MEDSA (0xdada), length 98: Forward, untagged, dev.port:vlan 0.3:0, pri 0: ethertype IPv4 (0x0800) 66.228.42.59.123 > 10.0.0.12.59809: NTPv4, Server, length 48 - 10 12:57:44.956531 26:a1:fb:92:da:73 > 01:80:c2:00:00:00, ethertype MEDSA (0xdada), length 68: To_CPU, untagged, dev.port:vlan 0.2:0, BDPU, pri 7: LLC, dsap STP (0x42) Individual, ssap STP (0x42) Command, ctrl 0x03: STP 802.1d, Config, Flags [none], bridge-id 8000.26:a1:fb:92:da:73.8001, length 43 - 11 12:57:46.190350 94:10:3e:80:bc:f3 > 00:22:02:00:18:44, ethertype MEDSA (0xdada), length 98: From_CPU, untagged, dev.port:vlan 0.3:0, pri 0: ethertype IPv4 (0x0800) 10.0.0.12.41068 > 208.97.140.69.123: NTPv4, Client, length 48 - 12 12:57:46.257959 00:22:02:00:18:44 > 94:10:3e:80:bc:f3, ethertype MEDSA (0xdada), length 98: Forward, untagged, dev.port:vlan 0.3:0, pri 0: ethertype IPv4 (0x0800) 208.97.140.69.123 > 10.0.0.12.41068: NTPv4, Server, length 48 - 13 12:57:46.956710 26:a1:fb:92:da:73 > 01:80:c2:00:00:00, ethertype MEDSA (0xdada), length 68: To_CPU, untagged, dev.port:vlan 0.2:0, BDPU, pri 7: LLC, dsap STP (0x42) Individual, ssap STP (0x42) Command, ctrl 0x03: STP 802.1d, Config, Flags [none], bridge-id 8000.26:a1:fb:92:da:73.8001, length 43 - 14 12:57:48.956704 26:a1:fb:92:da:73 > 01:80:c2:00:00:00, ethertype MEDSA (0xdada), length 68: To_CPU, untagged, dev.port:vlan 0.2:0, BDPU, pri 7: LLC, dsap STP (0x42) Individual, ssap STP (0x42) Command, ctrl 0x03: STP 802.1d, Config, Flags [none], bridge-id 8000.26:a1:fb:92:da:73.8001, length 43 - 15 12:57:50.560492 94:10:3e:80:bc:f3 > 00:22:02:00:18:44, ethertype MEDSA (0xdada), length 350: From_CPU, untagged, dev.port:vlan 0.3:0, pri 0: ethertype IPv4 (0x0800) 10.0.0.12.68 > 10.0.0.1.67: BOOTP/DHCP, Request from 94:10:3e:80:bc:f3, length 300 - 16 12:57:50.561440 00:22:02:00:18:44 > 94:10:3e:80:bc:f3, ethertype MEDSA (0xdada), length 350: Forward, untagged, dev.port:vlan 0.3:0, pri 0: ethertype IPv4 (0x0800) 10.0.0.1.67 > 10.0.0.12.68: BOOTP/DHCP, Reply, length 300 - 17 12:57:50.956688 26:a1:fb:92:da:73 > 01:80:c2:00:00:00, ethertype MEDSA (0xdada), length 68: To_CPU, untagged, dev.port:vlan 0.2:0, BDPU, pri 7: LLC, dsap STP (0x42) Individual, ssap STP (0x42) Command, ctrl 0x03: STP 802.1d, Config, Flags [none], bridge-id 8000.26:a1:fb:92:da:73.8001, length 43 - 18 12:57:52.956681 26:a1:fb:92:da:73 > 01:80:c2:00:00:00, ethertype MEDSA (0xdada), length 68: To_CPU, untagged, dev.port:vlan 0.2:0, BDPU, pri 7: LLC, dsap STP (0x42) Individual, ssap STP (0x42) Command, ctrl 0x03: STP 802.1d, Config, Flags [none], bridge-id 8000.26:a1:fb:92:da:73.8001, length 43 - 19 12:57:53.260353 94:10:3e:80:bc:f3 > 00:22:02:00:18:44, ethertype MEDSA (0xdada), length 98: From_CPU, untagged, dev.port:vlan 0.3:0, pri 0: ethertype IPv4 (0x0800) 10.0.0.12.45651 > 171.66.97.126.123: NTPv4, Client, length 48 - 20 12:57:53.325316 00:22:02:00:18:44 > 94:10:3e:80:bc:f3, ethertype MEDSA (0xdada), length 98: Forward, untagged, dev.port:vlan 0.3:0, pri 0: ethertype IPv4 (0x0800) 171.66.97.126.123 > 10.0.0.12.45651: NTPv4, Server, length 48 diff --git a/tests/medsa.out b/tests/medsa.out deleted file mode 100644 index e2c40569..00000000 --- a/tests/medsa.out +++ /dev/null @@ -1,20 +0,0 @@ - 1 12:57:38.954696 MEDSA 0.2:0: STP 802.1d, Config, Flags [none], bridge-id 8000.26:a1:fb:92:da:73.8001, length 43 - 2 12:57:40.089958 MEDSA 0.3:0: IP 10.0.0.12.59483 > 198.110.48.12.123: NTPv4, Client, length 48 - 3 12:57:40.129554 MEDSA 0.3:0: IP 198.110.48.12.123 > 10.0.0.12.59483: NTPv4, Server, length 48 - 4 12:57:40.955210 MEDSA 0.2:0: STP 802.1d, Config, Flags [none], bridge-id 8000.26:a1:fb:92:da:73.8001, length 43 - 5 12:57:42.956001 MEDSA 0.2:0: STP 802.1d, Config, Flags [none], bridge-id 8000.26:a1:fb:92:da:73.8001, length 43 - 6 12:57:44.130355 MEDSA 0.3:0: IP 10.0.0.12.59809 > 66.228.42.59.123: NTPv4, Client, length 48 - 7 12:57:44.130393 MEDSA 0.3:0: IP 10.0.0.12.58880 > 199.102.46.76.123: NTPv4, Client, length 48 - 8 12:57:44.175132 MEDSA 0.3:0: IP 199.102.46.76.123 > 10.0.0.12.58880: NTPv4, Server, length 48 - 9 12:57:44.189786 MEDSA 0.3:0: IP 66.228.42.59.123 > 10.0.0.12.59809: NTPv4, Server, length 48 - 10 12:57:44.956531 MEDSA 0.2:0: STP 802.1d, Config, Flags [none], bridge-id 8000.26:a1:fb:92:da:73.8001, length 43 - 11 12:57:46.190350 MEDSA 0.3:0: IP 10.0.0.12.41068 > 208.97.140.69.123: NTPv4, Client, length 48 - 12 12:57:46.257959 MEDSA 0.3:0: IP 208.97.140.69.123 > 10.0.0.12.41068: NTPv4, Server, length 48 - 13 12:57:46.956710 MEDSA 0.2:0: STP 802.1d, Config, Flags [none], bridge-id 8000.26:a1:fb:92:da:73.8001, length 43 - 14 12:57:48.956704 MEDSA 0.2:0: STP 802.1d, Config, Flags [none], bridge-id 8000.26:a1:fb:92:da:73.8001, length 43 - 15 12:57:50.560492 MEDSA 0.3:0: IP 10.0.0.12.68 > 10.0.0.1.67: BOOTP/DHCP, Request from 94:10:3e:80:bc:f3, length 300 - 16 12:57:50.561440 MEDSA 0.3:0: IP 10.0.0.1.67 > 10.0.0.12.68: BOOTP/DHCP, Reply, length 300 - 17 12:57:50.956688 MEDSA 0.2:0: STP 802.1d, Config, Flags [none], bridge-id 8000.26:a1:fb:92:da:73.8001, length 43 - 18 12:57:52.956681 MEDSA 0.2:0: STP 802.1d, Config, Flags [none], bridge-id 8000.26:a1:fb:92:da:73.8001, length 43 - 19 12:57:53.260353 MEDSA 0.3:0: IP 10.0.0.12.45651 > 171.66.97.126.123: NTPv4, Client, length 48 - 20 12:57:53.325316 MEDSA 0.3:0: IP 171.66.97.126.123 > 10.0.0.12.45651: NTPv4, Server, length 48 diff --git a/tests/medsa.pcap b/tests/medsa.pcap deleted file mode 100644 index ab20710e..00000000 Binary files a/tests/medsa.pcap and /dev/null differ