mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-02-10 00:37:00 +08:00
ensure that stats are only updated if they increase
That is, transferred bytes will not decrease in an update due to miscommunication between main and workers.
This commit is contained in:
@@ -189,7 +189,10 @@ message cookie
|
||||
message sec_auth_session_msg
|
||||
{
|
||||
required bytes sid = 1;
|
||||
optional uint32 uptime = 3; /* on close */
|
||||
/* on close */
|
||||
optional uint32 uptime = 3;
|
||||
optional uint64 bytes_in = 4;
|
||||
optional uint64 bytes_out = 5;
|
||||
}
|
||||
|
||||
message sec_auth_session_reply_msg
|
||||
|
||||
@@ -197,6 +197,10 @@ int session_cmd(main_server_st * s, struct proc_st *proc, unsigned open)
|
||||
|
||||
ireq.uptime = time(0)-proc->conn_time;
|
||||
ireq.has_uptime = 1;
|
||||
ireq.bytes_in = proc->bytes_in;
|
||||
ireq.has_bytes_in = 1;
|
||||
ireq.bytes_out = proc->bytes_out;
|
||||
ireq.has_bytes_out = 1;
|
||||
ireq.sid.data = proc->sid;
|
||||
ireq.sid.len = sizeof(proc->sid);
|
||||
|
||||
|
||||
@@ -366,8 +366,14 @@ int handle_sec_auth_session_cmd(int cfd, sec_mod_st * sec, const SecAuthSessionM
|
||||
}
|
||||
talloc_free(lpool);
|
||||
} else {
|
||||
if (req->has_uptime) {
|
||||
e->stats.uptime = req->uptime;
|
||||
if (req->has_uptime && req->uptime > e->stats.uptime) {
|
||||
e->stats.uptime = req->uptime;
|
||||
}
|
||||
if (req->has_bytes_in && req->bytes_in > e->stats.bytes_in) {
|
||||
e->stats.bytes_in = req->bytes_in;
|
||||
}
|
||||
if (req->has_bytes_out && req->bytes_out > e->stats.bytes_out) {
|
||||
e->stats.bytes_out = req->bytes_out;
|
||||
}
|
||||
del_client_entry(sec, e);
|
||||
}
|
||||
@@ -396,9 +402,13 @@ int handle_sec_auth_stats_cmd(sec_mod_st * sec, const CliStatsMsg * req)
|
||||
return -1;
|
||||
}
|
||||
|
||||
e->stats.bytes_in = req->bytes_in;
|
||||
e->stats.bytes_out = req->bytes_out;
|
||||
e->stats.uptime = req->uptime;
|
||||
/* stats only increase */
|
||||
if (req->bytes_in > e->stats.bytes_in)
|
||||
e->stats.bytes_in = req->bytes_in;
|
||||
if (req->bytes_out > e->stats.bytes_out)
|
||||
e->stats.bytes_out = req->bytes_out;
|
||||
if (req->uptime > e->stats.uptime)
|
||||
e->stats.uptime = req->uptime;
|
||||
|
||||
if (module == NULL || module->session_stats == NULL)
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user