]> Pileus Git - ~andy/linux/blobdiff - net/sched/sch_generic.c
qdisc: fix build with !CONFIG_NET_SCHED
[~andy/linux] / net / sched / sch_generic.c
index 48be3d5c0d9246117c03b0174da16a637129640c..a74e278654aa2290a0ef3061d1392c5cf405e5f5 100644 (file)
 #include <net/pkt_sched.h>
 #include <net/dst.h>
 
+/* Qdisc to use by default */
+const struct Qdisc_ops *default_qdisc_ops = &pfifo_fast_ops;
+EXPORT_SYMBOL(default_qdisc_ops);
+
 /* Main transmission queue. */
 
 /* Modifications to data participating in scheduling must be protected with
@@ -530,12 +534,11 @@ struct Qdisc_ops pfifo_fast_ops __read_mostly = {
        .dump           =       pfifo_fast_dump,
        .owner          =       THIS_MODULE,
 };
-EXPORT_SYMBOL(pfifo_fast_ops);
 
 static struct lock_class_key qdisc_tx_busylock;
 
 struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue,
-                         struct Qdisc_ops *ops)
+                         const struct Qdisc_ops *ops)
 {
        void *p;
        struct Qdisc *sch;
@@ -579,10 +582,14 @@ errout:
 }
 
 struct Qdisc *qdisc_create_dflt(struct netdev_queue *dev_queue,
-                               struct Qdisc_ops *ops, unsigned int parentid)
+                               const struct Qdisc_ops *ops,
+                               unsigned int parentid)
 {
        struct Qdisc *sch;
 
+       if (!try_module_get(ops->owner))
+               goto errout;
+
        sch = qdisc_alloc(dev_queue, ops);
        if (IS_ERR(sch))
                goto errout;
@@ -686,7 +693,7 @@ static void attach_one_default_qdisc(struct net_device *dev,
 
        if (dev->tx_queue_len) {
                qdisc = qdisc_create_dflt(dev_queue,
-                                         &pfifo_fast_ops, TC_H_ROOT);
+                                         default_qdisc_ops, TC_H_ROOT);
                if (!qdisc) {
                        netdev_info(dev, "activation failed\n");
                        return;
@@ -739,9 +746,8 @@ void dev_activate(struct net_device *dev)
        int need_watchdog;
 
        /* No queueing discipline is attached to device;
-          create default one i.e. pfifo_fast for devices,
-          which need queueing and noqueue_qdisc for
-          virtual interfaces
+        * create default one for devices, which need queueing
+        * and noqueue_qdisc for virtual interfaces
         */
 
        if (dev->qdisc == &noop_qdisc)