From a64be51391dd0bc618366574823566e0b4b76935 Mon Sep 17 00:00:00 2001 From: Robert Lubos Date: Tue, 10 Jan 2023 12:43:21 +0100 Subject: [PATCH] net: stats: Fix UDP packet counter for DHCPv4 TX Fix UDP TX packet count when DHCPv4 is used. Currently UDP TX counter is only updated when net context is in use. DHCPv4 however does not use net_context underneath, therefore it needs to update UDP TX stats on its own. Signed-off-by: Robert Lubos --- subsys/net/ip/dhcpv4.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/subsys/net/ip/dhcpv4.c b/subsys/net/ip/dhcpv4.c index b22c7bedc2a..a48f82d0dc7 100644 --- a/subsys/net/ip/dhcpv4.c +++ b/subsys/net/ip/dhcpv4.c @@ -29,6 +29,7 @@ LOG_MODULE_REGISTER(net_dhcpv4, CONFIG_NET_DHCPV4_LOG_LEVEL); #include "dhcpv4.h" #include "ipv4.h" +#include "net_stats.h" #define PKT_WAIT_TIME K_SECONDS(1) @@ -389,6 +390,8 @@ static uint32_t dhcpv4_send_request(struct net_if *iface) goto fail; } + net_stats_update_udp_sent(iface); + NET_DBG("send request dst=%s xid=0x%x ciaddr=%s%s%s timeout=%us", net_sprint_ipv4_addr(server_addr), iface->config.dhcpv4.xid, @@ -427,6 +430,8 @@ static uint32_t dhcpv4_send_discover(struct net_if *iface) goto fail; } + net_stats_update_udp_sent(iface); + timeout = dhcpv4_update_message_timeout(&iface->config.dhcpv4); NET_DBG("send discover xid=0x%x timeout=%us",