From: Daniel Salzman Date: Fri, 15 Oct 2021 12:38:04 +0000 (+0200) Subject: mod-stats: add tcp4-xdp and tcp6-xdp protocol counters X-Git-Tag: v3.3.dev~308 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f2d5bbf6121479c8a6b7f37d27203fa602e36f05;p=thirdparty%2Fknot-dns.git mod-stats: add tcp4-xdp and tcp6-xdp protocol counters --- diff --git a/src/knot/modules/stats/stats.c b/src/knot/modules/stats/stats.c index cedbd144ce..cc9caf5f30 100644 --- a/src/knot/modules/stats/stats.c +++ b/src/knot/modules/stats/stats.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2020 CZ.NIC, z.s.p.o. +/* Copyright (C) 2021 CZ.NIC, z.s.p.o. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -120,7 +120,9 @@ enum { PROTOCOL_UDP6, PROTOCOL_TCP6, PROTOCOL_UDP4_XDP, + PROTOCOL_TCP4_XDP, PROTOCOL_UDP6_XDP, + PROTOCOL_TCP6_XDP, PROTOCOL__COUNT }; @@ -132,7 +134,9 @@ static char *protocol_to_str(uint32_t idx, uint32_t count) case PROTOCOL_UDP6: return strdup("udp6"); case PROTOCOL_TCP6: return strdup("tcp6"); case PROTOCOL_UDP4_XDP: return strdup("udp4-xdp"); + case PROTOCOL_TCP4_XDP: return strdup("tcp4-xdp"); case PROTOCOL_UDP6_XDP: return strdup("udp6-xdp"); + case PROTOCOL_TCP6_XDP: return strdup("tcp6-xdp"); default: assert(0); return NULL; } } @@ -502,8 +506,13 @@ static knotd_state_t update_counters(knotd_state_t state, knot_pkt_t *pkt, PROTOCOL_UDP4, 1); } } else { - knotd_mod_stats_incr(mod, tid, CTR_PROTOCOL, - PROTOCOL_TCP4, 1); + if (xdp) { + knotd_mod_stats_incr(mod, tid, CTR_PROTOCOL, + PROTOCOL_TCP4_XDP, 1); + } else { + knotd_mod_stats_incr(mod, tid, CTR_PROTOCOL, + PROTOCOL_TCP4, 1); + } } } else { if (qdata->params->flags & KNOTD_QUERY_FLAG_LIMIT_SIZE) { @@ -515,8 +524,13 @@ static knotd_state_t update_counters(knotd_state_t state, knot_pkt_t *pkt, PROTOCOL_UDP6, 1); } } else { - knotd_mod_stats_incr(mod, tid, CTR_PROTOCOL, - PROTOCOL_TCP6, 1); + if (xdp) { + knotd_mod_stats_incr(mod, tid, CTR_PROTOCOL, + PROTOCOL_TCP6_XDP, 1); + } else { + knotd_mod_stats_incr(mod, tid, CTR_PROTOCOL, + PROTOCOL_TCP6, 1); + } } } } diff --git a/src/knot/modules/stats/stats.rst b/src/knot/modules/stats/stats.rst index cb467a5914..6b7c4f9579 100644 --- a/src/knot/modules/stats/stats.rst +++ b/src/knot/modules/stats/stats.rst @@ -75,7 +75,9 @@ If enabled, all incoming requests are counted by the network protocol: * udp6 - UDP over IPv6 * tcp6 - TCP over IPv6 * udp4-xdp - UDP over IPv4 through XDP +* tcp4-xdp - TCP over IPv4 through XDP * udp6-xdp - UDP over IPv6 through XDP +* tcp6-xdp - TCP over IPv6 through XDP *Default:* on