Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1939812rwb; Thu, 29 Sep 2022 04:20:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6coy3uVv9+Z9CNArstVMIY15ALMwkQ8GWYhPfXd/fpyecnl5CC9Hs9MmCwjqpVWEXftXCV X-Received: by 2002:a17:906:ef8c:b0:77c:8f77:330 with SMTP id ze12-20020a170906ef8c00b0077c8f770330mr2297666ejb.604.1664450410707; Thu, 29 Sep 2022 04:20:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664450410; cv=none; d=google.com; s=arc-20160816; b=EHjI1zdSc2mRbERKHZ+y4FfCcUBwtDaZoIbGejud0WqnbYBHGcdGeCsUZsJACwUIPa Ge8dVlmBt0jJGMH3gGsvNmkM20M3JFEl7wHAw9xn0H7/aHw2URuP1H/a8/hyLwkmRcOZ OKUsM6z1N/s6oZm4xyeL7IbVZBiZIyoficfLJKi7MnmxZQ9OmxZkKaT6yY5bhZ8GqmSm VQWVE5ovEhfBguhjaBaNmQVPCRQsxN3DVG+8Gq88AHF39Tf79r5P4DZQlAyFs8P7VegW bMZxq9pinBRbf7Od+76TCh9riN3jjVWs1bNvMxbUFOtPblgzYC8uHGmFPA6B0yNvpvdt RwAg== 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=x60850OwzI14ELYXZwZdzl8ndVMYfYeuP6gOtTkBNSQ=; b=wq9jfxjMQvp+PsU/3TeS/jX7G/ZCxC8MLzSzKpE5u6eY/cyA/N47cmMxxQdZ8SXtnj TR+obyd88fUgl/937pb67EPORlUDZrUKAsVGurgWWpxFAb4EFBghb+rkQiI+dftd3h8b Q+wvDIV6A5zg1WT+g0QnCf4ieVqbQOZLHP4WrqE2px8kRe/f5VQu4yBKkIXnHJ2gwchT VoUFIDg8WEe47SZ+2lEzGXuYs2T6GNMhHo4njFlzHezaan8M8lKxulcqqIChXN4ObImf 1w8BtZ2zc9FXlEIG+BDdaaUyNMilKz3afQqC3rqhAEivjCvRCtiBMaQHDwW7XF0eMuzQ oAlA== 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 sg40-20020a170907a42800b0073d6e50e564si7556421ejc.348.2022.09.29.04.19.45; Thu, 29 Sep 2022 04:20:10 -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 S235197AbiI2LEP (ORCPT + 99 others); Thu, 29 Sep 2022 07:04:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234687AbiI2LEM (ORCPT ); Thu, 29 Sep 2022 07:04:12 -0400 Received: from voyager.loytec.com (voyager.loytec.com [88.198.4.4]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF6AD12BDA8 for ; Thu, 29 Sep 2022 04:04:11 -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 1odrKs-0007Jf-8W for linux-bluetooth@vger.kernel.org; Thu, 29 Sep 2022 13:04:10 +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 28TB45CH3109252; Thu, 29 Sep 2022 13:04:08 +0200 From: Isak Westin To: linux-bluetooth@vger.kernel.org Cc: Isak Westin Subject: [PATCH BlueZ 3/4] mesh: Allow Key refresh to skip Phase 2 Date: Thu, 29 Sep 2022 13:03:43 +0200 Message-Id: <20220929110344.26130-4-isak.westin@loytec.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220929110344.26130-1-isak.westin@loytec.com> References: <20220929110344.26130-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 If we are in Key Refresh Phase 1, and receive a Secure Network beacon using the new NetKey and with KR flag set to 0, Phase 2 should be skipped. See MshPRFv1.0.1 section 3.10.4.1. --- mesh/net.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mesh/net.c b/mesh/net.c index c225fdb9a..379a6e250 100644 --- a/mesh/net.c +++ b/mesh/net.c @@ -2613,7 +2613,8 @@ static bool update_kr_state(struct mesh_subnet *subnet, bool kr, uint32_t id) { /* Figure out the key refresh phase */ if (kr) { - if (id == subnet->net_key_upd) { + if (subnet->kr_phase == KEY_REFRESH_PHASE_ONE && + id == subnet->net_key_upd) { l_debug("Beacon based KR phase 2 change"); return (key_refresh_phase_two(subnet->net, subnet->idx) == MESH_STATUS_SUCCESS); @@ -2754,7 +2755,7 @@ static void process_beacon(void *net_ptr, void *user_data) ivu != net->iv_update) updated |= update_iv_ivu_state(net, ivi, ivu); - if (kr != local_kr) + if (kr != local_kr || beacon_data->net_key_id != subnet->net_key_cur) updated |= update_kr_state(subnet, kr, beacon_data->net_key_id); if (updated) -- 2.20.1