Skip to content
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

Can't send or receive fragmented UDP packets #6082

Closed
Insomniac66 opened this issue Oct 13, 2020 · 13 comments
Closed

Can't send or receive fragmented UDP packets #6082

Insomniac66 opened this issue Oct 13, 2020 · 13 comments
Labels

Comments

@Insomniac66
Copy link

Environment

Windows build number:                         10.0.19041.0
Your Distribution version:                    Ubuntu 20.04
Whether the issue is on WSL 2 and/or WSL 1:   WSL 2

Steps to reproduce

I only ended up testing this issue with UDP and protocols based on it over IPv4.

  1. Listen for incoming UDP packets on port 8080 on some external host using nc -ul 8080.
  2. Open a socket to the external host inside WSL: nc -u <remote address> 8080
  3. Send a long (> 1471 characters excluding the \n) line / packet from WSL (doesn't arrive at external)
  4. Send a short line such as test from WSL to punch through the NAT for the next step (does arrive at external)
  5. Send a long (as above) reply from the external host (doesn't arrive at WSL)

External host console:

[user@hostname ~]$ nc -ul 8080
test
testaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
test
^C

If instead executed directly (outside of WSL) using a version of nc compiled for Windows, all packets arrive as expected.

WSL logs: Sadly I am not able to include logs due to Feedback being disabled.

Expected behavior

All packets are received at their respective destinations.

Actual behavior

Long packets are dropped somewhere between the physical NIC and WSL. This appears to happen whenever the IP datagram would exceed 1500 bytes in size. This issue seems related to #4517, however the proposed solution of lowering the MTU on WSL doesn't work for UDP since it disregards the MTU entirely and I am not connected to a VPN or similar. Running sudo tcpdump under WSL will produce output similar to the following upon sending these packets:

05:03:37.622552 IP 172.30.36.93.50284 > <external host redacted>.8080: UDP, bad length 1476 > 1472

Running Wireshark or tcpdump on the Windows host while receiving such long packets will show the fragmented package arriving, and Wireshark succeeds in displaying the reassembled UDP packet. Running sudo tcpdump in WSL produces no output related to the large packet.

image

@therealkenc
Copy link
Collaborator

Great analysis, thank-you. Was able to reproduce here. FWIW, Hyper-V with a bridged network is okay. Your step 3 can be quantified with something like the following, for (eg) 5000 'a' characters plus a newline:

$ printf '%*s\n' 5000 | tr ' ' a | nc -u 192.168.0.178 8080

This issue seems related to #4517

It is almost certainly the cause of at least some percentage of people's ssh woes as well.

@hansolav
Copy link

hansolav commented Jan 7, 2021

Have experienced the same problem over a long period sending UDP packages from a container in Docker for Windows. This was a problem while running Docker on Hyper-V and still is a problem running Docker in WSL2. Between the Docker containers packages are sent and received correctly. Trying to receive packages from the Docker container at the Windows host, it seems like fragmented UDP packages exceeding MTU are dropped.

@xamix
Copy link

xamix commented Jan 25, 2021

Experiencing the same problem here.
Any information on how/when this will be fixed?

I have a service which send stats by UDP and so it's unusable from inside the WSL...

@xamix
Copy link

xamix commented Jan 25, 2021

Until this is fixed, I use socat to do UDP tunelling over TCP.
Install it on both server and client (WSL)

sudo apt install socat

In the following example I forward the 8094 UDP port to the remote server:
Log with SSH on the remote server and launch the following command:

socat TCP4-LISTEN:8094,fork UDP4:localhost:8094

Finally open a terminal on the local client machine (WSL) and execute the following command:

sudo socat UDP4-LISTEN:8094,fork TCP4:<server_ip>:8094

Now on the local client machine (WSL) if you push with UDP on localhost::8094 then all is redirected on the remote server via TCP

@JohnyGemityg
Copy link

Hi, I think it also affects TCP traffic through a VPN interface where is lower MTU.

image

I workaroud it by ip route change $DEFAULT_ROUTE advmss $ADVMSS. But it is annoying.

@Aaron-Hartwig
Copy link

This still does not work as of Kernel version: 5.10.16.

@kennethgjohnson
Copy link

Any ETA?

@KevinPoole
Copy link

This is a major bummer. Took a long time to figure out what was happening. Running snmpbulkwalk from within a WSL instance...

# Works
snmpbulkwalk -c public -v 2c -192.168.87.203

# Fails - results in fragmented UDP packets that can be seen on wireshark on host but are not routed back to WSL instance
snmpbulkwalk -c public -v 2c -C r1024 192.168.87.203

Any update on this?

@AntoineGlacet
Copy link

Have the same problem to send WakeOnLan (udp) packets from wsl... Will try the TCP routing workaround!

@gdumke
Copy link

gdumke commented Jul 29, 2022

As mentioned by jstarks here, there's a workaround that might help you

@RobinTsai
Copy link

Same problem, waiting for solution.

@jnorell
Copy link

jnorell commented Nov 4, 2022

Just a note that the issue seems to be that all fragmented packets from the wsl2 host are dropped; I first experienced it with icmp, confirmed with udp and now also tcp.

An easy to reproduce case is to set the mtu in the WSL host lower, say to 1000; then send packets (icmp, udp or tcp) of size 900 and you will see them go through at various points in the network; then send the same packet of size 1100, so the WSL kernel fragments the packet, and it won't make it past the wsl interface to any other interface on the host nor to the network.

As everyone, would sure love a fix. (I'll probably just switch to a vm, as this makes WSL networking pretty flaky.)

Copy link
Contributor

This issue has been automatically closed since it has not had any activity for the past year. If you're still experiencing this issue please re-file this as a new issue or feature request.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests