|
@@ -1020,7 +1020,7 @@ static struct Qdisc *qdisc_create(struct net_device *dev,
|
|
|
#endif
|
|
|
|
|
|
err = -ENOENT;
|
|
|
- if (ops == NULL)
|
|
|
+ if (!ops)
|
|
|
goto err_out;
|
|
|
|
|
|
sch = qdisc_alloc(dev_queue, ops);
|
|
@@ -1060,54 +1060,60 @@ static struct Qdisc *qdisc_create(struct net_device *dev,
|
|
|
netdev_info(dev, "Caught tx_queue_len zero misconfig\n");
|
|
|
}
|
|
|
|
|
|
- if (!ops->init || (err = ops->init(sch, tca[TCA_OPTIONS])) == 0) {
|
|
|
- if (qdisc_is_percpu_stats(sch)) {
|
|
|
- sch->cpu_bstats =
|
|
|
- netdev_alloc_pcpu_stats(struct gnet_stats_basic_cpu);
|
|
|
- if (!sch->cpu_bstats)
|
|
|
- goto err_out4;
|
|
|
-
|
|
|
- sch->cpu_qstats = alloc_percpu(struct gnet_stats_queue);
|
|
|
- if (!sch->cpu_qstats)
|
|
|
- goto err_out4;
|
|
|
- }
|
|
|
+ if (ops->init) {
|
|
|
+ err = ops->init(sch, tca[TCA_OPTIONS]);
|
|
|
+ if (err != 0)
|
|
|
+ goto err_out5;
|
|
|
+ }
|
|
|
|
|
|
- if (tca[TCA_STAB]) {
|
|
|
- stab = qdisc_get_stab(tca[TCA_STAB]);
|
|
|
- if (IS_ERR(stab)) {
|
|
|
- err = PTR_ERR(stab);
|
|
|
- goto err_out4;
|
|
|
- }
|
|
|
- rcu_assign_pointer(sch->stab, stab);
|
|
|
- }
|
|
|
- if (tca[TCA_RATE]) {
|
|
|
- seqcount_t *running;
|
|
|
+ if (qdisc_is_percpu_stats(sch)) {
|
|
|
+ sch->cpu_bstats =
|
|
|
+ netdev_alloc_pcpu_stats(struct gnet_stats_basic_cpu);
|
|
|
+ if (!sch->cpu_bstats)
|
|
|
+ goto err_out4;
|
|
|
|
|
|
- err = -EOPNOTSUPP;
|
|
|
- if (sch->flags & TCQ_F_MQROOT)
|
|
|
- goto err_out4;
|
|
|
+ sch->cpu_qstats = alloc_percpu(struct gnet_stats_queue);
|
|
|
+ if (!sch->cpu_qstats)
|
|
|
+ goto err_out4;
|
|
|
+ }
|
|
|
|
|
|
- if ((sch->parent != TC_H_ROOT) &&
|
|
|
- !(sch->flags & TCQ_F_INGRESS) &&
|
|
|
- (!p || !(p->flags & TCQ_F_MQROOT)))
|
|
|
- running = qdisc_root_sleeping_running(sch);
|
|
|
- else
|
|
|
- running = &sch->running;
|
|
|
-
|
|
|
- err = gen_new_estimator(&sch->bstats,
|
|
|
- sch->cpu_bstats,
|
|
|
- &sch->rate_est,
|
|
|
- NULL,
|
|
|
- running,
|
|
|
- tca[TCA_RATE]);
|
|
|
- if (err)
|
|
|
- goto err_out4;
|
|
|
+ if (tca[TCA_STAB]) {
|
|
|
+ stab = qdisc_get_stab(tca[TCA_STAB]);
|
|
|
+ if (IS_ERR(stab)) {
|
|
|
+ err = PTR_ERR(stab);
|
|
|
+ goto err_out4;
|
|
|
}
|
|
|
+ rcu_assign_pointer(sch->stab, stab);
|
|
|
+ }
|
|
|
+ if (tca[TCA_RATE]) {
|
|
|
+ seqcount_t *running;
|
|
|
|
|
|
- qdisc_hash_add(sch, false);
|
|
|
+ err = -EOPNOTSUPP;
|
|
|
+ if (sch->flags & TCQ_F_MQROOT)
|
|
|
+ goto err_out4;
|
|
|
|
|
|
- return sch;
|
|
|
+ if (sch->parent != TC_H_ROOT &&
|
|
|
+ !(sch->flags & TCQ_F_INGRESS) &&
|
|
|
+ (!p || !(p->flags & TCQ_F_MQROOT)))
|
|
|
+ running = qdisc_root_sleeping_running(sch);
|
|
|
+ else
|
|
|
+ running = &sch->running;
|
|
|
+
|
|
|
+ err = gen_new_estimator(&sch->bstats,
|
|
|
+ sch->cpu_bstats,
|
|
|
+ &sch->rate_est,
|
|
|
+ NULL,
|
|
|
+ running,
|
|
|
+ tca[TCA_RATE]);
|
|
|
+ if (err)
|
|
|
+ goto err_out4;
|
|
|
}
|
|
|
+
|
|
|
+ qdisc_hash_add(sch, false);
|
|
|
+
|
|
|
+ return sch;
|
|
|
+
|
|
|
+err_out5:
|
|
|
/* ops->init() failed, we call ->destroy() like qdisc_create_dflt() */
|
|
|
if (ops->destroy)
|
|
|
ops->destroy(sch);
|
|
@@ -1139,7 +1145,7 @@ static int qdisc_change(struct Qdisc *sch, struct nlattr **tca)
|
|
|
int err = 0;
|
|
|
|
|
|
if (tca[TCA_OPTIONS]) {
|
|
|
- if (sch->ops->change == NULL)
|
|
|
+ if (!sch->ops->change)
|
|
|
return -EINVAL;
|
|
|
err = sch->ops->change(sch, tca[TCA_OPTIONS]);
|
|
|
if (err)
|
|
@@ -1344,7 +1350,8 @@ replay:
|
|
|
goto create_n_graft;
|
|
|
if (n->nlmsg_flags & NLM_F_EXCL)
|
|
|
return -EEXIST;
|
|
|
- if (tca[TCA_KIND] && nla_strcmp(tca[TCA_KIND], q->ops->id))
|
|
|
+ if (tca[TCA_KIND] &&
|
|
|
+ nla_strcmp(tca[TCA_KIND], q->ops->id))
|
|
|
return -EINVAL;
|
|
|
if (q == p ||
|
|
|
(p && check_loop(q, p, 0)))
|
|
@@ -1389,7 +1396,7 @@ replay:
|
|
|
}
|
|
|
|
|
|
/* Change qdisc parameters */
|
|
|
- if (q == NULL)
|
|
|
+ if (!q)
|
|
|
return -ENOENT;
|
|
|
if (n->nlmsg_flags & NLM_F_EXCL)
|
|
|
return -EEXIST;
|