mii-monitor-interval unit is undocumented, and may be wrong

Bug #1745597 reported by Chris Jones on 2018-01-26
14
This bug affects 1 person
Affects Status Importance Assigned to Milestone
netplan
High
Mathieu Trudel-Lapierre
nplan (Ubuntu)
Undecided
Unassigned
Xenial
Undecided
Unassigned
Artful
Undecided
Unassigned

Bug Description

[Impact]
Users of bond and bridges devices requiring tuning of the default device parameters.

[Test case]
== Configure MII monitor interval ==
1) Configure a bond device
2) Add parameters:

bonds:
  mybond0:
    parameters:
      mii-monitor-interval: 1

3) Verify that the applied MII monitor interval is of 1ms, as opposed to 1 second (1000ms), by verifying the contents of /sys/class/net/mybond0/bonding/miimon

== Validate default behavior ==
1) Configure a bond device without parameters.
2) Verify that no special MII monitor interval is applied, the default value should be 0:

$ cat /sys/class/net/mybond0/bonding/miimon
0

[Regression potential]
MII monitor behavior is changing with this SRU. Default behavior for an unqualified value (ie. a number alone), which was also the only way to specify parameters, was to interpret the values as *seconds*. This leads to relatively slow checking of the device link status (for MII monitor), much slower than generally expected. The same applies to other time-based values such as up delay, down delay, arp interval. The interpretation for these values changes to reading them as *milliseconds* when unqualified, and a new way of qualifying the values (adding a modifier) was added. This was, people who do require "slow" checking of the MII link status will be migrated to "fast" checking right now, moving from an interval of 1 second to 1 millisecond (more checking means less false-negatives for packet passing through an interface, should reduce packet loss, at the cost of potentially flapping the interfaces (bringing down a path often if MII status is bad or slow to be returned)). Users who require the old behavior may add "s" at the end of the value to make it read as "1 second" again, or modify the value to be "1000", which will be 1000ms (1 second). We estimate the impact of this change to users to be minimal, actually requiring a 1 second interval for MII monitoring / up/down delay, and ARP interval is very uncommon and counter-intuitive as all other systems work on a millisecond basis.

---

The manpage for netplan doesn't indicate what the unit for mii-monitor-interval is on bond devices. It appears to be in whole seconds, but at the kernel level, the unit is milliseconds.

From my testing, it appears to be impossible to set a value for mii-monitor-interval with netplan that is <1s (e.g. I got a syntax error with a value of 0.1 for 100ms)

Related branches

Ryan Harper (raharper) wrote :

The systemd documentation is somewhat confusing here as well.

MIIMonitorSec=
Specifies the frequency that Media Independent Interface link monitoring will occur. A value of zero disables MII link monitoring. This value is rounded down to the nearest millisecond. The default value is 0.

Netplan currently just passes this value to networkd via the configuration file.

At it turns out, systemd-networkd will allow the values to have suffixes, like 'ms':
So to achieve the 100ms interval you need to put in '100ms' in the value.

root@ubuntu:~# cat /etc/systemd/network/test-bond2-miimon.netdev
[NetDev]
Name=bond2
Kind=bond

[Bond]
Mode=active-backup
MIIMonitorSec=100ms
root@ubuntu:~# cat /sys/class/net/bond2/bonding/miimon
100

This means netplan will need an update to address this. If we attempt to read a netplan yaml using the suffix, then it fails to parse.

# netplan generate
Error in network definition //etc/netplan/50-cloud-init.yaml line 19 column 34: invalid unsigned int value 100ms

An easy path is to update the documentation to accept the value in milliseconds (like NetworkManager) and then when rendering networkd.netdev files, to append the 'ms' suffix.

Changed in netplan:
status: New → Confirmed

This one is going to be a little more involved, to support having values with an unit will require fixing up the parser to be able to unravel that string.

Using just milliseconds and passing that to systemd would be simpler, but I'm open to either way.

Changed in netplan:
status: Confirmed → Triaged
importance: Undecided → High
assignee: nobody → Mathieu Trudel-Lapierre (cyphermox)
Chris Jones (cmsj) wrote :

Might it be easier to keep the netplan value as a number, and switch it to a float, then hand that off to networkd in a form it understands?

tags: added: id-5acf94da4fdc30917ec9c571
Changed in netplan:
status: Triaged → In Progress

netplan.io (0.36) bionic; urgency=medium

  * 'netplan try': properly reset terminal flags at the end of the command,
    so that terminal behaves the same after as before it was run.
    (LP: #1766283)
  * Fix default behavior for unspecified time values in bond parameters: if
    no time-value suffix such as 'ms' is added, consider the value to be in
    milliseconds for MII monitor interval, up/down delay and ARP interval
    so users can have the expected additional granularity when setting up
    these parameters. (LP: #1765833)

Changed in nplan (Ubuntu):
status: New → Fix Released
Changed in netplan:
status: In Progress → Fix Released
description: updated

Hello Chris, or anyone else affected,

Accepted nplan into artful-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/nplan/0.32~17.10.4 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed.Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested and change the tag from verification-needed-artful to verification-done-artful. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-artful. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in nplan (Ubuntu Artful):
status: New → Fix Committed
tags: added: verification-needed verification-needed-artful
Brian Murray (brian-murray) wrote :

Hello Chris, or anyone else affected,

Accepted nplan into xenial-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/nplan/0.32~16.04.5 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed.Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested and change the tag from verification-needed-xenial to verification-done-xenial. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-xenial. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in nplan (Ubuntu Xenial):
status: New → Fix Committed
tags: added: verification-needed-xenial

Verification-done on artful: nplan 0.32~17.10.4

Setting mii-monitor-interval to "5" indeed leads to miimon value of 5 (rather than 5000 as previously), as expected:

ubuntu@DellVostroV130:~$ cat /sys/class/net/bond0/bonding/miimon
5
ubuntu@DellVostroV130:~$ cat /etc/netplan/bond.yaml
network:
    version: 2
    bonds:
        bond0:
            interfaces: [ asix, enp19s0 ]
            addresses:
            - 10.3.99.14/24
            parameters:
                mode: balance-alb
                mii-monitor-interval: 5
            gateway4: 10.3.99.1
            mtu: 1500
            nameservers:
                addresses:
                - 10.3.99.25

tags: added: verification-done-artful
removed: verification-needed-artful

Verification-done on xenial: nplan 0.32~16.04.5
Verification-done on artful: nplan 0.32~17.10.4

With the updated nplan; the mii-monitor-interval set in configuration is correctly applied to the device as expected, and is processed as milliseconds or seconds, as appropriate to the config:

676 --> 676
676ms --> 676
1s --> 1000

ubuntu@warm-sole:~$ cat /sys/class/net/bond0/bonding/miimon
1000
ubuntu@warm-sole:~$ cat /etc/netplan/50-cloud-init.yaml
# This file is generated from information provided by
# the datasource. Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    version: 2
    ethernets:
        ens6:
            match:
                macaddress: 52:54:00:5c:36:55
            mtu: 1500
            set-name: ens6
        ens7:
            match:
                macaddress: 52:54:00:ca:e3:8e
            mtu: 1500
            set-name: ens7
    bonds:
        bond0:
            interfaces: [ ens6, ens7 ]
            addresses:
            - 10.3.99.17/24
            gateway4: 10.3.99.1
            parameters:
                mii-monitor-interval: 1s

tags: added: verification-done-xenial
removed: verification-needed verification-needed-xenial
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers