@@ -554,6 +554,35 @@ fw_driver=iptables
554554 test_port_fw ip=6 proto=udp hostip=" fd65:8371:648b:0c06::1"
555555}
556556
557+ # Test that port forwarding works with strict Reverse Path Forwarding enabled on the host
558+ @test " $fw_driver - port forwarding with two networks and RPF - tcp" {
559+ # First, enable strict RPF on host/container ns.
560+ run_in_host_netns sysctl -w net.ipv4.conf.all.rp_filter=1
561+ run_in_host_netns sysctl -w net.ipv4.conf.default.rp_filter=1
562+ run_in_container_netns sysctl -w net.ipv4.conf.all.rp_filter=1
563+ run_in_container_netns sysctl -w net.ipv4.conf.default.rp_filter=1
564+
565+ # We need a dummy interface with a host ip,
566+ # if we connect directly to the bridge ip it doesn't reproduce.
567+ add_dummy_interface_on_host dummy0 " 10.0.0.1/24"
568+
569+ run_netavark --file ${TESTSDIR} /testfiles/two-networks.json setup $( get_container_netns_path)
570+ result=" $output "
571+
572+ run_in_host_netns cat /proc/sys/net/ipv4/conf/podman2/rp_filter
573+ assert " 2" " rp_filter podman2 bridge"
574+ run_in_host_netns cat /proc/sys/net/ipv4/conf/podman3/rp_filter
575+ assert " 2" " rp_filter podman3 bridge"
576+
577+ run_in_container_netns cat /proc/sys/net/ipv4/conf/eth0/rp_filter
578+ assert " 2" " rp_filter eth0 interface"
579+ run_in_container_netns cat /proc/sys/net/ipv4/conf/eth1/rp_filter
580+ assert " 2" " rp_filter eth1 interface"
581+
582+ # Important: Use the "host" ip here and not localhost or bridge ip.
583+ run_nc_test " 0" " tcp" 8080 " 10.0.0.1" 8080
584+ }
585+
557586@test " bridge ipam none" {
558587 read -r -d ' \0' config << EOF
559588{
789818 # when the sysctl value is already set correctly we should not error
790819 run_in_host_netns sh -c " echo 1 > /proc/sys/net/ipv4/ip_forward"
791820 run_in_container_netns sh -c " echo 1 > /proc/sys/net/ipv4/conf/default/arp_notify"
821+ run_in_host_netns sh -c " echo 2 > /proc/sys/net/ipv4/conf/default/rp_filter"
822+ run_in_container_netns sh -c " echo 2 > /proc/sys/net/ipv4/conf/default/rp_filter"
792823 run_in_host_netns mount -t proc -o ro,nosuid,nodev,noexec proc /proc
793824
794825 run_netavark --file ${TESTSDIR} /testfiles/simplebridge.json setup $( get_container_netns_path)
0 commit comments