Blame SOURCES/0539-40network-introduce-ip-either6-option.patch

18971c
From 26273649dcfbc095c8e9dbc0f65bb02fd90ee510 Mon Sep 17 00:00:00 2001
18971c
From: Pingfan Liu <piliu@redhat.com>
18971c
Date: Tue, 24 Apr 2018 16:41:21 +0800
18971c
Subject: [PATCH] 40network: introduce ip=either6 option
18971c
18971c
In kdump, if dump-target is ssh on ipv6, we need to sync until ipv6 addr
18971c
is ready. Currently ip=auto6/dhcp6 provides such function. But in 1st kernel,
18971c
it is hard to know whether the ipv6 addr is got by dhcpv6 or SLAAC.
18971c
E.g ifcfg-eth* contains DHCPV6C=yes direction, but there is no dhcpv6
18971c
server in the network, and then after the system is up, the user
18971c
echo 1 > /proc/sys/net/ipv6/conf/eth0/autoconf && accept_ra by manual
18971c
to obtain a ipv6 addr. Or vice.
18971c
So this patch suggests to make dhcpv6 as auto6 fallback
18971c
18971c
Signed-off-by: Pingfan Liu <piliu@redhat.com>
18971c
18971c
Cherry-picked from: 67354ee
18971c
Resolves: #1582398
18971c
---
18971c
 dracut.cmdline.7.asc                 | 4 +++-
18971c
 modules.d/40network/ifup.sh          | 6 +++++-
18971c
 modules.d/40network/net-lib.sh       | 4 ++--
18971c
 modules.d/40network/parse-ip-opts.sh | 1 +
18971c
 4 files changed, 11 insertions(+), 4 deletions(-)
18971c
18971c
diff --git a/dracut.cmdline.7.asc b/dracut.cmdline.7.asc
18971c
index 45902fa9..1204aeb2 100644
18971c
--- a/dracut.cmdline.7.asc
18971c
+++ b/dracut.cmdline.7.asc
18971c
@@ -449,7 +449,7 @@ USB Android phone::
18971c
 * enp0s29u1u2
18971c
 =====================
18971c
 
18971c
-**ip=**__{dhcp|on|any|dhcp6|auto6}__::
18971c
+**ip=**__{dhcp|on|any|dhcp6|auto6|either6}__::
18971c
     dhcp|on|any::: get ip from dhcp server from all interfaces. If root=dhcp,
18971c
     loop sequentially through all interfaces (eth0, eth1, ...) and use the first
18971c
     with a valid DHCP root-path.
18971c
@@ -458,6 +458,8 @@ USB Android phone::
18971c
 
18971c
     dhcp6::: IPv6 DHCP
18971c
 
18971c
+    either6::: if auto6 fails, then dhcp6
18971c
+
18971c
 **ip=**__<interface>__:__{dhcp|on|any|dhcp6|auto6}__[:[__<mtu>__][:__<macaddr>__]]::
18971c
     This parameter can be specified multiple times.
18971c
 +
18971c
diff --git a/modules.d/40network/ifup.sh b/modules.d/40network/ifup.sh
18971c
index 9ed48155..b3631648 100755
18971c
--- a/modules.d/40network/ifup.sh
18971c
+++ b/modules.d/40network/ifup.sh
18971c
@@ -76,6 +76,7 @@ load_ipv6() {
18971c
 }
18971c
 
18971c
 do_ipv6auto() {
18971c
+    local ret
18971c
     load_ipv6
18971c
     echo 0 > /proc/sys/net/ipv6/conf/$netif/forwarding
18971c
     echo 1 > /proc/sys/net/ipv6/conf/$netif/accept_ra
18971c
@@ -84,10 +85,11 @@ do_ipv6auto() {
18971c
     [ -n "$macaddr" ] && ip link set address $macaddr dev $netif
18971c
     [ -n "$mtu" ] && ip link set mtu $mtu dev $netif
18971c
     wait_for_ipv6_auto $netif
18971c
+    ret=$?
18971c
 
18971c
     [ -n "$hostname" ] && echo "echo $hostname > /proc/sys/kernel/hostname" > /tmp/net.$netif.hostname
18971c
 
18971c
-    return 0
18971c
+    return $ret
18971c
 }
18971c
 
18971c
 # Handle static ip configuration
18971c
@@ -393,6 +395,8 @@ for p in $(getargs ip=); do
18971c
                 do_dhcp -6 ;;
18971c
             auto6)
18971c
                 do_ipv6auto ;;
18971c
+            either6)
18971c
+                do_ipv6auto || do_dhcp -6 ;;
18971c
             *)
18971c
                 do_static ;;
18971c
         esac
18971c
diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh
18971c
index 23f2f9ff..9e87aeab 100755
18971c
--- a/modules.d/40network/net-lib.sh
18971c
+++ b/modules.d/40network/net-lib.sh
18971c
@@ -445,7 +445,7 @@ ip_to_var() {
18971c
     fi
18971c
 
18971c
     if [ $# -eq 1 ]; then
18971c
-        # format: ip={dhcp|on|any|dhcp6|auto6}
18971c
+        # format: ip={dhcp|on|any|dhcp6|auto6|either6}
18971c
         # or
18971c
         #         ip=<ipv4-address> means anaconda-style static config argument cluster
18971c
         autoconf="$1"
18971c
@@ -472,7 +472,7 @@ ip_to_var() {
18971c
         return 0
18971c
     fi
18971c
 
18971c
-    if [ "$2" = "dhcp" -o "$2" = "on" -o "$2" = "any" -o "$2" = "dhcp6" -o "$2" = "auto6" ]; then
18971c
+    if [ "$2" = "dhcp" -o "$2" = "on" -o "$2" = "any" -o "$2" = "dhcp6" -o "$2" = "auto6" -o "$2" = "either6" ]; then
18971c
         # format: ip=<interface>:{dhcp|on|any|dhcp6|auto6}[:[<mtu>][:<macaddr>]]
18971c
         [ -n "$1" ] && dev="$1"
18971c
         [ -n "$2" ] && autoconf="$2"
18971c
diff --git a/modules.d/40network/parse-ip-opts.sh b/modules.d/40network/parse-ip-opts.sh
18971c
index 68afe91b..3d1e95a6 100755
18971c
--- a/modules.d/40network/parse-ip-opts.sh
18971c
+++ b/modules.d/40network/parse-ip-opts.sh
18971c
@@ -78,6 +78,7 @@ for p in $(getargs ip=); do
18971c
                     die "Sorry, automatic calculation of netmask is not yet supported"
18971c
                 ;;
18971c
             auto6);;
18971c
+            either6);;
18971c
             dhcp|dhcp6|on|any) \
18971c
                 #[ -n "$NEEDBOOTDEV" ] && [ -z "$dev" ] && \
18971c
                 #    die "Sorry, 'ip=$p' does not make sense for multiple interface configurations"