All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Aring <aring@mojatatu.com>
To: jhs@mojatatu.com
Cc: xiyou.wangcong@gmail.com, jiri@resnulli.us,
	netdev@vger.kernel.org, eric.dumazet@gmail.com, bjb@mojatatu.com,
	Alexander Aring <aring@mojatatu.com>
Subject: [PATCH net-next 1/3] sched: act: ife: move encode/decode check to init
Date: Wed, 11 Oct 2017 17:16:06 -0400	[thread overview]
Message-ID: <20171011211608.22692-2-aring@mojatatu.com> (raw)
In-Reply-To: <20171011211608.22692-1-aring@mojatatu.com>

This patch adds the check of the two possible ife handlings encode
and decode to the init callback. The decode value is for usability
aspect and used in userspace code only. The current code offers encode
else decode only. This patch avoids any other option than this.

Signed-off-by: Alexander Aring <aring@mojatatu.com>
---
 net/sched/act_ife.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/net/sched/act_ife.c b/net/sched/act_ife.c
index 8ccd35825b6b..efac8a32c30a 100644
--- a/net/sched/act_ife.c
+++ b/net/sched/act_ife.c
@@ -450,6 +450,13 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla,
 
 	parm = nla_data(tb[TCA_IFE_PARMS]);
 
+	/* IFE_DECODE is 0 and indicates the opposite of IFE_ENCODE because
+	 * they cannot run as the same time. Check on all other values which
+	 * are not supported right now.
+	 */
+	if (parm->flags & ~IFE_ENCODE)
+		return -EINVAL;
+
 	exists = tcf_idr_check(tn, parm->index, a, bind);
 	if (exists && bind)
 		return 0;
@@ -772,17 +779,7 @@ static int tcf_ife_act(struct sk_buff *skb, const struct tc_action *a,
 	if (ife->flags & IFE_ENCODE)
 		return tcf_ife_encode(skb, a, res);
 
-	if (!(ife->flags & IFE_ENCODE))
-		return tcf_ife_decode(skb, a, res);
-
-	pr_info_ratelimited("unknown failure(policy neither de/encode\n");
-	spin_lock(&ife->tcf_lock);
-	bstats_update(&ife->tcf_bstats, skb);
-	tcf_lastuse_update(&ife->tcf_tm);
-	ife->tcf_qstats.drops++;
-	spin_unlock(&ife->tcf_lock);
-
-	return TC_ACT_SHOT;
+	return tcf_ife_decode(skb, a, res);
 }
 
 static int tcf_ife_walker(struct net *net, struct sk_buff *skb,
-- 
2.11.0

  reply	other threads:[~2017-10-11 21:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-11 21:16 [PATCH net-next 0/3] sched: act: ife: UAPI checks and performance tweaks Alexander Aring
2017-10-11 21:16 ` Alexander Aring [this message]
2017-10-13  1:38   ` [PATCH net-next 1/3] sched: act: ife: move encode/decode check to init Jamal Hadi Salim
2017-10-11 21:16 ` [PATCH net-next 2/3] sched: act: ife: migrate to use per-cpu counters Alexander Aring
2017-10-13  1:39   ` Jamal Hadi Salim
2017-10-11 21:16 ` [PATCH net-next 3/3] sched: act: ife: update parameters via rcu handling Alexander Aring
2017-10-13  1:39   ` Jamal Hadi Salim
2017-10-13  5:23 ` [PATCH net-next 0/3] sched: act: ife: UAPI checks and performance tweaks David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171011211608.22692-2-aring@mojatatu.com \
    --to=aring@mojatatu.com \
    --cc=bjb@mojatatu.com \
    --cc=eric.dumazet@gmail.com \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=netdev@vger.kernel.org \
    --cc=xiyou.wangcong@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.