Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 442594

Summary: sys-apps/openrc-0.11.4: ifconfig module doesn't support ipv6 routes without explicit prefix
Product: Gentoo Hosted Projects Reporter: Alexander Tsoy <alexander>
Component: netifrcAssignee: netifrc Team <netifrc>
Status: RESOLVED FIXED    
Severity: normal    
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 404503    
Attachments: openrc-ipv6-fixes.patch
fix-ipv6-routes-and-default-route.patch

Description Alexander Tsoy 2012-11-10 12:01:23 UTC
It seems there is no way to create ipv6 routes using 'ifconfig' module. Almost no problems with 'iproute2' module since 'ip' command can automatically determine inet family (if there is an IP adress in route definition of course). _add_route() function in both 'ifconfig' and 'iproute2' modules can accept inet family in first arguments, but this functionality is not used by net.lo init.d script.


This is an example of working config for OpenVZ container with venet interface (no gateway address is needed):

config_venet0=" xxx.xxx.xxx.xxx/32  yyyy:yyyy:yyyy:yyyy::yyyy/128 "
routes_venet0="0.0.0.0/0
::/0"

or

routes_venet0="-net 0.0.0.0/0
-net ::/0"


I can create the same routes using 'ifconfig' module only by commenting this block in net.lo inet.d script:

#case ${cmd} in
#   -net" "*|-host" "*);;
#    *" "netmask" "*)                   cmd="-net ${cmd}";;
#    *.*.*.*/32*)                       cmd="-host ${cmd}";;
#    *.*.*.*/*|0.0.0.0|0.0.0.0" "*)     cmd="-net ${cmd}";;
#    default|default" "*)               cmd="-net ${cmd}";;
#    *)                                 cmd="-host ${cmd}";;
#esac

and adding this to net config:

modules="!iproute2"
config_venet0=" xxx.xxx.xxx.xxx/32  yyyy:yyyy:yyyy:yyyy::yyyy/128 "
routes_venet0="-A inet -net 0.0.0.0/0
-A inet6 -net ::/0"


IMHO the best way to fix this and keep the current syntax of net config is to add support for separate option dedicated for ipv6 routes (routes6_${iface}?). This will also allow to keep routes config compatible between iproute2 and ifconfig modules (no prefix like '-6/-A inet6/..etc' will be needed). So the above routes config may be converted into this:

routes_venet0="0.0.0.0/0"
routes6_venet0="::/0"

or simply

routes_venet0="default"
routes6_venet0="default"

Reproducible: Always
Comment 1 Alexander Tsoy 2012-12-21 12:34:05 UTC
Created attachment 332914 [details, diff]
openrc-ipv6-fixes.patch

I believe this problem is mostly fixed in commit a61fdd0 (bug 447310). But there is still one problem. 'route' command dislikes '-net' and '-host' prefixes in target definition for ipv6 routes. So here is a patch which fixes this. Plus some ipv6-related changes in init.d script.
Comment 2 William Hubbs gentoo-dev 2012-12-21 20:37:06 UTC
The changes to net.lo.in have been applied in commit 2b0ff6f.
I have a question about the change below:

*snip*
diff -urN openrc-0.11.8.orig/net/ifconfig.sh.Linux.in openrc-0.11.8/net/ifconfig.sh.Linux.in
--- openrc-0.11.8.orig/net/ifconfig.sh.Linux.in	2012-12-07 19:53:28.000000000 +0400
+++ openrc-0.11.8/net/ifconfig.sh.Linux.in	2012-12-21 15:44:43.000000000 +0400
@@ -209,7 +209,7 @@
 	fi
 
 	case "$@" in
-		*:*) [ "$1" = "-net" ] && shift;;
+		*:*|default*) [ "$1" = "-net" -o "$1" = "-host" ] && shift;;
 	esac
 
 	route ${family} add "$@" dev "${IFACE}"
	*snip*

Why are you adding '|default*' to this case statement?

Thanks,

William
Comment 3 Alexander Tsoy 2012-12-21 21:52:32 UTC
(In reply to comment #2)
> -		*:*) [ "$1" = "-net" ] && shift;;
> +		*:*|default*) [ "$1" = "-net" -o "$1" = "-host" ] && shift;;
> Why are you adding '|default*' to this case statement?
> 

Because net.lo init.d script adds '-net' before 'default'. If we deal with ipv6 routes then '-net' makes route command unhappy - it tries to resolve it as a host name.

$ LANG=C sudo route -A inet6 add -net default gw xxxx:xxx:xxx:xxx::1
getaddrinfo: #net: -2
#net: Unknown host
$
Comment 4 William Hubbs gentoo-dev 2012-12-22 00:00:15 UTC
Thanks for the clarification. The secont part of this patch is in commit
a8ab9d6.
Comment 5 Alexander Tsoy 2012-12-25 09:03:57 UTC
Sorry, but this is not correct. It really should be '|*default*', but if somebody will use hostnames which includes substring 'default' then this will also match. How about this?

    if [ "$1" = "-net" -o "$1" = "-host" ]; then
        if [ "${2##*:}" != "$2" ]; then shift
        elif [ "$2" = "default" ]; then shift
        fi
    fi
Comment 6 Alexander Tsoy 2012-12-25 09:18:25 UTC
Created attachment 333262 [details, diff]
fix-ipv6-routes-and-default-route.patch
Comment 7 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2013-08-28 17:01:45 UTC
InGit.