From patchwork Thu Mar 16 01:16:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Gix X-Patchwork-Id: 13176901 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97FFEC61DA4 for ; Thu, 16 Mar 2023 01:16:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229617AbjCPBQg (ORCPT ); Wed, 15 Mar 2023 21:16:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229436AbjCPBQf (ORCPT ); Wed, 15 Mar 2023 21:16:35 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6FF337F11 for ; Wed, 15 Mar 2023 18:16:31 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id o11so147486ple.1 for ; Wed, 15 Mar 2023 18:16:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678929391; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=94yMlbDzjaMILVDL5DimGkuhCNlfrbJ5xFedRs1rvno=; b=mnixd8rSXI/g02gzXyySMm6FrKypmeExczKlSMaX7UDPDfjuCLQo0ayrpGuwP/5qUR bVTqgVlxxaHOpxHKbW2ksO5kuLeNne7bjhhHrLmWm0iGgv5CufFjqI2QUO1+0VsUSIvu BeKgq764JE2Hp4AvnJcyeVfJBvyMG0YmtsDDs8BXYZdKlT9amghw/mQdvdECiPTPm/AY QOovnFX9c0vmF3Z6lyfowgK5pmE/pm1A3JhYBhQYM1NrpSbtWqaBfB09txCHoTZ6cMcm u3bwK2Ru8McA0wxB/KluzkHu41cnJbGit7idNJRvuNNywDRDIJOUlVkVEb8Ww1JzJ11h i+XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678929391; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=94yMlbDzjaMILVDL5DimGkuhCNlfrbJ5xFedRs1rvno=; b=MvnXVDDt86ALbgNXA7lVJO4du1G7zu5Bg5jXRtFx4wbXxkjugaLKshLi9buKVwfIpX uO22cvKRsvvxOgaN5hmNfoKAD2fMPudVLkr1n0rcOKqRxvLnXMuLqGD6/qPBsxlDE7Ua VujzGL0pL+a5hZMqp++PMoYDx3Ne/IolcBe1GZ0no1va4h0kOZ0f8TnTz2ds5QQytqeR ZMjgI02IE886hLkOykhpj46ylFF0Ei73/0N2wcNll6nb7hQWggQTeCq6ml2F3rMTBUEI 8yTSGAPu1Q3HNFwylYwRWBySnXFd2gBvMaEn6DCjDoa4ph+4qPIRGrIWesq2ZgWsLQ7n g5NQ== X-Gm-Message-State: AO0yUKXwYdaW/Du8fboXJNrhaYfF0NEr5RBMU9IyqN4pi+GyAKa2qeuK aRQZmgvM3Smsa7Rt1U2CVSsyB2l2n5o= X-Google-Smtp-Source: AK7set9lJSRr9HvOPnpshCf7zL+/FaoZVyK7R40kqT0vZSC5n4yP1xkEvD1XhKho5CbOnpXyjXxPaw== X-Received: by 2002:a05:6a20:b054:b0:cc:63c6:8d3a with SMTP id dx20-20020a056a20b05400b000cc63c68d3amr1491315pzb.41.1678929390552; Wed, 15 Mar 2023 18:16:30 -0700 (PDT) Received: from zbook.. (97-113-12-200.tukw.qwest.net. [97.113.12.200]) by smtp.gmail.com with ESMTPSA id g3-20020a631103000000b00502ecb91940sm3914328pgl.55.2023.03.15.18.16.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 18:16:30 -0700 (PDT) From: Brian Gix To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, brian.gix@gmail.com, inga.stotland@intel.com Subject: [PATCH BlueZ v2 1/3] mesh: Filter originated Provisioning Data packets Date: Wed, 15 Mar 2023 18:16:25 -0700 Message-Id: <20230316011627.27322-1-brian.gix@gmail.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org The mesh daemon can process incoming mesh packets on more than one controller, but if a Provisioning data packet that originated from the local daemon is received by a different controller, it must be filtered and disregarded, or it will break the provisioning protocol. --- mesh/mesh-io-mgmt.c | 58 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 11 deletions(-) diff --git a/mesh/mesh-io-mgmt.c b/mesh/mesh-io-mgmt.c index 9ae1af05a..65994f058 100644 --- a/mesh/mesh-io-mgmt.c +++ b/mesh/mesh-io-mgmt.c @@ -82,6 +82,8 @@ struct dup_filter { uint8_t addr[6]; } __packed; +static const uint8_t zero_addr[] = {0, 0, 0, 0, 0, 0}; + static struct mesh_io_private *pvt; static uint32_t get_instant(void) @@ -110,6 +112,14 @@ static bool find_by_addr(const void *a, const void *b) return !memcmp(filter->addr, b, 6); } +static bool find_by_adv(const void *a, const void *b) +{ + const struct dup_filter *filter = a; + uint64_t data = l_get_be64(b); + + return !memcmp(filter->addr, zero_addr, 6) && filter->data == data; +} + static void filter_timeout(struct l_timeout *timeout, void *user_data) { struct dup_filter *filter; @@ -146,7 +156,22 @@ static bool filter_dups(const uint8_t *addr, const uint8_t *adv, uint32_t instant_delta; uint64_t data = l_get_be64(adv); - filter = l_queue_remove_if(pvt->dup_filters, find_by_addr, addr); + if (!addr) + addr = zero_addr; + + if (adv[1] == MESH_AD_TYPE_PROVISION) { + filter = l_queue_find(pvt->dup_filters, find_by_adv, adv); + + if (!filter && addr != zero_addr) + return false; + + l_queue_remove(pvt->dup_filters, filter); + + } else { + filter = l_queue_remove_if(pvt->dup_filters, find_by_addr, + addr); + } + if (!filter) { filter = l_new(struct dup_filter, 1); memcpy(filter->addr, addr, 6); @@ -177,7 +202,7 @@ static void process_rx_callbacks(void *v_reg, void *v_rx) rx_reg->cb(rx_reg->user_data, &rx->info, rx->data, rx->len); } -static void process_rx(struct mesh_io_private *pvt, int8_t rssi, +static void process_rx(uint16_t index, struct mesh_io_private *pvt, int8_t rssi, uint32_t instant, const uint8_t *addr, const uint8_t *data, uint8_t len) { @@ -191,6 +216,10 @@ static void process_rx(struct mesh_io_private *pvt, int8_t rssi, .info.rssi = rssi, }; + /* Accept all traffic except beacons from any controller */ + if (index != pvt->send_idx && data[0] == MESH_AD_TYPE_BEACON) + return; + print_packet("RX", data, len); l_queue_foreach(pvt->rx_regs, process_rx_callbacks, &rx); } @@ -205,7 +234,7 @@ static void event_device_found(uint16_t index, uint16_t length, const void *param, void *user_data) { const struct mgmt_ev_mesh_device_found *ev = param; - struct mesh_io *io = user_data; + struct mesh_io_private *pvt = user_data; const uint8_t *adv; const uint8_t *addr; uint32_t instant; @@ -236,9 +265,10 @@ static void event_device_found(uint16_t index, uint16_t length, if (len > adv_len) break; - if (adv[1] >= 0x29 && adv[1] <= 0x2B) - process_rx(io->pvt, ev->rssi, instant, addr, adv + 1, - adv[0]); + if (adv[1] >= MESH_AD_TYPE_PROVISION && + adv[1] <= MESH_AD_TYPE_BEACON) + process_rx(index, pvt, ev->rssi, instant, addr, + adv + 1, adv[0]); adv += field_len + 1; } @@ -320,6 +350,12 @@ static void ctl_up(uint8_t status, uint16_t length, mesh->num_ad_types = sizeof(mesh_ad_types); memcpy(mesh->ad_types, mesh_ad_types, sizeof(mesh_ad_types)); + pvt->rx_id = mesh_mgmt_register(MGMT_EV_MESH_DEVICE_FOUND, + MGMT_INDEX_NONE, event_device_found, pvt, + NULL); + pvt->tx_id = mesh_mgmt_register(MGMT_EV_MESH_PACKET_CMPLT, + index, send_cmplt, pvt, NULL); + mesh_mgmt_send(MGMT_OP_SET_MESH_RECEIVER, index, len, mesh, mesh_up, L_UINT_TO_PTR(index), NULL); l_debug("done %d mesh startup", index); @@ -407,11 +443,6 @@ static bool dev_init(struct mesh_io *io, void *opts, void *user_data) mesh_mgmt_send(MGMT_OP_READ_INFO, index, 0, NULL, read_info_cb, L_UINT_TO_PTR(index), NULL); - pvt->rx_id = mesh_mgmt_register(MGMT_EV_MESH_DEVICE_FOUND, - MGMT_INDEX_NONE, event_device_found, io, NULL); - pvt->tx_id = mesh_mgmt_register(MGMT_EV_MESH_PACKET_CMPLT, - MGMT_INDEX_NONE, send_cmplt, io, NULL); - pvt->dup_filters = l_queue_new(); pvt->rx_regs = l_queue_new(); pvt->tx_pkts = l_queue_new(); @@ -522,6 +553,11 @@ static void send_pkt(struct mesh_io_private *pvt, struct tx_pkt *tx, send->adv_data_len = tx->len + 1; send->adv_data[0] = tx->len; memcpy(send->adv_data + 1, tx->pkt, tx->len); + + /* Filter looped back Provision packets */ + if (tx->pkt[0] == MESH_AD_TYPE_PROVISION) + filter_dups(NULL, send->adv_data, get_instant()); + mesh_mgmt_send(MGMT_OP_MESH_SEND, index, len, send, send_queued, tx, NULL); print_packet("Mesh Send Start", tx->pkt, tx->len); From patchwork Thu Mar 16 01:16:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Gix X-Patchwork-Id: 13176902 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE45FC6FD1D for ; Thu, 16 Mar 2023 01:16:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229634AbjCPBQh (ORCPT ); Wed, 15 Mar 2023 21:16:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229487AbjCPBQg (ORCPT ); Wed, 15 Mar 2023 21:16:36 -0400 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 551A63CE2C for ; Wed, 15 Mar 2023 18:16:32 -0700 (PDT) Received: by mail-pl1-x633.google.com with SMTP id i5so142847pla.2 for ; Wed, 15 Mar 2023 18:16:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678929391; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=It02UyW2f2ZA/0vpvxYAhLaJMnV6tE3GwBT/VOn+yi4=; b=Q1u6w8z+bbg/XiY77bZ3oAPIgBY4al+w4VpYRvbQ9sCNUUk7RMyEgrMh6QvblHhJDM lFfl1KjgzEx2bHL9lR4z+cCilEYy9vZUGGmKAZXUkneNN3oJVyM8eBVcDFo7i2GjI7j4 x6vhdZW2MrGGVVbk1EtfXIXpMIKBhTEEzp3K8XHafFsZ8BMeLstU6coS3TiZbXh705JO 0cqcWBD+o6o1LrYuM2bn+S+hzKHrgIhmz8C+9WyQ6t7A28b30+DGjZryHF2rDkan9n8F VgpyOrwsO+o7D7IwsHQ7TP/6A9+SH/rlo1CMsjAG1kNiFZN1XI9d7xb3z7X9SfgJavzX 4i3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678929391; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=It02UyW2f2ZA/0vpvxYAhLaJMnV6tE3GwBT/VOn+yi4=; b=HkSqsN0W9yJicYmTmTImXAd8IBycupokVsahJ3lePY33Epfka0374LXlaCnzHgk3VN Jjfu7DGQGUvCGqhp8j5QvZN8L1uUD6bR/H7Axo9QiAHIPs9zeAYKYcckgMTQZhfYmPh4 3l+gQJYFCoDJ3bjIj6L20YUPZIwtRKTG2BWMQCt01gt9YLOYHEzQ8kzdXFkcUk3cXviV Bc25DaAkMOY0acNzfVG7FntNRhE0yII0dJzIdXpORKcmG5adDvVYmlJVanFGZAj1PoEz 62HcVYGH0m4mSZTz9lTfAxxrhhy349a3drCrKw9KyskC5DEp6ntzS6Fdrw3hzvpykldL tVMQ== X-Gm-Message-State: AO0yUKWNmAhu03hxEd/PRESbYsGLvIVVBoox7lLnWMLHYKUjhqUGqRi2 c3I1xSlf1kg/XuwMRHNYaoi64QsIfbo= X-Google-Smtp-Source: AK7set83ETzqPqK3mZ4GrpRNJq7vToK7RBE/+6f+DM295cEOiIrQ7sktSoypOhZ6eObS8jcW9lInIA== X-Received: by 2002:a05:6a21:3292:b0:d6:93bc:d94 with SMTP id yt18-20020a056a21329200b000d693bc0d94mr2123734pzb.4.1678929391223; Wed, 15 Mar 2023 18:16:31 -0700 (PDT) Received: from zbook.. (97-113-12-200.tukw.qwest.net. [97.113.12.200]) by smtp.gmail.com with ESMTPSA id g3-20020a631103000000b00502ecb91940sm3914328pgl.55.2023.03.15.18.16.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 18:16:30 -0700 (PDT) From: Brian Gix To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, brian.gix@gmail.com, inga.stotland@intel.com Subject: [PATCH BlueZ v2 2/3] mesh: Make MGMT mesh-io less noisy Date: Wed, 15 Mar 2023 18:16:26 -0700 Message-Id: <20230316011627.27322-2-brian.gix@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230316011627.27322-1-brian.gix@gmail.com> References: <20230316011627.27322-1-brian.gix@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Remove excessive logging traffic --- mesh/mesh-io-mgmt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mesh/mesh-io-mgmt.c b/mesh/mesh-io-mgmt.c index 65994f058..f1385edcc 100644 --- a/mesh/mesh-io-mgmt.c +++ b/mesh/mesh-io-mgmt.c @@ -227,7 +227,7 @@ static void process_rx(uint16_t index, struct mesh_io_private *pvt, int8_t rssi, static void send_cmplt(uint16_t index, uint16_t length, const void *param, void *user_data) { - print_packet("Mesh Send Complete", param, length); + /* print_packet("Mesh Send Complete", param, length); */ } static void event_device_found(uint16_t index, uint16_t length, @@ -506,7 +506,7 @@ static void send_cancel(struct mesh_io_private *pvt) if (pvt->handle) { remove.handle = pvt->handle; - l_debug("Cancel TX"); + /* l_debug("Cancel TX"); */ mesh_mgmt_send(MGMT_OP_MESH_SEND_CANCEL, pvt->send_idx, sizeof(remove), &remove, NULL, NULL, NULL); @@ -560,7 +560,7 @@ static void send_pkt(struct mesh_io_private *pvt, struct tx_pkt *tx, mesh_mgmt_send(MGMT_OP_MESH_SEND, index, len, send, send_queued, tx, NULL); - print_packet("Mesh Send Start", tx->pkt, tx->len); + /* print_packet("Mesh Send Start", tx->pkt, tx->len); */ pvt->tx = tx; } From patchwork Thu Mar 16 01:16:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Gix X-Patchwork-Id: 13176903 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50AE8C61DA4 for ; Thu, 16 Mar 2023 01:16:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229651AbjCPBQj (ORCPT ); Wed, 15 Mar 2023 21:16:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229436AbjCPBQh (ORCPT ); Wed, 15 Mar 2023 21:16:37 -0400 Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3F633D0BF for ; Wed, 15 Mar 2023 18:16:32 -0700 (PDT) Received: by mail-pg1-x532.google.com with SMTP id q23so68365pgt.7 for ; Wed, 15 Mar 2023 18:16:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678929392; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=du4Qoj4ZuF296NTy3Bf2f3Bt+6gwaSroClSCf0CVxnA=; b=CaY0Oof5UMwYVrw4yKake4ydg/jldDWfs5OMx7/rJgOKc/S7U9KxIiLTTNuiir2NEM ExulIztyul9XRTtgHGUKZgiR1DjBmsvpoNm9BtLg4EvCxR7pXKMquGr/2As+66Iwa6A+ BJ4Pxo5FWnGGMjEi0qyDOnwiRKjNZiNfwunr3craLXIQYXGQCbI0vTZ29DjGWIb4wguU uGzND3SZMGkSAbVtIX29kYmvRNXy4YDV/6W/09oTAgzhOzxhgj6VvYhE1SwZjbjnE3Oy 9i0CiZKAQfPcwCgJ1WkiEB0K5jwM5LKkB+hQZy2VtFCvztCV7Fx5P4Jj1gIfPABXhDFq gXeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678929392; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=du4Qoj4ZuF296NTy3Bf2f3Bt+6gwaSroClSCf0CVxnA=; b=xwyqFWx2PHCpZTmWEPSa+JfjPTu9zHza8Idhamk9WZe2t733TdBwm8OKEYDIJnjv3r NLq4QxLSHMdEujIy7sZfcTmjU6xZooM/i8tmYELnzXm3cauKxTCREBWpQvD2mgA0sllN vJU+2sTaAl/9o32kLKLuPZ7B9oi4Ca5vkmiJpwxrWjU4FWKr12j2xp4zdkaLjJAkilfv HurbKc5GUJyt3lTc2yErye9XhlVkBuBQVaCBsSBzK5DRPVvp4EfKB9fIgvPbnvxTn+UR j6BvqVuFVfHb7QaHQA9thKsY+8RltDSmIlLZikum3gtXDlg4RYxwEZnvLEdPixNQynqj C1bw== X-Gm-Message-State: AO0yUKUDXPY9uHHTMtGEXFK5n8J+dGZRvxas3g5fLuTsTZ5YvdjoAMrM +Q+hu7dWkgDzqGsMawUKMs6aeyZqa7U= X-Google-Smtp-Source: AK7set8aqBXEMwnEo727B76IxDzv8JM1LBQCpDofTwG/AC+aoUROrhgUt2oEmRxzEhxRSrzsVvznvg== X-Received: by 2002:aa7:9513:0:b0:5a8:b2bf:26ac with SMTP id b19-20020aa79513000000b005a8b2bf26acmr1485301pfp.20.1678929391937; Wed, 15 Mar 2023 18:16:31 -0700 (PDT) Received: from zbook.. (97-113-12-200.tukw.qwest.net. [97.113.12.200]) by smtp.gmail.com with ESMTPSA id g3-20020a631103000000b00502ecb91940sm3914328pgl.55.2023.03.15.18.16.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 18:16:31 -0700 (PDT) From: Brian Gix To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, brian.gix@gmail.com, inga.stotland@intel.com Subject: [PATCH BlueZ v2 3/3] mesh: Don't send Prov Failed on non-existant links Date: Wed, 15 Mar 2023 18:16:27 -0700 Message-Id: <20230316011627.27322-3-brian.gix@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230316011627.27322-1-brian.gix@gmail.com> References: <20230316011627.27322-1-brian.gix@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org If remote device does not respond to a Prov Link Open request, then the callbacks do not get established, and attempting to send Failure messages on the non-existent link rersult in seg fault. --- mesh/remprv-server.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mesh/remprv-server.c b/mesh/remprv-server.c index 6a9efdd47..927dbab0e 100644 --- a/mesh/remprv-server.c +++ b/mesh/remprv-server.c @@ -546,7 +546,7 @@ static bool remprv_srv_pkt(uint16_t src, uint16_t unicast, uint16_t app_idx, bool segmented = false; uint32_t opcode; uint8_t msg[69]; - uint8_t status; + uint8_t old_state, status; uint16_t n; if (app_idx != APP_IDX_DEV_LOCAL) @@ -843,10 +843,12 @@ static bool remprv_srv_pkt(uint16_t src, uint16_t unicast, uint16_t app_idx, if (!prov || prov->node != node || prov->client != src) return true; + old_state = prov->state; prov->state = PB_REMOTE_STATE_LINK_CLOSING; mesh_io_send_cancel(NULL, &pkt_filter, sizeof(pkt_filter)); send_prov_status(prov, PB_REM_ERR_SUCCESS); - if (pkt[0] == 0x02) { + if (pkt[0] == 0x02 && + old_state >= PB_REMOTE_STATE_LINK_ACTIVE) { msg[0] = PROV_FAILED; msg[1] = PROV_ERR_CANT_ASSIGN_ADDR; if (prov->nppi_proc == RPR_ADV)