Bluetooth: Mesh: Fix relaying conditions for Adv & GATT bearers

The bt_mesh_net_relay() function was missing several important checks
for whether a PDU should be relayed or not. In particular, it would
relay a packet from adv to adv even if the Relay state was set to
disabled, as long as GATT Proxy was set to enabled. The code would
also relay packets to the GATT Proxy bearer if the Relay state was set
to enabled but GATT Proxy was set to disabled. This patch addresses
both of these issues.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
Johan Hedberg 2017-12-03 09:48:25 +02:00 committed by Johan Hedberg
commit 4871d8567b

View file

@ -1179,14 +1179,26 @@ static void bt_mesh_net_relay(struct net_buf_simple *sbuf,
goto done;
}
if (IS_ENABLED(CONFIG_BT_MESH_GATT_PROXY)) {
/* Sending to the GATT bearer should only happen if GATT Proxy
* is enabled or the message originates from the local node.
*/
if (IS_ENABLED(CONFIG_BT_MESH_GATT_PROXY) &&
(bt_mesh_gatt_proxy_get() == BT_MESH_GATT_PROXY_ENABLED ||
rx->net_if == BT_MESH_NET_IF_LOCAL)) {
if (bt_mesh_proxy_relay(&buf->b, rx->dst) &&
BT_MESH_ADDR_IS_UNICAST(rx->dst)) {
BT_MESH_ADDR_IS_UNICAST(rx->dst)) {
goto done;
}
}
bt_mesh_adv_send(buf, NULL, NULL);
/* Relaying to the Advertising bearer should only happen if the
* Relay state is set to enabled, or if the packet has been
* received over some other bearer than Advertising.
*/
if (bt_mesh_relay_get() == BT_MESH_RELAY_ENABLED ||
rx->net_if != BT_MESH_NET_IF_ADV) {
bt_mesh_adv_send(buf, NULL, NULL);
}
done:
net_buf_unref(buf);