Created attachment 294007 [details] 6rd net module This script will add 6rd to Gentoo. 6rd is similar to 6to4 (and the script itself is based on the 6to4 openrc sources), but instead of using public relays, it uses a private one with the ISP ipv6 prefix instead of 2002:: ; otherwise the IP are generated similarly, however with 6rd with possible to "shave" off some of the ipv4 to make subnets bigger (thus if an ISP has an /8 they can shave off the first 8 bits of the generated ipv4 address to add 8 extra bits for the customer.). configuration is similar to 6to4, except the relay must be specified link_6rd="eth0" # required config_6rd="ip6rd" # required rc_need_6rd="net.eth0" # optional but recommened prefix_6rd="2602:100::/32" # required suffix_6d="ff" # optional defaults to 1 relay_6rd="68.114.165.1" # required ipv4mask_6rd="0" # optional, default is 0 Note since this script is based off the 6to4 one, it has the same bugs, too, in particular bug 372575 - (I modified a copy of net.lo it to test). The ip6rd_inet functions are all pretty generic (except ip6rd_prefix_shave_bits) and could be split off into a separate library for the other net scripts if desired. 6rd has provisions for autoconfiguration via DHCP (option 212), obviating the need to specify it all manually, however I don't know of way how to retrieve and parse the DHCP options in a dhcp client independent way - so it currently not implemented
Created attachment 294039 [details] 6rd net module Made an error computing the ipv6 subnet (forgot to add ipv4mask to the ISP's prefix subnet) - this corrects it.
Created attachment 295781 [details] 6rd net module First version has more bugs than I thought. _ip6rd_inet_get_network() wasn't correct, now fixed. Now that I understand why pre_start wasn't being run, I've now fixed that. So unlike 6to4 (which this module is based off of), it will work with a custom name - I opted just to re-do the loop. Also I made the coding style more consist ant with the rest of module. Need documentation, its pretty much the same as ip6to4, but it requires two additional parameter: "prefix", which is the 6rd prefix for the user's ISP in the form 2001:DB8::/32, and "relay" which is the ISP's 6rd border router (ip6to4 has the latter but its optional there). There's an additional optional ipv4mask parameter, which is the number of the most significant bits to shave off the user's IP address to generate the IP address (so if an ISP has an entire class A, the first 8 bits could be shaved off to gave users more IP - from a /64 to a /56 ). I don't think any ISP has implemented that, but it is in the RFC.
You uploaded dhclient.sh as your latest version in comment 2, instead of your 6rd.sh script. Please re-upload. md5: 0f3a34d6871314e219c632b0db520cc6 6rd.sh 0f3a34d6871314e219c632b0db520cc6 dhclient.sh
Created attachment 297257 [details] 6rd net module Here's the correct script
Created attachment 297261 [details] 6rd net module I didn't know about the service_{get/set}_value thing so I updated the script to use them to avoid looping twice. Also makes it more symmetrical to ip6to4.
Looks good, I think some more cleanup of the math (I think it can be refactored a bit) and it should be good to go. Thanks for using service_get_value, it helps a lot.
Created attachment 297265 [details] 297261: 6rd net module Forgot to check for empty relay (6rd requires the relay, prefix, and link values)
@robbat2: The substitutions on line 62 look like bashisms, but I'm not quite sure whether or not they are. We should probably be sure that this script is posix compliant before we commit it.
Created attachment 297277 [details] 6rd net module Forgot to add new parameters to _config_vars. Also spacing got mangled in copy/paste job so fixed it.
InCVS now, thanks for all the revisions of it. Not tested in depth because I don't have 6rd available to me.