Skip to content

Replace netsh for handling MTU#17

Merged
ssrlive merged 3 commits intotun2proxy:masterfrom
mullvad:use-iphlpapi-mtu
Dec 16, 2025
Merged

Replace netsh for handling MTU#17
ssrlive merged 3 commits intotun2proxy:masterfrom
mullvad:use-iphlpapi-mtu

Conversation

@dlon
Copy link
Contributor

@dlon dlon commented Sep 20, 2025

Also, use the simpler GetIpInterfaceEntry for obtaining the interface MTU. This should reliably work.

@dlon
Copy link
Contributor Author

dlon commented Sep 21, 2025

Fixed the clippy warnings here: #18

@dlon
Copy link
Contributor Author

dlon commented Sep 22, 2025

Looks like the version needs to be bumped. Do you want me to do that?

@ssrlive
Copy link
Member

ssrlive commented Sep 22, 2025

Needn't, since 'stdcall' is 'system` in windows. I have no time to review it right now, maybe tomarrow.

@dlon
Copy link
Contributor Author

dlon commented Dec 9, 2025

Do you think you could have a look at this?

@ssrlive
Copy link
Member

ssrlive commented Dec 10, 2025

I apologize for the long delay, as I encountered numerous setbacks with setting the MTU in Wintun. This is due to a flaw in the Wintun kernel driver. The MTU settings weren't actually working, but many disagreed with me. To quell the debate, I agreed with these opinions and pretended that the MTU modifications were effective.

On the other hand, I don't trust the various dazzling APIs provided by Microsoft for setting network parameters, as I've suffered countless losses using them. Therefore, I prefer to use Microsoft's command-line tools like net to set parameters; at least they are thoroughly tested and effective.

Did your modifications to these MTU settings actually work? If you have thoroughly verified them, they do indeed work and have been proven in practice. I would be happy to merge this PR.

@dlon
Copy link
Contributor Author

dlon commented Dec 11, 2025

No worries. I've done some tests below.

The MTU is correct according to this: netsh interface ipv4 show interface

Also, running the udp-echo example (sudo cargo r --example udp-echo) with different MTUs works as expected. If I ping the address with the DF flag set and set the size to anything above MTU - header sizes, it fails as expected:

>ping 10.28.13.100 -l 1373 -f

Pinging 10.28.13.100 with 1373 bytes of data:
Packet needs to be fragmented but DF set.

I could also add that the Mullvad VPN app has been using SetIpInterfaceEntry/GetIpInterfaceEntry for many years. :)

@ssrlive ssrlive merged commit a572371 into tun2proxy:master Dec 16, 2025
5 of 6 checks passed
@dlon dlon deleted the use-iphlpapi-mtu branch December 16, 2025 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants