提交 84ce1ddf 编写于 作者: A Alexander Aring 提交者: David S. Miller

6lowpan: init ipv6hdr buffer to zero

This patch simplify the handling to set fields inside of struct ipv6hdr
to zero. Instead of setting some memory regions with memset to zero we
initialize the whole ipv6hdr to zero.

This is a simplification for parsing the 6lowpan header for the upcomming
patches.
Signed-off-by: NAlexander Aring <alex.aring@gmail.com>
Reviewed-by: NWerner Almesberger <werner@almesberger.net>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 4cffa13d
...@@ -223,10 +223,6 @@ lowpan_uncompress_addr(struct sk_buff *skb, struct in6_addr *ipaddr, ...@@ -223,10 +223,6 @@ lowpan_uncompress_addr(struct sk_buff *skb, struct in6_addr *ipaddr,
if (prefcount > 0) if (prefcount > 0)
memcpy(ipaddr, prefix, prefcount); memcpy(ipaddr, prefix, prefcount);
if (prefcount + postcount < 16)
memset(&ipaddr->s6_addr[prefcount], 0,
16 - (prefcount + postcount));
if (postcount > 0) { if (postcount > 0) {
memcpy(&ipaddr->s6_addr[16 - postcount], skb->data, postcount); memcpy(&ipaddr->s6_addr[16 - postcount], skb->data, postcount);
skb_pull(skb, postcount); skb_pull(skb, postcount);
...@@ -723,7 +719,7 @@ frame_err: ...@@ -723,7 +719,7 @@ frame_err:
static int static int
lowpan_process_data(struct sk_buff *skb) lowpan_process_data(struct sk_buff *skb)
{ {
struct ipv6hdr hdr; struct ipv6hdr hdr = {};
u8 tmp, iphc0, iphc1, num_context = 0; u8 tmp, iphc0, iphc1, num_context = 0;
u8 *_saddr, *_daddr; u8 *_saddr, *_daddr;
int err; int err;
...@@ -868,8 +864,6 @@ lowpan_process_data(struct sk_buff *skb) ...@@ -868,8 +864,6 @@ lowpan_process_data(struct sk_buff *skb)
hdr.priority = ((tmp >> 2) & 0x0f); hdr.priority = ((tmp >> 2) & 0x0f);
hdr.flow_lbl[0] = ((tmp << 6) & 0xC0) | ((tmp >> 2) & 0x30); hdr.flow_lbl[0] = ((tmp << 6) & 0xC0) | ((tmp >> 2) & 0x30);
hdr.flow_lbl[1] = 0;
hdr.flow_lbl[2] = 0;
break; break;
/* /*
* Flow Label carried in-line * Flow Label carried in-line
...@@ -885,10 +879,6 @@ lowpan_process_data(struct sk_buff *skb) ...@@ -885,10 +879,6 @@ lowpan_process_data(struct sk_buff *skb)
break; break;
/* Traffic Class and Flow Label are elided */ /* Traffic Class and Flow Label are elided */
case 3: /* 11b */ case 3: /* 11b */
hdr.priority = 0;
hdr.flow_lbl[0] = 0;
hdr.flow_lbl[1] = 0;
hdr.flow_lbl[2] = 0;
break; break;
default: default:
break; break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册