aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched/act_police.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/sched/act_police.c')
-rw-r--r--net/sched/act_police.c52
1 files changed, 26 insertions, 26 deletions
diff --git a/net/sched/act_police.c b/net/sched/act_police.c
index 07ffdf9c5e59..3af5759aac26 100644
--- a/net/sched/act_police.c
+++ b/net/sched/act_police.c
@@ -54,7 +54,7 @@ static int tcf_act_police_walker(struct sk_buff *skb, struct netlink_callback *c
54{ 54{
55 struct tcf_common *p; 55 struct tcf_common *p;
56 int err = 0, index = -1, i = 0, s_i = 0, n_i = 0; 56 int err = 0, index = -1, i = 0, s_i = 0, n_i = 0;
57 struct rtattr *r; 57 struct nlattr *r;
58 58
59 read_lock_bh(&police_lock); 59 read_lock_bh(&police_lock);
60 60
@@ -69,8 +69,8 @@ static int tcf_act_police_walker(struct sk_buff *skb, struct netlink_callback *c
69 continue; 69 continue;
70 a->priv = p; 70 a->priv = p;
71 a->order = index; 71 a->order = index;
72 r = (struct rtattr *)skb_tail_pointer(skb); 72 r = (struct nlattr *)skb_tail_pointer(skb);
73 RTA_PUT(skb, a->order, 0, NULL); 73 NLA_PUT(skb, a->order, 0, NULL);
74 if (type == RTM_DELACTION) 74 if (type == RTM_DELACTION)
75 err = tcf_action_dump_1(skb, a, 0, 1); 75 err = tcf_action_dump_1(skb, a, 0, 1);
76 else 76 else
@@ -80,7 +80,7 @@ static int tcf_act_police_walker(struct sk_buff *skb, struct netlink_callback *c
80 nlmsg_trim(skb, r); 80 nlmsg_trim(skb, r);
81 goto done; 81 goto done;
82 } 82 }
83 r->rta_len = skb_tail_pointer(skb) - (u8 *)r; 83 r->nla_len = skb_tail_pointer(skb) - (u8 *)r;
84 n_i++; 84 n_i++;
85 } 85 }
86 } 86 }
@@ -90,7 +90,7 @@ done:
90 cb->args[0] += n_i; 90 cb->args[0] += n_i;
91 return n_i; 91 return n_i;
92 92
93rtattr_failure: 93nla_put_failure:
94 nlmsg_trim(skb, r); 94 nlmsg_trim(skb, r);
95 goto done; 95 goto done;
96} 96}
@@ -118,32 +118,32 @@ static void tcf_police_destroy(struct tcf_police *p)
118 BUG_TRAP(0); 118 BUG_TRAP(0);
119} 119}
120 120
121static int tcf_act_police_locate(struct rtattr *rta, struct rtattr *est, 121static int tcf_act_police_locate(struct nlattr *nla, struct nlattr *est,
122 struct tc_action *a, int ovr, int bind) 122 struct tc_action *a, int ovr, int bind)
123{ 123{
124 unsigned h; 124 unsigned h;
125 int ret = 0, err; 125 int ret = 0, err;
126 struct rtattr *tb[TCA_POLICE_MAX]; 126 struct nlattr *tb[TCA_POLICE_MAX + 1];
127 struct tc_police *parm; 127 struct tc_police *parm;
128 struct tcf_police *police; 128 struct tcf_police *police;
129 struct qdisc_rate_table *R_tab = NULL, *P_tab = NULL; 129 struct qdisc_rate_table *R_tab = NULL, *P_tab = NULL;
130 int size; 130 int size;
131 131
132 if (rta == NULL || rtattr_parse_nested(tb, TCA_POLICE_MAX, rta) < 0) 132 if (nla == NULL || nla_parse_nested(tb, TCA_POLICE_MAX, nla, NULL) < 0)
133 return -EINVAL; 133 return -EINVAL;
134 134
135 if (tb[TCA_POLICE_TBF-1] == NULL) 135 if (tb[TCA_POLICE_TBF] == NULL)
136 return -EINVAL; 136 return -EINVAL;
137 size = RTA_PAYLOAD(tb[TCA_POLICE_TBF-1]); 137 size = nla_len(tb[TCA_POLICE_TBF]);
138 if (size != sizeof(*parm) && size != sizeof(struct tc_police_compat)) 138 if (size != sizeof(*parm) && size != sizeof(struct tc_police_compat))
139 return -EINVAL; 139 return -EINVAL;
140 parm = RTA_DATA(tb[TCA_POLICE_TBF-1]); 140 parm = nla_data(tb[TCA_POLICE_TBF]);
141 141
142 if (tb[TCA_POLICE_RESULT-1] != NULL && 142 if (tb[TCA_POLICE_RESULT] != NULL &&
143 RTA_PAYLOAD(tb[TCA_POLICE_RESULT-1]) != sizeof(u32)) 143 nla_len(tb[TCA_POLICE_RESULT]) != sizeof(u32))
144 return -EINVAL; 144 return -EINVAL;
145 if (tb[TCA_POLICE_RESULT-1] != NULL && 145 if (tb[TCA_POLICE_RESULT] != NULL &&
146 RTA_PAYLOAD(tb[TCA_POLICE_RESULT-1]) != sizeof(u32)) 146 nla_len(tb[TCA_POLICE_RESULT]) != sizeof(u32))
147 return -EINVAL; 147 return -EINVAL;
148 148
149 if (parm->index) { 149 if (parm->index) {
@@ -174,12 +174,12 @@ static int tcf_act_police_locate(struct rtattr *rta, struct rtattr *est,
174override: 174override:
175 if (parm->rate.rate) { 175 if (parm->rate.rate) {
176 err = -ENOMEM; 176 err = -ENOMEM;
177 R_tab = qdisc_get_rtab(&parm->rate, (struct nlattr *)tb[TCA_POLICE_RATE-1]); 177 R_tab = qdisc_get_rtab(&parm->rate, tb[TCA_POLICE_RATE]);
178 if (R_tab == NULL) 178 if (R_tab == NULL)
179 goto failure; 179 goto failure;
180 if (parm->peakrate.rate) { 180 if (parm->peakrate.rate) {
181 P_tab = qdisc_get_rtab(&parm->peakrate, 181 P_tab = qdisc_get_rtab(&parm->peakrate,
182 (struct nlattr *)tb[TCA_POLICE_PEAKRATE-1]); 182 tb[TCA_POLICE_PEAKRATE]);
183 if (P_tab == NULL) { 183 if (P_tab == NULL) {
184 qdisc_put_rtab(R_tab); 184 qdisc_put_rtab(R_tab);
185 goto failure; 185 goto failure;
@@ -197,8 +197,8 @@ override:
197 police->tcfp_P_tab = P_tab; 197 police->tcfp_P_tab = P_tab;
198 } 198 }
199 199
200 if (tb[TCA_POLICE_RESULT-1]) 200 if (tb[TCA_POLICE_RESULT])
201 police->tcfp_result = *(u32*)RTA_DATA(tb[TCA_POLICE_RESULT-1]); 201 police->tcfp_result = *(u32*)nla_data(tb[TCA_POLICE_RESULT]);
202 police->tcfp_toks = police->tcfp_burst = parm->burst; 202 police->tcfp_toks = police->tcfp_burst = parm->burst;
203 police->tcfp_mtu = parm->mtu; 203 police->tcfp_mtu = parm->mtu;
204 if (police->tcfp_mtu == 0) { 204 if (police->tcfp_mtu == 0) {
@@ -210,13 +210,13 @@ override:
210 police->tcfp_ptoks = L2T_P(police, police->tcfp_mtu); 210 police->tcfp_ptoks = L2T_P(police, police->tcfp_mtu);
211 police->tcf_action = parm->action; 211 police->tcf_action = parm->action;
212 212
213 if (tb[TCA_POLICE_AVRATE-1]) 213 if (tb[TCA_POLICE_AVRATE])
214 police->tcfp_ewma_rate = 214 police->tcfp_ewma_rate =
215 *(u32*)RTA_DATA(tb[TCA_POLICE_AVRATE-1]); 215 *(u32*)nla_data(tb[TCA_POLICE_AVRATE]);
216 if (est) 216 if (est)
217 gen_replace_estimator(&police->tcf_bstats, 217 gen_replace_estimator(&police->tcf_bstats,
218 &police->tcf_rate_est, 218 &police->tcf_rate_est,
219 &police->tcf_lock, (struct nlattr *)est); 219 &police->tcf_lock, est);
220 220
221 spin_unlock_bh(&police->tcf_lock); 221 spin_unlock_bh(&police->tcf_lock);
222 if (ret != ACT_P_CREATED) 222 if (ret != ACT_P_CREATED)
@@ -332,15 +332,15 @@ tcf_act_police_dump(struct sk_buff *skb, struct tc_action *a, int bind, int ref)
332 opt.peakrate = police->tcfp_P_tab->rate; 332 opt.peakrate = police->tcfp_P_tab->rate;
333 else 333 else
334 memset(&opt.peakrate, 0, sizeof(opt.peakrate)); 334 memset(&opt.peakrate, 0, sizeof(opt.peakrate));
335 RTA_PUT(skb, TCA_POLICE_TBF, sizeof(opt), &opt); 335 NLA_PUT(skb, TCA_POLICE_TBF, sizeof(opt), &opt);
336 if (police->tcfp_result) 336 if (police->tcfp_result)
337 RTA_PUT(skb, TCA_POLICE_RESULT, sizeof(int), 337 NLA_PUT(skb, TCA_POLICE_RESULT, sizeof(int),
338 &police->tcfp_result); 338 &police->tcfp_result);
339 if (police->tcfp_ewma_rate) 339 if (police->tcfp_ewma_rate)
340 RTA_PUT(skb, TCA_POLICE_AVRATE, 4, &police->tcfp_ewma_rate); 340 NLA_PUT(skb, TCA_POLICE_AVRATE, 4, &police->tcfp_ewma_rate);
341 return skb->len; 341 return skb->len;
342 342
343rtattr_failure: 343nla_put_failure:
344 nlmsg_trim(skb, b); 344 nlmsg_trim(skb, b);
345 return -1; 345 return -1;
346} 346}