diff --git a/subsys/net/l2/ieee802154/ieee802154_6lo_fragment.c b/subsys/net/l2/ieee802154/ieee802154_6lo_fragment.c index 1eb8b770dd7..5d09ba6db1e 100644 --- a/subsys/net/l2/ieee802154/ieee802154_6lo_fragment.c +++ b/subsys/net/l2/ieee802154/ieee802154_6lo_fragment.c @@ -233,7 +233,7 @@ static void update_protocol_header_lengths(struct net_pkt *pkt, uint16_t size) ipv6 = (struct net_ipv6_hdr *)net_pkt_get_data(pkt, &ipv6_access); if (!ipv6) { - NET_ERR("could not get IPv6 header"); + NET_ERR("Could not get IPv6 header"); return; } @@ -251,7 +251,7 @@ static void update_protocol_header_lengths(struct net_pkt *pkt, uint16_t size) udp->len = htons(size - NET_IPV6H_LEN); net_pkt_set_data(pkt, &udp_access); } else { - NET_ERR("could not get UDP header"); + NET_ERR("Could not get UDP header"); } } } @@ -492,6 +492,7 @@ static inline enum net_verdict fragment_add_to_cache(struct net_pkt *pkt) if ((type == NET_6LO_DISPATCH_FRAG1 && frag->len < NET_6LO_FRAG1_HDR_LEN) || (type == NET_6LO_DISPATCH_FRAGN && frag->len < NET_6LO_FRAGN_HDR_LEN)) { + NET_ERR("Fragment too short (%u): fragment dropped", frag->len); return NET_DROP; } @@ -510,7 +511,9 @@ static inline enum net_verdict fragment_add_to_cache(struct net_pkt *pkt) if (!fcache) { fcache = set_reass_cache(pkt, size, tag); if (!fcache) { - NET_ERR("Could not get a cache entry"); + NET_ERR("Could not allocate fragment cache, consider increasing " + "CONFIG_NET_L2_IEEE802154_FRAGMENT_REASS_CACHE_SIZE: packet " + "dropped"); pkt->buffer = frag; return NET_DROP; } @@ -521,12 +524,14 @@ static inline enum net_verdict fragment_add_to_cache(struct net_pkt *pkt) fragment_append(fcache->pkt, frag); if (fragment_cached_pkt_len(fcache->pkt) == fcache->size) { + /* All fragments received - reassemble packet. */ + if (!first_frag) { /* Assign buffer back to input packet. */ pkt->buffer = fcache->pkt->buffer; fcache->pkt->buffer = NULL; } else { - /* in case pkt == fcache->pkt, we don't want + /* In case pkt == fcache->pkt, we don't want * to unref it while clearing the cache. */ fcache->pkt = NULL; @@ -535,14 +540,14 @@ static inline enum net_verdict fragment_add_to_cache(struct net_pkt *pkt) clear_reass_cache(size, tag); if (!fragment_packet_valid(pkt)) { - NET_ERR("Invalid fragmented packet"); + NET_ERR("Invalid fragment type: packet dropped"); return NET_DROP; } fragment_reconstruct_packet(pkt); if (!net_6lo_uncompress(pkt)) { - NET_ERR("Could not uncompress. Bogus packet?"); + NET_ERR("Invalid 6LoWPAN header: packet dropped"); return NET_DROP; } @@ -568,7 +573,7 @@ static inline enum net_verdict fragment_add_to_cache(struct net_pkt *pkt) enum net_verdict ieee802154_6lo_reassemble(struct net_pkt *pkt) { if (!pkt || !pkt->buffer) { - NET_ERR("Nothing to reassemble"); + NET_WARN("Empty payload: packet dropped"); return NET_DROP; } @@ -581,7 +586,7 @@ enum net_verdict ieee802154_6lo_reassemble(struct net_pkt *pkt) return NET_CONTINUE; } - NET_ERR("Could not uncompress. Bogus packet?"); + NET_ERR("Invalid header: packet dropped"); } return NET_DROP;