Index: sys/net/route.c =================================================================== --- sys/net/route.c +++ sys/net/route.c @@ -270,7 +270,7 @@ rnh = rt_tables_get_rnh_ptr(table, fam); if (rnh == NULL) panic("%s: rnh NULL", __func__); - dom->dom_rtattach((void **)rnh, 0, table); + *rnh = dom->dom_rtattach(table); } } } @@ -299,7 +299,7 @@ rnh = rt_tables_get_rnh_ptr(table, fam); if (rnh == NULL) panic("%s: rnh NULL", __func__); - dom->dom_rtdetach((void **)rnh, 0); + dom->dom_rtdetach(*rnh); } } Index: sys/netinet/in_proto.c =================================================================== --- sys/netinet/in_proto.c +++ sys/netinet/in_proto.c @@ -294,9 +294,6 @@ }, }; -extern int in_inithead(void **, int, u_int); -extern int in_detachhead(void **, int); - struct domain inetdomain = { .dom_family = AF_INET, .dom_name = "internet", Index: sys/netinet/in_rmx.c =================================================================== --- sys/netinet/in_rmx.c +++ sys/netinet/in_rmx.c @@ -54,10 +54,6 @@ #include #include -extern int in_inithead(void **head, int off, u_int fibnum); -#ifdef VIMAGE -extern int in_detachhead(void **head, int off); -#endif static int rib4_preadd(u_int fibnum, const struct sockaddr *addr, const struct sockaddr *mask, @@ -121,38 +117,32 @@ return (0); } -static int _in_rt_was_here; /* * Initialize our routing tree. */ -int -in_inithead(void **head, int off, u_int fibnum) +struct rib_head * +in_inithead(uint32_t fibnum) { struct rib_head *rh; rh = rt_table_init(32, AF_INET, fibnum); if (rh == NULL) - return (0); + return (NULL); rh->rnh_preadd = rib4_preadd; #ifdef RADIX_MPATH rt_mpath_init_rnh(rh); #endif - *head = (void *)rh; - if (_in_rt_was_here == 0 ) { - _in_rt_was_here = 1; - } - return 1; + return (rh); } #ifdef VIMAGE -int -in_detachhead(void **head, int off) +void +in_detachhead(struct rib_head *rh) { - rt_table_destroy((struct rib_head *)(*head)); - return (1); + rt_table_destroy(rh); } #endif Index: sys/netinet/in_var.h =================================================================== --- sys/netinet/in_var.h +++ sys/netinet/in_var.h @@ -436,8 +436,7 @@ #define MCAST_NOTSMEMBER 2 /* This host excluded source */ #define MCAST_MUTED 3 /* [deprecated] */ -struct rtentry; -struct route; +struct rib_head; struct ip_moptions; struct in_multi *inm_lookup_locked(struct ifnet *, const struct in_addr); @@ -470,6 +469,10 @@ struct mbuf *ip_tryforward(struct mbuf *); void *in_domifattach(struct ifnet *); void in_domifdetach(struct ifnet *, void *); +struct rib_head *in_inithead(uint32_t fibnum); +#ifdef VIMAGE +void in_detachhead(struct rib_head *rh); +#endif #endif /* _KERNEL */ Index: sys/netinet6/in6_proto.c =================================================================== --- sys/netinet6/in6_proto.c +++ sys/netinet6/in6_proto.c @@ -333,11 +333,6 @@ }, }; -extern int in6_inithead(void **, int, u_int); -#ifdef VIMAGE -extern int in6_detachhead(void **, int); -#endif - struct domain inet6domain = { .dom_family = AF_INET6, .dom_name = "internet6", Index: sys/netinet6/in6_rmx.c =================================================================== --- sys/netinet6/in6_rmx.c +++ sys/netinet6/in6_rmx.c @@ -101,11 +101,6 @@ #include #include -extern int in6_inithead(void **head, int off, u_int fibnum); -#ifdef VIMAGE -extern int in6_detachhead(void **head, int off); -#endif - static int rib6_preadd(u_int fibnum, const struct sockaddr *addr, const struct sockaddr *mask, struct nhop_object *nh) @@ -147,8 +142,8 @@ * Initialize our routing tree. */ -int -in6_inithead(void **head, int off, u_int fibnum) +struct rib_head * +in6_inithead(uint32_t fibnum) { struct epoch_tracker et; struct rib_head *rh; @@ -156,13 +151,12 @@ rh = rt_table_init(offsetof(struct sockaddr_in6, sin6_addr) << 3, AF_INET6, fibnum); if (rh == NULL) - return (0); + return (NULL); rh->rnh_preadd = rib6_preadd; #ifdef RADIX_MPATH rt_mpath_init_rnh(rh); #endif - *head = (void *)rh; NET_EPOCH_ENTER(et); if (rib_subscribe(fibnum, AF_INET6, nd6_subscription_cb, NULL, @@ -171,17 +165,15 @@ fibnum); NET_EPOCH_EXIT(et); - return (1); + return (rh); } #ifdef VIMAGE -int -in6_detachhead(void **head, int off) +void +in6_detachhead(struct rib_head *rh) { - rt_table_destroy((struct rib_head *)(*head)); - - return (1); + rt_table_destroy(rh); } #endif Index: sys/netinet6/in6_var.h =================================================================== --- sys/netinet6/in6_var.h +++ sys/netinet6/in6_var.h @@ -857,6 +857,7 @@ struct ip6_moptions; struct sockopt; struct inpcbinfo; +struct rib_head; /* Multicast KPIs. */ int im6o_mc_filter(const struct ip6_moptions *, const struct ifnet *, @@ -891,6 +892,8 @@ void *in6_domifattach(struct ifnet *); void in6_domifdetach(struct ifnet *, void *); int in6_domifmtu(struct ifnet *); +struct rib_head *in6_inithead(uint32_t fibnum); +void in6_detachhead(struct rib_head *rh); void in6_setmaxmtu(void); int in6_if2idlen(struct ifnet *); struct in6_ifaddr *in6ifa_ifpforlinklocal(struct ifnet *, int); Index: sys/sys/domain.h =================================================================== --- sys/sys/domain.h +++ sys/sys/domain.h @@ -45,6 +45,7 @@ struct mbuf; struct ifnet; struct socket; +struct rib_head; struct domain { int dom_family; /* AF_xxx */ @@ -59,10 +60,10 @@ (struct socket *); struct protosw *dom_protosw, *dom_protoswNPROTOSW; struct domain *dom_next; - int (*dom_rtattach) /* initialize routing table */ - (void **, int, u_int); - int (*dom_rtdetach) /* clean up routing table */ - (void **, int); + struct rib_head *(*dom_rtattach) /* initialize routing table */ + (uint32_t); + void (*dom_rtdetach) /* clean up routing table */ + (struct rib_head *); void *(*dom_ifattach)(struct ifnet *); void (*dom_ifdetach)(struct ifnet *, void *); int (*dom_ifmtu)(struct ifnet *);