提交 36272874 编写于 作者: W WANG Cong 提交者: David S. Miller

net_sched: convert tcf_proto_ops to use struct list_head

We don't need to maintain our own singly linked list code.

Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: NCong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: NJamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 1f747c26
...@@ -185,7 +185,7 @@ struct tcf_result { ...@@ -185,7 +185,7 @@ struct tcf_result {
}; };
struct tcf_proto_ops { struct tcf_proto_ops {
struct tcf_proto_ops *next; struct list_head head;
char kind[IFNAMSIZ]; char kind[IFNAMSIZ];
int (*classify)(struct sk_buff *, int (*classify)(struct sk_buff *,
......
...@@ -31,8 +31,7 @@ ...@@ -31,8 +31,7 @@
#include <net/pkt_cls.h> #include <net/pkt_cls.h>
/* The list of all installed classifier types */ /* The list of all installed classifier types */
static LIST_HEAD(tcf_proto_base);
static struct tcf_proto_ops *tcf_proto_base __read_mostly;
/* Protects list of registered TC modules. It is pure SMP lock. */ /* Protects list of registered TC modules. It is pure SMP lock. */
static DEFINE_RWLOCK(cls_mod_lock); static DEFINE_RWLOCK(cls_mod_lock);
...@@ -45,7 +44,7 @@ static const struct tcf_proto_ops *tcf_proto_lookup_ops(struct nlattr *kind) ...@@ -45,7 +44,7 @@ static const struct tcf_proto_ops *tcf_proto_lookup_ops(struct nlattr *kind)
if (kind) { if (kind) {
read_lock(&cls_mod_lock); read_lock(&cls_mod_lock);
for (t = tcf_proto_base; t; t = t->next) { list_for_each_entry(t, &tcf_proto_base, head) {
if (nla_strcmp(kind, t->kind) == 0) { if (nla_strcmp(kind, t->kind) == 0) {
if (!try_module_get(t->owner)) if (!try_module_get(t->owner))
t = NULL; t = NULL;
...@@ -61,16 +60,15 @@ static const struct tcf_proto_ops *tcf_proto_lookup_ops(struct nlattr *kind) ...@@ -61,16 +60,15 @@ static const struct tcf_proto_ops *tcf_proto_lookup_ops(struct nlattr *kind)
int register_tcf_proto_ops(struct tcf_proto_ops *ops) int register_tcf_proto_ops(struct tcf_proto_ops *ops)
{ {
struct tcf_proto_ops *t, **tp; struct tcf_proto_ops *t;
int rc = -EEXIST; int rc = -EEXIST;
write_lock(&cls_mod_lock); write_lock(&cls_mod_lock);
for (tp = &tcf_proto_base; (t = *tp) != NULL; tp = &t->next) list_for_each_entry(t, &tcf_proto_base, head)
if (!strcmp(ops->kind, t->kind)) if (!strcmp(ops->kind, t->kind))
goto out; goto out;
ops->next = NULL; list_add_tail(&ops->head, &tcf_proto_base);
*tp = ops;
rc = 0; rc = 0;
out: out:
write_unlock(&cls_mod_lock); write_unlock(&cls_mod_lock);
...@@ -80,17 +78,17 @@ EXPORT_SYMBOL(register_tcf_proto_ops); ...@@ -80,17 +78,17 @@ EXPORT_SYMBOL(register_tcf_proto_ops);
int unregister_tcf_proto_ops(struct tcf_proto_ops *ops) int unregister_tcf_proto_ops(struct tcf_proto_ops *ops)
{ {
struct tcf_proto_ops *t, **tp; struct tcf_proto_ops *t;
int rc = -ENOENT; int rc = -ENOENT;
write_lock(&cls_mod_lock); write_lock(&cls_mod_lock);
for (tp = &tcf_proto_base; (t = *tp) != NULL; tp = &t->next) list_for_each_entry(t, &tcf_proto_base, head)
if (t == ops) if (t == ops)
break; break;
if (!t) if (!t)
goto out; goto out;
*tp = t->next; list_del(&t->head);
rc = 0; rc = 0;
out: out:
write_unlock(&cls_mod_lock); write_unlock(&cls_mod_lock);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册