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