svn commit: r212320 - stable/8/sys/net
Marko Zec
zec at FreeBSD.org
Wed Sep 8 14:22:36 UTC 2010
Author: zec
Date: Wed Sep 8 14:22:35 2010
New Revision: 212320
URL: http://svn.freebsd.org/changeset/base/212320
Log:
MFC r211283:
When moving an ethernet ifnet from one vnet to another, destroy the
associated ng_ether netgraph node in the current vnet, and create a
new one in the target vnet.
Reviewed by: julian
Modified:
stable/8/sys/net/if.c
stable/8/sys/net/if_ethersubr.c
Directory Properties:
stable/8/sys/ (props changed)
stable/8/sys/amd64/include/xen/ (props changed)
stable/8/sys/cddl/contrib/opensolaris/ (props changed)
stable/8/sys/contrib/dev/acpica/ (props changed)
stable/8/sys/contrib/pf/ (props changed)
stable/8/sys/dev/xen/xenpci/ (props changed)
Modified: stable/8/sys/net/if.c
==============================================================================
--- stable/8/sys/net/if.c Wed Sep 8 14:21:12 2010 (r212319)
+++ stable/8/sys/net/if.c Wed Sep 8 14:22:35 2010 (r212320)
@@ -974,12 +974,21 @@ if_vmove(struct ifnet *ifp, struct vnet
*/
IFNET_WLOCK();
ifindex_free_locked(ifp->if_index);
+ IFNET_WUNLOCK();
+
+ /*
+ * Perform interface-specific reassignment tasks, if provided by
+ * the driver.
+ */
+ if (ifp->if_reassign != NULL)
+ ifp->if_reassign(ifp, new_vnet, NULL);
/*
* Switch to the context of the target vnet.
*/
CURVNET_SET_QUIET(new_vnet);
+ IFNET_WLOCK();
if (ifindex_alloc_locked(&idx) != 0) {
IFNET_WUNLOCK();
panic("if_index overflow");
Modified: stable/8/sys/net/if_ethersubr.c
==============================================================================
--- stable/8/sys/net/if_ethersubr.c Wed Sep 8 14:21:12 2010 (r212319)
+++ stable/8/sys/net/if_ethersubr.c Wed Sep 8 14:22:35 2010 (r212320)
@@ -135,6 +135,9 @@ static const u_char etherbroadcastaddr[E
static int ether_resolvemulti(struct ifnet *, struct sockaddr **,
struct sockaddr *);
+#ifdef VIMAGE
+static void ether_reassign(struct ifnet *, struct vnet *, char *);
+#endif
/* XXX: should be in an arp support file, not here */
MALLOC_DEFINE(M_ARPCOM, "arpcom", "802.* interface internals");
@@ -954,6 +957,9 @@ ether_ifattach(struct ifnet *ifp, const
ifp->if_output = ether_output;
ifp->if_input = ether_input;
ifp->if_resolvemulti = ether_resolvemulti;
+#ifdef VIMAGE
+ ifp->if_reassign = ether_reassign;
+#endif
if (ifp->if_baudrate == 0)
ifp->if_baudrate = IF_Mbps(10); /* just a default */
ifp->if_broadcastaddr = etherbroadcastaddr;
@@ -993,6 +999,25 @@ ether_ifdetach(struct ifnet *ifp)
if_detach(ifp);
}
+#ifdef VIMAGE
+void
+ether_reassign(struct ifnet *ifp, struct vnet *new_vnet, char *unused __unused)
+{
+
+ if (IFP2AC(ifp)->ac_netgraph != NULL) {
+ KASSERT(ng_ether_detach_p != NULL,
+ ("ng_ether_detach_p is NULL"));
+ (*ng_ether_detach_p)(ifp);
+ }
+
+ if (ng_ether_attach_p != NULL) {
+ CURVNET_SET_QUIET(new_vnet);
+ (*ng_ether_attach_p)(ifp);
+ CURVNET_RESTORE();
+ }
+}
+#endif
+
SYSCTL_DECL(_net_link);
SYSCTL_NODE(_net_link, IFT_ETHER, ether, CTLFLAG_RW, 0, "Ethernet");
#if defined(INET) || defined(INET6)
More information about the svn-src-stable-8
mailing list