Skip to contentSkip to conversation

Recent network bug fixes from the latest SuSE dracut repo

PATCH New Thomas Renninger 2 participants 14 messages May 12, 2016 – May 18, 2016 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

These are network related patches to get SuSE and mainline dracut sources closer together again.

If format, etc is ok, some more patches from other areas will follow.

I added a link to public bugzilla entries.

References like bnc# and bsc# point to restricted SLE bugzilla entries. If these patches need discussion, I should be able to add you to the bug or copy relevant parts to public, so this info is still needed.

Would be great to see these patches pushed into mainline git repo soon.

Thanks,

Thomas

#2 lore raw

PATCH 1/12 40network: Fix race condition when wait for networks

In reply to a message not in the archive

From: Pawel Wieczorkiewicz <[email protected]>

If no network related params are specific, but rd.neednet=1 is set, the default initqueue action is to wait until one of the network interfaces is marked as setup properly.

This also help with initqueue's race condition when the network interface shows upd late

References: bnc#866771

---
 modules.d/40network/net-genrules.sh | 3 +++
 1 file changed, 3 insertions(+)
modules.d/40network/net-genrules.sh +3 -0
index 5df50bd..c964531 100755
@@ -105,6 +105,9 @@ command -v fix_bootif >/dev/null || . /lib/net-lib.sh
         cond='ACTION=="add", SUBSYSTEM=="net"'
         # if you change the name of "91-default-net.rules", also change modules.d/80cms/cmssetup.sh
         echo "$cond, $runcmd" > /etc/udev/rules.d/91-default-net.rules
+        if [ "$NEEDNET" = "1" ]; then
+            echo "[ -f /tmp/net.*.did-setup ]" >$hookdir/initqueue/finished/wait-network.sh
+        fi
     fi
 
 # if you change the name of "90-net.rules", also change modules.d/80cms/cmssetup.sh
Signature · 1 line
2.1.4
#3 lore raw

PATCH 2/12 40network: always start netroot in ifup.sh

In reply to a message not in the archive

From: Hannes Reinecke <[email protected]>

It's totally irrelevant how the network is configured when trying to setup netroot. It only matters if it could be configured at all.
So change the logic the check for correct network setup and then start netroot.

References: bnc#881235

---
 modules.d/40network/ifup.sh | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)
modules.d/40network/ifup.sh +5 -13
index 1185523..3234c56 100755
@@ -388,19 +388,11 @@ for p in $(getargs ip=); do
             > /tmp/net.$(cat /sys/class/net/${netif}/address).up
         fi
 
-        case $autoconf in
-            dhcp|on|any|dhcp6)
-            ;;
-            *)
-                if [ $ret -eq 0 ]; then
-                    setup_net $netif
-                    source_hook initqueue/online $netif
-                    if [ -z "$manualup" ]; then
-                        /sbin/netroot $netif
-                    fi
-                fi
-                ;;
-        esac
+        setup_net $netif
+        source_hook initqueue/online $netif
+        if [ -z "$manualup" ]; then
+            /sbin/netroot $netif
+        fi
         exit $ret
     fi
 done
Signature · 1 line
2.1.4
#4 lore raw

PATCH 3/12 40network: Only enable network interfaces if explicitly requested

In reply to a message not in the archive

From: Pawel Wieczorkiewicz <[email protected]>

Currently all available network interfaces are started whenever 40network is pulled in. This causes massive delays during bootup. This patch modifies the behaviour to start interfaces only if rd.neednet is specified.

References: bnc#879038

---
 modules.d/40network/net-genrules.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
modules.d/40network/net-genrules.sh +1 -1
index c964531..acaee7c 100755
@@ -104,8 +104,8 @@ command -v fix_bootif >/dev/null || . /lib/net-lib.sh
     else
         cond='ACTION=="add", SUBSYSTEM=="net"'
         # if you change the name of "91-default-net.rules", also change modules.d/80cms/cmssetup.sh
-        echo "$cond, $runcmd" > /etc/udev/rules.d/91-default-net.rules
         if [ "$NEEDNET" = "1" ]; then
+            echo "$cond, $runcmd" > /etc/udev/rules.d/91-default-net.rules
             echo "[ -f /tmp/net.*.did-setup ]" >$hookdir/initqueue/finished/wait-network.sh
         fi
     fi
Signature · 1 line
2.1.4
#5 lore raw

PATCH 4/12 40network: Update iBFT scanning code to handle IPv6

In reply to a message not in the archive

From: Hannes Reinecke <[email protected]>

IPv6 addresses should be specified in brackets so that the ip= scanning code doesn't get confused.

References: bnc#887542

---
 modules.d/40network/net-lib.sh | 48 +++++++++++++++++++++++++++++++++++++-----
 1 file changed, 43 insertions(+), 5 deletions(-)
modules.d/40network/net-lib.sh +43 -5
index 31f1a56..c372665 100755
@@ -241,23 +241,54 @@ ibft_to_cmdline() {
 
             [ -e /tmp/net.${dev}.has_ibft_config ] && continue
 
+            [ -e ${iface}/flags ] && flags=$(read a < ${iface}/flags; echo $a)
+            # Skip invalid interfaces
+            (( $flags & 1 )) || continue
+            # Skip interfaces not used for booting
+            (( $flags & 2 )) || continue
             [ -e ${iface}/dhcp ] && dhcp=$(read a < ${iface}/dhcp; echo $a)
-
-            if [ -n "$dhcp" ]; then
-                echo "ip=$dev:dhcp"
+            [ -e ${iface}/origin ] && origin=$(read a < ${iface}/origin; echo $a)
+            [ -e ${iface}/ip-addr ] && ip=$(read a < ${iface}/ip-addr; echo $a)
+
+            if [ -n "$ip" ] ; then
+                case "$ip" in
+                    *.*.*.*)
+                        family=ipv4
+                        ;;
+                    *:*)
+                        family=ipv6
+                        ;;
+                esac
+            fi
+            if [ -n "$dhcp" ] || [ "$origin" -eq 3 ]; then
+                if [ "$family" = "ipv6" ] ; then
+                    echo "ip=$dev:dhcp6"
+                else
+                    echo "ip=$dev:dhcp"
+                fi
             elif [ -e ${iface}/ip-addr ]; then
-                [ -e ${iface}/ip-addr ] && ip=$(read a < ${iface}/ip-addr; echo $a)
                 # skip not assigned ip adresses
                 [ "$ip" = "0.0.0.0" ] && continue
                 [ -e ${iface}/gateway ] && gw=$(read a < ${iface}/gateway; echo $a)
                 [ "$gateway" = "0.0.0.0" ] && unset $gateway
                 [ -e ${iface}/subnet-mask ] && mask=$(read a < ${iface}/subnet-mask; echo $a)
+                [ -e ${iface}/prefix-len ] && prefix=$(read a < ${iface}/prefix-len; echo $a)
                 [ -e ${iface}/primary-dns ] && dns1=$(read a < ${iface}/primary-dns; echo $a)
                 [ "$dns1" = "0.0.0.0" ] && unset $dns1
                 [ -e ${iface}/secondary-dns ] && dns2=$(read a < ${iface}/secondary-dns; echo $a)
                 [ "$dns2" = "0.0.0.0" ] && unset $dns2
                 [ -e ${iface}/hostname ] && hostname=$(read a < ${iface}/hostname; echo $a)
-                if [ -n "$ip" ] && [ -n "$mask" ]; then
+                if [ "$family" = "ipv6" ] ; then
+                    if [ -n "$ip" ] ; then
+                        [ -n "$prefix" ] || prefix=64
+                        ip="[${ip}/${prefix}]"
+                        mask=
+                    fi
+                    if [ -n "$gw" ] ; then
+                        gw="[${gw}]"
+                    fi
+                fi
+                if [ -n "$ip" ] && [ -n "$mask" -o -n "$prefix" ]; then
                     echo "ip=$ip::$gw:$mask:$hostname:$dev:none${dns1:+:$dns1}${dns2:+:$dns2}"
                 else
                     warn "${iface} does not contain a valid iBFT configuration"
@@ -439,6 +470,13 @@ ip_to_var() {
             esac
             ;;
     esac
+    # Extract prefix length from CIDR notation
+    case $ip in
+        */*)
+            mask=${ip##*/}
+            ip=${ip%/*}
+            ;;
+    esac
 
     # ip=<ipv4-address> means anaconda-style static config argument cluster:
     # ip=<ip> gateway=<gw> netmask=<nm> hostname=<host> mtu=<mtu>
Signature · 1 line
2.1.4
#6 lore raw

PATCH 5/12 40network: separate 'mask' and 'prefix'

In reply to a message not in the archive

From: Hannes Reinecke <[email protected]>

The 'mask' parameter is used for both, the (IPv4) netmask and the prefix length. As both are in different format separate them out into 'mask' for the netmask and 'prefix' for the prefix length. And also prefer the use of 'prefix' where possible to ease calculation and better IPv6 support.

References: bnc#887542

---
 modules.d/40network/ifup.sh          | 17 +++++++++++----
 modules.d/40network/net-lib.sh       | 42 +++++++++++++++++++++++++++++++++---
 modules.d/40network/parse-ip-opts.sh |  2 +-
 3 files changed, 53 insertions(+), 8 deletions(-)
modules.d/40network/ifup.sh +13 -4
index 3234c56..4ab597f 100755
@@ -105,17 +105,26 @@ do_static() {
 
     [ -n "$macaddr" ] && ip link set address $macaddr dev $netif
     [ -n "$mtu" ] && ip link set mtu $mtu dev $netif
-    if strglobin $ip '*:*:*'; then
+    [ -n "$mask" -a -z "$prefix" ] && prefix=$(mask_to_prefix $mask)
+    if [ "${ip##*/}" != "${ip}" ] ; then
+        prefix="${ip##*/}"
+        ip="${ip%/*}"
+    fi
+if strglobin $ip '*:*:*'; then
+        # Always assume /64 prefix for IPv6
+        [ -z "$prefix" ] && prefix=64
         # note no ip addr flush for ipv6
-        ip addr add $ip/$mask ${srv:+peer $srv} dev $netif
+        ip addr add $ip/$prefix ${srv:+peer $srv} dev $netif
         wait_for_ipv6_dad $netif
     else
         if ! arping -f -q -D -c 2 -I $netif $ip; then
             warn "Duplicate address detected for $ip for interface $netif."
             return 1
         fi
+        # Assume /24 prefix for IPv4
+        [ -z "$prefix" ] && prefix=24
         ip addr flush dev $netif
-        ip addr add $ip/$mask ${srv:+peer $srv} brd + dev $netif
+        ip addr add $ip/$prefix ${srv:+peer $srv} brd + dev $netif
     fi
 
     [ -n "$gw" ] && echo ip route replace default via $gw dev $netif > /tmp/net.$netif.gw
@@ -362,7 +371,7 @@ for p in $(getargs ip=); do
     done
 
     # Store config for later use
-    for i in ip srv gw mask hostname macaddr mtu dns1 dns2; do
+    for i in ip srv gw mask prefix hostname macaddr mtu dns1 dns2; do
         eval '[ "$'$i'" ] && echo '$i'="$'$i'"'
     done > /tmp/net.$netif.override
 
modules.d/40network/net-lib.sh +39 -3

84 lines not on this page · raw message

modules.d/40network/parse-ip-opts.sh +1 -1
index 5779ef8..75ad0a4 100755
@@ -72,7 +72,7 @@ for p in $(getargs ip=); do
             none|off)
                 [ -z "$ip" ] && \
                     die "For argument 'ip=$p'\nValue '$autoopt' without static configuration does not make sense"
-                [ -z "$mask" ] && \
+                [ -z "$mask" -a -z "$prefix" ] && \
                     die "Sorry, automatic calculation of netmask is not yet supported"
                 ;;
             auto6);;
Signature · 1 line
2.1.4
#7 lore raw

PATCH 6/12 network/iscsi: Skip invalid ibft dhcp address

In reply to a message not in the archive

From: Thomas Blume <thomas.blume-IBi9RG/[email protected]>

bsc#953361

CC Hannes Reinecke <hare-IBi9RG/[email protected]>
---
 modules.d/40network/net-lib.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
modules.d/40network/net-lib.sh +1 -1
index 322d5b5..61aa2a9 100755
@@ -289,7 +289,7 @@ ibft_to_cmdline() {
                         ;;
                 esac
             fi
-            if [ -n "$dhcp" ] || [ "$origin" -eq 3 ]; then
+            if [ -n "$dhcp" -a "$dhcp" != "0.0.0.0" ] || [ -z "$dhcp" -a "$origin" -eq 3 ]; then
                 if [ "$family" = "ipv6" ] ; then
                     echo "ip=$dev:dhcp6"
                 else
Signature · 1 line
2.1.4
#8 lore raw

PATCH 7/12 nfs: Fix nfs rootfs in case of mounting via IPv4 not hostname

In reply to a message not in the archive

https://bugzilla.suse.com/show_bug.cgi?id=931307

---
 modules.d/95nfs/module-setup.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
modules.d/95nfs/module-setup.sh +2 -2
index 9767e57..c8dfa94 100755
@@ -51,9 +51,9 @@ cmdline() {
 
     ### ip= ###
     if [[ $nfs_device = [0-9]*\.[0-9]*\.[0-9]*.[0-9]* ]] || [[ $nfs_device = \[.*\] ]]; then
-        nfs_address="$nfs_device"
+        nfs_address="${nfs_device%%:*}"
     else
-        lookup=$(host $(echo ${nfs_device%%:*})| head -n1)
+        lookup=$(host "${nfs_device%%:*}"| head -n1)
         nfs_address=${lookup##* }
     fi
     ifname=$(ip -o route get to $nfs_address | sed -n 's/.*dev \([^ ]*\).*/\1/p')
Signature · 1 line
2.1.4
#9 lore raw

PATCH 8/12 NFS: Support host being a DNS ALIAS

In reply to a message not in the archive

From: Fabian Vogt <fvogt-IBi9RG/[email protected]>

The "host" command may also print something else than "asdf.local.lan has address 1.2.3.4", like:
"rootserver.local.net is an alias for rainbow.local.net.". So "head -n1" is not enough.

https://bugzilla.suse.com/show_bug.cgi?id=955592

---
 modules.d/95nfs/module-setup.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
modules.d/95nfs/module-setup.sh +1 -1
index c8dfa94..ed62b05 100755
@@ -53,7 +53,7 @@ cmdline() {
     if [[ $nfs_device = [0-9]*\.[0-9]*\.[0-9]*.[0-9]* ]] || [[ $nfs_device = \[.*\] ]]; then
         nfs_address="${nfs_device%%:*}"
     else
-        lookup=$(host "${nfs_device%%:*}"| head -n1)
+        lookup=$(host "${nfs_device%%:*}"| grep " address " | head -n1)
         nfs_address=${lookup##* }
     fi
     ifname=$(ip -o route get to $nfs_address | sed -n 's/.*dev \([^ ]*\).*/\1/p')
Signature · 1 line
2.1.4
#10 lore raw

PATCH 9/12 kernel-network-modules: Don't include qemu network modules without reason

In reply to a message not in the archive

From: Fabian Vogt <fvogt-IBi9RG/[email protected]>

virtio-net without other network tools does not make sense and causes various bugs, like:
https://bugzilla.suse.com/show_bug.cgi?id=960669
This patch merges 90qemu-net into 90-kernel-network-modules.

---
 modules.d/90kernel-network-modules/module-setup.sh | 25 ++++++++++++++++++++
 modules.d/90qemu-net/module-setup.sh               | 27 ----------------------
 2 files changed, 25 insertions(+), 27 deletions(-)
 delete mode 100755 modules.d/90qemu-net/module-setup.sh
modules.d/90kernel-network-modules/module-setup.sh +25 -0
index 11fbab9..b2c3547 100755
@@ -10,6 +10,25 @@ depends() {
     return 0
 }
 
+running_in_qemu() {
+    if type -P systemd-detect-virt >/dev/null 2>&1; then
+        vm=$(systemd-detect-virt --vm 2>&1)
+        (($? != 0)) && return 255
+        [[ $vm = "qemu" ]] && return 0
+        [[ $vm = "kvm" ]] && return 0
+        [[ $vm = "bochs" ]] && return 0
+    fi
+
+    for i in /sys/class/dmi/id/*_vendor; do
+        [[ -f $i ]] || continue
+        read vendor < $i
+        [[  "$vendor" == "QEMU" ]] && return 0
+        [[  "$vendor" == "Bochs" ]] && return 0
+    done
+
+    return 255
+}
+
 # called by dracut
 installkernel() {
     # Include wired net drivers, excluding wireless
@@ -30,6 +49,12 @@ installkernel() {
         =drivers/net/ethernet \
         ecb arc4 bridge stp llc ipv6 bonding 8021q af_packet virtio_net
     hostonly="" instmods iscsi_ibft crc32c iscsi_boot_sysfs
+
+    if running_in_qemu; then
+        hostonly='' instmods virtio_net e1000 8139cp pcnet32 e100 ne2k_pci
+    else
+        return 0
+    fi
 }
 
 # called by dracut
modules.d/90qemu-net/module-setup.sh deleted +0 -27
deleted file mode 100755
index 58f1233..0000000
@@ -1,27 +0,0 @@
-#!/bin/bash
-
-# called by dracut
-check() {
-    if type -P systemd-detect-virt >/dev/null 2>&1; then
-        vm=$(systemd-detect-virt --vm >/dev/null 2>&1)
-        (($? != 0)) && return 255
-        [[ $vm = "qemu" ]] && return 0
-        [[ $vm = "kvm" ]] && return 0
-        [[ $vm = "bochs" ]] && return 0
-    fi
-
-    for i in /sys/class/dmi/id/*_vendor; do
-        [[ -f $i ]] || continue
-        read vendor < $i
-        [[  "$vendor" == "QEMU" ]] && return 0
-        [[  "$vendor" == "Bochs" ]] && return 0
-    done
-
-    return 255
-}
-
-# called by dracut
-installkernel() {
-    # qemu specific modules
-    hostonly='' instmods virtio_net e1000 8139cp pcnet32 e100 ne2k_pci
-}
Signature · 1 line
2.1.4
#11 lore raw

PATCH 10/12 fcoe-uefi: Add check for usage

In reply to a message not in the archive

From: Fabian Vogt <fvogt-IBi9RG/[email protected]>

References:
https://bugzilla.suse.com/show_bug.cgi?id=965477

fcoe-uefi gets included by default on EFI systems, as it does not do the same check that fcoe does, therefore needlessly pulling in network modules. This patch copies the check from fcoe to fcoe-uefi.

---
 modules.d/95fcoe-uefi/module-setup.sh | 5 +++++
 1 file changed, 5 insertions(+)
modules.d/95fcoe-uefi/module-setup.sh +5 -0
index 5d8477c..66af804 100755
@@ -4,6 +4,11 @@
 check() {
     [[ $hostonly ]] || [[ $mount_needs ]] && {
         [ -d /sys/firmware/efi ] || return 255
+        for c in /sys/bus/fcoe/devices/ctlr_* ; do
+            [ -L $c ] || continue
+            fcoe_ctlr=$c
+        done
+        [ -z "$fcoe_ctlr" ] && return 255
     }
     require_binaries dcbtool fipvlan lldpad ip readlink || return 1
     return 0
Signature · 1 line
2.1.4
#12 lore raw

PATCH 11/12 mulitpath: Boot up, also without multipath.conf, it is not mandatory

In reply to a message not in the archive

From: Hannes Reinecke <[email protected]>

If rootfs is on multipath, but platform does not have an /etc/multipath.conf file which is not urgently needed, they system will not boot, due to:

multipathd is not started and rootfs and swap are not found:
systemctl status multipathd.service
* multipathd.service - Device-Mapper Multipath Device Controller
Loaded: loaded (/usr/lib/systemd/system/multipathd.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Condition: start condition failed at Thu 2015-05-07 11:49:11 CEST; 7min ago
ConditionPathExists=/etc/multipath.conf was not met

and exit to dracut shell.

---
 modules.d/90multipath/multipathd.service | 1 -
 1 file changed, 1 deletion(-)
modules.d/90multipath/multipathd.service +0 -1
index b64b02c..f7bc65f 100644
@@ -6,7 +6,6 @@ Conflicts=shutdown.target
 ConditionKernelCommandLine=!nompath
 ConditionKernelCommandLine=!rd.multipath=0
 ConditionKernelCommandLine=!rd_NO_MULTIPATH
-ConditionPathExists=/etc/multipath.conf
 
 [Service]
 Type=simple
Signature · 1 line
2.1.4
#13 lore raw

PATCH 12/12 multipath: Fix warning about multipath if not needed

In reply to a message not in the archive

From: Fabian Vogt <fvogt-IBi9RG/[email protected]>

Although no device uses multipath, the module checks for presence of the multipath binary first, printing a warning if not present. This patch fixes the wrong ordering.

---
 modules.d/90multipath/module-setup.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
modules.d/90multipath/module-setup.sh +3 -2
index 1676798..db91296 100755
@@ -21,13 +21,14 @@ majmin_to_mpath_dev() {
 # called by dracut
 check() {
     local _rootdev
-    # if there's no multipath binary, no go.
-    require_binaries multipath || return 1
 
     [[ $hostonly ]] || [[ $mount_needs ]] && {
         for_each_host_dev_and_slaves is_mpath || return 255
     }
 
+    # if there's no multipath binary, no go.
+    require_binaries multipath || return 1
+
     return 0
 }
 
Signature · 1 line
2.1.4
#14 lore raw
In reply to a message not in the archive
Quoted 11 lines · Thomas Renninger

These are network related patches to get SuSE and mainline dracut sources closer together again.

If format, etc is ok, some more patches from other areas will follow.

I added a link to public bugzilla entries.

References like bnc# and bsc# point to restricted SLE bugzilla entries. If these patches need discussion, I should be able to add you to the bug or copy relevant parts to public, so this info is still needed.

Quoted 6 lines

Would be great to see these patches pushed into mainline git repo soon.

Thanks,

Thomas

Thanks! Will review the next days.