Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 202923
b: refs/heads/master
c: de85d99
h: refs/heads/master
i:
  202921: 0227f91
  202919: 16297de
v: v3
  • Loading branch information
Herbert Xu authored and David S. Miller committed Jun 15, 2010
1 parent f3e6b1f commit 73c42a8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 36655042f9873efc2a90d251b9aef9b6b79d75d8
refs/heads/master: de85d99eb7b595f6751550184b94c1e2f74a828b
13 changes: 8 additions & 5 deletions trunk/include/linux/netpoll.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,25 +57,30 @@ void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb);
#ifdef CONFIG_NETPOLL
static inline bool netpoll_rx(struct sk_buff *skb)
{
struct netpoll_info *npinfo = skb->dev->npinfo;
struct netpoll_info *npinfo;
unsigned long flags;
bool ret = false;

rcu_read_lock_bh();
npinfo = rcu_dereference(skb->dev->npinfo);

if (!npinfo || (list_empty(&npinfo->rx_np) && !npinfo->rx_flags))
return false;
goto out;

spin_lock_irqsave(&npinfo->rx_lock, flags);
/* check rx_flags again with the lock held */
if (npinfo->rx_flags && __netpoll_rx(skb))
ret = true;
spin_unlock_irqrestore(&npinfo->rx_lock, flags);

out:
rcu_read_unlock_bh();
return ret;
}

static inline int netpoll_rx_on(struct sk_buff *skb)
{
struct netpoll_info *npinfo = skb->dev->npinfo;
struct netpoll_info *npinfo = rcu_dereference(skb->dev->npinfo);

return npinfo && (!list_empty(&npinfo->rx_np) || npinfo->rx_flags);
}
Expand All @@ -91,7 +96,6 @@ static inline void *netpoll_poll_lock(struct napi_struct *napi)
{
struct net_device *dev = napi->dev;

rcu_read_lock(); /* deal with race on ->npinfo */
if (dev && dev->npinfo) {
spin_lock(&napi->poll_lock);
napi->poll_owner = smp_processor_id();
Expand All @@ -108,7 +112,6 @@ static inline void netpoll_poll_unlock(void *have)
napi->poll_owner = -1;
spin_unlock(&napi->poll_lock);
}
rcu_read_unlock();
}

#else
Expand Down
20 changes: 12 additions & 8 deletions trunk/net/core/netpoll.c
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
unsigned long tries;
struct net_device *dev = np->dev;
const struct net_device_ops *ops = dev->netdev_ops;
/* It is up to the caller to keep npinfo alive. */
struct netpoll_info *npinfo = np->dev->npinfo;

if (!npinfo || !netif_running(dev) || !netif_device_present(dev)) {
Expand Down Expand Up @@ -810,10 +811,7 @@ int netpoll_setup(struct netpoll *np)
refill_skbs();

/* last thing to do is link it to the net device structure */
ndev->npinfo = npinfo;

/* avoid racing with NAPI reading npinfo */
synchronize_rcu();
rcu_assign_pointer(ndev->npinfo, npinfo);

return 0;

Expand Down Expand Up @@ -857,17 +855,23 @@ void netpoll_cleanup(struct netpoll *np)

if (atomic_dec_and_test(&npinfo->refcnt)) {
const struct net_device_ops *ops;

ops = np->dev->netdev_ops;
if (ops->ndo_netpoll_cleanup)
ops->ndo_netpoll_cleanup(np->dev);

rcu_assign_pointer(np->dev->npinfo, NULL);

/* avoid racing with NAPI reading npinfo */
synchronize_rcu_bh();

skb_queue_purge(&npinfo->arp_tx);
skb_queue_purge(&npinfo->txq);
cancel_rearming_delayed_work(&npinfo->tx_work);

/* clean after last, unfinished work */
__skb_queue_purge(&npinfo->txq);
kfree(npinfo);
ops = np->dev->netdev_ops;
if (ops->ndo_netpoll_cleanup)
ops->ndo_netpoll_cleanup(np->dev);
np->dev->npinfo = NULL;
}
}

Expand Down

0 comments on commit 73c42a8

Please sign in to comment.