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);
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to