Linux?????????????
?????Linux????????????? ???????[ 2012/8/8 10:02:03 ] ????????
????4??????????
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????e???????????
??????????????????????????????ж??????????????????????????????????2???????????ж???????????IP????????
#define list_for_each(pos?? head)
for (pos = (head)->next; prefetch(pos->next)?? pos != (head);
pos = pos->next)
struct list_head *p;
struct ipstore *store;
list_for_each(p?? &addr_list)
{
store = list_entry(p?? struct ipstore?? list);
if(store->addr[0] == ist->addr[0])
{
if(ist)
kfree(ist);
break;
}
}
INIT_LIST_HEAD(&ist->list);
list_add(&ist->list?? &addr_list);
????ist?????????????????????????????IP?????????IP?????????????????????????????????κβ????????????addr_list?????С?
???????????????????????????????????????????????????????list_entry()??
#define list_for_each_entry(pos?? head?? member)
for (pos = list_entry((head)->next?? typeof(*pos)?? member);
prefetch(pos->member.next)?? &pos->member != (head);
pos = list_entry(pos->member.next?? typeof(*pos)?? member))
??????????????????????£?????????????
struct ipstore *store;
list_for_each_entry(store?? &addr_list?? list)
{
if(store->addr[0] == ist->addr[0])
{
if(ist)
kfree(ist);
return 0;
}
}
????????????????????????
#define list_for_each_entry_safe(pos?? n?? head?? member)
for (pos = list_entry((head)->next?? typeof(*pos)?? member)??
n = list_entry(pos->member.next?? typeof(*pos)?? member);
&pos->member != (head);
pos = n?? n = list_entry(n->member.next?? typeof(*n)?? member))
?????????????????????????????????????????????????????“?????????”????????????
struct ipstore *v?? *n;
list_for_each_entry_safe(v?? n?? &addr_list?? list)
{
if(iph->saddr == v->addr[0])
{
list_del(&v->list);//??????
kfree(v);//???????????list_del()???????????????????????????????????棬???????????????檔
}
}
????5???п????
?????п???????????????????????????????????????
if(list_empty(&addr_list))
{
return 0;
}
????????????????????????????????????????????????????????????????????????????????????????????????????ο?LKD3e.
???????????????????С??????“?????????”??????????????????????????????????????
DEFINE_RWLOCK(v4_rwlock);
struct list_head *p;
struct ipstore *store;
list_for_each(p?? &addr_list)
{
store = list_entry(p?? struct ipstore?? list);
if(iph->saddr == store->addr[0])
{
read_lock(&v4_rwlock);
list_del(&store->list);
read_unlock(&v4_rwlock);
kfree(store);
return 0;
}
}
??????δ?????????????????????????????????????????????????????????????????????????????????????????????????????return 0?????????????????б??????????????????????????????????return????????????????????ī???????????????????????????????????
?????????д????????????????????????????????????????????????????????????????????????????????????????д?????????????????????????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11