-
Notifications
You must be signed in to change notification settings - Fork 890
Don't fail on unsupported DSA tag #1451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Don't fail on unsupported DSA tag #1451
Conversation
Up until commit 8f1f6fc ("If we can't allocate a DLT_ list, fail."), the iface_dsa_get_proto_info() return code was ignored, but now it isn't. Many DSA tags are in use which libpcap has no idea about: the-tcpdump-group#1367 Let's keep the behavior as before, i.e. don't give up on these packets, even though we don't know what's inside.
Hello Vlad, I'm all in for that one, I gave it a test and it works fine (debugging a ksz9477 setup whose tag format isn't supported as well). I strongly agree that this regression needs fixing. Thanks, Maxime |
So what will |
Yeah. I mean, they look horrible in tcpdump, but it gets the job done.
|
So these packets are not actually Ethernet, correct? |
They are absolutely Ethernet frames with an extra header (generically called "tag" because depending on switch vendor, it may not actually be "header" but also "trailer") that contains switch-specific information. For example, in the dump above, if you remove "dadb 0c02", what you get is a normal STP packet. |
Thank you for the comments. Do you mean in this specific case it is exactly one of those or something else? |
No, it's not one of the 4 protocols for which libpcap assigns a specific link type, but rather one of the remaining 25 for which it doesn't. |
Then perhaps we should assign more of them, and do tcpdump and Wireshark dissectors for them.
Then it sounds as if there should be a |
I mean, they are Ethernet packets, and comply to all Ethernet packet rules. The host port (which is most of the time a regular, DSA-unaware network card, and which any other day would actually use DLT_EN10M) parses as much of the packet as it can, and it treats it for what it is - an Ethernet frame with an unknown Ethertype. In the example above, "d8:58:d7:00:ca:6d > 01:80:c2:02:00:00, ethertype Unknown (0xdadb), length 64" is exactly as much as the protocol parser of the host port makes out of this packet. I don't know to what end we would lose even this small amount of information by dissecting as a raw hex dump in favor of just falling back to DLT_EN10M. |
By which you presumably mean "they are blobs of bytes that, somewhere within them, contain an Ethernet packet, perhaps with additional stuff stuck in front of it, after it, or in the middle of it." See, for example, the So, no, an Ethernet dissector will not necessarily...
...parse the packet as being an Ethernet frame with an unknown Ethertype. If And if, in fact, that's the case, then we don't need However, if a DSA tag type is ever used for on-the-wire Ethernet traffic, a In the example above, "d8:58:d7:00:ca:6d > 01:80:c2:02:00:00, ethertype Unknown (0xdadb), length 64" is exactly as much as the protocol parser of the host port makes out of this packet. I don't know to what end we would lose even this small amount of information by dissecting as a raw hex dump in favor of just falling back to DLT_EN10M. |
Arguably, if the frame was Ethernet, the hardware and the kernel would both handle it as Ethernet. If they both handle it as DSA, then most likely it is DSA. It would be most helpful to focus on the specification. |
Which specification? DSA doesn't specify what tags look like - that's up to the vendor, and many of them seem to do their own thing. |
So when I said that the host port is "most of the time a regular, DSA-unaware network card", I really selected my words carefully by saying "most of the time", and I wasn't trying to be dishonest about omitting the rest, it's just that I consider the exceptions to be irrelevant to this discussion. However you decided to pick out LINKTYPE_DSA_TAG_BRCM_PREPEND, which is one of the exceptions.
Very broadly speaking, DSA switches encapsulate Ethernet frames when delivering them towards the host port, yes, but I don't want you to draw the wrong conclusion from that. But you've jumped straight to LINKTYPE_DSA_TAG_BRCM_PREPEND, and I believe that only now do we have all the context on the table to explain it. Sometimes, DSA switches are integrated on the same silicon die with an entire SoC, and there you still have an internal Ethernet host port for management traffic. Sometimes, the vendor of the host port IP is different than the vendor of the integrated switch IP, like NXP LS1028A, with an enetc host and an ocelot switch. So, that changes nothing in terms of having to be Ethernet-compatible, because that's still the common denominator even though they're both on the same SoC. But sometimes, an SoC vendor like Broadcom integrates a Broadcom switch with a Broadcom host port, and they have the chance to optimize that integration, and break the compatibility with Ethernet for that internal MAC-to-MAC connection. Because all traffic that the host port is going to see is coming from the switch, these guys can modify the hardware protocol parser of the host port to essentially expect the DSA encapsulation. You can ask yourself why, if they bothered to optimize the design, they didn't go all the way and provide a more performant packet I/O mechanism, like have buffer descriptor rings and DMA for each switch port rather than the bottleneck of a single internal Ethernet link, and the answer has to do with the fact that it's just an evolution of the baseline design I already presented earlier. Anyway, you could make a valid point that DSA tagging protocols that aren't backwards compatible with Ethernet should have a dedicated link type, but that point is moot with LINKTYPE_DSA_TAG_BRCM_PREPEND which already does, but honestly, backwards compatiblity with Ethernet is not something that we as DSA maintainers monitor when we review new tagging protocol submissions, so I can't tell you for sure how many other such protocols are there in the wild. I'll try to think of some way to integrate in the medium term testing of new tagging protocols with the dsa_loop kernel driver (which is a way of making any Ethernet interface think it's attached to a DSA switch even if it physically isn't), and inform patch submitters that it's mandatory for them to submit a dedicated link type to libpcap if the protocol is not backwards-compatible with Ethernet. That's about the most I can promise, but I really want the assumed default to remain that DSA tagging protocols are compatible with Ethernet to some extent. Who wants to add a specific link type for a certain Ethernet-compatible protocol, perfectly fine, but don't force that. |
There are cases which are not as simple as that. Look, I really appreciate that you two are trying to understand and leave no stone unturned, but you have to understand that this regression has a bit of an urgency to it. Even though the change was made a long time ago, it only made it to distributions recently, and it has started affecting people. |
You need to define "wire" here. DSA-tagged traffic is passed between the switch and its host port. Since the host port is a dedicated Ethernet interface, that's pretty much "on the wire" as far as it's concerned, but outside of this system, DSA tags are not visible to the outside world. We would really hide the host port from being visible in ifconfig if we could, because as a user you're not supposed to interact with it, but directly with the switch user ports, but we can't, and it's occasionally useful to debug by running tcpdump on it. The host port is just a resource used by DSA, a dumb pipe, and the "wire" varies from Verilog wires (for integrated switches) to PCB traces to regular Ethernet cables (think Beaglebone Black connected to a switch evaluation board). Though, mainly during developer testing, we can activate the dsa_loop kernel driver, and this lets any Ethernet interface speak a certain DSA tagging protocol with the outside world, with no switch to parse the tags. The public infrastructure for this isn't developed almost at all - anybody who does this has their own tooling for their own purpose. But we treat a DSA tagging protocol, as identified by its textual name, as stable ABI (at least after a certain point, there have been incompatible changes before, which we're trying not to repeat), and anybody who wants to transition a protocol from the Ethernet link type to a specific one can do so at any time in the future. |
Yes, I'd already read the part of the DSA documentation about the three tag types. For type 1 tags, such as For type 2, if the tag begins with a two-octet big-endian field that contains an assigned Ethertype value that is used only for a particular tag type, then For type 3, the frame can be dissected as So if somebody can provide a list of the tag types that are:
then we can assign So:
Currently:
I'd be inclined, for now, to fall back on It would be very helpful if somebody could provide a list of type 1/type 2 without a usable Ethertype/type 3 tags, so we could, if nothing else, put entries in the |
As per your own criteria, you have edsa in the wrong category (it has its own link type but by your logic it shouldn't). |
Sorry, I must not have stated my logic clearly enough. As I understand it, the tag used by "edsa" begins with a 2-octet value that comes from a driver-settable register in the hardware, so there's no guarantee that somebody won't set it to 0x0800 or whatever and, even if it's set to the one value that the IEEE site says is assigned to Marvell, 0x22E3, we don't know for certain whether that might also be used for on-the-Ethernet protocols that cannot be reliably distinguished from EDSA tags. Therefore, it belongs in the "type 2 without a usable Ethertype value" - or, perhaps, "known-to-be-usable Ethertype value".
Because:
|
Ok, but confusingly you refer to type 2 tags with no usable EtherType as if there was any tag at all whose EtherType is in the IANA 802 numbers table. I don't think that's the case - none of them are. |
I know it's the case, as the Realtek tags are. They use Ethertype 0x8899, which is registered to "Realtek Semiconductor Corp.". Go to https://regauth.standards.ieee.org/standards-ra-web/pub/view.html#registries, select "EtherType(TM)" as the "Product", click the search button, enter 8899 in the filter box, and click "Filter". |
Here's what I've been able to extract from the kernel sources.
|
Is "sja1105" just a standard VLAN tag if it has an Ethertype of 0x8100? 0xdadb doesn't appear to be in the IEEE database. Are "lan9303", "ocelot-8021q", and "vsc73xx-8021q" all standard VLAN tags? (The "8021q" in the names of the latter two suggest that those two are.) |
They are all VLAN tags with specific meanings superimposed on top of the VID field. In the case of "sja1105", the TPID can either be 0x8100 or 0xdadb, depending on whether the switch is VLAN-aware or not - the TPID doesn't affect the interpretation of the other fields in the tag. The value of 0xdadb is self-assigned, no guarantee there won't appear a protocol using this EtherType in the future. |
Of the non-8100 Ethertypes:
|
So it's probably best to assign a |
What does this all mean for this patch? Do you mean separate link types should be assigned now, when I really have no interest in writing a disector, or when? |
My inclination right now is to expand the table of known tag types to include all he ones currently used in the Linux kernel, temporarily mapping all those that don't have If somebody adds a tag type, they should tell us about it, so we can add it to the list. After that, we assign |
Many of those entries need their own LINKTYPE_/DLT_? values, including tcpdump and Wireshark support for same, but at least this lets you see raw hex data from a capture. Fixes the-tcpdump-group#1367. Supercedes the-tcpdump-group#1451.
Using If the DSA protocol/type is known at the capture time and there is no specific DLT for it, it would seem reasonable to state: "this is a DSA frame, it was captured on Linux and Linux indicated the variety of DSA was X". In other words, it could be something such as Does it make sense? |
Alternatively, there could be something like |
@guyharris, do you mind if I prototype the changes to avoid mixing DSA into |
Nope, go ahead. |
I have 3 routers which I upgraded to OpenWrt 24.10.0 (r28427-6df0e3d02a) today.
Is there a reasonable simple way to install your fix on my devices without being either an OpenWRT nor libpcap developer, or do I need to downgrade OpenWRT to a previous version (how old does it need to be?) that doesn't have this bug? |
According to OpenWrt device pages (AX3000T, 4A Gb), these devices are supported. Perhaps the documentation is not 100% accurate in every regard, but this is not uncommon. A paying customer of the vendor that makes these Xiaomi devices could make a point that OpenWrt developers didn't do a thorough QA for this combination of hardware and firmware, and the counter-points could be that OpenWrt is free software, the work is done by volunteers, no warranty implied etc. But this would not improve libpcap support for DSA on Linux, would it? The workaround for these newer DSA types in libpcap is not yet complete. It is important to make sure it does not break other things for other users on Linux and other operating systems. It will take some time for the solution to reach the end users. Your best course of action would be rolling back to the previous working firmware and waiting until support for this hardware improves. Alternatively, you could try a different hardware that works out of the box. This has been my own experience with OpenWrt in the last ~13 years, and with open source software in general in the last ~25 years (that said, quite often users get the same experience after buying proprietary software). Sometimes such incomplete or lacking hardware support even motivates the users to become contributors or developers themselves. In future, if anyone expects support for a particular new software or hardware in libpcap, please do your research/testing/QA as soon as you can and report any problems as soon as you can because the correct solution may be more complicated than it seems. |
I think that you'll only see the DSA tags when dumping on the physical interface that connects to the switch. |
Hi all. Are there any progress on this issue? |
Thank you for waiting. As discussed, I have prototyped some code to introduce a new "opaque unstructured data" DLT and to use it in
Then I got distracted by other work. Would you be able to compile the proposed better solution when it becomes ready and to try it on the hardware with the unsupported DSA type? |
Sure, just ping me. |
I'm not sure whether that was my idea, or somebody else's suggestion that I added in comments, but I'm not sure it's the bet idea; What perhaps should be done is:
(And update Wireshark to support the new link-layer types as well.) |
Up until commit 8f1f6fc ("If we can't allocate a DLT_ list, fail."), the iface_dsa_get_proto_info() return code was ignored, but now it isn't.
Many DSA tags are in use which libpcap has no idea about: #1367
Let's keep the behavior as before, i.e. don't give up on these packets, even though we don't know what's inside.