openwrt / openwrt

This repository is a mirror of https://git.openwrt.org/openwrt/openwrt.git It is for reference only and is not active for check-ins. We will continue to accept Pull Requests here. They will be merged via staging trees then into openwrt.git.
Other
20.6k stars 10.57k forks source link

FS#31 - firewall3 fails to reload iptables policy extension #5311

Closed openwrt-bot closed 8 years ago

openwrt-bot commented 8 years ago

mpa:

download and install firmware image lede-lantiq-xrx200-TDW8980-squashfs-sysupgrade.bin

fw3 -d restart

Result: firewall rules as expected

opkg install iptables-mod-ipsec

uci set "firewall.@zone[0].extra_src=-m policy --dir in --pol none"

uci set "firewall.@zone[0].extra_dest=-m policy --dir out --pol none"

fw3 -d restart

Results:

My experiments seem to confirm that this is caused by missing dlclose support in musl libc. firewall3 uses dlclose/dlopen to reload iptables extensions for each address family and table, and it expects the extensions' constructor functions to be called each time. In musl, dlclose does nothing, and unloading/reloading of a shared library does not call its constructor function again. To check my theory, I added explicit calls to the extensions' _init() functions via dlsym. This made the policy match work again in all tables, but then firewall3 hangs on exit (tested with LEDE r289). I don't now if it is actually allowed to call dynamic library constructor functions explicitly.

Then I considered a more complex solution, but have no code for it yet. In short:

However, I would like to hear your opinion first how this bug should best be solved. If you want to work on this yourself, I'll step back and watch.

Regards Mirko

openwrt-bot commented 8 years ago

jow-:

Phew, thanks for the report. I'll investigate.

openwrt-bot commented 8 years ago

jow-:

I came up with a different approach which is less invasive compared to your multi process suggestion. Please give the attached patch a try and tell me if it solves your extension loading problem.

openwrt-bot commented 8 years ago

mpa:

Yes, the problem is solved, and your solution seems better than my idea.

The warnings are gone, and the policy matches now also appear in IPv4 nat and IPv6 filter, where they were previously missing.

Thank you. Mirko

openwrt-bot commented 8 years ago

jow-:

Fixed in master with http://git.lede-project.org/113544d