neigh_tbl_lock usage in net/core/neighbour.c

Meng Zhang jammy.linux at gmail.com
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
functions

static int neigh_delete(struct sk_buff *skb, struct nlmsghdr *nlh, void
*arg)
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
   continue;
--L5
  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
Jammy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20120627/d670f451/attachment.html 


More information about the Kernelnewbies mailing list