From 3002b9a08f15d345ee02d755bd46ee85dedc0d4e Mon Sep 17 00:00:00 2001 From: Pavel Cahyna Date: Tue, 22 Feb 2022 10:16:10 +0100 Subject: [PATCH] Apply upstream PR#2736 Adds EXCLUDE_IP_ADDRESSES and EXCLUDE_NETWORK_INTERFACES configuration parameters. Resolves: rhbz2035939 --- rear-bz2035939.patch | 56 ++++++++++++++++++++++++++++++++++++++++++++ rear.spec | 1 + 2 files changed, 57 insertions(+) create mode 100644 rear-bz2035939.patch diff --git a/rear-bz2035939.patch b/rear-bz2035939.patch new file mode 100644 index 0000000..30771c9 --- /dev/null +++ b/rear-bz2035939.patch @@ -0,0 +1,56 @@ +diff --git a/usr/share/rear/conf/default.conf b/usr/share/rear/conf/default.conf +index 0c230f38..f231bf3d 100644 +--- a/usr/share/rear/conf/default.conf ++++ b/usr/share/rear/conf/default.conf +@@ -2707,6 +2707,15 @@ WARN_MISSING_VOL_ID=1 + USE_CFG2HTML= + # The SKIP_CFG2HTML variable is no longer supported since ReaR 1.18 + ++# IP addresses that are present on the system but must be excluded when ++# building the network configuration used in recovery mode; this is typically ++# used when floating IP addresses are used on the system ++EXCLUDE_IP_ADDRESSES=() ++ ++# Network interfaces that are present on the system but must be excluded when ++# building the network configuration used in recovery mode ++EXCLUDE_NETWORK_INTERFACES=() ++ + # Simplify bonding setups by configuring always the first active device of a + # bond, except when mode is 4 (IEEE 802.3ad policy) + SIMPLIFY_BONDING=no +diff --git a/usr/share/rear/rescue/GNU/Linux/310_network_devices.sh b/usr/share/rear/rescue/GNU/Linux/310_network_devices.sh +index f806bfbf..2385f5b6 100644 +--- a/usr/share/rear/rescue/GNU/Linux/310_network_devices.sh ++++ b/usr/share/rear/rescue/GNU/Linux/310_network_devices.sh +@@ -355,6 +355,11 @@ function is_interface_up () { + local network_interface=$1 + local sysfspath=/sys/class/net/$network_interface + ++ if IsInArray "$network_interface" "${EXCLUDE_NETWORK_INTERFACES[@]}"; then ++ LogPrint "Excluding '$network_interface' per EXCLUDE_NETWORK_INTERFACES directive." ++ return 1 ++ fi ++ + local state=$( cat $sysfspath/operstate ) + if [ "$state" = "down" ] ; then + return 1 +@@ -403,11 +408,19 @@ function ipaddr_setup () { + if [ -n "$ipaddrs" ] ; then + # If some IP is found for the network interface, then use them + for ipaddr in $ipaddrs ; do ++ if IsInArray "${ipaddr%%/*}" "${EXCLUDE_IP_ADDRESSES[@]}"; then ++ LogPrint "Excluding IP address '$ipaddr' per EXCLUDE_IP_ADDRESSES directive even through it's defined in mapping file '$CONFIG_DIR/mappings/ip_addresses'." ++ continue ++ fi + echo "ip addr add $ipaddr dev $mapped_as" + done + else + # Otherwise, collect IP addresses for the network interface on the system + for ipaddr in $( ip a show dev $network_interface scope global | grep "inet.*\ " | tr -s " " | cut -d " " -f 3 ) ; do ++ if IsInArray "${ipaddr%%/*}" "${EXCLUDE_IP_ADDRESSES[@]}"; then ++ LogPrint "Excluding IP address '$ipaddr' per EXCLUDE_IP_ADDRESSES directive." ++ continue ++ fi + echo "ip addr add $ipaddr dev $mapped_as" + done + fi diff --git a/rear.spec b/rear.spec index 299da79..6c2a583 100644 --- a/rear.spec +++ b/rear.spec @@ -28,6 +28,7 @@ Patch37: rear-bz1747468.patch Patch38: rear-bz2049091.patch Patch39: rear-pr2675.patch Patch40: rear-bz2048454.patch +Patch41: rear-bz2035939.patch # rear contains only bash scripts plus documentation so that on first glance it could be "BuildArch: noarch" # but actually it is not "noarch" because it only works on those architectures that are explicitly supported.