Skip to content

Commit add6746

Browse files
committed
netfilter: add struct net * to target parameters
Signed-off-by: Patrick McHardy <kaber@trash.net>
1 parent 794e687 commit add6746

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

include/linux/netfilter/x_tables.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ struct xt_target_param {
249249
* Other fields see above.
250250
*/
251251
struct xt_tgchk_param {
252+
struct net *net;
252253
const char *table;
253254
const void *entryinfo;
254255
const struct xt_target *target;
@@ -259,6 +260,7 @@ struct xt_tgchk_param {
259260

260261
/* Target destructor parameters */
261262
struct xt_tgdtor_param {
263+
struct net *net;
262264
const struct xt_target *target;
263265
void *targinfo;
264266
u_int8_t family;

net/bridge/netfilter/ebtables.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -579,13 +579,14 @@ ebt_cleanup_match(struct ebt_entry_match *m, struct net *net, unsigned int *i)
579579
}
580580

581581
static inline int
582-
ebt_cleanup_watcher(struct ebt_entry_watcher *w, unsigned int *i)
582+
ebt_cleanup_watcher(struct ebt_entry_watcher *w, struct net *net, unsigned int *i)
583583
{
584584
struct xt_tgdtor_param par;
585585

586586
if (i && (*i)-- == 0)
587587
return 1;
588588

589+
par.net = net;
589590
par.target = w->u.watcher;
590591
par.targinfo = w->data;
591592
par.family = NFPROTO_BRIDGE;
@@ -606,10 +607,11 @@ ebt_cleanup_entry(struct ebt_entry *e, struct net *net, unsigned int *cnt)
606607
/* we're done */
607608
if (cnt && (*cnt)-- == 0)
608609
return 1;
609-
EBT_WATCHER_ITERATE(e, ebt_cleanup_watcher, NULL);
610+
EBT_WATCHER_ITERATE(e, ebt_cleanup_watcher, net, NULL);
610611
EBT_MATCH_ITERATE(e, ebt_cleanup_match, net, NULL);
611612
t = (struct ebt_entry_target *)(((char *)e) + e->target_offset);
612613

614+
par.net = net;
613615
par.target = t->u.target;
614616
par.targinfo = t->data;
615617
par.family = NFPROTO_BRIDGE;
@@ -674,7 +676,7 @@ ebt_check_entry(struct ebt_entry *e,
674676
}
675677
i = 0;
676678

677-
mtpar.net = net;
679+
mtpar.net = tgpar.net = net;
678680
mtpar.table = tgpar.table = name;
679681
mtpar.entryinfo = tgpar.entryinfo = e;
680682
mtpar.hook_mask = tgpar.hook_mask = hookmask;
@@ -730,7 +732,7 @@ ebt_check_entry(struct ebt_entry *e,
730732
(*cnt)++;
731733
return 0;
732734
cleanup_watchers:
733-
EBT_WATCHER_ITERATE(e, ebt_cleanup_watcher, &j);
735+
EBT_WATCHER_ITERATE(e, ebt_cleanup_watcher, net, &j);
734736
cleanup_matches:
735737
EBT_MATCH_ITERATE(e, ebt_cleanup_match, net, &i);
736738
return ret;

net/ipv4/netfilter/ip_tables.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -638,10 +638,11 @@ find_check_match(struct ipt_entry_match *m, struct xt_mtchk_param *par,
638638
return ret;
639639
}
640640

641-
static int check_target(struct ipt_entry *e, const char *name)
641+
static int check_target(struct ipt_entry *e, struct net *net, const char *name)
642642
{
643643
struct ipt_entry_target *t = ipt_get_target(e);
644644
struct xt_tgchk_param par = {
645+
.net = net,
645646
.table = name,
646647
.entryinfo = e,
647648
.target = t->u.kernel.target,
@@ -697,7 +698,7 @@ find_check_entry(struct ipt_entry *e, struct net *net, const char *name,
697698
}
698699
t->u.kernel.target = target;
699700

700-
ret = check_target(e, name);
701+
ret = check_target(e, net, name);
701702
if (ret)
702703
goto err;
703704

@@ -788,6 +789,7 @@ cleanup_entry(struct ipt_entry *e, struct net *net, unsigned int *i)
788789
IPT_MATCH_ITERATE(e, cleanup_match, net, NULL);
789790
t = ipt_get_target(e);
790791

792+
par.net = net;
791793
par.target = t->u.kernel.target;
792794
par.targinfo = t->data;
793795
par.family = NFPROTO_IPV4;
@@ -1675,7 +1677,7 @@ compat_check_entry(struct ipt_entry *e, struct net *net, const char *name,
16751677
if (ret)
16761678
goto cleanup_matches;
16771679

1678-
ret = check_target(e, name);
1680+
ret = check_target(e, net, name);
16791681
if (ret)
16801682
goto cleanup_matches;
16811683

net/ipv6/netfilter/ip6_tables.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -669,10 +669,11 @@ find_check_match(struct ip6t_entry_match *m, struct xt_mtchk_param *par,
669669
return ret;
670670
}
671671

672-
static int check_target(struct ip6t_entry *e, const char *name)
672+
static int check_target(struct ip6t_entry *e, struct net *net, const char *name)
673673
{
674674
struct ip6t_entry_target *t = ip6t_get_target(e);
675675
struct xt_tgchk_param par = {
676+
.net = net,
676677
.table = name,
677678
.entryinfo = e,
678679
.target = t->u.kernel.target,
@@ -729,7 +730,7 @@ find_check_entry(struct ip6t_entry *e, struct net *net, const char *name,
729730
}
730731
t->u.kernel.target = target;
731732

732-
ret = check_target(e, name);
733+
ret = check_target(e, net, name);
733734
if (ret)
734735
goto err;
735736

@@ -820,6 +821,7 @@ cleanup_entry(struct ip6t_entry *e, struct net *net, unsigned int *i)
820821
IP6T_MATCH_ITERATE(e, cleanup_match, net, NULL);
821822
t = ip6t_get_target(e);
822823

824+
par.net = net;
823825
par.target = t->u.kernel.target;
824826
par.targinfo = t->data;
825827
par.family = NFPROTO_IPV6;
@@ -1710,7 +1712,7 @@ static int compat_check_entry(struct ip6t_entry *e, struct net *net,
17101712
if (ret)
17111713
goto cleanup_matches;
17121714

1713-
ret = check_target(e, name);
1715+
ret = check_target(e, net, name);
17141716
if (ret)
17151717
goto cleanup_matches;
17161718

0 commit comments

Comments
 (0)