Thomas Graf wrote:
* Nicolas DICHTEL <426F42F0.9020609@xxxxxxxxx> 2005-04-27 09:44
Yes I agree, it doesn't really matter what value we return and `bound'
is most likely to be correct. I think we should also fix the unlikely
but still possible case when tv1.tv_usec is slightly smaller than
tv2.tv_usec. I know it is very unlikely but do_gettimeofday really
is not that reliable and we have users which rely on a positive
delta. Can you extend your patch to return abs(delta) for case 0
in PSCHED_TDIFF_SAFE?
Why abs(delta)? It could be above bound, in fact all cases besides
delta_sec > 2 doesn't take care to stay inside [0..bound] at all.
[PKT_SCHED]: Fix range in PSCHED_TDIFF_SAFE to 0..bound
Signed-off-by: Patrick McHardy <kaber@xxxxxxxxx>
---
commit d5f65671be760f33c1c7667f793ed75ad6e6a710
tree 4af3018396f125b0c2601882d924e63a0d74bef4
parent 980207c270e72e2cc6ae7b0de6ea6cd38a726e5b
author Patrick McHardy <kaber@xxxxxxxxx> 1114776755 +0200
committer Patrick McHardy <kaber@xxxxxxxxx> 1114776755 +0200
Index: include/net/pkt_sched.h
===================================================================
--- e38e7620d369bfa898a2e3f6aaf2f04c8826f38e/include/net/pkt_sched.h (mode:100644 sha1:7352e455053cc857e70f0cb1e008eb7adabbe011)
+++ 4af3018396f125b0c2601882d924e63a0d74bef4/include/net/pkt_sched.h (mode:100644 sha1:fcb05a387dbee560d6a0f20b6e8c3c4f1b2d93f1)
@@ -157,7 +157,8 @@
case 1: \
__delta += 1000000; \
case 0: \
- __delta = abs(__delta); \
+ if (__delta > bound || __delta < 0) \
+ __delta = bound; \
} \
__delta; \
})