Thread (7 messages) 7 messages, 5 authors, 2016-09-27

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

flat view

From: Vishwanath Pai <hidden>
Date: 2016-09-27 07:35:15
Also in: netfilter-devel

On Tue, Sep 27, 2016 at 12:15 AM, Liping Zhang [off-list ref] wrote:
Hi Vishwanath,

2016-09-23 0:43 GMT+08:00 Vishwanath Pai [off-list ref]:
quoted

 /* 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help