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

net/procfs: Support to show MTU in netdev statistics #9116

Merged
merged 1 commit into from Apr 28, 2023

Conversation

wangchen61698
Copy link
Contributor

Summary

Support to show MTU in netdev statistics

Impact

N/A

Testing

Usage:
ifconfig (interfacename)
example:
ifconfig eth0
eth0 Link encap:Ethernet HWaddr 42:d3:59:ad:5a:2f at RUNNING mtu 1500
inet addr:10.0.1.2 DRaddr:10.0.1.1 Mask:255.255.255.0
inet6 addr: fe80::40d3:59ff:fead:5a2f/64
inet6 DRaddr: ::/64

Usage:
ifconfig (interfacename)
example:
ifconfig eth0
eth0	Link encap:Ethernet HWaddr 42:d3:59:ad:5a:2f at RUNNING mtu 1500
	inet addr:10.0.1.2 DRaddr:10.0.1.1 Mask:255.255.255.0
	inet6 addr: fe80::40d3:59ff:fead:5a2f/64
	inet6 DRaddr: ::/64

Signed-off-by: wangchen <wangchen41@xiaomi.com>
@xiaoxiang781216 xiaoxiang781216 merged commit d197ca9 into apache:master Apr 28, 2023
26 checks passed
@masayuki2009
Copy link
Contributor

@wangchen61698
I noticed that the gs2200m driver with usrsock can not obtain MTU info from the Wi-Fi chip.
So I think that showing MTU info should be selectable.

@xiaoxiang781216
Copy link
Contributor

xiaoxiang781216 commented Apr 28, 2023

what' value will show in ifconfig?

@masayuki2009
Copy link
Contributor

masayuki2009 commented Apr 28, 2023

what' value will show in ifconfig?

nsh> ifconfig
wlan0	Link encap:Ethernet HWaddr 3c:95:09:00:89:96 at UP mtu 576
	inet addr:192.168.10.22 DRaddr:192.168.10.1 Mask:255.255.255.0

Perhaps, the value was calculated from the following parameters in .config

#
# Driver buffer configuration
#
CONFIG_NET_ETH_PKTSIZE=590
CONFIG_NET_GUARDSIZE=2
CONFIG_NET_LL_GUARDSIZE=14
CONFIG_NET_RECV_BUFSIZE=0

@xiaoxiang781216
Copy link
Contributor

@wangchen61698 I noticed that the gs2200m driver with usrsock can not obtain MTU info from the Wi-Fi chip. So I think that showing MTU info should be selectable.

WiFi has the standard MTU definition, why not return the value in gs2200m driver directly if the chip can't return mtd info directly?

@wengzhe
Copy link
Contributor

wengzhe commented Apr 28, 2023

@wangchen61698 I noticed that the gs2200m driver with usrsock can not obtain MTU info from the Wi-Fi chip. So I think that showing MTU info should be selectable.

@masayuki2009 Hi, it seems that the gs2200m driver doesn't do the step obtain MTU info from the Wi-Fi chip and change dev->d_pktsize, so dev->d_pktsize would be default value (CONFIG_NET_ETH_PKTSIZE). But I don't have the device so if there is a mistake please point out to me, thanks :-)

I mean, the net stack will default think its MTU is CONFIG_NET_ETH_PKTSIZE - ETH_HDRLEN and cannot send packet longer than this value, so it will be the 'actual' MTU that takes effect for packet send.

Overall, I suggest to set the value of CONFIG_NET_ETH_PKTSIZE to correct value (MTU + L2 header len), which is the main effect of this config (Refer to its description below, To get an MTU of 1500, for example, you would need packet buffer of size 1514). And the MTU info in ifconfig would faithfully show the value that takes effect.

nuttx/net/Kconfig

Lines 58 to 80 in c87da0d

config NET_ETH_PKTSIZE
int "Ethernet packet buffer size"
default 1294 if NET_IPv6
default 590 if !NET_IPv6
range 1294 1518 if NET_IPv6
range 590 1518 if !NET_IPv6
depends on NET_ETHERNET
---help---
Packet buffer size. This size includes the TCP/UDP payload plus the
size of TCP/UDP header, the IP header, and the Ethernet header.
This value is related to the MTU (Maximum Transmission Unit), except
that it includes the size of the link layer header; the payload is
the MSS (Maximum Segment Size).
IPv4 hosts are required to be able to handle an MSS of at least
536 octets, resulting in a minimum buffer size of 536+20+20+14 =
590.
IPv6 hosts are required to be able to handle an MSS of 1220 octets,
resulting in a minimum buffer size of 1220+20+40+14 = 1294
To get an MTU of 1500, for example, you would need packet buffer of
size 1514.

@jerpelea jerpelea added this to To-Add in Release Notes - 12.2.0 Jun 13, 2023
@jerpelea jerpelea moved this from To-Add to In Progress in Release Notes - 12.2.0 Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants