net: pkt: Introduce minimum length requirement to net_pkt_get_frag()
net_pkt_get_frag() and a few other functions did not specify the allocated fragment length, incorrectly assuming that fixed-sized buffers are always used. In order to make the function work properly also with variable-sized buffers, extend the function argument list with minimum expected fragment length parameter. This allows to use net_buf_alloc_len() allocator in variable buffer length configuration, as well as verify if the fixed-sized buffer is large enough to satisfy the requirements otherwise. Update the existing codebase to provide the expected fragment length, based on the context. Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
parent
98608b3c30
commit
387a66131e
18 changed files with 112 additions and 65 deletions
|
@ -508,8 +508,11 @@ static struct net_buf *ethernet_fill_header(struct ethernet_context *ctx,
|
|||
{
|
||||
struct net_buf *hdr_frag;
|
||||
struct net_eth_hdr *hdr;
|
||||
size_t hdr_len = IS_ENABLED(CONFIG_NET_VLAN) ?
|
||||
sizeof(struct net_eth_vlan_hdr) :
|
||||
sizeof(struct net_eth_hdr);
|
||||
|
||||
hdr_frag = net_pkt_get_frag(pkt, NET_BUF_TIMEOUT);
|
||||
hdr_frag = net_pkt_get_frag(pkt, hdr_len, NET_BUF_TIMEOUT);
|
||||
if (!hdr_frag) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue