Commit a4c84476 authored by Alexander Viro's avatar Alexander Viro Committed by David S. Miller

[PKT_SCHED]: Convert to {subsys,module}_initcall(), fix init failure bugs in sch_teql.c

pktsched_init() and tc_filter_init() converted to subsys_initcall().
initialization of individual qdisc and tcf_proto switched to
module_init().  Some of them used to be registered twice if built-in, BTW.
init failure handling in sch_teql.c fixed - it used to leave objects
(both qdisc and netdev) registered if insmod failed.
parent 144abfc2
......@@ -440,9 +440,6 @@ int qdisc_new_estimator(struct tc_stats *stats, struct rtattr *opt);
void qdisc_kill_estimator(struct tc_stats *stats);
struct qdisc_rate_table *qdisc_get_rtab(struct tc_ratespec *r, struct rtattr *tab);
void qdisc_put_rtab(struct qdisc_rate_table *tab);
int teql_init(void);
int tc_filter_init(void);
int pktsched_init(void);
extern int qdisc_restart(struct net_device *dev);
......
......@@ -3217,10 +3217,6 @@ static int __init net_dev_init(void)
dst_init();
dev_mcast_init();
#ifdef CONFIG_NET_SCHED
pktsched_init();
#endif
rc = 0;
out:
return rc;
......
......@@ -8,23 +8,23 @@ obj-$(CONFIG_NET_SCHED) += sch_api.o sch_fifo.o
obj-$(CONFIG_NET_ESTIMATOR) += estimator.o
obj-$(CONFIG_NET_CLS) += cls_api.o
obj-$(CONFIG_NET_CLS_POLICE) += police.o
obj-$(CONFIG_NET_SCH_INGRESS) += sch_ingress.o
obj-$(CONFIG_NET_SCH_CBQ) += sch_cbq.o
obj-$(CONFIG_NET_SCH_HTB) += sch_htb.o
obj-$(CONFIG_NET_SCH_CSZ) += sch_csz.o
obj-$(CONFIG_NET_SCH_HPFQ) += sch_hpfq.o
obj-$(CONFIG_NET_SCH_HFSC) += sch_hfsc.o
obj-$(CONFIG_NET_SCH_HTB) += sch_htb.o
obj-$(CONFIG_NET_SCH_SFQ) += sch_sfq.o
obj-$(CONFIG_NET_SCH_RED) += sch_red.o
obj-$(CONFIG_NET_SCH_TBF) += sch_tbf.o
obj-$(CONFIG_NET_SCH_PRIO) += sch_prio.o
obj-$(CONFIG_NET_SCH_TEQL) += sch_teql.o
obj-$(CONFIG_NET_SCH_GRED) += sch_gred.o
obj-$(CONFIG_NET_SCH_INGRESS) += sch_ingress.o
obj-$(CONFIG_NET_SCH_DSMARK) += sch_dsmark.o
obj-$(CONFIG_NET_CLS_TCINDEX) += cls_tcindex.o
obj-$(CONFIG_NET_SCH_SFQ) += sch_sfq.o
obj-$(CONFIG_NET_SCH_TBF) += sch_tbf.o
obj-$(CONFIG_NET_SCH_TEQL) += sch_teql.o
obj-$(CONFIG_NET_SCH_PRIO) += sch_prio.o
obj-$(CONFIG_NET_SCH_ATM) += sch_atm.o
obj-$(CONFIG_NET_CLS_U32) += cls_u32.o
obj-$(CONFIG_NET_CLS_RSVP) += cls_rsvp.o
obj-$(CONFIG_NET_CLS_RSVP6) += cls_rsvp6.o
obj-$(CONFIG_NET_CLS_ROUTE4) += cls_route.o
obj-$(CONFIG_NET_CLS_FW) += cls_fw.o
obj-$(CONFIG_NET_CLS_RSVP) += cls_rsvp.o
obj-$(CONFIG_NET_CLS_TCINDEX) += cls_tcindex.o
obj-$(CONFIG_NET_CLS_RSVP6) += cls_rsvp6.o
......@@ -425,7 +425,7 @@ static int tc_dump_tfilter(struct sk_buff *skb, struct netlink_callback *cb)
}
int __init tc_filter_init(void)
static int __init tc_filter_init(void)
{
struct rtnetlink_link *link_p = rtnetlink_links[PF_UNSPEC];
......@@ -439,31 +439,10 @@ int __init tc_filter_init(void)
link_p[RTM_GETTFILTER-RTM_BASE].doit = tc_ctl_tfilter;
link_p[RTM_GETTFILTER-RTM_BASE].dumpit = tc_dump_tfilter;
}
#define INIT_TC_FILTER(name) { \
extern struct tcf_proto_ops cls_##name##_ops; \
register_tcf_proto_ops(&cls_##name##_ops); \
}
#ifdef CONFIG_NET_CLS_U32
INIT_TC_FILTER(u32);
#endif
#ifdef CONFIG_NET_CLS_ROUTE4
INIT_TC_FILTER(route4);
#endif
#ifdef CONFIG_NET_CLS_FW
INIT_TC_FILTER(fw);
#endif
#ifdef CONFIG_NET_CLS_RSVP
INIT_TC_FILTER(rsvp);
#endif
#ifdef CONFIG_NET_CLS_TCINDEX
INIT_TC_FILTER(tcindex);
#endif
#ifdef CONFIG_NET_CLS_RSVP6
INIT_TC_FILTER(rsvp6);
#endif
return 0;
}
subsys_initcall(tc_filter_init);
EXPORT_SYMBOL(register_tcf_proto_ops);
EXPORT_SYMBOL(unregister_tcf_proto_ops);
......@@ -347,7 +347,7 @@ static int fw_dump(struct tcf_proto *tp, unsigned long fh,
return -1;
}
struct tcf_proto_ops cls_fw_ops = {
static struct tcf_proto_ops cls_fw_ops = {
.next = NULL,
.kind = "fw",
.classify = fw_classify,
......@@ -362,15 +362,16 @@ struct tcf_proto_ops cls_fw_ops = {
.owner = THIS_MODULE,
};
#ifdef MODULE
int init_module(void)
static int __init init_fw(void)
{
return register_tcf_proto_ops(&cls_fw_ops);
}
void cleanup_module(void)
static void __exit exit_fw(void)
{
unregister_tcf_proto_ops(&cls_fw_ops);
}
#endif
module_init(init_fw)
module_exit(exit_fw)
MODULE_LICENSE("GPL");
......@@ -602,7 +602,7 @@ static int route4_dump(struct tcf_proto *tp, unsigned long fh,
return -1;
}
struct tcf_proto_ops cls_route4_ops = {
static struct tcf_proto_ops cls_route4_ops = {
.next = NULL,
.kind = "route",
.classify = route4_classify,
......@@ -617,15 +617,16 @@ struct tcf_proto_ops cls_route4_ops = {
.owner = THIS_MODULE,
};
#ifdef MODULE
int init_module(void)
static int __init init_route4(void)
{
return register_tcf_proto_ops(&cls_route4_ops);
}
void cleanup_module(void)
static void __exit exit_route4(void)
{
unregister_tcf_proto_ops(&cls_route4_ops);
}
#endif
module_init(init_route4)
module_exit(exit_route4)
MODULE_LICENSE("GPL");
......@@ -667,7 +667,7 @@ static int rsvp_dump(struct tcf_proto *tp, unsigned long fh,
return -1;
}
struct tcf_proto_ops RSVP_OPS = {
static struct tcf_proto_ops RSVP_OPS = {
.next = NULL,
.kind = RSVP_ID,
.classify = rsvp_classify,
......@@ -682,14 +682,15 @@ struct tcf_proto_ops RSVP_OPS = {
.owner = THIS_MODULE,
};
#ifdef MODULE
int init_module(void)
static int __init init_rsvp(void)
{
return register_tcf_proto_ops(&RSVP_OPS);
}
void cleanup_module(void)
static void __exit exit_rsvp(void)
{
unregister_tcf_proto_ops(&RSVP_OPS);
}
#endif
module_init(init_rsvp)
module_exit(exit_rsvp)
......@@ -476,7 +476,7 @@ static int tcindex_dump(struct tcf_proto *tp, unsigned long fh,
return -1;
}
struct tcf_proto_ops cls_tcindex_ops = {
static struct tcf_proto_ops cls_tcindex_ops = {
.next = NULL,
.kind = "tcindex",
.classify = tcindex_classify,
......@@ -491,16 +491,16 @@ struct tcf_proto_ops cls_tcindex_ops = {
.owner = THIS_MODULE,
};
#ifdef MODULE
int init_module(void)
static int __init init_tcindex(void)
{
return register_tcf_proto_ops(&cls_tcindex_ops);
}
void cleanup_module(void)
static void __exit exit_tcindex(void)
{
unregister_tcf_proto_ops(&cls_tcindex_ops);
}
#endif
module_init(init_tcindex)
module_exit(exit_tcindex)
MODULE_LICENSE("GPL");
......@@ -684,7 +684,7 @@ static int u32_dump(struct tcf_proto *tp, unsigned long fh,
return -1;
}
struct tcf_proto_ops cls_u32_ops = {
static struct tcf_proto_ops cls_u32_ops = {
.next = NULL,
.kind = "u32",
.classify = u32_classify,
......@@ -699,15 +699,16 @@ struct tcf_proto_ops cls_u32_ops = {
.owner = THIS_MODULE,
};
#ifdef MODULE
int init_module(void)
static int __init init_u32(void)
{
return register_tcf_proto_ops(&cls_u32_ops);
}
void cleanup_module(void)
static void __exit exit_u32(void)
{
unregister_tcf_proto_ops(&cls_u32_ops);
}
#endif
module_init(init_u32)
module_exit(exit_u32)
MODULE_LICENSE("GPL");
......@@ -1165,7 +1165,7 @@ int __init psched_calibrate_clock(void)
}
#endif
int __init pktsched_init(void)
static int __init pktsched_init(void)
{
struct rtnetlink_link *link_p;
......@@ -1197,65 +1197,15 @@ int __init pktsched_init(void)
link_p[RTM_GETTCLASS-RTM_BASE].dumpit = tc_dump_tclass;
}
#define INIT_QDISC(name) { \
extern struct Qdisc_ops name##_qdisc_ops; \
register_qdisc(& name##_qdisc_ops); \
}
INIT_QDISC(pfifo);
INIT_QDISC(bfifo);
#ifdef CONFIG_NET_SCH_CBQ
INIT_QDISC(cbq);
#endif
#ifdef CONFIG_NET_SCH_HTB
INIT_QDISC(htb);
#endif
#ifdef CONFIG_NET_SCH_CSZ
INIT_QDISC(csz);
#endif
#ifdef CONFIG_NET_SCH_HPFQ
INIT_QDISC(hpfq);
#endif
#ifdef CONFIG_NET_SCH_HFSC
INIT_QDISC(hfsc);
#endif
#ifdef CONFIG_NET_SCH_RED
INIT_QDISC(red);
#endif
#ifdef CONFIG_NET_SCH_GRED
INIT_QDISC(gred);
#endif
#ifdef CONFIG_NET_SCH_INGRESS
INIT_QDISC(ingress);
#endif
#ifdef CONFIG_NET_SCH_DSMARK
INIT_QDISC(dsmark);
#endif
#ifdef CONFIG_NET_SCH_SFQ
INIT_QDISC(sfq);
#endif
#ifdef CONFIG_NET_SCH_TBF
INIT_QDISC(tbf);
#endif
#ifdef CONFIG_NET_SCH_TEQL
teql_init();
#endif
#ifdef CONFIG_NET_SCH_PRIO
INIT_QDISC(prio);
#endif
#ifdef CONFIG_NET_SCH_ATM
INIT_QDISC(atm);
#endif
#ifdef CONFIG_NET_CLS
tc_filter_init();
#endif
register_qdisc(&pfifo_qdisc_ops);
register_qdisc(&bfifo_qdisc_ops);
proc_net_fops_create("psched", 0, &psched_fops);
return 0;
}
subsys_initcall(pktsched_init);
EXPORT_SYMBOL(qdisc_copy_stats);
EXPORT_SYMBOL(qdisc_get_rtab);
EXPORT_SYMBOL(qdisc_put_rtab);
......
......@@ -682,7 +682,7 @@ static struct Qdisc_class_ops atm_class_ops = {
.dump = atm_tc_dump_class,
};
struct Qdisc_ops atm_qdisc_ops = {
static struct Qdisc_ops atm_qdisc_ops = {
.next = NULL,
.cl_ops = &atm_class_ops,
.id = "atm",
......@@ -700,15 +700,15 @@ struct Qdisc_ops atm_qdisc_ops = {
};
#ifdef MODULE
int init_module(void)
static int __init atm_init(void)
{
return register_qdisc(&atm_qdisc_ops);
}
void cleanup_module(void)
static void __exit atm_exit(void)
{
unregister_qdisc(&atm_qdisc_ops);
}
#endif
module_init(atm_init)
module_exit(atm_exit)
......@@ -2074,7 +2074,7 @@ static struct Qdisc_class_ops cbq_class_ops = {
.dump = cbq_dump_class,
};
struct Qdisc_ops cbq_qdisc_ops = {
static struct Qdisc_ops cbq_qdisc_ops = {
.next = NULL,
.cl_ops = &cbq_class_ops,
.id = "cbq",
......@@ -2091,15 +2091,14 @@ struct Qdisc_ops cbq_qdisc_ops = {
.owner = THIS_MODULE,
};
#ifdef MODULE
int init_module(void)
static int __init cbq_module_init(void)
{
return register_qdisc(&cbq_qdisc_ops);
}
void cleanup_module(void)
static void __exit cbq_module_exit(void)
{
unregister_qdisc(&cbq_qdisc_ops);
}
#endif
module_init(cbq_module_init)
module_exit(cbq_module_exit)
MODULE_LICENSE("GPL");
......@@ -1027,7 +1027,7 @@ struct Qdisc_class_ops csz_class_ops = {
.dump = csz_dump_class,
};
struct Qdisc_ops csz_qdisc_ops = {
static struct Qdisc_ops csz_qdisc_ops = {
.next = NULL,
.cl_ops = &csz_class_ops,
.id = "csz",
......@@ -1044,16 +1044,14 @@ struct Qdisc_ops csz_qdisc_ops = {
.owner = THIS_MODULE,
};
#ifdef MODULE
int init_module(void)
static int __init csz_module_init(void)
{
return register_qdisc(&csz_qdisc_ops);
}
void cleanup_module(void)
static void __exit csz_module_exit(void)
{
unregister_qdisc(&csz_qdisc_ops);
}
#endif
module_init(csz_module_init)
module_exit(csz_module_exit)
MODULE_LICENSE("GPL");
......@@ -447,7 +447,7 @@ static struct Qdisc_class_ops dsmark_class_ops = {
.dump = dsmark_dump_class,
};
struct Qdisc_ops dsmark_qdisc_ops = {
static struct Qdisc_ops dsmark_qdisc_ops = {
.next = NULL,
.cl_ops = &dsmark_class_ops,
.id = "dsmark",
......@@ -464,16 +464,14 @@ struct Qdisc_ops dsmark_qdisc_ops = {
.owner = THIS_MODULE,
};
#ifdef MODULE
int init_module(void)
static int __init dsmark_module_init(void)
{
return register_qdisc(&dsmark_qdisc_ops);
}
void cleanup_module(void)
static void __exit dsmark_module_exit(void)
{
unregister_qdisc(&dsmark_qdisc_ops);
}
#endif
module_init(dsmark_module_init)
module_exit(dsmark_module_exit)
MODULE_LICENSE("GPL");
......@@ -602,7 +602,7 @@ static void gred_destroy(struct Qdisc *sch)
}
}
struct Qdisc_ops gred_qdisc_ops = {
static struct Qdisc_ops gred_qdisc_ops = {
.next = NULL,
.cl_ops = NULL,
.id = "gred",
......@@ -619,16 +619,14 @@ struct Qdisc_ops gred_qdisc_ops = {
.owner = THIS_MODULE,
};
#ifdef MODULE
int init_module(void)
static int __init gred_module_init(void)
{
return register_qdisc(&gred_qdisc_ops);
}
void cleanup_module(void)
static void __exit gred_module_exit(void)
{
unregister_qdisc(&gred_qdisc_ops);
}
#endif
module_init(gred_module_init)
module_exit(gred_module_exit)
MODULE_LICENSE("GPL");
......@@ -1831,7 +1831,7 @@ static struct Qdisc_class_ops hfsc_class_ops = {
.walk = hfsc_walk
};
struct Qdisc_ops hfsc_qdisc_ops = {
static struct Qdisc_ops hfsc_qdisc_ops = {
.id = "hfsc",
.init = hfsc_init_qdisc,
.change = hfsc_change_qdisc,
......
......@@ -1646,7 +1646,7 @@ static struct Qdisc_class_ops htb_class_ops = {
.dump = htb_dump_class,
};
struct Qdisc_ops htb_qdisc_ops = {
static struct Qdisc_ops htb_qdisc_ops = {
.next = NULL,
.cl_ops = &htb_class_ops,
.id = "htb",
......@@ -1663,15 +1663,14 @@ struct Qdisc_ops htb_qdisc_ops = {
.owner = THIS_MODULE,
};
#ifdef MODULE
int init_module(void)
static int __init htb_module_init(void)
{
return register_qdisc(&htb_qdisc_ops);
}
void cleanup_module(void)
static void __exit htb_module_exit(void)
{
unregister_qdisc(&htb_qdisc_ops);
}
module_init(htb_module_init)
module_exit(htb_module_exit)
MODULE_LICENSE("GPL");
#endif
......@@ -333,7 +333,7 @@ static struct Qdisc_class_ops ingress_class_ops = {
.dump = NULL,
};
struct Qdisc_ops ingress_qdisc_ops = {
static struct Qdisc_ops ingress_qdisc_ops = {
.next = NULL,
.cl_ops = &ingress_class_ops,
.id = "ingress",
......@@ -350,9 +350,7 @@ struct Qdisc_ops ingress_qdisc_ops = {
.owner = THIS_MODULE,
};
#ifdef MODULE
int init_module(void)
static int __init ingress_module_init(void)
{
int ret = 0;
......@@ -363,13 +361,12 @@ int init_module(void)
return ret;
}
void cleanup_module(void)
static void __exit ingress_module_exit(void)
{
unregister_qdisc(&ingress_qdisc_ops);
if (nf_registered)
nf_unregister_hook(&ing_ops);
}
#endif
module_init(ingress_module_init)
module_exit(ingress_module_exit)
MODULE_LICENSE("GPL");
......@@ -382,7 +382,7 @@ static struct Qdisc_class_ops prio_class_ops = {
.dump = prio_dump_class,
};
struct Qdisc_ops prio_qdisc_ops = {
static struct Qdisc_ops prio_qdisc_ops = {
.next = NULL,
.cl_ops = &prio_class_ops,
.id = "prio",
......@@ -399,17 +399,17 @@ struct Qdisc_ops prio_qdisc_ops = {
.owner = THIS_MODULE,
};
#ifdef MODULE
int init_module(void)
static int __init prio_module_init(void)
{
return register_qdisc(&prio_qdisc_ops);
}
void cleanup_module(void)
static void __exit prio_module_exit(void)
{
unregister_qdisc(&prio_qdisc_ops);
}
#endif
module_init(prio_module_init)
module_exit(prio_module_exit)
MODULE_LICENSE("GPL");
......@@ -453,7 +453,7 @@ static void red_destroy(struct Qdisc *sch)
{
}
struct Qdisc_ops red_qdisc_ops = {
static struct Qdisc_ops red_qdisc_ops = {
.next = NULL,
.cl_ops = NULL,
.id = "red",
......@@ -470,16 +470,14 @@ struct Qdisc_ops red_qdisc_ops = {
.owner = THIS_MODULE,
};
#ifdef MODULE
int init_module(void)
static int __init red_module_init(void)
{
return register_qdisc(&red_qdisc_ops);
}
void cleanup_module(void)
static void __exit red_module_exit(void)
{
unregister_qdisc(&red_qdisc_ops);
}
#endif
module_init(red_module_init)
module_exit(red_module_exit)
MODULE_LICENSE("GPL");
......@@ -466,7 +466,7 @@ static int sfq_dump(struct Qdisc *sch, struct sk_buff *skb)
return -1;
}
struct Qdisc_ops sfq_qdisc_ops = {
static struct Qdisc_ops sfq_qdisc_ops = {
.next = NULL,
.cl_ops = NULL,
.id = "sfq",
......@@ -483,15 +483,14 @@ struct Qdisc_ops sfq_qdisc_ops = {
.owner = THIS_MODULE,
};
#ifdef MODULE
int init_module(void)
static int __init sfq_module_init(void)
{
return register_qdisc(&sfq_qdisc_ops);
}
void cleanup_module(void)
static void __exit sfq_module_exit(void)
{
unregister_qdisc(&sfq_qdisc_ops);
}
#endif
module_init(sfq_module_init)
module_exit(sfq_module_exit)
MODULE_LICENSE("GPL");
......@@ -510,7 +510,7 @@ static struct Qdisc_class_ops tbf_class_ops =
.dump = tbf_dump_class,
};
struct Qdisc_ops tbf_qdisc_ops = {
static struct Qdisc_ops tbf_qdisc_ops = {
.next = NULL,
.cl_ops = &tbf_class_ops,
.id = "tbf",
......@@ -527,16 +527,15 @@ struct Qdisc_ops tbf_qdisc_ops = {
.owner = THIS_MODULE,
};
#ifdef MODULE
int init_module(void)
static int __init tbf_module_init(void)
{
return register_qdisc(&tbf_qdisc_ops);
}
void cleanup_module(void)
static void __exit tbf_module_exit(void)
{
unregister_qdisc(&tbf_qdisc_ops);
}
#endif
module_init(tbf_module_init)
module_exit(tbf_module_exit)
MODULE_LICENSE("GPL");
......@@ -418,14 +418,12 @@ static int teql_master_mtu(struct net_device *dev, int new_mtu)
return 0;
}
static __init int teql_master_init(struct net_device *dev)
static __init void teql_master_setup(struct net_device *dev)
{
struct teql_master *master = dev->priv;
struct Qdisc_ops *ops = &master->qops;
master->dev = dev;
strlcpy(ops->id, dev->name, IFNAMSIZ);
ops->priv_size = sizeof(struct teql_sched_data);
ops->enqueue = teql_enqueue;
......@@ -436,12 +434,6 @@ static __init int teql_master_init(struct net_device *dev)
ops->destroy = teql_destroy;
ops->owner = THIS_MODULE;
return register_qdisc(ops);
}
static __init void teql_master_setup(struct net_device *dev)
{
dev->init = teql_master_init;
dev->open = teql_master_open;
dev->hard_start_xmit = teql_master_xmit;
dev->stop = teql_master_close;
......@@ -460,10 +452,10 @@ static int max_equalizers = 1;
MODULE_PARM(max_equalizers, "i");
MODULE_PARM_DESC(max_equalizers, "Max number of link equalizers");
int __init teql_init(void)
static int __init teql_init(void)
{
int i;
int err = 0;
int err = -ENODEV;
for (i = 0; i < max_equalizers; i++) {
struct net_device *dev;
......@@ -471,19 +463,30 @@ int __init teql_init(void)
dev = alloc_netdev(sizeof(struct teql_master),
"teql%d", teql_master_setup);
if (!dev)
return -ENOMEM;
if (!dev) {
err = -ENOMEM;
break;
}
if ((err = register_netdev(dev))) {
free_netdev(dev);
goto out;
break;
}
master = dev->priv;
strlcpy(master->qops.id, dev->name, IFNAMSIZ);
err = register_qdisc(&master->qops);
if (err) {
unregister_netdev(dev);
free_netdev(dev);
break;
}
list_add_tail(&master->master_list, &master_dev_list);
}
out:
return err;
return i ? 0 : err;
}
static void __exit teql_exit(void)
......
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