Skip to content

Commit

Permalink
6lowpan: introduce LOWPAN_IPHC_MAX_HC_BUF_LEN
Browse files Browse the repository at this point in the history
This patch introduces the LOWPAN_IPHC_MAX_HC_BUF_LEN define which
represent the worst-case supported IPHC buffer length. It's used to
allocate the stack buffer space for creating the IPHC header.

Signed-off-by: Alexander Aring <[email protected]>
Acked-by: Jukka Rissanen <[email protected]>
Signed-off-by: Marcel Holtmann <[email protected]>
  • Loading branch information
alexaring authored and holtmann committed Oct 20, 2015
1 parent cefdb80 commit bf513fd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions include/net/6lowpan.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,20 @@
#define EUI64_ADDR_LEN 8

#define LOWPAN_NHC_MAX_ID_LEN 1
/* Maximum next header compression length which we currently support inclusive
* possible inline data.
*/
#define LOWPAN_NHC_MAX_HDR_LEN (sizeof(struct udphdr))
/* Max IPHC Header len without IPv6 hdr specific inline data.
* Useful for getting the "extra" bytes we need at worst case compression.
*
* LOWPAN_IPHC + CID + LOWPAN_NHC_MAX_ID_LEN
*/
#define LOWPAN_IPHC_MAX_HEADER_LEN (2 + 1 + LOWPAN_NHC_MAX_ID_LEN)
/* Maximum worst case IPHC header buffer size */
#define LOWPAN_IPHC_MAX_HC_BUF_LEN (sizeof(struct ipv6hdr) + \
LOWPAN_IPHC_MAX_HEADER_LEN + \
LOWPAN_NHC_MAX_HDR_LEN)

/*
* ipv6 address based on mac
Expand Down
2 changes: 1 addition & 1 deletion net/6lowpan/iphc.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ int lowpan_header_compress(struct sk_buff *skb, struct net_device *dev,
{
u8 tmp, iphc0, iphc1, *hc_ptr;
struct ipv6hdr *hdr;
u8 head[100] = {};
u8 head[LOWPAN_IPHC_MAX_HC_BUF_LEN] = {};
int ret, addr_type;

if (type != ETH_P_IPV6)
Expand Down

0 comments on commit bf513fd

Please sign in to comment.