]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
ethtool: Make sure advertise is actually set when autonegotiation is used
authorJan Janssen <medhefgo@web.de>
Tue, 15 Jan 2019 14:46:32 +0000 (15:46 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 17 Jan 2019 08:15:09 +0000 (09:15 +0100)
man/systemd.link.xml
src/udev/net/ethtool-util.c

index f74edd0186b4797eabb5c2fe87079b3aefc3e369..ec0314dec3f8dc89f262797aceeb6026221a0895 100644 (file)
           common transmission parameters, such as speed, duplex mode, and flow control.
           When unset, the kernel's default will be used.</para>
 
-          <para>Note that if autonegotiation is enabled, speed, duplex and advertise settings are
-          read-only. If autonegotation is disabled, speed, duplex and advertise settings are writable
+          <para>Note that if autonegotiation is enabled, speed and duplex settings are
+          read-only. If autonegotation is disabled, speed and duplex settings are writable
           if the driver supports multiple link modes.</para>
         </listitem>
       </varlistentry>
         <term><varname>Advertise=</varname></term>
         <listitem>
           <para>This sets what speeds and duplex modes of operation are advertised for auto-negotiation.
-          The supported values are:
+          This implies <literal>AutoNegotiation=yes</literal>. The supported values are:
 
           <table>
             <title>Supported advertise values</title>
index a1eb6902aac73bc4efd3fb68b12ba9b5078b65b7..0dcec03f6703302ec4de8094af8ed1fb68354507 100644 (file)
@@ -583,7 +583,7 @@ int ethtool_set_glinksettings(int *fd, const char *ifname, struct link_config *l
         struct ifreq ifr = {};
         int r;
 
-        if (link->autonegotiation != 0) {
+        if (link->autonegotiation != AUTONEG_DISABLE && eqzero(link->advertise)) {
                 log_info("link_config: autonegotiation is unset or enabled, the speed and duplex are not writable.");
                 return 0;
         }
@@ -612,9 +612,11 @@ int ethtool_set_glinksettings(int *fd, const char *ifname, struct link_config *l
         if (link->port != _NET_DEV_PORT_INVALID)
                 u->base.port = link->port;
 
-        u->base.autoneg = link->autonegotiation;
+        if (link->autonegotiation >= 0)
+                u->base.autoneg = link->autonegotiation;
 
         if (!eqzero(link->advertise)) {
+                u->base.autoneg = AUTONEG_ENABLE;
                 memcpy(&u->link_modes.advertising, link->advertise, sizeof(link->advertise));
                 memzero((uint8_t*) &u->link_modes.advertising + sizeof(link->advertise),
                         ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NBYTES - sizeof(link->advertise));