Re: Introduce rt_msg() (was nd6_rtmsg)

2014-01-14 Thread Martin Pieuchot
On 02/09/13(Mon) 07:54, Kenneth R Westerback wrote:
 On Mon, Sep 02, 2013 at 12:43:51PM +0200, Martin Pieuchot wrote:
  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?
  
 
 This seems sane. ok krw@ fwiw.
 
 I would suggest copying the 'Inform listeners of the new route'
 comment to replace the 'tell the change to user processes watching
 the routing socket' comment. The latter reads very oddly to my
 native english speaking brain.

Here's an updated diff that takes into consideration all the previous
comments (changed the named and removed the comment), plus it fixes
the newly added `rtableid' argument in the IPv6 case to not
dereference `rt_ifp' if it is null.

Still ok?

Index: net/route.c
===
RCS file: /home/ncvs/src/sys/net/route.c,v
retrieving revision 1.149
diff -u -p -r1.149 route.c
--- net/route.c 10 Jan 2014 14:29:08 -  1.149
+++ net/route.c 14 Jan 2014 14:30:29 -
@@ -345,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_sendmsg(rt, RTM_ADD, tableid);
} else
rt-rt_refcnt++;
} else {
@@ -409,6 +399,24 @@ rtfree(struct rtentry *rt)
free(rt_key(rt), M_RTABLE);
pool_put(rtentry_pool, rt);
}
+}
+
+void
+rt_sendmsg(struct rtentry *rt, int cmd, u_int rtableid)
+{
+   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, rtableid);
 }
 
 void
Index: net/route.h
===
RCS file: /home/ncvs/src/sys/net/route.h,v
retrieving revision 1.83
diff -u -p -r1.83 route.h
--- net/route.h 31 Oct 2013 18:10:21 -  1.83
+++ net/route.h 14 Jan 2014 14:30:29 -
@@ -413,6 +413,7 @@ void rt_ifmsg(struct ifnet *);
 voidrt_ifannouncemsg(struct ifnet *, int);
 voidrt_maskedcopy(struct sockaddr *,
struct sockaddr *, struct sockaddr *);
+voidrt_sendmsg(struct rtentry *, int, u_int);
 voidrt_missmsg(int, struct rt_addrinfo *, int, struct ifnet *, int,
u_int);
 voidrt_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.77
diff -u -p -r1.77 nd6_rtr.c
--- netinet6/nd6_rtr.c  13 Jan 2014 23:03:52 -  1.77
+++ netinet6/nd6_rtr.c  14 Jan 2014 14:30:29 -
@@ -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 *);
@@ -425,27 +424,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, 

Re: Introduce rt_msg() (was nd6_rtmsg)

2013-09-05 Thread Alexander Bluhm
On Mon, Sep 02, 2013 at 12:43:51PM +0200, Martin Pieuchot wrote:
 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?

Less code is always good.  OK bluhm@

 
 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 -  1.145
 +++ net/route.c   2 Sep 2013 10:18:59 -
 @@ -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 -  1.78
 +++ net/route.h   2 Sep 2013 10:18:59 -
 @@ -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.c1 Jul 2013 14:22:20 -   1.72
 +++ netinet6/nd6_rtr.c2 Sep 2013 10:18:59 -
 @@ -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)
 @@ 

Introduce rt_msg() (was nd6_rtmsg)

2013-09-02 Thread Martin Pieuchot
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 -  1.145
+++ net/route.c 2 Sep 2013 10:18:59 -
@@ -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 -  1.78
+++ net/route.h 2 Sep 2013 10:18:59 -
@@ -369,6 +369,7 @@ void rt_ifmsg(struct ifnet *);
 voidrt_ifannouncemsg(struct ifnet *, int);
 voidrt_maskedcopy(struct sockaddr *,
struct sockaddr *, struct sockaddr *);
+voidrt_msg(struct rtentry *, int, u_int);
 voidrt_missmsg(int, struct rt_addrinfo *, int, struct ifnet *, int,
u_int);
 voidrt_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 -   1.72
+++ netinet6/nd6_rtr.c  2 Sep 2013 10:18:59 -
@@ -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);
  

Re: Introduce rt_msg() (was nd6_rtmsg)

2013-09-02 Thread Martin Pieuchot
On 02/09/13(Mon) 07:54, Kenneth R Westerback wrote:
 On Mon, Sep 02, 2013 at 12:43:51PM +0200, Martin Pieuchot wrote:
  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?
  
 
 This seems sane. ok krw@ fwiw.
 
 I would suggest copying the 'Inform listeners of the new route'
 comment to replace the 'tell the change to user processes watching
 the routing socket' comment. The latter reads very oddly to my
 native english speaking brain.

Thanks Ken, I take your suggestion and I'll wait for the return of
claudio@ to see what he thinks about the direction of the routing
table before attempting any change.

 
  Ken
 
  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 -  1.145
  +++ net/route.c 2 Sep 2013 10:18:59 -
  @@ -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 -  1.78
  +++ net/route.h 2 Sep 2013 10:18:59 -
  @@ -369,6 +369,7 @@ void rt_ifmsg(struct ifnet *);
   voidrt_ifannouncemsg(struct ifnet *, int);
   voidrt_maskedcopy(struct sockaddr *,
  struct sockaddr *, struct sockaddr *);
  +voidrt_msg(struct rtentry *, int, u_int);
   voidrt_missmsg(int, struct rt_addrinfo *, int, struct ifnet *, int,
  u_int);
   voidrt_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 -   1.72
  +++ netinet6/nd6_rtr.c  2 Sep 2013 10:18:59 -
  @@ -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;
  -   }

Re: Introduce rt_msg() (was nd6_rtmsg)

2013-09-02 Thread Kenneth R Westerback
On Mon, Sep 02, 2013 at 12:43:51PM +0200, Martin Pieuchot wrote:
 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?
 

This seems sane. ok krw@ fwiw.

I would suggest copying the 'Inform listeners of the new route'
comment to replace the 'tell the change to user processes watching
the routing socket' comment. The latter reads very oddly to my
native english speaking brain.

 Ken

 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 -  1.145
 +++ net/route.c   2 Sep 2013 10:18:59 -
 @@ -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 -  1.78
 +++ net/route.h   2 Sep 2013 10:18:59 -
 @@ -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.c1 Jul 2013 14:22:20 -   1.72
 +++ netinet6/nd6_rtr.c2 Sep 2013 10:18:59 -
 @@ -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,