From: Jan Doskočil Date: Fri, 18 Oct 2024 09:36:37 +0000 (+0200) Subject: kxdpgun: stats_period overflow bugfix X-Git-Tag: v3.5.0~219 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a00da5d234ca981da88c5e7d672fe635669b14da;p=thirdparty%2Fknot-dns.git kxdpgun: stats_period overflow bugfix --- diff --git a/src/utils/kxdpgun/main.c b/src/utils/kxdpgun/main.c index 5e10b6d079..3c036034ae 100644 --- a/src/utils/kxdpgun/main.c +++ b/src/utils/kxdpgun/main.c @@ -77,7 +77,7 @@ const static xdp_gun_ctx_t ctx_defaults = { .flags = KNOT_XDP_FILTER_UDP | KNOT_XDP_FILTER_PASS, .xdp_config = { .ring_size = 2048 }, .jw = NULL, - .stats_period = 0, + .stats_period_ns = 0, }; static void sigterm_handler(int signo) @@ -742,8 +742,8 @@ void *xdp_gun_thread(void *_ctx) uint64_t duration_ns = timer_end_ns(&timer); duration_us = duration_ns / 1000; uint64_t dura_exp = ((local_stats.qry_sent + periodic_stats.qry_sent) * 1000000) / ctx->qps; - if (ctx->thread_id == 0 && ctx->stats_period != 0 && global_stats.collected == 0 - && (duration_ns - (periodic_stats.since - local_stats.since)) >= ctx->stats_period) { + if (ctx->thread_id == 0 && ctx->stats_period_ns != 0 && global_stats.collected == 0 + && (duration_ns - (periodic_stats.since - local_stats.since)) >= ctx->stats_period_ns) { ATOMIC_SET(stats_switch, STATS_PERIODIC); ATOMIC_ADD(stats_trigger, 1); } @@ -1299,7 +1299,7 @@ static bool get_opts(int argc, char *argv[], xdp_gun_ctx_t *ctx) assert(optarg); arg = atoi(optarg); if (arg > 0) { - ctx->stats_period = arg * 1000000; // convert to ns + ctx->stats_period_ns = arg * 1000000ull; // convert to ns } else { ERR2("period must be a positive integer\n"); return false; diff --git a/src/utils/kxdpgun/main.h b/src/utils/kxdpgun/main.h index d87aee8804..d560709570 100644 --- a/src/utils/kxdpgun/main.h +++ b/src/utils/kxdpgun/main.h @@ -62,7 +62,7 @@ typedef struct xdp_gun_ctx { uint64_t qps, duration; uint64_t runid; uint64_t stats_start_us; - uint32_t stats_period; // 0 means no periodic stats + uint64_t stats_period_ns; // 0 means no periodic stats unsigned at_once; uint16_t msgid; uint16_t edns_size; diff --git a/src/utils/kxdpgun/stats.c b/src/utils/kxdpgun/stats.c index f1e4f43497..84b7c0d376 100644 --- a/src/utils/kxdpgun/stats.c +++ b/src/utils/kxdpgun/stats.c @@ -111,8 +111,8 @@ void json_stats_header(const xdp_gun_ctx_t *ctx) jsonw_end(w); jsonw_ulong(w, "time_units_per_sec", 1000000000); - if (ctx->stats_period > 0) { - jsonw_double(w, "stats_interval", ctx->stats_period / 1000.0); + if (ctx->stats_period_ns > 0) { + jsonw_double(w, "stats_interval", ctx->stats_period_ns / 1000000000.0); } // TODO: timeout