diff options
author | Jiri Pirko <jiri@mellanox.com> | 2017-05-17 11:07:57 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-05-17 15:22:13 -0400 |
commit | 9d36d9e545dce53c6fff046b277c261d6568c5b9 (patch) | |
tree | e13507fc16211a3f250a674ee8ea9b80838b1405 /net | |
parent | fbe9c5b01f97b44b1e4c7d86c092beaf707d4b9d (diff) | |
download | linux-9d36d9e545dce53c6fff046b277c261d6568c5b9.tar.bz2 |
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')
-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, struct tcmsg *t; u32 protocol; u32 prio; - u32 nprio; + bool prio_allocate; u32 parent; struct net_device *dev; struct Qdisc *q; @@ -306,7 +306,7 @@ replay: t = nlmsg_data(n); protocol = TC_H_MIN(t->tcm_info); prio = TC_H_MAJ(t->tcm_info); - nprio = prio; + prio_allocate = false; parent = t->tcm_parent; cl = 0; @@ -322,6 +322,7 @@ replay: */ if (n->nlmsg_flags & NLM_F_CREATE) { prio = TC_H_MAKE(0x80000000U, 0U); + prio_allocate = true; break; } /* fall-through */ @@ -383,7 +384,7 @@ replay: back = &tp->next) { if (tp->prio >= prio) { if (tp->prio == prio) { - if (!nprio || + if (prio_allocate || (tp->protocol != protocol && protocol)) { err = -EINVAL; goto errout; @@ -409,11 +410,11 @@ replay: goto errout; } - if (!nprio) - nprio = TC_H_MAJ(tcf_auto_prio(rtnl_dereference(*back))); + if (prio_allocate) + prio = TC_H_MAJ(tcf_auto_prio(rtnl_dereference(*back))); tp = tcf_proto_create(nla_data(tca[TCA_KIND]), - protocol, nprio, parent, q, block); + protocol, prio, parent, q, block); if (IS_ERR(tp)) { err = PTR_ERR(tp); goto errout; |