Commit 6028323b authored by David S. Miller's avatar David S. Miller

Merge branch 'net_sched'

Cong Wang says:

====================
net_sched: act: more cleanup and improvement

v2 -> v3:
* fix a mis-splitted patch
* keep hinfo as a pointer in ops

v1 -> v2:
* Fix a bug noticed by Jamal
* Drop patches already merged into net-next
* Add patch 5/5

Patches are cleanup's for the structures of tc actions, except patch 4
which is an improvement.

See each patch for details.
====================

Cc: Stephen Hemminger <stephen@networkplumber.org>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: default avatarCong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 7282ec8c 03701d6e
...@@ -89,7 +89,7 @@ struct tc_action_ops { ...@@ -89,7 +89,7 @@ struct tc_action_ops {
struct module *owner; struct module *owner;
int (*act)(struct sk_buff *, const struct tc_action *, struct tcf_result *); int (*act)(struct sk_buff *, const struct tc_action *, struct tcf_result *);
int (*dump)(struct sk_buff *, struct tc_action *, int, int); int (*dump)(struct sk_buff *, struct tc_action *, int, int);
int (*cleanup)(struct tc_action *, int bind); void (*cleanup)(struct tc_action *, int bind);
int (*lookup)(struct tc_action *, u32); int (*lookup)(struct tc_action *, u32);
int (*init)(struct net *net, struct nlattr *nla, int (*init)(struct net *net, struct nlattr *nla,
struct nlattr *est, struct tc_action *act, int ovr, struct nlattr *est, struct tc_action *act, int ovr,
...@@ -98,20 +98,18 @@ struct tc_action_ops { ...@@ -98,20 +98,18 @@ struct tc_action_ops {
}; };
int tcf_hash_search(struct tc_action *a, u32 index); int tcf_hash_search(struct tc_action *a, u32 index);
void tcf_hash_destroy(struct tcf_common *p, struct tcf_hashinfo *hinfo); void tcf_hash_destroy(struct tc_action *a);
int tcf_hash_release(struct tcf_common *p, int bind, int tcf_hash_release(struct tc_action *a, int bind);
struct tcf_hashinfo *hinfo);
u32 tcf_hash_new_index(struct tcf_hashinfo *hinfo); u32 tcf_hash_new_index(struct tcf_hashinfo *hinfo);
struct tcf_common *tcf_hash_check(u32 index, struct tc_action *a, int tcf_hash_check(u32 index, struct tc_action *a, int bind);
int bind); int tcf_hash_create(u32 index, struct nlattr *est, struct tc_action *a,
struct tcf_common *tcf_hash_create(u32 index, struct nlattr *est, int size, int bind);
struct tc_action *a, int size, void tcf_hash_cleanup(struct tc_action *a, struct nlattr *est);
int bind); void tcf_hash_insert(struct tc_action *a);
void tcf_hash_insert(struct tcf_common *p, struct tcf_hashinfo *hinfo);
int tcf_register_action(struct tc_action_ops *a); int tcf_register_action(struct tc_action_ops *a, unsigned int mask);
int tcf_unregister_action(struct tc_action_ops *a); int tcf_unregister_action(struct tc_action_ops *a);
void tcf_action_destroy(struct list_head *actions, int bind); int tcf_action_destroy(struct list_head *actions, int bind);
int tcf_action_exec(struct sk_buff *skb, const struct list_head *actions, int tcf_action_exec(struct sk_buff *skb, const struct list_head *actions,
struct tcf_result *res); struct tcf_result *res);
int tcf_action_init(struct net *net, struct nlattr *nla, int tcf_action_init(struct net *net, struct nlattr *nla,
......
...@@ -9,7 +9,7 @@ struct tcf_csum { ...@@ -9,7 +9,7 @@ struct tcf_csum {
u32 update_flags; u32 update_flags;
}; };
#define to_tcf_csum(pc) \ #define to_tcf_csum(a) \
container_of(pc,struct tcf_csum,common) container_of(a->priv,struct tcf_csum,common)
#endif /* __NET_TC_CSUM_H */ #endif /* __NET_TC_CSUM_H */
...@@ -8,7 +8,7 @@ struct tcf_defact { ...@@ -8,7 +8,7 @@ struct tcf_defact {
u32 tcfd_datalen; u32 tcfd_datalen;
void *tcfd_defdata; void *tcfd_defdata;
}; };
#define to_defact(pc) \ #define to_defact(a) \
container_of(pc, struct tcf_defact, common) container_of(a->priv, struct tcf_defact, common)
#endif /* __NET_TC_DEF_H */ #endif /* __NET_TC_DEF_H */
...@@ -11,7 +11,7 @@ struct tcf_gact { ...@@ -11,7 +11,7 @@ struct tcf_gact {
int tcfg_paction; int tcfg_paction;
#endif #endif
}; };
#define to_gact(pc) \ #define to_gact(a) \
container_of(pc, struct tcf_gact, common) container_of(a->priv, struct tcf_gact, common)
#endif /* __NET_TC_GACT_H */ #endif /* __NET_TC_GACT_H */
...@@ -11,7 +11,7 @@ struct tcf_ipt { ...@@ -11,7 +11,7 @@ struct tcf_ipt {
char *tcfi_tname; char *tcfi_tname;
struct xt_entry_target *tcfi_t; struct xt_entry_target *tcfi_t;
}; };
#define to_ipt(pc) \ #define to_ipt(a) \
container_of(pc, struct tcf_ipt, common) container_of(a->priv, struct tcf_ipt, common)
#endif /* __NET_TC_IPT_H */ #endif /* __NET_TC_IPT_H */
...@@ -11,7 +11,7 @@ struct tcf_mirred { ...@@ -11,7 +11,7 @@ struct tcf_mirred {
struct net_device *tcfm_dev; struct net_device *tcfm_dev;
struct list_head tcfm_list; struct list_head tcfm_list;
}; };
#define to_mirred(pc) \ #define to_mirred(a) \
container_of(pc, struct tcf_mirred, common) container_of(a->priv, struct tcf_mirred, common)
#endif /* __NET_TC_MIR_H */ #endif /* __NET_TC_MIR_H */
...@@ -13,9 +13,9 @@ struct tcf_nat { ...@@ -13,9 +13,9 @@ struct tcf_nat {
u32 flags; u32 flags;
}; };
static inline struct tcf_nat *to_tcf_nat(struct tcf_common *pc) static inline struct tcf_nat *to_tcf_nat(struct tc_action *a)
{ {
return container_of(pc, struct tcf_nat, common); return container_of(a->priv, struct tcf_nat, common);
} }
#endif /* __NET_TC_NAT_H */ #endif /* __NET_TC_NAT_H */
...@@ -9,7 +9,7 @@ struct tcf_pedit { ...@@ -9,7 +9,7 @@ struct tcf_pedit {
unsigned char tcfp_flags; unsigned char tcfp_flags;
struct tc_pedit_key *tcfp_keys; struct tc_pedit_key *tcfp_keys;
}; };
#define to_pedit(pc) \ #define to_pedit(a) \
container_of(pc, struct tcf_pedit, common) container_of(a->priv, struct tcf_pedit, common)
#endif /* __NET_TC_PED_H */ #endif /* __NET_TC_PED_H */
...@@ -29,7 +29,7 @@ struct tcf_skbedit { ...@@ -29,7 +29,7 @@ struct tcf_skbedit {
u16 queue_mapping; u16 queue_mapping;
/* XXX: 16-bit pad here? */ /* XXX: 16-bit pad here? */
}; };
#define to_skbedit(pc) \ #define to_skbedit(a) \
container_of(pc, struct tcf_skbedit, common) container_of(a->priv, struct tcf_skbedit, common)
#endif /* __NET_TC_SKBEDIT_H */ #endif /* __NET_TC_SKBEDIT_H */
...@@ -27,8 +27,11 @@ ...@@ -27,8 +27,11 @@
#include <net/act_api.h> #include <net/act_api.h>
#include <net/netlink.h> #include <net/netlink.h>
void tcf_hash_destroy(struct tcf_common *p, struct tcf_hashinfo *hinfo) void tcf_hash_destroy(struct tc_action *a)
{ {
struct tcf_common *p = a->priv;
struct tcf_hashinfo *hinfo = a->ops->hinfo;
spin_lock_bh(&hinfo->lock); spin_lock_bh(&hinfo->lock);
hlist_del(&p->tcfc_head); hlist_del(&p->tcfc_head);
spin_unlock_bh(&hinfo->lock); spin_unlock_bh(&hinfo->lock);
...@@ -42,18 +45,22 @@ void tcf_hash_destroy(struct tcf_common *p, struct tcf_hashinfo *hinfo) ...@@ -42,18 +45,22 @@ void tcf_hash_destroy(struct tcf_common *p, struct tcf_hashinfo *hinfo)
} }
EXPORT_SYMBOL(tcf_hash_destroy); EXPORT_SYMBOL(tcf_hash_destroy);
int tcf_hash_release(struct tcf_common *p, int bind, int tcf_hash_release(struct tc_action *a, int bind)
struct tcf_hashinfo *hinfo)
{ {
struct tcf_common *p = a->priv;
int ret = 0; int ret = 0;
if (p) { if (p) {
if (bind) if (bind)
p->tcfc_bindcnt--; p->tcfc_bindcnt--;
else if (p->tcfc_bindcnt > 0)
return -EPERM;
p->tcfc_refcnt--; p->tcfc_refcnt--;
if (p->tcfc_bindcnt <= 0 && p->tcfc_refcnt <= 0) { if (p->tcfc_bindcnt <= 0 && p->tcfc_refcnt <= 0) {
tcf_hash_destroy(p, hinfo); if (a->ops->cleanup)
a->ops->cleanup(a, bind);
tcf_hash_destroy(a);
ret = 1; ret = 1;
} }
} }
...@@ -118,6 +125,7 @@ static int tcf_del_walker(struct sk_buff *skb, struct tc_action *a) ...@@ -118,6 +125,7 @@ static int tcf_del_walker(struct sk_buff *skb, struct tc_action *a)
struct tcf_common *p; struct tcf_common *p;
struct nlattr *nest; struct nlattr *nest;
int i = 0, n_i = 0; int i = 0, n_i = 0;
int ret = -EINVAL;
nest = nla_nest_start(skb, a->order); nest = nla_nest_start(skb, a->order);
if (nest == NULL) if (nest == NULL)
...@@ -127,10 +135,13 @@ static int tcf_del_walker(struct sk_buff *skb, struct tc_action *a) ...@@ -127,10 +135,13 @@ static int tcf_del_walker(struct sk_buff *skb, struct tc_action *a)
for (i = 0; i < (hinfo->hmask + 1); i++) { for (i = 0; i < (hinfo->hmask + 1); i++) {
head = &hinfo->htab[tcf_hash(i, hinfo->hmask)]; head = &hinfo->htab[tcf_hash(i, hinfo->hmask)];
hlist_for_each_entry_safe(p, n, head, tcfc_head) { hlist_for_each_entry_safe(p, n, head, tcfc_head) {
if (ACT_P_DELETED == tcf_hash_release(p, 0, hinfo)) { a->priv = p;
ret = tcf_hash_release(a, 0);
if (ret == ACT_P_DELETED) {
module_put(a->ops->owner); module_put(a->ops->owner);
n_i++; n_i++;
} } else if (ret < 0)
goto nla_put_failure;
} }
} }
if (nla_put_u32(skb, TCA_FCNT, n_i)) if (nla_put_u32(skb, TCA_FCNT, n_i))
...@@ -140,7 +151,7 @@ static int tcf_del_walker(struct sk_buff *skb, struct tc_action *a) ...@@ -140,7 +151,7 @@ static int tcf_del_walker(struct sk_buff *skb, struct tc_action *a)
return n_i; return n_i;
nla_put_failure: nla_put_failure:
nla_nest_cancel(skb, nest); nla_nest_cancel(skb, nest);
return -EINVAL; return ret;
} }
static int tcf_generic_walker(struct sk_buff *skb, struct netlink_callback *cb, static int tcf_generic_walker(struct sk_buff *skb, struct netlink_callback *cb,
...@@ -198,7 +209,7 @@ int tcf_hash_search(struct tc_action *a, u32 index) ...@@ -198,7 +209,7 @@ int tcf_hash_search(struct tc_action *a, u32 index)
} }
EXPORT_SYMBOL(tcf_hash_search); EXPORT_SYMBOL(tcf_hash_search);
struct tcf_common *tcf_hash_check(u32 index, struct tc_action *a, int bind) int tcf_hash_check(u32 index, struct tc_action *a, int bind)
{ {
struct tcf_hashinfo *hinfo = a->ops->hinfo; struct tcf_hashinfo *hinfo = a->ops->hinfo;
struct tcf_common *p = NULL; struct tcf_common *p = NULL;
...@@ -207,19 +218,30 @@ struct tcf_common *tcf_hash_check(u32 index, struct tc_action *a, int bind) ...@@ -207,19 +218,30 @@ struct tcf_common *tcf_hash_check(u32 index, struct tc_action *a, int bind)
p->tcfc_bindcnt++; p->tcfc_bindcnt++;
p->tcfc_refcnt++; p->tcfc_refcnt++;
a->priv = p; a->priv = p;
return 1;
} }
return p; return 0;
} }
EXPORT_SYMBOL(tcf_hash_check); EXPORT_SYMBOL(tcf_hash_check);
struct tcf_common *tcf_hash_create(u32 index, struct nlattr *est, void tcf_hash_cleanup(struct tc_action *a, struct nlattr *est)
struct tc_action *a, int size, int bind) {
struct tcf_common *pc = a->priv;
if (est)
gen_kill_estimator(&pc->tcfc_bstats,
&pc->tcfc_rate_est);
kfree_rcu(pc, tcfc_rcu);
}
EXPORT_SYMBOL(tcf_hash_cleanup);
int tcf_hash_create(u32 index, struct nlattr *est, struct tc_action *a,
int size, int bind)
{ {
struct tcf_hashinfo *hinfo = a->ops->hinfo; struct tcf_hashinfo *hinfo = a->ops->hinfo;
struct tcf_common *p = kzalloc(size, GFP_KERNEL); struct tcf_common *p = kzalloc(size, GFP_KERNEL);
if (unlikely(!p)) if (unlikely(!p))
return ERR_PTR(-ENOMEM); return -ENOMEM;
p->tcfc_refcnt = 1; p->tcfc_refcnt = 1;
if (bind) if (bind)
p->tcfc_bindcnt = 1; p->tcfc_bindcnt = 1;
...@@ -234,17 +256,19 @@ struct tcf_common *tcf_hash_create(u32 index, struct nlattr *est, ...@@ -234,17 +256,19 @@ struct tcf_common *tcf_hash_create(u32 index, struct nlattr *est,
&p->tcfc_lock, est); &p->tcfc_lock, est);
if (err) { if (err) {
kfree(p); kfree(p);
return ERR_PTR(err); return err;
} }
} }
a->priv = (void *) p; a->priv = (void *) p;
return p; return 0;
} }
EXPORT_SYMBOL(tcf_hash_create); EXPORT_SYMBOL(tcf_hash_create);
void tcf_hash_insert(struct tcf_common *p, struct tcf_hashinfo *hinfo) void tcf_hash_insert(struct tc_action *a)
{ {
struct tcf_common *p = a->priv;
struct tcf_hashinfo *hinfo = a->ops->hinfo;
unsigned int h = tcf_hash(p->tcfc_index, hinfo->hmask); unsigned int h = tcf_hash(p->tcfc_index, hinfo->hmask);
spin_lock_bh(&hinfo->lock); spin_lock_bh(&hinfo->lock);
...@@ -256,12 +280,13 @@ EXPORT_SYMBOL(tcf_hash_insert); ...@@ -256,12 +280,13 @@ EXPORT_SYMBOL(tcf_hash_insert);
static LIST_HEAD(act_base); static LIST_HEAD(act_base);
static DEFINE_RWLOCK(act_mod_lock); static DEFINE_RWLOCK(act_mod_lock);
int tcf_register_action(struct tc_action_ops *act) int tcf_register_action(struct tc_action_ops *act, unsigned int mask)
{ {
struct tc_action_ops *a; struct tc_action_ops *a;
int err;
/* Must supply act, dump, cleanup and init */ /* Must supply act, dump and init */
if (!act->act || !act->dump || !act->cleanup || !act->init) if (!act->act || !act->dump || !act->init)
return -EINVAL; return -EINVAL;
/* Supply defaults */ /* Supply defaults */
...@@ -270,10 +295,21 @@ int tcf_register_action(struct tc_action_ops *act) ...@@ -270,10 +295,21 @@ int tcf_register_action(struct tc_action_ops *act)
if (!act->walk) if (!act->walk)
act->walk = tcf_generic_walker; act->walk = tcf_generic_walker;
act->hinfo = kmalloc(sizeof(struct tcf_hashinfo), GFP_KERNEL);
if (!act->hinfo)
return -ENOMEM;
err = tcf_hashinfo_init(act->hinfo, mask);
if (err) {
kfree(act->hinfo);
return err;
}
write_lock(&act_mod_lock); write_lock(&act_mod_lock);
list_for_each_entry(a, &act_base, head) { list_for_each_entry(a, &act_base, head) {
if (act->type == a->type || (strcmp(act->kind, a->kind) == 0)) { if (act->type == a->type || (strcmp(act->kind, a->kind) == 0)) {
write_unlock(&act_mod_lock); write_unlock(&act_mod_lock);
tcf_hashinfo_destroy(act->hinfo);
kfree(act->hinfo);
return -EEXIST; return -EEXIST;
} }
} }
...@@ -292,6 +328,8 @@ int tcf_unregister_action(struct tc_action_ops *act) ...@@ -292,6 +328,8 @@ int tcf_unregister_action(struct tc_action_ops *act)
list_for_each_entry(a, &act_base, head) { list_for_each_entry(a, &act_base, head) {
if (a == act) { if (a == act) {
list_del(&act->head); list_del(&act->head);
tcf_hashinfo_destroy(act->hinfo);
kfree(act->hinfo);
err = 0; err = 0;
break; break;
} }
...@@ -368,16 +406,21 @@ int tcf_action_exec(struct sk_buff *skb, const struct list_head *actions, ...@@ -368,16 +406,21 @@ int tcf_action_exec(struct sk_buff *skb, const struct list_head *actions,
} }
EXPORT_SYMBOL(tcf_action_exec); EXPORT_SYMBOL(tcf_action_exec);
void tcf_action_destroy(struct list_head *actions, int bind) int tcf_action_destroy(struct list_head *actions, int bind)
{ {
struct tc_action *a, *tmp; struct tc_action *a, *tmp;
int ret = 0;
list_for_each_entry_safe(a, tmp, actions, list) { list_for_each_entry_safe(a, tmp, actions, list) {
if (a->ops->cleanup(a, bind) == ACT_P_DELETED) ret = tcf_hash_release(a, bind);
if (ret == ACT_P_DELETED)
module_put(a->ops->owner); module_put(a->ops->owner);
else if (ret < 0)
return ret;
list_del(&a->list); list_del(&a->list);
kfree(a); kfree(a);
} }
return ret;
} }
int int
...@@ -642,6 +685,20 @@ act_get_notify(struct net *net, u32 portid, struct nlmsghdr *n, ...@@ -642,6 +685,20 @@ act_get_notify(struct net *net, u32 portid, struct nlmsghdr *n,
return rtnl_unicast(skb, net, portid); return rtnl_unicast(skb, net, portid);
} }
static struct tc_action *create_a(int i)
{
struct tc_action *act;
act = kzalloc(sizeof(*act), GFP_KERNEL);
if (act == NULL) {
pr_debug("create_a: failed to alloc!\n");
return NULL;
}
act->order = i;
INIT_LIST_HEAD(&act->list);
return act;
}
static struct tc_action * static struct tc_action *
tcf_action_get_1(struct nlattr *nla, struct nlmsghdr *n, u32 portid) tcf_action_get_1(struct nlattr *nla, struct nlmsghdr *n, u32 portid)
{ {
...@@ -661,11 +718,10 @@ tcf_action_get_1(struct nlattr *nla, struct nlmsghdr *n, u32 portid) ...@@ -661,11 +718,10 @@ tcf_action_get_1(struct nlattr *nla, struct nlmsghdr *n, u32 portid)
index = nla_get_u32(tb[TCA_ACT_INDEX]); index = nla_get_u32(tb[TCA_ACT_INDEX]);
err = -ENOMEM; err = -ENOMEM;
a = kzalloc(sizeof(struct tc_action), GFP_KERNEL); a = create_a(0);
if (a == NULL) if (a == NULL)
goto err_out; goto err_out;
INIT_LIST_HEAD(&a->list);
err = -EINVAL; err = -EINVAL;
a->ops = tc_lookup_action(tb[TCA_ACT_KIND]); a->ops = tc_lookup_action(tb[TCA_ACT_KIND]);
if (a->ops == NULL) /* could happen in batch of actions */ if (a->ops == NULL) /* could happen in batch of actions */
...@@ -695,20 +751,6 @@ static void cleanup_a(struct list_head *actions) ...@@ -695,20 +751,6 @@ static void cleanup_a(struct list_head *actions)
} }
} }
static struct tc_action *create_a(int i)
{
struct tc_action *act;
act = kzalloc(sizeof(*act), GFP_KERNEL);
if (act == NULL) {
pr_debug("create_a: failed to alloc!\n");
return NULL;
}
act->order = i;
INIT_LIST_HEAD(&act->list);
return act;
}
static int tca_action_flush(struct net *net, struct nlattr *nla, static int tca_action_flush(struct net *net, struct nlattr *nla,
struct nlmsghdr *n, u32 portid) struct nlmsghdr *n, u32 portid)
{ {
...@@ -720,18 +762,12 @@ static int tca_action_flush(struct net *net, struct nlattr *nla, ...@@ -720,18 +762,12 @@ static int tca_action_flush(struct net *net, struct nlattr *nla,
struct nlattr *nest; struct nlattr *nest;
struct nlattr *tb[TCA_ACT_MAX + 1]; struct nlattr *tb[TCA_ACT_MAX + 1];
struct nlattr *kind; struct nlattr *kind;
struct tc_action *a = create_a(0); struct tc_action a;
int err = -ENOMEM; int err = -ENOMEM;
if (a == NULL) {
pr_debug("tca_action_flush: couldnt create tc_action\n");
return err;
}
skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL); skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
if (!skb) { if (!skb) {
pr_debug("tca_action_flush: failed skb alloc\n"); pr_debug("tca_action_flush: failed skb alloc\n");
kfree(a);
return err; return err;
} }
...@@ -743,8 +779,10 @@ static int tca_action_flush(struct net *net, struct nlattr *nla, ...@@ -743,8 +779,10 @@ static int tca_action_flush(struct net *net, struct nlattr *nla,
err = -EINVAL; err = -EINVAL;
kind = tb[TCA_ACT_KIND]; kind = tb[TCA_ACT_KIND];
a->ops = tc_lookup_action(kind); memset(&a, 0, sizeof(struct tc_action));
if (a->ops == NULL) /*some idjot trying to flush unknown action */ INIT_LIST_HEAD(&a.list);
a.ops = tc_lookup_action(kind);
if (a.ops == NULL) /*some idjot trying to flush unknown action */
goto err_out; goto err_out;
nlh = nlmsg_put(skb, portid, n->nlmsg_seq, RTM_DELACTION, sizeof(*t), 0); nlh = nlmsg_put(skb, portid, n->nlmsg_seq, RTM_DELACTION, sizeof(*t), 0);
...@@ -759,7 +797,7 @@ static int tca_action_flush(struct net *net, struct nlattr *nla, ...@@ -759,7 +797,7 @@ static int tca_action_flush(struct net *net, struct nlattr *nla,
if (nest == NULL) if (nest == NULL)
goto out_module_put; goto out_module_put;
err = a->ops->walk(skb, &dcb, RTM_DELACTION, a); err = a.ops->walk(skb, &dcb, RTM_DELACTION, &a);
if (err < 0) if (err < 0)
goto out_module_put; goto out_module_put;
if (err == 0) if (err == 0)
...@@ -769,8 +807,7 @@ static int tca_action_flush(struct net *net, struct nlattr *nla, ...@@ -769,8 +807,7 @@ static int tca_action_flush(struct net *net, struct nlattr *nla,
nlh->nlmsg_len = skb_tail_pointer(skb) - b; nlh->nlmsg_len = skb_tail_pointer(skb) - b;
nlh->nlmsg_flags |= NLM_F_ROOT; nlh->nlmsg_flags |= NLM_F_ROOT;
module_put(a->ops->owner); module_put(a.ops->owner);
kfree(a);
err = rtnetlink_send(skb, net, portid, RTNLGRP_TC, err = rtnetlink_send(skb, net, portid, RTNLGRP_TC,
n->nlmsg_flags & NLM_F_ECHO); n->nlmsg_flags & NLM_F_ECHO);
if (err > 0) if (err > 0)
...@@ -779,11 +816,10 @@ static int tca_action_flush(struct net *net, struct nlattr *nla, ...@@ -779,11 +816,10 @@ static int tca_action_flush(struct net *net, struct nlattr *nla,
return err; return err;
out_module_put: out_module_put:
module_put(a->ops->owner); module_put(a.ops->owner);
err_out: err_out:
noflush_out: noflush_out:
kfree_skb(skb); kfree_skb(skb);
kfree(a);
return err; return err;
} }
...@@ -805,7 +841,11 @@ tcf_del_notify(struct net *net, struct nlmsghdr *n, struct list_head *actions, ...@@ -805,7 +841,11 @@ tcf_del_notify(struct net *net, struct nlmsghdr *n, struct list_head *actions,
} }
/* now do the delete */ /* now do the delete */
tcf_action_destroy(actions, 0); ret = tcf_action_destroy(actions, 0);
if (ret < 0) {
kfree_skb(skb);
return ret;
}
ret = rtnetlink_send(skb, net, portid, RTNLGRP_TC, ret = rtnetlink_send(skb, net, portid, RTNLGRP_TC,
n->nlmsg_flags & NLM_F_ECHO); n->nlmsg_flags & NLM_F_ECHO);
......
...@@ -37,7 +37,6 @@ ...@@ -37,7 +37,6 @@
#include <net/tc_act/tc_csum.h> #include <net/tc_act/tc_csum.h>
#define CSUM_TAB_MASK 15 #define CSUM_TAB_MASK 15
static struct tcf_hashinfo csum_hash_info;
static const struct nla_policy csum_policy[TCA_CSUM_MAX + 1] = { static const struct nla_policy csum_policy[TCA_CSUM_MAX + 1] = {
[TCA_CSUM_PARMS] = { .len = sizeof(struct tc_csum), }, [TCA_CSUM_PARMS] = { .len = sizeof(struct tc_csum), },
...@@ -48,7 +47,6 @@ static int tcf_csum_init(struct net *n, struct nlattr *nla, struct nlattr *est, ...@@ -48,7 +47,6 @@ static int tcf_csum_init(struct net *n, struct nlattr *nla, struct nlattr *est,
{ {
struct nlattr *tb[TCA_CSUM_MAX + 1]; struct nlattr *tb[TCA_CSUM_MAX + 1];
struct tc_csum *parm; struct tc_csum *parm;
struct tcf_common *pc;
struct tcf_csum *p; struct tcf_csum *p;
int ret = 0, err; int ret = 0, err;
...@@ -63,38 +61,31 @@ static int tcf_csum_init(struct net *n, struct nlattr *nla, struct nlattr *est, ...@@ -63,38 +61,31 @@ static int tcf_csum_init(struct net *n, struct nlattr *nla, struct nlattr *est,
return -EINVAL; return -EINVAL;
parm = nla_data(tb[TCA_CSUM_PARMS]); parm = nla_data(tb[TCA_CSUM_PARMS]);
pc = tcf_hash_check(parm->index, a, bind); if (!tcf_hash_check(parm->index, a, bind)) {
if (!pc) { ret = tcf_hash_create(parm->index, est, a, sizeof(*p), bind);
pc = tcf_hash_create(parm->index, est, a, sizeof(*p), bind); if (ret)
if (IS_ERR(pc)) return ret;
return PTR_ERR(pc);
ret = ACT_P_CREATED; ret = ACT_P_CREATED;
} else { } else {
if (bind)/* dont override defaults */ if (bind)/* dont override defaults */
return 0; return 0;
tcf_hash_release(pc, bind, a->ops->hinfo); tcf_hash_release(a, bind);
if (!ovr) if (!ovr)
return -EEXIST; return -EEXIST;
} }
p = to_tcf_csum(pc); p = to_tcf_csum(a);
spin_lock_bh(&p->tcf_lock); spin_lock_bh(&p->tcf_lock);
p->tcf_action = parm->action; p->tcf_action = parm->action;
p->update_flags = parm->update_flags; p->update_flags = parm->update_flags;
spin_unlock_bh(&p->tcf_lock); spin_unlock_bh(&p->tcf_lock);
if (ret == ACT_P_CREATED) if (ret == ACT_P_CREATED)
tcf_hash_insert(pc, a->ops->hinfo); tcf_hash_insert(a);
return ret; return ret;
} }
static int tcf_csum_cleanup(struct tc_action *a, int bind)
{
struct tcf_csum *p = a->priv;
return tcf_hash_release(&p->common, bind, &csum_hash_info);
}
/** /**
* tcf_csum_skb_nextlayer - Get next layer pointer * tcf_csum_skb_nextlayer - Get next layer pointer
* @skb: sk_buff to use * @skb: sk_buff to use
...@@ -569,12 +560,10 @@ static int tcf_csum_dump(struct sk_buff *skb, ...@@ -569,12 +560,10 @@ static int tcf_csum_dump(struct sk_buff *skb,
static struct tc_action_ops act_csum_ops = { static struct tc_action_ops act_csum_ops = {
.kind = "csum", .kind = "csum",
.hinfo = &csum_hash_info,
.type = TCA_ACT_CSUM, .type = TCA_ACT_CSUM,
.owner = THIS_MODULE, .owner = THIS_MODULE,
.act = tcf_csum, .act = tcf_csum,
.dump = tcf_csum_dump, .dump = tcf_csum_dump,
.cleanup = tcf_csum_cleanup,
.init = tcf_csum_init, .init = tcf_csum_init,
}; };
...@@ -583,11 +572,7 @@ MODULE_LICENSE("GPL"); ...@@ -583,11 +572,7 @@ MODULE_LICENSE("GPL");
static int __init csum_init_module(void) static int __init csum_init_module(void)
{ {
int err = tcf_hashinfo_init(&csum_hash_info, CSUM_TAB_MASK); return tcf_register_action(&act_csum_ops, CSUM_TAB_MASK);
if (err)
return err;
return tcf_register_action(&act_csum_ops);
} }
static void __exit csum_cleanup_module(void) static void __exit csum_cleanup_module(void)
......
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
#include <net/tc_act/tc_gact.h> #include <net/tc_act/tc_gact.h>
#define GACT_TAB_MASK 15 #define GACT_TAB_MASK 15
static struct tcf_hashinfo gact_hash_info;
#ifdef CONFIG_GACT_PROB #ifdef CONFIG_GACT_PROB
static int gact_net_rand(struct tcf_gact *gact) static int gact_net_rand(struct tcf_gact *gact)
...@@ -57,7 +56,6 @@ static int tcf_gact_init(struct net *net, struct nlattr *nla, ...@@ -57,7 +56,6 @@ static int tcf_gact_init(struct net *net, struct nlattr *nla,
struct nlattr *tb[TCA_GACT_MAX + 1]; struct nlattr *tb[TCA_GACT_MAX + 1];
struct tc_gact *parm; struct tc_gact *parm;
struct tcf_gact *gact; struct tcf_gact *gact;
struct tcf_common *pc;
int ret = 0; int ret = 0;
int err; int err;
#ifdef CONFIG_GACT_PROB #ifdef CONFIG_GACT_PROB
...@@ -86,21 +84,20 @@ static int tcf_gact_init(struct net *net, struct nlattr *nla, ...@@ -86,21 +84,20 @@ static int tcf_gact_init(struct net *net, struct nlattr *nla,
} }
#endif #endif
pc = tcf_hash_check(parm->index, a, bind); if (!tcf_hash_check(parm->index, a, bind)) {
if (!pc) { ret = tcf_hash_create(parm->index, est, a, sizeof(*gact), bind);
pc = tcf_hash_create(parm->index, est, a, sizeof(*gact), bind); if (ret)
if (IS_ERR(pc)) return ret;
return PTR_ERR(pc);
ret = ACT_P_CREATED; ret = ACT_P_CREATED;
} else { } else {
if (bind)/* dont override defaults */ if (bind)/* dont override defaults */
return 0; return 0;
tcf_hash_release(pc, bind, a->ops->hinfo); tcf_hash_release(a, bind);
if (!ovr) if (!ovr)
return -EEXIST; return -EEXIST;
} }
gact = to_gact(pc); gact = to_gact(a);
spin_lock_bh(&gact->tcf_lock); spin_lock_bh(&gact->tcf_lock);
gact->tcf_action = parm->action; gact->tcf_action = parm->action;
...@@ -113,19 +110,10 @@ static int tcf_gact_init(struct net *net, struct nlattr *nla, ...@@ -113,19 +110,10 @@ static int tcf_gact_init(struct net *net, struct nlattr *nla,
#endif #endif
spin_unlock_bh(&gact->tcf_lock); spin_unlock_bh(&gact->tcf_lock);
if (ret == ACT_P_CREATED) if (ret == ACT_P_CREATED)
tcf_hash_insert(pc, a->ops->hinfo); tcf_hash_insert(a);
return ret; return ret;
} }
static int tcf_gact_cleanup(struct tc_action *a, int bind)
{
struct tcf_gact *gact = a->priv;
if (gact)
return tcf_hash_release(&gact->common, bind, a->ops->hinfo);
return 0;
}
static int tcf_gact(struct sk_buff *skb, const struct tc_action *a, static int tcf_gact(struct sk_buff *skb, const struct tc_action *a,
struct tcf_result *res) struct tcf_result *res)
{ {
...@@ -191,12 +179,10 @@ static int tcf_gact_dump(struct sk_buff *skb, struct tc_action *a, int bind, int ...@@ -191,12 +179,10 @@ static int tcf_gact_dump(struct sk_buff *skb, struct tc_action *a, int bind, int
static struct tc_action_ops act_gact_ops = { static struct tc_action_ops act_gact_ops = {
.kind = "gact", .kind = "gact",
.hinfo = &gact_hash_info,
.type = TCA_ACT_GACT, .type = TCA_ACT_GACT,
.owner = THIS_MODULE, .owner = THIS_MODULE,
.act = tcf_gact, .act = tcf_gact,
.dump = tcf_gact_dump, .dump = tcf_gact_dump,
.cleanup = tcf_gact_cleanup,
.init = tcf_gact_init, .init = tcf_gact_init,
}; };
...@@ -206,21 +192,17 @@ MODULE_LICENSE("GPL"); ...@@ -206,21 +192,17 @@ MODULE_LICENSE("GPL");
static int __init gact_init_module(void) static int __init gact_init_module(void)
{ {
int err = tcf_hashinfo_init(&gact_hash_info, GACT_TAB_MASK);
if (err)
return err;
#ifdef CONFIG_GACT_PROB #ifdef CONFIG_GACT_PROB
pr_info("GACT probability on\n"); pr_info("GACT probability on\n");
#else #else
pr_info("GACT probability NOT on\n"); pr_info("GACT probability NOT on\n");
#endif #endif
return tcf_register_action(&act_gact_ops); return tcf_register_action(&act_gact_ops, GACT_TAB_MASK);
} }
static void __exit gact_cleanup_module(void) static void __exit gact_cleanup_module(void)
{ {
tcf_unregister_action(&act_gact_ops); tcf_unregister_action(&act_gact_ops);
tcf_hashinfo_destroy(&gact_hash_info);
} }
module_init(gact_init_module); module_init(gact_init_module);
......
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
#define IPT_TAB_MASK 15 #define IPT_TAB_MASK 15
static struct tcf_hashinfo ipt_hash_info;
static int ipt_init_target(struct xt_entry_target *t, char *table, unsigned int hook) static int ipt_init_target(struct xt_entry_target *t, char *table, unsigned int hook)
{ {
...@@ -69,22 +68,12 @@ static void ipt_destroy_target(struct xt_entry_target *t) ...@@ -69,22 +68,12 @@ static void ipt_destroy_target(struct xt_entry_target *t)
module_put(par.target->me); module_put(par.target->me);
} }
static int tcf_ipt_release(struct tcf_ipt *ipt, int bind) static void tcf_ipt_release(struct tc_action *a, int bind)
{ {
int ret = 0; struct tcf_ipt *ipt = to_ipt(a);
if (ipt) {
if (bind)
ipt->tcf_bindcnt--;
ipt->tcf_refcnt--;
if (ipt->tcf_bindcnt <= 0 && ipt->tcf_refcnt <= 0) {
ipt_destroy_target(ipt->tcfi_t); ipt_destroy_target(ipt->tcfi_t);
kfree(ipt->tcfi_tname); kfree(ipt->tcfi_tname);
kfree(ipt->tcfi_t); kfree(ipt->tcfi_t);
tcf_hash_destroy(&ipt->common, &ipt_hash_info);
ret = ACT_P_DELETED;
}
}
return ret;
} }
static const struct nla_policy ipt_policy[TCA_IPT_MAX + 1] = { static const struct nla_policy ipt_policy[TCA_IPT_MAX + 1] = {
...@@ -99,7 +88,6 @@ static int tcf_ipt_init(struct net *net, struct nlattr *nla, struct nlattr *est, ...@@ -99,7 +88,6 @@ static int tcf_ipt_init(struct net *net, struct nlattr *nla, struct nlattr *est,
{ {
struct nlattr *tb[TCA_IPT_MAX + 1]; struct nlattr *tb[TCA_IPT_MAX + 1];
struct tcf_ipt *ipt; struct tcf_ipt *ipt;
struct tcf_common *pc;
struct xt_entry_target *td, *t; struct xt_entry_target *td, *t;
char *tname; char *tname;
int ret = 0, err; int ret = 0, err;
...@@ -125,21 +113,20 @@ static int tcf_ipt_init(struct net *net, struct nlattr *nla, struct nlattr *est, ...@@ -125,21 +113,20 @@ static int tcf_ipt_init(struct net *net, struct nlattr *nla, struct nlattr *est,
if (tb[TCA_IPT_INDEX] != NULL) if (tb[TCA_IPT_INDEX] != NULL)
index = nla_get_u32(tb[TCA_IPT_INDEX]); index = nla_get_u32(tb[TCA_IPT_INDEX]);
pc = tcf_hash_check(index, a, bind); if (!tcf_hash_check(index, a, bind) ) {
if (!pc) { ret = tcf_hash_create(index, est, a, sizeof(*ipt), bind);
pc = tcf_hash_create(index, est, a, sizeof(*ipt), bind); if (ret)
if (IS_ERR(pc)) return ret;
return PTR_ERR(pc);
ret = ACT_P_CREATED; ret = ACT_P_CREATED;
} else { } else {
if (bind)/* dont override defaults */ if (bind)/* dont override defaults */
return 0; return 0;
tcf_ipt_release(to_ipt(pc), bind); tcf_hash_release(a, bind);
if (!ovr) if (!ovr)
return -EEXIST; return -EEXIST;
} }
ipt = to_ipt(pc); ipt = to_ipt(a);
hook = nla_get_u32(tb[TCA_IPT_HOOK]); hook = nla_get_u32(tb[TCA_IPT_HOOK]);
...@@ -170,7 +157,7 @@ static int tcf_ipt_init(struct net *net, struct nlattr *nla, struct nlattr *est, ...@@ -170,7 +157,7 @@ static int tcf_ipt_init(struct net *net, struct nlattr *nla, struct nlattr *est,
ipt->tcfi_hook = hook; ipt->tcfi_hook = hook;
spin_unlock_bh(&ipt->tcf_lock); spin_unlock_bh(&ipt->tcf_lock);
if (ret == ACT_P_CREATED) if (ret == ACT_P_CREATED)
tcf_hash_insert(pc, a->ops->hinfo); tcf_hash_insert(a);
return ret; return ret;
err3: err3:
...@@ -178,21 +165,11 @@ static int tcf_ipt_init(struct net *net, struct nlattr *nla, struct nlattr *est, ...@@ -178,21 +165,11 @@ static int tcf_ipt_init(struct net *net, struct nlattr *nla, struct nlattr *est,
err2: err2:
kfree(tname); kfree(tname);
err1: err1:
if (ret == ACT_P_CREATED) { if (ret == ACT_P_CREATED)
if (est) tcf_hash_cleanup(a, est);
gen_kill_estimator(&pc->tcfc_bstats,
&pc->tcfc_rate_est);
kfree_rcu(pc, tcfc_rcu);
}
return err; return err;
} }
static int tcf_ipt_cleanup(struct tc_action *a, int bind)
{
struct tcf_ipt *ipt = a->priv;
return tcf_ipt_release(ipt, bind);
}
static int tcf_ipt(struct sk_buff *skb, const struct tc_action *a, static int tcf_ipt(struct sk_buff *skb, const struct tc_action *a,
struct tcf_result *res) struct tcf_result *res)
{ {
...@@ -284,23 +261,21 @@ static int tcf_ipt_dump(struct sk_buff *skb, struct tc_action *a, int bind, int ...@@ -284,23 +261,21 @@ static int tcf_ipt_dump(struct sk_buff *skb, struct tc_action *a, int bind, int
static struct tc_action_ops act_ipt_ops = { static struct tc_action_ops act_ipt_ops = {
.kind = "ipt", .kind = "ipt",
.hinfo = &ipt_hash_info,
.type = TCA_ACT_IPT, .type = TCA_ACT_IPT,
.owner = THIS_MODULE, .owner = THIS_MODULE,
.act = tcf_ipt, .act = tcf_ipt,
.dump = tcf_ipt_dump, .dump = tcf_ipt_dump,
.cleanup = tcf_ipt_cleanup, .cleanup = tcf_ipt_release,
.init = tcf_ipt_init, .init = tcf_ipt_init,
}; };
static struct tc_action_ops act_xt_ops = { static struct tc_action_ops act_xt_ops = {
.kind = "xt", .kind = "xt",
.hinfo = &ipt_hash_info,
.type = TCA_ACT_XT, .type = TCA_ACT_XT,
.owner = THIS_MODULE, .owner = THIS_MODULE,
.act = tcf_ipt, .act = tcf_ipt,
.dump = tcf_ipt_dump, .dump = tcf_ipt_dump,
.cleanup = tcf_ipt_cleanup, .cleanup = tcf_ipt_release,
.init = tcf_ipt_init, .init = tcf_ipt_init,
}; };
...@@ -311,20 +286,16 @@ MODULE_ALIAS("act_xt"); ...@@ -311,20 +286,16 @@ MODULE_ALIAS("act_xt");
static int __init ipt_init_module(void) static int __init ipt_init_module(void)
{ {
int ret1, ret2, err; int ret1, ret2;
err = tcf_hashinfo_init(&ipt_hash_info, IPT_TAB_MASK);
if (err)
return err;
ret1 = tcf_register_action(&act_xt_ops); ret1 = tcf_register_action(&act_xt_ops, IPT_TAB_MASK);
if (ret1 < 0) if (ret1 < 0)
printk("Failed to load xt action\n"); printk("Failed to load xt action\n");
ret2 = tcf_register_action(&act_ipt_ops); ret2 = tcf_register_action(&act_ipt_ops, IPT_TAB_MASK);
if (ret2 < 0) if (ret2 < 0)
printk("Failed to load ipt action\n"); printk("Failed to load ipt action\n");
if (ret1 < 0 && ret2 < 0) { if (ret1 < 0 && ret2 < 0) {
tcf_hashinfo_destroy(&ipt_hash_info);
return ret1; return ret1;
} else } else
return 0; return 0;
...@@ -334,7 +305,6 @@ static void __exit ipt_cleanup_module(void) ...@@ -334,7 +305,6 @@ static void __exit ipt_cleanup_module(void)
{ {
tcf_unregister_action(&act_xt_ops); tcf_unregister_action(&act_xt_ops);
tcf_unregister_action(&act_ipt_ops); tcf_unregister_action(&act_ipt_ops);
tcf_hashinfo_destroy(&ipt_hash_info);
} }
module_init(ipt_init_module); module_init(ipt_init_module);
......
...@@ -31,23 +31,13 @@ ...@@ -31,23 +31,13 @@
#define MIRRED_TAB_MASK 7 #define MIRRED_TAB_MASK 7
static LIST_HEAD(mirred_list); static LIST_HEAD(mirred_list);
static struct tcf_hashinfo mirred_hash_info;
static int tcf_mirred_release(struct tcf_mirred *m, int bind) static void tcf_mirred_release(struct tc_action *a, int bind)
{ {
if (m) { struct tcf_mirred *m = to_mirred(a);
if (bind)
m->tcf_bindcnt--;
m->tcf_refcnt--;
if (!m->tcf_bindcnt && m->tcf_refcnt <= 0) {
list_del(&m->tcfm_list); list_del(&m->tcfm_list);
if (m->tcfm_dev) if (m->tcfm_dev)
dev_put(m->tcfm_dev); dev_put(m->tcfm_dev);
tcf_hash_destroy(&m->common, &mirred_hash_info);
return 1;
}
}
return 0;
} }
static const struct nla_policy mirred_policy[TCA_MIRRED_MAX + 1] = { static const struct nla_policy mirred_policy[TCA_MIRRED_MAX + 1] = {
...@@ -61,7 +51,6 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla, ...@@ -61,7 +51,6 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla,
struct nlattr *tb[TCA_MIRRED_MAX + 1]; struct nlattr *tb[TCA_MIRRED_MAX + 1];
struct tc_mirred *parm; struct tc_mirred *parm;
struct tcf_mirred *m; struct tcf_mirred *m;
struct tcf_common *pc;
struct net_device *dev; struct net_device *dev;
int ret, ok_push = 0; int ret, ok_push = 0;
...@@ -101,21 +90,20 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla, ...@@ -101,21 +90,20 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla,
dev = NULL; dev = NULL;
} }
pc = tcf_hash_check(parm->index, a, bind); if (!tcf_hash_check(parm->index, a, bind)) {
if (!pc) {
if (dev == NULL) if (dev == NULL)
return -EINVAL; return -EINVAL;
pc = tcf_hash_create(parm->index, est, a, sizeof(*m), bind); ret = tcf_hash_create(parm->index, est, a, sizeof(*m), bind);
if (IS_ERR(pc)) if (ret)
return PTR_ERR(pc); return ret;
ret = ACT_P_CREATED; ret = ACT_P_CREATED;
} else { } else {
if (!ovr) { if (!ovr) {
tcf_mirred_release(to_mirred(pc), bind); tcf_hash_release(a, bind);
return -EEXIST; return -EEXIST;
} }
} }
m = to_mirred(pc); m = to_mirred(a);
spin_lock_bh(&m->tcf_lock); spin_lock_bh(&m->tcf_lock);
m->tcf_action = parm->action; m->tcf_action = parm->action;
...@@ -131,21 +119,12 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla, ...@@ -131,21 +119,12 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla,
spin_unlock_bh(&m->tcf_lock); spin_unlock_bh(&m->tcf_lock);
if (ret == ACT_P_CREATED) { if (ret == ACT_P_CREATED) {
list_add(&m->tcfm_list, &mirred_list); list_add(&m->tcfm_list, &mirred_list);
tcf_hash_insert(pc, a->ops->hinfo); tcf_hash_insert(a);
} }
return ret; return ret;
} }
static int tcf_mirred_cleanup(struct tc_action *a, int bind)
{
struct tcf_mirred *m = a->priv;
if (m)
return tcf_mirred_release(m, bind);
return 0;
}
static int tcf_mirred(struct sk_buff *skb, const struct tc_action *a, static int tcf_mirred(struct sk_buff *skb, const struct tc_action *a,
struct tcf_result *res) struct tcf_result *res)
{ {
...@@ -254,12 +233,11 @@ static struct notifier_block mirred_device_notifier = { ...@@ -254,12 +233,11 @@ static struct notifier_block mirred_device_notifier = {
static struct tc_action_ops act_mirred_ops = { static struct tc_action_ops act_mirred_ops = {
.kind = "mirred", .kind = "mirred",
.hinfo = &mirred_hash_info,
.type = TCA_ACT_MIRRED, .type = TCA_ACT_MIRRED,
.owner = THIS_MODULE, .owner = THIS_MODULE,
.act = tcf_mirred, .act = tcf_mirred,
.dump = tcf_mirred_dump, .dump = tcf_mirred_dump,
.cleanup = tcf_mirred_cleanup, .cleanup = tcf_mirred_release,
.init = tcf_mirred_init, .init = tcf_mirred_init,
}; };
...@@ -273,19 +251,13 @@ static int __init mirred_init_module(void) ...@@ -273,19 +251,13 @@ static int __init mirred_init_module(void)
if (err) if (err)
return err; return err;
err = tcf_hashinfo_init(&mirred_hash_info, MIRRED_TAB_MASK);
if (err) {
unregister_netdevice_notifier(&mirred_device_notifier);
return err;
}
pr_info("Mirror/redirect action on\n"); pr_info("Mirror/redirect action on\n");
return tcf_register_action(&act_mirred_ops); return tcf_register_action(&act_mirred_ops, MIRRED_TAB_MASK);
} }
static void __exit mirred_cleanup_module(void) static void __exit mirred_cleanup_module(void)
{ {
tcf_unregister_action(&act_mirred_ops); tcf_unregister_action(&act_mirred_ops);
tcf_hashinfo_destroy(&mirred_hash_info);
unregister_netdevice_notifier(&mirred_device_notifier); unregister_netdevice_notifier(&mirred_device_notifier);
} }
......
...@@ -31,8 +31,6 @@ ...@@ -31,8 +31,6 @@
#define NAT_TAB_MASK 15 #define NAT_TAB_MASK 15
static struct tcf_hashinfo nat_hash_info;
static const struct nla_policy nat_policy[TCA_NAT_MAX + 1] = { static const struct nla_policy nat_policy[TCA_NAT_MAX + 1] = {
[TCA_NAT_PARMS] = { .len = sizeof(struct tc_nat) }, [TCA_NAT_PARMS] = { .len = sizeof(struct tc_nat) },
}; };
...@@ -44,7 +42,6 @@ static int tcf_nat_init(struct net *net, struct nlattr *nla, struct nlattr *est, ...@@ -44,7 +42,6 @@ static int tcf_nat_init(struct net *net, struct nlattr *nla, struct nlattr *est,
struct tc_nat *parm; struct tc_nat *parm;
int ret = 0, err; int ret = 0, err;
struct tcf_nat *p; struct tcf_nat *p;
struct tcf_common *pc;
if (nla == NULL) if (nla == NULL)
return -EINVAL; return -EINVAL;
...@@ -57,20 +54,19 @@ static int tcf_nat_init(struct net *net, struct nlattr *nla, struct nlattr *est, ...@@ -57,20 +54,19 @@ static int tcf_nat_init(struct net *net, struct nlattr *nla, struct nlattr *est,
return -EINVAL; return -EINVAL;
parm = nla_data(tb[TCA_NAT_PARMS]); parm = nla_data(tb[TCA_NAT_PARMS]);
pc = tcf_hash_check(parm->index, a, bind); if (!tcf_hash_check(parm->index, a, bind)) {
if (!pc) { ret = tcf_hash_create(parm->index, est, a, sizeof(*p), bind);
pc = tcf_hash_create(parm->index, est, a, sizeof(*p), bind); if (ret)
if (IS_ERR(pc)) return ret;
return PTR_ERR(pc);
ret = ACT_P_CREATED; ret = ACT_P_CREATED;
} else { } else {
if (bind) if (bind)
return 0; return 0;
tcf_hash_release(pc, bind, a->ops->hinfo); tcf_hash_release(a, bind);
if (!ovr) if (!ovr)
return -EEXIST; return -EEXIST;
} }
p = to_tcf_nat(pc); p = to_tcf_nat(a);
spin_lock_bh(&p->tcf_lock); spin_lock_bh(&p->tcf_lock);
p->old_addr = parm->old_addr; p->old_addr = parm->old_addr;
...@@ -82,18 +78,11 @@ static int tcf_nat_init(struct net *net, struct nlattr *nla, struct nlattr *est, ...@@ -82,18 +78,11 @@ static int tcf_nat_init(struct net *net, struct nlattr *nla, struct nlattr *est,
spin_unlock_bh(&p->tcf_lock); spin_unlock_bh(&p->tcf_lock);
if (ret == ACT_P_CREATED) if (ret == ACT_P_CREATED)
tcf_hash_insert(pc, a->ops->hinfo); tcf_hash_insert(a);
return ret; return ret;
} }
static int tcf_nat_cleanup(struct tc_action *a, int bind)
{
struct tcf_nat *p = a->priv;
return tcf_hash_release(&p->common, bind, &nat_hash_info);
}
static int tcf_nat(struct sk_buff *skb, const struct tc_action *a, static int tcf_nat(struct sk_buff *skb, const struct tc_action *a,
struct tcf_result *res) struct tcf_result *res)
{ {
...@@ -293,12 +282,10 @@ static int tcf_nat_dump(struct sk_buff *skb, struct tc_action *a, ...@@ -293,12 +282,10 @@ static int tcf_nat_dump(struct sk_buff *skb, struct tc_action *a,
static struct tc_action_ops act_nat_ops = { static struct tc_action_ops act_nat_ops = {
.kind = "nat", .kind = "nat",
.hinfo = &nat_hash_info,
.type = TCA_ACT_NAT, .type = TCA_ACT_NAT,
.owner = THIS_MODULE, .owner = THIS_MODULE,
.act = tcf_nat, .act = tcf_nat,
.dump = tcf_nat_dump, .dump = tcf_nat_dump,
.cleanup = tcf_nat_cleanup,
.init = tcf_nat_init, .init = tcf_nat_init,
}; };
...@@ -307,16 +294,12 @@ MODULE_LICENSE("GPL"); ...@@ -307,16 +294,12 @@ MODULE_LICENSE("GPL");
static int __init nat_init_module(void) static int __init nat_init_module(void)
{ {
int err = tcf_hashinfo_init(&nat_hash_info, NAT_TAB_MASK); return tcf_register_action(&act_nat_ops, NAT_TAB_MASK);
if (err)
return err;
return tcf_register_action(&act_nat_ops);
} }
static void __exit nat_cleanup_module(void) static void __exit nat_cleanup_module(void)
{ {
tcf_unregister_action(&act_nat_ops); tcf_unregister_action(&act_nat_ops);
tcf_hashinfo_destroy(&nat_hash_info);
} }
module_init(nat_init_module); module_init(nat_init_module);
......
...@@ -25,8 +25,6 @@ ...@@ -25,8 +25,6 @@
#define PEDIT_TAB_MASK 15 #define PEDIT_TAB_MASK 15
static struct tcf_hashinfo pedit_hash_info;
static const struct nla_policy pedit_policy[TCA_PEDIT_MAX + 1] = { static const struct nla_policy pedit_policy[TCA_PEDIT_MAX + 1] = {
[TCA_PEDIT_PARMS] = { .len = sizeof(struct tc_pedit) }, [TCA_PEDIT_PARMS] = { .len = sizeof(struct tc_pedit) },
}; };
...@@ -39,7 +37,6 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla, ...@@ -39,7 +37,6 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla,
struct tc_pedit *parm; struct tc_pedit *parm;
int ret = 0, err; int ret = 0, err;
struct tcf_pedit *p; struct tcf_pedit *p;
struct tcf_common *pc;
struct tc_pedit_key *keys = NULL; struct tc_pedit_key *keys = NULL;
int ksize; int ksize;
...@@ -57,26 +54,22 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla, ...@@ -57,26 +54,22 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla,
if (nla_len(tb[TCA_PEDIT_PARMS]) < sizeof(*parm) + ksize) if (nla_len(tb[TCA_PEDIT_PARMS]) < sizeof(*parm) + ksize)
return -EINVAL; return -EINVAL;
pc = tcf_hash_check(parm->index, a, bind); if (!tcf_hash_check(parm->index, a, bind)) {
if (!pc) {
if (!parm->nkeys) if (!parm->nkeys)
return -EINVAL; return -EINVAL;
pc = tcf_hash_create(parm->index, est, a, sizeof(*p), bind); ret = tcf_hash_create(parm->index, est, a, sizeof(*p), bind);
if (IS_ERR(pc)) if (ret)
return PTR_ERR(pc); return ret;
p = to_pedit(pc); p = to_pedit(a);
keys = kmalloc(ksize, GFP_KERNEL); keys = kmalloc(ksize, GFP_KERNEL);
if (keys == NULL) { if (keys == NULL) {
if (est) tcf_hash_cleanup(a, est);
gen_kill_estimator(&pc->tcfc_bstats,
&pc->tcfc_rate_est);
kfree_rcu(pc, tcfc_rcu);
return -ENOMEM; return -ENOMEM;
} }
ret = ACT_P_CREATED; ret = ACT_P_CREATED;
} else { } else {
p = to_pedit(pc); p = to_pedit(a);
tcf_hash_release(pc, bind, a->ops->hinfo); tcf_hash_release(a, bind);
if (bind) if (bind)
return 0; return 0;
if (!ovr) if (!ovr)
...@@ -100,22 +93,15 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla, ...@@ -100,22 +93,15 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla,
memcpy(p->tcfp_keys, parm->keys, ksize); memcpy(p->tcfp_keys, parm->keys, ksize);
spin_unlock_bh(&p->tcf_lock); spin_unlock_bh(&p->tcf_lock);
if (ret == ACT_P_CREATED) if (ret == ACT_P_CREATED)
tcf_hash_insert(pc, a->ops->hinfo); tcf_hash_insert(a);
return ret; return ret;
} }
static int tcf_pedit_cleanup(struct tc_action *a, int bind) static void tcf_pedit_cleanup(struct tc_action *a, int bind)
{ {
struct tcf_pedit *p = a->priv; struct tcf_pedit *p = a->priv;
if (p) {
struct tc_pedit_key *keys = p->tcfp_keys; struct tc_pedit_key *keys = p->tcfp_keys;
if (tcf_hash_release(&p->common, bind, &pedit_hash_info)) {
kfree(keys); kfree(keys);
return 1;
}
}
return 0;
} }
static int tcf_pedit(struct sk_buff *skb, const struct tc_action *a, static int tcf_pedit(struct sk_buff *skb, const struct tc_action *a,
...@@ -230,7 +216,6 @@ static int tcf_pedit_dump(struct sk_buff *skb, struct tc_action *a, ...@@ -230,7 +216,6 @@ static int tcf_pedit_dump(struct sk_buff *skb, struct tc_action *a,
static struct tc_action_ops act_pedit_ops = { static struct tc_action_ops act_pedit_ops = {
.kind = "pedit", .kind = "pedit",
.hinfo = &pedit_hash_info,
.type = TCA_ACT_PEDIT, .type = TCA_ACT_PEDIT,
.owner = THIS_MODULE, .owner = THIS_MODULE,
.act = tcf_pedit, .act = tcf_pedit,
...@@ -245,15 +230,11 @@ MODULE_LICENSE("GPL"); ...@@ -245,15 +230,11 @@ MODULE_LICENSE("GPL");
static int __init pedit_init_module(void) static int __init pedit_init_module(void)
{ {
int err = tcf_hashinfo_init(&pedit_hash_info, PEDIT_TAB_MASK); return tcf_register_action(&act_pedit_ops, PEDIT_TAB_MASK);
if (err)
return err;
return tcf_register_action(&act_pedit_ops);
} }
static void __exit pedit_cleanup_module(void) static void __exit pedit_cleanup_module(void)
{ {
tcf_hashinfo_destroy(&pedit_hash_info);
tcf_unregister_action(&act_pedit_ops); tcf_unregister_action(&act_pedit_ops);
} }
......
...@@ -41,7 +41,6 @@ struct tcf_police { ...@@ -41,7 +41,6 @@ struct tcf_police {
container_of(pc, struct tcf_police, common) container_of(pc, struct tcf_police, common)
#define POL_TAB_MASK 15 #define POL_TAB_MASK 15
static struct tcf_hashinfo police_hash_info;
/* old policer structure from before tc actions */ /* old policer structure from before tc actions */
struct tc_police_compat { struct tc_police_compat {
...@@ -234,7 +233,7 @@ static int tcf_act_police_locate(struct net *net, struct nlattr *nla, ...@@ -234,7 +233,7 @@ static int tcf_act_police_locate(struct net *net, struct nlattr *nla,
police->tcfp_t_c = ktime_to_ns(ktime_get()); police->tcfp_t_c = ktime_to_ns(ktime_get());
police->tcf_index = parm->index ? parm->index : police->tcf_index = parm->index ? parm->index :
tcf_hash_new_index(a->ops->hinfo); tcf_hash_new_index(hinfo);
h = tcf_hash(police->tcf_index, POL_TAB_MASK); h = tcf_hash(police->tcf_index, POL_TAB_MASK);
spin_lock_bh(&hinfo->lock); spin_lock_bh(&hinfo->lock);
hlist_add_head(&police->tcf_head, &hinfo->htab[h]); hlist_add_head(&police->tcf_head, &hinfo->htab[h]);
...@@ -253,14 +252,6 @@ static int tcf_act_police_locate(struct net *net, struct nlattr *nla, ...@@ -253,14 +252,6 @@ static int tcf_act_police_locate(struct net *net, struct nlattr *nla,
return err; return err;
} }
static int tcf_act_police_cleanup(struct tc_action *a, int bind)
{
struct tcf_police *p = a->priv;
if (p)
return tcf_hash_release(&p->common, bind, &police_hash_info);
return 0;
}
static int tcf_act_police(struct sk_buff *skb, const struct tc_action *a, static int tcf_act_police(struct sk_buff *skb, const struct tc_action *a,
struct tcf_result *res) struct tcf_result *res)
{ {
...@@ -357,12 +348,10 @@ MODULE_LICENSE("GPL"); ...@@ -357,12 +348,10 @@ MODULE_LICENSE("GPL");
static struct tc_action_ops act_police_ops = { static struct tc_action_ops act_police_ops = {
.kind = "police", .kind = "police",
.hinfo = &police_hash_info,
.type = TCA_ID_POLICE, .type = TCA_ID_POLICE,
.owner = THIS_MODULE, .owner = THIS_MODULE,
.act = tcf_act_police, .act = tcf_act_police,
.dump = tcf_act_police_dump, .dump = tcf_act_police_dump,
.cleanup = tcf_act_police_cleanup,
.init = tcf_act_police_locate, .init = tcf_act_police_locate,
.walk = tcf_act_police_walker .walk = tcf_act_police_walker
}; };
...@@ -370,19 +359,12 @@ static struct tc_action_ops act_police_ops = { ...@@ -370,19 +359,12 @@ static struct tc_action_ops act_police_ops = {
static int __init static int __init
police_init_module(void) police_init_module(void)
{ {
int err = tcf_hashinfo_init(&police_hash_info, POL_TAB_MASK); return tcf_register_action(&act_police_ops, POL_TAB_MASK);
if (err)
return err;
err = tcf_register_action(&act_police_ops);
if (err)
tcf_hashinfo_destroy(&police_hash_info);
return err;
} }
static void __exit static void __exit
police_cleanup_module(void) police_cleanup_module(void)
{ {
tcf_hashinfo_destroy(&police_hash_info);
tcf_unregister_action(&act_police_ops); tcf_unregister_action(&act_police_ops);
} }
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
#include <net/tc_act/tc_defact.h> #include <net/tc_act/tc_defact.h>
#define SIMP_TAB_MASK 7 #define SIMP_TAB_MASK 7
static struct tcf_hashinfo simp_hash_info;
#define SIMP_MAX_DATA 32 #define SIMP_MAX_DATA 32
static int tcf_simp(struct sk_buff *skb, const struct tc_action *a, static int tcf_simp(struct sk_buff *skb, const struct tc_action *a,
...@@ -47,20 +46,10 @@ static int tcf_simp(struct sk_buff *skb, const struct tc_action *a, ...@@ -47,20 +46,10 @@ static int tcf_simp(struct sk_buff *skb, const struct tc_action *a,
return d->tcf_action; return d->tcf_action;
} }
static int tcf_simp_release(struct tcf_defact *d, int bind) static void tcf_simp_release(struct tc_action *a, int bind)
{ {
int ret = 0; struct tcf_defact *d = to_defact(a);
if (d) {
if (bind)
d->tcf_bindcnt--;
d->tcf_refcnt--;
if (d->tcf_bindcnt <= 0 && d->tcf_refcnt <= 0) {
kfree(d->tcfd_defdata); kfree(d->tcfd_defdata);
tcf_hash_destroy(&d->common, &simp_hash_info);
ret = 1;
}
}
return ret;
} }
static int alloc_defdata(struct tcf_defact *d, char *defdata) static int alloc_defdata(struct tcf_defact *d, char *defdata)
...@@ -94,7 +83,6 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla, ...@@ -94,7 +83,6 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla,
struct nlattr *tb[TCA_DEF_MAX + 1]; struct nlattr *tb[TCA_DEF_MAX + 1];
struct tc_defact *parm; struct tc_defact *parm;
struct tcf_defact *d; struct tcf_defact *d;
struct tcf_common *pc;
char *defdata; char *defdata;
int ret = 0, err; int ret = 0, err;
...@@ -114,29 +102,25 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla, ...@@ -114,29 +102,25 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla,
parm = nla_data(tb[TCA_DEF_PARMS]); parm = nla_data(tb[TCA_DEF_PARMS]);
defdata = nla_data(tb[TCA_DEF_DATA]); defdata = nla_data(tb[TCA_DEF_DATA]);
pc = tcf_hash_check(parm->index, a, bind); if (!tcf_hash_check(parm->index, a, bind)) {
if (!pc) { ret = tcf_hash_create(parm->index, est, a, sizeof(*d), bind);
pc = tcf_hash_create(parm->index, est, a, sizeof(*d), bind); if (ret)
if (IS_ERR(pc)) return ret;
return PTR_ERR(pc);
d = to_defact(pc); d = to_defact(a);
ret = alloc_defdata(d, defdata); ret = alloc_defdata(d, defdata);
if (ret < 0) { if (ret < 0) {
if (est) tcf_hash_cleanup(a, est);
gen_kill_estimator(&pc->tcfc_bstats,
&pc->tcfc_rate_est);
kfree_rcu(pc, tcfc_rcu);
return ret; return ret;
} }
d->tcf_action = parm->action; d->tcf_action = parm->action;
ret = ACT_P_CREATED; ret = ACT_P_CREATED;
} else { } else {
d = to_defact(pc); d = to_defact(a);
if (bind) if (bind)
return 0; return 0;
tcf_simp_release(d, bind); tcf_hash_release(a, bind);
if (!ovr) if (!ovr)
return -EEXIST; return -EEXIST;
...@@ -144,19 +128,10 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla, ...@@ -144,19 +128,10 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla,
} }
if (ret == ACT_P_CREATED) if (ret == ACT_P_CREATED)
tcf_hash_insert(pc, a->ops->hinfo); tcf_hash_insert(a);
return ret; return ret;
} }
static int tcf_simp_cleanup(struct tc_action *a, int bind)
{
struct tcf_defact *d = a->priv;
if (d)
return tcf_simp_release(d, bind);
return 0;
}
static int tcf_simp_dump(struct sk_buff *skb, struct tc_action *a, static int tcf_simp_dump(struct sk_buff *skb, struct tc_action *a,
int bind, int ref) int bind, int ref)
{ {
...@@ -187,12 +162,11 @@ static int tcf_simp_dump(struct sk_buff *skb, struct tc_action *a, ...@@ -187,12 +162,11 @@ static int tcf_simp_dump(struct sk_buff *skb, struct tc_action *a,
static struct tc_action_ops act_simp_ops = { static struct tc_action_ops act_simp_ops = {
.kind = "simple", .kind = "simple",
.hinfo = &simp_hash_info,
.type = TCA_ACT_SIMP, .type = TCA_ACT_SIMP,
.owner = THIS_MODULE, .owner = THIS_MODULE,
.act = tcf_simp, .act = tcf_simp,
.dump = tcf_simp_dump, .dump = tcf_simp_dump,
.cleanup = tcf_simp_cleanup, .cleanup = tcf_simp_release,
.init = tcf_simp_init, .init = tcf_simp_init,
}; };
...@@ -202,23 +176,15 @@ MODULE_LICENSE("GPL"); ...@@ -202,23 +176,15 @@ MODULE_LICENSE("GPL");
static int __init simp_init_module(void) static int __init simp_init_module(void)
{ {
int err, ret; int ret;
err = tcf_hashinfo_init(&simp_hash_info, SIMP_TAB_MASK); ret = tcf_register_action(&act_simp_ops, SIMP_TAB_MASK);
if (err)
return err;
ret = tcf_register_action(&act_simp_ops);
if (!ret) if (!ret)
pr_info("Simple TC action Loaded\n"); pr_info("Simple TC action Loaded\n");
else
tcf_hashinfo_destroy(&simp_hash_info);
return ret; return ret;
} }
static void __exit simp_cleanup_module(void) static void __exit simp_cleanup_module(void)
{ {
tcf_hashinfo_destroy(&simp_hash_info);
tcf_unregister_action(&act_simp_ops); tcf_unregister_action(&act_simp_ops);
} }
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include <net/tc_act/tc_skbedit.h> #include <net/tc_act/tc_skbedit.h>
#define SKBEDIT_TAB_MASK 15 #define SKBEDIT_TAB_MASK 15
static struct tcf_hashinfo skbedit_hash_info;
static int tcf_skbedit(struct sk_buff *skb, const struct tc_action *a, static int tcf_skbedit(struct sk_buff *skb, const struct tc_action *a,
struct tcf_result *res) struct tcf_result *res)
...@@ -65,7 +64,6 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla, ...@@ -65,7 +64,6 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla,
struct nlattr *tb[TCA_SKBEDIT_MAX + 1]; struct nlattr *tb[TCA_SKBEDIT_MAX + 1];
struct tc_skbedit *parm; struct tc_skbedit *parm;
struct tcf_skbedit *d; struct tcf_skbedit *d;
struct tcf_common *pc;
u32 flags = 0, *priority = NULL, *mark = NULL; u32 flags = 0, *priority = NULL, *mark = NULL;
u16 *queue_mapping = NULL; u16 *queue_mapping = NULL;
int ret = 0, err; int ret = 0, err;
...@@ -100,19 +98,18 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla, ...@@ -100,19 +98,18 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla,
parm = nla_data(tb[TCA_SKBEDIT_PARMS]); parm = nla_data(tb[TCA_SKBEDIT_PARMS]);
pc = tcf_hash_check(parm->index, a, bind); if (!tcf_hash_check(parm->index, a, bind)) {
if (!pc) { ret = tcf_hash_create(parm->index, est, a, sizeof(*d), bind);
pc = tcf_hash_create(parm->index, est, a, sizeof(*d), bind); if (ret)
if (IS_ERR(pc)) return ret;
return PTR_ERR(pc);
d = to_skbedit(pc); d = to_skbedit(a);
ret = ACT_P_CREATED; ret = ACT_P_CREATED;
} else { } else {
d = to_skbedit(pc); d = to_skbedit(a);
if (bind) if (bind)
return 0; return 0;
tcf_hash_release(pc, bind, a->ops->hinfo); tcf_hash_release(a, bind);
if (!ovr) if (!ovr)
return -EEXIST; return -EEXIST;
} }
...@@ -132,19 +129,10 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla, ...@@ -132,19 +129,10 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla,
spin_unlock_bh(&d->tcf_lock); spin_unlock_bh(&d->tcf_lock);
if (ret == ACT_P_CREATED) if (ret == ACT_P_CREATED)
tcf_hash_insert(pc, a->ops->hinfo); tcf_hash_insert(a);
return ret; return ret;
} }
static int tcf_skbedit_cleanup(struct tc_action *a, int bind)
{
struct tcf_skbedit *d = a->priv;
if (d)
return tcf_hash_release(&d->common, bind, &skbedit_hash_info);
return 0;
}
static int tcf_skbedit_dump(struct sk_buff *skb, struct tc_action *a, static int tcf_skbedit_dump(struct sk_buff *skb, struct tc_action *a,
int bind, int ref) int bind, int ref)
{ {
...@@ -186,12 +174,10 @@ static int tcf_skbedit_dump(struct sk_buff *skb, struct tc_action *a, ...@@ -186,12 +174,10 @@ static int tcf_skbedit_dump(struct sk_buff *skb, struct tc_action *a,
static struct tc_action_ops act_skbedit_ops = { static struct tc_action_ops act_skbedit_ops = {
.kind = "skbedit", .kind = "skbedit",
.hinfo = &skbedit_hash_info,
.type = TCA_ACT_SKBEDIT, .type = TCA_ACT_SKBEDIT,
.owner = THIS_MODULE, .owner = THIS_MODULE,
.act = tcf_skbedit, .act = tcf_skbedit,
.dump = tcf_skbedit_dump, .dump = tcf_skbedit_dump,
.cleanup = tcf_skbedit_cleanup,
.init = tcf_skbedit_init, .init = tcf_skbedit_init,
}; };
...@@ -201,15 +187,11 @@ MODULE_LICENSE("GPL"); ...@@ -201,15 +187,11 @@ MODULE_LICENSE("GPL");
static int __init skbedit_init_module(void) static int __init skbedit_init_module(void)
{ {
int err = tcf_hashinfo_init(&skbedit_hash_info, SKBEDIT_TAB_MASK); return tcf_register_action(&act_skbedit_ops, SKBEDIT_TAB_MASK);
if (err)
return err;
return tcf_register_action(&act_skbedit_ops);
} }
static void __exit skbedit_cleanup_module(void) static void __exit skbedit_cleanup_module(void)
{ {
tcf_hashinfo_destroy(&skbedit_hash_info);
tcf_unregister_action(&act_skbedit_ops); tcf_unregister_action(&act_skbedit_ops);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment