On Tue, Sep 27, 2016 at 12:15 AM, Liping Zhang <zlpnob...@gmail.com> wrote:
> Hi Vishwanath,
>
> 2016-09-23 0:43 GMT+08:00 Vishwanath Pai <v...@akamai.com>:
>>
>>  /* Precision saver. */
>> -static u32 user2credits(u32 user)
>> +static u64 user2credits(u64 user, int revision)
>>  {
>> -       /* If multiplying would overflow... */
>> -       if (user > 0xFFFFFFFF / (HZ*CREDITS_PER_JIFFY_v1))
>> -               /* Divide first. */
>> -               return (user / XT_HASHLIMIT_SCALE_v1) *\
>> -                                       HZ * CREDITS_PER_JIFFY_v1;
>> +       if (revision == 1) {
>> +               /* If multiplying would overflow... */
>> +               if (user > 0xFFFFFFFF / (HZ*CREDITS_PER_JIFFY_v1))
>> +                       /* Divide first. */
>> +                       return (user / XT_HASHLIMIT_SCALE_v1) *\
>> +                                               HZ * CREDITS_PER_JIFFY_v1;
>> +
>> +               return (user * HZ * CREDITS_PER_JIFFY_v1) \
>> +                                               / XT_HASHLIMIT_SCALE_v1;
>> +       } else {
>> +               if (user > 0xFFFFFFFFFFFFFFFF / (HZ*CREDITS_PER_JIFFY))
>> +                       return (user / XT_HASHLIMIT_SCALE) *\
>> +                                               HZ * CREDITS_PER_JIFFY;
>>
>> -       return (user * HZ * CREDITS_PER_JIFFY_v1) / XT_HASHLIMIT_SCALE_v1;
>> +               return (user * HZ * CREDITS_PER_JIFFY) / XT_HASHLIMIT_SCALE;
>> +       }
>>  }
>>
>
> In my memory, 64-bit division operation should be replaced by
> div_u64 or div64_u64, otherwise on some 32-bit architecture
> systems, link error will happen. Something like this:
> ... undefined reference to `__udivdi3'.

I did not know that, thanks for pointing it out. I will send a patch
to fix this.

-Vishwanath
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to