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

Fixed the bug of missing expression numgen from GetRules #297

Merged
merged 1 commit into from
Feb 3, 2025

Conversation

sanya2022
Copy link
Contributor

@sanya2022 sanya2022 commented Jan 31, 2025

When we create a rule with expression numgen, it is created correctly. Here's an example:

table inet james-filter {
	map m2798997459 {
		type 0 : ipv4_addr
		flags constant
		elements = { 0 : 1.1.1.1, 1 : 2.2.2.2, 2 : 3.3.3.3 }
	}
	chain input {
		type nat hook prerouting priority filter; policy accept;
		ip saddr 1.1.1.1 th dport 2222 log prefix "nflog" group 0 counter packets 0 bytes 0 dnat ip to numgen inc mod 3 map @m2798997459 comment "temp rule"
	}
}

However, when we get the same rule from netlink via this library, the expression numgen is missing:

2025/01/31 20:52:41 *expr.Meta &{15 false 1}
2025/01/31 20:52:41 *expr.Cmp &{0 1 [2]}
2025/01/31 20:52:41 *expr.Payload &{0 1 0 1 12 4 0 0 0}
2025/01/31 20:52:41 *expr.Cmp &{0 1 [1 1 1 1]}
2025/01/31 20:52:41 *expr.Payload &{0 1 0 2 2 2 0 0 0}
2025/01/31 20:52:41 *expr.Cmp &{0 1 [8 174]}
2025/01/31 20:52:41 *expr.Log &{0 0 6 0 0 0 [110 102 108 111 103]}
2025/01/31 20:52:41 *expr.Counter &{0 0}
2025/01/31 20:52:41 *expr.Lookup &{1 1 true 0 m2798997459 false}
2025/01/31 20:52:41 *expr.NAT &{1 2 1 1 0 0 false false false false false}

Example with fix:

2025/01/31 20:52:14 *expr.Meta &{15 false 1}
2025/01/31 20:52:14 *expr.Cmp &{0 1 [2]}
2025/01/31 20:52:14 *expr.Payload &{0 1 0 1 12 4 0 0 0}
2025/01/31 20:52:14 *expr.Cmp &{0 1 [1 1 1 1]}
2025/01/31 20:52:14 *expr.Payload &{0 1 0 2 2 2 0 0 0}
2025/01/31 20:52:14 *expr.Cmp &{0 1 [8 174]}
2025/01/31 20:52:14 *expr.Log &{0 0 6 0 0 0 [110 102 108 111 103]}
2025/01/31 20:52:14 *expr.Counter &{0 0}
2025/01/31 20:52:14 *expr.Numgen &{1 3 0 0}
2025/01/31 20:52:14 *expr.Lookup &{1 1 true 0 m2798997459 false}
2025/01/31 20:52:14 *expr.NAT &{1 2 1 1 0 0 false false false false false}

Copy link

google-cla bot commented Jan 31, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@stapelberg
Copy link
Collaborator

Seems simple enough, but I can’t accept this PR before you sign the CLA. Please let me know once you signed it and the PR is ready for review. Thanks!

@sanya2022 sanya2022 force-pushed the fix-expr-case-numgen branch from edf7aa7 to 6a4599f Compare February 3, 2025 14:07
@sanya2022
Copy link
Contributor Author

@stapelberg Done it!

@stapelberg stapelberg merged commit 6f574e7 into google:main Feb 3, 2025
2 checks passed
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.

2 participants