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

Rule logging could slow down the system #1105

Open
filippocarletti opened this issue Mar 3, 2025 · 7 comments
Open

Rule logging could slow down the system #1105

filippocarletti opened this issue Mar 3, 2025 · 7 comments
Assignees
Labels
testing Packages are available from testing repositories

Comments

@filippocarletti
Copy link
Member

Enabling logging on single rules or zones may slow down the firewall.
Logging should always be limited.

Steps to reproduce

  • Create a firewall rule with logging enabled (prefer the UDP protocol)
  • Generate network traffic matching the rule

Expected behavior

The system should behave consistently while logging packets.

Actual behavior

Network traffic slows down while traffic is being logged.

See also

https://openwrt.org/docs/guide-user/firewall/fw3_configurations/fw3_traffic_logging
openwrt/firewall4@597dc90
openwrt/firewall4@1874050

@github-project-automation github-project-automation bot moved this to ToDo 🕐 in NethSecurity Mar 3, 2025
@gsanchietti gsanchietti added this to the NethSecurity 8.5 milestone Mar 3, 2025
@gsanchietti gsanchietti self-assigned this Mar 3, 2025
@gsanchietti gsanchietti moved this from ToDo 🕐 to In Progress 🛠 in NethSecurity Mar 3, 2025
@filippocarletti
Copy link
Member Author

filippocarletti commented Mar 3, 2025

Rule limit:

firewall.ns_b99826ea.log='1'
firewall.ns_b99826ea.log_limit='1/s'

Zone limit:

firewall.ns_lan.log='1'
firewall.ns_lan.log_limit='5/s'

@filippocarletti
Copy link
Member Author

A command to generate traffic:

sudo nmap -sU -Pn -T5 --min-rate 1000 192.168.1.1

Copy link
Contributor

github-actions bot commented Mar 5, 2025

Testing image version: 8-24.10.0-ns.1.4.99-alpha1-17-g3baea05c

@github-actions github-actions bot added the testing Packages are available from testing repositories label Mar 5, 2025
@gsanchietti gsanchietti removed their assignment Mar 5, 2025
@gsanchietti
Copy link
Member

Test case 1: firewall rules

  • From the UI, create a firewall rule with logging enabled
  • Verify the new rule has the log_limit option
  • From the UI, disable the logging for the same rule
  • Verify log option is set to 0 and log_limit option is not present

Test case 2: firewall rules, custom limit per rule

  • From the UI, create a firewall rule with logging enabled
  • Verify the new rule has the log_limit option
  • Manually change the limit from command line:
    uci set firewall.<id_rule>.log_limit='30/s'`
    uci commit firewall
    reload_config
    
  • From the UI, change something on the rule (eg. the name)
  • Verify the custom log_limit has not been overridden

Test case 3: redirects

  • Repeat the test case 1 but with a redirect (port-forward) rule

Test case 4: redirects, custom limit per rule

  • Repeat the test case 2 but with a redirect (port-forward) rule

Test case 5: zones

  • Repeat the test case 1 but with a zone

Test case 6: zones, custom limit

  • Repeat the test case 2 but with a zone

Test case 7

  • Use an existing installation where the issue is reproducible
  • From the command line, execute: firewall-apply-default-logging
  • Verify that all firewall rules, redirects rules and zones with logging enabled, now have the log_limit option
  • Verify the issue is not reproducible: the firewall must handle all the traffic without slowing down

@Tbaile Tbaile moved this from In Progress 🛠 to Testing in NethSecurity Mar 5, 2025
@Tbaile Tbaile self-assigned this Mar 5, 2025
@filippocarletti
Copy link
Member Author

I've successfully verified test cases 1-6.
Only one note, about the not harmful messages on every firewall restart:

root@NethSec:~# /etc/init.d/firewall restart
Section ns_defaults specifies unknown option 'rule_log_limit'
Section ns_defaults specifies unknown option 'zone_log_limit'
Section ns_defaults specifies unknown option 'redirect_log_limit'

@filippocarletti
Copy link
Member Author

Test case 7 ok:

 config zone 'ns_wan'
 	option name 'wan'
 	option input 'REJECT'
 	option output 'ACCEPT'
 	option forward 'REJECT'
 	option masq '1'
 	option mtu_fix '1'
 	list network 'wan'
 	list network 'DMZ'
 	list network 'al_DMZ'
 	option log '1'
+	option log_limit '5/s'

 config rule 'ns_allow_https'
 	option name 'Allow-HTTPS-from-WAN'
 	option src 'wan'
 	option dest_port '443'
 	option target 'ACCEPT'
 	option ns_service 'custom'
 	list proto 'tcp'
 	option enabled '1'
 	option log '1'
+	option log_limit '1/s'

@Tbaile
Copy link
Contributor

Tbaile commented Mar 6, 2025

Test case 3 has some concerns: when removing the log option through the UI, the log config is not set to 0, but deleted entirely. If this is intended, carry on.

Test case 4 fails:

root@NethSec:~# uci show firewall.ns_141e492f.log_limit
firewall.ns_141e492f.log_limit='30/s'

When i change the name of the port forward:

root@NethSec:~# uci changes
firewall.ns_141e492f.log_limit='1/s'
firewall.ns_141e492f.name='Test 2'
-firewall.ns_141e492f.proto
firewall.ns_141e492f.proto+='tcp'
firewall.ns_141e492f.proto+='udp'

Case 1,2,5,6 are verified.

@Tbaile Tbaile assigned gsanchietti and unassigned filippocarletti and Tbaile Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
testing Packages are available from testing repositories
Projects
Status: Testing
Development

No branches or pull requests

3 participants