Hi,
You need to account for subsecond differences when evaluating
a rule rate, otherwise you'll reset f_rate_cnt prematurely in
some cases.
e.g.:
t_now = { .tv_sec = 100, .tv_usec = 250000 };
frame->f_last = { .tv_sec = 99, .tv_usec = 750000 };
frame->f_rate_intval = 1;
/* true */
t_now.tv_sec - frame->f_last.tv_sec >= frame->f_rate_intval
/* and yet ... */
struct timeval t_diff;
timersub(&t_now, &frame->f_last, &t_diff);
/* also true */
t_diff.tv_sec < frame->f_rate_intval
ok?
--
Scott Cheloha
Index: usr.sbin/hostapd/handle.c
===================================================================
RCS file: /cvs/src/usr.sbin/hostapd/handle.c,v
retrieving revision 1.12
diff -u -p -r1.12 handle.c
--- usr.sbin/hostapd/handle.c 16 Jan 2015 06:40:17 -0000 1.12
+++ usr.sbin/hostapd/handle.c 14 Feb 2018 19:34:49 -0000
@@ -114,7 +114,7 @@ hostapd_handle_frame(struct hostapd_apme
struct hostapd_ieee80211_frame *mh;
struct hostapd_radiotap rtap;
u_int8_t *wfrom, *wto, *wbssid;
- struct timeval t_now;
+ struct timeval t_diff, t_now;
u_int32_t flags;
int offset, min_rate = 0, val;
@@ -247,7 +247,8 @@ hostapd_handle_frame(struct hostapd_apme
/* Handle optional minimal rate */
if (frame->f_rate && frame->f_rate_intval) {
- frame->f_rate_delay = t_now.tv_sec - frame->f_last.tv_sec;
+ timersub(&t_now, &frame->f_last, &t_diff);
+ frame->f_rate_delay = t_diff.tv_sec;
if (frame->f_rate_delay < frame->f_rate_intval) {
frame->f_rate_cnt++;
if (frame->f_rate_cnt < frame->f_rate)