From f5e0f62b31a9ad900fac3ebf4c555d63351c2c0d Mon Sep 17 00:00:00 2001 From: mpi Date: Tue, 27 Oct 2015 10:52:17 +0000 Subject: [PATCH] Use rt_ifidx rather than rt_ifp. ok bluhm@ --- sys/net/if.c | 17 ++++++++++++----- sys/net/pf.c | 10 ++++++---- sys/netinet6/nd6.c | 7 ++++--- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/sys/net/if.c b/sys/net/if.c index 66cc8b9e19f..e433dcf9dba 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.398 2015/10/25 21:58:04 deraadt Exp $ */ +/* $OpenBSD: if.c,v 1.399 2015/10/27 10:52:17 mpi Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -2341,6 +2341,7 @@ if_group_routechange(struct sockaddr *dst, struct sockaddr *mask) int if_group_egress_build(void) { + struct ifnet *ifp; struct ifg_group *ifg; struct ifg_member *ifgm, *next; struct sockaddr_in sa_in; @@ -2364,8 +2365,11 @@ if_group_egress_build(void) if (rt0 != NULL) { rt = rt0; do { - if (rt->rt_ifp) - if_addgroup(rt->rt_ifp, IFG_EGRESS); + ifp = if_get(rt->rt_ifidx); + if (ifp != NULL) { + if_addgroup(ifp, IFG_EGRESS); + if_put(ifp); + } #ifndef SMALL_KERNEL rt = rt_mpath_next(rt); #else @@ -2381,8 +2385,11 @@ if_group_egress_build(void) if (rt0 != NULL) { rt = rt0; do { - if (rt->rt_ifp) - if_addgroup(rt->rt_ifp, IFG_EGRESS); + ifp = if_get(rt->rt_ifidx); + if (ifp != NULL) { + if_addgroup(ifp, IFG_EGRESS); + if_put(ifp); + } #ifndef SMALL_KERNEL rt = rt_mpath_next(rt); #else diff --git a/sys/net/pf.c b/sys/net/pf.c index 174a4cc478f..a3ba046611c 100644 --- a/sys/net/pf.c +++ b/sys/net/pf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pf.c,v 1.947 2015/10/13 19:32:31 sashan Exp $ */ +/* $OpenBSD: pf.c,v 1.948 2015/10/27 10:52:17 mpi Exp $ */ /* * Copyright (c) 2001 Daniel Hartmeier @@ -2912,6 +2912,7 @@ pf_get_mss(struct pf_pdesc *pd) u_int16_t pf_calc_mss(struct pf_addr *addr, sa_family_t af, int rtableid, u_int16_t offer) { + struct ifnet *ifp; struct sockaddr_in *dst; #ifdef INET6 struct sockaddr_in6 *dst6; @@ -2944,11 +2945,12 @@ pf_calc_mss(struct pf_addr *addr, sa_family_t af, int rtableid, u_int16_t offer) #endif /* INET6 */ } - if (rt && rt->rt_ifp) { - mss = rt->rt_ifp->if_mtu - hlen - sizeof(struct tcphdr); + if (rt != NULL && (ifp = if_get(rt->rt_ifidx)) != NULL) { + mss = ifp->if_mtu - hlen - sizeof(struct tcphdr); mss = max(tcp_mssdflt, mss); - rtfree(rt); + if_put(ifp); } + rtfree(rt); mss = min(mss, offer); mss = max(mss, 64); /* sanity - at least max opt space */ return (mss); diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c index b40d1f4dcef..c065406742d 100644 --- a/sys/netinet6/nd6.c +++ b/sys/netinet6/nd6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nd6.c,v 1.162 2015/10/25 15:11:52 deraadt Exp $ */ +/* $OpenBSD: nd6.c,v 1.163 2015/10/27 10:52:18 mpi Exp $ */ /* $KAME: nd6.c,v 1.280 2002/06/08 19:52:07 itojun Exp $ */ /* @@ -392,8 +392,8 @@ nd6_llinfo_timer(void *arg) if ((rt = ln->ln_rt) == NULL) panic("ln->ln_rt == NULL"); - if ((ifp = rt->rt_ifp) == NULL) - panic("ln->ln_rt->rt_ifp == NULL"); + if ((ifp = if_get(rt->rt_ifidx)) == NULL) + return; ndi = ND_IFINFO(ifp); dst = satosin6(rt_key(rt)); @@ -477,6 +477,7 @@ nd6_llinfo_timer(void *arg) break; } + if_put(ifp); splx(s); } -- 2.20.1