Skip to content
Permalink
Browse files

net: ethernet: Fix asserts in net_eth_fill_header()

There's an apparent typo in testing net_buf headroom. Also, after
adding VLAN header support, its size should be used too.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
  • Loading branch information...
pfalcon authored and nashif committed Jun 12, 2018
1 parent f425c0a commit 699023a9871f2981341ef3ce17b6b82949d532b0
Showing with 5 additions and 2 deletions.
  1. +5 −2 subsys/net/ip/l2/ethernet/ethernet.c
@@ -326,12 +326,13 @@ struct net_eth_hdr *net_eth_fill_header(struct ethernet_context *ctx,
{
struct net_eth_hdr *hdr;

NET_ASSERT(net_buf_headroom(frag) > sizeof(struct net_eth_addr));

#if defined(CONFIG_NET_VLAN)
if (net_eth_is_vlan_enabled(ctx, net_pkt_iface(pkt))) {
struct net_eth_vlan_hdr *hdr_vlan;

NET_ASSERT(net_buf_headroom(frag) >=
sizeof(struct net_eth_vlan_hdr));

hdr_vlan = (struct net_eth_vlan_hdr *)(frag->data -
net_pkt_ll_reserve(pkt));

@@ -358,6 +359,8 @@ struct net_eth_hdr *net_eth_fill_header(struct ethernet_context *ctx,
}
#endif

NET_ASSERT(net_buf_headroom(frag) >= sizeof(struct net_eth_hdr));

hdr = (struct net_eth_hdr *)(frag->data - net_pkt_ll_reserve(pkt));

if (dst && ((u8_t *)&hdr->dst != dst)) {

0 comments on commit 699023a

Please sign in to comment.
You can’t perform that action at this time.