|
Packit Service |
a1bd4f |
/* SPDX-License-Identifier: GPL-2.0+ */
|
|
Packit |
5756e2 |
/*
|
|
Packit |
5756e2 |
* Copyright (C) 2017 Red Hat, Inc.
|
|
Packit |
5756e2 |
*/
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
#include "nm-default.h"
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
#include "nm-device-ovs-interface.h"
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
#include "nm-device-ovs-bridge.h"
|
|
Packit |
5756e2 |
#include "nm-ovsdb.h"
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
#include "devices/nm-device-private.h"
|
|
Packit |
5756e2 |
#include "nm-active-connection.h"
|
|
Packit |
5756e2 |
#include "nm-setting-connection.h"
|
|
Packit |
5756e2 |
#include "nm-setting-ovs-interface.h"
|
|
Packit |
5756e2 |
#include "nm-setting-ovs-port.h"
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
#define _NMLOG_DEVICE_TYPE NMDeviceOvsInterface
|
|
Packit |
5756e2 |
#include "devices/nm-device-logging.h"
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/*****************************************************************************/
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
typedef struct {
|
|
Packit Service |
a1bd4f |
bool waiting_for_interface : 1;
|
|
Packit |
5756e2 |
} NMDeviceOvsInterfacePrivate;
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
struct _NMDeviceOvsInterface {
|
|
Packit Service |
a1bd4f |
NMDevice parent;
|
|
Packit Service |
a1bd4f |
NMDeviceOvsInterfacePrivate _priv;
|
|
Packit |
5756e2 |
};
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
struct _NMDeviceOvsInterfaceClass {
|
|
Packit Service |
a1bd4f |
NMDeviceClass parent;
|
|
Packit |
5756e2 |
};
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
G_DEFINE_TYPE(NMDeviceOvsInterface, nm_device_ovs_interface, NM_TYPE_DEVICE)
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
#define NM_DEVICE_OVS_INTERFACE_GET_PRIVATE(self) \
|
|
Packit Service |
a1bd4f |
_NM_GET_PRIVATE(self, NMDeviceOvsInterface, NM_IS_DEVICE_OVS_INTERFACE, NMDevice)
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/*****************************************************************************/
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static const char *
|
|
Packit Service |
a1bd4f |
get_type_description(NMDevice *device)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
return "ovs-interface";
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static gboolean
|
|
Packit Service |
a1bd4f |
create_and_realize(NMDevice * device,
|
|
Packit Service |
a1bd4f |
NMConnection * connection,
|
|
Packit Service |
a1bd4f |
NMDevice * parent,
|
|
Packit Service |
a1bd4f |
const NMPlatformLink **out_plink,
|
|
Packit Service |
a1bd4f |
GError ** error)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
/* The actual backing resources will be created once an interface is
|
|
Packit Service |
a1bd4f |
* added to a port of ours, since there can be neither an empty port nor
|
|
Packit Service |
a1bd4f |
* an empty bridge. */
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
return TRUE;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static NMDeviceCapabilities
|
|
Packit Service |
a1bd4f |
get_generic_capabilities(NMDevice *device)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
return NM_DEVICE_CAP_CARRIER_DETECT | NM_DEVICE_CAP_IS_SOFTWARE;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static gboolean
|
|
Packit Service |
a1bd4f |
is_available(NMDevice *device, NMDeviceCheckDevAvailableFlags flags)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
return TRUE;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static gboolean
|
|
Packit Service |
a1bd4f |
check_connection_compatible(NMDevice *device, NMConnection *connection, GError **error)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMSettingOvsInterface *s_ovs_iface;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
if (!NM_DEVICE_CLASS(nm_device_ovs_interface_parent_class)
|
|
Packit Service |
a1bd4f |
->check_connection_compatible(device, connection, error))
|
|
Packit Service |
a1bd4f |
return FALSE;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
s_ovs_iface = nm_connection_get_setting_ovs_interface(connection);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
if (!NM_IN_STRSET(nm_setting_ovs_interface_get_interface_type(s_ovs_iface),
|
|
Packit Service |
a1bd4f |
"dpdk",
|
|
Packit Service |
a1bd4f |
"internal",
|
|
Packit Service |
a1bd4f |
"patch")) {
|
|
Packit Service |
a1bd4f |
nm_utils_error_set_literal(error,
|
|
Packit Service |
a1bd4f |
NM_UTILS_ERROR_CONNECTION_AVAILABLE_TEMPORARY,
|
|
Packit Service |
a1bd4f |
"unsupported OVS interface type in profile");
|
|
Packit Service |
a1bd4f |
return FALSE;
|
|
Packit Service |
a1bd4f |
}
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
return TRUE;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
link_changed(NMDevice *device, const NMPlatformLink *pllink)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMDeviceOvsInterfacePrivate *priv = NM_DEVICE_OVS_INTERFACE_GET_PRIVATE(device);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
if (!pllink || !priv->waiting_for_interface)
|
|
Packit Service |
a1bd4f |
return;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
priv->waiting_for_interface = FALSE;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
if (nm_device_get_state(device) == NM_DEVICE_STATE_IP_CONFIG) {
|
|
Packit Service |
a1bd4f |
if (!nm_device_hw_addr_set_cloned(device,
|
|
Packit Service |
a1bd4f |
nm_device_get_applied_connection(device),
|
|
Packit Service |
a1bd4f |
FALSE)) {
|
|
Packit Service |
a1bd4f |
nm_device_state_changed(device,
|
|
Packit Service |
a1bd4f |
NM_DEVICE_STATE_FAILED,
|
|
Packit Service |
a1bd4f |
NM_DEVICE_STATE_REASON_CONFIG_FAILED);
|
|
Packit Service |
a1bd4f |
return;
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
nm_device_bring_up(device, TRUE, NULL);
|
|
Packit Service |
a1bd4f |
nm_device_activate_schedule_stage3_ip_config_start(device);
|
|
Packit Service |
a1bd4f |
}
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static gboolean
|
|
Packit Service |
a1bd4f |
_is_internal_interface(NMDevice *device)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMSettingOvsInterface *s_ovs_iface;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
s_ovs_iface = nm_device_get_applied_setting(device, NM_TYPE_SETTING_OVS_INTERFACE);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
g_return_val_if_fail(s_ovs_iface, FALSE);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
return nm_streq(nm_setting_ovs_interface_get_interface_type(s_ovs_iface), "internal");
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
set_platform_mtu_cb(GError *error, gpointer user_data)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMDevice * device = user_data;
|
|
Packit Service |
a1bd4f |
NMDeviceOvsInterface *self = NM_DEVICE_OVS_INTERFACE(device);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
if (error && !g_error_matches(error, NM_UTILS_ERROR, NM_UTILS_ERROR_CANCELLED_DISPOSING)) {
|
|
Packit Service |
a1bd4f |
_LOGW(LOGD_DEVICE,
|
|
Packit Service |
a1bd4f |
"could not change mtu of '%s': %s",
|
|
Packit Service |
a1bd4f |
nm_device_get_iface(device),
|
|
Packit Service |
a1bd4f |
error->message);
|
|
Packit Service |
a1bd4f |
}
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
g_object_unref(device);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static gboolean
|
|
Packit Service |
a1bd4f |
set_platform_mtu(NMDevice *device, guint32 mtu)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
/*
|
|
Packit Service |
a1bd4f |
* If the MTU is not set in ovsdb, Open vSwitch will change
|
|
Packit Service |
a1bd4f |
* the MTU of an internal interface to match the minimum of
|
|
Packit Service |
a1bd4f |
* the other interfaces in the bridge.
|
|
Packit Service |
a1bd4f |
*/
|
|
Packit Service |
a1bd4f |
/* FIXME(shutdown): the function should become cancellable so
|
|
Packit Service |
a1bd4f |
* that it doesn't need to hold a reference to the device, and
|
|
Packit Service |
a1bd4f |
* it can be stopped during shutdown.
|
|
Packit Service |
a1bd4f |
*/
|
|
Packit Service |
a1bd4f |
if (_is_internal_interface(device)) {
|
|
Packit Service |
a1bd4f |
nm_ovsdb_set_interface_mtu(nm_ovsdb_get(),
|
|
Packit Service |
a1bd4f |
nm_device_get_ip_iface(device),
|
|
Packit Service |
a1bd4f |
mtu,
|
|
Packit Service |
a1bd4f |
set_platform_mtu_cb,
|
|
Packit Service |
a1bd4f |
g_object_ref(device));
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
return NM_DEVICE_CLASS(nm_device_ovs_interface_parent_class)->set_platform_mtu(device, mtu);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static NMActStageReturn
|
|
Packit Service |
a1bd4f |
act_stage3_ip_config_start(NMDevice * device,
|
|
Packit Service |
a1bd4f |
int addr_family,
|
|
Packit Service |
a1bd4f |
gpointer * out_config,
|
|
Packit Service |
a1bd4f |
NMDeviceStateReason *out_failure_reason)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMDeviceOvsInterface * self = NM_DEVICE_OVS_INTERFACE(device);
|
|
Packit Service |
a1bd4f |
NMDeviceOvsInterfacePrivate *priv = NM_DEVICE_OVS_INTERFACE_GET_PRIVATE(device);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
if (!_is_internal_interface(device))
|
|
Packit Service |
a1bd4f |
return NM_ACT_STAGE_RETURN_IP_FAIL;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
if (nm_device_get_ip_ifindex(device) <= 0) {
|
|
Packit Service |
a1bd4f |
_LOGT(LOGD_DEVICE, "waiting for link to appear");
|
|
Packit Service |
a1bd4f |
priv->waiting_for_interface = TRUE;
|
|
Packit Service |
a1bd4f |
return NM_ACT_STAGE_RETURN_POSTPONE;
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
if (!nm_device_hw_addr_set_cloned(device, nm_device_get_applied_connection(device), FALSE)) {
|
|
Packit Service |
a1bd4f |
*out_failure_reason = NM_DEVICE_STATE_REASON_CONFIG_FAILED;
|
|
Packit Service |
a1bd4f |
return NM_ACT_STAGE_RETURN_FAILURE;
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
return NM_DEVICE_CLASS(nm_device_ovs_interface_parent_class)
|
|
Packit Service |
a1bd4f |
->act_stage3_ip_config_start(device, addr_family, out_config, out_failure_reason);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static gboolean
|
|
Packit Service |
a1bd4f |
can_unmanaged_external_down(NMDevice *self)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
return FALSE;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
deactivate(NMDevice *device)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMDeviceOvsInterface * self = NM_DEVICE_OVS_INTERFACE(device);
|
|
Packit Service |
a1bd4f |
NMDeviceOvsInterfacePrivate *priv = NM_DEVICE_OVS_INTERFACE_GET_PRIVATE(self);
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
priv->waiting_for_interface = FALSE;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
typedef struct {
|
|
Packit Service |
a1bd4f |
NMDeviceOvsInterface * self;
|
|
Packit Service |
a1bd4f |
GCancellable * cancellable;
|
|
Packit Service |
a1bd4f |
NMDeviceDeactivateCallback callback;
|
|
Packit Service |
a1bd4f |
gpointer callback_user_data;
|
|
Packit Service |
a1bd4f |
gulong link_changed_id;
|
|
Packit Service |
a1bd4f |
gulong cancelled_id;
|
|
Packit Service |
a1bd4f |
guint link_timeout_id;
|
|
Packit |
5756e2 |
} DeactivateData;
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
deactivate_invoke_cb(DeactivateData *data, GError *error)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMDeviceOvsInterface *self = data->self;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
_LOGT(LOGD_CORE, "deactivate: async callback (%s)", error ? error->message : "success");
|
|
Packit Service |
a1bd4f |
data->callback(NM_DEVICE(data->self), error, data->callback_user_data);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
nm_clear_g_signal_handler(nm_device_get_platform(NM_DEVICE(data->self)),
|
|
Packit Service |
a1bd4f |
&data->link_changed_id);
|
|
Packit Service |
a1bd4f |
nm_clear_g_signal_handler(data->cancellable, &data->cancelled_id);
|
|
Packit Service |
a1bd4f |
nm_clear_g_source(&data->link_timeout_id);
|
|
Packit Service |
a1bd4f |
g_object_unref(data->self);
|
|
Packit Service |
a1bd4f |
g_object_unref(data->cancellable);
|
|
Packit Service |
a1bd4f |
nm_g_slice_free(data);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
deactivate_link_changed_cb(NMPlatform * platform,
|
|
Packit Service |
a1bd4f |
int obj_type_i,
|
|
Packit Service |
a1bd4f |
int ifindex,
|
|
Packit Service |
a1bd4f |
NMPlatformLink *info,
|
|
Packit Service |
a1bd4f |
int change_type_i,
|
|
Packit Service |
a1bd4f |
DeactivateData *data)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMDeviceOvsInterface * self = data->self;
|
|
Packit Service |
a1bd4f |
const NMPlatformSignalChangeType change_type = change_type_i;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
if (change_type == NM_PLATFORM_SIGNAL_REMOVED
|
|
Packit Service |
a1bd4f |
&& nm_streq0(info->name, nm_device_get_iface(NM_DEVICE(self)))) {
|
|
Packit Service |
a1bd4f |
_LOGT(LOGD_DEVICE, "deactivate: link removed, proceeding");
|
|
Packit Service |
a1bd4f |
nm_device_update_from_platform_link(NM_DEVICE(self), NULL);
|
|
Packit Service |
a1bd4f |
deactivate_invoke_cb(data, NULL);
|
|
Packit Service |
a1bd4f |
return;
|
|
Packit Service |
a1bd4f |
}
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static gboolean
|
|
Packit Service |
a1bd4f |
deactivate_link_timeout(gpointer user_data)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
DeactivateData * data = user_data;
|
|
Packit Service |
a1bd4f |
NMDeviceOvsInterface *self = data->self;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
_LOGT(LOGD_DEVICE, "deactivate: timeout waiting link removal");
|
|
Packit Service |
a1bd4f |
deactivate_invoke_cb(data, NULL);
|
|
Packit Service |
a1bd4f |
return G_SOURCE_REMOVE;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
deactivate_cancelled_cb(GCancellable *cancellable, gpointer user_data)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
gs_free_error GError *error = NULL;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
nm_utils_error_set_cancelled(&error, FALSE, NULL);
|
|
Packit Service |
a1bd4f |
deactivate_invoke_cb((DeactivateData *) user_data, error);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
deactivate_cb_on_idle(gpointer user_data, GCancellable *cancellable)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
DeactivateData *data = user_data;
|
|
Packit Service |
a1bd4f |
gs_free_error GError *cancelled_error = NULL;
|
|
Packit |
5756e2 |
|
|
Packit Service |
a1bd4f |
g_cancellable_set_error_if_cancelled(data->cancellable, &cancelled_error);
|
|
Packit Service |
a1bd4f |
deactivate_invoke_cb(data, cancelled_error);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
deactivate_async(NMDevice * device,
|
|
Packit Service |
a1bd4f |
GCancellable * cancellable,
|
|
Packit Service |
a1bd4f |
NMDeviceDeactivateCallback callback,
|
|
Packit Service |
a1bd4f |
gpointer callback_user_data)
|
|
Packit Service |
a1bd4f |
{
|
|
Packit Service |
a1bd4f |
NMDeviceOvsInterface * self = NM_DEVICE_OVS_INTERFACE(device);
|
|
Packit Service |
a1bd4f |
NMDeviceOvsInterfacePrivate *priv = NM_DEVICE_OVS_INTERFACE_GET_PRIVATE(self);
|
|
Packit Service |
a1bd4f |
DeactivateData * data;
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
_LOGT(LOGD_CORE, "deactivate: start async");
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
/* We want to ensure that the kernel link for this device is
|
|
Packit Service |
a1bd4f |
* removed upon disconnection so that it will not interfere with
|
|
Packit Service |
a1bd4f |
* later activations of the same device. Unfortunately there is
|
|
Packit Service |
a1bd4f |
* no synchronization mechanism with vswitchd, we only update
|
|
Packit Service |
a1bd4f |
* ovsdb and wait that changes are picked up.
|
|
Packit Service |
a1bd4f |
*/
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
data = g_slice_new(DeactivateData);
|
|
Packit Service |
a1bd4f |
*data = (DeactivateData){
|
|
Packit Service |
a1bd4f |
.self = g_object_ref(self),
|
|
Packit Service |
a1bd4f |
.cancellable = g_object_ref(cancellable),
|
|
Packit Service |
a1bd4f |
.callback = callback,
|
|
Packit Service |
a1bd4f |
.callback_user_data = callback_user_data,
|
|
Packit Service |
a1bd4f |
};
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
if (!priv->waiting_for_interface
|
|
Packit Service |
a1bd4f |
&& !nm_platform_link_get_by_ifname(nm_device_get_platform(device),
|
|
Packit Service |
a1bd4f |
nm_device_get_iface(device))) {
|
|
Packit Service |
a1bd4f |
_LOGT(LOGD_CORE, "deactivate: link not present, proceeding");
|
|
Packit Service |
a1bd4f |
nm_device_update_from_platform_link(NM_DEVICE(self), NULL);
|
|
Packit Service |
a1bd4f |
nm_utils_invoke_on_idle(cancellable, deactivate_cb_on_idle, data);
|
|
Packit Service |
a1bd4f |
return;
|
|
Packit Service |
a1bd4f |
}
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
if (priv->waiting_for_interface) {
|
|
Packit Service |
a1bd4f |
/* At this point we have issued an INSERT and a DELETE
|
|
Packit Service |
a1bd4f |
* command for the interface to ovsdb. We don't know if
|
|
Packit Service |
a1bd4f |
* vswitchd will see the two updates or only one. We
|
|
Packit Service |
a1bd4f |
* must add a timeout to avoid waiting forever in case
|
|
Packit Service |
a1bd4f |
* the link doesn't appear.
|
|
Packit Service |
a1bd4f |
*/
|
|
Packit Service |
a1bd4f |
data->link_timeout_id = g_timeout_add(6000, deactivate_link_timeout, data);
|
|
Packit Service |
a1bd4f |
_LOGT(LOGD_DEVICE, "deactivate: waiting for link to disappear in 6 seconds");
|
|
Packit Service |
a1bd4f |
} else
|
|
Packit Service |
a1bd4f |
_LOGT(LOGD_DEVICE, "deactivate: waiting for link to disappear");
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
data->cancelled_id =
|
|
Packit Service |
a1bd4f |
g_cancellable_connect(cancellable, G_CALLBACK(deactivate_cancelled_cb), data, NULL);
|
|
Packit Service |
a1bd4f |
data->link_changed_id = g_signal_connect(nm_device_get_platform(device),
|
|
Packit Service |
a1bd4f |
NM_PLATFORM_SIGNAL_LINK_CHANGED,
|
|
Packit Service |
a1bd4f |
G_CALLBACK(deactivate_link_changed_cb),
|
|
Packit Service |
a1bd4f |
data);
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static gboolean
|
|
Packit Service |
a1bd4f |
can_update_from_platform_link(NMDevice *device, const NMPlatformLink *plink)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
/* If the device is deactivating, we already sent the
|
|
Packit Service |
a1bd4f |
* deletion command to ovsdb and we don't want to deal
|
|
Packit Service |
a1bd4f |
* with any new link appearing from the previous
|
|
Packit Service |
a1bd4f |
* activation.
|
|
Packit Service |
a1bd4f |
*/
|
|
Packit Service |
a1bd4f |
return !plink || nm_device_get_state(device) != NM_DEVICE_STATE_DEACTIVATING;
|
|
Packit |
5756e2 |
}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
/*****************************************************************************/
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
nm_device_ovs_interface_init(NMDeviceOvsInterface *self)
|
|
Packit Service |
a1bd4f |
{}
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static const NMDBusInterfaceInfoExtended interface_info_device_ovs_interface = {
|
|
Packit Service |
a1bd4f |
.parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT(
|
|
Packit Service |
a1bd4f |
NM_DBUS_INTERFACE_DEVICE_OVS_INTERFACE,
|
|
Packit Service |
a1bd4f |
.signals = NM_DEFINE_GDBUS_SIGNAL_INFOS(&nm_signal_info_property_changed_legacy, ), ),
|
|
Packit Service |
a1bd4f |
.legacy_property_changed = TRUE,
|
|
Packit |
5756e2 |
};
|
|
Packit |
5756e2 |
|
|
Packit |
5756e2 |
static void
|
|
Packit Service |
a1bd4f |
nm_device_ovs_interface_class_init(NMDeviceOvsInterfaceClass *klass)
|
|
Packit |
5756e2 |
{
|
|
Packit Service |
a1bd4f |
NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS(klass);
|
|
Packit Service |
a1bd4f |
NMDeviceClass * device_class = NM_DEVICE_CLASS(klass);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
dbus_object_class->interface_infos =
|
|
Packit Service |
a1bd4f |
NM_DBUS_INTERFACE_INFOS(&interface_info_device_ovs_interface);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
device_class->connection_type_supported = NM_SETTING_OVS_INTERFACE_SETTING_NAME;
|
|
Packit Service |
a1bd4f |
device_class->connection_type_check_compatible = NM_SETTING_OVS_INTERFACE_SETTING_NAME;
|
|
Packit Service |
a1bd4f |
device_class->link_types = NM_DEVICE_DEFINE_LINK_TYPES(NM_LINK_TYPE_OPENVSWITCH);
|
|
Packit Service |
a1bd4f |
|
|
Packit Service |
a1bd4f |
device_class->can_update_from_platform_link = can_update_from_platform_link;
|
|
Packit Service |
a1bd4f |
device_class->deactivate = deactivate;
|
|
Packit Service |
a1bd4f |
device_class->deactivate_async = deactivate_async;
|
|
Packit Service |
a1bd4f |
device_class->get_type_description = get_type_description;
|
|
Packit Service |
a1bd4f |
device_class->create_and_realize = create_and_realize;
|
|
Packit Service |
a1bd4f |
device_class->get_generic_capabilities = get_generic_capabilities;
|
|
Packit Service |
a1bd4f |
device_class->is_available = is_available;
|
|
Packit Service |
a1bd4f |
device_class->check_connection_compatible = check_connection_compatible;
|
|
Packit Service |
a1bd4f |
device_class->link_changed = link_changed;
|
|
Packit Service |
a1bd4f |
device_class->act_stage3_ip_config_start = act_stage3_ip_config_start;
|
|
Packit Service |
a1bd4f |
device_class->can_unmanaged_external_down = can_unmanaged_external_down;
|
|
Packit Service |
a1bd4f |
device_class->set_platform_mtu = set_platform_mtu;
|
|
Packit Service |
a1bd4f |
device_class->get_configured_mtu = nm_device_get_configured_mtu_for_wired;
|
|
Packit Service |
a1bd4f |
device_class->can_reapply_change_ovs_external_ids = TRUE;
|
|
Packit Service |
a1bd4f |
device_class->reapply_connection = nm_device_ovs_reapply_connection;
|
|
Packit |
5756e2 |
}
|