@@ -329,3 +329,67 @@ function setup() {
329329 expected_rc=1 run_netavark -f ${TESTSDIR} /testfiles/invalid-port.json setup $( get_container_netns_path)
330330 assert_json " .error" " invalid host ip \" abcd\" provided for port 8080" " host ip error"
331331}
332+
333+ @test " $fw_driver - test firewalld reload" {
334+ NETAVARK_FW=iptables run_netavark --file ${TESTSDIR} /testfiles/simplebridge.json setup $( get_container_netns_path)
335+
336+ check_simple_bridge_iptables
337+ assert " $( < $NETAVARK_TMPDIR /config/firewall/firewall-driver) " " ==" " iptables" " firewall-driver file content"
338+
339+ run_in_host_netns firewall-cmd --reload
340+
341+ # After a firewalld reload we expect rules to be deleted
342+ # expected_rc=1 run_in_host_netns iptables -S NETAVARK_FORWARD
343+ # There was a firewalld change in 3.0 that it no longer flushes all rules, howver we can still check if
344+ # we are added to trusted.
345+ run_in_host_netns firewall-cmd --zone=trusted --list-sources
346+ assert " $output " == " " " no trusted sources"
347+
348+ # start reload service on start it should restore the rules
349+ run_netavark_firewalld_reload
350+
351+ # this run in the background so give it some time to add the rules
352+ sleep 1
353+ check_simple_bridge_iptables
354+ run_in_host_netns firewall-cmd --zone=trusted --list-sources
355+ assert " $output " == " 10.88.0.0/16" " container subnet is trusted after start"
356+
357+ run_in_host_netns firewall-cmd --reload
358+ sleep 1
359+ check_simple_bridge_iptables
360+ run_in_host_netns firewall-cmd --zone=trusted --list-sources
361+ assert " $output " == " 10.88.0.0/16" " container subnet is trusted after reload"
362+ }
363+
364+ @test " $fw_driver - port forwarding ipv4 - tcp with firewalld reload" {
365+ test_port_fw firewalld_reload=true
366+ }
367+
368+ @test " $fw_driver - test firewalld reload" {
369+ NETAVARK_FW=nftables run_netavark --file ${TESTSDIR} /testfiles/simplebridge.json setup $( get_container_netns_path)
370+
371+ check_simple_bridge_nftables
372+ assert " $( < $NETAVARK_TMPDIR /config/firewall/firewall-driver) " " ==" " nftables" " firewall-driver file content"
373+
374+ run_in_host_netns firewall-cmd --reload
375+
376+ # There was a firewalld change in 3.0 that it no longer flushes all rules, howver we can still check if
377+ # we are added to trusted.
378+ run_in_host_netns firewall-cmd --zone=trusted --list-sources
379+ assert " $output " == " " " no trusted sources"
380+
381+ # start reload service on start it should restore the rules
382+ run_netavark_firewalld_reload
383+
384+ # this run in the background so give it some time to add the rules
385+ sleep 1
386+ check_simple_bridge_nftables
387+ run_in_host_netns firewall-cmd --zone=trusted --list-sources
388+ assert " $output " == " 10.88.0.0/16" " container subnet is trusted after start"
389+
390+ run_in_host_netns firewall-cmd --reload
391+ sleep 1
392+ check_simple_bridge_nftables
393+ run_in_host_netns firewall-cmd --zone=trusted --list-sources
394+ assert " $output " == " 10.88.0.0/16" " container subnet is trusted after reload"
395+ }
0 commit comments