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

Subscribers

People subscribed via source and target branches