chiark / gitweb /
udev: net - allow MTU and Speed to be specified with units
authorTom Gundersen <teg@jklm.no>
Sat, 22 Feb 2014 17:23:19 +0000 (18:23 +0100)
committerTom Gundersen <teg@jklm.no>
Sat, 22 Feb 2014 17:29:43 +0000 (18:29 +0100)
This also changes the names to MTUBytes and BitsPerSecond, respectively. Notice
that the speed was mistakenly documented to be in bytes before this change.

man/udev.xml
src/udev/net/link-config-gperf.gperf
src/udev/net/link-config.c

index ae7dc61b03ec5c3cd57cf8b531e1d4230e362f3a..9733b85760569a429455c4ea672d9b38cf44ffc1 100644 (file)
           </listitem>
         </varlistentry>
         <varlistentry>
-          <term><varname>MTU=</varname></term>
+          <term><varname>MTUBytes=</varname></term>
           <listitem>
-            <para>The MTU to set for the device.</para>
+            <para>The maximum transmission unit in bytes to set for the device.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
-          <term><varname>SpeedMBytes=</varname></term>
+          <term><varname>BitsPerSecond=</varname></term>
           <listitem>
-            <para>The speed to set for the device.</para>
+            <para>The speed to set for the device, the value is rounded down
+            to the nearest Mbps.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
index 277ceb538620595206958dd6d6921f46aff89128..3384ca0418b3e22229c6049158ce75c85f179b0b 100644 (file)
@@ -30,7 +30,7 @@ Link.MACAddress,           config_parse_hwaddr,        0,
 Link.NamePolicy,           config_parse_name_policy,   0,                             offsetof(link_config, name_policy)
 Link.Name,                 config_parse_ifname,        0,                             offsetof(link_config, name)
 Link.Alias,                config_parse_ifalias,       0,                             offsetof(link_config, alias)
-Link.MTU,                  config_parse_unsigned,      0,                             offsetof(link_config, mtu)
-Link.SpeedMBytes,          config_parse_unsigned,      0,                             offsetof(link_config, speed)
+Link.MTUBytes,             config_parse_bytes_size,    0,                             offsetof(link_config, mtu)
+Link.BitsPerSecond,        config_parse_bytes_size,    0,                             offsetof(link_config, speed)
 Link.Duplex,               config_parse_duplex,        0,                             offsetof(link_config, duplex)
 Link.WakeOnLan,            config_parse_wol,           0,                             offsetof(link_config, wol)
index 92d248fc6b2b714b6c16bbaa72c5083ad0049bf4..05225e011175f1f2768449e751da6b9100d58c6a 100644 (file)
@@ -365,10 +365,11 @@ int link_config_apply(link_config_ctx *ctx, link_config *config, struct udev_dev
         if (!old_name)
                 return -EINVAL;
 
-        r = ethtool_set_speed(ctx->ethtool_fd, old_name, config->speed, config->duplex);
+        r = ethtool_set_speed(ctx->ethtool_fd, old_name, config->speed / 1024, config->duplex);
         if (r < 0)
-                log_warning("Could not set speed or duplex of %s to %u Mbytes (%s): %s",
-                             old_name, config->speed, duplex_to_string(config->duplex), strerror(-r));
+                log_warning("Could not set speed or duplex of %s to %u Mbps (%s): %s",
+                            old_name, config->speed / 1024, duplex_to_string(config->duplex),
+                            strerror(-r));
 
         r = ethtool_set_wol(ctx->ethtool_fd, old_name, config->wol);
         if (r < 0)