Skip to content

Commit

Permalink
net: sched: sch: add extack for change qdisc ops
Browse files Browse the repository at this point in the history
This patch adds extack support for change callback for qdisc ops
structtur to prepare per-qdisc specific changes for extack.

Cc: David Ahern <[email protected]>
Acked-by: Jamal Hadi Salim <[email protected]>
Signed-off-by: Alexander Aring <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Alexander Aring authored and davem330 committed Dec 21, 2017
1 parent e63d7df commit 2030721
Show file tree
Hide file tree
Showing 19 changed files with 52 additions and 40 deletions.
3 changes: 2 additions & 1 deletion include/net/sch_generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ struct Qdisc_ops {
void (*reset)(struct Qdisc *);
void (*destroy)(struct Qdisc *);
int (*change)(struct Qdisc *sch,
struct nlattr *arg);
struct nlattr *arg,
struct netlink_ext_ack *extack);
void (*attach)(struct Qdisc *sch);

int (*dump)(struct Qdisc *, struct sk_buff *);
Expand Down
2 changes: 1 addition & 1 deletion net/sched/sch_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,7 @@ static int qdisc_change(struct Qdisc *sch, struct nlattr **tca,
NL_SET_ERR_MSG(extack, "Change operation not supported by specified qdisc");
return -EINVAL;
}
err = sch->ops->change(sch, tca[TCA_OPTIONS]);
err = sch->ops->change(sch, tca[TCA_OPTIONS], extack);
if (err)
return err;
}
Expand Down
5 changes: 3 additions & 2 deletions net/sched/sch_cbs.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ static int cbs_enable_offload(struct net_device *dev, struct cbs_sched_data *q,
return 0;
}

static int cbs_change(struct Qdisc *sch, struct nlattr *opt)
static int cbs_change(struct Qdisc *sch, struct nlattr *opt,
struct netlink_ext_ack *extack)
{
struct cbs_sched_data *q = qdisc_priv(sch);
struct net_device *dev = qdisc_dev(sch);
Expand Down Expand Up @@ -307,7 +308,7 @@ static int cbs_init(struct Qdisc *sch, struct nlattr *opt,

qdisc_watchdog_init(&q->watchdog, sch);

return cbs_change(sch, opt);
return cbs_change(sch, opt, extack);
}

static void cbs_destroy(struct Qdisc *sch)
Expand Down
5 changes: 3 additions & 2 deletions net/sched/sch_choke.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,8 @@ static void choke_free(void *addr)
kvfree(addr);
}

static int choke_change(struct Qdisc *sch, struct nlattr *opt)
static int choke_change(struct Qdisc *sch, struct nlattr *opt,
struct netlink_ext_ack *extack)
{
struct choke_sched_data *q = qdisc_priv(sch);
struct nlattr *tb[TCA_CHOKE_MAX + 1];
Expand Down Expand Up @@ -434,7 +435,7 @@ static int choke_change(struct Qdisc *sch, struct nlattr *opt)
static int choke_init(struct Qdisc *sch, struct nlattr *opt,
struct netlink_ext_ack *extack)
{
return choke_change(sch, opt);
return choke_change(sch, opt, extack);
}

static int choke_dump(struct Qdisc *sch, struct sk_buff *skb)
Expand Down
5 changes: 3 additions & 2 deletions net/sched/sch_codel.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ static const struct nla_policy codel_policy[TCA_CODEL_MAX + 1] = {
[TCA_CODEL_CE_THRESHOLD]= { .type = NLA_U32 },
};

static int codel_change(struct Qdisc *sch, struct nlattr *opt)
static int codel_change(struct Qdisc *sch, struct nlattr *opt,
struct netlink_ext_ack *extack)
{
struct codel_sched_data *q = qdisc_priv(sch);
struct nlattr *tb[TCA_CODEL_MAX + 1];
Expand Down Expand Up @@ -197,7 +198,7 @@ static int codel_init(struct Qdisc *sch, struct nlattr *opt,
q->params.mtu = psched_mtu(qdisc_dev(sch));

if (opt) {
int err = codel_change(sch, opt);
int err = codel_change(sch, opt, extack);

if (err)
return err;
Expand Down
13 changes: 4 additions & 9 deletions net/sched/sch_fifo.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,6 @@ static int fifo_init(struct Qdisc *sch, struct nlattr *opt,
return 0;
}

static int fifo_change(struct Qdisc *sch, struct nlattr *opt)
{
return fifo_init(sch, opt, NULL);
}

static int fifo_dump(struct Qdisc *sch, struct sk_buff *skb)
{
struct tc_fifo_qopt opt = { .limit = sch->limit };
Expand All @@ -114,7 +109,7 @@ struct Qdisc_ops pfifo_qdisc_ops __read_mostly = {
.peek = qdisc_peek_head,
.init = fifo_init,
.reset = qdisc_reset_queue,
.change = fifo_change,
.change = fifo_init,
.dump = fifo_dump,
.owner = THIS_MODULE,
};
Expand All @@ -128,7 +123,7 @@ struct Qdisc_ops bfifo_qdisc_ops __read_mostly = {
.peek = qdisc_peek_head,
.init = fifo_init,
.reset = qdisc_reset_queue,
.change = fifo_change,
.change = fifo_init,
.dump = fifo_dump,
.owner = THIS_MODULE,
};
Expand All @@ -142,7 +137,7 @@ struct Qdisc_ops pfifo_head_drop_qdisc_ops __read_mostly = {
.peek = qdisc_peek_head,
.init = fifo_init,
.reset = qdisc_reset_queue,
.change = fifo_change,
.change = fifo_init,
.dump = fifo_dump,
.owner = THIS_MODULE,
};
Expand All @@ -163,7 +158,7 @@ int fifo_set_limit(struct Qdisc *q, unsigned int limit)
nla->nla_len = nla_attr_size(sizeof(struct tc_fifo_qopt));
((struct tc_fifo_qopt *)nla_data(nla))->limit = limit;

ret = q->ops->change(q, nla);
ret = q->ops->change(q, nla, NULL);
kfree(nla);
}
return ret;
Expand Down
5 changes: 3 additions & 2 deletions net/sched/sch_fq.c
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,8 @@ static const struct nla_policy fq_policy[TCA_FQ_MAX + 1] = {
[TCA_FQ_LOW_RATE_THRESHOLD] = { .type = NLA_U32 },
};

static int fq_change(struct Qdisc *sch, struct nlattr *opt)
static int fq_change(struct Qdisc *sch, struct nlattr *opt,
struct netlink_ext_ack *extack)
{
struct fq_sched_data *q = qdisc_priv(sch);
struct nlattr *tb[TCA_FQ_MAX + 1];
Expand Down Expand Up @@ -812,7 +813,7 @@ static int fq_init(struct Qdisc *sch, struct nlattr *opt,
qdisc_watchdog_init(&q->watchdog, sch);

if (opt)
err = fq_change(sch, opt);
err = fq_change(sch, opt, extack);
else
err = fq_resize(sch, q->fq_trees_log);

Expand Down
5 changes: 3 additions & 2 deletions net/sched/sch_fq_codel.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,8 @@ static const struct nla_policy fq_codel_policy[TCA_FQ_CODEL_MAX + 1] = {
[TCA_FQ_CODEL_MEMORY_LIMIT] = { .type = NLA_U32 },
};

static int fq_codel_change(struct Qdisc *sch, struct nlattr *opt)
static int fq_codel_change(struct Qdisc *sch, struct nlattr *opt,
struct netlink_ext_ack *extack)
{
struct fq_codel_sched_data *q = qdisc_priv(sch);
struct nlattr *tb[TCA_FQ_CODEL_MAX + 1];
Expand Down Expand Up @@ -478,7 +479,7 @@ static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt,
q->cparams.mtu = psched_mtu(qdisc_dev(sch));

if (opt) {
int err = fq_codel_change(sch, opt);
int err = fq_codel_change(sch, opt, NULL);
if (err)
return err;
}
Expand Down
3 changes: 2 additions & 1 deletion net/sched/sch_gred.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,8 @@ static const struct nla_policy gred_policy[TCA_GRED_MAX + 1] = {
[TCA_GRED_LIMIT] = { .type = NLA_U32 },
};

static int gred_change(struct Qdisc *sch, struct nlattr *opt)
static int gred_change(struct Qdisc *sch, struct nlattr *opt,
struct netlink_ext_ack *extack)
{
struct gred_sched *table = qdisc_priv(sch);
struct tc_gred_qopt *ctl;
Expand Down
3 changes: 2 additions & 1 deletion net/sched/sch_hfsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1430,7 +1430,8 @@ hfsc_init_qdisc(struct Qdisc *sch, struct nlattr *opt,
}

static int
hfsc_change_qdisc(struct Qdisc *sch, struct nlattr *opt)
hfsc_change_qdisc(struct Qdisc *sch, struct nlattr *opt,
struct netlink_ext_ack *extack)
{
struct hfsc_sched *q = qdisc_priv(sch);
struct tc_hfsc_qopt *qopt;
Expand Down
5 changes: 3 additions & 2 deletions net/sched/sch_hhf.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,8 @@ static const struct nla_policy hhf_policy[TCA_HHF_MAX + 1] = {
[TCA_HHF_NON_HH_WEIGHT] = { .type = NLA_U32 },
};

static int hhf_change(struct Qdisc *sch, struct nlattr *opt)
static int hhf_change(struct Qdisc *sch, struct nlattr *opt,
struct netlink_ext_ack *extack)
{
struct hhf_sched_data *q = qdisc_priv(sch);
struct nlattr *tb[TCA_HHF_MAX + 1];
Expand Down Expand Up @@ -590,7 +591,7 @@ static int hhf_init(struct Qdisc *sch, struct nlattr *opt,
q->hhf_non_hh_weight = 2;

if (opt) {
int err = hhf_change(sch, opt);
int err = hhf_change(sch, opt, extack);

if (err)
return err;
Expand Down
5 changes: 3 additions & 2 deletions net/sched/sch_multiq.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ multiq_destroy(struct Qdisc *sch)
kfree(q->queues);
}

static int multiq_tune(struct Qdisc *sch, struct nlattr *opt)
static int multiq_tune(struct Qdisc *sch, struct nlattr *opt,
struct netlink_ext_ack *extack)
{
struct multiq_sched_data *q = qdisc_priv(sch);
struct tc_multiq_qopt *qopt;
Expand Down Expand Up @@ -259,7 +260,7 @@ static int multiq_init(struct Qdisc *sch, struct nlattr *opt,
for (i = 0; i < q->max_bands; i++)
q->queues[i] = &noop_qdisc;

return multiq_tune(sch, opt);
return multiq_tune(sch, opt, extack);
}

static int multiq_dump(struct Qdisc *sch, struct sk_buff *skb)
Expand Down
5 changes: 3 additions & 2 deletions net/sched/sch_netem.c
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,8 @@ static int parse_attr(struct nlattr *tb[], int maxtype, struct nlattr *nla,
}

/* Parse netlink message to set options */
static int netem_change(struct Qdisc *sch, struct nlattr *opt)
static int netem_change(struct Qdisc *sch, struct nlattr *opt,
struct netlink_ext_ack *extack)
{
struct netem_sched_data *q = qdisc_priv(sch);
struct nlattr *tb[TCA_NETEM_MAX + 1];
Expand Down Expand Up @@ -996,7 +997,7 @@ static int netem_init(struct Qdisc *sch, struct nlattr *opt,
return -EINVAL;

q->loss_model = CLG_RANDOM;
ret = netem_change(sch, opt);
ret = netem_change(sch, opt, extack);
if (ret)
pr_info("netem: change failed\n");
return ret;
Expand Down
5 changes: 3 additions & 2 deletions net/sched/sch_pie.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ static const struct nla_policy pie_policy[TCA_PIE_MAX + 1] = {
[TCA_PIE_BYTEMODE] = {.type = NLA_U32},
};

static int pie_change(struct Qdisc *sch, struct nlattr *opt)
static int pie_change(struct Qdisc *sch, struct nlattr *opt,
struct netlink_ext_ack *extack)
{
struct pie_sched_data *q = qdisc_priv(sch);
struct nlattr *tb[TCA_PIE_MAX + 1];
Expand Down Expand Up @@ -452,7 +453,7 @@ static int pie_init(struct Qdisc *sch, struct nlattr *opt,
timer_setup(&q->adapt_timer, pie_timer, 0);

if (opt) {
int err = pie_change(sch, opt);
int err = pie_change(sch, opt, extack);

if (err)
return err;
Expand Down
3 changes: 2 additions & 1 deletion net/sched/sch_plug.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ static int plug_init(struct Qdisc *sch, struct nlattr *opt,
* command is received (just act as a pass-thru queue).
* TCQ_PLUG_LIMIT: Increase/decrease queue size
*/
static int plug_change(struct Qdisc *sch, struct nlattr *opt)
static int plug_change(struct Qdisc *sch, struct nlattr *opt,
struct netlink_ext_ack *extack)
{
struct plug_sched_data *q = qdisc_priv(sch);
struct tc_plug_qopt *msg;
Expand Down
5 changes: 3 additions & 2 deletions net/sched/sch_prio.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ prio_destroy(struct Qdisc *sch)
qdisc_destroy(q->queues[prio]);
}

static int prio_tune(struct Qdisc *sch, struct nlattr *opt)
static int prio_tune(struct Qdisc *sch, struct nlattr *opt,
struct netlink_ext_ack *extack)
{
struct prio_sched_data *q = qdisc_priv(sch);
struct Qdisc *queues[TCQ_PRIO_BANDS];
Expand Down Expand Up @@ -218,7 +219,7 @@ static int prio_init(struct Qdisc *sch, struct nlattr *opt,
if (err)
return err;

return prio_tune(sch, opt);
return prio_tune(sch, opt, extack);
}

static int prio_dump(struct Qdisc *sch, struct sk_buff *skb)
Expand Down
5 changes: 3 additions & 2 deletions net/sched/sch_red.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ static const struct nla_policy red_policy[TCA_RED_MAX + 1] = {
[TCA_RED_MAX_P] = { .type = NLA_U32 },
};

static int red_change(struct Qdisc *sch, struct nlattr *opt)
static int red_change(struct Qdisc *sch, struct nlattr *opt,
struct netlink_ext_ack *extack)
{
struct red_sched_data *q = qdisc_priv(sch);
struct nlattr *tb[TCA_RED_MAX + 1];
Expand Down Expand Up @@ -280,7 +281,7 @@ static int red_init(struct Qdisc *sch, struct nlattr *opt,
q->qdisc = &noop_qdisc;
q->sch = sch;
timer_setup(&q->adapt_timer, red_adaptative_timer, 0);
return red_change(sch, opt);
return red_change(sch, opt, extack);
}

static int red_dump_offload_stats(struct Qdisc *sch, struct tc_red_qopt *opt)
Expand Down
5 changes: 3 additions & 2 deletions net/sched/sch_sfb.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,8 @@ static const struct tc_sfb_qopt sfb_default_ops = {
.penalty_burst = 20,
};

static int sfb_change(struct Qdisc *sch, struct nlattr *opt)
static int sfb_change(struct Qdisc *sch, struct nlattr *opt,
struct netlink_ext_ack *extack)
{
struct sfb_sched_data *q = qdisc_priv(sch);
struct Qdisc *child;
Expand Down Expand Up @@ -560,7 +561,7 @@ static int sfb_init(struct Qdisc *sch, struct nlattr *opt,
return err;

q->qdisc = &noop_qdisc;
return sfb_change(sch, opt);
return sfb_change(sch, opt, extack);
}

static int sfb_dump(struct Qdisc *sch, struct sk_buff *skb)
Expand Down
5 changes: 3 additions & 2 deletions net/sched/sch_tbf.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,8 @@ static const struct nla_policy tbf_policy[TCA_TBF_MAX + 1] = {
[TCA_TBF_PBURST] = { .type = NLA_U32 },
};

static int tbf_change(struct Qdisc *sch, struct nlattr *opt)
static int tbf_change(struct Qdisc *sch, struct nlattr *opt,
struct netlink_ext_ack *extack)
{
int err;
struct tbf_sched_data *q = qdisc_priv(sch);
Expand Down Expand Up @@ -434,7 +435,7 @@ static int tbf_init(struct Qdisc *sch, struct nlattr *opt,

q->t_c = ktime_get_ns();

return tbf_change(sch, opt);
return tbf_change(sch, opt, extack);
}

static void tbf_destroy(struct Qdisc *sch)
Expand Down

0 comments on commit 2030721

Please sign in to comment.