On Thu, Nov 05, 2015 at 11:53:34AM +0100, Martin Pieuchot wrote:
> Change nd6_nud_hint() to no longer use rt_ifp directly. While here
> remove unused argument and convert the route check to rtisvalid(9).
>
> ok?
OK bluhm@
>
> Index: netinet/tcp_input.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet/tcp_input.c,v
> retrieving revision 1.307
> diff -u -p -r1.307 tcp_input.c
> --- netinet/tcp_input.c 28 Oct 2015 12:14:25 -0000 1.307
> +++ netinet/tcp_input.c 5 Nov 2015 10:47:29 -0000
> @@ -144,10 +144,9 @@ struct timeval tcp_ackdrop_ppslim_last;
> #ifdef INET6
> #define ND6_HINT(tp) \
> do { \
> - if (tp && tp->t_inpcb && (tp->t_inpcb->inp_flags & INP_IPV6) && \
> - tp->t_inpcb->inp_route6.ro_rt) { \
> - nd6_nud_hint(tp->t_inpcb->inp_route6.ro_rt, \
> - tp->t_inpcb->inp_rtableid); \
> + if (tp && tp->t_inpcb && (tp->t_inpcb->inp_flags & INP_IPV6) && \
> + rtisvalid(tp->t_inpcb->inp_route6.ro_rt)) { \
> + nd6_nud_hint(tp->t_inpcb->inp_route6.ro_rt); \
> } \
> } while (0)
> #else
> Index: netinet6/nd6.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet6/nd6.c,v
> retrieving revision 1.171
> diff -u -p -r1.171 nd6.c
> --- netinet6/nd6.c 2 Nov 2015 12:51:16 -0000 1.171
> +++ netinet6/nd6.c 5 Nov 2015 10:49:44 -0000
> @@ -847,25 +847,26 @@ nd6_free(struct rtentry *rt, int gc)
> * XXX cost-effective methods?
> */
> void
> -nd6_nud_hint(struct rtentry *rt, u_int rtableid)
> +nd6_nud_hint(struct rtentry *rt)
> {
> struct llinfo_nd6 *ln;
> + struct ifnet *ifp;
>
> - if (rt == NULL) {
> + ifp = if_get(rt->rt_ifidx);
> + if (ifp == NULL)
> return;
> - }
>
> if ((rt->rt_flags & RTF_GATEWAY) != 0 ||
> (rt->rt_flags & RTF_LLINFO) == 0 ||
> rt->rt_llinfo == NULL || rt->rt_gateway == NULL ||
> rt->rt_gateway->sa_family != AF_LINK) {
> /* This is not a host route. */
> - return;
> + goto out;
> }
>
> ln = (struct llinfo_nd6 *)rt->rt_llinfo;
> if (ln->ln_state < ND6_LLINFO_REACHABLE)
> - return;
> + goto out;
>
> /*
> * if we get upper-layer reachability confirmation many times,
> @@ -873,13 +874,13 @@ nd6_nud_hint(struct rtentry *rt, u_int r
> */
> ln->ln_byhint++;
> if (ln->ln_byhint > nd6_maxnudhint)
> - return;
> + goto out;
>
> ln->ln_state = ND6_LLINFO_REACHABLE;
> - if (!ND6_LLINFO_PERMANENT(ln)) {
> - nd6_llinfo_settimer(ln,
> - (long)ND_IFINFO(rt->rt_ifp)->reachable * hz);
> - }
> + if (!ND6_LLINFO_PERMANENT(ln))
> + nd6_llinfo_settimer(ln, (long)ND_IFINFO(ifp)->reachable * hz);
> +out:
> + if_put(ifp);
> }
>
> void
> Index: netinet6/nd6.h
> ===================================================================
> RCS file: /cvs/src/sys/netinet6/nd6.h,v
> retrieving revision 1.54
> diff -u -p -r1.54 nd6.h
> --- netinet6/nd6.h 2 Nov 2015 12:51:16 -0000 1.54
> +++ netinet6/nd6.h 5 Nov 2015 10:42:51 -0000
> @@ -258,7 +258,7 @@ void nd6_setmtu(struct ifnet *);
> void nd6_llinfo_settimer(struct llinfo_nd6 *, long);
> void nd6_timer(void *);
> void nd6_purge(struct ifnet *);
> -void nd6_nud_hint(struct rtentry *, u_int);
> +void nd6_nud_hint(struct rtentry *);
> int nd6_resolve(struct ifnet *, struct rtentry *,
> struct mbuf *, struct sockaddr *, u_char *);
> void nd6_rtrequest(struct ifnet *, int, struct rtentry *);