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