Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 22 Oct 2014 17:09:13 +0000 (UTC)
From:      Roger Pau Monné <royger@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r273477 - head/sys/dev/xen/netback
Message-ID:  <201410221709.s9MH9DWc060188@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: royger
Date: Wed Oct 22 17:09:12 2014
New Revision: 273477
URL: https://svnweb.freebsd.org/changeset/base/273477

Log:
  netback: change xnb naming convention
  
  Current FreeBSD netback names the interface with xnb<device unit>, but
  this is not suitable for usage with the Xen toolstack, which expects
  something similar to <prefix><domid><handle>. In order to solve this,
  change the netback naming convention to use xnb<domid>.<handle>.
  
  Sponsored by: Citrix Systems R&D
  
  dev/xen/netback/netback.c:
   - Change netback to use the nomenclature stated above.

Modified:
  head/sys/dev/xen/netback/netback.c

Modified: head/sys/dev/xen/netback/netback.c
==============================================================================
--- head/sys/dev/xen/netback/netback.c	Wed Oct 22 17:07:20 2014	(r273476)
+++ head/sys/dev/xen/netback/netback.c	Wed Oct 22 17:09:12 2014	(r273477)
@@ -511,6 +511,9 @@ struct xnb_softc {
 
 	/** The size of the global kva pool. */
 	int			kva_size;
+
+	/** Name of the interface */
+	char			 if_name[IFNAMSIZ];
 };
 
 /*---------------------------- Debugging functions ---------------------------*/
@@ -1201,6 +1204,7 @@ create_netdev(device_t dev)
 	struct ifnet *ifp;
 	struct xnb_softc *xnb;
 	int err = 0;
+	uint32_t handle;
 
 	xnb = device_get_softc(dev);
 	mtx_init(&xnb->sc_lock, "xnb_softc", "xen netback softc lock", MTX_DEF);
@@ -1225,11 +1229,24 @@ create_netdev(device_t dev)
 	 */
 	bzero(&xnb->mac[0], sizeof(xnb->mac));
 
+	/* The interface will be named using the following nomenclature:
+	 *
+	 * xnb<domid>.<handle>
+	 *
+	 * Where handle is the oder of the interface referred to the guest.
+	 */
+	err = xs_scanf(XST_NIL, xenbus_get_node(xnb->dev), "handle", NULL,
+		       "%" PRIu32, &handle);
+	if (err != 0)
+		return (err);
+	snprintf(xnb->if_name, IFNAMSIZ, "xnb%" PRIu16 ".%" PRIu32,
+	    xenbus_get_otherend_id(dev), handle);
+
 	if (err == 0) {
 		/* Set up ifnet structure */
 		ifp = xnb->xnb_ifp = if_alloc(IFT_ETHER);
 		ifp->if_softc = xnb;
-		if_initname(ifp, "xnb",  device_get_unit(dev));
+		if_initname(ifp, xnb->if_name,  IF_DUNIT_NONE);
 		ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
 		ifp->if_ioctl = xnb_ioctl;
 		ifp->if_output = ether_output;



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