Re: [PATCH v3 2/2] netfilter: Create revision 2 of xt_hashlimit to support higher pps rates

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Vishwanath,

2016-09-23 0:43 GMT+08:00 Vishwanath Pai <vpai@xxxxxxxxxx>:
>
>  /* 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'.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux