summaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorozaki-r <ozaki-r@NetBSD.org>2016-06-21 03:28:27 +0000
committerozaki-r <ozaki-r@NetBSD.org>2016-06-21 03:28:27 +0000
commita10bcd0ea4046a1b8917eff8bf12f033a6c14dc4 (patch)
tree7bded495e887fb4ef641ef70fad6ad3184b82314 /sys/net
parentab681f037c2368e97c6205cff6e4e536a1e61900 (diff)
Replace ifp of ip_moptions and ip6_moptions with if_index
The motivation is the same as the mbuf's rcvif case; avoid having a pointer of an ifnet object in ip_moptions and ip6_moptions, which is not MP-safe. ip_moptions and ip6_moptions can be stored in a PCB for inet or inet6 that's life time is different from ifnet one and so an ifnet object can be disappeared anytime we get it via them. Thus we need to look up an ifnet object by if_index every time for safe.
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/sys/net/if.h b/sys/net/if.h
index d6b9441db58..fd68ad36026 100644
--- a/sys/net/if.h
+++ b/sys/net/if.h
@@ -1,4 +1,4 @@
-/* $NetBSD: if.h,v 1.212 2016/06/21 03:07:54 ozaki-r Exp $ */
+/* $NetBSD: if.h,v 1.213 2016/06/21 03:28:27 ozaki-r Exp $ */
/*-
* Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -954,6 +954,13 @@ ifnet_t *if_get_byindex(u_int, struct psref *);
void if_put(const struct ifnet *, struct psref *);
void if_acquire_unsafe(struct ifnet *, struct psref *);
+static inline if_index_t
+if_get_index(const struct ifnet *ifp)
+{
+
+ return ifp != NULL ? ifp->if_index : 0;
+}
+
bool if_held(struct ifnet *);
void if_input(struct ifnet *, struct mbuf *);