[NET]: Set a separate lockdep class for neighbour table's proxy_queue
authorPavel Emelianov <xemul@sw.ru>
Tue, 17 Apr 2007 19:45:31 +0000 (12:45 -0700)
committerDavid S. Miller <davem@sunset.davemloft.net>
Tue, 17 Apr 2007 20:13:31 +0000 (13:13 -0700)
Otherwise the following calltrace will lead to a wrong
lockdep warning:

  neigh_proxy_process()
    `- lock(neigh_table->proxy_queue.lock);
  arp_redo /* via tbl->proxy_redo */
  arp_process
  neigh_event_ns
  neigh_update
  skb_queue_purge
    `- lock(neighbor->arp_queue.lock);

This is not a deadlock actually, as neighbor table's proxy_queue
and the neighbor's arp_queue are different queues.

Lockdep thinks there is a deadlock as both queues are initialized
with skb_queue_head_init() and thus have a common class.

Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/skbuff.h
net/core/neighbour.c

index 0e86b6007a0a16a4f71fd5e61e9e04acc54db8f9..5992f65b418423a7e28dd70636a1d2bc12a23ed2 100644 (file)
@@ -619,6 +619,13 @@ static inline void skb_queue_head_init(struct sk_buff_head *list)
        list->qlen = 0;
 }
 
+static inline void skb_queue_head_init_class(struct sk_buff_head *list,
+               struct lock_class_key *class)
+{
+       skb_queue_head_init(list);
+       lockdep_set_class(&list->lock, class);
+}
+
 /*
  *     Insert an sk_buff at the start of a list.
  *
index cfc60019cf920508cc9c416d950c147512c73766..841e3f32cab181c51ec5d50605e3f7560add79ae 100644 (file)
@@ -1331,6 +1331,8 @@ void neigh_parms_destroy(struct neigh_parms *parms)
        kfree(parms);
 }
 
+static struct lock_class_key neigh_table_proxy_queue_class;
+
 void neigh_table_init_no_netlink(struct neigh_table *tbl)
 {
        unsigned long now = jiffies;
@@ -1379,7 +1381,8 @@ void neigh_table_init_no_netlink(struct neigh_table *tbl)
        init_timer(&tbl->proxy_timer);
        tbl->proxy_timer.data     = (unsigned long)tbl;
        tbl->proxy_timer.function = neigh_proxy_process;
-       skb_queue_head_init(&tbl->proxy_queue);
+       skb_queue_head_init_class(&tbl->proxy_queue,
+                       &neigh_table_proxy_queue_class);
 
        tbl->last_flush = now;
        tbl->last_rand  = now + tbl->parms.reachable_time * 20;