0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #define xt_alloc_initial_table(type, typ2) ({ \
0018 unsigned int hook_mask = info->valid_hooks; \
0019 unsigned int nhooks = hweight32(hook_mask); \
0020 unsigned int bytes = 0, hooknum = 0, i = 0; \
0021 struct { \
0022 struct type##_replace repl; \
0023 struct type##_standard entries[]; \
0024 } *tbl; \
0025 struct type##_error *term; \
0026 size_t term_offset = (offsetof(typeof(*tbl), entries[nhooks]) + \
0027 __alignof__(*term) - 1) & ~(__alignof__(*term) - 1); \
0028 tbl = kzalloc(term_offset + sizeof(*term), GFP_KERNEL); \
0029 if (tbl == NULL) \
0030 return NULL; \
0031 term = (struct type##_error *)&(((char *)tbl)[term_offset]); \
0032 strncpy(tbl->repl.name, info->name, sizeof(tbl->repl.name)); \
0033 *term = (struct type##_error)typ2##_ERROR_INIT; \
0034 tbl->repl.valid_hooks = hook_mask; \
0035 tbl->repl.num_entries = nhooks + 1; \
0036 tbl->repl.size = nhooks * sizeof(struct type##_standard) + \
0037 sizeof(struct type##_error); \
0038 for (; hook_mask != 0; hook_mask >>= 1, ++hooknum) { \
0039 if (!(hook_mask & 1)) \
0040 continue; \
0041 tbl->repl.hook_entry[hooknum] = bytes; \
0042 tbl->repl.underflow[hooknum] = bytes; \
0043 tbl->entries[i++] = (struct type##_standard) \
0044 typ2##_STANDARD_INIT(NF_ACCEPT); \
0045 bytes += sizeof(struct type##_standard); \
0046 } \
0047 tbl; \
0048 })