]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
netfilter: xtables: move extension arguments into compound structure (6/6)
authorJan Engelhardt <jengelh@medozas.de>
Wed, 8 Oct 2008 09:35:19 +0000 (11:35 +0200)
committerPatrick McHardy <kaber@trash.net>
Wed, 8 Oct 2008 09:35:19 +0000 (11:35 +0200)
This patch does this for target extensions' destroy functions.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
Signed-off-by: Patrick McHardy <kaber@trash.net>
include/linux/netfilter/x_tables.h
net/bridge/netfilter/ebtables.c
net/ipv4/netfilter/arp_tables.c
net/ipv4/netfilter/ip_tables.c
net/ipv4/netfilter/ipt_CLUSTERIP.c
net/ipv6/netfilter/ip6_tables.c
net/netfilter/xt_CONNMARK.c
net/netfilter/xt_CONNSECMARK.c
net/netfilter/xt_RATEEST.c
net/netfilter/xt_SECMARK.c
net/sched/act_ipt.c

index 8daeb496ba7ae36a0977e63c71b4871bbced8253..e3b3b669a143064e56fc97ac156a580b9d320c32 100644 (file)
@@ -251,6 +251,12 @@ struct xt_tgchk_param {
        unsigned int hook_mask;
 };
 
+/* Target destructor parameters */
+struct xt_tgdtor_param {
+       const struct xt_target *target;
+       void *targinfo;
+};
+
 struct xt_match
 {
        struct list_head list;
@@ -311,7 +317,7 @@ struct xt_target
        bool (*checkentry)(const struct xt_tgchk_param *);
 
        /* Called when entry of this type deleted. */
-       void (*destroy)(const struct xt_target *target, void *targinfo);
+       void (*destroy)(const struct xt_tgdtor_param *);
 
        /* Called when userspace align differs from kernel space one */
        void (*compat_from_user)(void *dst, void *src);
index cf823c21c166696179c18b89b7f719a513d91978..29d8061fa15355bee99e7fe485dc94b018fac0bb 100644 (file)
@@ -581,18 +581,23 @@ ebt_cleanup_match(struct ebt_entry_match *m, unsigned int *i)
 static inline int
 ebt_cleanup_watcher(struct ebt_entry_watcher *w, unsigned int *i)
 {
+       struct xt_tgdtor_param par;
+
        if (i && (*i)-- == 0)
                return 1;
-       if (w->u.watcher->destroy)
-               w->u.watcher->destroy(w->u.watcher, w->data);
-       module_put(w->u.watcher->me);
 
+       par.target   = w->u.watcher;
+       par.targinfo = w->data;
+       if (par.target->destroy != NULL)
+               par.target->destroy(&par);
+       module_put(par.target->me);
        return 0;
 }
 
 static inline int
 ebt_cleanup_entry(struct ebt_entry *e, unsigned int *cnt)
 {
+       struct xt_tgdtor_param par;
        struct ebt_entry_target *t;
 
        if (e->bitmask == 0)
@@ -603,10 +608,12 @@ ebt_cleanup_entry(struct ebt_entry *e, unsigned int *cnt)
        EBT_WATCHER_ITERATE(e, ebt_cleanup_watcher, NULL);
        EBT_MATCH_ITERATE(e, ebt_cleanup_match, NULL);
        t = (struct ebt_entry_target *)(((char *)e) + e->target_offset);
-       if (t->u.target->destroy)
-               t->u.target->destroy(t->u.target, t->data);
-       module_put(t->u.target->me);
 
+       par.target   = t->u.target;
+       par.targinfo = t->data;
+       if (par.target->destroy != NULL)
+               par.target->destroy(&par);
+       module_put(par.target->me);
        return 0;
 }
 
index b3238d0101ccb918d82eeeef560f70d333b9eab5..3bab78330cf84b9c3e09cbac50ac617169b6516b 100644 (file)
@@ -557,15 +557,18 @@ static inline int check_entry_size_and_hooks(struct arpt_entry *e,
 
 static inline int cleanup_entry(struct arpt_entry *e, unsigned int *i)
 {
+       struct xt_tgdtor_param par;
        struct arpt_entry_target *t;
 
        if (i && (*i)-- == 0)
                return 1;
 
        t = arpt_get_target(e);
-       if (t->u.kernel.target->destroy)
-               t->u.kernel.target->destroy(t->u.kernel.target, t->data);
-       module_put(t->u.kernel.target->me);
+       par.target   = t->u.kernel.target;
+       par.targinfo = t->data;
+       if (par.target->destroy != NULL)
+               par.target->destroy(&par);
+       module_put(par.target->me);
        return 0;
 }
 
index e592c54d499227bdf7e7b7df0bf30277e592ad8d..50b9a6c34c38038cbd4142ba8c3f33afcfd2d327 100644 (file)
@@ -768,6 +768,7 @@ check_entry_size_and_hooks(struct ipt_entry *e,
 static int
 cleanup_entry(struct ipt_entry *e, unsigned int *i)
 {
+       struct xt_tgdtor_param par;
        struct ipt_entry_target *t;
 
        if (i && (*i)-- == 0)
@@ -776,9 +777,12 @@ cleanup_entry(struct ipt_entry *e, unsigned int *i)
        /* Cleanup all matches */
        IPT_MATCH_ITERATE(e, cleanup_match, NULL);
        t = ipt_get_target(e);
-       if (t->u.kernel.target->destroy)
-               t->u.kernel.target->destroy(t->u.kernel.target, t->data);
-       module_put(t->u.kernel.target->me);
+
+       par.target   = t->u.kernel.target;
+       par.targinfo = t->data;
+       if (par.target->destroy != NULL)
+               par.target->destroy(&par);
+       module_put(par.target->me);
        return 0;
 }
 
index 6c7254e025615691390289614b393333bb856e58..7ac1677419a9154331dc5d81ba0973bc5383c4e8 100644 (file)
@@ -411,9 +411,9 @@ static bool clusterip_tg_check(const struct xt_tgchk_param *par)
 }
 
 /* drop reference count of cluster config when rule is deleted */
-static void clusterip_tg_destroy(const struct xt_target *target, void *targinfo)
+static void clusterip_tg_destroy(const struct xt_tgdtor_param *par)
 {
-       const struct ipt_clusterip_tgt_info *cipinfo = targinfo;
+       const struct ipt_clusterip_tgt_info *cipinfo = par->targinfo;
 
        /* if no more entries are referencing the config, remove it
         * from the list and destroy the proc entry */
@@ -421,7 +421,7 @@ static void clusterip_tg_destroy(const struct xt_target *target, void *targinfo)
 
        clusterip_config_put(cipinfo->config);
 
-       nf_ct_l3proto_module_put(target->family);
+       nf_ct_l3proto_module_put(par->target->family);
 }
 
 #ifdef CONFIG_COMPAT
index ca14fb8bd3620b2a53de7e0d0f186d6a92ebc7ea..d934a6994632043497b3d3e2b7f39b150404460d 100644 (file)
@@ -793,6 +793,7 @@ check_entry_size_and_hooks(struct ip6t_entry *e,
 static int
 cleanup_entry(struct ip6t_entry *e, unsigned int *i)
 {
+       struct xt_tgdtor_param par;
        struct ip6t_entry_target *t;
 
        if (i && (*i)-- == 0)
@@ -801,9 +802,12 @@ cleanup_entry(struct ip6t_entry *e, unsigned int *i)
        /* Cleanup all matches */
        IP6T_MATCH_ITERATE(e, cleanup_match, NULL);
        t = ip6t_get_target(e);
-       if (t->u.kernel.target->destroy)
-               t->u.kernel.target->destroy(t->u.kernel.target, t->data);
-       module_put(t->u.kernel.target->me);
+
+       par.target   = t->u.kernel.target;
+       par.targinfo = t->data;
+       if (par.target->destroy != NULL)
+               par.target->destroy(&par);
+       module_put(par.target->me);
        return 0;
 }
 
index 8fc9f35e67dffc0400d256311de9cd8cdad80959..c5a5072e005ddda1989aa59fdac3be332c75a820 100644 (file)
@@ -146,10 +146,9 @@ static bool connmark_tg_check(const struct xt_tgchk_param *par)
        return true;
 }
 
-static void
-connmark_tg_destroy(const struct xt_target *target, void *targinfo)
+static void connmark_tg_destroy(const struct xt_tgdtor_param *par)
 {
-       nf_ct_l3proto_module_put(target->family);
+       nf_ct_l3proto_module_put(par->target->family);
 }
 
 #ifdef CONFIG_COMPAT
index 2041a3d4b4d82b32c1b66117f28f7af61c0cf6a7..b6e3f3f125fd914dce2696eccb721ffdabad1b7f 100644 (file)
@@ -114,10 +114,9 @@ static bool connsecmark_tg_check(const struct xt_tgchk_param *par)
        return true;
 }
 
-static void
-connsecmark_tg_destroy(const struct xt_target *target, void *targinfo)
+static void connsecmark_tg_destroy(const struct xt_tgdtor_param *par)
 {
-       nf_ct_l3proto_module_put(target->family);
+       nf_ct_l3proto_module_put(par->target->family);
 }
 
 static struct xt_target connsecmark_tg_reg[] __read_mostly = {
index edf4ab1f30ff94765f0104b05ad52e29f7333019..43f5676b1af405d1a0c12a374710ae543d06346a 100644 (file)
@@ -139,10 +139,9 @@ err1:
        return false;
 }
 
-static void xt_rateest_tg_destroy(const struct xt_target *target,
-                                 void *targinfo)
+static void xt_rateest_tg_destroy(const struct xt_tgdtor_param *par)
 {
-       struct xt_rateest_target_info *info = targinfo;
+       struct xt_rateest_target_info *info = par->targinfo;
 
        xt_rateest_put(info->est);
 }
index e5777227192cd536cc64daaf750c7abd51827f20..7a6f9e6f5dfaa6b7e4e5eb57890542a99065b0e3 100644 (file)
@@ -113,7 +113,7 @@ static bool secmark_tg_check(const struct xt_tgchk_param *par)
        return true;
 }
 
-static void secmark_tg_destroy(const struct xt_target *target, void *targinfo)
+static void secmark_tg_destroy(const struct xt_tgdtor_param *par)
 {
        switch (mode) {
        case SECMARK_MODE_SEL:
index a54dc3f8234f3554f8c946abc651bada7d91c986..b951d422db9bf440f70b9ff1050141f20599733e 100644 (file)
@@ -67,9 +67,13 @@ static int ipt_init_target(struct ipt_entry_target *t, char *table, unsigned int
 
 static void ipt_destroy_target(struct ipt_entry_target *t)
 {
-       if (t->u.kernel.target->destroy)
-               t->u.kernel.target->destroy(t->u.kernel.target, t->data);
-       module_put(t->u.kernel.target->me);
+       struct xt_tgdtor_param par = {
+               .target   = t->u.kernel.target,
+               .targinfo = t->data,
+       };
+       if (par.target->destroy != NULL)
+               par.target->destroy(&par);
+       module_put(par.target->me);
 }
 
 static int tcf_ipt_release(struct tcf_ipt *ipt, int bind)