Merge ~morphis/snappy-hwe-snaps/+git/network-manager:global-wol-config into ~snappy-hwe-team/snappy-hwe-snaps/+git/network-manager:master

Proposed by Simon Fels
Status: Merged
Approved by: Alfonso Sanchez-Beato
Approved revision: b549a36d29695c00e10213e4b2a4926e7376110a
Merged at revision: 0d73fadaa39fe9f1de4a80f73ddca604a3cf08b3
Proposed branch: ~morphis/snappy-hwe-snaps/+git/network-manager:global-wol-config
Merge into: ~snappy-hwe-team/snappy-hwe-snaps/+git/network-manager:master
Diff against target: 114 lines (+80/-0)
4 files modified
bin/networkmanager (+7/-0)
snapcraft.yaml (+1/-0)
startup-hooks/99-wol-by-default.sh (+13/-0)
tests/full/wol-enabled-by-default/task.yaml (+59/-0)
Reviewer Review Type Date Requested Status
System Enablement Bot continuous-integration Approve
Alfonso Sanchez-Beato Approve
Konrad Zapałowicz (community) code Approve
Tony Espy Pending
Review via email: mp+311843@code.launchpad.net

Description of the change

Enable wake-on-lan by default on all ethernet connections

This is a project requirement and we will refine this once we have proper configuration hook support and then each device can select via the gadget snap if this should be enabled or not. On devices like the Raspberry Pi having this enabled by default doesn't hurt as wake-on-lan is not supported at all.

Spread tests are just covering the configuration bits as in QEMU we can't really test the hardware part. Proper integration tests will be added to the engineering-tests.

To post a comment you must log in.
Revision history for this message
Konrad Zapałowicz (kzapalowicz) wrote :

ack

review: Approve (code)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Matteo Croce (teknoraver) :
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :

LGTM

review: Approve
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/bin/networkmanager b/bin/networkmanager
2index f72fa93..eab3b7e 100755
3--- a/bin/networkmanager
4+++ b/bin/networkmanager
5@@ -67,6 +67,13 @@ fi
6 # stopped.
7 $SNAP/bin/dhcp-lease-mover &
8
9+# Run available startup hooks to have a point to store custom
10+# logic outside of this script. More of the things from above
11+# should be moved into these.
12+for hook in $SNAP/startup-hooks/* ; do
13+ [ -x "$hook" ] && /bin/sh -x "$hook"
14+done
15+
16 export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$SNAP/usr/lib/NetworkManager"
17
18 $SNAP/usr/sbin/NetworkManager \
19diff --git a/snapcraft.yaml b/snapcraft.yaml
20index e34b875..50dc540 100644
21--- a/snapcraft.yaml
22+++ b/snapcraft.yaml
23@@ -35,6 +35,7 @@ parts:
24 bin/dhcp-lease-mover: bin/dhcp-lease-mover
25 conf/NetworkManager.conf: etc/NetworkManager/NetworkManager.conf
26 data/copyright: usr/share/doc/network-manager/copyright
27+ startup-hooks/99-wol-by-default.sh: startup-hooks/99-wol-by-default.sh
28
29 inotify-tools:
30 plugin: nil
31diff --git a/startup-hooks/99-wol-by-default.sh b/startup-hooks/99-wol-by-default.sh
32new file mode 100755
33index 0000000..c2d4480
34--- /dev/null
35+++ b/startup-hooks/99-wol-by-default.sh
36@@ -0,0 +1,13 @@
37+#!/bin/sh
38+
39+# Enable wake-on-lan by default until we have a configuration
40+# hook to do that.
41+if [ ! -e $SNAP_DATA/conf.d/enable-wol.conf ] ; then
42+ mkdir -p $SNAP_DATA/conf.d
43+ cat <<-EOF > $SNAP_DATA/conf.d/enable-wol.conf
44+ [connection]
45+ # Value 64 maps to the 'magic' setting; see man nm-settings
46+ # for more information.
47+ 802-3-ethernet.wake-on-lan=64
48+ EOF
49+fi
50diff --git a/tests/full/wol-enabled-by-default/task.yaml b/tests/full/wol-enabled-by-default/task.yaml
51new file mode 100644
52index 0000000..434ef01
53--- /dev/null
54+++ b/tests/full/wol-enabled-by-default/task.yaml
55@@ -0,0 +1,59 @@
56+summary: Verify that wake-on-lan is enabled by default for all ethernet connections
57+
58+execute: |
59+ . $TESTSLIB/utilities.sh
60+ nmcli=/snap/bin/network-manager.nmcli
61+ case "$SPREAD_REBOOT" in
62+ 0)
63+ # For correct timing if the device has just booted
64+ wait_for_network_manager
65+
66+ # The config file needs to be present and have the correct default set
67+ test -e /var/snap/network-manager/current/conf.d/enable-wol.conf
68+ cat /var/snap/network-manager/current/conf.d/enable-wol.conf | grep '802-3-ethernet.wake-on-lan=64'
69+
70+ # Precondition is a existing network connection
71+ $nmcli d | grep 'eth0.*connected'
72+
73+ # The netplan configuration file has WoL disabled by default as
74+ # the default one the core snap provides does not explicitly
75+ # enable WoL.
76+ connection=$($nmcli -m multiline -f UUID c show --active | awk '{print$2;exit}')
77+ $nmcli -m multiline -f connection.id c show $connection | grep 'netplan-eth0'
78+ $nmcli -m multiline -f connection.type c show $connection | grep '802-3-ethernet'
79+ $nmcli -m multiline -f 802-3-ethernet.wake-on-lan c show $connection | grep '0 (none)'
80+
81+ # Now prepare for the next boot where we will run without a netplan
82+ # config to get eth0 correctly configured.
83+ rm /etc/netplan/00-snapd-config.yaml
84+ REBOOT
85+ ;;
86+ 1)
87+ # For correct timing if the device has just booted
88+ wait_for_network_manager
89+
90+ # Precondition is a existing network connection
91+ $nmcli d | grep 'eth0.*connected'
92+
93+ # Connection should have the default wake-on-lan setting
94+ connection=$($nmcli -m multiline -f UUID c show | awk '{print$2;exit}')
95+ $nmcli -m multiline -f connection.type c show $connection | grep '802-3-ethernet'
96+ # wake-on-lan should be set to respect the global defaults here
97+ $nmcli -m multiline -f 802-3-ethernet.wake-on-lan c show $connection | grep '1 (default)'
98+
99+ # We can sadly only verify that the value was correctly applied when
100+ # we're running the tests on a real device. QEMU doesn't support setting
101+ # the WoL value of the ethernet network device.
102+ if [ ! cat /proc/cpuinfo | grep QEMU ] ; then
103+ # Get the tools snap to have the ethtool tool available
104+ snap install --devmode --edge se-test-tools
105+ snap connect se-test-tools:network core
106+ snap connect se-test-tools:network-bind core
107+ snap connect se-test-tools:network-control core
108+
109+ # See `man ethtool` for details; 'g' means 'wakeup when magic packet comes in'
110+ # and is the default behavior we want.
111+ /snap/bin/se-test-tools.ethtool eth0 | grep 'Wake-up: g'
112+ fi
113+ ;;
114+ esac

Subscribers

People subscribed via source and target branches