提交 cefdb801 编写于 作者: A Alexander Aring 提交者: Marcel Holtmann

bluetooth: 6lowpan: use lowpan dispatch helpers

This patch adds a check if the dataroom of skb contains a dispatch value
by checking if skb->len != 0. This patch also change the dispatch
evaluation by the recently introduced helpers for checking the common
6LoWPAN dispatch values for IPv6 and IPHC header.

There was also a forgotten else branch which should drop the packet if
no matching dispatch is available.
Signed-off-by: NAlexander Aring <alex.aring@gmail.com>
Acked-by: NJukka Rissanen <jukka.rissanen@linux.intel.com>
Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
上级 71cd2aa5
...@@ -314,15 +314,17 @@ static int recv_pkt(struct sk_buff *skb, struct net_device *dev, ...@@ -314,15 +314,17 @@ static int recv_pkt(struct sk_buff *skb, struct net_device *dev,
if (!netif_running(dev)) if (!netif_running(dev))
goto drop; goto drop;
if (dev->type != ARPHRD_6LOWPAN) if (dev->type != ARPHRD_6LOWPAN || !skb->len)
goto drop; goto drop;
skb_reset_network_header(skb);
skb = skb_share_check(skb, GFP_ATOMIC); skb = skb_share_check(skb, GFP_ATOMIC);
if (!skb) if (!skb)
goto drop; goto drop;
/* check that it's our buffer */ /* check that it's our buffer */
if (skb->data[0] == LOWPAN_DISPATCH_IPV6) { if (lowpan_is_ipv6(*skb_network_header(skb))) {
/* Copy the packet so that the IPv6 header is /* Copy the packet so that the IPv6 header is
* properly aligned. * properly aligned.
*/ */
...@@ -334,7 +336,6 @@ static int recv_pkt(struct sk_buff *skb, struct net_device *dev, ...@@ -334,7 +336,6 @@ static int recv_pkt(struct sk_buff *skb, struct net_device *dev,
local_skb->protocol = htons(ETH_P_IPV6); local_skb->protocol = htons(ETH_P_IPV6);
local_skb->pkt_type = PACKET_HOST; local_skb->pkt_type = PACKET_HOST;
skb_reset_network_header(local_skb);
skb_set_transport_header(local_skb, sizeof(struct ipv6hdr)); skb_set_transport_header(local_skb, sizeof(struct ipv6hdr));
if (give_skb_to_upper(local_skb, dev) != NET_RX_SUCCESS) { if (give_skb_to_upper(local_skb, dev) != NET_RX_SUCCESS) {
...@@ -347,38 +348,34 @@ static int recv_pkt(struct sk_buff *skb, struct net_device *dev, ...@@ -347,38 +348,34 @@ static int recv_pkt(struct sk_buff *skb, struct net_device *dev,
consume_skb(local_skb); consume_skb(local_skb);
consume_skb(skb); consume_skb(skb);
} else { } else if (lowpan_is_iphc(*skb_network_header(skb))) {
switch (skb->data[0] & 0xe0) { local_skb = skb_clone(skb, GFP_ATOMIC);
case LOWPAN_DISPATCH_IPHC: /* ipv6 datagram */ if (!local_skb)
local_skb = skb_clone(skb, GFP_ATOMIC); goto drop;
if (!local_skb)
goto drop;
ret = iphc_decompress(local_skb, dev, chan); ret = iphc_decompress(local_skb, dev, chan);
if (ret < 0) { if (ret < 0) {
kfree_skb(local_skb); kfree_skb(local_skb);
goto drop; goto drop;
} }
local_skb->protocol = htons(ETH_P_IPV6); local_skb->protocol = htons(ETH_P_IPV6);
local_skb->pkt_type = PACKET_HOST; local_skb->pkt_type = PACKET_HOST;
local_skb->dev = dev; local_skb->dev = dev;
if (give_skb_to_upper(local_skb, dev) if (give_skb_to_upper(local_skb, dev)
!= NET_RX_SUCCESS) { != NET_RX_SUCCESS) {
kfree_skb(local_skb); kfree_skb(local_skb);
goto drop; goto drop;
} }
dev->stats.rx_bytes += skb->len; dev->stats.rx_bytes += skb->len;
dev->stats.rx_packets++; dev->stats.rx_packets++;
consume_skb(local_skb); consume_skb(local_skb);
consume_skb(skb); consume_skb(skb);
break; } else {
default: goto drop;
break;
}
} }
return NET_RX_SUCCESS; return NET_RX_SUCCESS;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册