All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Vitaly E. Lavrov" <lve@guap.ru>
To: netdev@vger.kernel.org
Cc: jhs@mojatatu.com
Subject: [RFC PATCH] tc filter not show last u32 filter
Date: Tue, 21 Apr 2015 20:53:03 +0300	[thread overview]
Message-ID: <55368E7F.4030005@guap.ru> (raw)

"tc filter show" does not show last U32 filter on 32-bit systems (tested on x86).

Additional condition: filter does not have action and CONFIG_NET_CLS_ACT=y

Example: tc filter add dev eth0 parent 1:0 protocol ip prio 100 u32 match ip dst 10.200.2.2 flowid 1:20

Function tcf_action_copy_stats() returns an error because the (struct tc_action *)a->priv is NULL (for 32bit systems).

The sequence of calls:

u32_dump()
   cls_u32.c:1009 if (tcf_exts_dump_stats(skb, &n->exts) < 0) goto nla_put_failure;

   tcf_exts_dump_stats()
      cls_api.c:606  if (tcf_action_copy_stats(skb, a, 1) < 0) return -1;

      tcf_action_copy_stats()
         act_api.c:604 struct tcf_common *p = a->priv;
         act_api.c:606 if (p == NULL) goto errout; // return -1;

One of variants correcting this error is a verify the existence of action before calling tcf_action_copy_stats().

Patch for kernel 3.18.10

diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index aad6a67..8e7ad61 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -602,9 +602,11 @@ EXPORT_SYMBOL(tcf_exts_dump);
  int tcf_exts_dump_stats(struct sk_buff *skb, struct tcf_exts *exts)
  {
  #ifdef CONFIG_NET_CLS_ACT
-       struct tc_action *a = tcf_exts_first_act(exts);
-       if (tcf_action_copy_stats(skb, a, 1) < 0)
-               return -1;
+       if(tcf_exts_is_available(exts)) {
+               struct tc_action *a = tcf_exts_first_act(exts);
+               if (tcf_action_copy_stats(skb, a, 1) < 0)
+                       return -1;
+       }
  #endif
         return 0;
  }


This will fix the bug 84661 https://bugzilla.kernel.org/show_bug.cgi?id=84661

In 64bit system a->priv is not NULL, but is not a valid pointer, but because of a->type == 0 and
compat_mode == 1 returns a value 0.

"tc filter show dev eth0".
------------------------
tc filter add dev eth0 parent 1:0 protocol ip prio 100 u32 match ip dst 10.200.2.2 flowid 1:20
tc filter add dev eth0 parent 1:0 protocol ip prio 100 u32 match ip dst 10.200.2.3 flowid 1:30
tc filter show dev eth0
....
(1) filter parent 1: protocol ip pref 100 u32 fh 800::800 order 2048 key ht 800 bkt 0 flowid 1:20
   match 0ac80202/ffffffff at 16
(2) filter parent 1: protocol ip pref 100 u32 fh 800::801 order 2049 key ht 800 bkt 0 flowid 1:30
   match 0ac80203/ffffffff at 16
------------------------
64bit system
(1) a->priv == 0x80000800
(2) a->priv == 0x80000801

32bit system
(1) a->priv == 0x0
(2) a->priv == 0x0

I could not understand the reason for this difference between 32-bit and 64-bit systems.

             reply	other threads:[~2015-04-21 18:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-21 17:53 Vitaly E. Lavrov [this message]
2015-04-21 18:17 ` [RFC PATCH] tc filter not show last u32 filter Sergei Shtylyov
2015-04-21 20:07   ` Vitaly E. Lavrov
2015-04-21 20:25     ` Cong Wang

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=55368E7F.4030005@guap.ru \
    --to=lve@guap.ru \
    --cc=jhs@mojatatu.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 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.