netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: xiyou.wangcong@gmail.com
Cc: netdev@vger.kernel.org, jhs@mojatatu.com, cwang@twopensource.com
Subject: Re: [Patch net] net_sched: avoid generating same handle for u32 filters
Date: Sun, 20 Jul 2014 20:49:53 -0700 (PDT)	[thread overview]
Message-ID: <20140720.204953.867212897376669839.davem@davemloft.net> (raw)
In-Reply-To: <1405643693-4880-1-git-send-email-xiyou.wangcong@gmail.com>

From: Cong Wang <xiyou.wangcong@gmail.com>
Date: Thu, 17 Jul 2014 17:34:53 -0700

> From: Cong Wang <cwang@twopensource.com>
> 
> When kernel generates a handle for a u32 filter, it tries to start
> from the max in the bucket. So when we have a filter with the max (fff)
> handle, it will cause kernel always generates the same handle for new
> filters. This can be shown by the following command:
> 
> 	tc qdisc add dev eth0 ingress
> 	tc filter add dev eth0 parent ffff: protocol ip pref 770 handle 800::fff u32 match ip protocol 1 0xff
> 	tc filter add dev eth0 parent ffff: protocol ip pref 770 u32 match ip protocol 1 0xff
> 	...
> 
> we will get some u32 filters with same handle:
> 
>  # tc filter show dev eth0 parent ffff:
> filter protocol ip pref 770 u32 
> filter protocol ip pref 770 u32 fh 800: ht divisor 1 
> filter protocol ip pref 770 u32 fh 800::fff order 4095 key ht 800 bkt 0 
>   match 00010000/00ff0000 at 8
> filter protocol ip pref 770 u32 fh 800::fff order 4095 key ht 800 bkt 0 
>   match 00010000/00ff0000 at 8
> filter protocol ip pref 770 u32 fh 800::fff order 4095 key ht 800 bkt 0 
>   match 00010000/00ff0000 at 8
> filter protocol ip pref 770 u32 fh 800::fff order 4095 key ht 800 bkt 0 
>   match 00010000/00ff0000 at 8
> 
> handles should be unique. This patch fixes it by looking up a bitmap,
> so that can guarantee the handle is as unique as possible. For compatibility,
> we still start from 0x800.
> 
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Jamal Hadi Salim <jhs@mojatatu.com>
> Signed-off-by: Cong Wang <cwang@twopensource.com>
> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>

Applied, thank you.

      parent reply	other threads:[~2014-07-21  3:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-18  0:34 [Patch net] net_sched: avoid generating same handle for u32 filters Cong Wang
2014-07-19 22:07 ` Jamal Hadi Salim
2014-07-19 22:15   ` Cong Wang
2014-07-20 16:20     ` Jamal Hadi Salim
2014-07-21  3:49       ` David Miller
2014-07-21  3:49 ` David Miller [this message]

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=20140720.204953.867212897376669839.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=cwang@twopensource.com \
    --cc=jhs@mojatatu.com \
    --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 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).