neigh_tbl_lock usage in net/core/neighbour.c

Meng Zhang jammy.linux at
Wed Jun 27 08:49:20 EDT 2012

Hi~ @list

I'm on my way to jump into the kernel network stack;)

And I find the usage of neigh_tbl_lock might not make sense in following

static int neigh_delete(struct sk_buff *skb, struct nlmsghdr *nlh, void
static int neigh_add(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)

They both have the following code snippets

read_lock(&neigh_tbl_lock);                                       --L1
 for (tbl = neigh_tables; tbl; tbl = tbl->next) {               --L2
  struct neighbour *neigh;                                           --L3
  if (tbl->family != ndm->ndm_family)                          --L4
  read_unlock(&neigh_tbl_lock);                                 --L6
  if (nla_len(dst_attr) < tbl->key_len)                           --L7
   goto out_dev_put;

IMHO, there might be some race condition after L6. I mean when the L7 use
the tbl, is it possible other processor releasing the table entry?
Am I wrong?

Yours sincerely
-------------- next part --------------
An HTML attachment was scrubbed...

More information about the Kernelnewbies mailing list