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

Now in dracut only default gateway is added. However as below you can
see, if a service target is in different subnet with default gateway,
a subnet route to that service target has to be added into dracut.

sh> ip route show
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

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. For
now the PREFIX/nexthop/output_device is enough to route.

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 fef13b3..e2ab8a7 100644
--- a/dracut.cmdline.7.asc
+++ b/dracut.cmdline.7.asc
@@ -536,6 +536,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] 5+ messages in thread

* Re: [Patch v3] network: add static route support
       [not found] ` <1404442881-5654-1-git-send-email-bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2014-07-04  3:03   ` Baoquan He
  2014-07-15  2:46   ` Baoquan He
  1 sibling, 0 replies; 5+ messages in thread
From: Baoquan He @ 2014-07-04  3:03 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA, harald-H+wXaHxf7aLQT0dZR+AlfA
  Cc: dyoung-H+wXaHxf7aLQT0dZR+AlfA, vgoyal-H+wXaHxf7aLQT0dZR+AlfA

Hi Harald,

I have changed the error of documentation you pointed out. Do you like
this patch? Or you think it's better to use semicolon as separator?

Thanks
Baoquan

On 07/04/14 at 11:01am, Baoquan He wrote:
> Now in dracut only default gateway is added. However as below you can
> see, if a service target is in different subnet with default gateway,
> a subnet route to that service target has to be added into dracut.
> 
> sh> ip route show
> 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
> 
> 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. For
> now the PREFIX/nexthop/output_device is enough to route.
> 
> 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 fef13b3..e2ab8a7 100644
> --- a/dracut.cmdline.7.asc
> +++ b/dracut.cmdline.7.asc
> @@ -536,6 +536,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] 5+ messages in thread

* Re: [Patch v3] network: add static route support
       [not found] ` <1404442881-5654-1-git-send-email-bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  2014-07-04  3:03   ` Baoquan He
@ 2014-07-15  2:46   ` Baoquan He
       [not found]     ` <20140715024612.GA1787-je1gSBvt1TeLcxizHhUEZR/sF2h8X+2i0E9HWUfgJXw@public.gmane.org>
  1 sibling, 1 reply; 5+ messages in thread
From: Baoquan He @ 2014-07-15  2:46 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA, harald-H+wXaHxf7aLQT0dZR+AlfA
  Cc: dyoung-H+wXaHxf7aLQT0dZR+AlfA, vgoyal-H+wXaHxf7aLQT0dZR+AlfA

Hi Harald,

Do you have any suggestion on this patch? Or you have any other better
thoughts?

Thanks
Baoquan

On 07/04/14 at 11:01am, Baoquan He wrote:
> Now in dracut only default gateway is added. However as below you can
> see, if a service target is in different subnet with default gateway,
> a subnet route to that service target has to be added into dracut.
> 
> sh> ip route show
> 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
> 
> 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. For
> now the PREFIX/nexthop/output_device is enough to route.
> 
> 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 fef13b3..e2ab8a7 100644
> --- a/dracut.cmdline.7.asc
> +++ b/dracut.cmdline.7.asc
> @@ -536,6 +536,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
> 
> --
> To unsubscribe from this list: send the line "unsubscribe initramfs" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [Patch v3] network: add static route support
       [not found]     ` <20140715024612.GA1787-je1gSBvt1TeLcxizHhUEZR/sF2h8X+2i0E9HWUfgJXw@public.gmane.org>
@ 2014-07-22 12:31       ` Harald Hoyer
       [not found]         ` <53CE5994.8020407-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Harald Hoyer @ 2014-07-22 12:31 UTC (permalink / raw)
  To: Baoquan He, initramfs-u79uwXL29TY76Z2rM5mHXA
  Cc: dyoung-H+wXaHxf7aLQT0dZR+AlfA, vgoyal-H+wXaHxf7aLQT0dZR+AlfA

On 15.07.2014 04:46, Baoquan He wrote:
> Hi Harald,
> 
> Do you have any suggestion on this patch? Or you have any other better
> thoughts?
> 
> Thanks
> Baoquan

Thanks! Pushed a version with ":" and bracket for IPV6

       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.

           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

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

* Re: [Patch v3] network: add static route support
       [not found]         ` <53CE5994.8020407-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2014-07-23  2:10           ` Baoquan He
  0 siblings, 0 replies; 5+ messages in thread
From: Baoquan He @ 2014-07-23  2:10 UTC (permalink / raw)
  To: Harald Hoyer
  Cc: initramfs-u79uwXL29TY76Z2rM5mHXA, dyoung-H+wXaHxf7aLQT0dZR+AlfA,
	vgoyal-H+wXaHxf7aLQT0dZR+AlfA

On 07/22/14 at 02:31pm, Harald Hoyer wrote:
> On 15.07.2014 04:46, Baoquan He wrote:
> > Hi Harald,
> > 
> > Do you have any suggestion on this patch? Or you have any other better
> > thoughts?
> > 
> > Thanks
> > Baoquan
> 
> Thanks! Pushed a version with ":" and bracket for IPV6
> 
>        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.
> 
>            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


Thanks, Harald. It's gorgeous. And it includes the cases which only have
nexthop address and output interface, that's complete and makes sense.

Thanks
Baoquan

> 

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

end of thread, other threads:[~2014-07-23  2:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-04  3:01 [Patch v3] network: add static route support Baoquan He
     [not found] ` <1404442881-5654-1-git-send-email-bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-07-04  3:03   ` Baoquan He
2014-07-15  2:46   ` Baoquan He
     [not found]     ` <20140715024612.GA1787-je1gSBvt1TeLcxizHhUEZR/sF2h8X+2i0E9HWUfgJXw@public.gmane.org>
2014-07-22 12:31       ` Harald Hoyer
     [not found]         ` <53CE5994.8020407-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-07-23  2:10           ` 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.