From b3ae030fce8b24c4f32e9eb618c664d57c6e0dce Mon Sep 17 00:00:00 2001 From: Sebastian Pastor Date: Tue, 28 Nov 2017 14:54:12 +0100 Subject: [PATCH] suspend: set wireless interfaces managed by NM as unmanaged before suspend With these changes we tell NM to not manage the wireless interfaces before unloading the wireless module. This was causing some unexpected behavior that crashed NetworkManager. Signed-off-by: Sebastian Pastor https://jira.digi.com/browse/DEL-5351 https://jira.digi.com/browse/DEL-4571 --- .../busybox/busybox-1.24.1/ccimx6qpsbc/suspend | 12 ++++++++++++ .../busybox/busybox-1.24.1/ccimx6sbc/suspend | 12 ++++++++++++ .../busybox/busybox-1.24.1/ccimx6ul/suspend | 12 ++++++++++++ 3 files changed, 36 insertions(+) diff --git a/meta-digi-dey/recipes-core/busybox/busybox-1.24.1/ccimx6qpsbc/suspend b/meta-digi-dey/recipes-core/busybox/busybox-1.24.1/ccimx6qpsbc/suspend index 50e3e59a3..28a9f68ca 100755 --- a/meta-digi-dey/recipes-core/busybox/busybox-1.24.1/ccimx6qpsbc/suspend +++ b/meta-digi-dey/recipes-core/busybox/busybox-1.24.1/ccimx6qpsbc/suspend @@ -36,6 +36,13 @@ suspend_interfaces() { for i in $(sed -ne 's,^\(wlan[0-9]\)=.*,\1,g;T;p' /var/run/ifstate | sort -r); do ifdown "${i}" && RESUME_IFACES="${RESUME_IFACES:+${RESUME_IFACES} }${i}" done + + # Get a list of the wireless interfaces managed by NetworkManager + # and set them to unmanaged before suspend. + for i in $(nmcli -t -f DEVICE,TYPE,STATE dev | grep :wifi: | grep -v unmanaged | cut -d':' -f1); do + nmcli dev set "${i}" managed no && NM_MANAGED_IFACES="${NM_MANAGED_IFACES:+${NM_MANAGED_IFACES} }${i}" + done + grep -qs '^wlan' /proc/modules && rmmod wlan fi @@ -54,6 +61,11 @@ resume_interfaces() { udevadm trigger --action=add --attr-match="modalias=sdio:c00v0271d050A" timeout -t 5 sh -c "while [ ! -d /sys/class/net/wlan0 ]; do sleep .2; done" 2>/dev/null + # Set interfaces managed by NetworkManager back as managed + for i in $(echo ${NM_MANAGED_IFACES} | tr ' ' '\n' | sort); do + nmcli dev set "${i}" managed yes + done + # Bring up the interfaces that were bring down on suspend for i in $(echo ${RESUME_IFACES} | tr ' ' '\n' | sort); do grep -qs "^${i}" /var/run/ifstate || ifup "${i}" diff --git a/meta-digi-dey/recipes-core/busybox/busybox-1.24.1/ccimx6sbc/suspend b/meta-digi-dey/recipes-core/busybox/busybox-1.24.1/ccimx6sbc/suspend index 140645eea..44f9548e6 100755 --- a/meta-digi-dey/recipes-core/busybox/busybox-1.24.1/ccimx6sbc/suspend +++ b/meta-digi-dey/recipes-core/busybox/busybox-1.24.1/ccimx6sbc/suspend @@ -36,6 +36,13 @@ suspend_interfaces() { for i in $(sed -ne 's,^\(wlan[0-9]\)=.*,\1,g;T;p' /var/run/ifstate | sort -r); do ifdown "${i}" && RESUME_IFACES="${RESUME_IFACES:+${RESUME_IFACES} }${i}" done + + # Get a list of the wireless interfaces managed by NetworkManager + # and set them to unmanaged before suspend. + for i in $(nmcli -t -f DEVICE,TYPE,STATE dev | grep :wifi: | grep -v unmanaged | cut -d':' -f1); do + nmcli dev set "${i}" managed no && NM_MANAGED_IFACES="${NM_MANAGED_IFACES:+${NM_MANAGED_IFACES} }${i}" + done + grep -qs '^ath6kl_sdio' /proc/modules && rmmod ath6kl_sdio ath6kl_core fi @@ -54,6 +61,11 @@ resume_interfaces() { udevadm trigger --action=add --attr-match="modalias=sdio:c00v0271d0301" timeout -t 5 sh -c "while [ ! -d /sys/class/net/wlan0 ]; do sleep .2; done" 2>/dev/null + # Set interfaces managed by NetworkManager back as managed + for i in $(echo ${NM_MANAGED_IFACES} | tr ' ' '\n' | sort); do + nmcli dev set "${i}" managed yes + done + # Bring up the interfaces that were bring down on suspend for i in $(echo ${RESUME_IFACES} | tr ' ' '\n' | sort); do grep -qs "^${i}" /var/run/ifstate || ifup "${i}" diff --git a/meta-digi-dey/recipes-core/busybox/busybox-1.24.1/ccimx6ul/suspend b/meta-digi-dey/recipes-core/busybox/busybox-1.24.1/ccimx6ul/suspend index a74f24d35..f2ee3cb22 100755 --- a/meta-digi-dey/recipes-core/busybox/busybox-1.24.1/ccimx6ul/suspend +++ b/meta-digi-dey/recipes-core/busybox/busybox-1.24.1/ccimx6ul/suspend @@ -36,6 +36,13 @@ suspend_interfaces() { for i in $(sed -ne 's,^\(wlan[0-9]\)=.*,\1,g;T;p' /var/run/ifstate | sort -r); do ifdown "${i}" && RESUME_IFACES="${RESUME_IFACES:+${RESUME_IFACES} }${i}" done + + # Get a list of the wireless interfaces managed by NetworkManager + # and set them to unmanaged before suspend. + for i in $(nmcli -t -f DEVICE,TYPE,STATE dev | grep :wifi: | grep -v unmanaged | cut -d':' -f1); do + nmcli dev set "${i}" managed no && NM_MANAGED_IFACES="${NM_MANAGED_IFACES:+${NM_MANAGED_IFACES} }${i}" + done + grep -qs '^wlan' /proc/modules && rmmod wlan fi @@ -54,6 +61,11 @@ resume_interfaces() { udevadm trigger --action=add --attr-match="modalias=sdio:c00v0271d050A" timeout -t 5 sh -c "while [ ! -d /sys/class/net/wlan0 ]; do sleep .2; done" 2>/dev/null + # Set interfaces managed by NetworkManager back as managed + for i in $(echo ${NM_MANAGED_IFACES} | tr ' ' '\n' | sort); do + nmcli dev set "${i}" managed yes + done + # Bring up the interfaces that were bring down on suspend for i in $(echo ${RESUME_IFACES} | tr ' ' '\n' | sort); do grep -qs "^${i}" /var/run/ifstate || ifup "${i}"