Skip to content

RDKBNETWOR-80 : Transform to Nftables from Iptables#292

Open
vsai1990 wants to merge 6 commits into
rdkcentral:developfrom
vsai1990:rdk_nft
Open

RDKBNETWOR-80 : Transform to Nftables from Iptables#292
vsai1990 wants to merge 6 commits into
rdkcentral:developfrom
vsai1990:rdk_nft

Conversation

@vsai1990

Copy link
Copy Markdown

Reason for change:

  1. Translate all the RDKB IPtables rules to nftables
  2. write into /tmp/.nft and /tmp/.nft_v6 files and apply into netfilter
  3. all the nftables rules are added under firewall_nft dir

Test Procedure: RDKB Firewall functionality
Risks: Medium

@vsai1990 vsai1990 requested review from a team as code owners April 21, 2026 15:35
@rdkcmf-jenkins

Copy link
Copy Markdown
Contributor

b'## Blackduck scan failure details

Summary: 0 violations, 0 files pending approval, 1 file pending identification.

  • Protex Server Path: /home/blackduck/github/utopia/292/rdkb/components/opensource/ccsp/Utopia

  • Commit: 7655a49

Report detail: gist'

Comment thread source/utapi/lib/utapi.c Outdated
@rdkcmf-jenkins

Copy link
Copy Markdown
Contributor

b'## WARNING: A Blackduck scan failure has been waived

A prior failure has been upvoted

  • Upvote reason: ok

  • Commit: 7655a49
    '

Comment thread source/utapi/lib/utapi.c
Comment thread source/utapi/lib/utapi.c
Reason for change: 1) Translate all the RDKB IPtables rules to nftables
2) write into /tmp/.nft and /tmp/.nft_v6 files and apply into netfilter
3) all the nftables rules are added under firewall_nft dir

Test Procedure: RDKB Firewall functionality
Risks: Medium
snayak002c
snayak002c previously approved these changes Jun 22, 2026
Copilot AI review requested due to automatic review settings June 22, 2026 16:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 introduces an nftables-based firewall implementation alongside the existing iptables-based firewall, with build-time support (--enable-firewall-nft) and runtime selection via syscfg nft_enable.

Changes:

  • Adds a new source/firewall_nft/ implementation (firewall + nfqueue handler + support headers) intended to generate/apply nftables rules.
  • Updates build system (autotools + Makefile conditionals) to optionally build the nftables firewall and to build the legacy firewall binary as firewall_ipt.
  • Updates runtime launcher script and a utapi port-forwarding path to conditionally use nft vs iptables.

Reviewed changes

Copilot reviewed 14 out of 16 changed files in this pull request and generated 14 comments.

Show a summary per file
File Description
source/utapi/lib/utapi.c Adds runtime switch to attempt nft rules for ephemeral port forwarding.
source/utapi/lib/Makefile.am Adds -DNFT_ENABLE when FIREWALL_NFT is enabled.
source/scripts/init/service.d/service_firewall/firewall_log_handle.sh Switches between legacy and nft firewall binaries based on syscfg nft_enable.
source/Makefile.am Adds firewall_nft subdir when FIREWALL_NFT is enabled.
source/firewall/Makefile.am Builds legacy firewall as firewall_ipt under FIREWALL_NFT.
source/firewall_nft/raw_socket_send.c Adds raw packet send helper (copied from legacy).
source/firewall_nft/nfq_handler_nft.c Adds nft-oriented nfqueue handler implementation.
source/firewall_nft/Makefile.am Builds firewall_nft and an nfqueue handler binary.
source/firewall_nft/firewallnft.h Adds nft firewall header/API surface.
source/firewall_nft/firewall_priv_nft.c Adds nft versions of custom rule helpers.
source/firewall_nft/firewall_ipv6_nft.c Adds nft IPv6 firewall rule generation.
source/firewall_nft/firewall_interface_nft.c Adds weak stubs for platform hooks in nft firewall.
source/firewall_nft/firewall_ext_nft.c Adds extender-mode nft firewall logic.
source/firewall_nft/firewall_custom.h Adds nft firewall custom header and shared declarations/macros.
configure.ac Adds --enable-firewall-nft configure option and generates source/firewall_nft/Makefile.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread source/utapi/lib/utapi.c Outdated
Comment thread source/utapi/lib/utapi.c Outdated
Comment thread source/utapi/lib/utapi.c Outdated
Comment thread source/utapi/lib/utapi.c Outdated
Comment thread source/firewall/Makefile.am
Comment thread source/firewall_nft/nfq_handler_nft.c Outdated
Comment thread source/firewall_nft/firewall_ipv6_nft.c
Comment thread source/firewall_nft/firewallnft.h
Comment thread source/firewall_nft/firewall_ext_nft.c
Comment thread source/utapi/lib/utapi.c Outdated
Copilot AI review requested due to automatic review settings July 2, 2026 10:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 14 out of 16 changed files in this pull request and generated 24 comments.

Comment thread source/utapi/lib/utapi.c Outdated
Comment thread source/utapi/lib/utapi.c Outdated
Comment thread source/utapi/lib/utapi.c Outdated
Comment thread source/utapi/lib/utapi.c Outdated
Comment thread source/utapi/lib/utapi.c Outdated
Comment thread source/utapi/lib/utapi.c Outdated
Comment thread source/utapi/lib/utapi.c Outdated
Comment thread source/utapi/lib/utapi.c Outdated
Comment thread source/utapi/lib/utapi.c Outdated
Comment thread source/firewall_nft/firewall_ipv6_nft.c
Copilot AI review requested due to automatic review settings July 2, 2026 10:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 14 out of 16 changed files in this pull request and generated 18 comments.

Comment thread source/utapi/lib/utapi.c Outdated
Comment thread source/utapi/lib/utapi.c Outdated
Comment thread source/utapi/lib/utapi.c Outdated
Comment thread source/utapi/lib/utapi.c Outdated
Comment thread source/utapi/lib/utapi.c Outdated
Comment thread source/firewall_nft/firewall_ipv6_nft.c
Comment thread configure.ac
Comment thread source/firewall_nft/Makefile.am
Comment thread source/firewall_nft/firewall_ext_nft.c
Comment thread source/firewall_nft/firewall_ipv6_nft.c
Copilot AI review requested due to automatic review settings July 2, 2026 15:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 14 out of 16 changed files in this pull request and generated 25 comments.

Comment thread source/utapi/lib/utapi.c Outdated
Comment thread source/utapi/lib/utapi.c Outdated
Comment thread source/utapi/lib/utapi.c Outdated
Comment thread source/utapi/lib/utapi.c Outdated
Comment thread source/utapi/lib/utapi.c Outdated
Comment thread configure.ac
Comment thread source/firewall_nft/firewall_ipv6_nft.c Outdated
Comment thread source/firewall_nft/firewall_ipv6_nft.c Outdated
Comment thread source/firewall_nft/firewall_ipv6_nft.c Outdated
Comment thread source/firewall_nft/firewall_ipv6_nft.c Outdated
Copilot AI review requested due to automatic review settings July 2, 2026 15:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 14 out of 16 changed files in this pull request and generated 12 comments.

Comment thread source/utapi/lib/utapi.c Outdated
Comment thread source/utapi/lib/utapi.c
Comment thread source/utapi/lib/utapi.c Outdated
Comment thread source/utapi/lib/utapi.c
Comment thread configure.ac
Comment thread source/firewall_nft/firewall_ipv6_nft.c
Comment on lines +398 to +401
/* These rules are needed to accept IPv6 traffic with HBH extension header and No-Next-Header option */
/* To enable ipv6header module support need to set CONFIG_IP6_NF_MATCH_IPV6HEADER=m kernel config */
fprintf(filter_fp,"-I FORWARD 1 -o erouter0 -m ipv6header --soft --header hop-by-hop -j ACCEPT\n");
fprintf(filter_fp,"-I FORWARD 1 -o erouter0 -m ipv6header --soft --header hop-by-hop -j LOG --log-prefix \"UTOPIA: FW.IPv6 FORWARD Hop-by-Hop\" --log-level 6\n");
Comment thread source/firewall_nft/firewall_ipv6_nft.c Outdated
Comment thread source/firewall_nft/firewall_ipv6_nft.c Outdated
Comment thread source/firewall_nft/firewall_ipv6_nft.c
snayak002c
snayak002c previously approved these changes Jul 2, 2026
Copilot AI review requested due to automatic review settings July 8, 2026 14:34
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 14 out of 16 changed files in this pull request and generated 12 comments.

Comment thread source/firewall_nft/nfq_handler_nft.c
Comment thread source/firewall_nft/raw_socket_send.c
Comment thread source/firewall_nft/raw_socket_send.c
Comment thread source/firewall_nft/raw_socket_send.c
Comment thread source/firewall/Makefile.am
Comment thread source/firewall_nft/firewall_ipv6_nft.c
Comment thread source/firewall_nft/firewall_ipv6_nft.c Outdated
Comment thread source/firewall_nft/firewall_ipv6_nft.c
Comment thread source/firewall_nft/firewall_ipv6_nft.c
Comment thread source/firewall_nft/firewallnft.h
Resolve nftable command errors and flags.
Copilot AI review requested due to automatic review settings July 8, 2026 14:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 14 out of 16 changed files in this pull request and generated 9 comments.

Comment thread configure.ac
Comment thread source/firewall_nft/Makefile.am
Comment thread source/firewall_nft/nfq_handler_nft.c
Comment thread source/firewall_nft/firewall_nft.c
Comment thread source/firewall_nft/firewall_ipv6_nft.c
Comment thread source/firewall_nft/firewall_ipv6_nft.c
Comment thread source/firewall_nft/firewall_ext_nft.c
Comment thread source/firewall_nft/firewall_ipv6_nft.c
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.

4 participants