* [PATCH 1/2] network: add ipcalc for netmask calculation
@ 2014-04-28 9:41 Baoquan He
[not found] ` <1398678111-13601-1-git-send-email-bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
0 siblings, 1 reply; 13+ messages in thread
From: Baoquan He @ 2014-04-28 9:41 UTC (permalink / raw)
To: harald-H+wXaHxf7aLQT0dZR+AlfA
Cc: initramfs-u79uwXL29TY76Z2rM5mHXA, Baoquan He
If static route is supported, the route prefix need be calculated
by netmask provided by user. So add it now.
Signed-off-by: Baoquan He <bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
modules.d/40network/module-setup.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules.d/40network/module-setup.sh b/modules.d/40network/module-setup.sh
index 1df4174..dbe5205 100755
--- a/modules.d/40network/module-setup.sh
+++ b/modules.d/40network/module-setup.sh
@@ -72,7 +72,7 @@ installkernel() {
# called by dracut
install() {
local _arch _i _dir
- inst_multiple ip arping dhclient sed
+ inst_multiple ip arping dhclient ipcalc sed
inst_multiple -o ping ping6
inst_multiple -o brctl
inst_multiple -o teamd teamdctl teamnl
--
1.8.5.3
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 2/2] network: add static route support
[not found] ` <1398678111-13601-1-git-send-email-bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2014-04-28 9:41 ` Baoquan He
[not found] ` <1398678111-13601-2-git-send-email-bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
0 siblings, 1 reply; 13+ messages in thread
From: Baoquan He @ 2014-04-28 9:41 UTC (permalink / raw)
To: harald-H+wXaHxf7aLQT0dZR+AlfA
Cc: initramfs-u79uwXL29TY76Z2rM5mHXA, Baoquan He
User may specify static route for a target address which is different
than default gateway. The static route file could be like below:
192.168.200.222 via 192.168.100.222 dev eth0
Or
ADDRESS0=192.168.200.0
NETMASK0=255.255.255.0
GATEWAY0=192.168.100.222
In this patch, port the static route hanling from ifup-routes of initscript
component.
Signed-off-by: Baoquan He <bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
modules.d/40network/net-lib.sh | 42 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh
index d53e1a6..a9c647a 100755
--- a/modules.d/40network/net-lib.sh
+++ b/modules.d/40network/net-lib.sh
@@ -103,6 +103,16 @@ setup_net() {
[ -e /tmp/net.$netif.resolv.conf ] && \
cp -f /tmp/net.$netif.resolv.conf /etc/resolv.conf
+ #add static route if exist
+ f="/etc/route-$netif"
+ if [ -e "$f" ]; then
+ if grep -Eq '^[[:space:]]*ADDRESS[0-9]+=' $f ; then
+ handle_file $f $netif
+ else
+ handle_ip_file $f
+ fi
+ fi
+
# 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
@@ -517,6 +527,38 @@ find_iface_with_link() {
return 1
}
+MATCH='^[[:space:]]*(\#.*)?$'
+
+handle_file () {
+ . $1
+ routenum=0
+ while [ "x$(eval echo '$'ADDRESS$routenum)x" != "xx" ]; do
+ eval $(ipcalc -p $(eval echo '$'ADDRESS$routenum) $(eval echo '$'NETMASK$routenum))
+ line="$(eval echo '$'ADDRESS$routenum)/$PREFIX"
+ if [ "x$(eval echo '$'GATEWAY$routenum)x" != "xx" ]; then
+ line="$line via $(eval echo '$'GATEWAY$routenum)"
+ fi
+ line="$line dev $2"
+ /sbin/ip route add $line
+ routenum=$(($routenum+1))
+ done
+}
+
+handle_ip_file() {
+ local f t type= file=$1 proto="-4"
+ f=${file##*/}
+ t=${f%%-*}
+ type=${t%%6}
+ if [ "$type" != "$t" ]; then
+ proto="-6"
+ fi
+ { cat "$file" ; echo ; } | while read line; do
+ if [[ ! "$line" =~ $MATCH ]]; then
+ /sbin/ip $proto $type add $line
+ fi
+ done
+}
+
is_persistent_ethernet_name() {
case "$1" in
# udev persistent interface names
--
1.8.5.3
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 2/2] network: add static route support
[not found] ` <1398678111-13601-2-git-send-email-bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2014-04-28 10:05 ` Baoquan He
2014-05-05 7:12 ` [PATCH v2 " Baoquan He
1 sibling, 0 replies; 13+ messages in thread
From: Baoquan He @ 2014-04-28 10:05 UTC (permalink / raw)
To: harald-H+wXaHxf7aLQT0dZR+AlfA
Cc: initramfs-u79uwXL29TY76Z2rM5mHXA, milgram-c3HgaEZScxU
CC Marc
On 04/28/14 at 05:41pm, Baoquan He wrote:
> User may specify static route for a target address which is different
> than default gateway. The static route file could be like below:
>
> 192.168.200.222 via 192.168.100.222 dev eth0
>
> Or
>
> ADDRESS0=192.168.200.0
> NETMASK0=255.255.255.0
> GATEWAY0=192.168.100.222
>
> In this patch, port the static route hanling from ifup-routes of initscript
> component.
>
> Signed-off-by: Baoquan He <bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> ---
> modules.d/40network/net-lib.sh | 42 ++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 42 insertions(+)
>
> diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh
> index d53e1a6..a9c647a 100755
> --- a/modules.d/40network/net-lib.sh
> +++ b/modules.d/40network/net-lib.sh
> @@ -103,6 +103,16 @@ setup_net() {
> [ -e /tmp/net.$netif.resolv.conf ] && \
> cp -f /tmp/net.$netif.resolv.conf /etc/resolv.conf
>
> + #add static route if exist
> + f="/etc/route-$netif"
> + if [ -e "$f" ]; then
> + if grep -Eq '^[[:space:]]*ADDRESS[0-9]+=' $f ; then
> + handle_file $f $netif
> + else
> + handle_ip_file $f
> + fi
> + fi
> +
> # 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
> @@ -517,6 +527,38 @@ find_iface_with_link() {
> return 1
> }
>
> +MATCH='^[[:space:]]*(\#.*)?$'
> +
> +handle_file () {
> + . $1
> + routenum=0
> + while [ "x$(eval echo '$'ADDRESS$routenum)x" != "xx" ]; do
> + eval $(ipcalc -p $(eval echo '$'ADDRESS$routenum) $(eval echo '$'NETMASK$routenum))
> + line="$(eval echo '$'ADDRESS$routenum)/$PREFIX"
> + if [ "x$(eval echo '$'GATEWAY$routenum)x" != "xx" ]; then
> + line="$line via $(eval echo '$'GATEWAY$routenum)"
> + fi
> + line="$line dev $2"
> + /sbin/ip route add $line
> + routenum=$(($routenum+1))
> + done
> +}
> +
> +handle_ip_file() {
> + local f t type= file=$1 proto="-4"
> + f=${file##*/}
> + t=${f%%-*}
> + type=${t%%6}
> + if [ "$type" != "$t" ]; then
> + proto="-6"
> + fi
> + { cat "$file" ; echo ; } | while read line; do
> + if [[ ! "$line" =~ $MATCH ]]; then
> + /sbin/ip $proto $type add $line
> + fi
> + done
> +}
> +
> is_persistent_ethernet_name() {
> case "$1" in
> # udev persistent interface names
> --
> 1.8.5.3
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2 2/2] network: add static route support
[not found] ` <1398678111-13601-2-git-send-email-bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-04-28 10:05 ` Baoquan He
@ 2014-05-05 7:12 ` Baoquan He
[not found] ` <20140505071214.GA24097-je1gSBvt1Tcx0jIIkfS+Ph/sF2h8X+2i0E9HWUfgJXw@public.gmane.org>
1 sibling, 1 reply; 13+ messages in thread
From: Baoquan He @ 2014-05-05 7:12 UTC (permalink / raw)
To: harald-H+wXaHxf7aLQT0dZR+AlfA
Cc: initramfs-u79uwXL29TY76Z2rM5mHXA, mmilgram-H+wXaHxf7aLQT0dZR+AlfA
User may specify static route for a target address which is different
than default gateway. The static route file could be like below:
192.168.200.222 via 192.168.100.222 dev eth0
Or
ADDRESS0=192.168.200.0
NETMASK0=255.255.255.0
GATEWAY0=192.168.100.222
In this patch, port the static route hanling from ifup-routes of initscript
component.
v1->v2:
Remove the commentary line checking code and "MATCH" pattern
definition since dracut require posix syntax. Let's focus on the
functionality of static route.
Signed-off-by: Baoquan He <bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
modules.d/40network/net-lib.sh | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh
index a82f1a8..0d488b5 100755
--- a/modules.d/40network/net-lib.sh
+++ b/modules.d/40network/net-lib.sh
@@ -103,6 +103,16 @@ setup_net() {
[ -e /tmp/net.$netif.resolv.conf ] && \
cp -f /tmp/net.$netif.resolv.conf /etc/resolv.conf
+ #add static route if exist
+ f="/etc/route-$netif"
+ if [ -e "$f" ]; then
+ if grep -Eq '^[[:space:]]*ADDRESS[0-9]+=' $f ; then
+ handle_file $f $netif
+ else
+ handle_ip_file $f
+ fi
+ fi
+
# 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
@@ -517,6 +527,35 @@ find_iface_with_link() {
return 1
}
+handle_file () {
+ . $1
+ routenum=0
+ while [ "x$(eval echo '$'ADDRESS$routenum)x" != "xx" ]; do
+ eval $(ipcalc -p $(eval echo '$'ADDRESS$routenum) $(eval echo '$'NETMASK$routenum))
+ line="$(eval echo '$'ADDRESS$routenum)/$PREFIX"
+ if [ "x$(eval echo '$'GATEWAY$routenum)x" != "xx" ]; then
+ line="$line via $(eval echo '$'GATEWAY$routenum)"
+ fi
+ line="$line dev $2"
+ /sbin/ip route add $line
+ routenum=$(($routenum+1))
+ done
+}
+
+handle_ip_file() {
+ local f t type= file=$1 proto="-4"
+ f=${file##*/}
+ t=${f%%-*}
+ type=${t%%6}
+ if [ "$type" != "$t" ]; then
+ proto="-6"
+ fi
+
+ while read line; do
+ /sbin/ip $proto $type add $line
+ done < $file
+}
+
is_persistent_ethernet_name() {
case "$1" in
# udev persistent interface names
--
1.9.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v2 2/2] network: add static route support
[not found] ` <20140505071214.GA24097-je1gSBvt1Tcx0jIIkfS+Ph/sF2h8X+2i0E9HWUfgJXw@public.gmane.org>
@ 2014-05-06 13:08 ` Marc Milgram
[not found] ` <5368DEBE.90809-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-05-22 7:33 ` Dave Young
2014-05-29 6:27 ` Dave Young
2 siblings, 1 reply; 13+ messages in thread
From: Marc Milgram @ 2014-05-06 13:08 UTC (permalink / raw)
To: Baoquan He, harald-H+wXaHxf7aLQT0dZR+AlfA
Cc: initramfs-u79uwXL29TY76Z2rM5mHXA
On 05/05/2014 03:12 AM, Baoquan He wrote:
> User may specify static route for a target address which is different
> than default gateway. The static route file could be like below:
>
> 192.168.200.222 via 192.168.100.222 dev eth0
>
> Or
>
> ADDRESS0=192.168.200.0
> NETMASK0=255.255.255.0
> GATEWAY0=192.168.100.222
>
> In this patch, port the static route hanling from ifup-routes of initscript
> component.
>
> v1->v2:
> Remove the commentary line checking code and "MATCH" pattern
> definition since dracut require posix syntax. Let's focus on the
> functionality of static route.
>
> Signed-off-by: Baoquan He <bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
I tested in my environment. It works for me, and fixes the problem.
ACK
Marc
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 2/2] network: add static route support
[not found] ` <5368DEBE.90809-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2014-05-12 6:31 ` Baoquan He
0 siblings, 0 replies; 13+ messages in thread
From: Baoquan He @ 2014-05-12 6:31 UTC (permalink / raw)
To: harald-H+wXaHxf7aLQT0dZR+AlfA, Marc Milgram
Cc: initramfs-u79uwXL29TY76Z2rM5mHXA
Thanks for testing and reviewing, Marc.
Hi Harald,
What's your idea on this issue?
Thanks
Baoquan
On 05/06/14 at 09:08am, Marc Milgram wrote:
> On 05/05/2014 03:12 AM, Baoquan He wrote:
> >User may specify static route for a target address which is different
> >than default gateway. The static route file could be like below:
> >
> >192.168.200.222 via 192.168.100.222 dev eth0
> >
> >Or
> >
> >ADDRESS0=192.168.200.0
> >NETMASK0=255.255.255.0
> >GATEWAY0=192.168.100.222
> >
> >In this patch, port the static route hanling from ifup-routes of initscript
> >component.
> >
> >v1->v2:
> > Remove the commentary line checking code and "MATCH" pattern
> >definition since dracut require posix syntax. Let's focus on the
> >functionality of static route.
> >
> >Signed-off-by: Baoquan He <bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
>
> I tested in my environment. It works for me, and fixes the problem.
>
> ACK
>
> Marc
>
> --
> 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] 13+ messages in thread
* Re: [PATCH v2 2/2] network: add static route support
[not found] ` <20140505071214.GA24097-je1gSBvt1Tcx0jIIkfS+Ph/sF2h8X+2i0E9HWUfgJXw@public.gmane.org>
2014-05-06 13:08 ` Marc Milgram
@ 2014-05-22 7:33 ` Dave Young
[not found] ` <20140522073359.GD1859-4/PLUo9XfK+sDdueE5tM26fLeoKvNuZc@public.gmane.org>
2014-05-29 6:27 ` Dave Young
2 siblings, 1 reply; 13+ messages in thread
From: Dave Young @ 2014-05-22 7:33 UTC (permalink / raw)
To: Baoquan He
Cc: harald-H+wXaHxf7aLQT0dZR+AlfA, initramfs-u79uwXL29TY76Z2rM5mHXA,
mmilgram-H+wXaHxf7aLQT0dZR+AlfA
On 05/05/14 at 03:12pm, Baoquan He wrote:
> User may specify static route for a target address which is different
> than default gateway. The static route file could be like below:
>
> 192.168.200.222 via 192.168.100.222 dev eth0
>
> Or
>
> ADDRESS0=192.168.200.0
> NETMASK0=255.255.255.0
> GATEWAY0=192.168.100.222
>
> In this patch, port the static route hanling from ifup-routes of initscript
> component.
>
> v1->v2:
> Remove the commentary line checking code and "MATCH" pattern
> definition since dracut require posix syntax. Let's focus on the
> functionality of static route.
>
> Signed-off-by: Baoquan He <bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> ---
> modules.d/40network/net-lib.sh | 39 +++++++++++++++++++++++++++++++++++++++
> 1 file changed, 39 insertions(+)
>
> diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh
> index a82f1a8..0d488b5 100755
> --- a/modules.d/40network/net-lib.sh
> +++ b/modules.d/40network/net-lib.sh
> @@ -103,6 +103,16 @@ setup_net() {
> [ -e /tmp/net.$netif.resolv.conf ] && \
> cp -f /tmp/net.$netif.resolv.conf /etc/resolv.conf
>
> + #add static route if exist
> + f="/etc/route-$netif"
Hi, Baoquan
The route-$netif is supposed in 1st kernel filesystem. Can we passing the
detail ip/netmask/gw for specific nic in kernel cmdline instead of copy
the route file in initramfs? In that way we can avoid this dracut fix.
I'm not sure if it works for the complicate route setup though.
> + if [ -e "$f" ]; then
> + if grep -Eq '^[[:space:]]*ADDRESS[0-9]+=' $f ; then
> + handle_file $f $netif
> + else
> + handle_ip_file $f
> + fi
> + fi
> +
> # 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
> @@ -517,6 +527,35 @@ find_iface_with_link() {
> return 1
> }
>
> +handle_file () {
> + . $1
> + routenum=0
> + while [ "x$(eval echo '$'ADDRESS$routenum)x" != "xx" ]; do
> + eval $(ipcalc -p $(eval echo '$'ADDRESS$routenum) $(eval echo '$'NETMASK$routenum))
> + line="$(eval echo '$'ADDRESS$routenum)/$PREFIX"
> + if [ "x$(eval echo '$'GATEWAY$routenum)x" != "xx" ]; then
> + line="$line via $(eval echo '$'GATEWAY$routenum)"
> + fi
> + line="$line dev $2"
> + /sbin/ip route add $line
> + routenum=$(($routenum+1))
> + done
> +}
> +
> +handle_ip_file() {
> + local f t type= file=$1 proto="-4"
> + f=${file##*/}
> + t=${f%%-*}
> + type=${t%%6}
> + if [ "$type" != "$t" ]; then
> + proto="-6"
> + fi
> +
> + while read line; do
> + /sbin/ip $proto $type add $line
> + done < $file
> +}
> +
> is_persistent_ethernet_name() {
> case "$1" in
> # udev persistent interface names
> --
> 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] 13+ messages in thread
* Re: [PATCH v2 2/2] network: add static route support
[not found] ` <20140522073359.GD1859-4/PLUo9XfK+sDdueE5tM26fLeoKvNuZc@public.gmane.org>
@ 2014-05-27 6:25 ` Baoquan He
[not found] ` <20140527062512.GA1951-je1gSBvt1Tcx0jIIkfS+Ph/sF2h8X+2i0E9HWUfgJXw@public.gmane.org>
0 siblings, 1 reply; 13+ messages in thread
From: Baoquan He @ 2014-05-27 6:25 UTC (permalink / raw)
To: Dave Young
Cc: harald-H+wXaHxf7aLQT0dZR+AlfA, initramfs-u79uwXL29TY76Z2rM5mHXA,
mmilgram-H+wXaHxf7aLQT0dZR+AlfA
On 05/22/14 at 03:33pm, Dave Young wrote:
> On 05/05/14 at 03:12pm, Baoquan He wrote:
> Hi, Baoquan
>
> The route-$netif is supposed in 1st kernel filesystem. Can we passing the
> detail ip/netmask/gw for specific nic in kernel cmdline instead of copy
> the route file in initramfs? In that way we can avoid this dracut fix.
>
> I'm not sure if it works for the complicate route setup though.
I am not sure, it had better handle the route during setup net. I want
to hear what Harald will say. He is more familiar with this.
Thanks
Baoquan
>
> > + if [ -e "$f" ]; then
> > + if grep -Eq '^[[:space:]]*ADDRESS[0-9]+=' $f ; then
> > + handle_file $f $netif
> > + else
> > + handle_ip_file $f
> > + fi
> > + fi
> > +
> > # 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
> > @@ -517,6 +527,35 @@ find_iface_with_link() {
> > return 1
> > }
> >
> > +handle_file () {
> > + . $1
> > + routenum=0
> > + while [ "x$(eval echo '$'ADDRESS$routenum)x" != "xx" ]; do
> > + eval $(ipcalc -p $(eval echo '$'ADDRESS$routenum) $(eval echo '$'NETMASK$routenum))
> > + line="$(eval echo '$'ADDRESS$routenum)/$PREFIX"
> > + if [ "x$(eval echo '$'GATEWAY$routenum)x" != "xx" ]; then
> > + line="$line via $(eval echo '$'GATEWAY$routenum)"
> > + fi
> > + line="$line dev $2"
> > + /sbin/ip route add $line
> > + routenum=$(($routenum+1))
> > + done
> > +}
> > +
> > +handle_ip_file() {
> > + local f t type= file=$1 proto="-4"
> > + f=${file##*/}
> > + t=${f%%-*}
> > + type=${t%%6}
> > + if [ "$type" != "$t" ]; then
> > + proto="-6"
> > + fi
> > +
> > + while read line; do
> > + /sbin/ip $proto $type add $line
> > + done < $file
> > +}
> > +
> > is_persistent_ethernet_name() {
> > case "$1" in
> > # udev persistent interface names
> > --
> > 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
> --
> 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] 13+ messages in thread
* Re: [PATCH v2 2/2] network: add static route support
[not found] ` <20140527062512.GA1951-je1gSBvt1Tcx0jIIkfS+Ph/sF2h8X+2i0E9HWUfgJXw@public.gmane.org>
@ 2014-05-29 6:20 ` Dave Young
[not found] ` <20140529062059.GH2068-4/PLUo9XfK+sDdueE5tM26fLeoKvNuZc@public.gmane.org>
0 siblings, 1 reply; 13+ messages in thread
From: Dave Young @ 2014-05-29 6:20 UTC (permalink / raw)
To: Baoquan He
Cc: harald-H+wXaHxf7aLQT0dZR+AlfA, initramfs-u79uwXL29TY76Z2rM5mHXA,
mmilgram-H+wXaHxf7aLQT0dZR+AlfA
On 05/27/14 at 02:25pm, Baoquan He wrote:
> On 05/22/14 at 03:33pm, Dave Young wrote:
> > On 05/05/14 at 03:12pm, Baoquan He wrote:
>
> > Hi, Baoquan
> >
> > The route-$netif is supposed in 1st kernel filesystem. Can we passing the
> > detail ip/netmask/gw for specific nic in kernel cmdline instead of copy
> > the route file in initramfs? In that way we can avoid this dracut fix.
> >
> > I'm not sure if it works for the complicate route setup though.
>
> I am not sure, it had better handle the route during setup net. I want
> to hear what Harald will say. He is more familiar with this.
Ok, the route table item must be a line like "192.168.100.1 via 127.0.0.1 dev lo metric 203"
If passing them via cmdline we need quote it with some special character and append
it to the ip= cmdline param
The other way is copy the route file to /etc/ in initramfs like you are doing.
But we did need the functions to handle the static route.
So leave to Harald about the interface.
>
>
> >
> > > + if [ -e "$f" ]; then
> > > + if grep -Eq '^[[:space:]]*ADDRESS[0-9]+=' $f ; then
> > > + handle_file $f $netif
> > > + else
> > > + handle_ip_file $f
> > > + fi
> > > + fi
> > > +
> > > # 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
> > > @@ -517,6 +527,35 @@ find_iface_with_link() {
> > > return 1
> > > }
> > >
> > > +handle_file () {
> > > + . $1
> > > + routenum=0
> > > + while [ "x$(eval echo '$'ADDRESS$routenum)x" != "xx" ]; do
> > > + eval $(ipcalc -p $(eval echo '$'ADDRESS$routenum) $(eval echo '$'NETMASK$routenum))
> > > + line="$(eval echo '$'ADDRESS$routenum)/$PREFIX"
> > > + if [ "x$(eval echo '$'GATEWAY$routenum)x" != "xx" ]; then
> > > + line="$line via $(eval echo '$'GATEWAY$routenum)"
> > > + fi
> > > + line="$line dev $2"
> > > + /sbin/ip route add $line
> > > + routenum=$(($routenum+1))
> > > + done
> > > +}
> > > +
> > > +handle_ip_file() {
> > > + local f t type= file=$1 proto="-4"
> > > + f=${file##*/}
> > > + t=${f%%-*}
> > > + type=${t%%6}
> > > + if [ "$type" != "$t" ]; then
> > > + proto="-6"
> > > + fi
> > > +
> > > + while read line; do
> > > + /sbin/ip $proto $type add $line
> > > + done < $file
> > > +}
> > > +
> > > is_persistent_ethernet_name() {
> > > case "$1" in
> > > # udev persistent interface names
> > > --
> > > 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
> > --
> > 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
> --
> 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] 13+ messages in thread
* Re: [PATCH v2 2/2] network: add static route support
[not found] ` <20140505071214.GA24097-je1gSBvt1Tcx0jIIkfS+Ph/sF2h8X+2i0E9HWUfgJXw@public.gmane.org>
2014-05-06 13:08 ` Marc Milgram
2014-05-22 7:33 ` Dave Young
@ 2014-05-29 6:27 ` Dave Young
[not found] ` <20140529062727.GI2068-4/PLUo9XfK+sDdueE5tM26fLeoKvNuZc@public.gmane.org>
2 siblings, 1 reply; 13+ messages in thread
From: Dave Young @ 2014-05-29 6:27 UTC (permalink / raw)
To: Baoquan He
Cc: harald-H+wXaHxf7aLQT0dZR+AlfA, initramfs-u79uwXL29TY76Z2rM5mHXA,
mmilgram-H+wXaHxf7aLQT0dZR+AlfA
On 05/05/14 at 03:12pm, Baoquan He wrote:
> User may specify static route for a target address which is different
> than default gateway. The static route file could be like below:
>
> 192.168.200.222 via 192.168.100.222 dev eth0
>
> Or
>
> ADDRESS0=192.168.200.0
> NETMASK0=255.255.255.0
> GATEWAY0=192.168.100.222
For the latter format ADDRESS0, I guess the '0' means the order number of nic.
But if it's renamed to anything else which is not ending with number how to
find the right card?
So how about use one uniform format like "192.168.200.222 via 192.168.100.222 dev eth0"?
Maybe always get the route item by 'ip' command instead of reading the route file?
Using ip command there's another possible advantage that no need to handle ipv6 specific
formats in route file if there's any different.
>
> In this patch, port the static route hanling from ifup-routes of initscript
> component.
>
> v1->v2:
> Remove the commentary line checking code and "MATCH" pattern
> definition since dracut require posix syntax. Let's focus on the
> functionality of static route.
>
> Signed-off-by: Baoquan He <bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> ---
> modules.d/40network/net-lib.sh | 39 +++++++++++++++++++++++++++++++++++++++
> 1 file changed, 39 insertions(+)
>
> diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh
> index a82f1a8..0d488b5 100755
> --- a/modules.d/40network/net-lib.sh
> +++ b/modules.d/40network/net-lib.sh
> @@ -103,6 +103,16 @@ setup_net() {
> [ -e /tmp/net.$netif.resolv.conf ] && \
> cp -f /tmp/net.$netif.resolv.conf /etc/resolv.conf
>
> + #add static route if exist
> + f="/etc/route-$netif"
> + if [ -e "$f" ]; then
> + if grep -Eq '^[[:space:]]*ADDRESS[0-9]+=' $f ; then
> + handle_file $f $netif
> + else
> + handle_ip_file $f
> + fi
> + fi
> +
Suppose it's for static setup only, how about moving the code into do_static
in ifup.sh
> # 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
> @@ -517,6 +527,35 @@ find_iface_with_link() {
> return 1
> }
>
> +handle_file () {
> + . $1
> + routenum=0
> + while [ "x$(eval echo '$'ADDRESS$routenum)x" != "xx" ]; do
> + eval $(ipcalc -p $(eval echo '$'ADDRESS$routenum) $(eval echo '$'NETMASK$routenum))
> + line="$(eval echo '$'ADDRESS$routenum)/$PREFIX"
> + if [ "x$(eval echo '$'GATEWAY$routenum)x" != "xx" ]; then
> + line="$line via $(eval echo '$'GATEWAY$routenum)"
> + fi
> + line="$line dev $2"
> + /sbin/ip route add $line
> + routenum=$(($routenum+1))
> + done
> +}
> +
> +handle_ip_file() {
> + local f t type= file=$1 proto="-4"
> + f=${file##*/}
> + t=${f%%-*}
> + type=${t%%6}
> + if [ "$type" != "$t" ]; then
> + proto="-6"
> + fi
> +
> + while read line; do
> + /sbin/ip $proto $type add $line
> + done < $file
> +}
> +
> is_persistent_ethernet_name() {
> case "$1" in
> # udev persistent interface names
> --
> 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] 13+ messages in thread
* Re: [PATCH v2 2/2] network: add static route support
[not found] ` <20140529062727.GI2068-4/PLUo9XfK+sDdueE5tM26fLeoKvNuZc@public.gmane.org>
@ 2014-05-29 7:03 ` Baoquan He
0 siblings, 0 replies; 13+ messages in thread
From: Baoquan He @ 2014-05-29 7:03 UTC (permalink / raw)
To: Dave Young
Cc: harald-H+wXaHxf7aLQT0dZR+AlfA, initramfs-u79uwXL29TY76Z2rM5mHXA,
mmilgram-H+wXaHxf7aLQT0dZR+AlfA
On 05/29/14 at 02:27pm, Dave Young wrote:
> On 05/05/14 at 03:12pm, Baoquan He wrote:
> > User may specify static route for a target address which is different
> > than default gateway. The static route file could be like below:
> >
> > 192.168.200.222 via 192.168.100.222 dev eth0
> >
> > Or
> >
> > ADDRESS0=192.168.200.0
> > NETMASK0=255.255.255.0
> > GATEWAY0=192.168.100.222
>
> For the latter format ADDRESS0, I guess the '0' means the order number of nic.
> But if it's renamed to anything else which is not ending with number how to
> find the right card?
>
> So how about use one uniform format like "192.168.200.222 via 192.168.100.222 dev eth0"?
>
> Maybe always get the route item by 'ip' command instead of reading the route file?
> Using ip command there's another possible advantage that no need to handle ipv6 specific
> formats in route file if there's any different.
I guess ADDRESS0 means in one route-$netif file, there could be several
ip address on this $netif and several related routes. And according to
the code annatation in /etc/sysconfig/network-scripts/ifup-routes, this
is the new format of route file. Adding this can support the generic
route cases if other users want to add route, not only kdump.
I am OK if only take the older format, it's sufficient for kdump use.
>
> >
> > In this patch, port the static route hanling from ifup-routes of initscript
> > component.
> >
> > v1->v2:
> > Remove the commentary line checking code and "MATCH" pattern
> > definition since dracut require posix syntax. Let's focus on the
> > functionality of static route.
> >
> > Signed-off-by: Baoquan He <bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
> > ---
> > modules.d/40network/net-lib.sh | 39 +++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 39 insertions(+)
> >
> > diff --git a/modules.d/40network/net-lib.sh b/modules.d/40network/net-lib.sh
> > index a82f1a8..0d488b5 100755
> > --- a/modules.d/40network/net-lib.sh
> > +++ b/modules.d/40network/net-lib.sh
> > @@ -103,6 +103,16 @@ setup_net() {
> > [ -e /tmp/net.$netif.resolv.conf ] && \
> > cp -f /tmp/net.$netif.resolv.conf /etc/resolv.conf
> >
> > + #add static route if exist
> > + f="/etc/route-$netif"
> > + if [ -e "$f" ]; then
> > + if grep -Eq '^[[:space:]]*ADDRESS[0-9]+=' $f ; then
> > + handle_file $f $netif
> > + else
> > + handle_ip_file $f
> > + fi
> > + fi
> > +
>
> Suppose it's for static setup only, how about moving the code into do_static
> in ifup.sh
I am fine with this, but I tend to handle it in setup_net.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 2/2] network: add static route support
[not found] ` <20140529062059.GH2068-4/PLUo9XfK+sDdueE5tM26fLeoKvNuZc@public.gmane.org>
@ 2014-06-04 6:25 ` Dave Young
[not found] ` <20140604062516.GE2194-4/PLUo9XfK+sDdueE5tM26fLeoKvNuZc@public.gmane.org>
0 siblings, 1 reply; 13+ messages in thread
From: Dave Young @ 2014-06-04 6:25 UTC (permalink / raw)
To: Baoquan He, harald-H+wXaHxf7aLQT0dZR+AlfA
Cc: initramfs-u79uwXL29TY76Z2rM5mHXA, mmilgram-H+wXaHxf7aLQT0dZR+AlfA
On 05/29/14 at 02:20pm, Dave Young wrote:
> On 05/27/14 at 02:25pm, Baoquan He wrote:
> > On 05/22/14 at 03:33pm, Dave Young wrote:
> > > On 05/05/14 at 03:12pm, Baoquan He wrote:
> >
> > > Hi, Baoquan
> > >
> > > The route-$netif is supposed in 1st kernel filesystem. Can we passing the
> > > detail ip/netmask/gw for specific nic in kernel cmdline instead of copy
> > > the route file in initramfs? In that way we can avoid this dracut fix.
> > >
> > > I'm not sure if it works for the complicate route setup though.
> >
> > I am not sure, it had better handle the route during setup net. I want
> > to hear what Harald will say. He is more familiar with this.
>
> Ok, the route table item must be a line like "192.168.100.1 via 127.0.0.1 dev lo metric 203"
>
> If passing them via cmdline we need quote it with some special character and append
> it to the ip= cmdline param
>
> The other way is copy the route file to /etc/ in initramfs like you are doing.
> But we did need the functions to handle the static route.
>
> So leave to Harald about the interface.
Harald, what do you prefer to passing static route item to initramfs?
Do you have beeter idea in mind?
Thanks
Dave
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 2/2] network: add static route support
[not found] ` <20140604062516.GE2194-4/PLUo9XfK+sDdueE5tM26fLeoKvNuZc@public.gmane.org>
@ 2014-06-04 11:38 ` Harald Hoyer
0 siblings, 0 replies; 13+ messages in thread
From: Harald Hoyer @ 2014-06-04 11:38 UTC (permalink / raw)
To: Dave Young, Baoquan He
Cc: initramfs-u79uwXL29TY76Z2rM5mHXA, mmilgram-H+wXaHxf7aLQT0dZR+AlfA
On 04.06.2014 08:25, Dave Young wrote:
> On 05/29/14 at 02:20pm, Dave Young wrote:
>> On 05/27/14 at 02:25pm, Baoquan He wrote:
>>> On 05/22/14 at 03:33pm, Dave Young wrote:
>>>> On 05/05/14 at 03:12pm, Baoquan He wrote:
>>>
>>>> Hi, Baoquan
>>>>
>>>> The route-$netif is supposed in 1st kernel filesystem. Can we passing the
>>>> detail ip/netmask/gw for specific nic in kernel cmdline instead of copy
>>>> the route file in initramfs? In that way we can avoid this dracut fix.
>>>>
>>>> I'm not sure if it works for the complicate route setup though.
>>>
>>> I am not sure, it had better handle the route during setup net. I want
>>> to hear what Harald will say. He is more familiar with this.
>>
>> Ok, the route table item must be a line like "192.168.100.1 via 127.0.0.1 dev lo metric 203"
>>
>> If passing them via cmdline we need quote it with some special character and append
>> it to the ip= cmdline param
>>
>> The other way is copy the route file to /etc/ in initramfs like you are doing.
>> But we did need the functions to handle the static route.
>>
>> So leave to Harald about the interface.
>
> Harald, what do you prefer to passing static route item to initramfs?
> Do you have beeter idea in mind?
>
> Thanks
> Dave
>
Actually, I would like to parse systemd-networkd like config files.
As we will integrate systemd-networkd as a replacement for our shell script
mess in the future, I think it might make more sense not to introduce another
format, which will be obsoleted.
http://www.freedesktop.org/software/systemd/man/systemd.network.html
What do you think?
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2014-06-04 11:38 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-28 9:41 [PATCH 1/2] network: add ipcalc for netmask calculation Baoquan He
[not found] ` <1398678111-13601-1-git-send-email-bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-04-28 9:41 ` [PATCH 2/2] network: add static route support Baoquan He
[not found] ` <1398678111-13601-2-git-send-email-bhe-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-04-28 10:05 ` Baoquan He
2014-05-05 7:12 ` [PATCH v2 " Baoquan He
[not found] ` <20140505071214.GA24097-je1gSBvt1Tcx0jIIkfS+Ph/sF2h8X+2i0E9HWUfgJXw@public.gmane.org>
2014-05-06 13:08 ` Marc Milgram
[not found] ` <5368DEBE.90809-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2014-05-12 6:31 ` Baoquan He
2014-05-22 7:33 ` Dave Young
[not found] ` <20140522073359.GD1859-4/PLUo9XfK+sDdueE5tM26fLeoKvNuZc@public.gmane.org>
2014-05-27 6:25 ` Baoquan He
[not found] ` <20140527062512.GA1951-je1gSBvt1Tcx0jIIkfS+Ph/sF2h8X+2i0E9HWUfgJXw@public.gmane.org>
2014-05-29 6:20 ` Dave Young
[not found] ` <20140529062059.GH2068-4/PLUo9XfK+sDdueE5tM26fLeoKvNuZc@public.gmane.org>
2014-06-04 6:25 ` Dave Young
[not found] ` <20140604062516.GE2194-4/PLUo9XfK+sDdueE5tM26fLeoKvNuZc@public.gmane.org>
2014-06-04 11:38 ` Harald Hoyer
2014-05-29 6:27 ` Dave Young
[not found] ` <20140529062727.GI2068-4/PLUo9XfK+sDdueE5tM26fLeoKvNuZc@public.gmane.org>
2014-05-29 7:03 ` 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.