-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
network-flush: reset autoconnect-priority to zero (#65)
With older dracut, where NetworkManager does not run as a daemon and with dbus, the dracut module we have will not work to disable autoconnect for the connections created within the initramfs, which may be a problem as after the network flush, NM will activate the connection with the higher priority, and the initramfs connection may be it. Some connections are created with negative priority, by e.g. the Anaconda installer, which may be a problem in this situation. To work around this issue, we now reset the autoconnect priority of the connections to zero.
- Loading branch information
1 parent
ace3372
commit 44fd41c
Showing
4 changed files
with
38 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,37 @@ | ||
#!/bin/sh | ||
|
||
# This script flushes every active network interface. It is intended to | ||
# do_flush() flushes every active network interface. It is intended to | ||
# run before NetworkManager starts, so that when it does it will be able | ||
# to set up the network using the regular host configuration. | ||
do_flush() { | ||
for f in /sys/class/net/*; do | ||
iface="${f##*/}" | ||
[ "${iface}" = "lo" ] && continue | ||
echo "Preparing to flush interface ${iface}" >&2 | ||
ip -statistics address flush dev "${iface}" | ||
done | ||
} | ||
|
||
for f in /sys/class/net/*; do | ||
iface="${f##*/}" | ||
[ "${iface}" = "lo" ] && continue | ||
echo "Preparing to flush interface ${iface}" >&2 | ||
ip -statistics address flush dev "${iface}" | ||
done | ||
# reset_autoconn_prio() will reset the autoconnect priority | ||
# of the existing NM connections to zero. | ||
reset_autoconn_prio() { | ||
nmcli -t -f NAME connection show 2>/dev/null | while read -r _c; do | ||
if ! _prio="$(nmcli -t connection show "${_c}" \ | ||
| grep connection.autoconnect-priority: \ | ||
| cut -d: -f2)" || [ -z "${_prio}" ]; then | ||
continue | ||
fi | ||
[ "${_prio}" -ge 0 ] && continue | ||
echo "Setting autoconnect-priority of connection ${_c} to zero" >&2 | ||
nmcli connection modify "${_c}" connection.autoconnect-priority 0 | ||
done | ||
} | ||
|
||
case "${1}" in | ||
reset-autoconn-prio) | ||
reset_autoconn_prio;; | ||
flush) | ||
do_flush;; | ||
esac | ||
|
||
# vim:set ts=2 sw=2 et: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters