Merge ~raharper/netplan:fix/interval-sec into ~netplan-developers/netplan/+git/netplan:master

Proposed by Ryan Harper
Status: Merged
Merge reported by: Mathieu Trudel-Lapierre
Merged at revision: 243e4bbecb7e9c7538d95348443064a8320e30be
Proposed branch: ~raharper/netplan:fix/interval-sec
Merge into: ~netplan-developers/netplan/+git/netplan:master
Diff against target: 233 lines (+46/-49)
3 files modified
doc/netplan.md (+28/-31)
src/networkd.c (+9/-9)
tests/generate.py (+9/-9)
Reviewer Review Type Date Requested Status
Mathieu Trudel-Lapierre (community) Needs Information
Review via email: mp+336717@code.launchpad.net

Description of the change

Update docs and netplan to use milliseconds for time-based intervals

While networkd does accept time values for bonds and bridges at the 1 second
granularity, it also allows users to apply a suffix, such as 'ms' to indicate
the unit. netplan already documents that these time values are milliseconds for
the NetworkManager renderer, so this patch updates documentation to indicate
that all of the time values are now in millisecond form. The networkd renderer
is updated to append 'ms' to the interger value that's parsed.

LP: #1745597

To post a comment you must log in.
Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

I'm worried about breaking stuff for those who already use these parameters, so that would be one argument /for/ parsing using strings with time units.

On the other hand, the current behavior is quite limited in the systemd backend using only seconds.

review: Needs Information
Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

Closing, this got merged with changes on github...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/doc/netplan.md b/doc/netplan.md
2index 7f37ae1..afe9fcc 100644
3--- a/doc/netplan.md
4+++ b/doc/netplan.md
5@@ -247,10 +247,9 @@ Properties for device type ``bridges:``
6
7 ``parameters`` (mapping)
8
9-: Customization parameters for special bridging options. Using the
10- NetworkManager renderer, parameter values for time intervals should be
11- expressed in milliseconds; for the systemd renderer, they should be in
12- seconds unless otherwise specified.
13+: Customization parameters for special bridging options.
14+ Time-based values for intervals should be expressed in milliseconds
15+ unless otherwise specified.
16
17 ``ageing-time`` (scalar)
18 : Set the period of time to keep a MAC address in the forwarding
19@@ -268,20 +267,18 @@ Properties for device type ``bridges:``
20 designated port and root port selection algorithms.
21
22 ``forward-delay`` (scalar)
23- : Specify the period of time the bridge will remain in Listening and
24- Learning states before getting to the Forwarding state. This value
25- should be set in seconds for the systemd backend, and in milliseconds
26- for the NetworkManager backend.
27+ : Specify the period of time (milliseconds) the bridge will remain in
28+ Listening and Learning states before getting to the Forwarding state.
29
30 ``hello-time`` (scalar)
31- : Specify the interval between two hello packets being sent out from
32- the root and designated bridges. Hello packets communicate
33- information about the network topology.
34+ : Specify the interval (milliseconds) between two hello packets being
35+ sent out from the root and designated bridges. Hello packets
36+ communicate information about the network topology.
37
38 ``max-age`` (scalar)
39- : Set the maximum age of a hello packet. If the last hello packet is
40- older than that value, the bridge will attempt to become the root
41- bridge.
42+ : Set the maximum age (millliseconds) of a hello packet. If the last
43+ hello packet is older than that value, the bridge will attempt to
44+ become the root bridge.
45
46 ``path-cost`` (scalar)
47 : Set the cost of a path on the bridge. Faster interfaces should have
48@@ -313,10 +310,9 @@ Properties for device type ``bonds:``
49
50 ``parameters`` (mapping)
51
52-: Customization parameters for special bonding options. Using the
53- NetworkManager renderer, parameter values for intervals should be
54- expressed in milliseconds; for the systemd renderer, they should be in
55- seconds unless otherwise specified.
56+: Customization parameters for special bonding options.
57+ Time-based values for intervals should be expressed in milliseconds
58+ unless otherwise specified.
59
60 ``mode`` (scalar)
61 : Set the bonding mode used for the interfaces. The default is
62@@ -330,9 +326,9 @@ Properties for device type ``bonds:``
63 and ``fast`` (every second).
64
65 ``mii-monitor-interval`` (scalar)
66- : Specifies the interval for MII monitoring (verifying if an interface
67- of the bond has carrier). The default is ``0``; which disables MII
68- monitoring.
69+ : Specifies the interval (milliseconds) for MII monitoring (verifying
70+ if an interface of the bond has carrier). The default is ``0``; which
71+ disables MII monitoring.
72
73 ``min-links`` (scalar)
74 : The minimum number of links up in a bond to consider the bond
75@@ -356,8 +352,9 @@ Properties for device type ``bonds:``
76 behavior in most situations.
77
78 ``arp-interval`` (scalar)
79- : Set the interval value for how frequently ARP link monitoring should
80- happen. The default value is ``0``, which disables ARP monitoring.
81+ : Set the interval value (milliseconds) for how frequently ARP link
82+ monitoring should happen. The default value is ``0``, which disables
83+ ARP monitoring.
84
85 ``arp-ip-targets`` (sequence of scalars)
86 : IPs of other hosts on the link which should be sent ARP requests in
87@@ -379,12 +376,12 @@ Properties for device type ``bonds:``
88 enabled. Possible values are ``any`` and ``all``.
89
90 ``up-delay`` (scalar)
91- : Specify the delay before enabling a link once the link is physically
92- up. The default value is ``0``.
93+ : Specify the delay (milliseconds) before enabling a link once the link
94+ is physically up. The default value is ``0``.
95
96 ``down-delay`` (scalar)
97- : Specify the delay before disabling a link once the link has been
98- lost. The default value is ``0``.
99+ : Specify the delay (milliseconds) before disabling a link once the
100+ link has been lost. The default value is ``0``.
101
102 ``fail-over-mac-policy`` (scalar)
103 : Set whether to set all slaves to the same MAC address when adding
104@@ -412,10 +409,10 @@ Properties for device type ``bonds:``
105 possible values are ``always``, ``better``, and ``failure``.
106
107 ``learn-packet-interval`` (scalar)
108- : Specify the interval between sending learning packets to each slave.
109- The value range is between ``1`` and ``0x7fffffff``. The default
110- value is ``1``. This option only affects ``balance-tlb`` and
111- ``balance-alb`` modes.
112+ : Specify the interval (milliseconds) between sending learning packets
113+ to each slave. The value range is between ``1`` and ``0x7fffffff``.
114+ The default value is ``1``. This option only affects ``balance-tlb``
115+ and ``balance-alb`` modes.
116
117 ``primary`` (scalar)
118 : Specify a device to be used as a primary slave, or preferred device
119diff --git a/src/networkd.c b/src/networkd.c
120index f29f2db..7164c39 100644
121--- a/src/networkd.c
122+++ b/src/networkd.c
123@@ -65,7 +65,7 @@ write_bridge_params(GString* s, net_definition* def)
124 params = g_string_sized_new(200);
125
126 if (def->bridge_params.ageing_time)
127- g_string_append_printf(params, "AgeingTimeSec=%u\n", def->bridge_params.ageing_time);
128+ g_string_append_printf(params, "AgeingTimeSec=%ums\n", def->bridge_params.ageing_time);
129 #if 0
130 /* FIXME: Priority= is not valid for the bridge itself, although it should work as the
131 * STP priority of the bridge itself. It's not supported by networkd, but let's
132@@ -75,11 +75,11 @@ write_bridge_params(GString* s, net_definition* def)
133 g_string_append_printf(params, "Priority=%u\n", def->bridge_params.priority);
134 #endif
135 if (def->bridge_params.forward_delay)
136- g_string_append_printf(params, "ForwardDelaySec=%u\n", def->bridge_params.forward_delay);
137+ g_string_append_printf(params, "ForwardDelaySec=%ums\n", def->bridge_params.forward_delay);
138 if (def->bridge_params.hello_time)
139- g_string_append_printf(params, "HelloTimeSec=%u\n", def->bridge_params.hello_time);
140+ g_string_append_printf(params, "HelloTimeSec=%ums\n", def->bridge_params.hello_time);
141 if (def->bridge_params.max_age)
142- g_string_append_printf(params, "MaxAgeSec=%u\n", def->bridge_params.max_age);
143+ g_string_append_printf(params, "MaxAgeSec=%ums\n", def->bridge_params.max_age);
144 g_string_append_printf(params, "STP=%s\n", def->bridge_params.stp ? "true" : "false");
145
146 g_string_append_printf(s, "\n[Bridge]\n%s", params->str);
147@@ -131,7 +131,7 @@ write_bond_parameters(net_definition* def, GString* s)
148 if (def->bond_params.lacp_rate)
149 g_string_append_printf(params, "\nLACPTransmitRate=%s", def->bond_params.lacp_rate);
150 if (def->bond_params.monitor_interval)
151- g_string_append_printf(params, "\nMIIMonitorSec=%d", def->bond_params.monitor_interval);
152+ g_string_append_printf(params, "\nMIIMonitorSec=%dms", def->bond_params.monitor_interval);
153 if (def->bond_params.min_links)
154 g_string_append_printf(params, "\nMinLinks=%d", def->bond_params.min_links);
155 if (def->bond_params.transmit_hash_policy)
156@@ -141,7 +141,7 @@ write_bond_parameters(net_definition* def, GString* s)
157 if (def->bond_params.all_slaves_active)
158 g_string_append_printf(params, "\nAllSlavesActive=%d", def->bond_params.all_slaves_active);
159 if (def->bond_params.arp_interval)
160- g_string_append_printf(params, "\nARPIntervalSec=%d", def->bond_params.arp_interval);
161+ g_string_append_printf(params, "\nARPIntervalSec=%dms", def->bond_params.arp_interval);
162 if (def->bond_params.arp_ip_targets && def->bond_params.arp_ip_targets->len > 0) {
163 g_string_append_printf(params, "\nARPIPTargets=");
164 for (unsigned i = 0; i < def->bond_params.arp_ip_targets->len; ++i) {
165@@ -155,9 +155,9 @@ write_bond_parameters(net_definition* def, GString* s)
166 if (def->bond_params.arp_all_targets)
167 g_string_append_printf(params, "\nARPAllTargets=%s", def->bond_params.arp_all_targets);
168 if (def->bond_params.up_delay)
169- g_string_append_printf(params, "\nUpDelaySec=%d", def->bond_params.up_delay);
170+ g_string_append_printf(params, "\nUpDelaySec=%dms", def->bond_params.up_delay);
171 if (def->bond_params.down_delay)
172- g_string_append_printf(params, "\nDownDelaySec=%d", def->bond_params.down_delay);
173+ g_string_append_printf(params, "\nDownDelaySec=%dms", def->bond_params.down_delay);
174 if (def->bond_params.fail_over_mac_policy)
175 g_string_append_printf(params, "\nFailOverMACPolicy=%s", def->bond_params.fail_over_mac_policy);
176 if (def->bond_params.gratuitious_arp)
177@@ -170,7 +170,7 @@ write_bond_parameters(net_definition* def, GString* s)
178 if (def->bond_params.resend_igmp)
179 g_string_append_printf(params, "\nResendIGMP=%d", def->bond_params.resend_igmp);
180 if (def->bond_params.learn_interval)
181- g_string_append_printf(params, "\nLearnPacketIntervalSec=%d", def->bond_params.learn_interval);
182+ g_string_append_printf(params, "\nLearnPacketIntervalSec=%dms", def->bond_params.learn_interval);
183
184 if (params->len)
185 g_string_append_printf(s, "\n[Bond]%s\n", params->str);
186diff --git a/tests/generate.py b/tests/generate.py
187index 95abae2..572b978 100755
188--- a/tests/generate.py
189+++ b/tests/generate.py
190@@ -981,10 +981,10 @@ unmanaged-devices+=interface-name:eth42,interface-name:eth43,interface-name:mybr
191 dhcp4: true''')
192
193 self.assert_networkd({'br0.netdev': '[NetDev]\nName=br0\nKind=bridge\n\n'
194- '[Bridge]\nAgeingTimeSec=50\n'
195- 'ForwardDelaySec=12\n'
196- 'HelloTimeSec=6\n'
197- 'MaxAgeSec=24\n'
198+ '[Bridge]\nAgeingTimeSec=50ms\n'
199+ 'ForwardDelaySec=12ms\n'
200+ 'HelloTimeSec=6ms\n'
201+ 'MaxAgeSec=24ms\n'
202 'STP=true\n',
203 'br0.network': ND_DHCP4 % 'br0',
204 'eno1.network': '[Match]\nName=eno1\n\n'
205@@ -1087,23 +1087,23 @@ unmanaged-devices+=interface-name:bn0,''')
206 '[Bond]\n'
207 'Mode=802.1ad\n'
208 'LACPTransmitRate=10\n'
209- 'MIIMonitorSec=10\n'
210+ 'MIIMonitorSec=10ms\n'
211 'MinLinks=10\n'
212 'TransmitHashPolicy=none\n'
213 'AdSelect=none\n'
214 'AllSlavesActive=1\n'
215- 'ARPIntervalSec=10\n'
216+ 'ARPIntervalSec=10ms\n'
217 'ARPIPTargets=10.10.10.10,20.20.20.20\n'
218 'ARPValidate=all\n'
219 'ARPAllTargets=all\n'
220- 'UpDelaySec=10\n'
221- 'DownDelaySec=10\n'
222+ 'UpDelaySec=10ms\n'
223+ 'DownDelaySec=10ms\n'
224 'FailOverMACPolicy=none\n'
225 'GratuitiousARP=10\n'
226 'PacketsPerSlave=10\n'
227 'PrimaryReselectPolicy=none\n'
228 'ResendIGMP=10\n'
229- 'LearnPacketIntervalSec=10\n',
230+ 'LearnPacketIntervalSec=10ms\n',
231 'bn0.network': ND_DHCP4 % 'bn0',
232 'eno1.network': '[Match]\nName=eno1\n\n'
233 '[Network]\nBond=bn0\nLinkLocalAddressing=no\nIPv6AcceptRA=no\n',

Subscribers

People subscribed via source and target branches