From 72ff21680daf0e1e8cd4b7f0c2d4cbc9fd93ed69 Mon Sep 17 00:00:00 2001 From: royger Date: Wed, 22 Oct 2014 17:09:12 +0000 Subject: [PATCH] netback: change xnb naming convention Current FreeBSD netback names the interface with xnb, but this is not suitable for usage with the Xen toolstack, which expects something similar to . In order to solve this, change the netback naming convention to use xnb.. Sponsored by: Citrix Systems R&D dev/xen/netback/netback.c: - Change netback to use the nomenclature stated above. --- sys/dev/xen/netback/netback.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/sys/dev/xen/netback/netback.c b/sys/dev/xen/netback/netback.c index e9d3dc1286f4..201e5d632cea 100644 --- a/sys/dev/xen/netback/netback.c +++ b/sys/dev/xen/netback/netback.c @@ -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. + * + * 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;