netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexei Starovoitov <ast@plumgrid.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>,
	Jamal Hadi Salim <jhs@mojatatu.com>,
	John Fastabend <john.r.fastabend@intel.com>,
	netdev@vger.kernel.org
Subject: [RFC 1/3] tc: fix return values of ingress qdisc
Date: Tue, 21 Apr 2015 12:27:54 -0700	[thread overview]
Message-ID: <1429644476-8914-2-git-send-email-ast@plumgrid.com> (raw)
In-Reply-To: <1429644476-8914-1-git-send-email-ast@plumgrid.com>

ingress qdisc should return NET_XMIT_* values just like all other qdiscs.

Since it's invoked via qdisc_enqueue_root() (which suppose to return
only NET_XMIT_* values as well), it was working by accident,
since TC_ACT_* values fit within NET_XMIT_MASK.

Signed-off-by: Alexei Starovoitov <ast@plumgrid.com>
---
 net/core/dev.c          |    8 ++------
 net/sched/sch_ingress.c |    9 ++++-----
 2 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index 1796cef55ab5..ac6233f6f353 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3533,7 +3533,7 @@ static int ing_filter(struct sk_buff *skb, struct netdev_queue *rxq)
 {
 	struct net_device *dev = skb->dev;
 	u32 ttl = G_TC_RTTL(skb->tc_verd);
-	int result = TC_ACT_OK;
+	int result = NET_XMIT_SUCCESS;
 	struct Qdisc *q;
 
 	if (unlikely(MAX_RED_LOOP < ttl++)) {
@@ -3570,12 +3570,8 @@ static inline struct sk_buff *handle_ing(struct sk_buff *skb,
 		*pt_prev = NULL;
 	}
 
-	switch (ing_filter(skb, rxq)) {
-	case TC_ACT_SHOT:
-	case TC_ACT_STOLEN:
-		kfree_skb(skb);
+	if (ing_filter(skb, rxq) == NET_XMIT_DROP)
 		return NULL;
-	}
 
 	return skb;
 }
diff --git a/net/sched/sch_ingress.c b/net/sched/sch_ingress.c
index 4cdbfb85686a..e68f4a5dbeba 100644
--- a/net/sched/sch_ingress.c
+++ b/net/sched/sch_ingress.c
@@ -65,21 +65,20 @@ static int ingress_enqueue(struct sk_buff *skb, struct Qdisc *sch)
 
 	result = tc_classify(skb, fl, &res);
 
-	qdisc_bstats_update(sch, skb);
 	switch (result) {
 	case TC_ACT_SHOT:
-		result = TC_ACT_SHOT;
 		qdisc_qstats_drop(sch);
-		break;
 	case TC_ACT_STOLEN:
 	case TC_ACT_QUEUED:
-		result = TC_ACT_STOLEN;
+		result = NET_XMIT_DROP;
+		kfree_skb(skb);
 		break;
 	case TC_ACT_RECLASSIFY:
 	case TC_ACT_OK:
 		skb->tc_index = TC_H_MIN(res.classid);
 	default:
-		result = TC_ACT_OK;
+		qdisc_bstats_update(sch, skb);
+		result = NET_XMIT_SUCCESS;
 		break;
 	}
 
-- 
1.7.9.5

  reply	other threads:[~2015-04-21 19:28 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-21 19:27 [RFC 0/3] tc cleanup? Alexei Starovoitov
2015-04-21 19:27 ` Alexei Starovoitov [this message]
2015-04-22  4:59   ` [RFC 1/3] tc: fix return values of ingress qdisc Cong Wang
2015-04-22 22:04     ` Alexei Starovoitov
2015-04-22 23:29       ` Cong Wang
2015-04-23  8:46         ` Thomas Graf
2015-04-21 19:27 ` [RFC 2/3] tc: deprecate TC_ACT_QUEUED Alexei Starovoitov
2015-04-22  5:02   ` Cong Wang
2015-04-22  7:43     ` Daniel Borkmann
2015-04-22 22:22     ` Alexei Starovoitov
2015-04-22 23:39       ` Cong Wang
2015-04-23  2:46         ` Alexei Starovoitov
2015-04-23  7:13           ` Daniel Borkmann
2015-04-23 18:12           ` Cong Wang
2015-04-23 18:21             ` Daniel Borkmann
2015-04-23 18:30               ` Cong Wang
2015-04-23 20:45       ` Jamal Hadi Salim
2015-04-23 21:20         ` Florian Westphal
2015-04-23 22:13         ` Alexei Starovoitov
2015-04-23 22:33           ` Cong Wang
2015-04-23 22:51           ` Jamal Hadi Salim
2015-04-24  0:59             ` Alexei Starovoitov
2015-04-24  3:37               ` Cong Wang
2015-04-24  8:12                 ` Daniel Borkmann
2015-04-27 12:31               ` Jamal Hadi Salim
2015-04-21 19:27 ` [RFC 3/3] tc: cleanup tc_classify Alexei Starovoitov
2015-04-22  5:05   ` Cong Wang
2015-04-22 22:27     ` Alexei Starovoitov
2015-04-22 23:38       ` Cong Wang
2015-04-23  8:49         ` Thomas Graf

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=1429644476-8914-2-git-send-email-ast@plumgrid.com \
    --to=ast@plumgrid.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jhs@mojatatu.com \
    --cc=john.r.fastabend@intel.com \
    --cc=netdev@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).