Skip to content

RDKEMW-16150: Let's get connected" displayed during Migration testing…#311

Open
gururaajar wants to merge 2 commits into
support/2.0.0from
topic/RDKEMW-16154
Open

RDKEMW-16150: Let's get connected" displayed during Migration testing…#311
gururaajar wants to merge 2 commits into
support/2.0.0from
topic/RDKEMW-16154

Conversation

@gururaajar
Copy link
Copy Markdown
Contributor

… (#296)

  • RDKEMW-16150: Let's get connected" displayed during Migration testing

Reason for Change: Deleting all the connections only in case of BOOT_MIGRATION so that networkmanager connecting to the eth0 connection can be avoided and we can create new "Wired Connection 1" to connect.
Test Procedure: Migration Scenario
Priority: P1
Risks: Medium

  • RDKEMW-16150: Let's get connected" displayed during Migration testing

Reason for Change: Deleting all the connections only in case of BOOT_MIGRATION so that networkmanager connecting to the eth0 connection can be avoided and we can create new "Wired Connection 1" to connect.
Test Procedure: Migration Scenario
Priority: P1
Risks: Medium


…#296)

* RDKEMW-16150: Let's get connected" displayed during Migration testing

Reason for Change: Deleting all the connections only in case of BOOT_MIGRATION so that networkmanager connecting to the eth0 connection can be avoided and we can create new "Wired Connection 1" to connect.
Test Procedure: Migration Scenario
Priority: P1
Risks: Medium
Signed-off-by: Gururaaja ESR<Gururaja_ErodeSriranganRamlingham@comcast.com>

* RDKEMW-16150: Let's get connected" displayed during Migration testing

Reason for Change: Deleting all the connections only in case of BOOT_MIGRATION so that networkmanager connecting to the eth0 connection can be avoided and we can create new "Wired Connection 1" to connect.
Test Procedure: Migration Scenario
Priority: P1
Risks: Medium
Signed-off-by: Gururaaja ESR<Gururaja_ErodeSriranganRamlingham@comcast.com>

---------

Signed-off-by: Gururaaja ESR<Gururaja_ErodeSriranganRamlingham@comcast.com>
Copilot AI review requested due to automatic review settings May 17, 2026 23:10
@gururaajar gururaajar requested a review from a team as a code owner May 17, 2026 23:10
Reason for Change: Fixed potential causes of plugin crash
Test Procedure: Monitor for networkmanager plugin crash
Priority: P1
Risks: Medium

Signed-off-by: Gururaaja ESR<Gururaja_ErodeSriranganRamlingham@comcast.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 adjusts the GNOME NetworkManager plugin’s ethernet enable flow to better support migration scenarios by conditionally removing existing wired connection profiles and ensuring a “Wired connection 1” profile is present/activated to avoid unintended autoconnect behavior during BOOT_MIGRATION.

Changes:

  • Added wifiManager::addMinimalEthernetConnection() API and implementation to persist a minimal wired profile via nm_client_add_connection2().
  • Updated NetworkManagerImplementation::SetInterfaceState() to detect BOOT_MIGRATION, disconnect eth0, delete wired profiles, then add/activate the default wired profile when enabling ethernet.
  • Minor formatting change (blank line) in the proxy implementation.

Reviewed changes

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

File Description
plugin/gnome/NetworkManagerGnomeWIFI.h Adds a new wifiManager method declaration for creating a minimal ethernet connection profile.
plugin/gnome/NetworkManagerGnomeWIFI.cpp Implements the async add-to-disk path for a minimal ethernet connection profile.
plugin/gnome/NetworkManagerGnomeProxy.cpp Adds BOOT_MIGRATION detection + wired profile deletion, then creates/activates the default wired connection on eth enable.
Comments suppressed due to low confidence (2)

plugin/gnome/NetworkManagerGnomeProxy.cpp:531

  • The return value of addMinimalEthernetConnection() is ignored here. If creating the on-disk profile fails, the code still proceeds to enable the interface and later tries to activate "Wired connection 1", which may fail or activate an unexpected existing profile. Please handle the failure (log + return an error, or skip activation and fall back to the existing connection list).
                                        continue;
                                    }
                                    g_ptr_array_add(snapshot, g_object_ref(conn));
                                }

                                for(guint i = 0; i < snapshot->len; ++i)
                                {
                                    NMRemoteConnection *conn = NM_REMOTE_CONNECTION(snapshot->pdata[i]);

plugin/gnome/NetworkManagerGnomeProxy.cpp:520

  • New BOOT_MIGRATION behavior (reading /tmp/bootType, disconnecting eth0, snapshotting + deleting wired connections, then adding a minimal profile) isn’t covered by the existing libnm proxy SetInterfaceState_* tests. Please add/extend tests to validate: (1) BOOT_MIGRATION triggers wired-connection deletion, (2) non-migration boots do not delete/add, and (3) failures in delete/add are handled as expected.
                rc = Core::ERROR_NONE;
                // TODO: if no proimary connection, should we return empty string? RDK V return empty string
            }

            m_defaultInterface = interface;
            return rc;
        }
#endif

        uint32_t NetworkManagerImplementation::SetInterfaceState(const string& interface/* @in */, const bool enabled /* @in */)
        {

            if(m_nmClient == nullptr)
            {
                NMLOG_WARNING("NMClient is null");
                return Core::ERROR_RPC_CALL_FAILED;
            }

            if(interface.empty() || (interface != nmUtils::wlanIface() && interface != nmUtils::ethIface()))
            {
                NMLOG_ERROR("interface: %s; not valied", interface.c_str()!=nullptr? interface.c_str():"empty");
                return Core::ERROR_GENERAL;
            }

            // For ethernet enable: run BOOT_MIGRATION cleanup first, then setInterfaceState
            if(enabled && interface == nmUtils::ethIface())
            {
                // Check boot type and delete all ethernet NM connections if BOOT_MIGRATION
                {
                    const char* bootFile = "/tmp/bootType";
                    std::ifstream file(bootFile);

                    if(file.is_open())
                    {
                        std::string line, bootTypeValue;
                        while(std::getline(file, line))
                        {
                            const std::string key = "BOOT_TYPE=";
                            auto pos = line.find(key);
                            if(pos != std::string::npos)
                            {
                                bootTypeValue = line.substr(pos + key.size());
                                break;
                            }
                        }

                        if(bootTypeValue == "BOOT_MIGRATION")
                        {
                            NMLOG_INFO("BOOT_MIGRATION detected, deleting all wired NM connections");

                            // Bring down the ethernet interface before wiping its connections
                            // so NM doesn't immediately re-activate them during deletion.
                            NMDevice *ethDev = nm_client_get_device_by_iface(m_nmClient, interface.c_str());
                            if(ethDev)
                            {
                                GError *discError = nullptr;
                                if(!nm_device_disconnect(ethDev, nullptr, &discError))
                                {
                                    NMLOG_WARNING("Failed to disconnect %s before migration cleanup: %s",
                                            interface.c_str(),
                                            discError ? discError->message : "unknown error");
                                    if(discError) g_error_free(discError);
                                }
                            }

                            const GPtrArray *connections = nm_client_get_connections(m_nmClient);
                            if(connections && connections->len > 0)
                            {
                                /* Snapshot the list before iterating: nm_client_get_connections()
                                 * returns an internal array that can be mutated as connections
                                 * are removed, so we must not iterate it while deleting. */
                                GPtrArray *snapshot = g_ptr_array_new_full(connections->len, g_object_unref);
                                for(guint i = 0; i < connections->len; ++i)
                                {
                                    NMRemoteConnection *conn = NM_REMOTE_CONNECTION(connections->pdata[i]);
                                    if(!conn) continue;
                                    NMSettingConnection *sCon = nm_connection_get_setting_connection(NM_CONNECTION(conn));
                                    if(!sCon) continue;
                                    const char *connType = nm_setting_connection_get_connection_type(sCon);

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

Comment on lines +656 to +677
bool wifiManager::addMinimalEthernetConnection(std::string iface)
{
if (!createClientNewConnection())
return false;

NMConnection *ethConn = createMinimalEthernetConnection(iface);
if (ethConn == NULL)
{
NMLOG_ERROR("Failed to create minimal ethernet connection");
deleteClientConnection();
return false;
}

GVariant *connSettings = nm_connection_to_dbus(ethConn, NM_CONNECTION_SERIALIZE_ALL);
g_object_unref(ethConn);

m_isSuccess = false;
nm_client_add_connection2(m_client,
connSettings,
NM_SETTINGS_ADD_CONNECTION2_FLAG_TO_DISK,
NULL, TRUE, m_cancellable,
addMinimalEthernetConnectionCb, this);
Comment on lines 442 to +526
rc = Core::ERROR_NONE;
// TODO: if no proimary connection, should we return empty string? RDK V return empty string
}

m_defaultInterface = interface;
return rc;
}
#endif

uint32_t NetworkManagerImplementation::SetInterfaceState(const string& interface/* @in */, const bool enabled /* @in */)
{

if(client == nullptr)
if(m_nmClient == nullptr)
{
NMLOG_WARNING("client connection null:");
NMLOG_WARNING("NMClient is null");
return Core::ERROR_RPC_CALL_FAILED;
}

if(interface.empty() || (interface != nmUtils::wlanIface() && interface != nmUtils::ethIface()))
{
NMLOG_ERROR("interface: %s; not valied", interface.c_str()!=nullptr? interface.c_str():"empty");
return Core::ERROR_GENERAL;
}

if(!wifi->setInterfaceState(interface, enabled))
// For ethernet enable: run BOOT_MIGRATION cleanup first, then setInterfaceState
if(enabled && interface == nmUtils::ethIface())
{
NMLOG_ERROR("interface state change failed");
return Core::ERROR_GENERAL;
}
// Check boot type and delete all ethernet NM connections if BOOT_MIGRATION
{
const char* bootFile = "/tmp/bootType";
std::ifstream file(bootFile);

NMLOG_INFO("interface %s state: %s", interface.c_str(), enabled ? "enabled" : "disabled");
// update the interface global cache state
if(interface == nmUtils::wlanIface() && _instance != NULL)
_instance->m_wlanEnabled.store(enabled);
else if(interface == nmUtils::ethIface() && _instance != NULL)
_instance->m_ethEnabled.store(enabled);
if(file.is_open())
{
std::string line, bootTypeValue;
while(std::getline(file, line))
{
const std::string key = "BOOT_TYPE=";
auto pos = line.find(key);
if(pos != std::string::npos)
{
bootTypeValue = line.substr(pos + key.size());
break;
}
}

if(bootTypeValue == "BOOT_MIGRATION")
{
NMLOG_INFO("BOOT_MIGRATION detected, deleting all wired NM connections");

// Bring down the ethernet interface before wiping its connections
// so NM doesn't immediately re-activate them during deletion.
NMDevice *ethDev = nm_client_get_device_by_iface(m_nmClient, interface.c_str());
if(ethDev)
{
GError *discError = nullptr;
if(!nm_device_disconnect(ethDev, nullptr, &discError))
{
NMLOG_WARNING("Failed to disconnect %s before migration cleanup: %s",
interface.c_str(),
discError ? discError->message : "unknown error");
if(discError) g_error_free(discError);
}
}

const GPtrArray *connections = nm_client_get_connections(m_nmClient);
if(connections && connections->len > 0)
{
/* Snapshot the list before iterating: nm_client_get_connections()
* returns an internal array that can be mutated as connections
* are removed, so we must not iterate it while deleting. */
GPtrArray *snapshot = g_ptr_array_new_full(connections->len, g_object_unref);
for(guint i = 0; i < connections->len; ++i)
{
NMRemoteConnection *conn = NM_REMOTE_CONNECTION(connections->pdata[i]);
if(!conn) continue;
NMSettingConnection *sCon = nm_connection_get_setting_connection(NM_CONNECTION(conn));
if(!sCon) continue;
const char *connType = nm_setting_connection_get_connection_type(sCon);
if(g_strcmp0(connType, NM_SETTING_WIRED_SETTING_NAME) != 0)
{
NMLOG_DEBUG("Skipping non-wired connection type: %s", connType ? connType : "null");
continue;
}
g_ptr_array_add(snapshot, g_object_ref(conn));
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.

2 participants