net: ip: 6lo (IPHC) uncompression rework

This is a rework of the 6lo IPHC uncompression.
The uncompression now tries to work in place on the original buffer
instead of allocation a new one. If there is not enough tail-room,
a new buffer is allocated and filled with the IP and maybe UDP header.
The compressed header is pulled from the original buffer and the
buffer is preserved.

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
This commit is contained in:
Alexander Wachter 2019-06-18 19:23:15 +02:00 committed by Jukka Rissanen
parent 0261ecdee4
commit f10da7b643
2 changed files with 499 additions and 462 deletions

File diff suppressed because it is too large Load diff

View file

@ -20,6 +20,7 @@
#define NET_6LO_DISPATCH_FRAG1 0xC0 /* 11000xxx */
#define NET_6LO_DISPATCH_FRAGN 0xE0 /* 11100xxx */
#define NET_6LO_DISPATCH_IPHC_MASK 0xE0
/**
* TF (Traffic class and Flow label)
* 00: ECN + DSCP + 4-bit Pad + Flow Label (4 bytes)
@ -27,48 +28,73 @@
* 10: ECN + DSCP (1 byte), Flow Label is elided.
* 11: Traffic Class and Flow Label are elided.
*/
#define NET_6LO_IPHC_TF_00 0x00
#define NET_6LO_IPHC_TF_01 0x08
#define NET_6LO_IPHC_TF_10 0x10
#define NET_6LO_IPHC_TF_11 0x18
#define NET_6LO_IPHC_TF_POS 11
#define NET_6LO_IPHC_TF_MASK (0x03 << NET_6LO_IPHC_TF_POS)
#define NET_6LO_IPHC_TF_00 (0x00 << NET_6LO_IPHC_TF_POS)
#define NET_6LO_IPHC_TF_01 (0x01 << NET_6LO_IPHC_TF_POS)
#define NET_6LO_IPHC_TF_10 (0x02 << NET_6LO_IPHC_TF_POS)
#define NET_6LO_IPHC_TF_11 (0x03 << NET_6LO_IPHC_TF_POS)
/* NH (next header) */
#define NET_6LO_IPHC_NH_0 0x00
#define NET_6LO_IPHC_NH_1 0x04
#define NET_6LO_IPHC_NH_POS 10
#define NET_6LO_IPHC_NH_MASK (0x01 << NET_6LO_IPHC_NH_POS)
#define NET_6LO_IPHC_NH_0 (0x00 << NET_6LO_IPHC_NH_POS)
#define NET_6LO_IPHC_NH_1 (0x01 << NET_6LO_IPHC_NH_POS)
/* HLIM (Hop Limit) */
#define NET_6LO_IPHC_HLIM 0x00 /* 00 */
#define NET_6LO_IPHC_HLIM1 0x01 /* 01 */
#define NET_6LO_IPHC_HLIM64 0x02 /* 10 */
#define NET_6LO_IPHC_HLIM255 0x03 /* 11 */
#define NET_6LO_IPHC_HLIM_POS 8
#define NET_6LO_IPHC_HLIM_MASK (0x03 << NET_6LO_IPHC_HLIM_POS)
#define NET_6LO_IPHC_HLIM (0x00 << NET_6LO_IPHC_HLIM_POS) /* 00 */
#define NET_6LO_IPHC_HLIM1 (0x01 << NET_6LO_IPHC_HLIM_POS) /* 01 */
#define NET_6LO_IPHC_HLIM64 (0x02 << NET_6LO_IPHC_HLIM_POS) /* 10 */
#define NET_6LO_IPHC_HLIM255 (0x03 << NET_6LO_IPHC_HLIM_POS) /* 11 */
/* CID (Context Identifier Extension) */
#define NET_6LO_IPHC_CID_0 0x00
#define NET_6LO_IPHC_CID_1 0x80
#define NET_6LO_IPHC_CID_POS 7
#define NET_6LO_IPHC_CID_MASK (0x01 << NET_6LO_IPHC_CID_POS)
#define NET_6LO_IPHC_CID_0 (0x00 << NET_6LO_IPHC_CID_POS)
#define NET_6LO_IPHC_CID_1 (0x01 << NET_6LO_IPHC_CID_POS)
/* SAC (Source Address Compression) */
#define NET_6LO_IPHC_SAC_0 0x00
#define NET_6LO_IPHC_SAC_1 0x40
#define NET_6LO_IPHC_SAC_POS 6
#define NET_6LO_IPHC_SAC_MASK (0x01 << NET_6LO_IPHC_SAC_POS)
#define NET_6LO_IPHC_SAC_0 (0x00 << NET_6LO_IPHC_SAC_POS)
#define NET_6LO_IPHC_SAC_1 (0x01 << NET_6LO_IPHC_SAC_POS)
/* SAM (Source Address Mode) */
#define NET_6LO_IPHC_SAM_00 0x00
#define NET_6LO_IPHC_SAM_01 0x10
#define NET_6LO_IPHC_SAM_10 0x20
#define NET_6LO_IPHC_SAM_11 0x30
#define NET_6LO_IPHC_SAM_POS 4
#define NET_6LO_IPHC_SAM_MASK (0x03 << NET_6LO_IPHC_SAM_POS)
#define NET_6LO_IPHC_SAM_00 (0x00 << NET_6LO_IPHC_SAM_POS)
#define NET_6LO_IPHC_SAM_01 (0x01 << NET_6LO_IPHC_SAM_POS)
#define NET_6LO_IPHC_SAM_10 (0x02 << NET_6LO_IPHC_SAM_POS)
#define NET_6LO_IPHC_SAM_11 (0x03 << NET_6LO_IPHC_SAM_POS)
#define NET_6LO_IPHC_SA_MASK (NET_6LO_IPHC_SAC_MASK | \
NET_6LO_IPHC_SAM_MASK)
/* M (Multicast compression) */
#define NET_6LO_IPHC_M_0 0x00
#define NET_6LO_IPHC_M_1 0x08
#define NET_6LO_IPHC_M_POS 3
#define NET_6LO_IPHC_M_MASK (0x01 << NET_6LO_IPHC_M_POS)
#define NET_6LO_IPHC_M_0 (0x00 << NET_6LO_IPHC_M_POS)
#define NET_6LO_IPHC_M_1 (0x01 << NET_6LO_IPHC_M_POS)
/* DAC (Destination Address Compression) */
#define NET_6LO_IPHC_DAC_0 0x00
#define NET_6LO_IPHC_DAC_1 0x04
#define NET_6LO_IPHC_DAC_POS 2
#define NET_6LO_IPHC_DAC_MASK (0x01 << NET_6LO_IPHC_DAC_POS)
#define NET_6LO_IPHC_DAC_0 (0x00 << NET_6LO_IPHC_DAC_POS)
#define NET_6LO_IPHC_DAC_1 (0x01 << NET_6LO_IPHC_DAC_POS)
/* DAM (Destination Address Mode) */
#define NET_6LO_IPHC_DAM_00 0x00
#define NET_6LO_IPHC_DAM_01 0x01
#define NET_6LO_IPHC_DAM_10 0x02
#define NET_6LO_IPHC_DAM_11 0x03
#define NET_6LO_IPHC_DAM_POS 0
#define NET_6LO_IPHC_DAM_MASK (0x03 << NET_6LO_IPHC_DAM_POS)
#define NET_6LO_IPHC_DAM_00 (0x00 << NET_6LO_IPHC_DAM_POS)
#define NET_6LO_IPHC_DAM_01 (0x01 << NET_6LO_IPHC_DAM_POS)
#define NET_6LO_IPHC_DAM_10 (0x02 << NET_6LO_IPHC_DAM_POS)
#define NET_6LO_IPHC_DAM_11 (0x03 << NET_6LO_IPHC_DAM_POS)
#define NET_6LO_IPHC_DA_MASK (NET_6LO_IPHC_DAC_MASK | \
NET_6LO_IPHC_DAM_MASK | \
NET_6LO_IPHC_M_MASK)
/* Next Header UDP */
#define NET_6LO_NHC_UDP_BARE 0xF0
@ -76,6 +102,7 @@
#define NET_6LO_NHC_UDP_CHKSUM_0 0x00
#define NET_6LO_NHC_UDP_CHKSUM_1 0x08
#define NET_6LO_NHC_UDP_PORT_MASK 0x03
#define NET_6LO_NHC_UDP_PORT_00 0x00
#define NET_6LO_NHC_UDP_PORT_01 0x01
#define NET_6LO_NHC_UDP_PORT_10 0x02
@ -84,9 +111,6 @@
#define NET_6LO_NHC_UDP_8_BIT_PORT 0xF0
#define NET_6LO_NHC_UDP_4_BIT_PORT 0xF0B
#define IPHC ((frag)->data)
#define CIPHC ((pkt->frags)->data)
#define NET_6LO_FRAG1_HDR_LEN 4
#define NET_6LO_FRAGN_HDR_LEN 5