gamemann / XDP-Firewall

A firewall that utilizes the Linux kernel's XDP hook. The XDP hook allows for very fast network processing on Linux systems. This is great for dropping malicious traffic from a (D)DoS attack. IPv6 is supported with this firewall! I hope this helps network engineers/programmers interested in utilizing XDP!
https://deaconn.net/
MIT License
492 stars 87 forks source link

[Question] Optimization #34

Closed Nasty07 closed 1 year ago

Nasty07 commented 1 year ago

I noticed that filtersmap is getting re-written in each update loop. Is there an actual reason for it that I am missing? What if we only update the hashmap when the conf has been actually edited, by tracking the files "st_mtime"?

I don't know how to calculate the performance increase, but I can make a pr for it.

gamemann commented 1 year ago

Hey! The reason for the functionality being added was to automatically update the filters when a change to the config file occurs so you didn't have to restart the program. What you proposed is a much better solution, though. To be honest, I was fairly new to C when writing this firewall and having the BPF maps update only when a filter changes via config is safer and better for performance.

Unfortunately, I've been running into time constraints due to other projects I'm working on, so I'm not sure when I'd have time to look into this. A PR would be appreciated and if you go that route, you may modify the README.md as well to add your username to the credits if you'd like. If you want, I can give you write access to the repository as well since you seem pretty smart with C and such 😃

Thanks for the help as well!

Nasty07 commented 1 year ago

Thanks for the trust! I wish I was super good with C but I am not heh, just a hard worker. I studied your project a lot to make my own firewall and these are things/ideas I came across. I have the code ready in my fork so I'll make a pr soon.

Nasty07 commented 1 year ago

You can check #35

gamemann commented 1 year ago

No problem and thank you for the PR, I just merged it!

I was curious if we could talk a bit further on Discord via chat if you have the application in regards to write access in the case you find anything else that should be improved on.

Nasty07 commented 1 year ago

Sure, I already joined your Modding-Com discord, you can find me under this nick -> Nasty#1010