Skip to content

Commit 40ae990

Browse files
jukkarkrish2718
authored andcommitted
[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 <[email protected]> (cherry picked from commit 18cd2d8) (cherry picked from commit 6052253)
1 parent 698b0a5 commit 40ae990

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

subsys/net/ip/net_pkt.c

+2-3
Original file line numberDiff line numberDiff line change
@@ -1033,13 +1033,12 @@ static struct net_buf *pkt_alloc_buffer(struct net_pkt *pkt,
10331033

10341034
#if defined(CONFIG_NET_PKT_ALLOC_STATS)
10351035
uint32_t start_time = k_cycle_get_32();
1036-
size_t total_size = size;
1036+
size_t total_size = size + headroom;
10371037
#else
10381038
ARG_UNUSED(pkt);
10391039
#endif
1040-
ARG_UNUSED(headroom);
10411040

1042-
buf = net_buf_alloc_len(pool, size, timeout);
1041+
buf = net_buf_alloc_len(pool, size + headroom, timeout);
10431042

10441043
#if CONFIG_NET_PKT_LOG_LEVEL >= LOG_LEVEL_DBG
10451044
NET_FRAG_CHECK_IF_NOT_IN_USE(buf, buf->ref + 1);

tests/net/vlan/testcase.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@ tests:
1111
net.vlan.header_reserved:
1212
extra_configs:
1313
- CONFIG_NET_L2_ETHERNET_RESERVE_HEADER=y
14+
net.vlan.header_reserved.variable_size:
15+
extra_configs:
16+
- CONFIG_NET_L2_ETHERNET_RESERVE_HEADER=y
17+
- CONFIG_NET_BUF_VARIABLE_DATA_SIZE=y

0 commit comments

Comments
 (0)