mkinitrd unification across distributions
 help / color / mirror / Atom feed
From: Baoquan He <bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: harald-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	dyoung-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	vgoyal-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	Baoquan He <bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Subject: [Patch v2] network: add static route support
Date: Fri, 27 Jun 2014 16:08:00 +0800	[thread overview]
Message-ID: <1403856480-13745-1-git-send-email-bhe@redhat.com> (raw)

User may specify static route for a target address which is different
than default gateway, hence static route need be added.

Now add a cmdline parameter rd.route="" and the related operation to
parse it. User can add static route by specify it in cmdline like:

rd.route="192.168.200.0/24:via:192.168.100.222:dev:ens10"
---
 dracut.cmdline.7.asc           | 8 ++++++++
 modules.d/40network/net-lib.sh | 9 +++++++++
 2 files changed, 17 insertions(+)

diff --git a/dracut.cmdline.7.asc b/dracut.cmdline.7.asc
index 10550ee..87acc54 100644
--- a/dracut.cmdline.7.asc
+++ b/dracut.cmdline.7.asc
@@ -528,6 +528,14 @@ interface name. Better name it "bootnet" or "bluesocket".
     list of physical (ethernet) interfaces. Bridge without parameters assumes
     bridge=br0:eth0
 
+**rd.route=**__<route-options>__::
+    Add static route to route table with route options which are separated by
+    underscore. Among them some are necessary, such as the destination prefix
+    of the route, the address of the nexthop route, the output device name.
+    It's like
+    rd.route=192.168.200.0/24:via:192.168.100.222:dev:ens10
+
+
 NFS
 ~~~
 **root=**\[_<server-ip>_:]__<root-dir>__[:__<nfs-options>__]::
diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh
index a82f1a8..b428abb 100755
--- a/modules.d/40network/net-lib.sh
+++ b/modules.d/40network/net-lib.sh
@@ -103,6 +103,15 @@ setup_net() {
     [ -e /tmp/net.$netif.resolv.conf ] && \
         cp -f /tmp/net.$netif.resolv.conf /etc/resolv.conf
 
+    # add static route
+    local _p _r
+    for _p in $(getargs rd.route=); do
+        if strstr "$_p" "$netif"; then
+            _r=${_p//'_'/' '}
+            ip route add $_r
+        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
-- 
1.9.0

             reply	other threads:[~2014-06-27  8:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-27  8:08 Baoquan He [this message]
     [not found] ` <1403856480-13745-1-git-send-email-bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-06-27  8:34   ` [Patch v2] network: add static route support Baoquan He
2014-06-27  8:57   ` Harald Hoyer
     [not found]     ` <53AD3206.2020601-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-06-27 10:33       ` Baoquan He
     [not found]         ` <20140627103335.GA12159-je1gSBvt1Tcx0jIIkfS+Ph/sF2h8X+2i0E9HWUfgJXw@public.gmane.org>
2014-06-27 11:24           ` Harald Hoyer
     [not found]             ` <53AD5473.3020707-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-06-27 12:31               ` Baoquan He
2014-06-27 14:23               ` Baoquan He

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1403856480-13745-1-git-send-email-bhe@redhat.com \
    --to=bhe-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
    --cc=dyoung-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=harald-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=initramfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=vgoyal-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox