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
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.
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
(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 $
Thanks for the clarification. The secont part of this patch is in commit a8ab9d6.
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
Created attachment 333262 [details, diff] fix-ipv6-routes-and-default-route.patch
InGit.