Index: head/sys/net/radix_mpath.c =================================================================== --- head/sys/net/radix_mpath.c +++ head/sys/net/radix_mpath.c @@ -290,38 +290,18 @@ RT_UNLOCK(ro->ro_rt); } -extern int in6_inithead(void **head, int off, u_int fibnum); -extern int in_inithead(void **head, int off, u_int fibnum); - -#ifdef INET -int -rn4_mpath_inithead(void **head, int off, u_int fibnum) +void +rt_mpath_init_rnh(struct rib_head *rnh) { - struct rib_head *rnh; - hashjitter = arc4random(); - if (in_inithead(head, off, fibnum) == 1) { - rnh = (struct rib_head *)*head; - rnh->rnh_multipath = 1; - return 1; - } else - return 0; + rnh->rnh_multipath = 1; } -#endif -#ifdef INET6 -int -rn6_mpath_inithead(void **head, int off, u_int fibnum) +static void +mpath_init(void) { - struct rib_head *rnh; hashjitter = arc4random(); - if (in6_inithead(head, off, fibnum) == 1) { - rnh = (struct rib_head *)*head; - rnh->rnh_multipath = 1; - return 1; - } else - return 0; } +SYSINIT(mpath_init, SI_SUB_PROTO_DOMAIN, SI_ORDER_ANY, mpath_init, NULL); -#endif Index: head/sys/net/route_var.h =================================================================== --- head/sys/net/route_var.h +++ head/sys/net/route_var.h @@ -88,6 +88,7 @@ "ro_dst and " #_dst_new " are at different offset") struct rib_head *rt_tables_get_rnh(int fib, int family); +void rt_mpath_init_rnh(struct rib_head *rnh); /* rte<>nhop translation */ static inline uint16_t Index: head/sys/netinet/in_proto.c =================================================================== --- head/sys/netinet/in_proto.c +++ head/sys/netinet/in_proto.c @@ -62,9 +62,6 @@ #include #include #include -#ifdef RADIX_MPATH -#include -#endif #include #endif /* INET */ @@ -305,11 +302,7 @@ .dom_name = "internet", .dom_protosw = inetsw, .dom_protoswNPROTOSW = &inetsw[nitems(inetsw)], -#ifdef RADIX_MPATH - .dom_rtattach = rn4_mpath_inithead, -#else .dom_rtattach = in_inithead, -#endif #ifdef VIMAGE .dom_rtdetach = in_detachhead, #endif Index: head/sys/netinet/in_rmx.c =================================================================== --- head/sys/netinet/in_rmx.c +++ head/sys/netinet/in_rmx.c @@ -30,6 +30,8 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_mpath.h" + #include #include #include @@ -125,6 +127,9 @@ return (0); rh->rnh_addaddr = in_addroute; +#ifdef RADIX_MPATH + rt_mpath_init_rnh(rh); +#endif *head = (void *)rh; if (_in_rt_was_here == 0 ) { Index: head/sys/netinet6/in6_proto.c =================================================================== --- head/sys/netinet6/in6_proto.c +++ head/sys/netinet6/in6_proto.c @@ -90,9 +90,6 @@ #include #include #include -#ifdef RADIX_MPATH -#include -#endif #include #include @@ -346,11 +343,7 @@ .dom_name = "internet6", .dom_protosw = (struct protosw *)inet6sw, .dom_protoswNPROTOSW = (struct protosw *)&inet6sw[nitems(inet6sw)], -#ifdef RADIX_MPATH - .dom_rtattach = rn6_mpath_inithead, -#else .dom_rtattach = in6_inithead, -#endif #ifdef VIMAGE .dom_rtdetach = in6_detachhead, #endif Index: head/sys/netinet6/in6_rmx.c =================================================================== --- head/sys/netinet6/in6_rmx.c +++ head/sys/netinet6/in6_rmx.c @@ -64,6 +64,8 @@ #include __FBSDID("$FreeBSD$"); +#include "opt_mpath.h" + #include #include #include @@ -167,6 +169,9 @@ return (0); rh->rnh_addaddr = in6_addroute; +#ifdef RADIX_MPATH + rt_mpath_init_rnh(rh); +#endif *head = (void *)rh; return (1);