Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 442594 - sys-apps/openrc-0.11.4: ifconfig module doesn't support ipv6 routes without explicit prefix
Summary: sys-apps/openrc-0.11.4: ifconfig module doesn't support ipv6 routes without e...
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: netifrc (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: netifrc Team
Depends on:
Blocks: 404503
  Show dependency tree
Reported: 2012-11-10 12:01 UTC by Alexander Tsoy
Modified: 2013-08-28 17:01 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---

openrc-ipv6-fixes.patch (002-ipv6-fixes.patch,1.06 KB, patch)
2012-12-21 12:34 UTC, Alexander Tsoy
Details | Diff
fix-ipv6-routes-and-default-route.patch (,500 bytes, patch)
2012-12-25 09:18 UTC, Alexander Tsoy
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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="  yyyy:yyyy:yyyy:yyyy::yyyy/128 "


-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}";;
#    *.*.*.*/*||" "*)     cmd="-net ${cmd}";;
#    default|default" "*)               cmd="-net ${cmd}";;
#    *)                                 cmd="-host ${cmd}";;

and adding this to net config:

config_venet0="  yyyy:yyyy:yyyy:yyyy::yyyy/128 "
routes_venet0="-A inet -net
-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:


or simply


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

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 have been applied in commit 2b0ff6f.
I have a question about the change below:

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

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


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
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
Comment 6 Alexander Tsoy 2012-12-25 09:18:25 UTC
Created attachment 333262 [details, diff]
Comment 7 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2013-08-28 17:01:45 UTC