Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 Nov 2007 22:37:39 GMT
From:      Marko Zec <zec@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 129846 for review
Message-ID:  <200711302237.lAUMbdtE022040@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=129846

Change 129846 by zec@zec_tpx32 on 2007/11/30 22:37:20

	Implement ng_iface_reassign() handler - ng_iface ifnets can
	now be moved among vnets.

Affected files ...

.. //depot/projects/vimage/src/sys/netgraph/ng_iface.c#4 edit

Differences ...

==== //depot/projects/vimage/src/sys/netgraph/ng_iface.c#4 (text+ko) ====

@@ -124,6 +124,10 @@
 static int	ng_iface_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data);
 static int	ng_iface_output(struct ifnet *ifp, struct mbuf *m0,
 			struct sockaddr *dst, struct rtentry *rt0);
+#ifdef VIMAGE
+static void	ng_iface_reassign(struct ifnet *ifp, struct vnet *vnet,
+			char *dname);
+#endif
 static void	ng_iface_bpftap(struct ifnet *ifp,
 			struct mbuf *m, sa_family_t family);
 static int	ng_iface_send(struct ifnet *ifp, struct mbuf *m,
@@ -546,6 +550,9 @@
 	ifp->if_output = ng_iface_output;
 	ifp->if_start = ng_iface_start;
 	ifp->if_ioctl = ng_iface_ioctl;
+#ifdef VIMAGE
+	ifp->if_reassign = ng_iface_reassign;
+#endif
 	ifp->if_watchdog = NULL;
 	ifp->if_mtu = NG_IFACE_MTU_DEFAULT;
 	ifp->if_flags = (IFF_SIMPLEX|IFF_POINTOPOINT|IFF_NOARP|IFF_MULTICAST);
@@ -570,6 +577,24 @@
 	return (0);
 }
 
+#ifdef VIMAGE
+static void
+ng_iface_reassign(struct ifnet *ifp, struct vnet *vnet, char *dname)
+{
+	bpfdetach(ifp);
+	if_detach(ifp);
+	ifp->if_bpf = NULL;
+	if_reassign_common(ifp, vnet, "ser");
+	if (dname)
+		snprintf(ifp->if_xname, IFNAMSIZ, "%s", dname);
+ 
+	CURVNET_SET_QUIET(vnet);
+	if_attach(ifp);
+	bpfattach(ifp, DLT_NULL, sizeof(u_int32_t));
+	CURVNET_RESTORE();
+}
+#endif
+
 /*
  * Give our ok for a hook to be added
  */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200711302237.lAUMbdtE022040>