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

does bpfilter support redirect? #167

Open
liudf0716 opened this issue Nov 12, 2024 · 2 comments
Open

does bpfilter support redirect? #167

liudf0716 opened this issue Nov 12, 2024 · 2 comments

Comments

@liudf0716
Copy link

I’m currently developing an open-source project, apfree-wifidog, which relies on nftables to handle HTTP and HTTPS redirection for network control purposes. I'm interested in using bpfilter to potentially accelerate performance. However, a key requirement is that bpfilter needs to support HTTP and HTTPS redirection functionality similar to what nftables offers. Does bpfilter currently support such redirection features? And if not, are there recommended workarounds or upcoming features that might facilitate this?

the nft rule like this:

nft add rule inet fw4 dstnat_wifidogx_unknown tcp dport 80 redirect to  2060
@qdeslandes
Copy link
Contributor

Hi @liudf0716

Redirect is not supported for now, as this is NAT related, it would need some design first before it can be properly integrated to bpfilter. I'm happy to mentor anyone that will try to do it.

An easier solution would be to support user-defined bytecode (it's on the roadmap for 2025 H1, which will be published as soon as it's validated):

  • Users define their own filtering logic as a BPF program, in this case: check if tcp.dport is 80, then redirect the packet to the correct port.
  • The compiled BPF program is sent to bpfilter, which integrates it as a custom rule.
  • At runtime, the user-provided bytecode is executed as part of a rule.

User-defined bytecode would ensure bpfilter supports virtually every use case.

@liudf0716
Copy link
Author

liudf0716 commented Nov 14, 2024

@qdeslandes, thank you for your help and guidance. I've made some progress in porting bpfilter to OpenWRT, as it's being used in conjunction with APFree WiFidog on this platform.

To simplify the compilation process on OpenWRT, I added two options to disable documentation and testing. Additionally, I've included the necessary dependency for argp support, which is argp-library, in the relevant CMakeLists.txt files.

Although I've successfully compiled and ported bpfilter to OpenWRT, there are still some issues to be addressed. I've submitted a pull request (PR) to the bpfilter main branch, and I'd appreciate it if you could review it and provide some feedback to help make it suitable for merging.

You can find the PR link below. Thank you again for your assistance and guidance!
#172

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants