File 0131-40network-handle-prefixed-IP-addresses-correctly.patch of Package dracut.12460

From fc03504435d8bf5d0a31b8c566c2e783fbb96ec6 Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Wed, 30 Jul 2014 10:28:27 +0200
Subject: 40network: handle prefixed IP addresses correctly

If an IP address is given with prefix length ifup should be
parsing that correctly. And we should assume a prefix length
of /64 for IPv6 resp /24 for IPv4 if none were given.

References: bnc#880108

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 modules.d/40network/ifup.sh | 8 ++++++++
 1 file changed, 8 insertions(+)

Index: dracut-044/modules.d/40network/ifup.sh
===================================================================
--- dracut-044.orig/modules.d/40network/ifup.sh
+++ dracut-044/modules.d/40network/ifup.sh
@@ -241,7 +241,13 @@ do_static() {
     [ -n "$macaddr" ] && ip link set address $macaddr dev $netif
     [ -n "$mtu" ] && ip link set mtu $mtu dev $netif
     [ -n "$mask" -a -z "$prefix" ] && prefix=$(mask_to_prefix $mask)
-    if strglobin $ip '*:*:*'; then
+    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/$prefix ${srv:+peer $srv} dev $netif
         wait_for_ipv6_dad $netif
@@ -250,6 +256,8 @@ do_static() {
             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/$prefix ${srv:+peer $srv} brd + dev $netif
     fi
openSUSE Build Service is sponsored by