Bug 1460217

Summary: nmcli summary doesn't show mtu for gsm devices
Product: Red Hat Enterprise Linux 7 Reporter: Vladimir Benes <vbenes>
Component: NetworkManagerAssignee: Francesco Giudici <fgiudici>
Status: CLOSED ERRATA QA Contact: Desktop QE <desktop-qa-list>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.4CC: atragler, bgalvani, fgiudici, lrintel, rkhan, sukulkar, thaller
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1623520 (view as bug list) Environment:
Last Closed: 2018-04-10 13:24:24 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1470965    
Attachments:
Description Flags
Patch: got mtu from ip device
none
Patch: update device mtu from ip interface
none
Patch: update device mtu from ip interface none

Description Vladimir Benes 2017-06-09 11:52:54 UTC
Description of problem:
[root@gsm-r6s17-01 ~]# nmcli 
eth0: connected to testeth0
	"Intel 82579LM Gigabit"
	ethernet (e1000e), 44:37:E6:C6:00:F7, hw, mtu 1500
	ip4 default, ip6 default
	inet4 10.16.122.81/24
	inet6 2620:52:0:107a:e97c:dde2:224b:b81a/64
	inet6 fe80::3f4b:77af:f81b:c936/64
	route6 2620:52:0:107a::/64

cdc-wdm0: connected to gsm
	"cdc-wdm0"
	gsm (qcserial, qmi_wwan), hw, iface wwp0s20u
	inet4 192.168.99.3/29

eth1: disconnected
	"eth1"
	1 connection available
	ethernet (veth), 72:6C:08:D2:83:12, sw, mtu 1500


mtu for gsm device is set to 1600 in this case but is not shown at all.

Version-Release number of selected component (if applicable):
1.8

Comment 1 Thomas Haller 2017-06-15 20:56:07 UTC
For WWAN types (among others), there is a distinction between the "ifindex" and the "ip_ifindex". Yes, we don't properly expose the MTU in this case. Should be improved.

It was also discussed, whether these device types shoudn't be split. Currently, one NMDevice in a way represents two interfaces. Instead, there should be a "controller device" and an "ip device". That would require a larger work.

Comment 2 Francesco Giudici 2017-11-20 14:10:15 UTC
Created attachment 1355850 [details]
Patch: got mtu from ip device

Comment 3 Francesco Giudici 2017-11-20 14:11:11 UTC
(In reply to Thomas Haller from comment #1)
> For WWAN types (among others), there is a distinction between the "ifindex"
> and the "ip_ifindex". Yes, we don't properly expose the MTU in this case.
> Should be improved.
> 
> It was also discussed, whether these device types shoudn't be split.
> Currently, one NMDevice in a way represents two interfaces. Instead, there
> should be a "controller device" and an "ip device". That would require a
> larger work.

Yeah, probably a major rework is something we want to do here.
Anyway, fixing the MTU in this case seems as easy as getting it from the platform events reported on the "ip_ifindex".
If there would not be a case where we get 2 different MTUs from the "controller device" and the associated "ip device" it should be safe and good enough.

Please comment attached patch

Comment 4 Thomas Haller 2017-11-21 10:17:32 UTC
(In reply to Francesco Giudici from comment #2)
> Created attachment 1355850 [details]
> Patch: got mtu from ip device

A subsequent device_link_changed() would reset it to something else and two interface would fight for setting the MTU property. At least, if ip-ifindex is set, then the MTU from the non-ip-ifindex must be ignored.

But may one day we might want to split the IP-device. At that point, it might be  be better if "mtu" references the MTU of the device with the non-ip-ifindex. You change that meaning now (which is a change in behavior), but later, we may not want to revert the behavior again.

I am not convinced that this is the right approach. Dunno.

Comment 5 Beniamino Galvani 2017-11-21 10:43:55 UTC
(In reply to Francesco Giudici from comment #3)
> (In reply to Thomas Haller from comment #1)
> > For WWAN types (among others), there is a distinction between the "ifindex"
> > and the "ip_ifindex". Yes, we don't properly expose the MTU in this case.
> > Should be improved.
> > 
> > It was also discussed, whether these device types shoudn't be split.
> > Currently, one NMDevice in a way represents two interfaces. Instead, there
> > should be a "controller device" and an "ip device". That would require a
> > larger work.
> 
> Yeah, probably a major rework is something we want to do here.
> Anyway, fixing the MTU in this case seems as easy as getting it from the
> platform events reported on the "ip_ifindex".
> If there would not be a case where we get 2 different MTUs from the
> "controller device" and the associated "ip device" it should be safe and
> good enough.

I think the iface and ip_iface can have different MTUs and then NM would report a a random one between them. In my opinion, it's better to fix it in other ways, as considering the the devices as distinct, or adding a new property for the IP interface MTU.

Comment 6 Francesco Giudici 2017-11-21 14:27:15 UTC
(In reply to Beniamino Galvani from comment #5)
> (In reply to Francesco Giudici from comment #3)
> > (In reply to Thomas Haller from comment #1)
> > > For WWAN types (among others), there is a distinction between the "ifindex"
> > > and the "ip_ifindex". Yes, we don't properly expose the MTU in this case.
> > > Should be improved.
> > > 
> > > It was also discussed, whether these device types shoudn't be split.
> > > Currently, one NMDevice in a way represents two interfaces. Instead, there
> > > should be a "controller device" and an "ip device". That would require a
> > > larger work.
> > 
> > Yeah, probably a major rework is something we want to do here.
> > Anyway, fixing the MTU in this case seems as easy as getting it from the
> > platform events reported on the "ip_ifindex".
> > If there would not be a case where we get 2 different MTUs from the
> > "controller device" and the associated "ip device" it should be safe and
> > good enough.
> 
> I think the iface and ip_iface can have different MTUs and then NM would
> report a a random one between them. In my opinion, it's better to fix it in
> other ways, as considering the the devices as distinct, or adding a new
> property for the IP interface MTU.

In this specific case the cdc-wdm0 device is a character device speaking qmi to control the modem: the exposed network device is "wwp0s20u" and is the only one for which network configuration (ip conf, mtu, hw address...) apply.
I cannot figure out a case where we have a MTU on both device and ip_iface and they differs... because at the end we would have only one network configuration, and so only one correct MTU, isn't it? And in this case, wouldn't be correct to report the ip_interface MTU (as it embodies the ip connection we are tracking)?

In order to be safe in the event that the control interface has a valid mtu we have two choices:
1) take the MTU only from the ip_interface when present (as Thomas suggested)
2) take the MTU from the ip_interface only if the main device as MTU unset: this would require to track with a gboolean if the MTU has been set from the ip_interface or the main one.

I wonder if it is worth to spend an effort to do this or just let it as is as we will soon or later do a major rework there.
Well, the effort would be so tiny and the result immediate that maybe we can do this: option 1) seems to me the right thing to do, option 2) is instead a safe approach to have mtu on this kind of devices in the case it is not set at all.

Comment 7 Thomas Haller 2017-11-21 14:56:46 UTC
> I cannot figure out a case where we have a MTU on both device and ip_iface and 
> they differs...

if they would never differ, the patch would not be useful.

Comment 8 Francesco Giudici 2017-11-21 15:56:36 UTC
(In reply to Thomas Haller from comment #7)
> > I cannot figure out a case where we have a MTU on both device and ip_iface and 
> > they differs...
> 
> if they would never differ, the patch would not be useful.

Right! Sorry, I meant, both set to a valid value and differ... I would expect the control interface to never have a valid MTU.

Comment 9 Francesco Giudici 2017-11-23 09:15:24 UTC
Created attachment 1358078 [details]
Patch: update device mtu from ip interface

I realized that this simple case, i.e., a device tracking a control device (which is a char device with no network interface), it is easily detectable checking the ifindex. If it is 0, we know that we are in this case and that the only exposed network interface (and so MTU) is from the ip interface.

Please, check the updated patch.

Comment 10 Thomas Haller 2017-11-24 12:30:08 UTC
  if (!priv->ifindex && pllink->mtu)

the correct way for checking for valid ifindex is "ifindex > 0". At various places we set ifindex to -1 to indicate an invalid ifindex. We shouldn't do that, and maybe there exist no more code paths that still do that. But unless you proof that (and make sure that it continues to be true in future), checks must consider that there might be negative values.

Comment 11 Francesco Giudici 2017-11-24 13:27:32 UTC
(In reply to Thomas Haller from comment #10)
>   if (!priv->ifindex && pllink->mtu)
> 
> the correct way for checking for valid ifindex is "ifindex > 0". At various
> places we set ifindex to -1 to indicate an invalid ifindex. We shouldn't do
> that, and maybe there exist no more code paths that still do that. But
> unless you proof that (and make sure that it continues to be true in
> future), checks must consider that there might be negative values.

I missed it, thanks.
Changed the condition to check for invalid ifindex:
priv->ifindex <= 0

Comment 12 Francesco Giudici 2017-11-24 13:28:15 UTC
Created attachment 1358664 [details]
Patch: update device mtu from ip interface

Comment 13 Beniamino Galvani 2017-11-24 14:14:03 UTC
I think it's correct to export the MTU of IP interface if there is no lower interface. Patch lgtm.

Comment 16 Vladimir Benes 2018-02-09 22:45:58 UTC
working well, covered in CI

Comment 19 errata-xmlrpc 2018-04-10 13:24:24 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2018:0778