Visitar URL original
Routed network ACL: match protocol-number rules with ip protocol, not ip nexthdr by bhouse-nexthop · Pull Request #14352 · apache/cloudstack · GitHub
Skip to content

Routed network ACL: match protocol-number rules with ip protocol, not ip nexthdr - #14352

Open
bhouse-nexthop wants to merge 3 commits into
apache:4.22from
bhouse-nexthop:fix-routed-acl-ip-protocol
Open

bhouse-nexthop wants to merge 3 commits into
apache:4.22from
bhouse-nexthop:fix-routed-acl-ip-protocol

Conversation

@bhouse-nexthop

@bhouse-nexthop bhouse-nexthop commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

Description

On a network in routed mode, a network ACL rule that uses a protocol number (e.g. 47 for GRE) is never applied on the VR.

Fixes #14351

Why it breaks

In routed mode the VR renders IPv4 ACL rules as nftables, in CsAcl.AclDevice.__process_routing_ip4(). A protocol-number rule was rendered as ip nexthdr 47. nexthdr is an IPv6 header field, so nft rejects it in an ip rule:

Error: syntax error, unexpected string
add rule ip ip4_acl eth3_ingress_policy ip saddr 1.2.3.4/32 ip nexthdr 47 accept
                                                            ^^^^^^^

The rules are added one nft add rule at a time, and the failure is only logged: /var/log/cloud.log records that the command exited with status 1, while nft's error message goes to stderr. So the rule is silently missing from ip4_acl while the rest of the list loads:

  • an allow rule for that protocol never matches;
  • a deny rule for it is lost, and the traffic falls through to whatever later rule matches it.

This was introduced with routed mode in #9470 (4.20).

How it is fixed

The IPv4 match now uses the IPv4 field, ip protocol <n>. The IPv6 path in __process_ip6() is not touched by this change.

How to reproduce the old behaviour

  1. Create a VPC in routed mode with an IPv4 tier. Network ACLs only exist on VPC tiers; a routed isolated network uses routing firewall rules instead and is not affected.
  2. Add an ACL rule to the tier's ACL list: protocol number 47, CIDR 1.2.3.4/32, action Allow. Add a TCP 22 rule from the same CIDR for contrast.
  3. On the VR, run nft list chain ip ip4_acl ethX_ingress_policy.

Before (the GRE rule is missing; /var/log/cloud.log has Command 'nft add rule ... ip nexthdr 47 accept' returned non-zero exit status 1):

ip saddr 1.2.3.4 tcp dport 22 accept
counter packets 0 bytes 0 drop

After:

ip saddr 1.2.3.4 ip protocol gre accept
ip saddr 1.2.3.4 tcp dport 22 accept
counter packets 0 bytes 0 drop

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

How Has This Been Tested?

  • New systemvm/test/TestCsAclRouting.py checks the rendered IPv4 rule in both directions (ip saddr ingress, ip daddr egress), and that the IPv4 match does not reach the IPv6 rule. It fails on the current 4.22 code and passes with this change. (Nothing in .github/workflows runs systemvm/test, so it runs via systemvm/test/runtests.sh.)
  • The before/after chains above are real output. They come from feeding the rules AclDevice generates through the unmodified CsNetfilters.apply_nft_ipv4_rules() into real nft (1.0.9) in a network namespace. ip protocol 47 was also checked on nft 1.0.6, the version in the Debian 12 systemvm template.
  • pycodestyle and pylint (as in runtests.sh) report nothing new.

How did you try to break this feature and the system with this change?

In routed mode the VR renders IPv4 ACL rules as nftables, and a rule for a
protocol number (e.g. 47, GRE) came out as "ip nexthdr 47". nexthdr is an
IPv6 header field; nft rejects it in an ip rule with a syntax error, which
is only logged, so the rule was silently missing from ip4_acl. Use the IPv4
field, "ip protocol". The IPv6 path's "ip6 nexthdr" is correct and unchanged.

Fixes: apache#14351

Signed-off-by: Brad House <bhouse@nexthop.ai>
@bhouse-nexthop

Copy link
Copy Markdown
Collaborator Author

@vladimirpetrov @sureshanaparti could you take a look at this one? We'd like this fix to make it into the upcoming 4.22.2 release.

@codecov

codecov Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 4.04%. Comparing base (2974af8) to head (d94d544).
⚠️ Report is 1 commits behind head on 4.22.

❗ There is a different number of reports uploaded between BASE (2974af8) and HEAD (d94d544). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (2974af8) HEAD (d94d544)
unittests 1 0
Additional details and impacted files
@@              Coverage Diff              @@
##               4.22   #14352       +/-   ##
=============================================
- Coverage     18.02%    4.04%   -13.99%     
=============================================
  Files          5936      449     -5487     
  Lines        535823    38240   -497583     
  Branches      65612     7082    -58530     
=============================================
- Hits          96582     1546    -95036     
+ Misses       428242    36482   -391760     
+ Partials      10999      212    -10787     
Flag Coverage Δ
uitests 4.04% <ø> (ø)
unittests ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Signed-off-by: Brad House <bhouse@nexthop.ai>
Check only that the IPv4 match does not reach the IPv6 rule.

Signed-off-by: Brad House <bhouse@nexthop.ai>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant