Skip to content

Commit bb70dfa

Browse files
author
Jan Engelhardt
committed
netfilter: xtables: consolidate comefrom debug cast access
Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
1 parent 7a6b1c4 commit bb70dfa

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

net/ipv4/netfilter/ip_tables.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,8 @@ ipt_do_table(struct sk_buff *skb,
311311
const struct net_device *out,
312312
struct xt_table *table)
313313
{
314+
#define tb_comefrom ((struct ipt_entry *)table_base)->comefrom
315+
314316
static const char nulldevname[IFNAMSIZ] __attribute__((aligned(sizeof(long))));
315317
const struct iphdr *ip;
316318
u_int16_t datalen;
@@ -409,18 +411,19 @@ ipt_do_table(struct sk_buff *skb,
409411
abs. verdicts */
410412
tgpar.target = t->u.kernel.target;
411413
tgpar.targinfo = t->data;
414+
415+
412416
#ifdef CONFIG_NETFILTER_DEBUG
413-
((struct ipt_entry *)table_base)->comefrom = 0xeeeeeeec;
417+
tb_comefrom = 0xeeeeeeec;
414418
#endif
415419
verdict = t->u.kernel.target->target(skb, &tgpar);
416420
#ifdef CONFIG_NETFILTER_DEBUG
417-
if (((struct ipt_entry *)table_base)->comefrom != 0xeeeeeeec &&
418-
verdict == IPT_CONTINUE) {
421+
if (comefrom != 0xeeeeeeec && verdict == IPT_CONTINUE) {
419422
printk("Target %s reentered!\n",
420423
t->u.kernel.target->name);
421424
verdict = NF_DROP;
422425
}
423-
((struct ipt_entry *)table_base)->comefrom = 0x57acc001;
426+
tb_comefrom = 0x57acc001;
424427
#endif
425428
/* Target might have changed stuff. */
426429
ip = ip_hdr(skb);
@@ -441,6 +444,8 @@ ipt_do_table(struct sk_buff *skb,
441444
return NF_DROP;
442445
else return verdict;
443446
#endif
447+
448+
#undef tb_comefrom
444449
}
445450

446451
/* Figures out from what hook each rule can be called: returns 0 if

net/ipv6/netfilter/ip6_tables.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,8 @@ ip6t_do_table(struct sk_buff *skb,
343343
const struct net_device *out,
344344
struct xt_table *table)
345345
{
346+
#define tb_comefrom ((struct ip6t_entry *)table_base)->comefrom
347+
346348
static const char nulldevname[IFNAMSIZ] __attribute__((aligned(sizeof(long))));
347349
bool hotdrop = false;
348350
/* Initializing verdict to NF_DROP keeps gcc happy. */
@@ -440,18 +442,17 @@ ip6t_do_table(struct sk_buff *skb,
440442
tgpar.targinfo = t->data;
441443

442444
#ifdef CONFIG_NETFILTER_DEBUG
443-
((struct ip6t_entry *)table_base)->comefrom = 0xeeeeeeec;
445+
tb_comefrom = 0xeeeeeeec;
444446
#endif
445447
verdict = t->u.kernel.target->target(skb, &tgpar);
446448

447449
#ifdef CONFIG_NETFILTER_DEBUG
448-
if (((struct ip6t_entry *)table_base)->comefrom != 0xeeeeeeec &&
449-
verdict == IP6T_CONTINUE) {
450+
if (tb_comefrom != 0xeeeeeeec && verdict == IP6T_CONTINUE) {
450451
printk("Target %s reentered!\n",
451452
t->u.kernel.target->name);
452453
verdict = NF_DROP;
453454
}
454-
((struct ip6t_entry *)table_base)->comefrom = 0x57acc001;
455+
tb_comefrom = 0x57acc001;
455456
#endif
456457
if (verdict == IP6T_CONTINUE)
457458
e = ip6t_next_entry(e);
@@ -461,7 +462,7 @@ ip6t_do_table(struct sk_buff *skb,
461462
} while (!hotdrop);
462463

463464
#ifdef CONFIG_NETFILTER_DEBUG
464-
((struct ip6t_entry *)table_base)->comefrom = NETFILTER_LINK_POISON;
465+
tb_comefrom = NETFILTER_LINK_POISON;
465466
#endif
466467
xt_info_rdunlock_bh();
467468

@@ -472,6 +473,8 @@ ip6t_do_table(struct sk_buff *skb,
472473
return NF_DROP;
473474
else return verdict;
474475
#endif
476+
477+
#undef tb_comefrom
475478
}
476479

477480
/* Figures out from what hook each rule can be called: returns 0 if

0 commit comments

Comments
 (0)