From ff89404cc74702e02f0184afe40a56cb65ff844a Mon Sep 17 00:00:00 2001 From: Muhammed Rafi C Date: Thu, 21 May 2026 21:34:01 +0530 Subject: [PATCH 1/5] RDKEMW-18247 Panel is listing as a PLATCO device in Router client list in WiFi mode Reason for change: Set the NetworkManager dhcp-hostname in the connection profile to use the default hostname instead of the device name. --- .github/workflows/libnm_proxy_L1_test.yml | 2 +- plugin/gnome/NetworkManagerGnomeUtils.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/libnm_proxy_L1_test.yml b/.github/workflows/libnm_proxy_L1_test.yml index 80d945d5..d947d643 100644 --- a/.github/workflows/libnm_proxy_L1_test.yml +++ b/.github/workflows/libnm_proxy_L1_test.yml @@ -111,7 +111,7 @@ jobs: run: | sudo bash -c 'echo "ETHERNET_INTERFACE=eth0 WIFI_INTERFACE=wlan0 - DEVICE_NAME=rdk_test_device " > /etc/device.properties' + DEFAULT_HOSTNAME=rdk_test_device " > /etc/device.properties' - name: Generate IARM headers run: | diff --git a/plugin/gnome/NetworkManagerGnomeUtils.cpp b/plugin/gnome/NetworkManagerGnomeUtils.cpp index 7d97e5e8..24900bbf 100644 --- a/plugin/gnome/NetworkManagerGnomeUtils.cpp +++ b/plugin/gnome/NetworkManagerGnomeUtils.cpp @@ -261,13 +261,13 @@ namespace WPEFramework } } - if (line.find("DEVICE_NAME=") != std::string::npos) { + if (line.find("DEFAULT_HOSTNAME=") != std::string::npos) { deviceHostname = line.substr(line.find('=') + 1); deviceHostname.erase(deviceHostname.find_last_not_of("\r\n\t") + 1); deviceHostname.erase(0, deviceHostname.find_first_not_of("\r\n\t")); if(deviceHostname.empty()) { - NMLOG_WARNING("DEVICE_NAME is empty in /etc/device.properties"); + NMLOG_WARNING("DEFAULT_HOSTNAME is empty in /etc/device.properties"); deviceHostname = ""; // set empty device name } } From 2cac9397c9b80dae4f8e4ce49f3c85e08b30c9f5 Mon Sep 17 00:00:00 2001 From: Muhammed Rafi C Date: Fri, 22 May 2026 12:24:18 +0530 Subject: [PATCH 2/5] add empty check added --- plugin/gnome/NetworkManagerGnomeProxy.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugin/gnome/NetworkManagerGnomeProxy.cpp b/plugin/gnome/NetworkManagerGnomeProxy.cpp index b661a8de..4fec7b5b 100644 --- a/plugin/gnome/NetworkManagerGnomeProxy.cpp +++ b/plugin/gnome/NetworkManagerGnomeProxy.cpp @@ -151,6 +151,11 @@ namespace WPEFramework if(!nmUtils::readPersistentHostname(hostname)) { hostname = nmUtils::deviceHostname(); // default hostname as device name + if(hostname.empty()) + { + NMLOG_WARNING("default hostname is empty no modification in nm connections"); + return false; + } } connections = nm_client_get_connections(client); From 0705f7c16a6f492a7e12328bc801b7aa7c987285 Mon Sep 17 00:00:00 2001 From: Muhammed Rafi C Date: Fri, 22 May 2026 13:46:42 +0530 Subject: [PATCH 3/5] hostaname empty check added --- plugin/gnome/NetworkManagerGnomeWIFI.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/plugin/gnome/NetworkManagerGnomeWIFI.cpp b/plugin/gnome/NetworkManagerGnomeWIFI.cpp index 2348124d..8550abcc 100644 --- a/plugin/gnome/NetworkManagerGnomeWIFI.cpp +++ b/plugin/gnome/NetworkManagerGnomeWIFI.cpp @@ -640,15 +640,19 @@ namespace WPEFramework // IPv4 settings with DHCP NMSettingIP4Config *sIpv4 = (NMSettingIP4Config *)nm_setting_ip4_config_new(); g_object_set(G_OBJECT(sIpv4), NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); - g_object_set(G_OBJECT(sIpv4), NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, hostname.c_str(), NULL); - g_object_set(G_OBJECT(sIpv4), NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, TRUE, NULL); + if(hostname.length() > 0) { + g_object_set(G_OBJECT(sIpv4), NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, hostname.c_str(), NULL); + g_object_set(G_OBJECT(sIpv4), NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, TRUE, NULL); + } nm_connection_add_setting(connection, NM_SETTING(sIpv4)); // IPv6 settings with DHCP NMSettingIP6Config *sIpv6 = (NMSettingIP6Config *)nm_setting_ip6_config_new(); g_object_set(G_OBJECT(sIpv6), NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, NULL); - g_object_set(G_OBJECT(sIpv6), NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, hostname.c_str(), NULL); - g_object_set(G_OBJECT(sIpv6), NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, TRUE, NULL); + if(hostname.length() > 0) { + g_object_set(G_OBJECT(sIpv6), NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, hostname.c_str(), NULL); + g_object_set(G_OBJECT(sIpv6), NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, TRUE, NULL); + } nm_connection_add_setting(connection, NM_SETTING(sIpv6)); NMLOG_DEBUG("Created minimal ethernet connection with autoconnect=true"); @@ -902,15 +906,19 @@ namespace WPEFramework /* Build up the 'IPv4' Setting */ NMSettingIP4Config *sIpv4Conf = (NMSettingIP4Config *) nm_setting_ip4_config_new(); g_object_set(G_OBJECT(sIpv4Conf), NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); // autoconf = true - g_object_set(G_OBJECT(sIpv4Conf), NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, hostname.c_str(), NULL); - g_object_set(G_OBJECT(sIpv4Conf), NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, TRUE, NULL); // hostname send enabled + if(hostname.length() > 0) { + g_object_set(G_OBJECT(sIpv4Conf), NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, hostname.c_str(), NULL); + g_object_set(G_OBJECT(sIpv4Conf), NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, TRUE, NULL); // hostname send enabled + } nm_connection_add_setting(m_connection, NM_SETTING(sIpv4Conf)); /* Build up the 'IPv6' Setting */ NMSettingIP6Config *sIpv6Conf = (NMSettingIP6Config *) nm_setting_ip6_config_new(); g_object_set(G_OBJECT(sIpv6Conf), NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, NULL); // autoconf = true - g_object_set(G_OBJECT(sIpv6Conf), NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, hostname.c_str(), NULL); - g_object_set(G_OBJECT(sIpv6Conf), NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, TRUE, NULL); // hostname send enabled + if(hostname.length() > 0) { + g_object_set(G_OBJECT(sIpv6Conf), NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, hostname.c_str(), NULL); + g_object_set(G_OBJECT(sIpv6Conf), NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, TRUE, NULL); // hostname send enabled + } nm_connection_add_setting(m_connection, NM_SETTING(sIpv6Conf)); return true; } From bf78d0010dff10193eeb746735eb7ef4c2b390f4 Mon Sep 17 00:00:00 2001 From: Muhammed Rafi C Date: Fri, 22 May 2026 14:39:04 +0530 Subject: [PATCH 4/5] empty check log added --- plugin/gnome/NetworkManagerGnomeWIFI.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/plugin/gnome/NetworkManagerGnomeWIFI.cpp b/plugin/gnome/NetworkManagerGnomeWIFI.cpp index 8550abcc..00fc9751 100644 --- a/plugin/gnome/NetworkManagerGnomeWIFI.cpp +++ b/plugin/gnome/NetworkManagerGnomeWIFI.cpp @@ -637,10 +637,15 @@ namespace WPEFramework NMLOG_DEBUG("No persistent hostname found, using device hostname"); } + if(hostname.empty()) + NMLOG_WARNING("dhcp hostname: "); + else + NMLOG_INFO("dhcp hostname: %s", hostname.c_str()); + // IPv4 settings with DHCP NMSettingIP4Config *sIpv4 = (NMSettingIP4Config *)nm_setting_ip4_config_new(); g_object_set(G_OBJECT(sIpv4), NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); - if(hostname.length() > 0) { + if(!hostname.empty()) { g_object_set(G_OBJECT(sIpv4), NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, hostname.c_str(), NULL); g_object_set(G_OBJECT(sIpv4), NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, TRUE, NULL); } @@ -649,7 +654,7 @@ namespace WPEFramework // IPv6 settings with DHCP NMSettingIP6Config *sIpv6 = (NMSettingIP6Config *)nm_setting_ip6_config_new(); g_object_set(G_OBJECT(sIpv6), NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, NULL); - if(hostname.length() > 0) { + if(!hostname.empty()) { g_object_set(G_OBJECT(sIpv6), NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, hostname.c_str(), NULL); g_object_set(G_OBJECT(sIpv6), NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, TRUE, NULL); } @@ -898,15 +903,18 @@ namespace WPEFramework if(!nmUtils::readPersistentHostname(hostname)) { hostname = nmUtils::deviceHostname(); - NMLOG_DEBUG("no persistent hostname found taking device name as hostname !"); + NMLOG_DEBUG("No persistent hostname found, using device hostname"); } - NMLOG_INFO("dhcp hostname: %s", hostname.c_str()); + if(hostname.empty()) + NMLOG_WARNING("dhcp hostname: "); + else + NMLOG_INFO("dhcp hostname: %s", hostname.c_str()); /* Build up the 'IPv4' Setting */ NMSettingIP4Config *sIpv4Conf = (NMSettingIP4Config *) nm_setting_ip4_config_new(); g_object_set(G_OBJECT(sIpv4Conf), NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP4_CONFIG_METHOD_AUTO, NULL); // autoconf = true - if(hostname.length() > 0) { + if(!hostname.empty()) { g_object_set(G_OBJECT(sIpv4Conf), NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, hostname.c_str(), NULL); g_object_set(G_OBJECT(sIpv4Conf), NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, TRUE, NULL); // hostname send enabled } @@ -915,7 +923,7 @@ namespace WPEFramework /* Build up the 'IPv6' Setting */ NMSettingIP6Config *sIpv6Conf = (NMSettingIP6Config *) nm_setting_ip6_config_new(); g_object_set(G_OBJECT(sIpv6Conf), NM_SETTING_IP_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, NULL); // autoconf = true - if(hostname.length() > 0) { + if(!hostname.empty()) { g_object_set(G_OBJECT(sIpv6Conf), NM_SETTING_IP_CONFIG_DHCP_HOSTNAME, hostname.c_str(), NULL); g_object_set(G_OBJECT(sIpv6Conf), NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME, TRUE, NULL); // hostname send enabled } From 7d1acef6edfdddb75752a95598ca5587d2e0bf28 Mon Sep 17 00:00:00 2001 From: Muhammed Rafi C Date: Tue, 26 May 2026 10:54:38 +0530 Subject: [PATCH 5/5] update copilot review comment --- definition/NetworkManager.json | 2 +- docs/NetworkManagerPlugin.md | 4 ++-- plugin/gnome/NetworkManagerGnomeProxy.cpp | 14 ++++++++------ plugin/gnome/NetworkManagerGnomeUtils.cpp | 6 +++--- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/definition/NetworkManager.json b/definition/NetworkManager.json index 65fb6e6c..ed322080 100644 --- a/definition/NetworkManager.json +++ b/definition/NetworkManager.json @@ -1341,7 +1341,7 @@ } }, "SetHostname": { - "summary": "To configure a custom DHCP hostname instead of the default (which is typically the device name).\n\nSetting host name will take effect upon reconnect; like, device reboot, wake-up from deepsleep, while connecting to new Wi-Fi connection, WiFi On/Off, or renewal of the DHCP lease.", + "summary": "To configure a custom DHCP hostname instead of the default (which is typically the default hostname).\n\nSetting host name will take effect upon reconnect; like, device reboot, wake-up from deepsleep, while connecting to new Wi-Fi connection, WiFi On/Off, or renewal of the DHCP lease.", "params": { "type": "object", "properties": { diff --git a/docs/NetworkManagerPlugin.md b/docs/NetworkManagerPlugin.md index 2c31542f..64ccae15 100644 --- a/docs/NetworkManagerPlugin.md +++ b/docs/NetworkManagerPlugin.md @@ -103,7 +103,7 @@ NetworkManager interface methods: | [GetWiFiSignalQuality](#method.GetWiFiSignalQuality) | Get WiFi signal quality of currently connected SSID | | [GetSupportedSecurityModes](#method.GetSupportedSecurityModes) | Returns the Wifi security modes that the device supports | | [GetWifiState](#method.GetWifiState) | Returns the current Wifi State | -| [SetHostname](#method.SetHostname) | To configure a custom DHCP hostname instead of the default (which is typically the device name) | +| [SetHostname](#method.SetHostname) | To configure a custom DHCP hostname instead of the default (which is typically the default hostname) | ## *SetLogLevel [method](#head.Methods)* @@ -1726,7 +1726,7 @@ This method takes no parameters. ## *SetHostname [method](#head.Methods)* -To configure a custom DHCP hostname instead of the default (which is typically the device name). +To configure a custom DHCP hostname instead of the default (which is typically the default hostname). Setting host name will take effect upon reconnect; like, device reboot, wake-up from deepsleep, while connecting to new Wi-Fi connection, WiFi On/Off, or renewal of the DHCP lease. diff --git a/plugin/gnome/NetworkManagerGnomeProxy.cpp b/plugin/gnome/NetworkManagerGnomeProxy.cpp index 4fec7b5b..ff42dcc9 100644 --- a/plugin/gnome/NetworkManagerGnomeProxy.cpp +++ b/plugin/gnome/NetworkManagerGnomeProxy.cpp @@ -150,12 +150,14 @@ namespace WPEFramework // read persistent hostname if exist if(!nmUtils::readPersistentHostname(hostname)) { - hostname = nmUtils::deviceHostname(); // default hostname as device name - if(hostname.empty()) - { - NMLOG_WARNING("default hostname is empty no modification in nm connections"); - return false; - } + hostname = nmUtils::deviceHostname(); // default hostname as default hostname + } + + // Validate hostname is non-empty regardless of source (persistent or default) + if(hostname.empty()) + { + NMLOG_WARNING("Hostname is empty. No modification will be made to NM connections."); + return false; } connections = nm_client_get_connections(client); diff --git a/plugin/gnome/NetworkManagerGnomeUtils.cpp b/plugin/gnome/NetworkManagerGnomeUtils.cpp index 24900bbf..fa2b2869 100644 --- a/plugin/gnome/NetworkManagerGnomeUtils.cpp +++ b/plugin/gnome/NetworkManagerGnomeUtils.cpp @@ -40,7 +40,7 @@ namespace WPEFramework { static std::string m_ethifname = "eth0"; static std::string m_wlanifname = "wlan0"; - static std::string m_deviceHostname = "rdk-device"; // Device name can be empty if not set in /etc/device.properties + static std::string m_deviceHostname = "rdk-device"; // default hostname can be empty if not set in /etc/device.properties const char* nmUtils::wlanIface() {return m_wlanifname.c_str();} const char* nmUtils::ethIface() {return m_ethifname.c_str();} @@ -268,7 +268,7 @@ namespace WPEFramework if(deviceHostname.empty()) { NMLOG_WARNING("DEFAULT_HOSTNAME is empty in /etc/device.properties"); - deviceHostname = ""; // set empty device name + deviceHostname = ""; // set empty default hostname } } } @@ -277,7 +277,7 @@ namespace WPEFramework m_wlanifname = wifiIfname; m_ethifname = ethIfname; m_deviceHostname = deviceHostname; - NMLOG_INFO("/etc/device.properties eth: %s, wlan: %s, device name: %s", m_ethifname.c_str(), m_wlanifname.c_str(), m_deviceHostname.c_str()); + NMLOG_INFO("/etc/device.properties eth: %s, wlan: %s, default hostname: %s", m_ethifname.c_str(), m_wlanifname.c_str(), m_deviceHostname.c_str()); return true; }