summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2017-01-25 14:36:49 +0200
committerJukka Rissanen <jukka.rissanen@linux.intel.com>2017-01-27 12:35:52 +0200
commit2e9fd888bf49e535a5442c1475868f2bf05c5e59 (patch)
treeb750c07601719131dcdbeccf4d87caab09c79fcc
parent02b104dae85e0788203f74eedc8377ff14d75f3e (diff)
net: bt: Fix not checking for valid ll addresses
ll addresses need to be set properly before sending as the stack is not checking if they are NULL. Change-Id: Ia4e96240f18b53b0e32e21649a8b571c94260731 Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
-rw-r--r--subsys/net/ip/l2/bluetooth.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/subsys/net/ip/l2/bluetooth.c b/subsys/net/ip/l2/bluetooth.c
index 42c945eea..c24b1437b 100644
--- a/subsys/net/ip/l2/bluetooth.c
+++ b/subsys/net/ip/l2/bluetooth.c
@@ -32,6 +32,8 @@
#include <bluetooth/uuid.h>
#include <bluetooth/l2cap.h>
+#include "ipv6.h"
+
#define L2CAP_IPSP_PSM 0x0023
#define L2CAP_IPSP_MTU 1280
@@ -85,6 +87,27 @@ static enum net_verdict net_bt_send(struct net_if *iface, struct net_buf *buf)
return NET_DROP;
}
+ /* TODO: Move ll address check to the stack */
+
+ /* If the ll address is not set at all, then we must set
+ * it here.
+ */
+ if (!net_nbuf_ll_src(buf)->addr) {
+ net_nbuf_ll_src(buf)->addr = net_nbuf_ll_if(buf)->addr;
+ net_nbuf_ll_src(buf)->len = net_nbuf_ll_if(buf)->len;
+ }
+
+ /* If the ll dst address is not set check if it is present in the nbr
+ * cache.
+ */
+ if (!net_nbuf_ll_dst(buf)->addr &&
+ !net_is_ipv6_addr_mcast(&NET_IPV6_BUF(buf)->dst)) {
+ buf = net_ipv6_prepare_for_send(buf);
+ if (!buf) {
+ return NET_CONTINUE;
+ }
+ }
+
if (!net_6lo_compress(buf, true, NULL)) {
NET_DBG("Packet compression failed");
return NET_DROP;