Mageia Bugzilla – Attachment 7260 Details for
Bug 17108
udev hotplug kills children by timeout
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
New Account
|
Forgot Password
[patch]
3 files to add or change, added to git tree
0001-udev-network-hotplug-fix.patch (text/plain), 6.66 KB, created by
Yves DEMUR
on 2015-12-02 21:45:26 CET
(
hide
)
Description:
3 files to add or change, added to git tree
Filename:
MIME Type:
Creator:
Yves DEMUR
Created:
2015-12-02 21:45:26 CET
Size:
6.66 KB
patch
obsolete
>From 3c985dbf2a1a82a72fc12dd746f8deca1502449f Mon Sep 17 00:00:00 2001 >From: Yves Demur <yves.demur@m4am.net> >Date: Wed, 2 Dec 2015 21:36:18 +0100 >Subject: [PATCH] udev network hotplug fix > >--- > systemd/system/udev-net@.service | 12 +++++++ > udev/net_action | 41 +++++++++++++++++++++ > udev/net_create_ifcfg | 78 ++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 131 insertions(+) > create mode 100644 systemd/system/udev-net@.service > create mode 100755 udev/net_action > create mode 100755 udev/net_create_ifcfg > >diff --git a/systemd/system/udev-net@.service b/systemd/system/udev-net@.service >new file mode 100644 >index 0000000..64b113d >--- /dev/null >+++ b/systemd/system/udev-net@.service >@@ -0,0 +1,12 @@ >+# Used by udev to start/stop a hotplugged network interface, because an udev event launched process has a short lifetime and ends in killing all its forked children (wpa_supplicant, ifplugd, dhclient) even if they are daemonized >+# "Starting daemons or other long-running processes is not appropriate for udev; the forked processes, detached or not, will be unconditionally killed after the event handling has finished." >+ >+[Unit] >+Description=Service for running "net_action %i service" >+## no ! ## BindsTo=dev-%i.device # prevents service start at unplug due to absence of device, %i is not a device (+-add or +-remove) >+ >+[Service] >+Type=forking >+GuessMainPID=no >+RemainAfterExit=yes >+ExecStart=-/usr/lib/udev/net_action "%i" service >diff --git a/udev/net_action b/udev/net_action >new file mode 100755 >index 0000000..e243dbf >--- /dev/null >+++ b/udev/net_action >@@ -0,0 +1,41 @@ >+#!/bin/sh >+# to see the messages of this script : >+# journalctl --since="today" | grep net_action | less # G to go to last messages >+ >+[ "$2" = "service" ] && { ACTION="${1##*-}" ; INTERFACE="${1%-${ACTION}}" ; } >+[ "${ACTION}" != "add" -a "${ACTION}" != "remove" ] && { echo "Invalid action = '${ACTION}'" | systemd-cat -t net_action -p err ; exit 1 ; } >+ >+[ -z "${INTERFACE}" ] && { echo "No interface specified" | systemd-cat -t net_action -p err ; exit 2 ; } >+[ "${ACTION}" != "remove" -a ! -f /var/lock/subsys/network ] && { echo "Service network is not running, interface ${INTERFACE} not configured" | systemd-cat -t net_action -p warning ; exit 0 ; } >+ >+[ "$2" != "service" -a "${INTERFACE#ppp}" = "${INTERFACE}" ] && /usr/sbin/mdv-network-event ${ACTION} ${INTERFACE} >+ >+[ -r /etc/sysconfig/udev_net ] && . /etc/sysconfig/udev_net >+[ "${ACTION}" != "remove" -a -n "${BLACKLIST_ALL}" ] && eval "case ${INTERFACE} in ${BLACKLIST_ALL}) echo \"Interface ${INTERFACE} is blacklisted in udev_net\" | systemd-cat -t net_action -p warning ; exit 0 ;; esac" >+ >+[ -r /etc/sysconfig/network-scripts/ifcfg-${INTERFACE} ] || { echo "Interface ifcfg-${INTERFACE} file not found" | systemd-cat -t net_action -p warning ; exit 0 ; } >+ >+export IN_HOTPLUG=1 >+ >+ >+if [ "$2" != "service" ] ; then >+ >+ >+# PART LAUNCHED BY udev >+ >+# pass thru a service to start daemons or other long-running processes >+set -x ; exec /usr/bin/systemctl --no-block restart udev-net@${INTERFACE}-${ACTION}.service >+ >+# next processing, after the "else" statement, will be performed by the service process >+ >+ >+else >+ >+ >+# PART LAUNCHED BY udev-net@${INTERFACE}-${ACTION}.service >+ >+[ "${ACTION}" = "add" ] && { set -x ; exec /sbin/ifup ${INTERFACE} daemon ; } >+[ "${ACTION}" = "remove" ] && { set -x ; exec /sbin/ifdown ${INTERFACE} daemon ; } >+ >+ >+fi ; exit 0 >diff --git a/udev/net_create_ifcfg b/udev/net_create_ifcfg >new file mode 100755 >index 0000000..056b46a >--- /dev/null >+++ b/udev/net_create_ifcfg >@@ -0,0 +1,78 @@ >+#!/bin/sh >+ >+if [ "$AUTOMATIC_IFCFG" != no -a ! -e /etc/wpa_supplicant.conf ] ; then >+ cat > /etc/wpa_supplicant.conf << EOF >+# /etc/wpa_supplicant.conf >+ >+ctrl_interface=/var/run/wpa_supplicant >+update_config=1 >+eapol_version=1 >+ap_scan=1 >+fast_reauth=1 >+EOF >+fi >+ >+[ -z "$INTERFACE" ] && exit 0 >+ >+CFG=/etc/sysconfig/network-scripts/ifcfg-$INTERFACE >+[ -r $CFG ] && exit 0 >+ >+[ -r /etc/sysconfig/udev_net ] && . /etc/sysconfig/udev_net >+[ -n "$BLACKLIST_ALL" ] && eval "case $INTERFACE in $BLACKLIST_ALL) exit 1;; esac" >+[ -n "$BLACKLIST_PERSISTENT" ] && eval "case $INTERFACE in $BLACKLIST_PERSISTENT) exit 1;; esac" >+ >+# eagle-usb/firewire create a fake ethX interface >+#[ "$PHYSDEVDRIVER" = "ne2k-pci" ] || /usr/sbin/ethtool $INTERFACE &>/dev/null || exit 0 >+ >+# conform to network service (AUTOMATIC_IFCFG) >+[ -r /etc/sysconfig/network ] && . /etc/sysconfig/network >+ >+if [ "$AUTOMATIC_IFCFG" != no ]; then >+ cat > $CFG <<EOF >+# ${CFG} >+ >+# This file has been automatically generated by /usr/lib/udev/net_create_ifcfg at first plug of interface ${INTERFACE} because AUTOMATIC_IFCFG is not set to "no" in /etc/sysconfig/network >+ >+# The interface ${INTERFACE} will automagically connect to a wireless network at first plug if >+# - AUTOMATIC_IFCFG is not set to "no" in /etc/sysconfig/network >+# - the interface is not blacklisted in /etc/sysconfig/udev_net >+# - the kernel module for driving the interface is available >+# - /usr/lib/udev/net_action is configured to launch long time processes >+# - the application wpa_supplicant is installed and its service is not running >+# - the /etc/wpa_supplicant.conf is configured for the wireless networks used (see below and/or use # urpmi wpa_supplicant-gui ; wpa_gui & # ManageNetworks/Scan ...) >+# - the wireless network connected offers a dhcp server >+ >+# # Example of /etc/wpa_supplicant.conf: (several "network={...}" blocks may be present) >+# ctrl_interface=/var/run/wpa_supplicant >+# update_config=1 >+# eapol_version=1 >+# ap_scan=1 >+# fast_reauth=1 >+# # the line "psk=..." of next block is from the result of command # wpa_passphrase my_box_1234 "the_wifi_passwd_of_my_box_1234_access_point" (encrypts the password, so it is not readable in the file) >+# network={ >+# scan_ssid=0 # 1 if hidden network >+# ssid="my_box_1234" >+# psk=7a3c3ab47bedd917b46aba754c2b1c7302ed9a9e70de63ccb2639228b524f3ac >+# priority=1 >+# disabled=0 >+# } >+# # To avoid error message, create the void file /etc/sysconfig/network-scripts/wireless.d/my_box_1234 >+ >+DEVICE="${INTERFACE}" >+BOOTPROTO="dhcp" >+METRIC=35 >+USERCTL="yes" >+ >+# The default for ONBOOT is "yes" >+# Comment next line if interface is always plugged ; if commented, puts network.service in failed state at startup if interface is not plugged >+ONBOOT="no" >+# WARNING : if network.service start failed, do manually "# ifdown <if> daemon" on each running interface before restart >+ >+# WIRELESS_WPA_DRIVER must be defined to start the wpa_supplicant daemon at interface upping >+# Needs /etc/wpa_supplicant.conf configured for the wireless networks used (see above) >+WIRELESS_WPA_DRIVER="wext" >+ >+# The default for NM_CONTROLLED is "yes" (use of NetworkManager) >+NM_CONTROLLED="no" >+EOF >+fi >-- >2.3.10 >
From 3c985dbf2a1a82a72fc12dd746f8deca1502449f Mon Sep 17 00:00:00 2001 From: Yves Demur <yves.demur@m4am.net> Date: Wed, 2 Dec 2015 21:36:18 +0100 Subject: [PATCH] udev network hotplug fix --- systemd/system/udev-net@.service | 12 +++++++ udev/net_action | 41 +++++++++++++++++++++ udev/net_create_ifcfg | 78 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 131 insertions(+) create mode 100644 systemd/system/udev-net@.service create mode 100755 udev/net_action create mode 100755 udev/net_create_ifcfg diff --git a/systemd/system/udev-net@.service b/systemd/system/udev-net@.service new file mode 100644 index 0000000..64b113d --- /dev/null +++ b/systemd/system/udev-net@.service @@ -0,0 +1,12 @@ +# Used by udev to start/stop a hotplugged network interface, because an udev event launched process has a short lifetime and ends in killing all its forked children (wpa_supplicant, ifplugd, dhclient) even if they are daemonized +# "Starting daemons or other long-running processes is not appropriate for udev; the forked processes, detached or not, will be unconditionally killed after the event handling has finished." + +[Unit] +Description=Service for running "net_action %i service" +## no ! ## BindsTo=dev-%i.device # prevents service start at unplug due to absence of device, %i is not a device (+-add or +-remove) + +[Service] +Type=forking +GuessMainPID=no +RemainAfterExit=yes +ExecStart=-/usr/lib/udev/net_action "%i" service diff --git a/udev/net_action b/udev/net_action new file mode 100755 index 0000000..e243dbf --- /dev/null +++ b/udev/net_action @@ -0,0 +1,41 @@ +#!/bin/sh +# to see the messages of this script : +# journalctl --since="today" | grep net_action | less # G to go to last messages + +[ "$2" = "service" ] && { ACTION="${1##*-}" ; INTERFACE="${1%-${ACTION}}" ; } +[ "${ACTION}" != "add" -a "${ACTION}" != "remove" ] && { echo "Invalid action = '${ACTION}'" | systemd-cat -t net_action -p err ; exit 1 ; } + +[ -z "${INTERFACE}" ] && { echo "No interface specified" | systemd-cat -t net_action -p err ; exit 2 ; } +[ "${ACTION}" != "remove" -a ! -f /var/lock/subsys/network ] && { echo "Service network is not running, interface ${INTERFACE} not configured" | systemd-cat -t net_action -p warning ; exit 0 ; } + +[ "$2" != "service" -a "${INTERFACE#ppp}" = "${INTERFACE}" ] && /usr/sbin/mdv-network-event ${ACTION} ${INTERFACE} + +[ -r /etc/sysconfig/udev_net ] && . /etc/sysconfig/udev_net +[ "${ACTION}" != "remove" -a -n "${BLACKLIST_ALL}" ] && eval "case ${INTERFACE} in ${BLACKLIST_ALL}) echo \"Interface ${INTERFACE} is blacklisted in udev_net\" | systemd-cat -t net_action -p warning ; exit 0 ;; esac" + +[ -r /etc/sysconfig/network-scripts/ifcfg-${INTERFACE} ] || { echo "Interface ifcfg-${INTERFACE} file not found" | systemd-cat -t net_action -p warning ; exit 0 ; } + +export IN_HOTPLUG=1 + + +if [ "$2" != "service" ] ; then + + +# PART LAUNCHED BY udev + +# pass thru a service to start daemons or other long-running processes +set -x ; exec /usr/bin/systemctl --no-block restart udev-net@${INTERFACE}-${ACTION}.service + +# next processing, after the "else" statement, will be performed by the service process + + +else + + +# PART LAUNCHED BY udev-net@${INTERFACE}-${ACTION}.service + +[ "${ACTION}" = "add" ] && { set -x ; exec /sbin/ifup ${INTERFACE} daemon ; } +[ "${ACTION}" = "remove" ] && { set -x ; exec /sbin/ifdown ${INTERFACE} daemon ; } + + +fi ; exit 0 diff --git a/udev/net_create_ifcfg b/udev/net_create_ifcfg new file mode 100755 index 0000000..056b46a --- /dev/null +++ b/udev/net_create_ifcfg @@ -0,0 +1,78 @@ +#!/bin/sh + +if [ "$AUTOMATIC_IFCFG" != no -a ! -e /etc/wpa_supplicant.conf ] ; then + cat > /etc/wpa_supplicant.conf << EOF +# /etc/wpa_supplicant.conf + +ctrl_interface=/var/run/wpa_supplicant +update_config=1 +eapol_version=1 +ap_scan=1 +fast_reauth=1 +EOF +fi + +[ -z "$INTERFACE" ] && exit 0 + +CFG=/etc/sysconfig/network-scripts/ifcfg-$INTERFACE +[ -r $CFG ] && exit 0 + +[ -r /etc/sysconfig/udev_net ] && . /etc/sysconfig/udev_net +[ -n "$BLACKLIST_ALL" ] && eval "case $INTERFACE in $BLACKLIST_ALL) exit 1;; esac" +[ -n "$BLACKLIST_PERSISTENT" ] && eval "case $INTERFACE in $BLACKLIST_PERSISTENT) exit 1;; esac" + +# eagle-usb/firewire create a fake ethX interface +#[ "$PHYSDEVDRIVER" = "ne2k-pci" ] || /usr/sbin/ethtool $INTERFACE &>/dev/null || exit 0 + +# conform to network service (AUTOMATIC_IFCFG) +[ -r /etc/sysconfig/network ] && . /etc/sysconfig/network + +if [ "$AUTOMATIC_IFCFG" != no ]; then + cat > $CFG <<EOF +# ${CFG} + +# This file has been automatically generated by /usr/lib/udev/net_create_ifcfg at first plug of interface ${INTERFACE} because AUTOMATIC_IFCFG is not set to "no" in /etc/sysconfig/network + +# The interface ${INTERFACE} will automagically connect to a wireless network at first plug if +# - AUTOMATIC_IFCFG is not set to "no" in /etc/sysconfig/network +# - the interface is not blacklisted in /etc/sysconfig/udev_net +# - the kernel module for driving the interface is available +# - /usr/lib/udev/net_action is configured to launch long time processes +# - the application wpa_supplicant is installed and its service is not running +# - the /etc/wpa_supplicant.conf is configured for the wireless networks used (see below and/or use # urpmi wpa_supplicant-gui ; wpa_gui & # ManageNetworks/Scan ...) +# - the wireless network connected offers a dhcp server + +# # Example of /etc/wpa_supplicant.conf: (several "network={...}" blocks may be present) +# ctrl_interface=/var/run/wpa_supplicant +# update_config=1 +# eapol_version=1 +# ap_scan=1 +# fast_reauth=1 +# # the line "psk=..." of next block is from the result of command # wpa_passphrase my_box_1234 "the_wifi_passwd_of_my_box_1234_access_point" (encrypts the password, so it is not readable in the file) +# network={ +# scan_ssid=0 # 1 if hidden network +# ssid="my_box_1234" +# psk=7a3c3ab47bedd917b46aba754c2b1c7302ed9a9e70de63ccb2639228b524f3ac +# priority=1 +# disabled=0 +# } +# # To avoid error message, create the void file /etc/sysconfig/network-scripts/wireless.d/my_box_1234 + +DEVICE="${INTERFACE}" +BOOTPROTO="dhcp" +METRIC=35 +USERCTL="yes" + +# The default for ONBOOT is "yes" +# Comment next line if interface is always plugged ; if commented, puts network.service in failed state at startup if interface is not plugged +ONBOOT="no" +# WARNING : if network.service start failed, do manually "# ifdown <if> daemon" on each running interface before restart + +# WIRELESS_WPA_DRIVER must be defined to start the wpa_supplicant daemon at interface upping +# Needs /etc/wpa_supplicant.conf configured for the wireless networks used (see above) +WIRELESS_WPA_DRIVER="wext" + +# The default for NM_CONTROLLED is "yes" (use of NetworkManager) +NM_CONTROLLED="no" +EOF +fi -- 2.3.10
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 17108
:
7189
|
7191
| 7260