aboutsummaryrefslogtreecommitdiffstats
path: root/src/ap/accounting.c
diff options
context:
space:
mode:
authorAlan T. DeKok <aland@freeradius.org>2015-06-04 20:53:06 (GMT)
committerJouni Malinen <j@w1.fi>2015-06-06 14:23:43 (GMT)
commitf13e815491de4a522919569a696ff679f8c15419 (patch)
tree27f9b4b73c17516aa6d42c113aa85f921cc4337c /src/ap/accounting.c
parent92f190a0acf1d8cfd5fddf12b7c2034a7f37b16a (diff)
downloadhostap-f13e815491de4a522919569a696ff679f8c15419.zip
hostap-f13e815491de4a522919569a696ff679f8c15419.tar.gz
hostap-f13e815491de4a522919569a696ff679f8c15419.tar.bz2
Set Acct-Session-Id from os_get_random() instead of os_get_time()
So that systems with bad clocks will send random session IDs, instead of always ones starting at the same second. If os_get_random() isn't available, use os_get_time(). But also mix in now.tv_usec, so that the accounting session ID is more likely to be globally and temporally unique. Signed-off-by: Alan DeKok <aland@freeradius.org>
Diffstat (limited to 'src/ap/accounting.c')
-rw-r--r--src/ap/accounting.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/ap/accounting.c b/src/ap/accounting.c
index 7c55146..3312034 100644
--- a/src/ap/accounting.c
+++ b/src/ap/accounting.c
@@ -459,10 +459,14 @@ int accounting_init(struct hostapd_data *hapd)
{
struct os_time now;
- /* Acct-Session-Id should be unique over reboots. If reliable clock is
- * not available, this could be replaced with reboot counter, etc. */
+ /* Acct-Session-Id should be unique over reboots. Using a random number
+ * is preferred. If that is not available, take the current time. Mix
+ * in microseconds to make this more likely to be unique. */
os_get_time(&now);
- hapd->acct_session_id_hi = now.sec;
+ if (os_get_random((u8 *) &hapd->acct_session_id_hi,
+ sizeof(hapd->acct_session_id_hi)) < 0)
+ hapd->acct_session_id_hi = now.sec;
+ hapd->acct_session_id_hi ^= now.usec;
if (radius_client_register(hapd->radius, RADIUS_ACCT,
accounting_receive, hapd))