1/* 2 * Today's hack: quantum tunneling in structs 3 * 4 * 'entries' and 'term' are never anywhere referenced by word in code. In fact, 5 * they serve as the hanging-off data accessed through repl.data[]. 6 */ 7 8#define xt_alloc_initial_table(type, typ2) ({ \ 9 unsigned int hook_mask = info->valid_hooks; \ 10 unsigned int nhooks = hweight32(hook_mask); \ 11 unsigned int bytes = 0, hooknum = 0, i = 0; \ 12 struct { \ 13 struct type##_replace repl; \ 14 struct type##_standard entries[nhooks]; \ 15 struct type##_error term; \ 16 } *tbl = kzalloc(sizeof(*tbl), GFP_KERNEL); \ 17 if (tbl == NULL) \ 18 return NULL; \ 19 strncpy(tbl->repl.name, info->name, sizeof(tbl->repl.name)); \ 20 tbl->term = (struct type##_error)typ2##_ERROR_INIT; \ 21 tbl->repl.valid_hooks = hook_mask; \ 22 tbl->repl.num_entries = nhooks + 1; \ 23 tbl->repl.size = nhooks * sizeof(struct type##_standard) + \ 24 sizeof(struct type##_error); \ 25 for (; hook_mask != 0; hook_mask >>= 1, ++hooknum) { \ 26 if (!(hook_mask & 1)) \ 27 continue; \ 28 tbl->repl.hook_entry[hooknum] = bytes; \ 29 tbl->repl.underflow[hooknum] = bytes; \ 30 tbl->entries[i++] = (struct type##_standard) \ 31 typ2##_STANDARD_INIT(NF_ACCEPT); \ 32 bytes += sizeof(struct type##_standard); \ 33 } \ 34 tbl; \ 35}) 36