From patchwork Tue Mar 31 12:09:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Przemys=C5=82aw_Fierek?= X-Patchwork-Id: 11467707 X-Patchwork-Delegate: brian.gix@gmail.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CFDB4912 for ; Tue, 31 Mar 2020 12:09:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A587020848 for ; Tue, 31 Mar 2020 12:09:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=silvair-com.20150623.gappssmtp.com header.i=@silvair-com.20150623.gappssmtp.com header.b="pvAOtOmQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730418AbgCaMJS (ORCPT ); Tue, 31 Mar 2020 08:09:18 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:35787 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729997AbgCaMJS (ORCPT ); Tue, 31 Mar 2020 08:09:18 -0400 Received: by mail-lf1-f67.google.com with SMTP id t16so16241448lfl.2 for ; Tue, 31 Mar 2020 05:09:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silvair-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=4B5VJsRWUQWe+MqSeLE19KvaIR1tuis2QGTSiG34LdM=; b=pvAOtOmQl2HcprsXjyvr3ei4oEn58ditrnZEsVe/LXX1oWGIbR2vkN2gDGLYjlbdM1 ND/5CvBAJwO/6+LdjpMs3xNhJe5xIj1iRT+4IVHYYygeyensHkwtx/A3IArxKhPAex7S mIJzvCufUIY02Bbr5SfSKyjlPC4C17vfk1RBrwRxa3DD7wyjS/YT+OF7hbIP14ludX0x 1vWHAehlOTOqrEyGrIDJ3o1TIY2GeEap5QyFar6E1LXlv0FPrXto6Uo8wXYWvs6pQN3u xLxWaJW4c9c6EF+PzH7EdIH5MGC7qWrQeRdnHZ0wsIOVxqNG1o/uJEEFOjXLqPv3gYMp FVzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=4B5VJsRWUQWe+MqSeLE19KvaIR1tuis2QGTSiG34LdM=; b=MuZq/PLQaSCaefr66Ys2s9nzcKwMRZCwUAEwV/HdnNAQFY9rZd/RyCiXyLbsEswBuA xS5Qi7gTfyU+tOXtUM2EYEcfvV0cqFmoEP4vHmjQJGcIYHB5+JxAj64HLdjj6+WG2Hw6 6Czyfecm8ZmarFVVZrUgqiFkrBnewe3rlPaGeSyAArml6mbBEq8jat8Bz0OABIwDK0w/ C0/NLfgVzSxXaSHPFqkD7DZo01hPGqjquJt09FQU179yWCpEIxEDP2HK1C2cdzAcmRxn fXFhxOhjbRexYqH0dfIs97N6ZNhL9kS5GArk17T60zQRdy8XGJE7FEAvWEROYGPV5HCg BzJQ== X-Gm-Message-State: AGi0PuZggdLQrbrAEuC5aMTs1QWL43S3FlK0Lu3nNbJZOhQC46/+rwom CAkm0sBm7E5XJ0+z3kBX0pS7+s9ZpLY= X-Google-Smtp-Source: APiQypKUwQM/fPHKbQDD4hu/HFlxpWqAucp4Ji9BMd4iZsazZMzslpzSAHfWVUGCdbehWQSQd56MfQ== X-Received: by 2002:a05:6512:6c4:: with SMTP id u4mr11362305lff.89.1585656555854; Tue, 31 Mar 2020 05:09:15 -0700 (PDT) Received: from pfierek1997.silvair.lan (174.60.citypartner.pl. [195.210.60.174]) by smtp.gmail.com with ESMTPSA id i190sm9828620lfi.7.2020.03.31.05.09.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Mar 2020 05:09:15 -0700 (PDT) From: =?utf-8?q?Przemys=C5=82aw_Fierek?= To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v2 1/3] mesh: Remove unused argument from 'mesh_net_transport_send' function Date: Tue, 31 Mar 2020 14:09:06 +0200 Message-Id: <20200331120908.23215-2-przemyslaw.fierek@silvair.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200331120908.23215-1-przemyslaw.fierek@silvair.com> References: <20200331120908.23215-1-przemyslaw.fierek@silvair.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org --- mesh/friend.c | 16 ++++++++-------- mesh/net.c | 14 +++++++------- mesh/net.h | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/mesh/friend.c b/mesh/friend.c index 5f5f6f823..6d26de15b 100644 --- a/mesh/friend.c +++ b/mesh/friend.c @@ -97,7 +97,7 @@ static void response_delay(struct l_timeout *timeout, void *user_data) n += 2; seq = mesh_net_next_seq_num(neg->net); print_packet("Tx-NET_OP_FRND_OFFER", msg, n); - mesh_net_transport_send(neg->net, key_id, true, + mesh_net_transport_send(neg->net, key_id, mesh_net_get_iv_index(neg->net), 0, seq, 0, neg->lp_addr, msg, n); @@ -316,7 +316,7 @@ void friend_clear(struct mesh_net *net, uint16_t src, uint16_t lpn, l_put_be16(lpn, msg + 1); l_put_be16(lpnCounter, msg + 3); - mesh_net_transport_send(net, 0, false, + mesh_net_transport_send(net, 0, mesh_net_get_iv_index(net), DEFAULT_TTL, 0, 0, src, msg, sizeof(msg)); @@ -332,7 +332,7 @@ static void clear_retry(struct l_timeout *timeout, void *user_data) l_put_be16(neg->lp_addr, msg + 1); l_put_be16(neg->lp_cnt, msg + 3); - mesh_net_transport_send(neg->net, 0, false, + mesh_net_transport_send(neg->net, 0, mesh_net_get_iv_index(neg->net), DEFAULT_TTL, 0, 0, neg->old_friend, msg, sizeof(msg)); @@ -398,7 +398,7 @@ static void friend_delay_rsp(struct l_timeout *timeout, void *user_data) pkt->u.one[0].data, pkt->last_len); pkt->u.one[0].sent = true; - mesh_net_transport_send(net, frnd->net_key_cur, false, + mesh_net_transport_send(net, frnd->net_key_cur, pkt->iv_index, pkt->ttl, pkt->u.one[0].seq, pkt->src, pkt->dst, pkt->u.one[0].data, pkt->last_len); @@ -439,7 +439,7 @@ update: l_put_be32(iv_index, upd + 2); upd[6] = false; /* Queue is Empty */ print_packet("Update", upd, sizeof(upd)); - mesh_net_transport_send(net, frnd->net_key_cur, false, + mesh_net_transport_send(net, frnd->net_key_cur, mesh_net_get_iv_index(net), 0, net_seq, 0, frnd->lp_addr, upd, sizeof(upd)); @@ -487,7 +487,7 @@ void friend_poll(struct mesh_net *net, uint16_t src, bool seq, neg->u.negotiate.clearing = true; l_put_be16(neg->lp_addr, msg + 1); l_put_be16(neg->lp_cnt, msg + 3); - mesh_net_transport_send(net, 0, false, + mesh_net_transport_send(net, 0, mesh_net_get_iv_index(net), DEFAULT_TTL, 0, 0, neg->old_friend, msg, sizeof(msg)); @@ -596,7 +596,7 @@ void friend_sub_add(struct mesh_net *net, struct mesh_friend *frnd, print_packet("Tx-NET_OP_PROXY_SUB_CONFIRM", msg, sizeof(msg)); net_seq = mesh_net_get_seq_num(net); - mesh_net_transport_send(net, frnd->net_key_cur, false, + mesh_net_transport_send(net, frnd->net_key_cur, mesh_net_get_iv_index(net), 0, net_seq, 0, frnd->lp_addr, msg, sizeof(msg)); @@ -634,7 +634,7 @@ void friend_sub_del(struct mesh_net *net, struct mesh_friend *frnd, print_packet("Tx-NET_OP_PROXY_SUB_CONFIRM", msg, sizeof(msg)); net_seq = mesh_net_get_seq_num(net); - mesh_net_transport_send(net, frnd->net_key_cur, false, + mesh_net_transport_send(net, frnd->net_key_cur, mesh_net_get_iv_index(net), 0, net_seq, 0, frnd->lp_addr, msg, sizeof(msg)); diff --git a/mesh/net.c b/mesh/net.c index 0343c4c49..11a9d84a3 100644 --- a/mesh/net.c +++ b/mesh/net.c @@ -1566,7 +1566,7 @@ static void send_frnd_ack(struct mesh_net *net, uint16_t src, uint16_t dst, friend_ack_rxed(net, mesh_net_get_iv_index(net), mesh_net_next_seq_num(net), 0, dst, msg); } else { - mesh_net_transport_send(net, 0, false, + mesh_net_transport_send(net, 0, mesh_net_get_iv_index(net), DEFAULT_TTL, 0, 0, dst, msg, sizeof(msg)); } @@ -1601,7 +1601,7 @@ static void send_net_ack(struct mesh_net *net, struct mesh_sar *sar, return; } - mesh_net_transport_send(net, 0, false, + mesh_net_transport_send(net, 0, mesh_net_get_iv_index(net), DEFAULT_TTL, 0, src, dst, msg, sizeof(msg)); } @@ -2208,7 +2208,7 @@ static bool ctl_received(struct mesh_net *net, uint16_t key_id, } if (n) { - mesh_net_transport_send(net, 0, false, + mesh_net_transport_send(net, 0, mesh_net_get_iv_index(net), rsp_ttl, 0, dst & 0x8000 ? 0 : dst, src, msg, n); @@ -2988,7 +2988,7 @@ void mesh_net_sub_list_add(struct mesh_net *net, uint16_t addr) l_put_be16(addr, msg + n); n += 2; - mesh_net_transport_send(net, 0, false, + mesh_net_transport_send(net, 0, mesh_net_get_iv_index(net), 0, 0, 0, 0, msg, n); } @@ -3001,7 +3001,7 @@ void mesh_net_sub_list_del(struct mesh_net *net, uint16_t addr) l_put_be16(addr, msg + n); n += 2; - mesh_net_transport_send(net, 0, false, + mesh_net_transport_send(net, 0, mesh_net_get_iv_index(net), 0, 0, 0, 0, msg, n); } @@ -3350,7 +3350,7 @@ void mesh_net_ack_send(struct mesh_net *net, uint32_t key_id, /* TODO: add net key index */ void mesh_net_transport_send(struct mesh_net *net, uint32_t key_id, - bool fast, uint32_t iv_index, uint8_t ttl, + uint32_t iv_index, uint8_t ttl, uint32_t seq, uint16_t src, uint16_t dst, const uint8_t *msg, uint16_t msg_len) { @@ -3583,7 +3583,7 @@ void mesh_net_heartbeat_send(struct mesh_net *net) l_put_be16(hb->features, msg + n); n += 2; - mesh_net_transport_send(net, 0, false, mesh_net_get_iv_index(net), + mesh_net_transport_send(net, 0, mesh_net_get_iv_index(net), hb->pub_ttl, 0, 0, hb->pub_dst, msg, n); } diff --git a/mesh/net.h b/mesh/net.h index cb90c1d92..57585ceff 100644 --- a/mesh/net.h +++ b/mesh/net.h @@ -305,7 +305,7 @@ struct l_queue *mesh_net_get_app_keys(struct mesh_net *net); bool mesh_net_flush(struct mesh_net *net); void mesh_net_transport_send(struct mesh_net *net, uint32_t key_id, - bool fast, uint32_t iv_index, uint8_t ttl, + uint32_t iv_index, uint8_t ttl, uint32_t seq, uint16_t src, uint16_t dst, const uint8_t *msg, uint16_t msg_len); From patchwork Tue Mar 31 12:09:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Przemys=C5=82aw_Fierek?= X-Patchwork-Id: 11467709 X-Patchwork-Delegate: brian.gix@gmail.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 013E515AB for ; Tue, 31 Mar 2020 12:09:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D3EC520838 for ; Tue, 31 Mar 2020 12:09:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=silvair-com.20150623.gappssmtp.com header.i=@silvair-com.20150623.gappssmtp.com header.b="tScMjxXi" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730436AbgCaMJT (ORCPT ); Tue, 31 Mar 2020 08:09:19 -0400 Received: from mail-lf1-f47.google.com ([209.85.167.47]:45700 "EHLO mail-lf1-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729483AbgCaMJT (ORCPT ); Tue, 31 Mar 2020 08:09:19 -0400 Received: by mail-lf1-f47.google.com with SMTP id v4so17044832lfo.12 for ; Tue, 31 Mar 2020 05:09:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silvair-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=9Sy22lMvpxzpI8o4xfvZVI1l9nlQgjalZ08I2FKQd9Q=; b=tScMjxXi0TV+9Ksbn40ZZu/82WiigvCbsLpSsylbU02OXdUgiv+AdD1pjRhB1KBdOD q4PLBxdNFkRl0kjRegYzFtwo0W88VB1hOxAdgeN2G1FozO3XwSxEh3ga/BZNMd6N9p12 uQfDKi2jh4ktOmd9ZHA1Xjas6i+NkUXswGA2ru4GZ6ZjYHoWRJiv8lXFdf9vaUGxGyi1 cHf8DOAuToyEllJTXNrPbD+0FIAnGfDdZecPPtvIgBaUuSlN1H1VnwlWZmGE3C+axVAv Itt45EluaPhSVCXnPxqBS4xc8LOB1u6IJHcxoubRdrf2mbXmNwNZ5oF6dvoR7H+pZu8Z Pxvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=9Sy22lMvpxzpI8o4xfvZVI1l9nlQgjalZ08I2FKQd9Q=; b=NYSfU+m5WzxYACtAE0ZBY7SPid3pHqO+272xTHFu7tbOplSi8lzqiUaEMvk5lHStym 2ZM3+x0vrs+v0GrF9oRDfTGp5Wifco2vKA2w1lMG6Rnm2m1PFh+dBDWvRRJYf17JTItA n6XvnXnFTNLw5pyjWOfYZOqWKyhqqhBt7dOCfwLW70yIcA5OsquyHr9o3nLVv5jp0pJO j/vG5IOH28L6r87QCEbeCY/YA894aRmFpJPNRj4mN4t+MJS4PZjPxIgZbU8GI9ne/cIm igZaF3pRIR4baBpExVnN6UJun9XKMPb80bJoomYpIUNZlRmQIt5T4nA6qLfnwRkdm1X0 FaCQ== X-Gm-Message-State: AGi0PuZ7AivQbDiQtwlGGlH0vTglX6kJFexC7vesaTDss/QxlBS1u6/X gvbI2pgjPwrzSb/pOaNCqHduxOcqYO0= X-Google-Smtp-Source: APiQypJYvUi8ozRzMx9v58mlzeRJsVO6Ibzov/bZV1tfrhrWGSYl01XIxwdcUnzAlIeQ9F1puz0eBQ== X-Received: by 2002:ac2:46ed:: with SMTP id q13mr11276965lfo.176.1585656556509; Tue, 31 Mar 2020 05:09:16 -0700 (PDT) Received: from pfierek1997.silvair.lan (174.60.citypartner.pl. [195.210.60.174]) by smtp.gmail.com with ESMTPSA id i190sm9828620lfi.7.2020.03.31.05.09.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Mar 2020 05:09:16 -0700 (PDT) From: =?utf-8?q?Przemys=C5=82aw_Fierek?= To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v2 2/3] mesh: Remove unused functions: 'mesh_net_sub_list_add' and 'mesh_net_sub_list_del' Date: Tue, 31 Mar 2020 14:09:07 +0200 Message-Id: <20200331120908.23215-3-przemyslaw.fierek@silvair.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200331120908.23215-1-przemyslaw.fierek@silvair.com> References: <20200331120908.23215-1-przemyslaw.fierek@silvair.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org --- mesh/net.c | 27 --------------------------- mesh/net.h | 2 -- 2 files changed, 29 deletions(-) diff --git a/mesh/net.c b/mesh/net.c index 11a9d84a3..5f49034e4 100644 --- a/mesh/net.c +++ b/mesh/net.c @@ -2979,33 +2979,6 @@ bool mesh_net_iv_index_update(struct mesh_net *net) } - -void mesh_net_sub_list_add(struct mesh_net *net, uint16_t addr) -{ - uint8_t msg[11] = { PROXY_OP_FILTER_ADD }; - uint8_t n = 1; - - l_put_be16(addr, msg + n); - n += 2; - - mesh_net_transport_send(net, 0, - mesh_net_get_iv_index(net), 0, - 0, 0, 0, msg, n); -} - -void mesh_net_sub_list_del(struct mesh_net *net, uint16_t addr) -{ - uint8_t msg[11] = { PROXY_OP_FILTER_DEL }; - uint8_t n = 1; - - l_put_be16(addr, msg + n); - n += 2; - - mesh_net_transport_send(net, 0, - mesh_net_get_iv_index(net), 0, - 0, 0, 0, msg, n); -} - bool mesh_net_dst_reg(struct mesh_net *net, uint16_t dst) { struct mesh_destination *dest = l_queue_find(net->destinations, diff --git a/mesh/net.h b/mesh/net.h index 57585ceff..df4366b59 100644 --- a/mesh/net.h +++ b/mesh/net.h @@ -363,8 +363,6 @@ void mesh_net_provisioner_mode_set(struct mesh_net *net, bool mode); bool mesh_net_provisioner_mode_get(struct mesh_net *net); bool mesh_net_key_list_get(struct mesh_net *net, uint8_t *buf, uint16_t *count); uint16_t mesh_net_get_primary_idx(struct mesh_net *net); -void mesh_net_sub_list_add(struct mesh_net *net, uint16_t addr); -void mesh_net_sub_list_del(struct mesh_net *net, uint16_t addr); uint32_t mesh_net_friend_timeout(struct mesh_net *net, uint16_t addr); struct mesh_io *mesh_net_get_io(struct mesh_net *net); struct mesh_node *mesh_net_node_get(struct mesh_net *net); From patchwork Tue Mar 31 12:09:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Przemys=C5=82aw_Fierek?= X-Patchwork-Id: 11467711 X-Patchwork-Delegate: brian.gix@gmail.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EF80315AB for ; Tue, 31 Mar 2020 12:09:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B9FB620838 for ; Tue, 31 Mar 2020 12:09:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=silvair-com.20150623.gappssmtp.com header.i=@silvair-com.20150623.gappssmtp.com header.b="IF6VUKAb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730437AbgCaMJV (ORCPT ); Tue, 31 Mar 2020 08:09:21 -0400 Received: from mail-lf1-f45.google.com ([209.85.167.45]:46643 "EHLO mail-lf1-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729997AbgCaMJV (ORCPT ); Tue, 31 Mar 2020 08:09:21 -0400 Received: by mail-lf1-f45.google.com with SMTP id q5so17059897lfb.13 for ; Tue, 31 Mar 2020 05:09:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silvair-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references; bh=gW9scRCQt3echZK/7jHFNMXLTq0XzcM1Tl1QpKVGFbo=; b=IF6VUKAbmfFYto44ejkk26gS+CoEirUKvOpKAf3suuLA25BeOATk/uo0AERDZdHN4X shBegzm453MuzKX0apMMqJjiFc3+QwW3KOAMvheR1kxzifMspmBsR+kJf7papvvCKti9 g+V41GLkWXlM+55UFHic9lzTqLTk5Kh9JL4Xa3VMjFUHk+RpvzpOGKY4EMpRhDMdsFVc /obQC4jtKfr5Nk18YeMjPbtD2olaRFtdsSHc0gVTBInUlDHpRTk+BxRpmEVEkuxExPCg Jk8oHvE56E9a25Yg2AQfGUuY4omOTnLW8Ur6aeygZ7iPwABodrBlYr2bixq+1dotgsrw KM1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=gW9scRCQt3echZK/7jHFNMXLTq0XzcM1Tl1QpKVGFbo=; b=D8kE4iyhO7IYs+IB9vEN2/QjkEiTUZq4bubdZdiUGgD4DK3HPozQywSFO28oiPD8IY fopkczU8p8QxydPu1trM8w4DOyw80TcbB9xGLjd+nVWIpFd5jW3m4WbrWiDHXftsJvqZ MjRv2msWda7jDNIPj6D72pEoVqGjJ1g8p9ny2g8to991wVyRH7gtJLmvLeBL9Egau3f4 U0A9vnp2Nju/Qh9rANsFyLlTqZfD0ZUrW+3ZMfnJ2r5zr5nAj7sJquCj0pVaQThSbeHn BxrHGvma++aAvbLZnSyzhx3ShKgIDyaSh8rkz98yjENWoPcwXboZS0dGKEREAEykQ6Pm 7ZOg== X-Gm-Message-State: AGi0PuZxQ0cfC6HjrV0B9fJDQnjllod77CskyLr78cJYn6kYekmzMGMv U6slJSgtYUysv09fl/p/hwA8Rt/GlJU= X-Google-Smtp-Source: APiQypL4ftjsunKV5Yr9Gm/zq4nHCfMJA2IdYTurLsAPRL0Rh8wcC2jIIKT9RdDPm6phhXJa+rtydg== X-Received: by 2002:a05:6512:51c:: with SMTP id o28mr11376289lfb.116.1585656557197; Tue, 31 Mar 2020 05:09:17 -0700 (PDT) Received: from pfierek1997.silvair.lan (174.60.citypartner.pl. [195.210.60.174]) by smtp.gmail.com with ESMTPSA id i190sm9828620lfi.7.2020.03.31.05.09.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Mar 2020 05:09:16 -0700 (PDT) From: =?utf-8?q?Przemys=C5=82aw_Fierek?= To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v2 3/3] mesh: Add net key index to send_seg() Date: Tue, 31 Mar 2020 14:09:08 +0200 Message-Id: <20200331120908.23215-4-przemyslaw.fierek@silvair.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200331120908.23215-1-przemyslaw.fierek@silvair.com> References: <20200331120908.23215-1-przemyslaw.fierek@silvair.com> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This patch adds net key index to send_seg(). This fixes problem with using invalid network key to encrypt application messages. --- mesh/friend.c | 16 ++++++++-------- mesh/net.c | 50 ++++++++++++++++++++++++++++++-------------------- mesh/net.h | 7 ++++--- 3 files changed, 42 insertions(+), 31 deletions(-) diff --git a/mesh/friend.c b/mesh/friend.c index 6d26de15b..d27da9592 100644 --- a/mesh/friend.c +++ b/mesh/friend.c @@ -97,7 +97,7 @@ static void response_delay(struct l_timeout *timeout, void *user_data) n += 2; seq = mesh_net_next_seq_num(neg->net); print_packet("Tx-NET_OP_FRND_OFFER", msg, n); - mesh_net_transport_send(neg->net, key_id, + mesh_net_transport_send(neg->net, key_id, 0, mesh_net_get_iv_index(neg->net), 0, seq, 0, neg->lp_addr, msg, n); @@ -316,7 +316,7 @@ void friend_clear(struct mesh_net *net, uint16_t src, uint16_t lpn, l_put_be16(lpn, msg + 1); l_put_be16(lpnCounter, msg + 3); - mesh_net_transport_send(net, 0, + mesh_net_transport_send(net, 0, 0, mesh_net_get_iv_index(net), DEFAULT_TTL, 0, 0, src, msg, sizeof(msg)); @@ -332,7 +332,7 @@ static void clear_retry(struct l_timeout *timeout, void *user_data) l_put_be16(neg->lp_addr, msg + 1); l_put_be16(neg->lp_cnt, msg + 3); - mesh_net_transport_send(neg->net, 0, + mesh_net_transport_send(neg->net, 0, 0, mesh_net_get_iv_index(neg->net), DEFAULT_TTL, 0, 0, neg->old_friend, msg, sizeof(msg)); @@ -398,7 +398,7 @@ static void friend_delay_rsp(struct l_timeout *timeout, void *user_data) pkt->u.one[0].data, pkt->last_len); pkt->u.one[0].sent = true; - mesh_net_transport_send(net, frnd->net_key_cur, + mesh_net_transport_send(net, frnd->net_key_cur, 0, pkt->iv_index, pkt->ttl, pkt->u.one[0].seq, pkt->src, pkt->dst, pkt->u.one[0].data, pkt->last_len); @@ -439,7 +439,7 @@ update: l_put_be32(iv_index, upd + 2); upd[6] = false; /* Queue is Empty */ print_packet("Update", upd, sizeof(upd)); - mesh_net_transport_send(net, frnd->net_key_cur, + mesh_net_transport_send(net, frnd->net_key_cur, 0, mesh_net_get_iv_index(net), 0, net_seq, 0, frnd->lp_addr, upd, sizeof(upd)); @@ -487,7 +487,7 @@ void friend_poll(struct mesh_net *net, uint16_t src, bool seq, neg->u.negotiate.clearing = true; l_put_be16(neg->lp_addr, msg + 1); l_put_be16(neg->lp_cnt, msg + 3); - mesh_net_transport_send(net, 0, + mesh_net_transport_send(net, 0, 0, mesh_net_get_iv_index(net), DEFAULT_TTL, 0, 0, neg->old_friend, msg, sizeof(msg)); @@ -596,7 +596,7 @@ void friend_sub_add(struct mesh_net *net, struct mesh_friend *frnd, print_packet("Tx-NET_OP_PROXY_SUB_CONFIRM", msg, sizeof(msg)); net_seq = mesh_net_get_seq_num(net); - mesh_net_transport_send(net, frnd->net_key_cur, + mesh_net_transport_send(net, frnd->net_key_cur, 0, mesh_net_get_iv_index(net), 0, net_seq, 0, frnd->lp_addr, msg, sizeof(msg)); @@ -634,7 +634,7 @@ void friend_sub_del(struct mesh_net *net, struct mesh_friend *frnd, print_packet("Tx-NET_OP_PROXY_SUB_CONFIRM", msg, sizeof(msg)); net_seq = mesh_net_get_seq_num(net); - mesh_net_transport_send(net, frnd->net_key_cur, + mesh_net_transport_send(net, frnd->net_key_cur, 0, mesh_net_get_iv_index(net), 0, net_seq, 0, frnd->lp_addr, msg, sizeof(msg)); diff --git a/mesh/net.c b/mesh/net.c index 5f49034e4..ba9a8caf1 100644 --- a/mesh/net.c +++ b/mesh/net.c @@ -179,6 +179,7 @@ struct mesh_sar { uint32_t seqAuth; uint16_t seqZero; uint16_t app_idx; + uint16_t net_idx; uint16_t src; uint16_t remote; uint16_t len; @@ -1528,7 +1529,8 @@ static void friend_ack_rxed(struct mesh_net *net, uint32_t iv_index, l_queue_foreach(net->friends, enqueue_friend_pkt, &frnd_ack); } -static bool send_seg(struct mesh_net *net, struct mesh_sar *msg, uint8_t seg); +static bool send_seg(struct mesh_net *net, uint16_t net_idx, + struct mesh_sar *msg, uint8_t seg); static void send_frnd_ack(struct mesh_net *net, uint16_t src, uint16_t dst, uint32_t hdr, uint32_t flags) @@ -1566,7 +1568,7 @@ static void send_frnd_ack(struct mesh_net *net, uint16_t src, uint16_t dst, friend_ack_rxed(net, mesh_net_get_iv_index(net), mesh_net_next_seq_num(net), 0, dst, msg); } else { - mesh_net_transport_send(net, 0, + mesh_net_transport_send(net, 0, 0, mesh_net_get_iv_index(net), DEFAULT_TTL, 0, 0, dst, msg, sizeof(msg)); } @@ -1601,9 +1603,10 @@ static void send_net_ack(struct mesh_net *net, struct mesh_sar *sar, return; } - mesh_net_transport_send(net, 0, + mesh_net_transport_send(net, 0, sar->net_idx, mesh_net_get_iv_index(net), DEFAULT_TTL, - 0, src, dst, msg, sizeof(msg)); + 0, src, dst, msg, + sizeof(msg)); } static void inseg_to(struct l_timeout *seg_timeout, void *user_data) @@ -1734,7 +1737,7 @@ static void ack_received(struct mesh_net *net, bool timeout, l_info("Resend Seg %d net:%p dst:%x app_idx:%3.3x", i, net, outgoing->remote, outgoing->app_idx); - send_seg(net, outgoing, i); + send_seg(net, outgoing->net_idx, outgoing, i); } l_timeout_remove(outgoing->seg_timeout); @@ -2012,6 +2015,7 @@ static bool seg_rxed(struct mesh_net *net, bool frnd, uint32_t iv_index, sar_in->key_aid = key_aid; sar_in->len = len; sar_in->last_seg = 0xff; + sar_in->net_idx = net_idx; sar_in->msg_timeout = l_timeout_create(MSG_TO, inmsg_to, net, NULL); @@ -2208,7 +2212,7 @@ static bool ctl_received(struct mesh_net *net, uint16_t key_id, } if (n) { - mesh_net_transport_send(net, 0, + mesh_net_transport_send(net, 0, 0, mesh_net_get_iv_index(net), rsp_ttl, 0, dst & 0x8000 ? 0 : dst, src, msg, n); @@ -3031,8 +3035,8 @@ bool mesh_net_flush(struct mesh_net *net) return true; } -/* TODO: add net key index */ -static bool send_seg(struct mesh_net *net, struct mesh_sar *msg, uint8_t segO) +static bool send_seg(struct mesh_net *net, uint16_t net_idx, + struct mesh_sar *msg, uint8_t segO) { struct mesh_subnet *subnet; uint8_t seg_len; @@ -3041,7 +3045,6 @@ static bool send_seg(struct mesh_net *net, struct mesh_sar *msg, uint8_t segO) uint8_t packet_len; uint8_t segN = SEG_MAX(msg->segmented, msg->len); uint16_t seg_off = SEG_OFF(segO); - uint32_t key_id = 0; uint32_t seq_num; if (msg->segmented) { @@ -3082,10 +3085,13 @@ static bool send_seg(struct mesh_net *net, struct mesh_sar *msg, uint8_t segO) } print_packet("Clr-Net Tx", packet + 1, packet_len); - subnet = get_primary_subnet(net); - key_id = subnet->net_key_tx; + subnet = l_queue_find(net->subnets, match_key_index, + L_UINT_TO_PTR(net_idx)); + if (!subnet) + return false; - if (!net_key_encrypt(key_id, msg->iv_index, packet + 1, packet_len)) { + if (!net_key_encrypt(subnet->net_key_tx, msg->iv_index, packet + 1, + packet_len)) { l_error("Failed to encode packet"); return false; } @@ -3217,6 +3223,7 @@ bool mesh_net_app_send(struct mesh_net *net, bool frnd_cred, uint16_t src, payload->szmic = szmic; payload->frnd_cred = frnd_cred; payload->key_aid = key_aid; + payload->net_idx = net_idx; payload->iv_index = mesh_net_get_iv_index(net); payload->seqAuth = seq; payload->segmented = segmented; @@ -3245,11 +3252,11 @@ bool mesh_net_app_send(struct mesh_net *net, bool frnd_cred, uint16_t src, for (i = 0; i < 4; i++) { for (seg = 0; seg <= seg_max && result; seg++) - result = send_seg(net, payload, seg); + result = send_seg(net, net_idx, payload, seg); } } else { for (seg = 0; seg <= seg_max && result; seg++) - result = send_seg(net, payload, seg); + result = send_seg(net, net_idx, payload, seg); } /* Reliable: Cache; Unreliable: Flush*/ @@ -3321,11 +3328,11 @@ void mesh_net_ack_send(struct mesh_net *net, uint32_t key_id, l_free(str); } -/* TODO: add net key index */ void mesh_net_transport_send(struct mesh_net *net, uint32_t key_id, - uint32_t iv_index, uint8_t ttl, - uint32_t seq, uint16_t src, uint16_t dst, - const uint8_t *msg, uint16_t msg_len) + uint16_t net_idx, uint32_t iv_index, + uint8_t ttl, uint32_t seq, uint16_t src, + uint16_t dst, const uint8_t *msg, + uint16_t msg_len) { uint32_t use_seq = seq; uint8_t pkt_len; @@ -3373,7 +3380,10 @@ void mesh_net_transport_send(struct mesh_net *net, uint32_t key_id, } if (!key_id) { - struct mesh_subnet *subnet = get_primary_subnet(net); + struct mesh_subnet *subnet = l_queue_find(net->subnets, + match_key_index, L_UINT_TO_PTR(net_idx)); + if (!subnet) + return; key_id = subnet->net_key_tx; use_seq = mesh_net_next_seq_num(net); @@ -3556,7 +3566,7 @@ void mesh_net_heartbeat_send(struct mesh_net *net) l_put_be16(hb->features, msg + n); n += 2; - mesh_net_transport_send(net, 0, mesh_net_get_iv_index(net), + mesh_net_transport_send(net, 0, 0, mesh_net_get_iv_index(net), hb->pub_ttl, 0, 0, hb->pub_dst, msg, n); } diff --git a/mesh/net.h b/mesh/net.h index df4366b59..60396dbe7 100644 --- a/mesh/net.h +++ b/mesh/net.h @@ -305,9 +305,10 @@ struct l_queue *mesh_net_get_app_keys(struct mesh_net *net); bool mesh_net_flush(struct mesh_net *net); void mesh_net_transport_send(struct mesh_net *net, uint32_t key_id, - uint32_t iv_index, uint8_t ttl, - uint32_t seq, uint16_t src, uint16_t dst, - const uint8_t *msg, uint16_t msg_len); + uint16_t net_idx, uint32_t iv_index, + uint8_t ttl, uint32_t seq, uint16_t src, + uint16_t dst, const uint8_t *msg, + uint16_t msg_len); bool mesh_net_app_send(struct mesh_net *net, bool frnd_cred, uint16_t src, uint16_t dst, uint8_t key_id, uint16_t net_idx,