mesh: Check for enabled modes when dst is fixed address
authorInga Stotland <inga.stotland@intel.com>
Tue, 18 Aug 2020 22:22:08 +0000 (15:22 -0700)
committerAbhay Agarwal <ay.agarwal@samsung.com>
Mon, 28 Dec 2020 06:20:04 +0000 (11:50 +0530)
This moves the check for incoming messages addressed to fixed addresses,
e.g. RELAY, PROXY, FRIEND. If the corresponding feature is not enabled,
the message is not processed.

Change-Id: I0d7ccefa3e905cf5c7c9a35b12ef0bbbcf74a9e5
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
mesh/model.c
mesh/net.c

index 961391f..b44e2f6 100644 (file)
@@ -937,27 +937,6 @@ bool mesh_model_rx(struct mesh_node *node, bool szmict, uint32_t seq0,
        if (!num_ele || IS_UNASSIGNED(addr))
                goto done;
 
-       /*
-        * In case of fixed group  addresses check if the
-        * corresponding mode is enabled.
-        */
-       if (dst == PROXIES_ADDRESS &&
-                       (node_proxy_mode_get(node) != MESH_MODE_ENABLED))
-               goto done;
-
-       if (dst == FRIENDS_ADDRESS &&
-                       (node_friend_mode_get(node) != MESH_MODE_ENABLED))
-               goto done;
-
-       if (dst == RELAYS_ADDRESS) {
-               uint8_t cnt;
-               uint16_t interval;
-
-               if (node_relay_mode_get(node, &cnt, &interval) !=
-                                                       MESH_MODE_ENABLED)
-                       goto done;
-       }
-
        is_subscription = !(IS_UNICAST(dst));
 
        for (i = 0; i < num_ele; i++) {
index bdece1e..ab2c2cd 100644 (file)
@@ -1656,6 +1656,15 @@ static bool msg_rxed(struct mesh_net *net, bool frnd, uint32_t iv_index,
        }
 
 not_for_friend:
+       if (dst == FRIENDS_ADDRESS && !net->friend_enable)
+               return false;
+
+       if (dst == RELAYS_ADDRESS && !net->relay.enable)
+               return false;
+
+       if (dst == PROXIES_ADDRESS && !net->proxy_enable)
+               return false;
+
        return mesh_model_rx(net->node, szmic, seqAuth, seq, iv_index, net_idx,
                                                src, dst, key_aid, data, size);
 }