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

Add Log Expression #56

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Conversation

KyleKaniecki
Copy link

@KyleKaniecki KyleKaniecki commented Mar 14, 2024

Builds on top of dead PR #46 to add log expressions to macros, and addresses PR comments

Fixes #45


This change is Reviewable

Copy link
Member

@faern faern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for wanting to contribute! I definitely see good usage for logging expressions!

Can you please also add this expression to the add-rules example? It's nice to showcase as many expressions as possible. I'm thinking like:

allow_loopback_in_rule.add_expr(&nft_expr!(log));

unsafe {
let expr = try_alloc!(sys::nftnl_expr_alloc(b"log\0" as *const _ as *const c_char));
if let Some(group) = self.group {
sys::nftnl_expr_set_u16(expr, sys::NFTNL_EXPR_LOG_GROUP as u16, group as u16);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

group as u16 <- group is already a u16, no need to cast.

}

#[macro_export]
macro_rules! nft_expr_log {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also need to add this as a separate branch into nft_expr! macro also. So it's possible to create all types of expression with just nft_expr!(...)

@faern
Copy link
Member

faern commented May 29, 2024

Please also squash some of your git history to tidy it up a bit 🙏

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

Successfully merging this pull request may close these issues.

How to add a log rule
2 participants