From owner-svn-src-all@FreeBSD.ORG Fri Aug 22 15:10:27 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 0ABFCC62; Fri, 22 Aug 2014 15:10:27 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D0A9A3CDE; Fri, 22 Aug 2014 15:10:26 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s7MFAQCO092037; Fri, 22 Aug 2014 15:10:26 GMT (envelope-from royger@FreeBSD.org) Received: (from royger@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s7MFAQqw092036; Fri, 22 Aug 2014 15:10:26 GMT (envelope-from royger@FreeBSD.org) Message-Id: <201408221510.s7MFAQqw092036@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: royger set sender to royger@FreeBSD.org using -f From: Roger Pau Monné Date: Fri, 22 Aug 2014 15:10:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r270333 - head/sys/dev/xen/netback X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Aug 2014 15:10:27 -0000 Author: royger Date: Fri Aug 22 15:10:26 2014 New Revision: 270333 URL: http://svnweb.freebsd.org/changeset/base/270333 Log: netback: fixes for netback This patch contains the following fixes for netback: - Only unbind the evtchn if it has been bound. - Set xnb->bridge to NULL after free to prevent double-freeing it. - Set the MAC address for the host-facing interface to a dummy value. Sponsored by: Citrix Systems R&D dev/xen/netback/netback.c: - Prevent trying to unbind if the evtchn has not been bounded. - Prevent double-freeing xnb->bridge. - Set the MAC address of the host-facing interface to a dummy value, so it can work when the interface is added to a bridge. Modified: head/sys/dev/xen/netback/netback.c Modified: head/sys/dev/xen/netback/netback.c ============================================================================== --- head/sys/dev/xen/netback/netback.c Fri Aug 22 15:05:51 2014 (r270332) +++ head/sys/dev/xen/netback/netback.c Fri Aug 22 15:10:26 2014 (r270333) @@ -652,7 +652,8 @@ xnb_disconnect(struct xnb_softc *xnb) int error; int i; - xen_intr_unbind(xnb->xen_intr_handle); + if (xnb->xen_intr_handle != NULL) + xen_intr_unbind(&xnb->xen_intr_handle); /* * We may still have another thread currently processing requests. We @@ -666,8 +667,10 @@ xnb_disconnect(struct xnb_softc *xnb) mtx_unlock(&xnb->rx_lock); /* Free malloc'd softc member variables */ - if (xnb->bridge != NULL) + if (xnb->bridge != NULL) { free(xnb->bridge, M_XENSTORE); + xnb->bridge = NULL; + } /* All request processing has stopped, so unmap the rings */ for (i=0; i < XNB_NUM_RING_TYPES; i++) { @@ -1211,7 +1214,18 @@ create_netdev(device_t dev) ifmedia_add(&xnb->sc_media, IFM_ETHER|IFM_MANUAL, 0, NULL); ifmedia_set(&xnb->sc_media, IFM_ETHER|IFM_MANUAL); - err = xen_net_read_mac(dev, xnb->mac); + /* + * Set the MAC address to a dummy value (00:00:00:00:00), + * if the MAC address of the host-facing interface is set + * to the same as the guest-facing one (the value found in + * xenstore), the bridge would stop delivering packets to + * us because it would see that the destination address of + * the packet is the same as the interface, and so the bridge + * would expect the packet has already been delivered locally + * (and just drop it). + */ + bzero(&xnb->mac[0], sizeof(xnb->mac)); + if (err == 0) { /* Set up ifnet structure */ ifp = xnb->xnb_ifp = if_alloc(IFT_ETHER);