All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch v2] network: add static route support
@ 2014-06-27  8:08 Baoquan He
       [not found] ` <1403856480-13745-1-git-send-email-bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 7+ messages in thread
From: Baoquan He @ 2014-06-27  8:08 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA
  Cc: harald-H+wXaHxf7aLQT0dZR+AlfA, dyoung-H+wXaHxf7aLQT0dZR+AlfA,
	vgoyal-H+wXaHxf7aLQT0dZR+AlfA, Baoquan He

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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [Patch v2] network: add static route support
       [not found] ` <1403856480-13745-1-git-send-email-bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2014-06-27  8:34   ` Baoquan He
  2014-06-27  8:57   ` Harald Hoyer
  1 sibling, 0 replies; 7+ messages in thread
From: Baoquan He @ 2014-06-27  8:34 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA
  Cc: harald-H+wXaHxf7aLQT0dZR+AlfA, dyoung-H+wXaHxf7aLQT0dZR+AlfA,
	vgoyal-H+wXaHxf7aLQT0dZR+AlfA, mmilgram-H+wXaHxf7aLQT0dZR+AlfA

CC Marc.

On 06/27/14 at 04:08pm, Baoquan He wrote:
> 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
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Patch v2] network: add static route support
       [not found] ` <1403856480-13745-1-git-send-email-bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  2014-06-27  8:34   ` Baoquan He
@ 2014-06-27  8:57   ` Harald Hoyer
       [not found]     ` <53AD3206.2020601-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  1 sibling, 1 reply; 7+ messages in thread
From: Harald Hoyer @ 2014-06-27  8:57 UTC (permalink / raw)
  To: Baoquan He, initramfs-u79uwXL29TY76Z2rM5mHXA
  Cc: dyoung-H+wXaHxf7aLQT0dZR+AlfA, vgoyal-H+wXaHxf7aLQT0dZR+AlfA


"_" or ":" as a seperator??? code and documentation seem to differ

Can we restrict this to network gateway dev ?

On 27.06.2014 10:08, Baoquan He wrote:
> 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
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Patch v2] network: add static route support
       [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>
  0 siblings, 1 reply; 7+ messages in thread
From: Baoquan He @ 2014-06-27 10:33 UTC (permalink / raw)
  To: Harald Hoyer
  Cc: initramfs-u79uwXL29TY76Z2rM5mHXA, dyoung-H+wXaHxf7aLQT0dZR+AlfA,
	vgoyal-H+wXaHxf7aLQT0dZR+AlfA, mmilgram-H+wXaHxf7aLQT0dZR+AlfA

On 06/27/14 at 10:57am, Harald Hoyer wrote:
> 
> "_" or ":" as a seperator??? code and documentation seem to differ

Sorry, I tried to keep consitent with other parameter which use
semicolon as separator when add parameter description, then I realized
what you suggested using underscore is more meaningful because of ipv6.
So here forgot changing the example.

> 
> Can we restrict this to network gateway dev ?

I think it cann't be. This special case is raised by Marc, the scenario
is in kdump kernel below 3 services need be done and go through
different NIC. Though default gateway is setup for one NIC, other
service need route to direct.

1)NFS or SSH or iscsi host
2)cluster heartbeat host
3)DNS resolver

> 
> On 27.06.2014 10:08, Baoquan He wrote:
> > 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"

Here should be:

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
> > 
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Patch v2] network: add static route support
       [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>
  0 siblings, 1 reply; 7+ messages in thread
From: Harald Hoyer @ 2014-06-27 11:24 UTC (permalink / raw)
  To: Baoquan He
  Cc: initramfs-u79uwXL29TY76Z2rM5mHXA, dyoung-H+wXaHxf7aLQT0dZR+AlfA,
	vgoyal-H+wXaHxf7aLQT0dZR+AlfA, mmilgram-H+wXaHxf7aLQT0dZR+AlfA

On 27.06.2014 12:33, Baoquan He wrote:> On 06/27/14 at 10:57am, Harald Hoyer wrote:
>>
>> "_" or ":" as a seperator??? code and documentation seem to differ
>
> Sorry, I tried to keep consitent with other parameter which use
> semicolon as separator when add parameter description, then I realized
> what you suggested using underscore is more meaningful because of ipv6.
> So here forgot changing the example.
>
>>
>> Can we restrict this to network gateway dev ?
>
> I think it cann't be. This special case is raised by Marc, the scenario
> is in kdump kernel below 3 services need be done and go through
> different NIC. Though default gateway is setup for one NIC, other
> service need route to direct.
>
> 1)NFS or SSH or iscsi host
> 2)cluster heartbeat host
> 3)DNS resolver

huh? Isn't a network with mask 32 a host route. So, I think network/gateway/dev
should be enough.

rd.route=192.168.100.222/32_192.168.1.1_ens10

>
>>
>> On 27.06.2014 10:08, Baoquan He wrote:
>>> 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"
>
> Here should be:
>
> rd.route="192.168.200.0/24_via_192.168.100.222_dev_ens10"
>


in theory we could also use ":" and for IPv6 require [] to be consistent.

rd.route=192.168.100.222/32:192.168.1.1:ens10
rd.route=[2001:DB7::]:[2001:DB8::1]:ens10


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Patch v2] network: add static route support
       [not found]             ` <53AD5473.3020707-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2014-06-27 12:31               ` Baoquan He
  2014-06-27 14:23               ` Baoquan He
  1 sibling, 0 replies; 7+ messages in thread
From: Baoquan He @ 2014-06-27 12:31 UTC (permalink / raw)
  To: Harald Hoyer
  Cc: initramfs-u79uwXL29TY76Z2rM5mHXA, dyoung-H+wXaHxf7aLQT0dZR+AlfA,
	vgoyal-H+wXaHxf7aLQT0dZR+AlfA, mmilgram-H+wXaHxf7aLQT0dZR+AlfA

On 06/27/14 at 01:24pm, Harald Hoyer wrote:
> On 27.06.2014 12:33, Baoquan He wrote:> On 06/27/14 at 10:57am, Harald Hoyer wrote:
> >>
> >> "_" or ":" as a seperator??? code and documentation seem to differ
> >
> > Sorry, I tried to keep consitent with other parameter which use
> > semicolon as separator when add parameter description, then I realized
> > what you suggested using underscore is more meaningful because of ipv6.
> > So here forgot changing the example.
> >
> >>
> >> Can we restrict this to network gateway dev ?
> >
> > I think it cann't be. This special case is raised by Marc, the scenario
> > is in kdump kernel below 3 services need be done and go through
> > different NIC. Though default gateway is setup for one NIC, other
> > service need route to direct.
> >
> > 1)NFS or SSH or iscsi host
> > 2)cluster heartbeat host
> > 3)DNS resolver
> 
> huh? Isn't a network with mask 32 a host route. So, I think network/gateway/dev
> should be enough.
> 
> rd.route=192.168.100.222/32_192.168.1.1_ens10

This is the test environment for this patch. Default gateway goes
through eth0, while the kdump target (192.168.200.222) goes through
ens10. These 2 NICs are not in the same subnet. For guiding data path, as
you said, network/gateway/dev is truly enough. 

default via 192.168.122.1 dev eth0  proto static  metric 1024 
192.168.200.0/24 via 192.168.100.222 dev ens10  proto static  metric 1

> 
> >
> >>
> >> On 27.06.2014 10:08, Baoquan He wrote:
> >>> 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"
> >
> > Here should be:
> >
> > rd.route="192.168.200.0/24_via_192.168.100.222_dev_ens10"
> >
> 
> 
> in theory we could also use ":" and for IPv6 require [] to be consistent.
> 
> rd.route=192.168.100.222/32:192.168.1.1:ens10
> rd.route=[2001:DB7::]:[2001:DB8::1]:ens10
Ah, yeah, this works. 

But using "_" as you suggested before is much easier, code is very
simple and understandable.


> 
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Patch v2] network: add static route support
       [not found]             ` <53AD5473.3020707-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  2014-06-27 12:31               ` Baoquan He
@ 2014-06-27 14:23               ` Baoquan He
  1 sibling, 0 replies; 7+ messages in thread
From: Baoquan He @ 2014-06-27 14:23 UTC (permalink / raw)
  To: Harald Hoyer
  Cc: initramfs-u79uwXL29TY76Z2rM5mHXA, dyoung-H+wXaHxf7aLQT0dZR+AlfA,
	vgoyal-H+wXaHxf7aLQT0dZR+AlfA, mmilgram-H+wXaHxf7aLQT0dZR+AlfA

On 06/27/14 at 01:24pm, Harald Hoyer wrote:
> On 27.06.2014 12:33, Baoquan He wrote:> On 06/27/14 at 10:57am, Harald Hoyer wrote:
> >>
> >> "_" or ":" as a seperator??? code and documentation seem to differ
> >
> > Sorry, I tried to keep consitent with other parameter which use
> > semicolon as separator when add parameter description, then I realized
> > what you suggested using underscore is more meaningful because of ipv6.
> > So here forgot changing the example.
> >
> >>
> >> Can we restrict this to network gateway dev ?
> >
> > I think it cann't be. This special case is raised by Marc, the scenario
> > is in kdump kernel below 3 services need be done and go through
> > different NIC. Though default gateway is setup for one NIC, other
> > service need route to direct.
> >
> > 1)NFS or SSH or iscsi host
> > 2)cluster heartbeat host
> > 3)DNS resolver
> 
> huh? Isn't a network with mask 32 a host route. So, I think network/gateway/dev
> should be enough.
> 
> rd.route=192.168.100.222/32_192.168.1.1_ens10

Well, maybe the patch log is misleading. Usually host route need not be
added, because it's added automatically by network stack, host route
means a target connected directly by cable. In this pathc, only subnet
route need be added specifically. Surely, the
prefix/nexthop/output_device also are enough.

> 
> >
> >>
> >> On 27.06.2014 10:08, Baoquan He wrote:
> >>> 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"
> >
> > Here should be:
> >
> > rd.route="192.168.200.0/24_via_192.168.100.222_dev_ens10"
> >
> 
> 
> in theory we could also use ":" and for IPv6 require [] to be consistent.
> 
> rd.route=192.168.100.222/32:192.168.1.1:ens10
> rd.route=[2001:DB7::]:[2001:DB8::1]:ens10

Originally I used ":", later changed to "_". In this situation, dracut
only need get the string from rd.route and replace the separator with
space, nothing more need be considered. The content of rd.route is
guaranteed by user, if they can execute "ip route add route_string", the
route_string which will be transfered by replacing space with "_" can be
added in dracut shell script. Then dracut needn't care it's a ipv4 or
ipv6, whether prefix/nexthop/output_device is enough or special route
options are needed, just add it into route table.

> 
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-06-27 14:23 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-27  8:08 [Patch v2] network: add static route support Baoquan He
     [not found] ` <1403856480-13745-1-git-send-email-bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-06-27  8:34   ` 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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.