Skip to content

RDKCOM-5619: RDKBNETWOR-99 Implement Dynamic L2/L3 Packet Marking Framework - #396

Open
sherik-sensin wants to merge 1 commit into
rdkcentral:developfrom
sherik-sensin:RDKBNETWOR-99_qos
Open

RDKCOM-5619: RDKBNETWOR-99 Implement Dynamic L2/L3 Packet Marking Framework#396
sherik-sensin wants to merge 1 commit into
rdkcentral:developfrom
sherik-sensin:RDKBNETWOR-99_qos

Conversation

@sherik-sensin

@sherik-sensin sherik-sensin commented Aug 5, 2026

Copy link
Copy Markdown

Copilot AI lite review requested due to automatic review settings August 5, 2026 11:30
@sherik-sensin
sherik-sensin requested review from a team as code owners August 5, 2026 11:30
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

📋 PR Format Reminder

  • Description missing:
    • Reason for change
    • Test Procedure
    • Risks (Low / Medium / High)
    • Priority (P0 / P1 / P2)

Expected:

TICKET-123 : brief description

Reason for change: why
Test Procedure: how to verify
Risks: Low / Medium / High
Priority: P0 / P1 / P2

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 WAN Manager–driven QoS marking rule generation in the firewall subsystem, emitting DSCP and CLASSIFY rules into the iptables mangle table for both IPv4 and IPv6 when the WAN service is ready.

Changes:

  • Adds a new add_qos_skb_mark(FILE*, int family) API (guarded by FEATURE_WANMGR_L2_MARKING) to build DSCP/CLASSIFY rules based on WanManager TR-181 marking entries.
  • Invokes the new QoS rule emission from the IPv4 mangle table setup and from the IPv6 filter path.
  • Introduces WanManager TR-181 parameter name constants and protocol-specific rule generation (DNS/NTP/HTTP/VoIP/IPTV/IGMP/MLD/etc.).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
source/firewall/firewall.h Declares the new add_qos_skb_mark API behind FEATURE_WANMGR_L2_MARKING.
source/firewall/firewall.c Implements WanManager-based DSCP/CLASSIFY rule generation and hooks it into IPv4 mangle table preparation.
source/firewall/firewall_ipv6.c Hooks the new rule generation into the IPv6 rule generation path.
Suppressed comments (4)

source/firewall/firewall.c:5504

  • strncpy(..., sizeof(dest)) may leave SKBMark without a null terminator when the source is long. Prefer a guaranteed-terminated copy.
                strncpy(SKBMark, acTmpReturnValue, sizeof(SKBMark));

source/firewall/firewall.c:5517

  • strncpy(..., sizeof(dest)) may leave DSCPMark without a null terminator when the source is long. Prefer a guaranteed-terminated copy.
                strncpy(DSCPMark, acTmpReturnValue, sizeof(DSCPMark));

source/firewall/firewall.c:5530

  • strncpy(..., sizeof(dest)) may leave MarkingName without a null terminator when the source is long, which can break the subsequent strcmp chain. Prefer a guaranteed-terminated copy.
                strncpy(MarkingName, acTmpReturnValue, sizeof(MarkingName));

source/firewall/firewall.c:5545

  • strncpy(..., sizeof(dest)) may leave WanVIfName without a null terminator when the source is long, which can result in malformed iptables rules. Prefer a guaranteed-terminated copy.
                    strncpy(WanVIfName, acTmpReturnValue, sizeof(WanVIfName));

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

Comment thread source/firewall/firewall.c
Comment on lines +5402 to +5406
memset(acTmpReturnValue, 0, sizeof(acTmpReturnValue));
if (ANSC_STATUS_FAILURE == RdkBus_GetParamValues(WAN_COMPONENT_NAME, WAN_DBUS_PATH, WAN_IF_COUNT, acTmpReturnValue))
{
printf("[%s][%d]Failed to get WAN interface count\n", __FUNCTION__, __LINE__);
return -1;
Comment thread source/firewall/firewall.c
Comment thread source/firewall/firewall.c
Comment thread source/firewall/firewall.c
@sherik-sensin sherik-sensin changed the title Rdkbnetwor 99 qos RDKBNETWOR-99 Implement Dynamic L2/L3 Packet Marking Framework Aug 5, 2026
@pradeeptakdas pradeeptakdas changed the title RDKBNETWOR-99 Implement Dynamic L2/L3 Packet Marking Framework RDKCOM-5625: RDKBNETWOR-99 Implement Dynamic L2/L3 Packet Marking Framework Aug 6, 2026
@pradeeptakdas pradeeptakdas changed the title RDKCOM-5625: RDKBNETWOR-99 Implement Dynamic L2/L3 Packet Marking Framework RDKCOM-5619: RDKBNETWOR-99 Implement Dynamic L2/L3 Packet Marking Framework Aug 6, 2026
@AkhilaReddyK7 AkhilaReddyK7 added the community-contribution Contribution from community label Aug 12, 2026
Reason for change: Marking table should be created dynamically based on the virtual interface marking entry from WanManager.
                   Add L3 marking based on WanManager marking entries.

Test Procedure: Performed firewall Sanity test.
Risks: None.

Signed-off-by: Sherik Sensin A <sherik.a@telekom-digital.com>
Copilot AI review requested due to automatic review settings August 27, 2026 13:11

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 3 out of 3 changed files in this pull request and generated no new comments.

Suppressed comments (16)

source/firewall/firewall.c:5515

  • RdkBus_GetParamValues() requires a returnValSize argument; this call currently passes only 4 parameters and will not compile.
                snprintf(acGetParamName, sizeof(acGetParamName), "%s.DSCPMark", WanVIfMarkingEntry);
                if (ANSC_STATUS_FAILURE == RdkBus_GetParamValues(WAN_COMPONENT_NAME, WAN_DBUS_PATH, acGetParamName, acTmpReturnValue))
                {
                    printf("[%s][%d]Failed to get [%s]\n", __FUNCTION__, __LINE__, acGetParamName);
                    return -1;

source/firewall/firewall.c:5528

  • RdkBus_GetParamValues() requires a returnValSize argument; this call currently passes only 4 parameters and will not compile.
                snprintf(acGetParamName, sizeof(acGetParamName), "%s.Name", WanVIfMarkingEntry);
                if (ANSC_STATUS_FAILURE == RdkBus_GetParamValues(WAN_COMPONENT_NAME, WAN_DBUS_PATH, acGetParamName, acTmpReturnValue))
                {
                    printf("[%s][%d]Failed to get [%s]\n", __FUNCTION__, __LINE__, acGetParamName);
                    return -1;

source/firewall/firewall.c:5407

  • RdkBus_GetParamValues() is declared with a 5th returnValSize parameter (see firewall.h:845). This call passes only 4 arguments, which will not compile and also prevents safe truncation handling.
        memset(acTmpReturnValue, 0, sizeof(acTmpReturnValue));
        if (ANSC_STATUS_FAILURE == RdkBus_GetParamValues(WAN_COMPONENT_NAME, WAN_DBUS_PATH, WAN_IF_COUNT, acTmpReturnValue))
        {
            printf("[%s][%d]Failed to get WAN interface count\n", __FUNCTION__, __LINE__);
            return -1;

source/firewall/firewall.c:5422

  • RdkBus_GetParamValues() requires a returnValSize argument; this call currently passes only 4 parameters and will not compile.
            snprintf(acGetParamName, sizeof(acGetParamName), WAN_IF_ACTIVE_LINK, wanif_idx);
            if (ANSC_STATUS_FAILURE == RdkBus_GetParamValues(WAN_COMPONENT_NAME, WAN_DBUS_PATH, acGetParamName, acTmpReturnValue))
            {
                printf("[%s][%d]Failed to get [%s]\n", __FUNCTION__, __LINE__, acGetParamName);
                return -1;

source/firewall/firewall.c:5452

  • RdkBus_GetParamValues() requires a returnValSize argument; this call currently passes only 4 parameters and will not compile.
            snprintf(acGetParamName, sizeof(acGetParamName), WAN_VIF_COUNT, activeLinkIdx);
            if (ANSC_STATUS_FAILURE == RdkBus_GetParamValues(WAN_COMPONENT_NAME, WAN_DBUS_PATH, acGetParamName, acTmpReturnValue))
            {
                printf("[%s][%d]Failed to get [%s]\n", __FUNCTION__, __LINE__, acGetParamName);
                return -1;
            }

source/firewall/firewall.c:5470

  • RdkBus_GetParamValues() requires a returnValSize argument; this call currently passes only 4 parameters and will not compile.
            snprintf(acGetParamName, sizeof(acGetParamName), WAN_VIF_NOF_MARKINGS, activeLinkIdx, vlan_idx);
            if (ANSC_STATUS_FAILURE == RdkBus_GetParamValues(WAN_COMPONENT_NAME, WAN_DBUS_PATH, acGetParamName, acTmpReturnValue))
            {
                printf("[%s][%d]Failed to get [%s], skipping\n", __FUNCTION__, __LINE__, acGetParamName);
                continue;

source/firewall/firewall.c:5489

  • RdkBus_GetParamValues() requires a returnValSize argument; this call currently passes only 4 parameters and will not compile.
                snprintf(acGetParamName, sizeof(acGetParamName), WAN_VIF_MARKINGS_ENTRY, activeLinkIdx, vlan_idx, vIfMarkingIdx);
                if (ANSC_STATUS_FAILURE == RdkBus_GetParamValues(WAN_COMPONENT_NAME, WAN_DBUS_PATH, acGetParamName, acTmpReturnValue))
                {
                    printf("[%s][%d]Failed to get [%s]\n", __FUNCTION__, __LINE__, acGetParamName);
                    return -1;

source/firewall/firewall.c:5502

  • RdkBus_GetParamValues() requires a returnValSize argument; this call currently passes only 4 parameters and will not compile.
                snprintf(acGetParamName, sizeof(acGetParamName), "%s.SKBMark", WanVIfMarkingEntry);
                if (ANSC_STATUS_FAILURE == RdkBus_GetParamValues(WAN_COMPONENT_NAME, WAN_DBUS_PATH, acGetParamName, acTmpReturnValue))
                {
                    printf("[%s][%d]Failed to get [%s]\n", __FUNCTION__, __LINE__, acGetParamName);
                    return -1;

source/firewall/firewall.c:5543

  • RdkBus_GetParamValues() requires a returnValSize argument; this call currently passes only 4 parameters and will not compile.
                    snprintf(acGetParamName, sizeof(acGetParamName), WAN_VIF_NAME, activeLinkIdx, vlan_idx);
                    if (ANSC_STATUS_FAILURE == RdkBus_GetParamValues(WAN_COMPONENT_NAME, WAN_DBUS_PATH, acGetParamName, acTmpReturnValue))
                    {
                        printf("[%s][%d]Failed to get [%s], skipping\n", __FUNCTION__, __LINE__, acGetParamName);
                        continue;

source/firewall/firewall.c:5492

  • strncpy(..., sizeof(buf)) does not guarantee NUL-termination when the source is the same size or longer. This value is later used as a C string (e.g., in snprintf with "%s"), which can cause out-of-bounds reads and potentially leak stack data into the generated iptables rules.
                strncpy(WanVIfMarkingEntry, acTmpReturnValue, sizeof(WanVIfMarkingEntry));

source/firewall/firewall.c:5505

  • strncpy(..., sizeof(buf)) does not guarantee NUL-termination. Since SKBMark is later printed with %s, ensure it is always terminated to avoid out-of-bounds reads.
                strncpy(SKBMark, acTmpReturnValue, sizeof(SKBMark));

source/firewall/firewall.c:5518

  • strncpy(..., sizeof(buf)) does not guarantee NUL-termination. Since DSCPMark is later printed with %s, ensure it is always terminated to avoid out-of-bounds reads.
                strncpy(DSCPMark, acTmpReturnValue, sizeof(DSCPMark));

source/firewall/firewall.c:5531

  • strncpy(..., sizeof(buf)) does not guarantee NUL-termination. Since MarkingName is later used in strcmp(), ensure it is always terminated to avoid out-of-bounds reads.
                strncpy(MarkingName, acTmpReturnValue, sizeof(MarkingName));

source/firewall/firewall.c:5546

  • strncpy(..., sizeof(buf)) does not guarantee NUL-termination. Since WanVIfName is used with %s in generated rules, ensure it is always terminated to avoid out-of-bounds reads.
                    strncpy(WanVIfName, acTmpReturnValue, sizeof(WanVIfName));

source/firewall/firewall.c:5562

  • In iptables, match options like -p must appear before the jump target (-j). With -j DSCP placed before -p, -p udp/tcp becomes an invalid target option and the rule will fail to restore.
                    dest_port = 123; // for NTP
                    fprintf(mangle_fp, "-A POSTROUTING -j DSCP -p udp --dport %d -o %s --set-dscp-class %s\n", dest_port, current_wan_ifname, DSCPMark);
                    fprintf(mangle_fp, "-A POSTROUTING -j DSCP -p tcp --dport %d -o %s --set-dscp-class %s\n", dest_port, current_wan_ifname, DSCPMark);
                    fprintf(mangle_fp, "-A POSTROUTING -j CLASSIFY -p udp --dport %d -o %s --set-class 0:%s\n", dest_port, current_wan_ifname, SKBMark);
                    fprintf(mangle_fp, "-A POSTROUTING -j CLASSIFY -p tcp --dport %d -o %s --set-class 0:%s\n", dest_port, current_wan_ifname, SKBMark);

source/firewall/firewall.c:5575

  • This HTTP CLASSIFY rule is missing -o %s (egress interface match). As written it can match traffic on any outgoing interface, not just the WAN interface, which is inconsistent with the adjacent DSCP rule.
                    fprintf(mangle_fp, "-A POSTROUTING -p tcp --dport %d -m dscp --dscp-class cs3 -o %s -j DSCP --set-dscp-class %s\n", HTTP_PORT, current_wan_ifname, DSCPMark);
                    fprintf(mangle_fp, "-A POSTROUTING -p tcp --dport %d -m dscp --dscp-class %s -j CLASSIFY --set-class 0:%s\n", HTTP_PORT, DSCPMark, SKBMark);

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

Labels

community-contribution Contribution from community

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants