From c7560969dd8540fb1ee76b494d5e744ad15c5a3e Mon Sep 17 00:00:00 2001 From: Jan Macku Date: Tue, 16 Jun 2020 09:22:43 +0200 Subject: ifup-eth: Switch to bc utility, which supports floating point computations. backport of: 0be5319 Resolves: #1826637 --- initscripts.spec | 1 + network-scripts/ifup-eth | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/initscripts.spec b/initscripts.spec index 8ac1dac0..97b3225e 100644 --- a/initscripts.spec +++ b/initscripts.spec @@ -95,6 +95,7 @@ Requires: %{name}%{?_isa} = %{version}-%{release} %shared_requirements +Requires: bc Requires: dbus Requires: gawk Requires: grep diff --git a/network-scripts/ifup-eth b/network-scripts/ifup-eth index b49af168..1d6f18e7 100755 --- a/network-scripts/ifup-eth +++ b/network-scripts/ifup-eth @@ -89,9 +89,11 @@ if [ "${TYPE}" = "Bridge" ]; then forward_delay="$(convert2sec ${forward_delay} centi)" fi - forward_delay=$(expr ${forward_delay} \* 2 + 7) + forward_delay=$(bc -q <<< "${forward_delay} * 2 + 7") - [ 0$LINKDELAY -lt $forward_delay ] && LINKDELAY=$forward_delay + # It's possible we are comparing floating point numbers here, therefore + # we are using 'bc' for comparison. The [ ] and [[ ]] do not work. + (( $(bc -l <<< "${LINKDELAY:-0} < ${forward_delay}") )) && LINKDELAY=${forward_delay} unset forward_delay fi -- cgit v1.2.1