aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/act_api.h
diff options
context:
space:
mode:
authorWANG Cong <xiyou.wangcong@gmail.com>2013-12-15 20:15:08 -0800
committerDavid S. Miller <davem@davemloft.net>2013-12-18 12:52:07 -0500
commit369ba56787d7469c0afda70bb9ff76ad5faaead5 (patch)
tree58425d3d564e3255c6660185bf22c80b76305ff5 /include/net/act_api.h
parentnet_sched: cls: refactor out struct tcf_ext_map (diff)
downloadlinux-dev-369ba56787d7469c0afda70bb9ff76ad5faaead5.tar.xz
linux-dev-369ba56787d7469c0afda70bb9ff76ad5faaead5.zip
net_sched: init struct tcf_hashinfo at register time
It looks weird to store the lock out of the struct but still points to a static variable. Just move them into the struct. Cc: Jamal Hadi Salim <jhs@mojatatu.com> Cc: David S. Miller <davem@davemloft.net> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/act_api.h')
-rw-r--r--include/net/act_api.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/include/net/act_api.h b/include/net/act_api.h
index a72642610790..2b5ec5abfeb3 100644
--- a/include/net/act_api.h
+++ b/include/net/act_api.h
@@ -38,7 +38,7 @@ struct tcf_common {
struct tcf_hashinfo {
struct tcf_common **htab;
unsigned int hmask;
- rwlock_t *lock;
+ rwlock_t lock;
};
static inline unsigned int tcf_hash(u32 index, unsigned int hmask)
@@ -46,6 +46,22 @@ static inline unsigned int tcf_hash(u32 index, unsigned int hmask)
return index & hmask;
}
+static inline int tcf_hashinfo_init(struct tcf_hashinfo *hf, unsigned int mask)
+{
+ rwlock_init(&hf->lock);
+ hf->hmask = mask;
+ hf->htab = kzalloc((mask + 1) * sizeof(struct tcf_common *),
+ GFP_KERNEL);
+ if (!hf->htab)
+ return -ENOMEM;
+ return 0;
+}
+
+static inline void tcf_hashinfo_destroy(struct tcf_hashinfo *hf)
+{
+ kfree(hf->htab);
+}
+
#ifdef CONFIG_NET_CLS_ACT
#define ACT_P_CREATED 1