[systemd-devel] Trouble with speed/mode in .link files - RESOLVED/PATCH

Bruce A. Johnson bjohnson at blueridgenetworks.com
Wed Jan 3 20:32:39 UTC 2018


My problem seems to be a bug in ethtool-util.c's set_slinksettings().
The base parameters were not being copied into the ethtool_link_settings
request, so they were all zero and ioctl didn't like that.  I've pasted
the patch below.  Please let me know if there is anything else I need to
do to get this to the right person.

Thanks!
--
Bruce A Johnson
Chantilly, Virginia

diff --git a/src/udev/net/ethtool-util.c b/src/udev/net/ethtool-util.c
index 201fc23..a16ea07 100644
--- a/src/udev/net/ethtool-util.c
+++ b/src/udev/net/ethtool-util.c
@@ -436,15 +436,16 @@ static int set_slinksettings(int *fd, struct ifreq *ifr, const struct ethtool_li
         struct {
                 struct ethtool_link_settings req;
                 __u32 link_mode_data[3 * ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32];
-        } ecmd = {
-                .req.cmd = ETHTOOL_SLINKSETTINGS,
-        };
+        } ecmd;
         unsigned int offset;
         int r;
 
         if (u->base.cmd != ETHTOOL_GLINKSETTINGS || u->base.link_mode_masks_nwords <= 0)
                 return -EINVAL;
 
+        memset(&ecmd, sizeof(ecmd), 0);
+        memcpy(&ecmd.req, &u->base, sizeof(ecmd.req));
+        ecmd.req.cmd = ETHTOOL_SLINKSETTINGS;
         offset = 0;
         memcpy(&ecmd.link_mode_data[offset], u->link_modes.supported, 4 * ecmd.req.link_mode_masks_nwords);




More information about the systemd-devel mailing list