Diff below is just a small refactoring of two similar code chunks to inform user processes that something changed regarding a route.
I'd like to get this in because it removes one use of rt_addrinfo in netinet6. There's no functional change, ok? Index: net/route.c =================================================================== RCS file: /home/ncvs/src/sys/net/route.c,v retrieving revision 1.145 diff -u -p -r1.145 route.c --- net/route.c 28 Aug 2013 06:58:57 -0000 1.145 +++ net/route.c 2 Sep 2013 10:18:59 -0000 @@ -346,17 +345,7 @@ rtalloc1(struct sockaddr *dst, int flags goto miss; } /* Inform listeners of the new route */ - bzero(&info, sizeof(info)); - info.rti_info[RTAX_DST] = rt_key(rt); - info.rti_info[RTAX_NETMASK] = rt_mask(rt); - info.rti_info[RTAX_GATEWAY] = rt->rt_gateway; - if (rt->rt_ifp != NULL) { - info.rti_info[RTAX_IFP] = - TAILQ_FIRST(&rt->rt_ifp->if_addrlist)->ifa_addr; - info.rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr; - } - rt_missmsg(RTM_ADD, &info, rt->rt_flags, - rt->rt_ifp, 0, tableid); + rt_msg(rt, RTM_ADD, tableid); } else rt->rt_refcnt++; } else { @@ -410,6 +399,25 @@ rtfree(struct rtentry *rt) Free(rt_key(rt)); pool_put(&rtentry_pool, rt); } +} + +/* tell the change to user processes watching the routing socket. */ +void +rt_msg(struct rtentry *rt, int cmd, u_int tableid) +{ + struct rt_addrinfo info; + + bzero(&info, sizeof(info)); + info.rti_info[RTAX_DST] = rt_key(rt); + info.rti_info[RTAX_GATEWAY] = rt->rt_gateway; + info.rti_info[RTAX_NETMASK] = rt_mask(rt); + if (rt->rt_ifp != NULL) { + info.rti_info[RTAX_IFP] = + TAILQ_FIRST(&rt->rt_ifp->if_addrlist)->ifa_addr; + info.rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr; + } + + rt_missmsg(cmd, &info, rt->rt_flags, rt->rt_ifp, 0, tableid); } void Index: net/route.h =================================================================== RCS file: /home/ncvs/src/sys/net/route.h,v retrieving revision 1.78 diff -u -p -r1.78 route.h --- net/route.h 19 Sep 2012 16:14:01 -0000 1.78 +++ net/route.h 2 Sep 2013 10:18:59 -0000 @@ -369,6 +369,7 @@ void rt_ifmsg(struct ifnet *); void rt_ifannouncemsg(struct ifnet *, int); void rt_maskedcopy(struct sockaddr *, struct sockaddr *, struct sockaddr *); +void rt_msg(struct rtentry *, int, u_int); void rt_missmsg(int, struct rt_addrinfo *, int, struct ifnet *, int, u_int); void rt_newaddrmsg(int, struct ifaddr *, int, struct rtentry *); Index: netinet6/nd6_rtr.c =================================================================== RCS file: /home/ncvs/src/sys/netinet6/nd6_rtr.c,v retrieving revision 1.72 diff -u -p -r1.72 nd6_rtr.c --- netinet6/nd6_rtr.c 1 Jul 2013 14:22:20 -0000 1.72 +++ netinet6/nd6_rtr.c 2 Sep 2013 10:18:59 -0000 @@ -70,7 +70,6 @@ void pfxrtr_add(struct nd_prefix *, stru void pfxrtr_del(struct nd_pfxrouter *); struct nd_pfxrouter *find_pfxlist_reachable_router(struct nd_prefix *); void defrouter_delreq(struct nd_defrouter *); -void nd6_rtmsg(int, struct rtentry *); void purge_detached(struct ifnet *); void in6_init_address_ltimes(struct nd_prefix *, struct in6_addrlifetime *); @@ -410,26 +409,6 @@ nd6_ra_input(struct mbuf *m, int off, in /* * default router list processing sub routines */ - -/* tell the change to user processes watching the routing socket. */ -void -nd6_rtmsg(int cmd, struct rtentry *rt) -{ - struct rt_addrinfo info; - - bzero((caddr_t)&info, sizeof(info)); - info.rti_info[RTAX_DST] = rt_key(rt); - info.rti_info[RTAX_GATEWAY] = rt->rt_gateway; - info.rti_info[RTAX_NETMASK] = rt_mask(rt); - if (rt->rt_ifp) { - info.rti_info[RTAX_IFP] = - TAILQ_FIRST(&rt->rt_ifp->if_addrlist)->ifa_addr; - info.rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr; - } - - rt_missmsg(cmd, &info, rt->rt_flags, rt->rt_ifp, 0, 0); -} - void defrouter_addreq(struct nd_defrouter *new) { @@ -459,7 +438,7 @@ defrouter_addreq(struct nd_defrouter *ne error = rtrequest1(RTM_ADD, &info, RTP_DEFAULT, &newrt, new->ifp->if_rdomain); if (newrt) { - nd6_rtmsg(RTM_ADD, newrt); /* tell user process */ + rt_msg(newrt, RTM_ADD, 0); /* tell user process */ newrt->rt_refcnt--; } if (error == 0) @@ -563,7 +542,7 @@ defrouter_delreq(struct nd_defrouter *dr rtrequest1(RTM_DELETE, &info, RTP_DEFAULT, &oldrt, dr->ifp->if_rdomain); if (oldrt) { - nd6_rtmsg(RTM_DELETE, oldrt); + rt_msg(oldrt, RTM_DELETE, 0); if (oldrt->rt_refcnt <= 0) { /* * XXX: borrowed from the RTM_DELETE case of @@ -1637,7 +1616,7 @@ nd6_prefix_onlink(struct nd_prefix *pr) error = rtrequest1(RTM_ADD, &info, RTP_CONNECTED, &rt, ifp->if_rdomain); if (error == 0) { if (rt != NULL) /* this should be non NULL, though */ - nd6_rtmsg(RTM_ADD, rt); + rt_msg(rt, RTM_ADD, 0); pr->ndpr_stateflags |= NDPRF_ONLINK; } else { nd6log((LOG_ERR, "nd6_prefix_onlink: failed to add route for a" @@ -1692,7 +1671,7 @@ nd6_prefix_offlink(struct nd_prefix *pr) /* report the route deletion to the routing socket. */ if (rt != NULL) - nd6_rtmsg(RTM_DELETE, rt); + rt_msg(rt, RTM_DELETE, 0); /* * There might be the same prefix on another interface,