diff --git a/src/LMI_IPConfigurationServiceProvider.c b/src/LMI_IPConfigurationServiceProvider.c index 49f2db5..09e79d7 100644 --- a/src/LMI_IPConfigurationServiceProvider.c +++ b/src/LMI_IPConfigurationServiceProvider.c @@ -305,7 +305,7 @@ KUint32 LMI_IPConfigurationService_ApplySettingToIPNetworkConnection( LMIResult res_current = LMI_SUCCESS, res_next = LMI_SUCCESS; Require(SettingData, "No SettingData has been specified", result, 2); - Require(IPNetworkConnection, "No IPNetworkConnection has been specified", result, 2); + //Require(IPNetworkConnection, "No IPNetworkConnection has been specified", result, 2); if (!Mode->exists || Mode->null) { warn("No Mode has been specified, assuming 1"); @@ -317,19 +317,26 @@ KUint32 LMI_IPConfigurationService_ApplySettingToIPNetworkConnection( } } - CIM_IPNetworkConnectionRef ipNetworkConnectionRef; - CIM_IPNetworkConnectionRef_InitFromObjectPath(&ipNetworkConnectionRef, _cb, IPNetworkConnection->value); - if (strcmp(ipNetworkConnectionRef.SystemName.chars, get_system_name()) != 0) { - KSetStatus2(_cb, status, ERR_INVALID_PARAMETER, "IPNetworkConnection doesn't exists"); - return result; - } - network_lock(network); - const Ports *ports = network_get_ports(network); Port *port = NULL; - for (i = 0; i < ports_length(ports); ++i) { - if (strcmp(port_get_id(ports_index(ports, i)), ipNetworkConnectionRef.Name.chars) == 0) { - port = ports_index(ports, i); - break; + network_lock(network); + if (IPNetworkConnection->exists && !IPNetworkConnection->null) { + CIM_IPNetworkConnectionRef ipNetworkConnectionRef; + CIM_IPNetworkConnectionRef_InitFromObjectPath(&ipNetworkConnectionRef, _cb, IPNetworkConnection->value); + if (strcmp(ipNetworkConnectionRef.SystemName.chars, get_system_name()) != 0) { + KSetStatus2(_cb, status, ERR_INVALID_PARAMETER, "IPNetworkConnection doesn't exists"); + return result; + } + const Ports *ports = network_get_ports(network); + for (i = 0; i < ports_length(ports); ++i) { + if (strcmp(port_get_id(ports_index(ports, i)), ipNetworkConnectionRef.Name.chars) == 0) { + port = ports_index(ports, i); + break; + } + } + if (port == NULL) { + KSetStatus2(_cb, status, ERR_INVALID_PARAMETER, "IPNetworkConnection doesn't exists"); + network_unlock(network); + return result; } } @@ -362,12 +369,6 @@ KUint32 LMI_IPConfigurationService_ApplySettingToIPNetworkConnection( } free(id); - if (port == NULL) { - KSetStatus2(_cb, status, ERR_INVALID_PARAMETER, "IPNetworkConnection doesn't exists"); - network_unlock(network); - return result; - } - if (connection == NULL) { KSetStatus2(_cb, status, ERR_INVALID_PARAMETER, "SettingData doesn't exists"); network_unlock(network); diff --git a/src/network.c b/src/network.c index db77116..426a4f3 100644 --- a/src/network.c +++ b/src/network.c @@ -214,9 +214,9 @@ const Connections *network_get_connections(Network *network) LMIResult network_activate_connection(Network *network, const Port *port, const Connection *connection, Job **job) { - debug("network_activate_connection %s %s", port_get_id(port), connection->port != NULL ? port_get_id(connection->port) : "NULL"); + debug("network_activate_connection %s %s", port != NULL ? port_get_id(port) : "NULL", connection->port != NULL ? port_get_id(connection->port) : "NULL"); ConnectionType type = connection_get_type(connection); - if (type == CONNECTION_TYPE_BOND || type == CONNECTION_TYPE_BRIDGE) { + if (port != NULL && (type == CONNECTION_TYPE_BOND || type == CONNECTION_TYPE_BRIDGE)) { // Activate slave connection const Connections *connections = network_get_connections(network); Connection *c, *master; @@ -234,7 +234,7 @@ LMIResult network_activate_connection(Network *network, const Port *port, const error("No slave connection for port %s and connection %s", port_get_id(port), connection_get_id(connection)); return LMI_ERROR_CONNECTION_INVALID; } - if (connection->port != NULL && !port_compare(port, connection->port)) { + if (port != NULL && connection->port != NULL && !port_compare(port, connection->port)) { error("Port %s is not the same as port %s assigned to connection %s", port_get_id(port), port_get_id(connection->port), connection->id); return LMI_ERROR_CONNECTION_INVALID; diff --git a/src/network_nm.c b/src/network_nm.c index 7f37833..6b054f2 100644 --- a/src/network_nm.c +++ b/src/network_nm.c @@ -176,7 +176,7 @@ LMIResult network_priv_activate_connection(Network *network, const Port *port, c char *activeConnectionPath; if (!dbus_g_proxy_call(priv->managerProxy, "ActivateConnection", &err, DBUS_TYPE_G_OBJECT_PATH, connection->uuid, - DBUS_TYPE_G_OBJECT_PATH, port_get_uuid(port), + DBUS_TYPE_G_OBJECT_PATH, port != NULL ? port_get_uuid(port) : "/", DBUS_TYPE_G_OBJECT_PATH, "/", G_TYPE_INVALID, DBUS_TYPE_G_OBJECT_PATH, &activeConnectionPath, G_TYPE_INVALID)) { @@ -230,7 +230,7 @@ LMIResult network_priv_activate_connection(Network *network, const Port *port, c } debug("Job monitoring ActiveConnection %s started", activeConnectionPath); free(activeConnectionPath); - if (job_add_affected_element(*job, JOB_AFFECTED_PORT_ID, port_get_id(port)) != LMI_SUCCESS) { + if (port != NULL && job_add_affected_element(*job, JOB_AFFECTED_PORT_ID, port_get_id(port)) != LMI_SUCCESS) { job_free(*job); *job = NULL; return LMI_ERROR_MEMORY;