Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE] “Error applying iptables rules” 30% of cases when Add Delay is selected #1353

Open
resolutecake opened this issue Sep 11, 2023 · 7 comments
Labels

Comments

@resolutecake
Copy link

Describe the bug
Due to inadequate parallelism code, iptables commands are delayed several seconds causes “Error applying iptables rules”
— fix: options -w1 -W1 to iptables for Android 11+
— retire Android less than 11, since those devices have unsupported swelling batteries anyway
— or fix the non-wait code, I didn’t bother

I would HIGHLY RECOMMEND to always use Add Delay and retire all pre-Android 11 devices

Firewall Logs
Please get the log from Menu -> Show Rules -> (menu) Export to storage and attach it here

Smartphone (please complete the following information):
Pixel 3/6/Samsung all

Additional context
There are two threads doing iptables but each collision waits 1 s: check man iptables to understand how its concurrency is supposed to work

@jackpennetta
Copy link

jackpennetta commented Sep 15, 2023

Hi!
Yesterday I had to install a fresh Android (upgrading from pie to android 13 [pixel experience]) on my phone with the last magisk root, and everything's going well so I wanted to install Afwall+ to secure my apps' internet connection, as I usually do on fresh androids.
Anyway once installed and configured the apk I tried to enable it applying the rules, but it seems to be impossible to proceed: the counter stucks at 46 or 47/113 (no matter which app I select, the same if none selected) for both ipv4 and ipv6 (same disabling ipv6) in "allow selected" mode. Same happens in "block selected" mode. It only enables the firewall in block selected if none is selected. I the previous system I had sporadic "error applying rules" but now I get it every time and then the connection hangs.
I understand it may be related with this topic but I'm not sure so I'm asking here before.

Should I try to fix as suggested above (fix: options -w1 -W1 to iptables for Android 11+) ? How am I supposed to apply -w1 -W1 options using the app?
Thanks in advance and please pardon me for my bad english

p.s. I forgot to mention that the "add delay" option didn't change anything in this case

@Mannshoch
Copy link

Same Problem here, If Afwall work. It seems not working permanently.It seems a bit random bit sometims no Internet connection is possible.
I assum that whitelist and unsucessfull load was the causr.

Exporting rules also not worked so I had to remove and downgrade AFWall and recreate all rules.

@vsatmydynipnet
Copy link

running into the same problems:

  • error applying the rules, especially when switching fast between nets, e.g. WLAN/LTE but also yesterday in an area switching often from home net to roaming LTE.
  • sometimes it stops traffic, needs to reboot

Ruuning LOS20 on Fairphone 3+, rooted with Magisk.

@resolutecake
Copy link
Author

resolutecake commented Sep 20, 2023

The app has several bugs, I am running my own branch

The -w1 -W1 is a code change in the app that I diagnosed and completed. Once the right answer is known, coding the fix is quick. -w1 -W1 are options to the iptables command available in Android since 11, and they allow iptables to retry concurrency collisions rather than doing retries outside the executable.

For some reason multiple threads do the iptables and the parallelism design is bad. This is why rules apply fails in 30% of cases whether with or without AddDelay. When anything fails, AFWall+ goes to a default which is blocking almost anything

I also fixed some crashes that also leads to block everything

3.5.3 is simply not reliable, but that is what people use. AFWall+ is only game in town

@resolutecake
Copy link
Author

resolutecake commented Sep 20, 2023

And you must use Active Rules or there is no VPN control
(note: if Active Rule is unselected checkbox settings in LAN and VPN are lost)

If you only want to control wi-fi and wan, Active Rules can be cleared, and fewer rules applications happen that may fail and cause block-all state

@resolutecake
Copy link
Author

The fix for AFWall+ bad state is to Apply Rules again
If you want it disabled, first enable then disable

Unless the last shown thing was a toaster “Rules applied with success” AFWall+ is in a bad state

@Marksway
Copy link

The app has several bugs, I am running my own branch
#1353 (comment)

Hello. Is it possible to test your build with new changes? If everything works, it might be great to send a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants