diff options
author | Jiri Pirko <jiri@mellanox.com> | 2017-05-17 05:07:57 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-05-17 15:22:13 -0400 |
commit | 9d36d9e545dce53c6fff046b277c261d6568c5b9 (patch) | |
tree | e13507fc16211a3f250a674ee8ea9b80838b1405 /net/sched/cls_api.c | |
parent | fbe9c5b01f97b44b1e4c7d86c092beaf707d4b9d (diff) |
net: sched: replace nprio by a bool to make the function more readable
The use of "nprio" variable in tc_ctl_tfilter is a bit cryptic and makes
a reader wonder what is going on for a while. So help him to understand
this priority allocation dance a litte bit better.
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched/cls_api.c')
-rw-r--r-- | net/sched/cls_api.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index c02b03e0b39e..bf2e59cc1174 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c | |||
@@ -277,7 +277,7 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n, | |||
277 | struct tcmsg *t; | 277 | struct tcmsg *t; |
278 | u32 protocol; | 278 | u32 protocol; |
279 | u32 prio; | 279 | u32 prio; |
280 | u32 nprio; | 280 | bool prio_allocate; |
281 | u32 parent; | 281 | u32 parent; |
282 | struct net_device *dev; | 282 | struct net_device *dev; |
283 | struct Qdisc *q; | 283 | struct Qdisc *q; |
@@ -306,7 +306,7 @@ replay: | |||
306 | t = nlmsg_data(n); | 306 | t = nlmsg_data(n); |
307 | protocol = TC_H_MIN(t->tcm_info); | 307 | protocol = TC_H_MIN(t->tcm_info); |
308 | prio = TC_H_MAJ(t->tcm_info); | 308 | prio = TC_H_MAJ(t->tcm_info); |
309 | nprio = prio; | 309 | prio_allocate = false; |
310 | parent = t->tcm_parent; | 310 | parent = t->tcm_parent; |
311 | cl = 0; | 311 | cl = 0; |
312 | 312 | ||
@@ -322,6 +322,7 @@ replay: | |||
322 | */ | 322 | */ |
323 | if (n->nlmsg_flags & NLM_F_CREATE) { | 323 | if (n->nlmsg_flags & NLM_F_CREATE) { |
324 | prio = TC_H_MAKE(0x80000000U, 0U); | 324 | prio = TC_H_MAKE(0x80000000U, 0U); |
325 | prio_allocate = true; | ||
325 | break; | 326 | break; |
326 | } | 327 | } |
327 | /* fall-through */ | 328 | /* fall-through */ |
@@ -383,7 +384,7 @@ replay: | |||
383 | back = &tp->next) { | 384 | back = &tp->next) { |
384 | if (tp->prio >= prio) { | 385 | if (tp->prio >= prio) { |
385 | if (tp->prio == prio) { | 386 | if (tp->prio == prio) { |
386 | if (!nprio || | 387 | if (prio_allocate || |
387 | (tp->protocol != protocol && protocol)) { | 388 | (tp->protocol != protocol && protocol)) { |
388 | err = -EINVAL; | 389 | err = -EINVAL; |
389 | goto errout; | 390 | goto errout; |
@@ -409,11 +410,11 @@ replay: | |||
409 | goto errout; | 410 | goto errout; |
410 | } | 411 | } |
411 | 412 | ||
412 | if (!nprio) | 413 | if (prio_allocate) |
413 | nprio = TC_H_MAJ(tcf_auto_prio(rtnl_dereference(*back))); | 414 | prio = TC_H_MAJ(tcf_auto_prio(rtnl_dereference(*back))); |
414 | 415 | ||
415 | tp = tcf_proto_create(nla_data(tca[TCA_KIND]), | 416 | tp = tcf_proto_create(nla_data(tca[TCA_KIND]), |
416 | protocol, nprio, parent, q, block); | 417 | protocol, prio, parent, q, block); |
417 | if (IS_ERR(tp)) { | 418 | if (IS_ERR(tp)) { |
418 | err = PTR_ERR(tp); | 419 | err = PTR_ERR(tp); |
419 | goto errout; | 420 | goto errout; |