FreeBSD 9 changes IPv6 settings

Those who upgraded to FreeBSD 9.0 RELEASE this weekend were in for an interesting surprise setting up IPv6. The settings for IPv6 changed so much in the new version of FreeBSD that an older configuration -most likely- simply will not work. Here's how my IPv6 got back online on FreeBSD 9.
Gateway
On the gateway machine you first need an interface that has an IPv6 address in the first place. I'm running IPv6 off a SIXXS tunnel so that's what I'll be demonstrating here. What you'll need on the gateway is a working tunnel and a working routing advertisement daemon to allow autoconfiguration for your clients. My /etc/rc.conf looks like this:
ipv6_interfaces="auto"
ipv6_ifconfig_em0="2001:610:7be:0::1 prefixlen 64"
ipv6_defaultrouter="2001:610:600:730::2"
sixxs_aiccu_enable="YES"
rtadvd_enable="YES"
rtadvd_interfaces="em0"
ipv6_gateway_enable="YES"
ip6addrctl_enable="YES"
ip6addrctl_policy="ipv6_prefer"
The first line enables IPv6 for all supported interfaces. The second line configures em0 with a static IPv6 address at the start of one of my /64 ranges. SIXXS hands out huge /48 ranges, but what any home user like me would do with one of these is utterly beyond me. I'll probably be dead long before my /64 runs out. The ipv6_defaultrouter is set to my local end of the SIXXS tunnel. You can gather that from the ifconfig of your tunnel interface. Mine looks like this:
inet6 2001:610:600:730::2 --> 2001:610:600:730::1 prefixlen 128
The lines following are self-explanatory: they simply enable the SIXXS aiccu tunnel building utility and the router advertisement daemon and the interface rtadvd will advertise on. The very last line makes sure the kernel gets configured so that it'll forward IPv6 packages. Advertising the right routes The last bit you need to do, is to have your gateway advertise the correct router. On my system this is done by advertising the /64 I currently have in use through /etc/rtadvd.conf:
em0: \
:addr="2001:610:7be:0::":prefixlen#64:
Set all of this, reboot your gateway, and it should allow every IPv6-enabled client on your network to autoconfigure itself.
FreeBSD 9 clients
To get IPv6 working like it's supposed to, you need to set the following in your client's /etc/rc.conf file.
ip6addrctl_enable="YES"
ip6addrctl_policy="ipv6_prefer"
ifconfig_em0_ipv6="inet6 accept_rtadv"
If your network is IPv6-enabled, specifications dictate that IPv6 should be the preferred addressing scheme. The first two lines set your client up to make this the case. Only swap this around if you run into some kind of otherwise insurmountable issue because you will be breaking expected behavior by setting the policy to ipv4_prefer. The ifconfig-line is specific to your interface. See the manpage on rc.conf for an extended description of what you can do with it. In this example I've set it up so that my em0 Intel NIC accepts router advertisements from my gateway.
