Re: tc: u32: Wrong sample hash calculation

2021-01-24 Thread Jamal Hadi Salim
Hi Phil, On 2021-01-22 8:59 a.m., Phil Sutter wrote: Jamal, On Fri, Jan 22, 2021 at 06:25:22AM -0500, Jamal Hadi Salim wrote: [...] My gut feel is user space is the right/easier spot to fix this as long as it doesnt break the working setup of 8b. One last attempt at clarifying the situation:

Re: tc: u32: Wrong sample hash calculation

2021-01-22 Thread Phil Sutter
Jamal, On Fri, Jan 22, 2021 at 06:25:22AM -0500, Jamal Hadi Salim wrote: [...] > My gut feel is user space is the right/easier spot to fix this > as long as it doesnt break the working setup of 8b. One last attempt at clarifying the situation: Back in 2004, your commit 4e54c4816bf ("[NET]: Add t

Re: tc: u32: Wrong sample hash calculation

2021-01-22 Thread Phil Sutter
Hi Jamal, On Fri, Jan 22, 2021 at 06:25:22AM -0500, Jamal Hadi Salim wrote: [...] > Is this always true though for all scenarios of key > 8b? Key size reduction algorithms simply differ, and before applying the divisor the key is reduced to an eight bit value. If the higher bytes are zero, the re

Re: tc: u32: Wrong sample hash calculation

2021-01-22 Thread Jamal Hadi Salim
Hi Phil, On 2021-01-20 10:23 a.m., Phil Sutter wrote: Hi Jamal, On Wed, Jan 20, 2021 at 08:55:11AM -0500, Jamal Hadi Salim wrote: On 2021-01-18 6:29 a.m., Phil Sutter wrote: Hi! Playing with u32 filter's hash table I noticed it is not possible to use 'sample' option with keys larger than 8bi

Re: tc: u32: Wrong sample hash calculation

2021-01-20 Thread Jamal Hadi Salim
Hi, On 2021-01-18 6:29 a.m., Phil Sutter wrote: Hi! Playing with u32 filter's hash table I noticed it is not possible to use 'sample' option with keys larger than 8bits to calculate the hash bucket. I have mostly used something like: ht 2:: sample ip protocol 1 0xff Hoping this is continuin

Re: tc: u32: Wrong sample hash calculation

2021-01-20 Thread Phil Sutter
Hi Jamal, On Wed, Jan 20, 2021 at 08:55:11AM -0500, Jamal Hadi Salim wrote: > On 2021-01-18 6:29 a.m., Phil Sutter wrote: > > Hi! > > > > Playing with u32 filter's hash table I noticed it is not possible to use > > 'sample' option with keys larger than 8bits to calculate the hash > > bucket. >

tc: u32: Wrong sample hash calculation

2021-01-18 Thread Phil Sutter
Hi! Playing with u32 filter's hash table I noticed it is not possible to use 'sample' option with keys larger than 8bits to calculate the hash bucket. Turns out key hashing in kernel and iproute2 differ: * net/sched/cls_u32.c (kernel) basically does: hash = ntohl(key & mask); hash >>= ffs(ntohl(