From 698b0a59f9bb9a2320873af44404d590ec4549fb Mon Sep 17 00:00:00 2001 From: Chaitanya Tata Date: Sat, 8 Feb 2025 01:14:34 +0530 Subject: [PATCH 1/3] [nrf fromtree] drivers: nrf_wifi: Fix get config Only a single condition is specific to RAW mode, rest should be unconditional. Signed-off-by: Chaitanya Tata (cherry picked from commit a409d31169f0db08d3f64ef15e2552ff6e8fb37c) (cherry picked from commit bad9e656e4b9cb958700b98cefd2e3b01e249bb7) --- drivers/wifi/nrf_wifi/src/net_if.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/wifi/nrf_wifi/src/net_if.c b/drivers/wifi/nrf_wifi/src/net_if.c index 5f79e2de26d..8cdb9a472bd 100644 --- a/drivers/wifi/nrf_wifi/src/net_if.c +++ b/drivers/wifi/nrf_wifi/src/net_if.c @@ -946,7 +946,7 @@ int nrf_wifi_if_get_config_zep(const struct device *dev, struct ethernet_config *config) { int ret = -1; -#ifdef CONFIG_NRF70_RAW_DATA_TX + struct nrf_wifi_vif_ctx_zep *vif_ctx_zep = NULL; struct nrf_wifi_ctx_zep *rpu_ctx_zep = NULL; struct nrf_wifi_fmac_dev_ctx *fmac_dev_ctx = NULL; @@ -986,11 +986,12 @@ int nrf_wifi_if_get_config_zep(const struct device *dev, } memset(config, 0, sizeof(struct ethernet_config)); - +#ifdef CONFIG_NRF70_RAW_DATA_TX if (type == ETHERNET_CONFIG_TYPE_TXINJECTION_MODE) { config->txinjection_mode = sys_dev_ctx->vif_ctx[vif_ctx_zep->vif_idx]->txinjection_mode; } +#endif #ifdef CONFIG_NRF70_TCP_IP_CHECKSUM_OFFLOAD if (type == ETHERNET_CONFIG_TYPE_TX_CHECKSUM_SUPPORT || type == ETHERNET_CONFIG_TYPE_RX_CHECKSUM_SUPPORT) { @@ -1011,7 +1012,6 @@ int nrf_wifi_if_get_config_zep(const struct device *dev, unlock: k_mutex_unlock(&vif_ctx_zep->vif_lock); out: -#endif return ret; } From 40ae990a7e157fa7ac7c706d082657fd695a7e7d Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Mon, 20 Jan 2025 10:50:54 +0200 Subject: [PATCH 2/3] [nrf fromtree] net: pkt: Alloc headroom also for variable size data buffers The headroom was not taken into account for variable size data buffers when CONFIG_NET_L2_ETHERNET_RESERVE_HEADER was enabled. Add a test case for it to make sure the reserve allocation works properly. Fixes #84053 Signed-off-by: Jukka Rissanen (cherry picked from commit 18cd2d83be52679e75e2a2e3f28fd136d95e7e67) (cherry picked from commit 6052253ce20fef2765f1ad89a645467e04a0aef8) --- subsys/net/ip/net_pkt.c | 5 ++--- tests/net/vlan/testcase.yaml | 4 ++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/subsys/net/ip/net_pkt.c b/subsys/net/ip/net_pkt.c index 792e9f12a9f..650f7f2f2b7 100644 --- a/subsys/net/ip/net_pkt.c +++ b/subsys/net/ip/net_pkt.c @@ -1033,13 +1033,12 @@ static struct net_buf *pkt_alloc_buffer(struct net_pkt *pkt, #if defined(CONFIG_NET_PKT_ALLOC_STATS) uint32_t start_time = k_cycle_get_32(); - size_t total_size = size; + size_t total_size = size + headroom; #else ARG_UNUSED(pkt); #endif - ARG_UNUSED(headroom); - buf = net_buf_alloc_len(pool, size, timeout); + buf = net_buf_alloc_len(pool, size + headroom, timeout); #if CONFIG_NET_PKT_LOG_LEVEL >= LOG_LEVEL_DBG NET_FRAG_CHECK_IF_NOT_IN_USE(buf, buf->ref + 1); diff --git a/tests/net/vlan/testcase.yaml b/tests/net/vlan/testcase.yaml index c036e767a40..97f637bd3f1 100644 --- a/tests/net/vlan/testcase.yaml +++ b/tests/net/vlan/testcase.yaml @@ -11,3 +11,7 @@ tests: net.vlan.header_reserved: extra_configs: - CONFIG_NET_L2_ETHERNET_RESERVE_HEADER=y + net.vlan.header_reserved.variable_size: + extra_configs: + - CONFIG_NET_L2_ETHERNET_RESERVE_HEADER=y + - CONFIG_NET_BUF_VARIABLE_DATA_SIZE=y From 45eff649cf9b3d5433438ba6d9db8e369dbc3c43 Mon Sep 17 00:00:00 2001 From: Robert Lubos Date: Tue, 21 Jan 2025 14:48:50 +0100 Subject: [PATCH 3/3] [nrf fromtree] net: pkt: Fix fixed buffer allocation with headroom bug The size calculation for the first buffer, in case extra headroom is requested, had a bug which could result in a size variable underflow followed by net_buf exhaustion. In case the net_buf size was larger than requested size, but smaller than requested size + headroom, the whole buffer size was subtracted from the requested size. This however did not take the extra headroom into account and in effect could result in underflow. Signed-off-by: Robert Lubos (cherry picked from commit ea191bddafc272124ebb37906c41bbfa9ca5e21f) (cherry picked from commit 81eaa466f86919803d7a1e12f26f214a49e61fb1) --- subsys/net/ip/net_pkt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subsys/net/ip/net_pkt.c b/subsys/net/ip/net_pkt.c index 650f7f2f2b7..675ca9d2b34 100644 --- a/subsys/net/ip/net_pkt.c +++ b/subsys/net/ip/net_pkt.c @@ -970,7 +970,7 @@ static struct net_buf *pkt_alloc_buffer(struct net_pkt *pkt, size = 0U; } else { - size -= current->size; + size -= current->size - headroom; } } else { if (current->size > size) {