From ab871b50253f2ec0da7573457e3e7ae6145c3b44 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Mon, 4 Feb 2019 21:07:54 -0800 Subject: [PATCH] [mle] skip saving network info on role change to detached (#3553) This commit changes the behavior of `Mle` to skip the saving of network info (to non-volatile memory) on role change to detached. Note that `Store()` does only update the MAC/MLE counters if device is not attached. The MAC/MLE counters update is tracked already by `KeyManager`. --- src/core/thread/mle.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/core/thread/mle.cpp b/src/core/thread/mle.cpp index 8287ff77f..7a0df26a2 100644 --- a/src/core/thread/mle.cpp +++ b/src/core/thread/mle.cpp @@ -1522,7 +1522,13 @@ void Mle::HandleStateChanged(otChangedFlags aFlags) if (aFlags & (OT_CHANGED_THREAD_ROLE | OT_CHANGED_THREAD_KEY_SEQUENCE_COUNTER)) { - Store(); + // Store the settings on a key seq change, or when role changes and device + // is attached (i.e., skip `Store()` on role change to detached). + + if ((aFlags & OT_CHANGED_THREAD_KEY_SEQUENCE_COUNTER) || IsAttached()) + { + Store(); + } } if (aFlags & OT_CHANGED_SECURITY_POLICY)