Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1068768rwb; Thu, 6 Oct 2022 08:06:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4HJnBDggu2aayZBcX7rarz8/yT86uYmwf8ZM1MyG8cZRhpuqesdnjM3YKjARlejjs1FJCH X-Received: by 2002:a17:906:794b:b0:787:a9ee:3bf0 with SMTP id l11-20020a170906794b00b00787a9ee3bf0mr257129ejo.354.1665068817468; Thu, 06 Oct 2022 08:06:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665068817; cv=none; d=google.com; s=arc-20160816; b=hC2tD6QlzDgmnGDWUGpmfYQQpxDQkOyHnKnEnB2AQ2t8gk2J+JSPFycOdcvw0MXQp7 UFrD3R+4H8t/CiRDLKbiOe6FgBxA3Is+XCOyyT0Y9QNXxZGC8MlgrS05VE084AW3m2fH im0cOudWqTOnHQOzGIwEgRD/Xh8npV17iJI1s2JOlh9gO1aeflbfqsBMiPAZ+Wvbs6nt 8u98ExI2wl/Rl4Pwos9mlWAK58cGFu83HqHQs14dvsUWJeqxi4kwCIijF+yX7CKl3CBR EGHJUtxXB/5W36qBWY5H5/ySEc5nQjB/wCMNQ1q1pgYqcewSxaGP5CAjHaawziMCBh0W marA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=hhyKSCQ2tCO1EfHFdLPvShtTRxHuZCE6IqJQdb6ggzU=; b=ppWHNJcwNnT9FJrFswcEizj+dlU2zI8iSZoyIdkG/Ddgz/YvLBY0AgNW8C7XrJr2VB 7KLgM+eejtRdgP1vVcP2WNVpFn9d6rwdM+ZV2lqXjjvNlPzJSiDSpSVI3XFWHd7IS87D 0dyTDzi1DpqbVv2A65oOy/yhBVmrEEqfABT8fxXGfVHby1FllAm3ojcB04Kdn3FcTQMf SuQf/WdzOFOUq8boAilarUv7jbyiOhIaQiJJLV5cYxv4sNRFS2u1n/4U52Y3lmdZnOix 317Jre6BbmxrT96vUXgAUGEgGcatktRsrwVym8zMpqNHz0964s5m+ozr3z2ECUMPr2/+ UKNQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sb25-20020a1709076d9900b0078badb3816dsi11264451ejc.952.2022.10.06.08.06.03; Thu, 06 Oct 2022 08:06:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231814AbiJFO77 (ORCPT + 99 others); Thu, 6 Oct 2022 10:59:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230453AbiJFO76 (ORCPT ); Thu, 6 Oct 2022 10:59:58 -0400 Received: from voyager.loytec.com (voyager.loytec.com [88.198.4.4]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C73411D339 for ; Thu, 6 Oct 2022 07:59:54 -0700 (PDT) Received: from 212-17-98-152.static.upcbusiness.at ([212.17.98.152] helo=lexx.office.loytec.com) by voyager.loytec.com with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ogSLo-0006rY-1e for linux-bluetooth@vger.kernel.org; Thu, 06 Oct 2022 16:59:52 +0200 Received: from loytec-dev-vm.delta.corp ([10.101.25.21]) by lexx.office.loytec.com (8.15.2/8.15.2/Some OS 1.2.3-4.5) with ESMTP id 296ExnRF4163430; Thu, 6 Oct 2022 16:59:49 +0200 From: Isak Westin To: linux-bluetooth@vger.kernel.org Cc: Isak Westin Subject: [PATCH BlueZ 3/6] mesh: provisionee: Handle failed provisioning Date: Thu, 6 Oct 2022 16:59:24 +0200 Message-Id: <20221006145927.32731-4-isak.westin@loytec.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20221006145927.32731-1-isak.westin@loytec.com> References: <20221006145927.32731-1-isak.westin@loytec.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 212.17.98.152 X-SA-Exim-Mail-From: isak.westin@loytec.com X-SA-Exim-Scanned: No (on voyager.loytec.com); SAEximRunCond expanded to false X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org When a provisioning fails, all additionally received PDU should be unexpected until link is closed by provisioner. See MshPRFv1.0.1 section 5.4.4. --- mesh/prov-acceptor.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mesh/prov-acceptor.c b/mesh/prov-acceptor.c index ac257b170..0cefb2fa9 100644 --- a/mesh/prov-acceptor.c +++ b/mesh/prov-acceptor.c @@ -70,6 +70,7 @@ struct mesh_prov_acceptor { uint8_t material; uint8_t expected; int8_t previous; + bool failed; struct conf_input conf_inputs; uint8_t calc_key[16]; uint8_t salt[16]; @@ -408,7 +409,8 @@ static void acp_prov_rx(void *user_data, const uint8_t *data, uint16_t len) if (type == prov->previous) { l_error("Ignore repeated %2.2x packet", type); return; - } else if (type > prov->expected || type < prov->previous) { + } else if (prov->failed || type > prov->expected || + type < prov->previous) { l_error("Expected %2.2x, Got:%2.2x", prov->expected, type); fail.reason = PROV_ERR_UNEXPECTED_PDU; goto failure; @@ -648,6 +650,8 @@ static void acp_prov_rx(void *user_data, const uint8_t *data, uint16_t len) failure: fail.opcode = PROV_FAILED; prov_send(prov, &fail, sizeof(fail)); + prov->failed = true; + prov->previous = -1; if (prov->cmplt) prov->cmplt(prov->caller_data, fail.reason, NULL); prov->cmplt = NULL; @@ -707,6 +711,7 @@ bool acceptor_start(uint8_t num_ele, uint8_t uuid[16], prov->cmplt = complete_cb; prov->ob = l_queue_new(); prov->previous = -1; + prov->failed = false; prov->out_opcode = PROV_NONE; prov->caller_data = caller_data; -- 2.20.1