-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
ModemManager: MTU not being set based on Bearer info #11383
Comments
I see in the netifd script that this is marked as a "TODO"
Any hints on how to implement this? |
I think I've figured out what parts are missing. As with most C language programs, Netifd is stunningly under documented, so I'm probably not fully understanding the complete picture. That being said, here we go. Netifd/interface-ip.c:
And then later in this function:
We have this block:
So there's already a ubus interface that has something to do with the MTU, and specifically it looks to be the ubus command message that tells netifd to set up the route. Then, in netifd/netifd-functions.sh
Which calls this function:
Which is probably the gnarlyiest function I've seen in a while. But my take is that it's appending values to the environment variable "PROTO_ROUTE" in a way that respects the '/' character as the seperator. Gnarly. Then, some time later, somebody calls this function:
Which calls this function:
Which is the second gnarlyiest function I've seen in a while. This function grabs all the details from the PROTO_ROUTE variable and sticks them into the current json object. And then the resulting json string is sent to ubus like so:
So what appears to be missing is that despite netifd having direct support for this on the UBus interface, the associated scripts don't understand how to receive the MTU information from anything, or to communicate that to netifd. I think that modifying
like such:
and then
Will fix the underlying netifd issue. From there, you change : Such that:
Becomes
Unfortunately, at the moment, I don't know what to do about the missing "metric" variable. Theoretically passing just "" will be sufficient to make it get skipped, but I am not an expert on posix shell, so that's not clear yet. That being said... We do have the metric:
So why are we attempting to pass that as a loose integer variable in the json, instead of using the existing route function? @aleksander0m Do you recall why you set up the metric like this? |
@nickberry17 @aleksander0m ModemManager's ppp integration also does not set the MTU. You'll see in /lib/netifd/proto/ppp.sh
Whereas modemmanager.sh
Does not attempt to communicate the mtu the bearer reports to pppd. |
An attempt at a patch for the MTU problem (untested)
|
Well, with those two patches, i get this ubus call: ubus call network.interface notify_proto "{ "action": 0, "ifname": "wwan0", "link-up": true, "keep": true, "ipaddr": [ { "ipaddr": "10.3.129.231", "mask": "255.255.255.240" } ], "routes": [ { "target": "0.0.0.0", "netmask": "0", "gateway": "10.3.129.232", "source": "10.3.129.231", "mtu": "1430" } ], "dns": [ "172.26.38.1", "10.0.0.252" ], "interface": "wwan" }" Unfortunately, it doesn't result in the MTU changing. Probably because my version of netifd is from June 2018, and I see several MTU related changes in the git history since then. Will try updating to the 19.07 version and see what happens. |
Nope. netifd from openwrt-19.07 makes no difference. |
I'm not going to bother trying to patch the netifd c code. i'll just add a script that checks the mtu from modemmanager and sets it with the ifconfig program. |
I just want to be clear, to make sure everyone is on the same page: I am not working on this any more. I've completely worked-around this problem with a fugly hack that sets the MTU after modemmanager and netifd finish their work, by looping over modemmanager's mmcli output and checking against the mtu of the interface, and setting it with ifconfig if needed. Since that solves my problem good enough, I'll stick with that. That being said, if anyone else wants to jump in on this, I would be happy to collaborate, including testing, code review, and programming help. |
I don't remember, but if I had to give an answer, I guess it's because the MTU is a per-interface configuration, not a route configuration; isn't that right? Why is the MTU part of the route settings? |
Apologies for any confusion. My question about the metric was a code style question that arose while investigating the MTU. Not really related to the MTU. MTU is a per interface thing, not a per route thing, as you said. |
Re-reading this whole issue, I see why you ask about the MTU and the route. Yes, you're correct, and I was also confused why it looked like netifd wanted to be told about the MTU as part of the route. The Netifd source code is not documented sufficiently for me to understand how to fix this in the amount of time I have available for the task, so I gave up and implemented a work-around. But I agree with you that if the MTU is to be set, it should be set on the interface itself, not on the route. Please also note that the MTU is not being passed to pppd either, so that's something to consider and probably would be easy enough to address quickly, which would leave only the static ip address case as not having the MTU (I think? DHCP should get it automatically, if I'm not mistaken) |
@jonesmz I'm also new to netifd. How do you know when "netifd" finished it's work? i.e. from where you call your workaround? |
You would do something like this
I just loop on that forever, with a sleep per iteration. It's hacky, but it works. |
@jonesmz Thank you for your investigation. I looked into your proposed changes and the MTU which netifd modifies is "route MTU" and not "interface MTU". So after applying your suggested changes we see: $ ip route show Please note "mtu 1430" in the end. Same for ipv6 |
Well honestly I didn't even know a route MTU was a thing. Since you are new to netifd, I suppose you probably don't know of any mechanism to set the MTU for the interface? |
Well, only method I found to set interface MTU via netifd is to have below UCI in /etc/config/network. I'm not able to find any ubus call config device |
Using the same method used by other protocol handlers like uqmi. Fixes openwrt#11383 Signed-off-by: Aleksander Morgado <aleksander@aleksander.es>
Using the same method used by other protocol handlers like uqmi. Fixes openwrt#11383 Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> (cherry picked from commit 41552c1)
Using the same method used by other protocol handlers like uqmi. Fixes openwrt/packages#11383 Signed-off-by: Aleksander Morgado <aleksander@aleksander.es>
Using the same method used by other protocol handlers like uqmi. Fixes openwrt#11383 Signed-off-by: Aleksander Morgado <aleksander@aleksander.es>
Using the same method used by other protocol handlers like uqmi. Fixes openwrt#11383 Signed-off-by: Aleksander Morgado <aleksander@aleksander.es>
Maintainer: @nickberry17
Description:
When Netifd brings a ModemManager based connection up, the bearer informs Netifd of the MTU that the connection supports.
For example, an AT&T cellphone connection frequently has an MTU of below 1500 (e.g. https://www.digi.com/support/knowledge-base/recommended-mtu-mru-settings-on-cellular-networks)
For example:
However, netifd is not using that information to set the MTU of the wwan0 interface that it brings up.
This results in some traffic getting silently dropped.
The text was updated successfully, but these errors were encountered: