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