Commit 9d36d9e5 authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller

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: default avatarJiri Pirko <jiri@mellanox.com>
Acked-by: default avatarJamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent fbe9c5b0
...@@ -277,7 +277,7 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n, ...@@ -277,7 +277,7 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n,
struct tcmsg *t; struct tcmsg *t;
u32 protocol; u32 protocol;
u32 prio; u32 prio;
u32 nprio; bool prio_allocate;
u32 parent; u32 parent;
struct net_device *dev; struct net_device *dev;
struct Qdisc *q; struct Qdisc *q;
...@@ -306,7 +306,7 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n, ...@@ -306,7 +306,7 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n,
t = nlmsg_data(n); t = nlmsg_data(n);
protocol = TC_H_MIN(t->tcm_info); protocol = TC_H_MIN(t->tcm_info);
prio = TC_H_MAJ(t->tcm_info); prio = TC_H_MAJ(t->tcm_info);
nprio = prio; prio_allocate = false;
parent = t->tcm_parent; parent = t->tcm_parent;
cl = 0; cl = 0;
...@@ -322,6 +322,7 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n, ...@@ -322,6 +322,7 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n,
*/ */
if (n->nlmsg_flags & NLM_F_CREATE) { if (n->nlmsg_flags & NLM_F_CREATE) {
prio = TC_H_MAKE(0x80000000U, 0U); prio = TC_H_MAKE(0x80000000U, 0U);
prio_allocate = true;
break; break;
} }
/* fall-through */ /* fall-through */
...@@ -383,7 +384,7 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n, ...@@ -383,7 +384,7 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n,
back = &tp->next) { back = &tp->next) {
if (tp->prio >= prio) { if (tp->prio >= prio) {
if (tp->prio == prio) { if (tp->prio == prio) {
if (!nprio || if (prio_allocate ||
(tp->protocol != protocol && protocol)) { (tp->protocol != protocol && protocol)) {
err = -EINVAL; err = -EINVAL;
goto errout; goto errout;
...@@ -409,11 +410,11 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n, ...@@ -409,11 +410,11 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n,
goto errout; goto errout;
} }
if (!nprio) if (prio_allocate)
nprio = TC_H_MAJ(tcf_auto_prio(rtnl_dereference(*back))); prio = TC_H_MAJ(tcf_auto_prio(rtnl_dereference(*back)));
tp = tcf_proto_create(nla_data(tca[TCA_KIND]), tp = tcf_proto_create(nla_data(tca[TCA_KIND]),
protocol, nprio, parent, q, block); protocol, prio, parent, q, block);
if (IS_ERR(tp)) { if (IS_ERR(tp)) {
err = PTR_ERR(tp); err = PTR_ERR(tp);
goto errout; goto errout;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment