I've tried to split the ip6_output function. The change is available here http://netbsd-soc.cvs.sourceforge.net/netbsd-soc/ipsec6/sys/netinet6/ip6_output.c?view=log