Skip to content

[CRM] Safety check for division by 0#1569

Merged
lguohan merged 1 commit intosonic-net:masterfrom
prsunny:crmfix
Dec 26, 2020
Merged

[CRM] Safety check for division by 0#1569
lguohan merged 1 commit intosonic-net:masterfrom
prsunny:crmfix

Conversation

@prsunny
Copy link
Collaborator

@prsunny prsunny commented Dec 25, 2020

What I did
Check if divisor is 0. If yes, log warning and skip division

Why I did it
Safety check to avoid exception and crash.

How I verified it

Details if related

@lguohan lguohan merged commit 41fd2c4 into sonic-net:master Dec 26, 2020
@prsunny prsunny deleted the crmfix branch December 27, 2020 18:51
yxieca pushed a commit that referenced this pull request Feb 17, 2021
Check if divisor is 0. If yes, log warning and skip division
prsunny pushed a commit that referenced this pull request Nov 16, 2021
*Test divide by zero processing path. Add vs test coverage for #1569
Signed-off-by: Wenda Ni <wonda.ni@gmail.com>
EdenGri pushed a commit to EdenGri/sonic-swss that referenced this pull request Feb 28, 2022
What I did
There is a bug that occasionally turn root-overlay as RO. This makes /etc & /home as RO. This blocks any new remote user login, as that needs to write into /etc & /home.

This tool scans /etc & /home (or given dirs) as in RW or RO state. If RO, it could create a writable overlay using tmpfs.
This is transient and stays until next reboot. Any write after the overlay will be lost upon reboot.

But this allows new remote users login.

How I did it
Create upper & work dirs in /run/mount (tmpfs). Mount /etc & /home as lowerdirs and use the same name for final merge. This allows anyone opening a file in /etc or /home to operate on the merged overlay, transparently.

How to verify it
Mount any dir on tmpfs ( mount -t tmpfs tmpfs test_dir)
remount as RO (mount -o remount,ro test_dir)
Pass that dir to this script. (disk_check.py -d ./test_dir)
Now it should be RW
Janetxxx pushed a commit to Janetxxx/sonic-swss that referenced this pull request Nov 10, 2025
Check if divisor is 0. If yes, log warning and skip division
Janetxxx pushed a commit to Janetxxx/sonic-swss that referenced this pull request Nov 10, 2025
*Test divide by zero processing path. Add vs test coverage for sonic-net#1569
Signed-off-by: Wenda Ni <wonda.ni@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants