PERFORCE change 161805 for review
Marko Zec
zec at FreeBSD.org
Sat May 9 02:00:45 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=161805
Change 161805 by zec at zec_tpx32 on 2009/05/09 01:59:51
Introduce ethernet-specific method for reassigning ifnets
from one vnet to another.
While here, make sure that we only print out ifnet's ethernet
address on console when it gets attached in the default vnet.
Obtained from: vimage branch in p4
Affected files ...
.. //depot/projects/vimage-commit2/src/sys/net/if_ethersubr.c#25 edit
Differences ...
==== //depot/projects/vimage-commit2/src/sys/net/if_ethersubr.c#25 (text+ko) ====
@@ -924,6 +924,25 @@
return (etherbuf);
}
+#ifdef VIMAGE
+static void
+ether_reassign(struct ifnet *ifp, struct vnet *vnet, char *dname)
+{
+ u_char eaddr[6];
+
+ bcopy(IF_LLADDR(ifp), eaddr, 6);
+ ether_ifdetach(ifp);
+ ifp->if_bpf = NULL;
+ if_reassign_common(ifp, vnet, "eth");
+ if (dname)
+ snprintf(ifp->if_xname, IFNAMSIZ, "%s", dname);
+
+ CURVNET_SET_QUIET(vnet);
+ ether_ifattach(ifp, eaddr);
+ CURVNET_RESTORE();
+}
+#endif
+
/*
* Perform common duties while attaching to interface list
*/
@@ -933,6 +952,9 @@
int i;
struct ifaddr *ifa;
struct sockaddr_dl *sdl;
+#ifdef VIMAGE
+ struct vnet *home_vnet_0 = ifp->if_home_vnet;
+#endif
ifp->if_addrlen = ETHER_ADDR_LEN;
ifp->if_hdrlen = ETHER_HDR_LEN;
@@ -941,6 +963,9 @@
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;
@@ -960,7 +985,11 @@
for (i = 0; i < ifp->if_addrlen; i++)
if (lla[i] != 0)
break;
+#ifdef VIMAGE
+ if (i != ifp->if_addrlen && home_vnet_0 != ifp->if_home_vnet)
+#else
if (i != ifp->if_addrlen)
+#endif
if_printf(ifp, "Ethernet address: %6D\n", lla, ":");
}
More information about the p4-projects
mailing list