linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Prathyusha Nelluri <prathyusha.n@samsung.com>
To: linux-bluetooth@vger.kernel.org
Cc: s.syam@samsung.com, Prathyusha N <prathyusha.n@samsung.com>
Subject: [PATCH 1/1] mesh: Handle KeyRefresh phase 1 to phase 3
Date: Wed, 25 Mar 2020 00:57:19 +0530	[thread overview]
Message-ID: <1585078044-14974-5-git-send-email-prathyusha.n@samsung.com> (raw)
In-Reply-To: <1585078044-14974-1-git-send-email-prathyusha.n@samsung.com>

From: Prathyusha N <prathyusha.n@samsung.com>

Switch to phase 3 when updated net key index is same as
beacon key id. Switch beaconing key in phase 2 and phase 3.
---
 mesh/net.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/mesh/net.c b/mesh/net.c
index ec05b6be9..3b6c8365f 100644
--- a/mesh/net.c
+++ b/mesh/net.c
@@ -2598,6 +2598,14 @@ static int key_refresh_phase_two(struct mesh_net *net, uint16_t idx)
 	 */
 	subnet->kr_phase = KEY_REFRESH_PHASE_TWO;
 	refresh_beacon(subnet, net);
+
+	/* send snb with updated net key id in phase 2 */
+	if (net->beacon_enable) {
+		/* Switch beaconing key */
+		net_key_beacon_disable(subnet->net_key_cur);
+		net_key_beacon_enable(subnet->net_key_upd);
+	}
+
 	queue_friend_update(net);
 
 	l_queue_foreach(net->friends, frnd_kr_phase2, net);
@@ -2625,6 +2633,13 @@ static int key_refresh_finish(struct mesh_net *net, uint16_t idx)
 
 	l_info("Key refresh phase 3: use new keys only, discard old ones");
 
+	/* required when skipping phase 2 */
+	if (net->beacon_enable) {
+		/* Switch beaconing key */
+		net_key_beacon_disable(subnet->net_key_cur);
+		net_key_beacon_enable(subnet->net_key_upd);
+	}
+
 	/* Switch to using new keys, discard old ones */
 	net_key_unref(subnet->net_key_cur);
 	subnet->net_key_tx = subnet->net_key_cur = subnet->net_key_upd;
@@ -2755,7 +2770,8 @@ static void process_beacon(void *net_ptr, void *user_data)
 				ivi != net->iv_index || ivu != net->iv_update)
 		update_iv_ivu_state(net, ivi, ivu);
 
-	if (kr != local_kr)
+	if (kr != local_kr || (subnet->kr_phase == KEY_REFRESH_PHASE_ONE &&
+				subnet->net_key_upd == beacon_data->key_id))
 		update_kr_state(subnet, kr, beacon_data->key_id);
 
 	net_key_beacon_refresh(beacon_data->key_id, net->iv_index,
-- 
2.17.1


  parent reply	other threads:[~2020-03-24 19:28 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20200324192821epcas5p3e756863feafcf1f8eab993a237c19521@epcas5p3.samsung.com>
2020-03-24 19:27 ` [PATCH 1/1] mesh: Add mesh agent cleanup to mesh cleanup Prathyusha Nelluri
     [not found]   ` <CGME20200324192820epcas5p10a4ae9a6d7e7dab22f4a5ab4ee752099@epcas5p1.samsung.com>
2020-03-24 19:27     ` [PATCH 1/1] mesh: Check limits for count and interval of relay Prathyusha Nelluri
2020-03-25 19:12       ` Gix, Brian
2020-03-26 17:02         ` Gix, Brian
     [not found]   ` <CGME20200324192821epcas5p1cc8182aac6ed0b096c76e3ccbd269688@epcas5p1.samsung.com>
2020-03-24 19:27     ` [PATCH 1/1] mesh: Handle close for Acceptor Prathyusha Nelluri
     [not found]   ` <CGME20200324192822epcas5p2986c35616c596051bb7826457439c893@epcas5p2.samsung.com>
2020-03-24 19:27     ` [PATCH 1/1] mesh: Handle invalid public keys Prathyusha Nelluri
2020-03-26 17:03       ` Gix, Brian
     [not found]   ` <CGME20200324192823epcas5p3b25363353b98e206a50d7fd4572c9552@epcas5p3.samsung.com>
2020-03-24 19:27     ` Prathyusha Nelluri [this message]
     [not found]   ` <CGME20200324192824epcas5p4886d88a31b8f9b31eeaf2fa38385698b@epcas5p4.samsung.com>
2020-03-24 19:27     ` [PATCH 1/1] mesh: Handle KeyRefresh phase set to 3 Prathyusha Nelluri
     [not found]   ` <CGME20200324192824epcas5p1de37a38491d79ea6dca2cc5da50cd289@epcas5p1.samsung.com>
2020-03-24 19:27     ` [PATCH 1/1] mesh: Handle netkey delete when netkey is not in netkeylist Prathyusha Nelluri
2020-03-26 17:03       ` Gix, Brian
     [not found]   ` <CGME20200324192825epcas5p4c038b652414de6be433f224a655a2244@epcas5p4.samsung.com>
2020-03-24 19:27     ` [PATCH 1/1] mesh: Initialize local_acked to zero Prathyusha Nelluri
     [not found]   ` <CGME20200324192826epcas5p2eb80e44ac061329faf5421ba3b76e5f8@epcas5p2.samsung.com>
2020-03-24 19:27     ` [PATCH 1/1] mesh: Send input complete for input OOB Authentication Prathyusha Nelluri
2020-03-26 17:02       ` Gix, Brian
     [not found]   ` <CGME20200324192827epcas5p3f70d5e24d6042786ffea8bdbd5ddc8e8@epcas5p3.samsung.com>
2020-03-24 19:27     ` [PATCH 1/1] mesh: Validate Provisioning Start PDU values Prathyusha Nelluri

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1585078044-14974-5-git-send-email-prathyusha.n@samsung.com \
    --to=prathyusha.n@samsung.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=s.syam@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).