6lowpan: iphc: cleanups
Alexander Aring
maintainercover 6lowpan: iphc: cleanups
Hi,
These two patches are from the current RFC of stateful compression support. It has nothing todo with stateful compression, I send it now as PATCH so it can be applied before.
- Alex
Alexander Aring (2):
6lowpan: iphc: add check for reserved values
6lowpan: iphc: remove handling when dam is zero
net/6lowpan/iphc.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
Signature · 1 line
2.6.1
Alexander Aring
maintainerPATCH 1/2 6lowpan: iphc: add check for reserved values
This patch adds a check on reserved values for IPHC header. We should at first check on these fields instead of doing parsing before. Afterwards we can be sure there are no reserved values anymore. The reserved bits doesn't contain reserved values for NHC headers. This need to be handled inside the next layer.
--- net/6lowpan/iphc.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
net/6lowpan/iphc.c +16 -1
@@ -455,6 +455,20 @@ static const u8 lowpan_ttl_values[] = { [LOWPAN_IPHC_HLIM_11] = 255, }; +static inline bool lowpan_iphc_is_reserved (u8 iphc1) +{ +switch (iphc1 & (LOWPAN_IPHC_DAC |LOWPAN_IPHC_M | +LOWPAN_IPHC_DAM_MASK )) { +case LOWPAN_IPHC_DAC |LOWPAN_IPHC_DAM_00 : +case LOWPAN_IPHC_DAC |LOWPAN_IPHC_M |LOWPAN_IPHC_DAM_01 : +case LOWPAN_IPHC_DAC |LOWPAN_IPHC_M |LOWPAN_IPHC_DAM_10 : +case LOWPAN_IPHC_DAC |LOWPAN_IPHC_M |LOWPAN_IPHC_DAM_11 : +return true; +default : +return false; + } +} +int lowpan_header_decompress (struct sk_buff *skb,const struct net_device *dev,const void *daddr,const void *saddr) {
@@ -466,7 +480,8 @@ int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev, skb->data, skb->len);if (lowpan_fetch_skb (skb, &iphc0,sizeof (iphc0)) || -lowpan_fetch_skb (skb, &iphc1,sizeof (iphc1))) +lowpan_fetch_skb (skb, &iphc1,sizeof (iphc1)) || +lowpan_iphc_is_reserved (iphc1))return -EINVAL ;/* another if the CID flag is set */
Signature · 1 line
2.6.1
Re: [PATCH bluetooth-next 1/2] 6lowpan: iphc: add check for reserved values
Hello.
Quoted 37 lines · Alexander Aring
This patch adds a check on reserved values for IPHC header. We should at first check on these fields instead of doing parsing before. Afterwards we can be sure there are no reserved values anymore. The reserved bits doesn't contain reserved values for NHC headers. This need to be handled inside the next layer.
Signed-off-by Alexander Aring <[email protected]>--- net/6lowpan/iphc.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)net/6lowpan/iphc.c +14
-0@@ -455,6 +455,20 @@ static const u8 lowpan_ttl_values[] = { [LOWPAN_IPHC_HLIM_11] = 255, }; +static inline bool lowpan_iphc_is_reserved (u8 iphc1) +{ +switch (iphc1 & (LOWPAN_IPHC_DAC |LOWPAN_IPHC_M | +LOWPAN_IPHC_DAM_MASK )) { +case LOWPAN_IPHC_DAC |LOWPAN_IPHC_DAM_00 : +case LOWPAN_IPHC_DAC |LOWPAN_IPHC_M |LOWPAN_IPHC_DAM_01 : +case LOWPAN_IPHC_DAC |LOWPAN_IPHC_M |LOWPAN_IPHC_DAM_10 : +case LOWPAN_IPHC_DAC |LOWPAN_IPHC_M |LOWPAN_IPHC_DAM_11 : +return true; +default : +return false; + } +} +int lowpan_header_decompress (struct sk_buff *skb,const struct net_device *dev,const void *daddr,const void *saddr) {
net/6lowpan/iphc.c int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev, · line 487
Quoted 9 lines
net/6lowpan/iphc.c +2
-1@@ -466,7 +480,8 @@ int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev, skb->data, skb->len);if (lowpan_fetch_skb (skb, &iphc0,sizeof (iphc0)) || -lowpan_fetch_skb (skb, &iphc1,sizeof (iphc1))) +lowpan_fetch_skb (skb, &iphc1,sizeof (iphc1)) || +lowpan_iphc_is_reserved (iphc1))return -EINVAL ;/* another if the CID flag is set */
regards
Stefan Schmidt
Alexander Aring
maintainerPATCH 2/2 6lowpan: iphc: remove handling when dam is zero
In reply to Alexander AringThis patch removes handling of LOWPAN_IPHC_DAM_00 inside the lowpan_compress_addr_64 function. The case of LOWPAN_IPHC_DAM_00 can never occur. there exists a if branch which use LOWPAN_IPHC_DAM_11 and LOWPAN_IPHC_DAM_10 and inside the else branch LOWPAN_IPHC_DAM_01. So LOWPAN_IPHC_DAM_00 can never occur.
--- net/6lowpan/iphc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/6lowpan/iphc.c +1 -2
@@ -594,7 +594,6 @@ int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev,EXPORT_SYMBOL_GPL (lowpan_header_decompress);static const u8 lowpan_iphc_dam_to_sam_value[] = { - [LOWPAN_IPHC_DAM_00 ] =LOWPAN_IPHC_SAM_00 , [LOWPAN_IPHC_DAM_01 ] =LOWPAN_IPHC_SAM_01 , [LOWPAN_IPHC_DAM_10 ] =LOWPAN_IPHC_SAM_10 , [LOWPAN_IPHC_DAM_11 ] =LOWPAN_IPHC_SAM_11 ,
@@ -603,7 +602,7 @@ static const u8 lowpan_iphc_dam_to_sam_value[] = {static u8 lowpan_compress_addr_64 (u8 **hc_ptr,const struct in6_addr *ipaddr,const unsigned char *lladdr,bool sam) { -u8 dam =LOWPAN_IPHC_DAM_00 ; +u8 dam;if (is_addr_mac_addr_based (ipaddr, lladdr)) { dam =LOWPAN_IPHC_DAM_11 ;/* 0-bits */
Signature · 1 line
2.6.1
Re: [PATCH bluetooth-next 2/2] 6lowpan: iphc: remove handling when dam is zero
Hello.
Quoted 5 lines · Alexander Aring
This patch removes handling of
LOWPAN_IPHC_DAM_00inside thelowpan_compress_addr_64function. The case ofLOWPAN_IPHC_DAM_00can never occur. there exists a if branch which useLOWPAN_IPHC_DAM_11andLOWPAN_IPHC_DAM_10and inside the else branchLOWPAN_IPHC_DAM_01. SoLOWPAN_IPHC_DAM_00can never occur.
Agreed the DAM_00 case means no compressions and carry the 128 bit address in line. We never call lowpan_compress_addr_64() for this case so removing this case which is never used is fine.
Quoted 18 lines
Signed-off-by Alexander Aring <[email protected]>--- net/6lowpan/iphc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)net/6lowpan/iphc.c +0
-1@@ -594,7 +594,6 @@ int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev,EXPORT_SYMBOL_GPL (lowpan_header_decompress);static const u8 lowpan_iphc_dam_to_sam_value[] = { - [LOWPAN_IPHC_DAM_00 ] =LOWPAN_IPHC_SAM_00 , [LOWPAN_IPHC_DAM_01 ] =LOWPAN_IPHC_SAM_01 , [LOWPAN_IPHC_DAM_10 ] =LOWPAN_IPHC_SAM_10 , [LOWPAN_IPHC_DAM_11 ] =LOWPAN_IPHC_SAM_11 ,
net/6lowpan/iphc.c static const u8 lowpan_iphc_dam_to_sam_value[] = { · line 608
Quoted 8 lines
net/6lowpan/iphc.c +1
-1@@ -603,7 +602,7 @@ static const u8 lowpan_iphc_dam_to_sam_value[] = {static u8 lowpan_compress_addr_64 (u8 **hc_ptr,const struct in6_addr *ipaddr,const unsigned char *lladdr,bool sam) { -u8 dam =LOWPAN_IPHC_DAM_00 ; +u8 dam;if (is_addr_mac_addr_based (ipaddr, lladdr)) { dam =LOWPAN_IPHC_DAM_11 ;/* 0-bits */
regards
Stefan Schmidt
Alexander Aring
maintainerQuoted 6 lines · Alexander Aring
Hi,
These two patches are from the current RFC of stateful compression support. It has nothing todo with stateful compression, I send it now as PATCH so it can be applied before.
ping :-)
- Alex