提交 068c6e98 编写于 作者: N Neil Horman 提交者: David S. Miller

[NET] netpoll: break recursive loop in netpoll rx path

The netpoll system currently has a rx to tx path via:

netpoll_rx
 __netpoll_rx
  arp_reply
   netpoll_send_skb
    dev->hard_start_tx

This rx->tx loop places network drivers at risk of inadvertently causing a
deadlock or BUG halt by recursively trying to acquire a spinlock that is
used in both their rx and tx paths (this problem was origionally reported
to me in the 3c59x driver, which shares a spinlock between the
boomerang_interrupt and boomerang_start_xmit routines).

This patch breaks this loop, by queueing arp frames, so that they can be
responded to after all receive operations have been completed.  Tested by
myself and the reported with successful results.

Specifically it was tested with netdump.  Heres the BZ with details:
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=194055Signed-off-by: NNeil Horman <nhorman@tuxdriver.com>
Acked-by: NMatt Mackall <mpm@selenic.com>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 8834807b
...@@ -31,6 +31,7 @@ struct netpoll_info { ...@@ -31,6 +31,7 @@ struct netpoll_info {
int rx_flags; int rx_flags;
spinlock_t rx_lock; spinlock_t rx_lock;
struct netpoll *rx_np; /* netpoll that registered an rx_hook */ struct netpoll *rx_np; /* netpoll that registered an rx_hook */
struct sk_buff_head arp_tx; /* list of arp requests to reply to */
}; };
void netpoll_poll(struct netpoll *np); void netpoll_poll(struct netpoll *np);
......
...@@ -54,6 +54,7 @@ static atomic_t trapped; ...@@ -54,6 +54,7 @@ static atomic_t trapped;
sizeof(struct iphdr) + sizeof(struct ethhdr)) sizeof(struct iphdr) + sizeof(struct ethhdr))
static void zap_completion_queue(void); static void zap_completion_queue(void);
static void arp_reply(struct sk_buff *skb);
static void queue_process(void *p) static void queue_process(void *p)
{ {
...@@ -153,6 +154,22 @@ static void poll_napi(struct netpoll *np) ...@@ -153,6 +154,22 @@ static void poll_napi(struct netpoll *np)
} }
} }
static void service_arp_queue(struct netpoll_info *npi)
{
struct sk_buff *skb;
if (unlikely(!npi))
return;
skb = skb_dequeue(&npi->arp_tx);
while (skb != NULL) {
arp_reply(skb);
skb = skb_dequeue(&npi->arp_tx);
}
return;
}
void netpoll_poll(struct netpoll *np) void netpoll_poll(struct netpoll *np)
{ {
if(!np->dev || !netif_running(np->dev) || !np->dev->poll_controller) if(!np->dev || !netif_running(np->dev) || !np->dev->poll_controller)
...@@ -163,6 +180,8 @@ void netpoll_poll(struct netpoll *np) ...@@ -163,6 +180,8 @@ void netpoll_poll(struct netpoll *np)
if (np->dev->poll) if (np->dev->poll)
poll_napi(np); poll_napi(np);
service_arp_queue(np->dev->npinfo);
zap_completion_queue(); zap_completion_queue();
} }
...@@ -442,7 +461,9 @@ int __netpoll_rx(struct sk_buff *skb) ...@@ -442,7 +461,9 @@ int __netpoll_rx(struct sk_buff *skb)
int proto, len, ulen; int proto, len, ulen;
struct iphdr *iph; struct iphdr *iph;
struct udphdr *uh; struct udphdr *uh;
struct netpoll *np = skb->dev->npinfo->rx_np; struct netpoll_info *npi = skb->dev->npinfo;
struct netpoll *np = npi->rx_np;
if (!np) if (!np)
goto out; goto out;
...@@ -452,7 +473,7 @@ int __netpoll_rx(struct sk_buff *skb) ...@@ -452,7 +473,7 @@ int __netpoll_rx(struct sk_buff *skb)
/* check if netpoll clients need ARP */ /* check if netpoll clients need ARP */
if (skb->protocol == __constant_htons(ETH_P_ARP) && if (skb->protocol == __constant_htons(ETH_P_ARP) &&
atomic_read(&trapped)) { atomic_read(&trapped)) {
arp_reply(skb); skb_queue_tail(&npi->arp_tx, skb);
return 1; return 1;
} }
...@@ -647,6 +668,7 @@ int netpoll_setup(struct netpoll *np) ...@@ -647,6 +668,7 @@ int netpoll_setup(struct netpoll *np)
npinfo->poll_owner = -1; npinfo->poll_owner = -1;
npinfo->tries = MAX_RETRIES; npinfo->tries = MAX_RETRIES;
spin_lock_init(&npinfo->rx_lock); spin_lock_init(&npinfo->rx_lock);
skb_queue_head_init(&npinfo->arp_tx);
} else } else
npinfo = ndev->npinfo; npinfo = ndev->npinfo;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册