]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
mkinitrd-suse.sh: Fix prefix calculation 222/head
authorDaniel Molkentin <dmolkentin@suse.com>
Tue, 25 Apr 2017 13:25:20 +0000 (15:25 +0200)
committerDaniel Molkentin <dmolkentin@suse.com>
Tue, 25 Apr 2017 13:30:13 +0000 (15:30 +0200)
The previous algorithm was incorrect and would return
incorrect results e.g. for a /20 mask. Also gets rid
of an undocumented depencency on bc(1).

Reference: bsc#1035743

mkinitrd-suse.sh

index bc49d731f8956af91c26b1e9f992befd44ad587a..d9de81b9825b9f267dc6cf12a33463d82935a474 100755 (executable)
@@ -104,7 +104,7 @@ calc_netmask() {
     local prefix=$1
 
     [ -z "$prefix" ] && return
-    mask=$(echo "(2 ^ 32) - (2 ^ $prefix)" | bc -l)
+    mask=$(( 0xffffffff << (32 - $prefix) ))
     byte1=$(( mask >> 24 ))
     byte2=$(( mask >> 16 ))
     byte3=$(( mask >> 8 ))