When we already had a valid ``ifp'' I used it. Since defrouter_lookup()
is only doing a comparison, let's use interface indexes.
ok?
Index: netinet6/nd6.c
===================================================================
RCS file: /cvs/src/sys/netinet6/nd6.c,v
retrieving revision 1.166
diff -u -p -r1.166 nd6.c
--- netinet6/nd6.c 29 Oct 2015 14:28:34 -0000 1.166
+++ netinet6/nd6.c 29 Oct 2015 14:49:03 -0000
@@ -658,7 +658,7 @@ nd6_lookup(struct in6_addr *addr6, int c
*/
if ((rt->rt_flags & RTF_GATEWAY) || (rt->rt_flags & RTF_LLINFO) == 0 ||
rt->rt_gateway->sa_family != AF_LINK || rt->rt_llinfo == NULL ||
- (ifp != NULL && rt->rt_ifp != ifp)) {
+ (ifp != NULL && rt->rt_ifidx != ifp->if_index)) {
if (create) {
char addr[INET6_ADDRSTRLEN];
nd6log((LOG_DEBUG, "%s: failed to lookup %s (if=%s)\n",
@@ -751,17 +751,19 @@ nd6_free(struct rtentry *rt, int gc)
struct llinfo_nd6 *ln = (struct llinfo_nd6 *)rt->rt_llinfo, *next;
struct in6_addr in6 = satosin6(rt_key(rt))->sin6_addr;
struct nd_defrouter *dr;
+ struct ifnet *ifp;
int s;
/*
* we used to have pfctlinput(PRC_HOSTDEAD) here.
* even though it is not harmful, it was not really necessary.
*/
+ ifp = if_get(rt->rt_ifidx);
s = splsoftnet();
if (!ip6_forwarding) {
dr = defrouter_lookup(&satosin6(rt_key(rt))->sin6_addr,
- rt->rt_ifp);
+ rt->rt_ifidx);
if (dr != NULL && dr->expire &&
ln->ln_state == ND6_LLINFO_STALE && gc) {
@@ -783,6 +785,7 @@ nd6_free(struct rtentry *rt, int gc)
} else
nd6_llinfo_settimer(ln, (long)nd6_gctimer * hz);
splx(s);
+ if_put(ifp);
return (ln->ln_next);
}
@@ -792,7 +795,7 @@ nd6_free(struct rtentry *rt, int gc)
* is in the Default Router List.
* See a corresponding comment in nd6_na_input().
*/
- rt6_flush(&in6, rt->rt_ifp);
+ rt6_flush(&in6, ifp);
}
if (dr) {
@@ -839,9 +842,11 @@ nd6_free(struct rtentry *rt, int gc)
* caches, and disable the route entry not to be used in already
* cached routes.
*/
- rtdeletemsg(rt, rt->rt_ifp->if_rdomain);
+ rtdeletemsg(rt, ifp->if_rdomain);
splx(s);
+ if_put(ifp);
+
return (next);
}
@@ -899,7 +904,8 @@ nd6_rtrequest(struct ifnet *ifp, int req
&in6addr_any) && rt_mask(rt) && (rt_mask(rt)->sa_len == 0 ||
IN6_ARE_ADDR_EQUAL(&(satosin6(rt_mask(rt)))->sin6_addr,
&in6addr_any)))) {
- dr = defrouter_lookup(&satosin6(gate)->sin6_addr, ifp);
+ dr = defrouter_lookup(&satosin6(gate)->sin6_addr,
+ ifp->if_index);
if (dr)
dr->installed = 0;
}
Index: netinet6/nd6.h
===================================================================
RCS file: /cvs/src/sys/netinet6/nd6.h,v
retrieving revision 1.52
diff -u -p -r1.52 nd6.h
--- netinet6/nd6.h 28 Oct 2015 12:14:25 -0000 1.52
+++ netinet6/nd6.h 29 Oct 2015 14:42:35 -0000
@@ -299,7 +299,7 @@ int prelist_update(struct nd_prefix *, s
int nd6_prelist_add(struct nd_prefix *, struct nd_defrouter *,
struct nd_prefix **);
void pfxlist_onlink_check(void);
-struct nd_defrouter *defrouter_lookup(struct in6_addr *, struct ifnet *);
+struct nd_defrouter *defrouter_lookup(struct in6_addr *, unsigned int);
struct nd_prefix *nd6_prefix_lookup(struct nd_prefix *);
int in6_ifdel(struct ifnet *, struct in6_addr *);
Index: netinet6/nd6_nbr.c
===================================================================
RCS file: /cvs/src/sys/netinet6/nd6_nbr.c,v
retrieving revision 1.97
diff -u -p -r1.97 nd6_nbr.c
--- netinet6/nd6_nbr.c 22 Oct 2015 15:37:47 -0000 1.97
+++ netinet6/nd6_nbr.c 29 Oct 2015 14:47:42 -0000
@@ -730,7 +730,7 @@ nd6_na_input(struct mbuf *m, int off, in
ln->ln_byhint = 0;
if (!ND6_LLINFO_PERMANENT(ln)) {
nd6_llinfo_settimer(ln,
- (long)ND_IFINFO(rt->rt_ifp)->reachable *
hz);
+ (long)ND_IFINFO(ifp)->reachable * hz);
}
} else {
ln->ln_state = ND6_LLINFO_STALE;
@@ -851,7 +851,7 @@ nd6_na_input(struct mbuf *m, int off, in
* context. However, we keep it just for safety.
*/
s = splsoftnet();
- dr = defrouter_lookup(in6, rt->rt_ifp);
+ dr = defrouter_lookup(in6, rt->rt_ifidx);
if (dr)
defrtrlist_del(dr);
else if (!ip6_forwarding) {
@@ -862,7 +862,7 @@ nd6_na_input(struct mbuf *m, int off, in
* (e.g. redirect case). So we must
* call rt6_flush explicitly.
*/
- rt6_flush(&ip6->ip6_src, rt->rt_ifp);
+ rt6_flush(&ip6->ip6_src, ifp);
}
splx(s);
}
Index: netinet6/nd6_rtr.c
===================================================================
RCS file: /cvs/src/sys/netinet6/nd6_rtr.c,v
retrieving revision 1.130
diff -u -p -r1.130 nd6_rtr.c
--- netinet6/nd6_rtr.c 28 Oct 2015 12:14:25 -0000 1.130
+++ netinet6/nd6_rtr.c 29 Oct 2015 14:46:19 -0000
@@ -611,12 +611,13 @@ defrouter_addreq(struct nd_defrouter *ne
}
struct nd_defrouter *
-defrouter_lookup(struct in6_addr *addr, struct ifnet *ifp)
+defrouter_lookup(struct in6_addr *addr, unsigned int ifidx)
{
struct nd_defrouter *dr;
TAILQ_FOREACH(dr, &nd_defrouter, dr_entry)
- if (dr->ifp == ifp && IN6_ARE_ADDR_EQUAL(addr, &dr->rtaddr))
+ if (dr->ifp->if_index == ifidx &&
+ IN6_ARE_ADDR_EQUAL(addr, &dr->rtaddr))
return (dr);
return (NULL); /* search failed */
@@ -873,7 +874,7 @@ defrtrlist_update(struct nd_defrouter *n
struct in6_ifextra *ext = new->ifp->if_afdata[AF_INET6];
int s = splsoftnet();
- if ((dr = defrouter_lookup(&new->rtaddr, new->ifp)) != NULL) {
+ if ((dr = defrouter_lookup(&new->rtaddr, new->ifp->if_index)) != NULL) {
/* entry exists */
if (new->rtlifetime == 0) {
defrtrlist_del(dr);