# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Node ID 41130540891e4c167aa2105b314b5068da27b267
# Parent a73aa6ec4c763a6a2f91f207e3289acaf36d8853
[NET] front: Improve correctness when there is no connection to backend driver.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c | 32 +++++++++++--------
1 files changed, 19 insertions(+), 13 deletions(-)
diff -r a73aa6ec4c76 -r 41130540891e
linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c Thu Aug 17
18:45:59 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c Thu Aug 17
19:11:14 2006 +0100
@@ -456,7 +456,8 @@ static int setup_device(struct xenbus_de
memcpy(netdev->dev_addr, info->mac, ETH_ALEN);
err = bind_evtchn_to_irqhandler(info->evtchn, netif_int,
- SA_SAMPLE_RANDOM, netdev->name, netdev);
+ SA_SAMPLE_RANDOM, netdev->name,
+ netdev);
if (err < 0)
goto fail;
info->irq = err;
@@ -535,11 +536,14 @@ static int network_open(struct net_devic
memset(&np->stats, 0, sizeof(np->stats));
- network_alloc_rx_buffers(dev);
- np->rx.sring->rsp_event = np->rx.rsp_cons + 1;
-
- if (RING_HAS_UNCONSUMED_RESPONSES(&np->rx))
- netif_rx_schedule(dev);
+ spin_lock(&np->rx_lock);
+ if (netif_carrier_ok(dev)) {
+ network_alloc_rx_buffers(dev);
+ np->rx.sring->rsp_event = np->rx.rsp_cons + 1;
+ if (RING_HAS_UNCONSUMED_RESPONSES(&np->rx))
+ netif_rx_schedule(dev);
+ }
+ spin_unlock(&np->rx_lock);
netif_start_queue(dev);
@@ -568,8 +572,7 @@ static void network_tx_buf_gc(struct net
struct netfront_info *np = netdev_priv(dev);
struct sk_buff *skb;
- if (unlikely(!netif_carrier_ok(dev)))
- return;
+ BUG_ON(!netif_carrier_ok(dev));
do {
prod = np->tx.sring->rsp_prod;
@@ -961,12 +964,15 @@ static irqreturn_t netif_int(int irq, vo
unsigned long flags;
spin_lock_irqsave(&np->tx_lock, flags);
- network_tx_buf_gc(dev);
+
+ if (likely(netif_carrier_ok(dev))) {
+ network_tx_buf_gc(dev);
+ /* Under tx_lock: protects access to rx shared-ring indexes. */
+ if (RING_HAS_UNCONSUMED_RESPONSES(&np->rx))
+ netif_rx_schedule(dev);
+ }
+
spin_unlock_irqrestore(&np->tx_lock, flags);
-
- if (RING_HAS_UNCONSUMED_RESPONSES(&np->rx) &&
- likely(netif_running(dev)))
- netif_rx_schedule(dev);
return IRQ_HANDLED;
}
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|