-/* $OpenBSD: if.c,v 1.306 2014/12/08 10:46:14 mpi Exp $ */
+/* $OpenBSD: if.c,v 1.307 2014/12/17 09:45:59 mpi Exp $ */
/* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */
/*
#endif
#undef IF_DETACH_QUEUES
- /*
- * XXX transient ifp refs? inpcb.ip_moptions.imo_multicast_ifp?
- * Other network stacks than INET?
- */
-
/* Remove the interface from the list of all interfaces. */
TAILQ_REMOVE(&ifnet, ifp, if_list);
if (ISSET(ifp->if_xflags, IFXF_TXREADY))
-/* $OpenBSD: if_pfsync.c,v 1.212 2014/11/23 07:39:02 deraadt Exp $ */
+/* $OpenBSD: if_pfsync.c,v 1.213 2014/12/17 09:45:59 mpi Exp $ */
/*
* Copyright (c) 2002 Michael Shalayeff
if (imo->imo_num_memberships > 0) {
in_delmulti(imo->imo_membership[
--imo->imo_num_memberships]);
- imo->imo_multicast_ifp = NULL;
+ imo->imo_ifidx = 0;
}
splx(s);
break;
if (imo->imo_num_memberships > 0) {
in_delmulti(imo->imo_membership[--imo->imo_num_memberships]);
- imo->imo_multicast_ifp = NULL;
+ imo->imo_ifidx = 0;
}
if (sc->sc_sync_if &&
return (ENOBUFS);
}
imo->imo_num_memberships++;
- imo->imo_multicast_ifp = sc->sc_sync_if;
+ imo->imo_ifidx = sc->sc_sync_if->if_index;
imo->imo_multicast_ttl = PFSYNC_DFLTTL;
imo->imo_multicast_loop = 0;
}
-/* $OpenBSD: if_vxlan.c,v 1.17 2014/12/05 15:50:04 mpi Exp $ */
+/* $OpenBSD: if_vxlan.c,v 1.18 2014/12/17 09:45:59 mpi Exp $ */
/*
* Copyright (c) 2013 Reyk Floeter <reyk@openbsd.org>
{
struct vxlan_softc *sc = (struct vxlan_softc *)ifp->if_softc;
struct ip_moptions *imo = &sc->sc_imo;
- struct ifnet *mifp = imo->imo_multicast_ifp;
+ struct ifnet *mifp;
+ mifp = if_get(imo->imo_ifidx);
if (mifp != NULL) {
if (sc->sc_ahcookie != NULL) {
hook_disestablish(mifp->if_addrhooks, sc->sc_ahcookie);
if (imo->imo_num_memberships > 0) {
in_delmulti(imo->imo_membership[--imo->imo_num_memberships]);
- imo->imo_multicast_ifp = NULL;
+ imo->imo_ifidx = 0;
}
}
return (ENOBUFS);
imo->imo_num_memberships++;
- imo->imo_multicast_ifp = mifp;
+ imo->imo_ifidx = mifp->if_index;
if (sc->sc_ttl > 0)
imo->imo_multicast_ttl = sc->sc_ttl;
else
-/* $OpenBSD: igmp.c,v 1.46 2014/11/18 02:37:31 tedu Exp $ */
+/* $OpenBSD: igmp.c,v 1.47 2014/12/17 09:45:59 mpi Exp $ */
/* $NetBSD: igmp.c,v 1.15 1996/02/13 23:41:25 christos Exp $ */
/*
m->m_data -= sizeof(struct ip);
m->m_len += sizeof(struct ip);
- imo.imo_multicast_ifp = if_get(inm->inm_ifidx);
+ imo.imo_ifidx = inm->inm_ifidx;
imo.imo_multicast_ttl = 1;
/*
-/* $OpenBSD: in_pcb.c,v 1.164 2014/12/05 15:50:04 mpi Exp $ */
+/* $OpenBSD: in_pcb.c,v 1.165 2014/12/17 09:45:59 mpi Exp $ */
/* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */
/*
if (IN_MULTICAST(sin->sin_addr.s_addr) && mopts != NULL) {
struct ifnet *ifp;
- ifp = mopts->imo_multicast_ifp;
+ ifp = if_get(mopts->imo_ifidx);
if (ifp != NULL) {
if (ifp->if_rdomain == rtable_l2(rtableid))
IFP_TO_IA(ifp, ia);
-/* $OpenBSD: ip_carp.c,v 1.240 2014/12/05 15:50:04 mpi Exp $ */
+/* $OpenBSD: ip_carp.c,v 1.241 2014/12/17 09:45:59 mpi Exp $ */
/*
* Copyright (c) 2002 Michael Shalayeff. All rights reserved.
}
}
imo->imo_num_memberships = 0;
- imo->imo_multicast_ifp = NULL;
+ imo->imo_ifidx = 0;
#ifdef INET6
while (!LIST_EMPTY(&im6o->im6o_memberships)) {
LIST_REMOVE(imm, i6mm_chain);
in6_leavegroup(imm);
}
- im6o->im6o_multicast_ifp = NULL;
+ im6o->im6o_ifidx = 0;
#endif
/* And any other multicast memberships */
imo->imo_membership[0] = imm;
imo->imo_num_memberships = 1;
- imo->imo_multicast_ifp = &sc->sc_if;
+ imo->imo_ifidx = sc->sc_if.if_index;
imo->imo_multicast_ttl = CARP_DFLTTL;
imo->imo_multicast_loop = 0;
return (0);
}
/* apply v6 multicast membership */
- im6o->im6o_multicast_ifp = &sc->sc_if;
+ im6o->im6o_ifidx = sc->sc_if.if_index;
if (imm)
LIST_INSERT_HEAD(&im6o->im6o_memberships, imm,
i6mm_chain);
-/* $OpenBSD: ip_mroute.c,v 1.72 2014/12/05 15:50:04 mpi Exp $ */
+/* $OpenBSD: ip_mroute.c,v 1.73 2014/12/17 09:45:59 mpi Exp $ */
/* $NetBSD: ip_mroute.c,v 1.85 2004/04/26 01:31:57 matt Exp $ */
/*
*/
struct ip_moptions imo;
- imo.imo_multicast_ifp = vifp->v_ifp;
+ imo.imo_ifidx = vifp->v_ifp->if_index;
imo.imo_multicast_ttl = mtod(m, struct ip *)->ip_ttl - IPTTLDEC;
imo.imo_multicast_loop = 1;
-/* $OpenBSD: ip_output.c,v 1.274 2014/12/08 10:51:00 mpi Exp $ */
+/* $OpenBSD: ip_output.c,v 1.275 2014/12/17 09:45:59 mpi Exp $ */
/* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */
/*
if ((IN_MULTICAST(ip->ip_dst.s_addr) ||
(ip->ip_dst.s_addr == INADDR_BROADCAST)) &&
- imo != NULL && imo->imo_multicast_ifp != NULL) {
- ifp = imo->imo_multicast_ifp;
+ imo != NULL && (ifp = if_get(imo->imo_ifidx)) != NULL) {
mtu = ifp->if_mtu;
IFP_TO_IA(ifp, ia);
} else {
if ((IN_MULTICAST(ip->ip_dst.s_addr) ||
(ip->ip_dst.s_addr == INADDR_BROADCAST)) &&
- imo != NULL && imo->imo_multicast_ifp != NULL) {
- ifp = imo->imo_multicast_ifp;
+ imo != NULL && (ifp = if_get(imo->imo_ifidx)) != NULL) {
mtu = ifp->if_mtu;
IFP_TO_IA(ifp, ia);
} else {
(sizeof(*immp) * IP_MIN_MEMBERSHIPS), M_IPMOPTS,
M_WAITOK|M_ZERO);
*imop = imo;
- imo->imo_multicast_ifp = NULL;
+ imo->imo_ifidx = 0;
imo->imo_multicast_ttl = IP_DEFAULT_MULTICAST_TTL;
imo->imo_multicast_loop = IP_DEFAULT_MULTICAST_LOOP;
imo->imo_num_memberships = 0;
* chosen every time a multicast packet is sent.
*/
if (addr.s_addr == INADDR_ANY) {
- imo->imo_multicast_ifp = NULL;
+ imo->imo_ifidx = 0;
break;
}
/*
error = EADDRNOTAVAIL;
break;
}
- imo->imo_multicast_ifp = ifp;
+ imo->imo_ifidx = ifp->if_index;
break;
case IP_MULTICAST_TTL:
/*
* If all options have default values, no need to keep the data.
*/
- if (imo->imo_multicast_ifp == NULL &&
+ if (imo->imo_ifidx == 0 &&
imo->imo_multicast_ttl == IP_DEFAULT_MULTICAST_TTL &&
imo->imo_multicast_loop == IP_DEFAULT_MULTICAST_LOOP &&
imo->imo_num_memberships == 0) {
u_char *loop;
struct in_addr *addr;
struct in_ifaddr *ia;
+ struct ifnet *ifp;
*mp = m_get(M_WAIT, MT_SOOPTS);
case IP_MULTICAST_IF:
addr = mtod(*mp, struct in_addr *);
(*mp)->m_len = sizeof(struct in_addr);
- if (imo == NULL || imo->imo_multicast_ifp == NULL)
+ if (imo == NULL || (ifp = if_get(imo->imo_ifidx)) == NULL)
addr->s_addr = INADDR_ANY;
else {
- IFP_TO_IA(imo->imo_multicast_ifp, ia);
+ IFP_TO_IA(ifp, ia);
addr->s_addr = (ia == NULL) ? INADDR_ANY
: ia->ia_addr.sin_addr.s_addr;
}
-/* $OpenBSD: ip_var.h,v 1.57 2014/11/05 14:03:02 mpi Exp $ */
+/* $OpenBSD: ip_var.h,v 1.58 2014/12/17 09:45:59 mpi Exp $ */
/* $NetBSD: ip_var.h,v 1.16 1996/02/13 23:43:20 christos Exp $ */
/*
* passed to ip_output when IP multicast options are in use.
*/
struct ip_moptions {
- struct ifnet *imo_multicast_ifp; /* ifp for outgoing multicasts */
+ struct in_multi **imo_membership; /* group memberships */
+ unsigned short imo_ifidx; /* ifp index for outgoing multicasts */
u_int8_t imo_multicast_ttl; /* TTL for outgoing multicasts */
u_int8_t imo_multicast_loop; /* 1 => hear sends if a member */
u_int16_t imo_num_memberships; /* no. memberships this socket */
u_int16_t imo_max_memberships; /* max memberships this socket */
- struct in_multi **imo_membership; /* group memberships */
};
#include <sys/queue.h>
-/* $OpenBSD: in6_src.c,v 1.49 2014/12/05 15:50:04 mpi Exp $ */
+/* $OpenBSD: in6_src.c,v 1.50 2014/12/17 09:45:59 mpi Exp $ */
/* $KAME: in6_src.c,v 1.36 2001/02/06 04:08:17 itojun Exp $ */
/*
* choose a loopback interface as the outgoing interface.
*/
if (IN6_IS_ADDR_MULTICAST(dst)) {
- ifp = mopts ? mopts->im6o_multicast_ifp : NULL;
+ ifp = mopts ? if_get(mopts->im6o_ifidx) : NULL;
if (!ifp && dstsock->sin6_scope_id)
ifp = if_get(htons(dstsock->sin6_scope_id));
* interface for the address is specified by the caller, use it.
*/
if (IN6_IS_ADDR_MULTICAST(dst) &&
- mopts != NULL && (ifp = mopts->im6o_multicast_ifp) != NULL) {
+ mopts != NULL && (ifp = if_get(mopts->im6o_ifidx)) != NULL) {
goto done; /* we do not need a route for multicast. */
}
in6->s6_addr16[1] = htons(pi->ipi6_ifindex);
} else if (in6p && IN6_IS_ADDR_MULTICAST(in6) &&
in6p->inp_moptions6 &&
- in6p->inp_moptions6->im6o_multicast_ifp) {
- ifp = in6p->inp_moptions6->im6o_multicast_ifp;
+ (ifp = if_get(in6p->inp_moptions6->im6o_ifidx))) {
in6->s6_addr16[1] = htons(ifp->if_index);
} else if (scopeid) {
ifp = if_get(scopeid);
if (m->m_pkthdr.rcvif == NULL) {
struct ip6_moptions im6o;
- im6o.im6o_multicast_ifp = ifp;
+ im6o.im6o_ifidx = ifp->if_index;
/* XXX: ip6_output will override ip6->ip6_hlim */
im6o.im6o_multicast_hlim = ip6->ip6_hlim;
im6o.im6o_multicast_loop = 1;
-/* $OpenBSD: ip6_output.c,v 1.163 2014/12/05 15:50:04 mpi Exp $ */
+/* $OpenBSD: ip6_output.c,v 1.164 2014/12/17 09:45:59 mpi Exp $ */
/* $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $ */
/*
if (im6o == NULL)
return (ENOBUFS);
*im6op = im6o;
- im6o->im6o_multicast_ifp = NULL;
+ im6o->im6o_ifidx = 0;
im6o->im6o_multicast_hlim = ip6_defmcasthlim;
im6o->im6o_multicast_loop = IPV6_DEFAULT_MULTICAST_LOOP;
LIST_INIT(&im6o->im6o_memberships);
break;
}
}
- im6o->im6o_multicast_ifp = ifp;
+ im6o->im6o_ifidx = ifindex;
break;
case IPV6_MULTICAST_HOPS:
* If all options have default values, no need to keep the option
* structure.
*/
- if (im6o->im6o_multicast_ifp == NULL &&
+ if (im6o->im6o_ifidx == 0 &&
im6o->im6o_multicast_hlim == ip6_defmcasthlim &&
im6o->im6o_multicast_loop == IPV6_DEFAULT_MULTICAST_LOOP &&
LIST_EMPTY(&im6o->im6o_memberships)) {
case IPV6_MULTICAST_IF:
ifindex = mtod(*mp, u_int *);
(*mp)->m_len = sizeof(u_int);
- if (im6o == NULL || im6o->im6o_multicast_ifp == NULL)
+ if (im6o == NULL || im6o->im6o_ifidx == 0)
*ifindex = 0;
else
- *ifindex = im6o->im6o_multicast_ifp->if_index;
+ *ifindex = im6o->im6o_ifidx;
return (0);
case IPV6_MULTICAST_HOPS:
-/* $OpenBSD: ip6_var.h,v 1.49 2014/07/11 16:39:06 henning Exp $ */
+/* $OpenBSD: ip6_var.h,v 1.50 2014/12/17 09:45:59 mpi Exp $ */
/* $KAME: ip6_var.h,v 1.33 2000/06/11 14:59:20 jinmei Exp $ */
/*
#define IP6_REASS_MBUF(ip6af) ((ip6af)->ip6af_m)
struct ip6_moptions {
- struct ifnet *im6o_multicast_ifp; /* ifp for outgoing multicasts */
+ LIST_HEAD(, in6_multi_mship) im6o_memberships;
+ unsigned short im6o_ifidx; /* ifp index for outgoing multicasts */
u_char im6o_multicast_hlim; /* hoplimit for outgoing multicasts */
u_char im6o_multicast_loop; /* 1 >= hear sends if a member */
- LIST_HEAD(, in6_multi_mship) im6o_memberships;
};
/*
-/* $OpenBSD: mld6.c,v 1.39 2014/11/18 02:37:31 tedu Exp $ */
+/* $OpenBSD: mld6.c,v 1.40 2014/12/17 09:45:59 mpi Exp $ */
/* $KAME: mld6.c,v 1.26 2001/02/16 14:50:35 itojun Exp $ */
/*
/* construct multicast option */
bzero(&im6o, sizeof(im6o));
- im6o.im6o_multicast_ifp = ifp;
+ im6o.im6o_ifidx = ifp->if_index;
im6o.im6o_multicast_hlim = 1;
/*
-/* $OpenBSD: nd6_nbr.c,v 1.86 2014/12/05 15:50:04 mpi Exp $ */
+/* $OpenBSD: nd6_nbr.c,v 1.87 2014/12/17 09:45:59 mpi Exp $ */
/* $KAME: nd6_nbr.c,v 1.61 2001/02/10 16:06:14 jinmei Exp $ */
/*
if (daddr6 == NULL || IN6_IS_ADDR_MULTICAST(daddr6)) {
m->m_flags |= M_MCAST;
- im6o.im6o_multicast_ifp = ifp;
+ im6o.im6o_ifidx = ifp->if_index;
im6o.im6o_multicast_hlim = 255;
im6o.im6o_multicast_loop = 0;
}
if (IN6_IS_ADDR_MULTICAST(daddr6)) {
m->m_flags |= M_MCAST;
- im6o.im6o_multicast_ifp = ifp;
+ im6o.im6o_ifidx = ifp->if_index;
im6o.im6o_multicast_hlim = 255;
im6o.im6o_multicast_loop = 0;
}
-/* $OpenBSD: nd6_rtr.c,v 1.92 2014/12/05 15:50:04 mpi Exp $ */
+/* $OpenBSD: nd6_rtr.c,v 1.93 2014/12/17 09:45:59 mpi Exp $ */
/* $KAME: nd6_rtr.c,v 1.97 2001/02/07 11:09:13 itojun Exp $ */
/*
m->m_flags |= M_MCAST;
m->m_pkthdr.csum_flags |= M_ICMP_CSUM_OUT;
- im6o.im6o_multicast_ifp = ifp;
+ im6o.im6o_ifidx = ifp->if_index;
im6o.im6o_multicast_hlim = 255;
im6o.im6o_multicast_loop = 0;