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

Bug #1745597 reported by Chris Jones
14
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Netplan
Fix Released
High
Mathieu Trudel-Lapierre
nplan (Ubuntu)
Fix Released
Undecided
Unassigned
Xenial
Fix Released
Undecided
Unassigned
Artful
Fix Released
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

Revision history for this message
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
Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

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)
Revision history for this message
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
Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

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
Revision history for this message
Brian Murray (brian-murray) wrote : Please test proposed package

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
Revision history for this message
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
Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

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
Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

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
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package nplan - 0.32~17.10.4

---------------
nplan (0.32~17.10.4) artful; urgency=medium

  * bond/bridge: Support suffixes for time-based values so things like
    "mii-monitor-interval" can support milliseconds. (LP: #1745597)
  * debian/postinst: Write breadcrumbs on disk in /etc/network/interfaces to
    denote the migration to using netplan. (LP: #1756742)
  * DHCPv4: add a "dhcp-identifier: mac" field that can be set to fix interop
    with Windows Server-based DHCP servers which don't support RFC 4361.
    (LP: #1738998)
  * IPv6: accept-ra should default to being unset, so that the kernel default
    can be used. (LP: #1732002)
  * doc/netplan.md: Clarify the behavior for time-based values for bonds
    and bridges. (LP: #1756587)
  * critical: provide a way to set "CriticalConnection=true" on a networkd
    connection, especially for remote-fs scenarios. (LP: #1769682)
  * networkd: don't wipe out /run/netplan on generate: we do want to keep any
    YAML configurations in that directory, we just need to remove generated
    wpasupplicant configs. (LP: #1764869)

 -- Mathieu Trudel-Lapierre <email address hidden> Tue, 08 May 2018 11:04:30 -0400

Changed in nplan (Ubuntu Artful):
status: Fix Committed → Fix Released
Revision history for this message
Chris Halse Rogers (raof) wrote : Update Released

The verification of the Stable Release Update for nplan has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package nplan - 0.32~16.04.5

---------------
nplan (0.32~16.04.5) xenial; urgency=medium

  * bond/bridge: Support suffixes for time-based values so things like
    "mii-monitor-interval" can support milliseconds. (LP: #1745597)
  * Do not attempt to rebind driver 'qeth'. (LP: #1756322)
  * Allow setting ClientIdentifier=mac for networkd-renderered devices
    (LP: #1738998)
  * IPv6: accept-ra should default to being unset, so that the kernel default
    can be used. (LP: #1732002)
  * doc/netplan.md: Clarify the behavior for time-based values for bonds
    and bridges. (LP: #1756587)
  * critical: provide a way to set "CriticalConnection=true" on a networkd
    connection, especially for remote-fs scenarios. (LP: #1769682)
  * networkd: don't wipe out /run/netplan on generate: we do want to keep any
    YAML configurations in that directory, we just need to remove generated
    wpasupplicant configs. (LP: #1764869)

 -- Mathieu Trudel-Lapierre <email address hidden> Tue, 08 May 2018 10:36:24 -0400

Changed in nplan (Ubuntu Xenial):
status: Fix Committed → Fix Released
Revision history for this message
Mark Shuttleworth (sabdfl) wrote :

Hi folks

Thanks for working on this. However, I think it unwise to change the units of the unqualified number in an SRU. That would mean that people who adjusted to "1" (second) as I did would suddenly find themselves at 1ms.

Rather, I suggest:

 * keep the unqualified number as seconds
 * document that very clearly! neither the man page nor the website gets this right
 * also document the ability to specify qualifiers such as ms
 * also document a recommended value (100ms?) and explain the rationale for a higher or lower number

In my case I have seen very bad consequences from wide swings in this setting. Going from 1 per second to 1000 per second will be very poorly received, so I urge you not to push this change into -updates and in fact to pull it from -proposed.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.