From 1b65523708e448e0708f3ea66c3ce6ce0a14cd11 Mon Sep 17 00:00:00 2001 From: Sivaraj Sivalingam Date: Mon, 4 May 2026 13:43:34 -0400 Subject: [PATCH 1/7] Prefer computed PSID from dhcp6c when available In WanDmlMapDomGetRule_Data, select the computed PSID and PSID length from pVirtIf->MAP.MaptConfig when the dhcp6c message indicates a PSID is present (psidLen>0) and EA length is zero. Otherwise, fall back to the existing dhcp6cMAPparameters values. This ensures the code uses the computed PSID/length supplied by dhcp6c when appropriate. --- source/TR-181/middle_layer_src/wanmgr_map_apis.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/source/TR-181/middle_layer_src/wanmgr_map_apis.c b/source/TR-181/middle_layer_src/wanmgr_map_apis.c index 35a0ac07..ddf25df3 100644 --- a/source/TR-181/middle_layer_src/wanmgr_map_apis.c +++ b/source/TR-181/middle_layer_src/wanmgr_map_apis.c @@ -765,8 +765,18 @@ WanDmlMapDomGetRule_Data pMapRule->EABitsLength = pVirtIf->MAP.dhcp6cMAPparameters.eaLen; pMapRule->IsFMR = pVirtIf->MAP.dhcp6cMAPparameters.isFMR; pMapRule->PSIDOffset = pVirtIf->MAP.dhcp6cMAPparameters.psidOffset; - pMapRule->PSIDLength = pVirtIf->MAP.dhcp6cMAPparameters.psidLen; - pMapRule->PSID = pVirtIf->MAP.dhcp6cMAPparameters.psid; + + /* get computed PSID and PSID length values if received from dhcp6c */ + if ((dhcp6cMAPTMsgBody->psidLen > 0) && (dhcp6cMAPTMsgBody->eaLen == 0)) + { + pMapRule->PSIDLength = pVirtIf->MAP.MaptConfig.psidLen; + pMapRule->PSID = pVirtIf->MAP.MaptConfig.psidValue; + } + else + { + pMapRule->PSIDLength = pVirtIf->MAP.dhcp6cMAPparameters.psidLen; + pMapRule->PSID = pVirtIf->MAP.dhcp6cMAPparameters.psid; + } pMapRule->Ratio = pVirtIf->MAP.dhcp6cMAPparameters.ratio; pMapRule->IncludeSystemPorts = FALSE; } From 708218152268468eba3526bff45f8f13caf1d075 Mon Sep 17 00:00:00 2001 From: Sivaraj Sivalingam Date: Mon, 4 May 2026 15:40:20 -0400 Subject: [PATCH 2/7] Update wanmgr_map_apis.c --- source/TR-181/middle_layer_src/wanmgr_map_apis.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/TR-181/middle_layer_src/wanmgr_map_apis.c b/source/TR-181/middle_layer_src/wanmgr_map_apis.c index ddf25df3..61683675 100644 --- a/source/TR-181/middle_layer_src/wanmgr_map_apis.c +++ b/source/TR-181/middle_layer_src/wanmgr_map_apis.c @@ -769,13 +769,13 @@ WanDmlMapDomGetRule_Data /* get computed PSID and PSID length values if received from dhcp6c */ if ((dhcp6cMAPTMsgBody->psidLen > 0) && (dhcp6cMAPTMsgBody->eaLen == 0)) { - pMapRule->PSIDLength = pVirtIf->MAP.MaptConfig.psidLen; - pMapRule->PSID = pVirtIf->MAP.MaptConfig.psidValue; + pMapRule->PSIDLength = pVirtIf->MAP.dhcp6cMAPparameters.psidLen; + pMapRule->PSID = pVirtIf->MAP.dhcp6cMAPparameters.psid; } else { - pMapRule->PSIDLength = pVirtIf->MAP.dhcp6cMAPparameters.psidLen; - pMapRule->PSID = pVirtIf->MAP.dhcp6cMAPparameters.psid; + pMapRule->PSIDLength = pVirtIf->MAP.MaptConfig.psidLen; + pMapRule->PSID = pVirtIf->MAP.MaptConfig.psidValue; } pMapRule->Ratio = pVirtIf->MAP.dhcp6cMAPparameters.ratio; pMapRule->IncludeSystemPorts = FALSE; From e31e4162a57a9dc34e088a72f5382284e5877364 Mon Sep 17 00:00:00 2001 From: Sivaraj Sivalingam Date: Mon, 4 May 2026 19:37:10 -0400 Subject: [PATCH 3/7] Update wanmgr_map_apis.c --- source/TR-181/middle_layer_src/wanmgr_map_apis.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/TR-181/middle_layer_src/wanmgr_map_apis.c b/source/TR-181/middle_layer_src/wanmgr_map_apis.c index 61683675..24896e05 100644 --- a/source/TR-181/middle_layer_src/wanmgr_map_apis.c +++ b/source/TR-181/middle_layer_src/wanmgr_map_apis.c @@ -767,7 +767,7 @@ WanDmlMapDomGetRule_Data pMapRule->PSIDOffset = pVirtIf->MAP.dhcp6cMAPparameters.psidOffset; /* get computed PSID and PSID length values if received from dhcp6c */ - if ((dhcp6cMAPTMsgBody->psidLen > 0) && (dhcp6cMAPTMsgBody->eaLen == 0)) + if ((pVirtIf->MAP.dhcp6cMAPparameters.psidLen > 0) && (pVirtIf->MAP.dhcp6cMAPparameters.eaLen == 0)) { pMapRule->PSIDLength = pVirtIf->MAP.dhcp6cMAPparameters.psidLen; pMapRule->PSID = pVirtIf->MAP.dhcp6cMAPparameters.psid; From 18cf0a96c0f7094ff913bc32360e2780e3e0c2a5 Mon Sep 17 00:00:00 2001 From: Sivaraj Sivalingam Date: Wed, 6 May 2026 09:49:47 -0400 Subject: [PATCH 4/7] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- source/TR-181/middle_layer_src/wanmgr_map_apis.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/TR-181/middle_layer_src/wanmgr_map_apis.c b/source/TR-181/middle_layer_src/wanmgr_map_apis.c index 24896e05..76906cca 100644 --- a/source/TR-181/middle_layer_src/wanmgr_map_apis.c +++ b/source/TR-181/middle_layer_src/wanmgr_map_apis.c @@ -774,8 +774,13 @@ WanDmlMapDomGetRule_Data } else { +#ifdef FEATURE_MAPT pMapRule->PSIDLength = pVirtIf->MAP.MaptConfig.psidLen; pMapRule->PSID = pVirtIf->MAP.MaptConfig.psidValue; +#else + pMapRule->PSIDLength = 0; + pMapRule->PSID = 0; +#endif } pMapRule->Ratio = pVirtIf->MAP.dhcp6cMAPparameters.ratio; pMapRule->IncludeSystemPorts = FALSE; From 314cb89a890fc85b52f442dad970b4d8f8b2d4cb Mon Sep 17 00:00:00 2001 From: Sivaraj Sivalingam Date: Thu, 7 May 2026 10:24:24 -0400 Subject: [PATCH 5/7] Update wanmgr_map_apis.c --- source/TR-181/middle_layer_src/wanmgr_map_apis.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/source/TR-181/middle_layer_src/wanmgr_map_apis.c b/source/TR-181/middle_layer_src/wanmgr_map_apis.c index 76906cca..2e26e2e7 100644 --- a/source/TR-181/middle_layer_src/wanmgr_map_apis.c +++ b/source/TR-181/middle_layer_src/wanmgr_map_apis.c @@ -766,8 +766,14 @@ WanDmlMapDomGetRule_Data pMapRule->IsFMR = pVirtIf->MAP.dhcp6cMAPparameters.isFMR; pMapRule->PSIDOffset = pVirtIf->MAP.dhcp6cMAPparameters.psidOffset; - /* get computed PSID and PSID length values if received from dhcp6c */ - if ((pVirtIf->MAP.dhcp6cMAPparameters.psidLen > 0) && (pVirtIf->MAP.dhcp6cMAPparameters.eaLen == 0)) + /* + * MAP-E computes and stores PSID/PSIDLength in dhcp6cMAPparameters even + * when EA bits are present. + * Use explicit PSID values from DHCPv6 only when psidLen is present and eaLen is 0; + * otherwise use the locally computed MAP-T PSID values from PD EA-bits, or 0 when unavailable. + */ + if ((pVirtIf->MAP.MapeStatus && (pVirtIf->MAP.dhcp6cMAPparameters.psidLen > 0)) || + ((pVirtIf->MAP.dhcp6cMAPparameters.psidLen > 0) && (pVirtIf->MAP.dhcp6cMAPparameters.eaLen == 0))) { pMapRule->PSIDLength = pVirtIf->MAP.dhcp6cMAPparameters.psidLen; pMapRule->PSID = pVirtIf->MAP.dhcp6cMAPparameters.psid; From eff433265f4bd4c0946f18beb963de2b94258a98 Mon Sep 17 00:00:00 2001 From: Sivaraj Sivalingam Date: Fri, 8 May 2026 16:47:52 -0400 Subject: [PATCH 6/7] Always use DHCPv6 PSID; store MAP-T PSID Stop falling back to MaptConfig PSID when EA bits or other conditions are present; always populate PSIDLength and PSID from dhcp6cMAPparameters. In WanManager_VerifyMAPTConfiguration, propagate the calculated MAP-T psid and psidLen back into dhcp6cMAPTMsgBody so callers (e.g. Device.MAP.Domain rule responses) receive the correct values. Also tidy up error handling/logging indentation and add a comment explaining the value propagation. --- .../TR-181/middle_layer_src/wanmgr_map_apis.c | 25 ++--------------- source/WanManager/wanmgr_net_utils.c | 28 +++++++++++-------- 2 files changed, 19 insertions(+), 34 deletions(-) diff --git a/source/TR-181/middle_layer_src/wanmgr_map_apis.c b/source/TR-181/middle_layer_src/wanmgr_map_apis.c index 2e26e2e7..35a0ac07 100644 --- a/source/TR-181/middle_layer_src/wanmgr_map_apis.c +++ b/source/TR-181/middle_layer_src/wanmgr_map_apis.c @@ -765,29 +765,8 @@ WanDmlMapDomGetRule_Data pMapRule->EABitsLength = pVirtIf->MAP.dhcp6cMAPparameters.eaLen; pMapRule->IsFMR = pVirtIf->MAP.dhcp6cMAPparameters.isFMR; pMapRule->PSIDOffset = pVirtIf->MAP.dhcp6cMAPparameters.psidOffset; - - /* - * MAP-E computes and stores PSID/PSIDLength in dhcp6cMAPparameters even - * when EA bits are present. - * Use explicit PSID values from DHCPv6 only when psidLen is present and eaLen is 0; - * otherwise use the locally computed MAP-T PSID values from PD EA-bits, or 0 when unavailable. - */ - if ((pVirtIf->MAP.MapeStatus && (pVirtIf->MAP.dhcp6cMAPparameters.psidLen > 0)) || - ((pVirtIf->MAP.dhcp6cMAPparameters.psidLen > 0) && (pVirtIf->MAP.dhcp6cMAPparameters.eaLen == 0))) - { - pMapRule->PSIDLength = pVirtIf->MAP.dhcp6cMAPparameters.psidLen; - pMapRule->PSID = pVirtIf->MAP.dhcp6cMAPparameters.psid; - } - else - { -#ifdef FEATURE_MAPT - pMapRule->PSIDLength = pVirtIf->MAP.MaptConfig.psidLen; - pMapRule->PSID = pVirtIf->MAP.MaptConfig.psidValue; -#else - pMapRule->PSIDLength = 0; - pMapRule->PSID = 0; -#endif - } + pMapRule->PSIDLength = pVirtIf->MAP.dhcp6cMAPparameters.psidLen; + pMapRule->PSID = pVirtIf->MAP.dhcp6cMAPparameters.psid; pMapRule->Ratio = pVirtIf->MAP.dhcp6cMAPparameters.ratio; pMapRule->IncludeSystemPorts = FALSE; } diff --git a/source/WanManager/wanmgr_net_utils.c b/source/WanManager/wanmgr_net_utils.c index 4ce7cb06..10bcd43d 100644 --- a/source/WanManager/wanmgr_net_utils.c +++ b/source/WanManager/wanmgr_net_utils.c @@ -918,22 +918,28 @@ ANSC_STATUS WanManager_VerifyMAPTConfiguration(ipc_map_data_t *dhcp6cMAPTMsgBody { ret = WanManager_CalculatePsidAndV4Index(dhcp6cMAPTMsgBody->pdIPv6Prefix, dhcp6cMAPTMsgBody->v6Len, dhcp6cMAPTMsgBody->iapdPrefixLen, dhcp6cMAPTMsgBody->v4Len, &(MaptConfig->psidValue), &ipv4IndexValue, &(MaptConfig->psidLen)); - } - if (ret != RETURN_OK) - { - CcspTraceError(("Error in calculating MAPT PSID value \n")); + if (ret != RETURN_OK) + { + CcspTraceError(("Error in calculating MAPT PSID value \n")); #ifdef FEATURE_MAPT_DEBUG - MaptInfo("Exiting MAPT configuration, MAPT will not be configured, error found in getting PSID value"); + MaptInfo("Exiting MAPT configuration, MAPT will not be configured, error found in getting PSID value"); #endif - CcspTraceNotice(("FEATURE_MAPT: MAP-T configuration failed\n")); - return ANSC_STATUS_FAILURE; - } + CcspTraceNotice(("FEATURE_MAPT: MAP-T configuration failed\n")); + return ANSC_STATUS_FAILURE; + } #ifdef FEATURE_MAPT_DEBUG - MaptInfo("--- MAP-T Computed Values - START ---"); - MaptInfo("mapt: PSID Value: %d, ipv4IndexValue: %d", MaptConfig->psidValue, ipv4IndexValue); - MaptInfo("mapt: PSID Length: %d", MaptConfig->psidLen); + MaptInfo("--- MAP-T Computed Values - START ---"); + MaptInfo("mapt: PSID Value: %d, ipv4IndexValue: %d", MaptConfig->psidValue, ipv4IndexValue); + MaptInfo("mapt: PSID Length: %d", MaptConfig->psidLen); #endif + /* Since the Device.MAP.Domain DM uses the rule data structure to return values, + * we need to update the structure with the calculated values + * so that it returns the correct values + */ + dhcp6cMAPTMsgBody->psid = MaptConfig->psidValue; + dhcp6cMAPTMsgBody->psidLen = MaptConfig->psidLen; + } inet_pton(AF_INET, dhcp6cMAPTMsgBody->ruleIPv4Prefix, &(result)); From 82d7b319541e09d8abfb892d58a39b991fae431b Mon Sep 17 00:00:00 2001 From: Sivaraj Sivalingam Date: Fri, 8 May 2026 17:18:55 -0400 Subject: [PATCH 7/7] Add isPSIDComputed flag to MaptConfig Introduce a new boolean isPSIDComputed in MaptData_t to mark when PSID/PSIDLength were computed. Update map APIs to prefer MaptConfig.psid/psidLen when this flag is set, and modify WanManager_VerifyMAPTConfiguration to set the flag (FALSE when using dhcp6c-provided values, TRUE when computed) while removing the previous practice of copying computed values back into the dhcp6c message body. Files changed: wanmgr_dml.h, wanmgr_map_apis.c, wanmgr_net_utils.c. --- source/TR-181/include/wanmgr_dml.h | 1 + source/TR-181/middle_layer_src/wanmgr_map_apis.c | 7 +++++++ source/WanManager/wanmgr_net_utils.c | 8 ++------ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/source/TR-181/include/wanmgr_dml.h b/source/TR-181/include/wanmgr_dml.h index b52f6db1..8db55694 100644 --- a/source/TR-181/include/wanmgr_dml.h +++ b/source/TR-181/include/wanmgr_dml.h @@ -441,6 +441,7 @@ typedef struct BOOL mapeAssigned; /**< Have we been assigned mape config ? */ BOOL maptAssigned; /**< Have we been assigned mapt config ? */ BOOL isFMR; + BOOL isPSIDComputed; }MaptData_t; typedef struct _WANMGR_MAPT_CONFIG_DATA_ diff --git a/source/TR-181/middle_layer_src/wanmgr_map_apis.c b/source/TR-181/middle_layer_src/wanmgr_map_apis.c index 35a0ac07..c0f65aad 100644 --- a/source/TR-181/middle_layer_src/wanmgr_map_apis.c +++ b/source/TR-181/middle_layer_src/wanmgr_map_apis.c @@ -767,6 +767,13 @@ WanDmlMapDomGetRule_Data pMapRule->PSIDOffset = pVirtIf->MAP.dhcp6cMAPparameters.psidOffset; pMapRule->PSIDLength = pVirtIf->MAP.dhcp6cMAPparameters.psidLen; pMapRule->PSID = pVirtIf->MAP.dhcp6cMAPparameters.psid; +#ifdef FEATURE_MAPT + if (pVirtIf->MAP.MaptConfig.isPSIDComputed) + { + pMapRule->PSIDLength = pVirtIf->MAP.MaptConfig.psidLen; + pMapRule->PSID = pVirtIf->MAP.MaptConfig.psid; + } +#endif pMapRule->Ratio = pVirtIf->MAP.dhcp6cMAPparameters.ratio; pMapRule->IncludeSystemPorts = FALSE; } diff --git a/source/WanManager/wanmgr_net_utils.c b/source/WanManager/wanmgr_net_utils.c index 10bcd43d..6ecb66d0 100644 --- a/source/WanManager/wanmgr_net_utils.c +++ b/source/WanManager/wanmgr_net_utils.c @@ -913,6 +913,7 @@ ANSC_STATUS WanManager_VerifyMAPTConfiguration(ipc_map_data_t *dhcp6cMAPTMsgBody MaptInfo("Using psidLen value from dhcp6c options : %d", MaptConfig->psidLen); MaptInfo("Using psidOffset value from dhcp6c options : %d", dhcp6cMAPTMsgBody->psidOffset); #endif + MaptConfig->isPSIDComputed = FALSE; } else { @@ -933,12 +934,7 @@ ANSC_STATUS WanManager_VerifyMAPTConfiguration(ipc_map_data_t *dhcp6cMAPTMsgBody MaptInfo("mapt: PSID Value: %d, ipv4IndexValue: %d", MaptConfig->psidValue, ipv4IndexValue); MaptInfo("mapt: PSID Length: %d", MaptConfig->psidLen); #endif - /* Since the Device.MAP.Domain DM uses the rule data structure to return values, - * we need to update the structure with the calculated values - * so that it returns the correct values - */ - dhcp6cMAPTMsgBody->psid = MaptConfig->psidValue; - dhcp6cMAPTMsgBody->psidLen = MaptConfig->psidLen; + MaptConfig->isPSIDComputed = TRUE; } inet_pton(AF_INET, dhcp6cMAPTMsgBody->ruleIPv4Prefix, &(result));