dracut/0010-network-add-rd.route-parameter.patch
Harald Hoyer e09d6b8a2a dracut-038-14.git20140724
- fixed lvm modules issues
Resolves: rhbz#1118890
 fixed vlan issues
- fixed prelink for FIPS
- new rd.route parameter
- more ARM modules
2014-07-24 14:44:21 +02:00

126 lines
4.5 KiB
Diff

From 7b46244bb94e3dfd635a8d222044ae7fc920240d Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Tue, 22 Jul 2014 11:03:56 +0200
Subject: [PATCH] network: add rd.route parameter
---
dracut.cmdline.7.asc | 15 +++++++++++++-
modules.d/40network/net-lib.sh | 42 ++++++++++++++++++++++++++++++++++++++++
modules.d/45ifcfg/write-ifcfg.sh | 3 +++
3 files changed, 59 insertions(+), 1 deletion(-)
diff --git a/dracut.cmdline.7.asc b/dracut.cmdline.7.asc
index fef13b3..f66bace 100644
--- a/dracut.cmdline.7.asc
+++ b/dracut.cmdline.7.asc
@@ -493,6 +493,19 @@ WARNING: Do **not** use the default kernel naming scheme for the interface name,
as it can conflict with the kernel names. So, don't use "eth[0-9]+" for the
interface name. Better name it "bootnet" or "bluesocket".
+**rd.route=**__<net>__/__<netmask>__:__<gateway>__[:__<interface>__]::
+ Add a static route with route options, which are separated by a colon.
+ IPv6 addresses have to be put in brackets.
++
+[listing]
+.Example
+--
+ rd.route=192.168.200.0/24:192.168.100.222:ens10
+ rd.route=192.168.200.0/24:192.168.100.222
+ rd.route=192.168.200.0/24::ens10
+ rd.route=[2001:DB8:3::/8]:[2001:DB8:2::1]:ens10
+--
+
**bootdev=**__<interface>__::
specify network interface to use routing and netroot information from.
Required if multiple ip= lines are used.
@@ -540,7 +553,7 @@ NFS
~~~
**root=**\[_<server-ip>_:]__<root-dir>__[:__<nfs-options>__]::
mount nfs share from <server-ip>:/<root-dir>, if no server-ip is given, use
- dhcp next_server. if server-ip is an IPv6 address it has to be put in
+ dhcp next_server. If server-ip is an IPv6 address it has to be put in
brackets, e.g. [2001:DB8::1]. NFS options can be appended with the prefix
":" or "," and are seperated by ",".
diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh
index f8e1179..c118c53 100755
--- a/modules.d/40network/net-lib.sh
+++ b/modules.d/40network/net-lib.sh
@@ -89,6 +89,7 @@ ifdown() {
setup_net() {
local netif="$1" f="" gw_ip="" netroot_ip="" iface="" IFACES=""
+ local _p
[ -e /tmp/net.$netif.did-setup ] && return
[ -e /sys/class/net/$netif/address ] && \
[ -e /tmp/net.$(cat /sys/class/net/$netif/address).did-setup ] && return
@@ -103,6 +104,20 @@ setup_net() {
[ -e /tmp/net.$netif.resolv.conf ] && \
cp -f /tmp/net.$netif.resolv.conf /etc/resolv.conf
+ # add static route
+ for _p in $(getargs rd.route); do
+ route_to_var "$_p" || continue
+ [ -n "$route_dev" ] && [ "$route_dev" != "$netif"] && continue
+ ip route add "$route_mask" ${route_gw:+via "$route_gw"} ${route_dev:+dev "$route_dev"}
+ if strstr ":" "$route_mask"; then
+ printf -- "%s\n" "$route_mask ${route_gw:+via $route_gw} ${route_dev:+dev $route_dev}" \
+ > /tmp/net.route6."$netif"
+ else
+ printf -- "%s\n" "$route_mask ${route_gw:+via $route_gw} ${route_dev:+dev $route_dev}" \
+ > /tmp/net.route."$netif"
+ fi
+ done
+
# Handle STP Timeout: arping the default gateway.
# (or the root server, if a) it's local or b) there's no gateway.)
# Note: This assumes that if no router is present the
@@ -400,6 +415,33 @@ ip_to_var() {
fi
}
+route_to_var() {
+ local v=${1}:
+ local i
+ set --
+ while [ -n "$v" ]; do
+ if [ "${v#\[*:*:*\]:}" != "$v" ]; then
+ # handle IPv6 address
+ i="${v%%\]:*}"
+ i="${i##\[}"
+ set -- "$@" "$i"
+ v=${v#\[$i\]:}
+ else
+ set -- "$@" "${v%%:*}"
+ v=${v#*:}
+ fi
+ done
+
+ unset route_mask route_gw route_dev
+ case $# in
+ 2) [ -n "$1" ] && route_mask="$1"; [ -n "$2" ] && route_gw="$2"
+ return 0;;
+ 3) [ -n "$1" ] && route_mask="$1"; [ -n "$2" ] && route_gw="$2"; [ -n "$3" ] && route_dev="$3"
+ return 0;;
+ *) return 1;;
+ esac
+}
+
parse_ifname_opts() {
local IFS=:
set $1
diff --git a/modules.d/45ifcfg/write-ifcfg.sh b/modules.d/45ifcfg/write-ifcfg.sh
index 803ae8e..7e301de 100755
--- a/modules.d/45ifcfg/write-ifcfg.sh
+++ b/modules.d/45ifcfg/write-ifcfg.sh
@@ -268,6 +268,9 @@ for netup in /tmp/net.*.did-setup ; do
echo "DNS${i}=\"${ns}\"" >> /tmp/ifcfg/ifcfg-$netif
i=$((i+1))
done
+
+ [ -f /tmp/net.route6."$netif" ] && cp /tmp/net.route6."$netif" /tmp/ifcfg/route6-"$netif"
+ [ -f /tmp/net.route."$netif" ] && cp /tmp/net.route."$netif" /tmp/ifcfg/route-"$netif"
done
# Pass network opts