Skip to content

CORENET-7252: Migrate iptables to nftables in networking test suite#3935

Open
weliang1 wants to merge 1 commit into
openshift:mainfrom
weliang1:replace-iptable-with-nftable
Open

CORENET-7252: Migrate iptables to nftables in networking test suite#3935
weliang1 wants to merge 1 commit into
openshift:mainfrom
weliang1:replace-iptable-with-nftable

Conversation

@weliang1

Copy link
Copy Markdown
Contributor

Summary

Replace all iptables command references with nftables equivalents across the networking test suite.

Changes

  • pod.feature: Migrate u32 module matching to nftables raw payload matching
  • egress-ip.feature: Update EgressIP rule verification to use nft
  • ovn.feature: Convert OVN port blocking with IPv4/IPv6 support
  • service.feature: Update service DNAT/REDIRECT verification
  • sdn.feature: Rule repair, version checks, and conntrack rules

Migration Statistics

  • ✅ 5 files updated, 108 lines changed (55+, 53-)
  • ✅ 8 test scenarios updated
  • ✅ 100% iptables references removed

Technical Changes

  • iptables --versionnft --version
  • iptables-savenft list ruleset
  • iptables -S -t <table>nft list table ip <table>
  • ip6tables support → nft family ip6
  • Rule deletion now uses handle-based approach

Documentation

  • Added MIGRATION_SUMMARY.md with complete migration guide
  • Includes command mappings and syntax differences
  • Documents next steps for step definition updates

Status: WIP

Pending work:

  • Update Ruby step definitions for nftables commands
    • the node nftables config is checked
    • the node standard nftables rules are removed
    • the node standard nftables rules are completely flushed
  • Test scenarios against OpenShift 4.x cluster
  • Verify nftables availability on test nodes (RHEL 8+)

Testing

Requires RHEL 8+ nodes with nftables support.

See MIGRATION_SUMMARY.md for complete technical details.

@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 25, 2026
@openshift-ci openshift-ci Bot requested review from asood-rh and rbbratta June 25, 2026 14:37
@openshift-ci

openshift-ci Bot commented Jun 25, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign anuragthehatter for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Replace all iptables command references with nftables equivalents
across 5 test feature files in the networking test suite.

Changes:
- pod.feature: Migrate u32 module matching to nftables raw payload
- egress-ip.feature: Update EgressIP rule verification to use nft
- ovn.feature: Convert OVN port blocking with IPv4/IPv6 support
- service.feature: Update service DNAT/REDIRECT verification
- sdn.feature: Rule repair, version checks, and conntrack rules

Migration statistics:
- 5 files updated, 108 lines changed (55+, 53-)
- 8 test scenarios updated
- 100% iptables references removed

Technical changes:
- iptables --version → nft --version
- iptables-save → nft list ruleset
- iptables -S -t <table> → nft list table ip <table>
- ip6tables support → nft family ip6
- Rule deletion now uses handle-based approach

Note: Ruby step definitions still need updates for:
- node nftables config checks
- nftables rule removal/flush operations

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@weliang1 weliang1 force-pushed the replace-iptable-with-nftable branch from 2d6dbf9 to b6fc3cd Compare June 25, 2026 14:39
@asood-rh

Copy link
Copy Markdown
Contributor

@weliang1 Does it make sense to migrate all to go so that when they are OTE enabled we do not need to think of ruby tests all?

@openshift-ci

openshift-ci Bot commented Jun 25, 2026

Copy link
Copy Markdown

@weliang1: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@weliang1

Copy link
Copy Markdown
Contributor Author

@weliang1 Does it make sense to migrate all to go so that when they are OTE enabled we do not need to think of ruby tests all?

@asood-rh That's a good idea. This PR is WIP. We can migrate them to go after all the testing pass.

@weliang1 weliang1 changed the title WIP: Migrate iptables to nftables in networking test suite CORENET-7252: Migrate iptables to nftables in networking test suite Jul 8, 2026
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 8, 2026
@openshift-ci-robot

openshift-ci-robot commented Jul 8, 2026

Copy link
Copy Markdown

@weliang1: This pull request references CORENET-7252 which is a valid jira issue.

Details

In response to this:

Summary

Replace all iptables command references with nftables equivalents across the networking test suite.

Changes

  • pod.feature: Migrate u32 module matching to nftables raw payload matching
  • egress-ip.feature: Update EgressIP rule verification to use nft
  • ovn.feature: Convert OVN port blocking with IPv4/IPv6 support
  • service.feature: Update service DNAT/REDIRECT verification
  • sdn.feature: Rule repair, version checks, and conntrack rules

Migration Statistics

  • ✅ 5 files updated, 108 lines changed (55+, 53-)
  • ✅ 8 test scenarios updated
  • ✅ 100% iptables references removed

Technical Changes

  • iptables --versionnft --version
  • iptables-savenft list ruleset
  • iptables -S -t <table>nft list table ip <table>
  • ip6tables support → nft family ip6
  • Rule deletion now uses handle-based approach

Documentation

  • Added MIGRATION_SUMMARY.md with complete migration guide
  • Includes command mappings and syntax differences
  • Documents next steps for step definition updates

Status: WIP

Pending work:

  • Update Ruby step definitions for nftables commands
  • the node nftables config is checked
  • the node standard nftables rules are removed
  • the node standard nftables rules are completely flushed
  • Test scenarios against OpenShift 4.x cluster
  • Verify nftables availability on test nodes (RHEL 8+)

Testing

Requires RHEL 8+ nodes with nftables support.

See MIGRATION_SUMMARY.md for complete technical details.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 8, 2026
@weliang1

weliang1 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

/cc @danwinship @bpickard22

@openshift-ci openshift-ci Bot requested review from bpickard22 and danwinship July 8, 2026 16:07
@inactive
Scenario: OCP-15473:SDN The related iptables/openflow rules will be removed once the egressIP gets removed from netnamespace
Scenario: OCP-15473:SDN The related nftables/openflow rules will be removed once the egressIP gets removed from netnamespace
Given the env is using "OpenShiftSDN" networkType

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is an openshift-sdn-specific test, so (if it's still going to be kept) it should still refer to iptables.

# don't block all traffic that breaks etcd, just block the OVN ssl ports
When I run commands on the host:
| <%= cb.iptables_command %> -t filter -A INPUT -s <%= cb.south_leader.ip %> -p tcp --dport 9643:9644 -j DROP |
| bash | -c | nft add rule <%= cb.nft_family %> filter INPUT <%= cb.nft_saddr %> <%= cb.south_leader.ip %> tcp dport 9643-9644 drop |

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The filter table and INPUT chain are created by iptables-nft. In the future, in nftables-only systems, they will not exist. You need to create your own table and chain. eg:

nft add table inet ocp-testing
nft add chain inet ocp-testing input { type filter hook input priority filter ; }
nft add rule inet ocp-testing input <%= cb.nft_family %> saddr <%= cb.south_leader.ip %> tcp dport 9643-9644 drop

and then just nft delete table inet ocp-testing for the cleanup.

Given evaluation of `(cb.south_leader.ip.include? ":") ? "ip6tables" : "iptables"` is stored in the :iptables_command clipboard
# Determine IP family for nftables (ip or ip6)
Given evaluation of `(cb.south_leader.ip.include? ":") ? "ip6" : "ip"` is stored in the :nft_family clipboard
Given evaluation of `(cb.south_leader.ip.include? ":") ? "ip6 saddr" : "ip saddr"` is stored in the :nft_saddr clipboard

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

(You don't really need nft_saddr as a separate variable, since it's always just nft_family followed by "saddr")

@admin
@destructive
@inactive
Scenario: OCP-33413:SDN xt_u32 kernel module functionality check from NET_ADMIN pods

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Searching for "OCP-33413" in Jira turns up https://redhat.atlassian.net/browse/CNF-930. This is specifically a test that customers can use the iptables xt_u32 module. It should not be changed.

@@ -1 +1 @@
Feature: SDN related networking scenarios

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This whole file seems to be openshift-sdn specific and should not be changed.

@s390x @ppc64le @heterogeneous @arm64 @amd64
@hypershift-hosted
Scenario: OCP-10216:SDN The iptables rules for the service should be DNAT or REDIRECT to node after being idled
Scenario: OCP-10216:SDN The nftables rules for the service should be DNAT or REDIRECT to node after being idled

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This also appears to be an openshift-sdn-specific test, and should not be changed.

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

Labels

jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants