- 論壇徽章:
- 1
|
本帖最后由 jiufei19 于 2014-09-29 10:51 編輯
在連接跟蹤代碼對擴展進行注冊時,有如下函數(shù)處理
static void update_alloc_size(struct nf_ct_ext_type *type)
{
int i, j;
struct nf_ct_ext_type *t1, *t2;
enum nf_ct_ext_id min = 0, max = NF_CT_EXT_NUM - 1;
/* unnecessary to update all types */
if ((type->flags & NF_CT_EXT_F_PREALLOC) == 0) {
min = type->id;
max = type->id;
}
/* This assumes that extended areas in conntrack for the types
whose NF_CT_EXT_F_PREALLOC bit set are allocated in order */
for (i = min; i <= max; i++) {
t1 = nf_ct_ext_types;
if (!t1)
continue;
t1->alloc_size = sizeof(struct nf_ct_ext)
+ ALIGN(sizeof(struct nf_ct_ext), t1->align)
+ t1->len;
上面紅色字體就是我的問題,即這里為什么要多加個sizeof(struct nf_ct_ext)呢?在該函數(shù)的上級調(diào)用函數(shù)nf_ct_extend_register中,已經(jīng)明明有如下語句了:
type->alloc_size = ALIGN(sizeof(struct nf_ct_ext),
type->align) + type->len;
PS:
這個問題lunixwh在“論壇›程序設計›C/C++›”中也提出了這一問題,參見“netfilter擴展字段 注冊的時候alloc_size 字段問題”,但是沒有得到解答 |
|