Chinaunix首页 | 论坛 | 博客
  • 博客访问: 370596
  • 博文数量: 56
  • 博客积分: 1449
  • 博客等级: 中尉
  • 技术积分: 822
  • 用 户 组: 普通用户
  • 注册时间: 2010-10-08 10:24
文章分类

全部博文(56)

文章存档

2014年(7)

2012年(13)

2011年(10)

2010年(26)

分类: LINUX

2012-05-22 19:12:12


点击(此处)折叠或打开

  1. struct inet_frag_queue *inet_frag_find(struct inet_frags *f, void *key,
  2.         unsigned int hash)
  3. {
  4.     struct inet_frag_queue *q;
  5.     struct hlist_node *n;

  6.     /* f->lock是读写锁,先搜索是否存在该IP分段所属的队列 */
  7.     read_lock(&f->lock);
  8.     hlist_for_each_entry(q, n, &f->hash[hash], list) { /* 扫描该HASH槽中所有节点 */
  9.     /* f->match中match字段在ipfrag_init中初始化为ip4_frag_match函数。*/
  10.     /* 对比分片队列中的散列字段和user是否和key相等,key指向的是struct ip4_create_arg
  11.      * 结构,包含IP头部和user字段。 */
  12.         if (f->match(q, key)) {
  13.             atomic_inc(&q->refcnt);     /* 若找到,则增加该队列引用计数。 */
  14.             read_unlock(&f->lock);
  15.             return q;                /* 返回该队列 */
  16.         }
  17.     }
  18.     read_unlock(&f->lock);
  19.     /* 该分片是第一个IP分片,创建一个新的分片队列并添加到合适的HASH队列 */
  20.     return inet_frag_create(f, key, hash);
  21. }

阅读(2387) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~