o net/sched: some trivial code cleanups, making some code smaller

Smaller by not calling write_unlock two times.
parent aee01ebf
......@@ -65,37 +65,38 @@ struct tcf_proto_ops * tcf_proto_lookup_ops(struct rtattr *kind)
int register_tcf_proto_ops(struct tcf_proto_ops *ops)
{
struct tcf_proto_ops *t, **tp;
int rc = -EEXIST;
write_lock(&cls_mod_lock);
for (tp = &tcf_proto_base; (t=*tp) != NULL; tp = &t->next) {
if (strcmp(ops->kind, t->kind) == 0) {
write_unlock(&cls_mod_lock);
return -EEXIST;
}
}
for (tp = &tcf_proto_base; (t = *tp) != NULL; tp = &t->next)
if (!strcmp(ops->kind, t->kind))
goto out;
ops->next = NULL;
*tp = ops;
rc = 0;
out:
write_unlock(&cls_mod_lock);
return 0;
return rc;
}
int unregister_tcf_proto_ops(struct tcf_proto_ops *ops)
{
struct tcf_proto_ops *t, **tp;
int rc = -ENOENT;
write_lock(&cls_mod_lock);
for (tp = &tcf_proto_base; (t=*tp) != NULL; tp = &t->next)
if (t == ops)
break;
if (!t) {
write_unlock(&cls_mod_lock);
return -ENOENT;
}
if (!t)
goto out;
*tp = t->next;
rc = 0;
out:
write_unlock(&cls_mod_lock);
return 0;
return rc;
}
static int tfilter_notify(struct sk_buff *oskb, struct nlmsghdr *n,
......@@ -371,11 +372,8 @@ static int tc_dump_tfilter(struct sk_buff *skb, struct netlink_callback *cb)
q = dev->qdisc_sleeping;
else
q = qdisc_lookup(dev, TC_H_MAJ(tcm->tcm_parent));
if (q == NULL) {
read_unlock(&qdisc_tree_lock);
dev_put(dev);
return skb->len;
}
if (!q)
goto out;
if ((cops = q->ops->cl_ops) == NULL)
goto errout;
if (TC_H_MIN(tcm->tcm_parent)) {
......@@ -425,7 +423,7 @@ static int tc_dump_tfilter(struct sk_buff *skb, struct netlink_callback *cb)
errout:
if (cl)
cops->put(q, cl);
out:
read_unlock(&qdisc_tree_lock);
dev_put(dev);
return skb->len;
......
......@@ -152,7 +152,7 @@ static int fw_delete(struct tcf_proto *tp, unsigned long arg)
struct fw_filter **fp;
if (head == NULL || f == NULL)
return -EINVAL;
goto out;
for (fp=&head->ht[fw_hash(f->id)]; *fp; fp = &(*fp)->next) {
if (*fp == f) {
......@@ -171,6 +171,7 @@ static int fw_delete(struct tcf_proto *tp, unsigned long arg)
return 0;
}
}
out:
return -EINVAL;
}
......
......@@ -203,17 +203,17 @@ static __inline__ struct tc_u_knode *
u32_lookup_key(struct tc_u_hnode *ht, u32 handle)
{
unsigned sel;
struct tc_u_knode *n;
struct tc_u_knode *n = NULL;
sel = TC_U32_HASH(handle);
if (sel > ht->divisor)
return 0;
goto out;
for (n = ht->ht[sel]; n; n = n->next)
if (n->handle == handle)
return n;
return NULL;
break;
out:
return n;
}
......
......@@ -139,21 +139,19 @@ static rwlock_t qdisc_mod_lock = RW_LOCK_UNLOCKED;
/* The list of all installed queueing disciplines. */
static struct Qdisc_ops *qdisc_base = NULL;
static struct Qdisc_ops *qdisc_base;
/* Register/uregister queueing discipline */
int register_qdisc(struct Qdisc_ops *qops)
{
struct Qdisc_ops *q, **qp;
int rc = -EEXIST;
write_lock(&qdisc_mod_lock);
for (qp = &qdisc_base; (q=*qp)!=NULL; qp = &q->next) {
if (strcmp(qops->id, q->id) == 0) {
write_unlock(&qdisc_mod_lock);
return -EEXIST;
}
}
for (qp = &qdisc_base; (q = *qp) != NULL; qp = &q->next)
if (!strcmp(qops->id, q->id))
goto out;
if (qops->enqueue == NULL)
qops->enqueue = noop_qdisc_ops.enqueue;
......@@ -164,8 +162,10 @@ int register_qdisc(struct Qdisc_ops *qops)
qops->next = NULL;
*qp = qops;
rc = 0;
out:
write_unlock(&qdisc_mod_lock);
return 0;
return rc;
}
int unregister_qdisc(struct Qdisc_ops *qops)
......
......@@ -45,7 +45,7 @@
/* Thanks to Doron Oz for this hack
*/
static int nf_registered = 0;
static int nf_registered;
struct ingress_qdisc_data {
struct Qdisc *q;
......@@ -237,15 +237,13 @@ used on the egress (might slow things for an iota)
}
/* after ipt_filter */
static struct nf_hook_ops ing_ops =
{
{ NULL, NULL},
ing_hook,
THIS_MODULE,
PF_INET,
NF_IP_PRE_ROUTING,
NF_IP_PRI_FILTER + 1
};
static struct nf_hook_ops ing_ops = {
.hook = ing_hook,
.owner = THIS_MODULE,
.pf = PF_INET,
.hooknum = NF_IP_PRE_ROUTING,
.priority = NF_IP_PRI_FILTER + 1,
}
int ingress_init(struct Qdisc *sch,struct rtattr *opt)
{
......@@ -255,7 +253,7 @@ int ingress_init(struct Qdisc *sch,struct rtattr *opt)
if (nf_register_hook(&ing_ops) < 0) {
printk("ingress qdisc registration error \n");
goto error;
}
}
nf_registered++;
}
......
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