summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYASUOKA Masahiko <yasuoka@cvs.openbsd.org>2024-08-16 09:54:22 +0000
committerYASUOKA Masahiko <yasuoka@cvs.openbsd.org>2024-08-16 09:54:22 +0000
commitc50458aaf043fcf1a6035a977b61742ee1c6d5c7 (patch)
tree225b94d10d56ff39e29aba97ae05036880f42a1c
parentaa6230ccfde71eded5ebcabc2862ffda1a0747a0 (diff)
Make sure that the uptime field is always updated. Previously it was
used before initialized when the database has a session.
-rw-r--r--usr.sbin/radiusd/radiusd_ipcp.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/usr.sbin/radiusd/radiusd_ipcp.c b/usr.sbin/radiusd/radiusd_ipcp.c
index 308b0b314d3..27cd3c4bd13 100644
--- a/usr.sbin/radiusd/radiusd_ipcp.c
+++ b/usr.sbin/radiusd/radiusd_ipcp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: radiusd_ipcp.c,v 1.11 2024/08/16 09:52:16 yasuoka Exp $ */
+/* $OpenBSD: radiusd_ipcp.c,v 1.12 2024/08/16 09:54:21 yasuoka Exp $ */
/*
* Copyright (c) 2024 Internet Initiative Japan Inc.
@@ -191,6 +191,7 @@ static void ipcp_put_db(struct module_ipcp *, struct assigned_ipv4 *);
static void ipcp_del_db(struct module_ipcp *, struct assigned_ipv4 *);
static void ipcp_db_dump_fill_record(struct radiusd_ipcp_db_dump *, int,
struct assigned_ipv4 *);
+static void ipcp_update_time(struct module_ipcp *);
static void ipcp_on_timer(int, short, void *);
static void ipcp_schedule_timer(struct module_ipcp *);
static void ipcp_dae_send_disconnect_request(struct assigned_ipv4 *);
@@ -268,6 +269,7 @@ ipcp_init(struct module_ipcp *self)
TAILQ_INIT(&self->daes);
self->seq = 1;
self->no_session_timeout = true;
+ ipcp_update_time(self);
}
void
@@ -278,6 +280,7 @@ ipcp_start(void *ctx)
struct module_ipcp_dae *dae;
int sock;
+ ipcp_update_time(self);
if (self->start_wait == 0)
self->start_wait = RADIUSD_IPCP_START_WAIT;
@@ -323,6 +326,7 @@ ipcp_stop(void *ctx)
struct module_ipcp *self = ctx;
struct module_ipcp_dae *dae;
+ ipcp_update_time(self);
/* stop the sockets for DAE */
TAILQ_FOREACH(dae, &self->daes, next) {
if (dae->sock >= 0) {
@@ -562,6 +566,7 @@ ipcp_dispatch_control(void *ctx, struct imsg *imsg)
struct radiusctl_client *client;
const char *cause;
+ ipcp_update_time(self);
datalen = imsg->hdr.len - IMSG_HEADER_SIZE;
switch (imsg->hdr.type) {
case IMSG_RADIUSD_MODULE_CTRL_UNBIND:
@@ -717,7 +722,7 @@ ipcp_resdeco(void *ctx, u_int q_id, const u_char *req, size_t reqlen,
struct user *user = NULL;
struct assigned_ipv4 *assigned = NULL, *assign;
- clock_gettime(CLOCK_BOOTTIME, &self->uptime);
+ ipcp_update_time(self);
if ((radres = radius_convert_packet(res, reslen)) == NULL) {
log_warn("%s: radius_convert_packet() failed", __func__);
@@ -1008,7 +1013,7 @@ ipcp_accounting_request(void *ctx, u_int q_id, const u_char *pkt,
stat;
struct module_ipcp_dae *dae;
- clock_gettime(CLOCK_BOOTTIME, &self->uptime);
+ ipcp_update_time(self);
if ((radpkt = radius_convert_packet(pkt, pktlen)) == NULL) {
log_warn("%s: radius_convert_packet() failed", __func__);
@@ -1473,11 +1478,17 @@ ipcp_db_dump_fill_record(struct radiusd_ipcp_db_dump *dump, int idx,
* Timer
***********************************************************************/
void
+ipcp_update_time(struct module_ipcp *self)
+{
+ clock_gettime(CLOCK_BOOTTIME, &self->uptime);
+}
+
+void
ipcp_on_timer(int fd, short ev, void *ctx)
{
struct module_ipcp *self = ctx;
- clock_gettime(CLOCK_BOOTTIME, &self->uptime);
+ ipcp_update_time(self);
ipcp_schedule_timer(self);
}
@@ -1606,6 +1617,8 @@ ipcp_dae_on_event(int fd, short ev, void *ctx)
const char *cause = "";
struct radiusctl_client *client;
+ ipcp_update_time(self);
+
if ((ev & EV_READ) == 0)
return;