aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched/sch_htb.c
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2008-01-23 23:34:11 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:11:18 -0500
commit4b3550ef530cfc153fa91f0b37cbda448bad11c6 (patch)
tree02aba7497298f220629af8e47f48e56df86d428f /net/sched/sch_htb.c
parentcee63723b358e594225e812d6e14a2a0abfd5c88 (diff)
[NET_SCHED]: Use nla_nest_start/nla_nest_end
Use nla_nest_start/nla_nest_end for dumping nested attributes. 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.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index 512df9a0a242..69fac320f8bc 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -1043,25 +1043,29 @@ static int htb_init(struct Qdisc *sch, struct nlattr *opt)
1043static int htb_dump(struct Qdisc *sch, struct sk_buff *skb) 1043static int htb_dump(struct Qdisc *sch, struct sk_buff *skb)
1044{ 1044{
1045 struct htb_sched *q = qdisc_priv(sch); 1045 struct htb_sched *q = qdisc_priv(sch);
1046 unsigned char *b = skb_tail_pointer(skb); 1046 struct nlattr *nest;
1047 struct nlattr *nla;
1048 struct tc_htb_glob gopt; 1047 struct tc_htb_glob gopt;
1048
1049 spin_lock_bh(&sch->dev->queue_lock); 1049 spin_lock_bh(&sch->dev->queue_lock);
1050 gopt.direct_pkts = q->direct_pkts;
1051 1050
1051 gopt.direct_pkts = q->direct_pkts;
1052 gopt.version = HTB_VER; 1052 gopt.version = HTB_VER;
1053 gopt.rate2quantum = q->rate2quantum; 1053 gopt.rate2quantum = q->rate2quantum;
1054 gopt.defcls = q->defcls; 1054 gopt.defcls = q->defcls;
1055 gopt.debug = 0; 1055 gopt.debug = 0;
1056 nla = (struct nlattr *)b; 1056
1057 NLA_PUT(skb, TCA_OPTIONS, 0, NULL); 1057 nest = nla_nest_start(skb, TCA_OPTIONS);
1058 if (nest == NULL)
1059 goto nla_put_failure;
1058 NLA_PUT(skb, TCA_HTB_INIT, sizeof(gopt), &gopt); 1060 NLA_PUT(skb, TCA_HTB_INIT, sizeof(gopt), &gopt);
1059 nla->nla_len = skb_tail_pointer(skb) - b; 1061 nla_nest_end(skb, nest);
1062
1060 spin_unlock_bh(&sch->dev->queue_lock); 1063 spin_unlock_bh(&sch->dev->queue_lock);
1061 return skb->len; 1064 return skb->len;
1065
1062nla_put_failure: 1066nla_put_failure:
1063 spin_unlock_bh(&sch->dev->queue_lock); 1067 spin_unlock_bh(&sch->dev->queue_lock);
1064 nlmsg_trim(skb, skb_tail_pointer(skb)); 1068 nla_nest_cancel(skb, nest);
1065 return -1; 1069 return -1;
1066} 1070}
1067 1071
@@ -1069,8 +1073,7 @@ static int htb_dump_class(struct Qdisc *sch, unsigned long arg,
1069 struct sk_buff *skb, struct tcmsg *tcm) 1073 struct sk_buff *skb, struct tcmsg *tcm)
1070{ 1074{
1071 struct htb_class *cl = (struct htb_class *)arg; 1075 struct htb_class *cl = (struct htb_class *)arg;
1072 unsigned char *b = skb_tail_pointer(skb); 1076 struct nlattr *nest;
1073 struct nlattr *nla;
1074 struct tc_htb_opt opt; 1077 struct tc_htb_opt opt;
1075 1078
1076 spin_lock_bh(&sch->dev->queue_lock); 1079 spin_lock_bh(&sch->dev->queue_lock);
@@ -1079,8 +1082,9 @@ static int htb_dump_class(struct Qdisc *sch, unsigned long arg,
1079 if (!cl->level && cl->un.leaf.q) 1082 if (!cl->level && cl->un.leaf.q)
1080 tcm->tcm_info = cl->un.leaf.q->handle; 1083 tcm->tcm_info = cl->un.leaf.q->handle;
1081 1084
1082 nla = (struct nlattr *)b; 1085 nest = nla_nest_start(skb, TCA_OPTIONS);
1083 NLA_PUT(skb, TCA_OPTIONS, 0, NULL); 1086 if (nest == NULL)
1087 goto nla_put_failure;
1084 1088
1085 memset(&opt, 0, sizeof(opt)); 1089 memset(&opt, 0, sizeof(opt));
1086 1090
@@ -1092,12 +1096,14 @@ static int htb_dump_class(struct Qdisc *sch, unsigned long arg,
1092 opt.prio = cl->un.leaf.prio; 1096 opt.prio = cl->un.leaf.prio;
1093 opt.level = cl->level; 1097 opt.level = cl->level;
1094 NLA_PUT(skb, TCA_HTB_PARMS, sizeof(opt), &opt); 1098 NLA_PUT(skb, TCA_HTB_PARMS, sizeof(opt), &opt);
1095 nla->nla_len = skb_tail_pointer(skb) - b; 1099
1100 nla_nest_end(skb, nest);
1096 spin_unlock_bh(&sch->dev->queue_lock); 1101 spin_unlock_bh(&sch->dev->queue_lock);
1097 return skb->len; 1102 return skb->len;
1103
1098nla_put_failure: 1104nla_put_failure:
1099 spin_unlock_bh(&sch->dev->queue_lock); 1105 spin_unlock_bh(&sch->dev->queue_lock);
1100 nlmsg_trim(skb, b); 1106 nla_nest_cancel(skb, nest);
1101 return -1; 1107 return -1;
1102} 1108}
1103 1109