Linux-Bluetooth Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH BlueZ] mesh: Fix exiting IV_UPD_STATE when receiving first SNB
@ 2020-01-09 12:58 Michał Lowas-Rzechonek
  2020-01-14 14:40 ` Gix, Brian
  0 siblings, 1 reply; 2+ messages in thread
From: Michał Lowas-Rzechonek @ 2020-01-09 12:58 UTC (permalink / raw)
  To: linux-bluetooth

First valid SNB received from the network should cause the node to
switch into IV_UPD_NORMAL state.

Otherwise, it will never try to enter IV Update procedure when sequence
number approaches the IV_UPDATE_SEQ_TRIGGER, because that's only allowed
in IV_UPD_NORMAL.
---
 mesh/net.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/mesh/net.c b/mesh/net.c
index 20e9a1e81..bd8826b58 100644
--- a/mesh/net.c
+++ b/mesh/net.c
@@ -2688,11 +2688,17 @@ static void process_beacon(void *net_ptr, void *user_data)
 	/* We have officially *seen* this beacon now */
 	beacon_data->processed = true;
 
-	if (ivi == net->iv_index && ivu == net->iv_update && kr == local_kr)
-		return;
+	/*
+	 * Ignore the beacon if it doesn't change anything, unless we're
+	 * doing IV Recovery
+	 */
+	if (net->iv_upd_state == IV_UPD_INIT ||
+				ivi != net->iv_index || ivu != net->iv_update)
+		update_iv_ivu_state(net, ivi, ivu);
+
+	if (kr != local_kr)
+		update_kr_state(subnet, kr, beacon_data->key_id);
 
-	update_iv_ivu_state(net, ivi, ivu);
-	update_kr_state(subnet, kr, beacon_data->key_id);
 	net_key_beacon_refresh(beacon_data->key_id, net->iv_index,
 		!!(subnet->kr_phase == KEY_REFRESH_PHASE_TWO), net->iv_update);
 }
-- 
2.19.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH BlueZ] mesh: Fix exiting IV_UPD_STATE when receiving first SNB
  2020-01-09 12:58 [PATCH BlueZ] mesh: Fix exiting IV_UPD_STATE when receiving first SNB Michał Lowas-Rzechonek
@ 2020-01-14 14:40 ` Gix, Brian
  0 siblings, 0 replies; 2+ messages in thread
From: Gix, Brian @ 2020-01-14 14:40 UTC (permalink / raw)
  To: michal.lowas-rzechonek, linux-bluetooth

Applied
On Thu, 2020-01-09 at 13:58 +0100, Michał Lowas-Rzechonek wrote:
> First valid SNB received from the network should cause the node to
> switch into IV_UPD_NORMAL state.
> 
> Otherwise, it will never try to enter IV Update procedure when sequence
> number approaches the IV_UPDATE_SEQ_TRIGGER, because that's only allowed
> in IV_UPD_NORMAL.
> ---
>  mesh/net.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/mesh/net.c b/mesh/net.c
> index 20e9a1e81..bd8826b58 100644
> --- a/mesh/net.c
> +++ b/mesh/net.c
> @@ -2688,11 +2688,17 @@ static void process_beacon(void *net_ptr, void *user_data)
>  	/* We have officially *seen* this beacon now */
>  	beacon_data->processed = true;
>  
> -	if (ivi == net->iv_index && ivu == net->iv_update && kr == local_kr)
> -		return;
> +	/*
> +	 * Ignore the beacon if it doesn't change anything, unless we're
> +	 * doing IV Recovery
> +	 */
> +	if (net->iv_upd_state == IV_UPD_INIT ||
> +				ivi != net->iv_index || ivu != net->iv_update)
> +		update_iv_ivu_state(net, ivi, ivu);
> +
> +	if (kr != local_kr)
> +		update_kr_state(subnet, kr, beacon_data->key_id);
>  
> -	update_iv_ivu_state(net, ivi, ivu);
> -	update_kr_state(subnet, kr, beacon_data->key_id);
>  	net_key_beacon_refresh(beacon_data->key_id, net->iv_index,
>  		!!(subnet->kr_phase == KEY_REFRESH_PHASE_TWO), net->iv_update);
>  }

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-09 12:58 [PATCH BlueZ] mesh: Fix exiting IV_UPD_STATE when receiving first SNB Michał Lowas-Rzechonek
2020-01-14 14:40 ` Gix, Brian

Linux-Bluetooth Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-bluetooth/0 linux-bluetooth/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-bluetooth linux-bluetooth/ https://lore.kernel.org/linux-bluetooth \
		linux-bluetooth@vger.kernel.org
	public-inbox-index linux-bluetooth

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-bluetooth


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git