-
Notifications
You must be signed in to change notification settings - Fork 3.8k
snort3: fix deps and CMake options per arch to allow building for more devices #27037
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
Conversation
0a68dc2 to
7d42947
Compare
3ac1210 to
f79ef83
Compare
|
Traveling this whole week... |
|
I pushed to your repo. Check it out. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the snort3 package build configuration to improve cross-architecture compatibility by making architecture-specific dependencies optional and using conditional CMake options based on the target architecture.
Key changes:
- Replaced hardcoded architecture filtering for dependencies with optional package dependencies
- Moved architecture-specific CMake options into conditional blocks based on CONFIG_ARCH
- Simplified dependency declaration by inlining them directly in the Package/snort3 definition
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
I think we should merge this as it is to solve the missing snort3 packages for almost any OpenWrt device except aarch64 and x86_64. Further improvements can be done later. This is definitely a huge step forward, and I’d like to backport it to OpenWrt 24.10 as soon as possible. If @graysky2 finds a better solution, he can always open another pull request. :) Before merging, I’ll drop the recently added commit related to actions-shared-workflows, since it was only created for testing and submitting a PR against that repo. |
|
I agree @BKPepe, this is a major step forward, thank you for the collaboration! |
|
Since you merged our two commits, eg BKPepe@f999d41 I think you add me as a Co-authored-by, no? |
I didn't merge your commits to my branch, because CI/CD in BKPepe#4 still fails. |
|
|
|
I’ve spent quite a lot of time looking into the things you added to the packages repository, especially regarding the integration of vectorscan/hyperscan and gperftools for snort3. Being a package maintainer is not just about adding and updating packages — it also means addressing certain issues with the upstream developers, or passing on some of the tasks I asked you to solve (e.g. #21627 (comment)). I have to say I was a bit disappointed that things were not properly finalized, and I had to step in to make sure snort3 could be used on more devices than just aarch64 and x86_64. Looking at the history, ever since I wrote this comment: #24055 (comment), things have still not been fully polished. Step by step, with the changes I’ve prepared, we’re getting closer, but since last week there’s already a change prepared that works and has passed CI/CD. Now you’re telling me this needs more time, but how much time is actually needed?
But we should also ask ourselves an important question: how many people actually use snort3 on OpenWrt, and how many of them really require tmalloc or hyperscan/vectorscan support — or both at the same time? OpenWrt can run even on very minimal devices with as little as 8 MB of flash and 64 MB of RAM. I understand that these integrations are important to you, but for many users they are simply not. For them, basic snort3 support will be more than enough. I’m not saying that my solution is the perfect one, but I believe we should merge it as it is for now. If you later come up with a better approach, feel free to adjust and improve it. :) |
|
Many of the points you raise are valid. Your time and effort to help diagnose and fix the non-trivial dependency chain are also appreciated. OpenWrt is a complex system given the multiple targets/SoCs it offers so I feel that at times, that keeping things updated and working is a team sport. Can you please edit the commit msg to mention the need to manually pull in these two dependencies since both give performance increases? Also please mention the intention to fix this in a future PR. Then let's merge this PR. /edit also did you want to bump the |
|
Please keep in mind that others cannot be expected to fix mistakes just because someone “didn’t have the time” to test or check properly. In open-source, people usually dedicate their free time to things they find interesting and want to contribute to, rather than correcting issues caused by someone else’s lack of effort.
I’m not quite sure what you mean by manually pulling those two dependencies. If you were using an official OpenWrt build on your router and installing packages from the OpenWrt repository, you would simply install snort3. If vectorscan/hyperscan and/or gperftools are available, they would be installed automatically as dependencies, since snort3 was compiled with their support. It seems like you haven’t tested this thoroughly. You can try it by using the available build artifacts. What I meant is that if gperftools, vectorscan, or hyperscan fail to build due to an error or because the architecture is unsupported, their support will just be disabled, but snort3 will still work without them. What remains questionable is how important gperftools really is for snort3. You would need a very powerful device to see any real benefit. For regular snort3 usage, you don’t actually need gperftools.
Well, no — because that would imply I’m committing to doing that, which I’m not. Anyone could do that. :) |
1. Enabled hyperscan/vectorscan together with adding dependency only for x86_64 and aarch64. 2. Disabled tmalloc (from gperftools package) for powerpc and mips. By doing this refactor, snort3 is going to be available for more OpenWrt devices (as it was in the past) as currently it was compiled only for x86_x64 and aarch64 by mistake. Fixes: 257e2fc ("snort3: fix logic in gpertools-runtime depends") Signed-off-by: Josef Schlehofer <[email protected]>
|
@neheb Could you also take a look here, please? :) |
This happened not out of laziness, the blind spot is that I am continuing to learning the OpenWrt build system. This is why I am now using this script to help me cover the many targets and subtargets.
I am thinking (perhaps incorrectly) that if this is merged, the build bots will indeed compile snort3 but will do so without gperftools and without vectorscan. So the only way to users can have access to snort3 compiled against either or both of those is to compile an image on their own. I based my statement on the output of the aforementioned script after pull in this PR: Click to expand
✔ means enabled ; ✘ means available but disabled ; blank means unavailable |
You're thinking in the right direction, but your reasoning isn’t entirely correct. At this point, the pull request has successfully passed the CI/CD tests, and if you look at the logs, you’ll see that support for vectorscan, hyperscan, and gperftools is enabled, if it is available. CI/CD uses minimal builds. The condition in the Makefile ensures that these packages are selected and used automatically if they’re available. OpenWrt buildbots compile all packages. I believe (and hopefully I’m right) that in your make menuconfig, you don’t have vectorscan, hyperscan, or gperftools selected — which means the build system isn’t aware of them. Simply mark them as M (modules). You can also test this by forcing those dependencies as Y and then recompiling snort3. That way, the build system will recognize them and compile with the proper support. Oh and dont forget to save in make menuconfig. |
I see... so the order of the build matters? For users compiling their own images, I believe they will have to manually select these based on the output of the script I referenced above. Is this a correct statement? When you are back home and can have a look, BKPepe@e7ecbe7 seeks to address this. |
| CATEGORY:=Network | ||
| DEPENDS:=$(SNORT3DEPS) | ||
| DEPENDS:=+libstdcpp +libdaq3 +libdnet +libopenssl +libpcap +libpcre2 \ | ||
| +libpthread +libuuid +zlib +libhwloc +libtirpc @HAS_LUAJIT_ARCH +luajit +libatomic \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
libpthread can go away.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, let's remove it in different PR as I am thinking that this is not related to this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, mabye packages (you pointed it even in syslog-ng) has this dependency. Shouldn't be there treewide commit removal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably
| -DENABLE_HYPERSCAN=OFF | ||
| endif | ||
|
|
||
| TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include/daq3 -I$(STAGING_DIR)/usr/include/tirpc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this is interesting. Typically tirpc is added for musl and not glibc. See https://github.com/openwrt/packages/blob/master/net/dante/Makefile#L36
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not using glibc, but good catch, let's create PR and let me ask someone to try it. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the CI completed successfully in that PR. Thank you @neheb for pointing this out.
Yes, this is my point. A user should not need to know that in addition to selecting snort3, he or she must also select (either as a module or compiled in) vectorscan-runtime and gperftools-runtime. The build system should do this. For example, use this is your .config: Now I am trying to fix this in BKPepe#4 as you know but hitting snags. @neheb - if you have any suggestions, I am grateful to hear them. |
|
You have to look at it from another perspective. Hyperscan, Vectorscan, and possibly gperftools are not mandatory dependencies. So why should someone be forced to use them if they don’t want to? For the average OpenWrt user who simply downloads an official image and installs packages built by the buildbot, everything will already be feature-complete — just as you intend it to be. But what if someone doesn’t want that? :) Many technically skilled users prefer to build their own OpenWrt images with a minimal set of packages. They first need to check whether their router even has enough capacity, and then explicitly choose which optional dependencies to include during compilation. That’s a conscious design choice. From that perspective, the build system behaves exactly as it should. It can’t — and shouldn’t — “know” about packages that aren’t part of the build. Optional really means optional, and that flexibility is one of the core strengths of the OpenWrt ecosystem. |
|
For now, I am merging this as it is. Discussion can be done as follow-up or you can finish the PR, which you referenced. |
|
@BKPepe - I can appreciate the minimalist's perspective. I wonder if the best solution here is to simply add some context/instruction to snort3's description to flag to users who might not know, that there are optionally dependencies that can and do improve snort's performance. I will create a new PR with this change. Thanks for explaining the user-case. EDIT: #27601 |
CI/CD testing