Skip to content

Commit 9382a50

Browse files
committed
Merge branch 'sch_api-style'
Alexander Aring says: ==================== net: sched: sch_api: fix coding style issues for extack this patch prepares to handle extack for qdiscs and fixes checkpatch issues. There are a bunch of warnings issued by checkpatch which bothered me. This first patchset is to get rid of those warnings to make way for the next patchsets. I plan to followup with qdiscs, classifiers and actions after this. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 045203e + 54160ef commit 9382a50

File tree

2 files changed

+58
-49
lines changed

2 files changed

+58
-49
lines changed

include/net/sch_generic.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ struct Qdisc_class_ops {
161161
void (*walk)(struct Qdisc *, struct qdisc_walker * arg);
162162

163163
/* Filter manipulation */
164-
struct tcf_block * (*tcf_block)(struct Qdisc *, unsigned long);
164+
struct tcf_block * (*tcf_block)(struct Qdisc *sch,
165+
unsigned long arg);
165166
unsigned long (*bind_tcf)(struct Qdisc *, unsigned long,
166167
u32 classid);
167168
void (*unbind_tcf)(struct Qdisc *, unsigned long);
@@ -185,11 +186,12 @@ struct Qdisc_ops {
185186
struct sk_buff * (*dequeue)(struct Qdisc *);
186187
struct sk_buff * (*peek)(struct Qdisc *);
187188

188-
int (*init)(struct Qdisc *, struct nlattr *arg);
189+
int (*init)(struct Qdisc *sch, struct nlattr *arg);
189190
void (*reset)(struct Qdisc *);
190191
void (*destroy)(struct Qdisc *);
191-
int (*change)(struct Qdisc *, struct nlattr *arg);
192-
void (*attach)(struct Qdisc *);
192+
int (*change)(struct Qdisc *sch,
193+
struct nlattr *arg);
194+
void (*attach)(struct Qdisc *sch);
193195

194196
int (*dump)(struct Qdisc *, struct sk_buff *);
195197
int (*dump_stats)(struct Qdisc *, struct gnet_dump *);

net/sched/sch_api.c

Lines changed: 52 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,7 @@ static struct Qdisc *qdisc_create(struct net_device *dev,
10201020
#endif
10211021

10221022
err = -ENOENT;
1023-
if (ops == NULL)
1023+
if (!ops)
10241024
goto err_out;
10251025

10261026
sch = qdisc_alloc(dev_queue, ops);
@@ -1060,54 +1060,60 @@ static struct Qdisc *qdisc_create(struct net_device *dev,
10601060
netdev_info(dev, "Caught tx_queue_len zero misconfig\n");
10611061
}
10621062

1063-
if (!ops->init || (err = ops->init(sch, tca[TCA_OPTIONS])) == 0) {
1064-
if (qdisc_is_percpu_stats(sch)) {
1065-
sch->cpu_bstats =
1066-
netdev_alloc_pcpu_stats(struct gnet_stats_basic_cpu);
1067-
if (!sch->cpu_bstats)
1068-
goto err_out4;
1069-
1070-
sch->cpu_qstats = alloc_percpu(struct gnet_stats_queue);
1071-
if (!sch->cpu_qstats)
1072-
goto err_out4;
1073-
}
1063+
if (ops->init) {
1064+
err = ops->init(sch, tca[TCA_OPTIONS]);
1065+
if (err != 0)
1066+
goto err_out5;
1067+
}
10741068

1075-
if (tca[TCA_STAB]) {
1076-
stab = qdisc_get_stab(tca[TCA_STAB]);
1077-
if (IS_ERR(stab)) {
1078-
err = PTR_ERR(stab);
1079-
goto err_out4;
1080-
}
1081-
rcu_assign_pointer(sch->stab, stab);
1082-
}
1083-
if (tca[TCA_RATE]) {
1084-
seqcount_t *running;
1069+
if (qdisc_is_percpu_stats(sch)) {
1070+
sch->cpu_bstats =
1071+
netdev_alloc_pcpu_stats(struct gnet_stats_basic_cpu);
1072+
if (!sch->cpu_bstats)
1073+
goto err_out4;
10851074

1086-
err = -EOPNOTSUPP;
1087-
if (sch->flags & TCQ_F_MQROOT)
1088-
goto err_out4;
1075+
sch->cpu_qstats = alloc_percpu(struct gnet_stats_queue);
1076+
if (!sch->cpu_qstats)
1077+
goto err_out4;
1078+
}
10891079

1090-
if ((sch->parent != TC_H_ROOT) &&
1091-
!(sch->flags & TCQ_F_INGRESS) &&
1092-
(!p || !(p->flags & TCQ_F_MQROOT)))
1093-
running = qdisc_root_sleeping_running(sch);
1094-
else
1095-
running = &sch->running;
1096-
1097-
err = gen_new_estimator(&sch->bstats,
1098-
sch->cpu_bstats,
1099-
&sch->rate_est,
1100-
NULL,
1101-
running,
1102-
tca[TCA_RATE]);
1103-
if (err)
1104-
goto err_out4;
1080+
if (tca[TCA_STAB]) {
1081+
stab = qdisc_get_stab(tca[TCA_STAB]);
1082+
if (IS_ERR(stab)) {
1083+
err = PTR_ERR(stab);
1084+
goto err_out4;
11051085
}
1086+
rcu_assign_pointer(sch->stab, stab);
1087+
}
1088+
if (tca[TCA_RATE]) {
1089+
seqcount_t *running;
11061090

1107-
qdisc_hash_add(sch, false);
1091+
err = -EOPNOTSUPP;
1092+
if (sch->flags & TCQ_F_MQROOT)
1093+
goto err_out4;
11081094

1109-
return sch;
1095+
if (sch->parent != TC_H_ROOT &&
1096+
!(sch->flags & TCQ_F_INGRESS) &&
1097+
(!p || !(p->flags & TCQ_F_MQROOT)))
1098+
running = qdisc_root_sleeping_running(sch);
1099+
else
1100+
running = &sch->running;
1101+
1102+
err = gen_new_estimator(&sch->bstats,
1103+
sch->cpu_bstats,
1104+
&sch->rate_est,
1105+
NULL,
1106+
running,
1107+
tca[TCA_RATE]);
1108+
if (err)
1109+
goto err_out4;
11101110
}
1111+
1112+
qdisc_hash_add(sch, false);
1113+
1114+
return sch;
1115+
1116+
err_out5:
11111117
/* ops->init() failed, we call ->destroy() like qdisc_create_dflt() */
11121118
if (ops->destroy)
11131119
ops->destroy(sch);
@@ -1139,7 +1145,7 @@ static int qdisc_change(struct Qdisc *sch, struct nlattr **tca)
11391145
int err = 0;
11401146

11411147
if (tca[TCA_OPTIONS]) {
1142-
if (sch->ops->change == NULL)
1148+
if (!sch->ops->change)
11431149
return -EINVAL;
11441150
err = sch->ops->change(sch, tca[TCA_OPTIONS]);
11451151
if (err)
@@ -1344,7 +1350,8 @@ static int tc_modify_qdisc(struct sk_buff *skb, struct nlmsghdr *n,
13441350
goto create_n_graft;
13451351
if (n->nlmsg_flags & NLM_F_EXCL)
13461352
return -EEXIST;
1347-
if (tca[TCA_KIND] && nla_strcmp(tca[TCA_KIND], q->ops->id))
1353+
if (tca[TCA_KIND] &&
1354+
nla_strcmp(tca[TCA_KIND], q->ops->id))
13481355
return -EINVAL;
13491356
if (q == p ||
13501357
(p && check_loop(q, p, 0)))
@@ -1389,7 +1396,7 @@ static int tc_modify_qdisc(struct sk_buff *skb, struct nlmsghdr *n,
13891396
}
13901397

13911398
/* Change qdisc parameters */
1392-
if (q == NULL)
1399+
if (!q)
13931400
return -ENOENT;
13941401
if (n->nlmsg_flags & NLM_F_EXCL)
13951402
return -EEXIST;

0 commit comments

Comments
 (0)