diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-12-03 14:19:56 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-12-03 14:19:56 +0000 |
commit | 408a66936c0f91578d26258dc6f232569860e129 (patch) | |
tree | 27193fd588beb54421f10e497181897896247632 /sys/net | |
parent | d3f72f555df1d0f3b3cf927894fe87abac7d2c4c (diff) |
Store an interface index instead of a pointer in the "struct rtentry".
These indexes are unique and should be used with if_get() to get a
pointer to the corresponding ``ifp''. Such pointer is guaranteed to
be valid in a MP environment until if_put() is called.
ok claudio@, sthen@
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/route.c | 6 | ||||
-rw-r--r-- | sys/net/route.h | 12 | ||||
-rw-r--r-- | sys/net/rtsock.c | 4 |
3 files changed, 11 insertions, 11 deletions
diff --git a/sys/net/route.c b/sys/net/route.c index 99a908064b1..d160dd7ec4e 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.283 2015/12/02 16:49:58 bluhm Exp $ */ +/* $OpenBSD: route.c,v 1.284 2015/12/03 14:19:55 mpi Exp $ */ /* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */ /* @@ -1009,7 +1009,7 @@ rtrequest(int req, struct rt_addrinfo *info, u_int8_t prio, ifa->ifa_refcnt++; rt->rt_ifa = ifa; - rt->rt_ifp = ifp; + rt->rt_ifidx = ifp->if_index; if (rt->rt_flags & RTF_CLONED) { /* * If the ifa of the cloning route was stale, a @@ -1031,7 +1031,7 @@ rtrequest(int req, struct rt_addrinfo *info, u_int8_t prio, ifa->ifa_refcnt++; (*ret_nrt)->rt_ifa = ifa; - (*ret_nrt)->rt_ifp = ifp; + (*ret_nrt)->rt_ifidx = ifp->if_index; ifp->if_rtrequest(ifp, RTM_ADD, *ret_nrt); } /* diff --git a/sys/net/route.h b/sys/net/route.h index ae58d77269e..4cdd6b8da6c 100644 --- a/sys/net/route.h +++ b/sys/net/route.h @@ -1,4 +1,4 @@ -/* $OpenBSD: route.h,v 1.126 2015/12/02 16:35:53 bluhm Exp $ */ +/* $OpenBSD: route.h,v 1.127 2015/12/03 14:19:55 mpi Exp $ */ /* $NetBSD: route.h,v 1.9 1996/02/13 22:00:49 christos Exp $ */ /* @@ -102,8 +102,6 @@ struct rtentry { struct srpl_entry rt_next; /* Next multipath entry to our dst. */ #endif struct sockaddr *rt_gateway; /* value */ - struct ifnet *rt_ifp; /* the answer: interface to use */ -#define rt_ifidx rt_ifp->if_index struct ifaddr *rt_ifa; /* the answer: interface addr to use */ caddr_t rt_llinfo; /* pointer to link level info cache or to an MPLS structure */ @@ -111,6 +109,7 @@ struct rtentry { struct rtentry *rt_parent; /* If cloned, parent of this route. */ LIST_HEAD(, rttimer) rt_timer; /* queue of timeouts for misc funcs */ struct rt_kmetrics rt_rmx; /* metrics used by rx'ing protocols */ + unsigned int rt_ifidx; /* the answer: interface to use */ unsigned int rt_flags; /* up/down?, host/net */ unsigned int rt_tableid; /* routing table ID */ int rt_refcnt; /* # held references */ @@ -345,10 +344,11 @@ void rtlabel_unref(u_int16_t); extern struct rtstat rtstat; extern const struct sockaddr_rtin rt_defmask4; -struct mbuf; -struct socket; -void route_init(void); +struct mbuf; +struct socket; +struct ifnet; +void route_init(void); int route_output(struct mbuf *, ...); int route_usrreq(struct socket *, int, struct mbuf *, struct mbuf *, struct mbuf *, struct proc *); diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index af6c188c847..6f1ab2bce12 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtsock.c,v 1.183 2015/11/18 14:13:52 mpi Exp $ */ +/* $OpenBSD: rtsock.c,v 1.184 2015/12/03 14:19:55 mpi Exp $ */ /* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */ /* @@ -758,7 +758,7 @@ report: ifa->ifa_refcnt++; rt->rt_ifa = ifa; - rt->rt_ifp = ifa->ifa_ifp; + rt->rt_ifidx = ifa->ifa_ifp->if_index; #ifndef SMALL_KERNEL /* recheck link state after ifp change*/ rt_if_linkstate_change(rt, ifa->ifa_ifp, |