Skip to content

Fix AiMesh 2nd Login Attempt - #615

Open
ExtremeFiretop wants to merge 11 commits into
devfrom
Fix-AiMesh-2nd-Login
Open

ExtremeFiretop wants to merge 11 commits into
devfrom
Fix-AiMesh-2nd-Login

Conversation

@ExtremeFiretop

@ExtremeFiretop ExtremeFiretop commented Sep 25, 2026 •

Copy link
Copy Markdown
Owner

@Martinski4GitHub

Extension of your PR: #603
Currently, the code allows the node to try a second time when it detects a stale cookie/session

However, the primary does not attempt to "logout" after it invalidates the nodes cookie first, and grabs the node data / flashing status. This means the node is not actually allowed to login on the second attempt. Since the first session is still held by the primary router.

See the below error I received while testing for release:

  • CODE BLOCK:
Please wait to allow already started cron jobs to complete execution...
Done.
Post-update email notification hook was added successfully to '/jffs/scripts/services-start' script.
MerlinAU_[14510]: START of Unmount/Eject USB Drive...
MerlinAU_[14510]: Unmount/Eject USB Drive succeeded [10 secs]
MerlinAU_[14510]: END of Unmount/Eject USB Drive.

Flashing RT-BE92U_3006_102.9_0_nand_squashfs.pkgtb...
Please wait for reboot in about 4 minutes or less.

MerlinAU_[14510]: **ERROR**: Router Login 2nd Attempt Failed [Login Failure Code: 777].
MerlinAU_[14510]: *WARNING*: Router will be rebooted at this point.

Sending email notification [FAILED_FW_UPDATE_STATUS].
Please wait...
The email notification [FAILED_FW_UPDATE_STATUS] was sent successfully.
Terminated
Admin@RT-BE92U-2340:/tmp/home/root#
Done.
  • SCREENSHOT:
Screenshot 2026-09-24 183525

I've adjusted the logic so as soon as the primary logs into the node, grabs the flashing status, it sends a logout.

I also learned that routers with nvram set: re_mode=1 will reject a logout request from the primary router anyways. https://github.com/RMerl/asuswrt-merlin.ng/blob/53680019cc1491452ecda2824e1b43f32a34d61b/release/src/router/httpd/httpd.c#L1672

Due to this, I used a bounced attempt to restart the httpd service which will release the primary router session and invalidate it's cookie, and allow the second login to work from the node.

I kept the attempted logout in place in case it works, for example, on my older routers on 3004 firmware.
However the real save will end up being the httpd restart.

Additionally, I added some nicer formatting around the (mn) menu as found below:
Screenshot 2026-09-25 070537

I also found a bug not releasing/resetting the flashing flag we setup: merlinau_fw_update
and resolved that as well.. It should now say: Cleared AiMesh F/W-update NVRAM guard [merlinau_fw_update].

As found below:
image

Log out of an AiMesh node immediately when merlinau_fw_update=1 is detected.
Skip all further node actions / status while that node is flashing.
Report actively flashing nodes as busy instead of failed/unreachable in mn screen.
Clean up per-run AiMesh state properly.
Preserve failed WebUI login diagnostics in JFFS.
Protect concurrent diagnostic writes.
Reuse existing log-retention mechanism for the new diagnostic logs..
Clear the firmware-update guard on failed or aborted updates.
Fix Logout Request... Standardizing node logouts
removes the ineffective 5-second wait for login_ip_str to clear...
if the existing cookie has failed and login_ip_str is still populated, restarts httpd
Cleanup
improve wording
@ExtremeFiretop ExtremeFiretop added the bug Something isn't working label Sep 25, 2026
@ExtremeFiretop ExtremeFiretop changed the title Fix AiMesh 2nd login Attempt Fix AiMesh 2nd Login Attempt Sep 25, 2026
@ExtremeFiretop

ExtremeFiretop commented Sep 25, 2026 •

Copy link
Copy Markdown
Owner Author

I won't lie.
I'm still wrapping my brain around how I was so sure for the last 2 years since 2024 that the logouts worked.
#179 (comment)

But they only worked for me and @TheS1R because we had set the re_mode nvram value which allowed us to view and login to the node WebUI.

So this entire time the logout only worked because in my testing and development of the logout request, I had my node operating as a router. And it's WebUI restrictions were disabled.

Now, I don't think this is a reason to fully remove it. Many people are aware of the workaround to disable the restrictions on nodes. And otherwise it's a no-op and does nothing but send back a redirect request.

So I won't remove it. But I've clearly documented it in the notes, basically does nothing so I'll stop assuming in the future that the logouts actually work normally.

Long story short, that's the reason I pivoted from just doing a logout from the primary router to also doing a httpd restart on the node.

@ExtremeFiretop

ExtremeFiretop commented Sep 25, 2026 •

Copy link
Copy Markdown
Owner Author

FYI this was tested end to end on my side now.
And my node correctly flashed after the second login attempt, even when I interrupted it by logging in from the primary.

image

Moving the flashing wording
wording improvements
Comment thread MerlinAU.sh
Comment thread MerlinAU.sh Outdated
Comment thread MerlinAU.sh Outdated
Comment thread MerlinAU.sh
Comment thread MerlinAU.sh
Comment thread MerlinAU.sh
@Martinski4GitHub

Copy link
Copy Markdown
Collaborator

@ExtremeFiretop.

In general, the PR looks good, but I do have some questions, as noted above in my review comments.

Perhaps I'm already too tired, but I feel like something may be missing...(??)

Talk to you tomorrow when my brain has recharged and my mind is clearer... :>).

Additional cleanup
Correct date
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants