aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched/sch_htb.c
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2008-01-23 01:11:17 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:11:10 -0500
commit1e90474c377e92db7262a8968a45c1dd980ca9e5 (patch)
tree645af56dcb17cf1a76fd3b7f1a8b833a3fffc3d7 /net/sched/sch_htb.c
parent01480e1cf5e2118eba8a8968239f3242072f9563 (diff)
[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_htb.c')
-rw-r--r--net/sched/sch_htb.c68
1 files changed, 34 insertions, 34 deletions
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index 6a2352cd9c2e..3b3ff641b6d7 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -992,19 +992,19 @@ static void htb_reset(struct Qdisc *sch)
992 INIT_LIST_HEAD(q->drops + i); 992 INIT_LIST_HEAD(q->drops + i);
993} 993}
994 994
995static int htb_init(struct Qdisc *sch, struct rtattr *opt) 995static int htb_init(struct Qdisc *sch, struct nlattr *opt)
996{ 996{
997 struct htb_sched *q = qdisc_priv(sch); 997 struct htb_sched *q = qdisc_priv(sch);
998 struct rtattr *tb[TCA_HTB_INIT]; 998 struct nlattr *tb[TCA_HTB_INIT + 1];
999 struct tc_htb_glob *gopt; 999 struct tc_htb_glob *gopt;
1000 int i; 1000 int i;
1001 if (!opt || rtattr_parse_nested(tb, TCA_HTB_INIT, opt) || 1001 if (!opt || nla_parse_nested(tb, TCA_HTB_INIT, opt, NULL) ||
1002 tb[TCA_HTB_INIT - 1] == NULL || 1002 tb[TCA_HTB_INIT] == NULL ||
1003 RTA_PAYLOAD(tb[TCA_HTB_INIT - 1]) < sizeof(*gopt)) { 1003 nla_len(tb[TCA_HTB_INIT]) < sizeof(*gopt)) {
1004 printk(KERN_ERR "HTB: hey probably you have bad tc tool ?\n"); 1004 printk(KERN_ERR "HTB: hey probably you have bad tc tool ?\n");
1005 return -EINVAL; 1005 return -EINVAL;
1006 } 1006 }
1007 gopt = RTA_DATA(tb[TCA_HTB_INIT - 1]); 1007 gopt = nla_data(tb[TCA_HTB_INIT]);
1008 if (gopt->version != HTB_VER >> 16) { 1008 if (gopt->version != HTB_VER >> 16) {
1009 printk(KERN_ERR 1009 printk(KERN_ERR
1010 "HTB: need tc/htb version %d (minor is %d), you have %d\n", 1010 "HTB: need tc/htb version %d (minor is %d), you have %d\n",
@@ -1036,7 +1036,7 @@ static int htb_dump(struct Qdisc *sch, struct sk_buff *skb)
1036{ 1036{
1037 struct htb_sched *q = qdisc_priv(sch); 1037 struct htb_sched *q = qdisc_priv(sch);
1038 unsigned char *b = skb_tail_pointer(skb); 1038 unsigned char *b = skb_tail_pointer(skb);
1039 struct rtattr *rta; 1039 struct nlattr *nla;
1040 struct tc_htb_glob gopt; 1040 struct tc_htb_glob gopt;
1041 spin_lock_bh(&sch->dev->queue_lock); 1041 spin_lock_bh(&sch->dev->queue_lock);
1042 gopt.direct_pkts = q->direct_pkts; 1042 gopt.direct_pkts = q->direct_pkts;
@@ -1045,13 +1045,13 @@ static int htb_dump(struct Qdisc *sch, struct sk_buff *skb)
1045 gopt.rate2quantum = q->rate2quantum; 1045 gopt.rate2quantum = q->rate2quantum;
1046 gopt.defcls = q->defcls; 1046 gopt.defcls = q->defcls;
1047 gopt.debug = 0; 1047 gopt.debug = 0;
1048 rta = (struct rtattr *)b; 1048 nla = (struct nlattr *)b;
1049 RTA_PUT(skb, TCA_OPTIONS, 0, NULL); 1049 NLA_PUT(skb, TCA_OPTIONS, 0, NULL);
1050 RTA_PUT(skb, TCA_HTB_INIT, sizeof(gopt), &gopt); 1050 NLA_PUT(skb, TCA_HTB_INIT, sizeof(gopt), &gopt);
1051 rta->rta_len = skb_tail_pointer(skb) - b; 1051 nla->nla_len = skb_tail_pointer(skb) - b;
1052 spin_unlock_bh(&sch->dev->queue_lock); 1052 spin_unlock_bh(&sch->dev->queue_lock);
1053 return skb->len; 1053 return skb->len;
1054rtattr_failure: 1054nla_put_failure:
1055 spin_unlock_bh(&sch->dev->queue_lock); 1055 spin_unlock_bh(&sch->dev->queue_lock);
1056 nlmsg_trim(skb, skb_tail_pointer(skb)); 1056 nlmsg_trim(skb, skb_tail_pointer(skb));
1057 return -1; 1057 return -1;
@@ -1062,7 +1062,7 @@ static int htb_dump_class(struct Qdisc *sch, unsigned long arg,
1062{ 1062{
1063 struct htb_class *cl = (struct htb_class *)arg; 1063 struct htb_class *cl = (struct htb_class *)arg;
1064 unsigned char *b = skb_tail_pointer(skb); 1064 unsigned char *b = skb_tail_pointer(skb);
1065 struct rtattr *rta; 1065 struct nlattr *nla;
1066 struct tc_htb_opt opt; 1066 struct tc_htb_opt opt;
1067 1067
1068 spin_lock_bh(&sch->dev->queue_lock); 1068 spin_lock_bh(&sch->dev->queue_lock);
@@ -1071,8 +1071,8 @@ static int htb_dump_class(struct Qdisc *sch, unsigned long arg,
1071 if (!cl->level && cl->un.leaf.q) 1071 if (!cl->level && cl->un.leaf.q)
1072 tcm->tcm_info = cl->un.leaf.q->handle; 1072 tcm->tcm_info = cl->un.leaf.q->handle;
1073 1073
1074 rta = (struct rtattr *)b; 1074 nla = (struct nlattr *)b;
1075 RTA_PUT(skb, TCA_OPTIONS, 0, NULL); 1075 NLA_PUT(skb, TCA_OPTIONS, 0, NULL);
1076 1076
1077 memset(&opt, 0, sizeof(opt)); 1077 memset(&opt, 0, sizeof(opt));
1078 1078
@@ -1083,11 +1083,11 @@ static int htb_dump_class(struct Qdisc *sch, unsigned long arg,
1083 opt.quantum = cl->un.leaf.quantum; 1083 opt.quantum = cl->un.leaf.quantum;
1084 opt.prio = cl->un.leaf.prio; 1084 opt.prio = cl->un.leaf.prio;
1085 opt.level = cl->level; 1085 opt.level = cl->level;
1086 RTA_PUT(skb, TCA_HTB_PARMS, sizeof(opt), &opt); 1086 NLA_PUT(skb, TCA_HTB_PARMS, sizeof(opt), &opt);
1087 rta->rta_len = skb_tail_pointer(skb) - b; 1087 nla->nla_len = skb_tail_pointer(skb) - b;
1088 spin_unlock_bh(&sch->dev->queue_lock); 1088 spin_unlock_bh(&sch->dev->queue_lock);
1089 return skb->len; 1089 return skb->len;
1090rtattr_failure: 1090nla_put_failure:
1091 spin_unlock_bh(&sch->dev->queue_lock); 1091 spin_unlock_bh(&sch->dev->queue_lock);
1092 nlmsg_trim(skb, b); 1092 nlmsg_trim(skb, b);
1093 return -1; 1093 return -1;
@@ -1290,29 +1290,29 @@ static void htb_put(struct Qdisc *sch, unsigned long arg)
1290} 1290}
1291 1291
1292static int htb_change_class(struct Qdisc *sch, u32 classid, 1292static int htb_change_class(struct Qdisc *sch, u32 classid,
1293 u32 parentid, struct rtattr **tca, 1293 u32 parentid, struct nlattr **tca,
1294 unsigned long *arg) 1294 unsigned long *arg)
1295{ 1295{
1296 int err = -EINVAL; 1296 int err = -EINVAL;
1297 struct htb_sched *q = qdisc_priv(sch); 1297 struct htb_sched *q = qdisc_priv(sch);
1298 struct htb_class *cl = (struct htb_class *)*arg, *parent; 1298 struct htb_class *cl = (struct htb_class *)*arg, *parent;
1299 struct rtattr *opt = tca[TCA_OPTIONS - 1]; 1299 struct nlattr *opt = tca[TCA_OPTIONS];
1300 struct qdisc_rate_table *rtab = NULL, *ctab = NULL; 1300 struct qdisc_rate_table *rtab = NULL, *ctab = NULL;
1301 struct rtattr *tb[TCA_HTB_RTAB]; 1301 struct nlattr *tb[TCA_HTB_RTAB + 1];
1302 struct tc_htb_opt *hopt; 1302 struct tc_htb_opt *hopt;
1303 1303
1304 /* extract all subattrs from opt attr */ 1304 /* extract all subattrs from opt attr */
1305 if (!opt || rtattr_parse_nested(tb, TCA_HTB_RTAB, opt) || 1305 if (!opt || nla_parse_nested(tb, TCA_HTB_RTAB, opt, NULL) ||
1306 tb[TCA_HTB_PARMS - 1] == NULL || 1306 tb[TCA_HTB_PARMS] == NULL ||
1307 RTA_PAYLOAD(tb[TCA_HTB_PARMS - 1]) < sizeof(*hopt)) 1307 nla_len(tb[TCA_HTB_PARMS]) < sizeof(*hopt))
1308 goto failure; 1308 goto failure;
1309 1309
1310 parent = parentid == TC_H_ROOT ? NULL : htb_find(parentid, sch); 1310 parent = parentid == TC_H_ROOT ? NULL : htb_find(parentid, sch);
1311 1311
1312 hopt = RTA_DATA(tb[TCA_HTB_PARMS - 1]); 1312 hopt = nla_data(tb[TCA_HTB_PARMS]);
1313 1313
1314 rtab = qdisc_get_rtab(&hopt->rate, tb[TCA_HTB_RTAB - 1]); 1314 rtab = qdisc_get_rtab(&hopt->rate, tb[TCA_HTB_RTAB]);
1315 ctab = qdisc_get_rtab(&hopt->ceil, tb[TCA_HTB_CTAB - 1]); 1315 ctab = qdisc_get_rtab(&hopt->ceil, tb[TCA_HTB_CTAB]);
1316 if (!rtab || !ctab) 1316 if (!rtab || !ctab)
1317 goto failure; 1317 goto failure;
1318 1318
@@ -1320,12 +1320,12 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,
1320 struct Qdisc *new_q; 1320 struct Qdisc *new_q;
1321 int prio; 1321 int prio;
1322 struct { 1322 struct {
1323 struct rtattr rta; 1323 struct nlattr nla;
1324 struct gnet_estimator opt; 1324 struct gnet_estimator opt;
1325 } est = { 1325 } est = {
1326 .rta = { 1326 .nla = {
1327 .rta_len = RTA_LENGTH(sizeof(est.opt)), 1327 .nla_len = nla_attr_size(sizeof(est.opt)),
1328 .rta_type = TCA_RATE, 1328 .nla_type = TCA_RATE,
1329 }, 1329 },
1330 .opt = { 1330 .opt = {
1331 /* 4s interval, 16s averaging constant */ 1331 /* 4s interval, 16s averaging constant */
@@ -1350,7 +1350,7 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,
1350 1350
1351 gen_new_estimator(&cl->bstats, &cl->rate_est, 1351 gen_new_estimator(&cl->bstats, &cl->rate_est,
1352 &sch->dev->queue_lock, 1352 &sch->dev->queue_lock,
1353 tca[TCA_RATE-1] ? : &est.rta); 1353 tca[TCA_RATE] ? : &est.nla);
1354 cl->refcnt = 1; 1354 cl->refcnt = 1;
1355 INIT_LIST_HEAD(&cl->sibling); 1355 INIT_LIST_HEAD(&cl->sibling);
1356 INIT_HLIST_NODE(&cl->hlist); 1356 INIT_HLIST_NODE(&cl->hlist);
@@ -1403,10 +1403,10 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,
1403 list_add_tail(&cl->sibling, 1403 list_add_tail(&cl->sibling,
1404 parent ? &parent->children : &q->root); 1404 parent ? &parent->children : &q->root);
1405 } else { 1405 } else {
1406 if (tca[TCA_RATE-1]) 1406 if (tca[TCA_RATE])
1407 gen_replace_estimator(&cl->bstats, &cl->rate_est, 1407 gen_replace_estimator(&cl->bstats, &cl->rate_est,
1408 &sch->dev->queue_lock, 1408 &sch->dev->queue_lock,
1409 tca[TCA_RATE-1]); 1409 tca[TCA_RATE]);
1410 sch_tree_lock(sch); 1410 sch_tree_lock(sch);
1411 } 1411 }
1412 1412