summaryrefslogtreecommitdiffstats
path: root/net/sched/sch_gred.c
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2008-01-22 22:11:17 -0800
committerDavid S. Miller <davem@davemloft.net>2008-01-28 15:11:10 -0800
commit1e90474c377e92db7262a8968a45c1dd980ca9e5 (patch)
tree645af56dcb17cf1a76fd3b7f1a8b833a3fffc3d7 /net/sched/sch_gred.c
parent01480e1cf5e2118eba8a8968239f3242072f9563 (diff)
downloadlinux-1e90474c377e92db7262a8968a45c1dd980ca9e5.tar.bz2
[NET_SCHED]: Convert packet schedulers from rtnetlink to new netlink API
Convert packet schedulers to use the netlink API. Unfortunately a gradual conversion is not possible without breaking compilation in the middle or adding lots of casts, so this patch converts them all in one step. The patch has been mostly generated automatically with some minor edits to at least allow seperate conversion of classifiers and actions. Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched/sch_gred.c')
-rw-r--r--net/sched/sch_gred.c59
1 files changed, 32 insertions, 27 deletions
diff --git a/net/sched/sch_gred.c b/net/sched/sch_gred.c
index e2bcd6682c70..6b784838a534 100644
--- a/net/sched/sch_gred.c
+++ b/net/sched/sch_gred.c
@@ -350,16 +350,16 @@ static inline void gred_destroy_vq(struct gred_sched_data *q)
kfree(q);
}
-static inline int gred_change_table_def(struct Qdisc *sch, struct rtattr *dps)
+static inline int gred_change_table_def(struct Qdisc *sch, struct nlattr *dps)
{
struct gred_sched *table = qdisc_priv(sch);
struct tc_gred_sopt *sopt;
int i;
- if (dps == NULL || RTA_PAYLOAD(dps) < sizeof(*sopt))
+ if (dps == NULL || nla_len(dps) < sizeof(*sopt))
return -EINVAL;
- sopt = RTA_DATA(dps);
+ sopt = nla_data(dps);
if (sopt->DPs > MAX_DPs || sopt->DPs == 0 || sopt->def_DP >= sopt->DPs)
return -EINVAL;
@@ -425,28 +425,28 @@ static inline int gred_change_vq(struct Qdisc *sch, int dp,
return 0;
}
-static int gred_change(struct Qdisc *sch, struct rtattr *opt)
+static int gred_change(struct Qdisc *sch, struct nlattr *opt)
{
struct gred_sched *table = qdisc_priv(sch);
struct tc_gred_qopt *ctl;
- struct rtattr *tb[TCA_GRED_MAX];
+ struct nlattr *tb[TCA_GRED_MAX + 1];
int err = -EINVAL, prio = GRED_DEF_PRIO;
u8 *stab;
- if (opt == NULL || rtattr_parse_nested(tb, TCA_GRED_MAX, opt))
+ if (opt == NULL || nla_parse_nested(tb, TCA_GRED_MAX, opt, NULL))
return -EINVAL;
- if (tb[TCA_GRED_PARMS-1] == NULL && tb[TCA_GRED_STAB-1] == NULL)
+ if (tb[TCA_GRED_PARMS] == NULL && tb[TCA_GRED_STAB] == NULL)
return gred_change_table_def(sch, opt);
- if (tb[TCA_GRED_PARMS-1] == NULL ||
- RTA_PAYLOAD(tb[TCA_GRED_PARMS-1]) < sizeof(*ctl) ||
- tb[TCA_GRED_STAB-1] == NULL ||
- RTA_PAYLOAD(tb[TCA_GRED_STAB-1]) < 256)
+ if (tb[TCA_GRED_PARMS] == NULL ||
+ nla_len(tb[TCA_GRED_PARMS]) < sizeof(*ctl) ||
+ tb[TCA_GRED_STAB] == NULL ||
+ nla_len(tb[TCA_GRED_STAB]) < 256)
return -EINVAL;
- ctl = RTA_DATA(tb[TCA_GRED_PARMS-1]);
- stab = RTA_DATA(tb[TCA_GRED_STAB-1]);
+ ctl = nla_data(tb[TCA_GRED_PARMS]);
+ stab = nla_data(tb[TCA_GRED_STAB]);
if (ctl->DP >= table->DPs)
goto errout;
@@ -486,23 +486,23 @@ errout:
return err;
}
-static int gred_init(struct Qdisc *sch, struct rtattr *opt)
+static int gred_init(struct Qdisc *sch, struct nlattr *opt)
{
- struct rtattr *tb[TCA_GRED_MAX];
+ struct nlattr *tb[TCA_GRED_MAX + 1];
- if (opt == NULL || rtattr_parse_nested(tb, TCA_GRED_MAX, opt))
+ if (opt == NULL || nla_parse_nested(tb, TCA_GRED_MAX, opt, NULL))
return -EINVAL;
- if (tb[TCA_GRED_PARMS-1] || tb[TCA_GRED_STAB-1])
+ if (tb[TCA_GRED_PARMS] || tb[TCA_GRED_STAB])
return -EINVAL;
- return gred_change_table_def(sch, tb[TCA_GRED_DPS-1]);
+ return gred_change_table_def(sch, tb[TCA_GRED_DPS]);
}
static int gred_dump(struct Qdisc *sch, struct sk_buff *skb)
{
struct gred_sched *table = qdisc_priv(sch);
- struct rtattr *parms, *opts = NULL;
+ struct nlattr *parms, *opts = NULL;
int i;
struct tc_gred_sopt sopt = {
.DPs = table->DPs,
@@ -511,9 +511,13 @@ static int gred_dump(struct Qdisc *sch, struct sk_buff *skb)
.flags = table->red_flags,
};
- opts = RTA_NEST(skb, TCA_OPTIONS);
- RTA_PUT(skb, TCA_GRED_DPS, sizeof(sopt), &sopt);
- parms = RTA_NEST(skb, TCA_GRED_PARMS);
+ opts = nla_nest_start(skb, TCA_OPTIONS);
+ if (opts == NULL)
+ goto nla_put_failure;
+ NLA_PUT(skb, TCA_GRED_DPS, sizeof(sopt), &sopt);
+ parms = nla_nest_start(skb, TCA_GRED_PARMS);
+ if (parms == NULL)
+ goto nla_put_failure;
for (i = 0; i < MAX_DPs; i++) {
struct gred_sched_data *q = table->tab[i];
@@ -555,15 +559,16 @@ static int gred_dump(struct Qdisc *sch, struct sk_buff *skb)
opt.qave = red_calc_qavg(&q->parms, q->parms.qavg);
append_opt:
- RTA_APPEND(skb, sizeof(opt), &opt);
+ if (nla_append(skb, sizeof(opt), &opt) < 0)
+ goto nla_put_failure;
}
- RTA_NEST_END(skb, parms);
+ nla_nest_end(skb, parms);
- return RTA_NEST_END(skb, opts);
+ return nla_nest_end(skb, opts);
-rtattr_failure:
- return RTA_NEST_CANCEL(skb, opts);
+nla_put_failure:
+ return nla_nest_cancel(skb, opts);
}
static void gred_destroy(struct Qdisc *sch)