Hi there,

I seem to have come across a couple of issues with udevd v219's
configuration of Ethernet link-level parameters specified in .link
files, in particular the speed and duplex settings.  Firstly, the speed
and duplex ioctl() call is succeeding but without any changes taking
effect on the interface.  Secondly, the Duplex parameter of the .link
file does not appear to be parsed correctly; the duplex value presented
to link_apply_config() is not the value specified in the .link file
while the speed value is.


With the attached .link file specifying a speed of 100M, half duplex,
and MAC address of 52:54:00:77:77:77, I get the following after boot:

root@qemux86-64:~# ethtool eth0
Settings for eth0:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Supported pause frame use: No
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Advertised pause frame use: No
        Advertised auto-negotiation: Yes
        Speed: 1000Mb/s
        Duplex: Full
        Port: Twisted Pair
        PHYAD: 0
        Transceiver: internal
        Auto-negotiation: on
        MDI-X: off (auto)
        Supports Wake-on: umbg
        Wake-on: d
        Current message level: 0x00000007 (7)
                               drv probe link
        Link detected: yes
root@qemux86-64:~# journalctl -b -u systemd-udevd.service
-- Logs begin at Tue 2015-07-21 13:08:03 UTC, end at Tue 2015-07-21 13:08:21 
UTC. --
Jul 21 13:08:04 qemux86-64 systemd[1]: Starting udev Kernel Device Manager...
Jul 21 13:08:04 qemux86-64 systemd-udevd[91]: starting version 219
Jul 21 13:08:05 qemux86-64 systemd[1]: Started udev Kernel Device Manager.
Jul 21 13:08:05 qemux86-64 systemd-udevd[108]: failed to execute 
'/lib/systemd/systemd-vconsole-setup' '/lib/systemd/systemd-vconsole-setup': No 
such file or directory
Jul 21 13:08:06 qemux86-64 systemd-udevd[98]: Failed to apply ACL on 
/dev/sequencer: Operation not supported
Jul 21 13:08:06 qemux86-64 systemd-udevd[98]: Failed to apply ACL on 
/dev/sequencer2: Operation not supported
Jul 21 13:08:06 qemux86-64 systemd-udevd[99]: Failed to apply ACL on 
/dev/snd/timer: Operation not supported
Jul 21 13:08:06 qemux86-64 systemd-udevd[96]: Failed to apply ACL on 
/dev/snd/seq: Operation not supported
Jul 21 13:08:08 qemux86-64 systemd-udevd[130]: failed to execute 
'/lib/systemd/systemd-vconsole-setup' '/lib/systemd/systemd-vconsole-setup': No 
such file or directory
Jul 21 13:08:08 qemux86-64 systemd-udevd[129]: failed to execute 
'/lib/systemd/systemd-vconsole-setup' '/lib/systemd/systemd-vconsole-setup': No 
such file or directory
root@qemux86-64:~# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 52:54:00:77:77:77  
...


but with the attached patch, which adds a system() call to execute the
ethtool program using the specified parameters, I get advertised link
modes different from above:


root@qemux86-64:~# ethtool eth0
Settings for eth0:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full 
                                100baseT/Half 100baseT/Full 
                                1000baseT/Full 
        Supported pause frame use: No
        Supports auto-negotiation: Yes
        Advertised link modes:  100baseT/Full 
        Advertised pause frame use: No
        Advertised auto-negotiation: Yes
        Speed: 1000Mb/s
        Duplex: Full
        Port: Twisted Pair
        PHYAD: 0
        Transceiver: internal
        Auto-negotiation: on
        MDI-X: off (auto)
        Supports Wake-on: umbg
        Wake-on: d
        Current message level: 0x00000007 (7)
                               drv probe link
        Link detected: yes
root@qemux86-64:~# journalctl -b -u systemd-udevd.service
-- Logs begin at Tue 2015-07-21 12:42:35 UTC, end at Tue 2015-07-21 12:43:00 
UTC. --
Jul 21 12:42:36 qemux86-64 systemd[1]: Starting udev Kernel Device Manager...
Jul 21 12:42:37 qemux86-64 systemd-udevd[91]: starting version 219
Jul 21 12:42:37 qemux86-64 systemd[1]: Started udev Kernel Device Manager.
Jul 21 12:42:37 qemux86-64 systemd-udevd[104]: failed to execute 
'/lib/systemd/systemd-vconsole-setup' '/lib/systemd/systemd-vconsole-setup': No 
such file or directory
Jul 21 12:42:38 qemux86-64 systemd-udevd[101]: Setting link eth0 speed to 97656 
Mbps, duplex: full
Jul 21 12:42:38 qemux86-64 systemd-udevd[101]: Successfully set link eth0 speed 
to 97656 Mbps (raw: 100000000), duplex: full
Jul 21 12:42:38 qemux86-64 systemd-udevd[102]: Failed to apply ACL on 
/dev/sequencer: Operation not supported
Jul 21 12:42:38 qemux86-64 systemd-udevd[99]: Failed to apply ACL on 
/dev/snd/seq: Operation not supported
Jul 21 12:42:38 qemux86-64 systemd-udevd[98]: Setting link sit0 speed to 0 
Mbps, duplex: (null)
Jul 21 12:42:38 qemux86-64 systemd-udevd[98]: Successfully set link sit0 speed 
to 0 Mbps (raw: 0), duplex: (null)
Jul 21 12:42:38 qemux86-64 systemd-udevd[103]: Failed to apply ACL on 
/dev/snd/timer: Operation not supported
Jul 21 12:42:38 qemux86-64 systemd-udevd[99]: Failed to apply ACL on 
/dev/sequencer2: Operation not supported
Jul 21 12:42:38 qemux86-64 systemd-udevd[97]: Setting link lo speed to 0 Mbps, 
duplex: (null)
Jul 21 12:42:38 qemux86-64 systemd-udevd[97]: Successfully set link lo speed to 
0 Mbps (raw: 0), duplex: (null)
Jul 21 12:42:39 qemux86-64 systemd-udevd[101]: Return code 0 from execution of 
ethtool: `ethtool --change eth0 speed 100 duplex full >/dev/console 2>&1'
root@qemux86-64:~# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 52:54:00:77:77:77
...


-- 
Bob Ham <bob....@collabora.com>
Software Engineer

>>>>>>>>
Open First 
Collabora is hiring!
Please check out our latest opportunities here:
http://bit.ly/Collabora-Careers
<<<<<<<<

[Match]
Path=pci-0000:00:03.0

[Link]
Duplex=half
BitsPerSecond=100M
MACAddress=52:54:00:77:77:77
diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c
index 8b3dc45..a524acc 100644
--- a/src/udev/net/link-config.c
+++ b/src/udev/net/link-config.c
@@ -379,12 +379,31 @@ int link_config_apply(link_config_ctx *ctx, link_config *config,
         if (!old_name)
                 return -EINVAL;
 
+        log_warning("Setting link %s speed to %u Mbps, duplex: %s", old_name,
+                    config->speed / 1024, duplex_to_string(config->duplex));
         r = ethtool_set_speed(&ctx->ethtool_fd, old_name, config->speed / 1024,
                               config->duplex);
         if (r < 0)
                 log_warning_errno(r, "Could not set speed or duplex of %s to %u Mbps (%s): %m",
                                   old_name, config->speed / 1024,
                                   duplex_to_string(config->duplex));
+        else {
+                log_warning("Successfully set link %s speed to %u Mbps (raw: %u), duplex: %s",
+                            old_name, config->speed / 1024, config->speed,
+                            duplex_to_string(config->duplex));
+                if (config->speed != 0) {
+                        char command[1024];
+                        int e;
+
+                        sprintf(command, "ethtool --change %s speed %u duplex %s"
+                                " >/dev/console 2>&1", old_name, config->speed / 1000000,
+                                duplex_to_string(config->duplex));
+
+                        e = system(command);
+                        log_warning("Return code %d from execution of ethtool: `%s'", e, command);
+                }
+        }
+
 
         r = ethtool_set_wol(&ctx->ethtool_fd, old_name, config->wol);
         if (r < 0)
_______________________________________________
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel

Reply via email to