diff options
| author | Michael Biebl <biebl@debian.org> | 2018-06-04 00:07:45 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2018-06-04 00:07:45 +0200 |
| commit | 04bc9e1cd3544445d883ad29ea108c1645c8e7b7 (patch) | |
| tree | d10c354b1b980ca8a7b9e48ec9019e8ed88bde2b /src/devices/ovs | |
| parent | ee9c73a923909e23a649407be77e25235d769e25 (diff) | |
New upstream version 1.11.4 upstream/1.11.4
Diffstat (limited to 'src/devices/ovs')
| -rw-r--r-- | src/devices/ovs/meson.build | 38 | ||||
| -rw-r--r-- | src/devices/ovs/nm-device-ovs-bridge.c | 21 | ||||
| -rw-r--r-- | src/devices/ovs/nm-device-ovs-interface.c | 19 | ||||
| -rw-r--r-- | src/devices/ovs/nm-device-ovs-port.c | 22 | ||||
| -rw-r--r-- | src/devices/ovs/nm-ovsdb.c | 52 |
5 files changed, 96 insertions, 56 deletions
diff --git a/src/devices/ovs/meson.build b/src/devices/ovs/meson.build new file mode 100644 index 00000000..f4edd57c --- /dev/null +++ b/src/devices/ovs/meson.build @@ -0,0 +1,38 @@ +sources = files( + 'nm-device-ovs-bridge.c', + 'nm-device-ovs-interface.c', + 'nm-device-ovs-port.c', + 'nm-ovsdb.c', + 'nm-ovs-factory.c' +) + +deps = [ + jansson_dep, + nm_dep +] + +libnm_device_plugin_ovs = shared_module( + 'nm-device-plugin-ovs', + sources: sources, + dependencies: deps, + c_args: '-DRUNSTATEDIR="@0@"'.format(nm_runstatedir), + link_args: ldflags_linker_script_devices, + link_depends: linker_script_devices, + install: true, + install_dir: nm_plugindir +) + +core_plugins += libnm_device_plugin_ovs + +run_target( + 'check-local-devices-ovs', + command: [check_exports, libnm_device_plugin_ovs.full_path(), linker_script_devices], + depends: libnm_device_plugin_ovs +) + +# FIXME: check_so_symbols replacement +''' +check-local-devices-ovs: src/devices/ovs/libnm-device-plugin-ovs.la + $(srcdir)/tools/check-exports.sh $(builddir)/src/devices/ovs/.libs/libnm-device-plugin-ovs.so "$(srcdir)/linker-script-devices.ver" + $(call check_so_symbols,$(builddir)/src/devices/ovs/.libs/libnm-device-plugin-ovs.so) +''' diff --git a/src/devices/ovs/nm-device-ovs-bridge.c b/src/devices/ovs/nm-device-ovs-bridge.c index 53ea2b82..5244ca8b 100644 --- a/src/devices/ovs/nm-device-ovs-bridge.c +++ b/src/devices/ovs/nm-device-ovs-bridge.c @@ -28,10 +28,8 @@ #include "nm-setting-connection.h" #include "nm-setting-ovs-bridge.h" -#include "introspection/org.freedesktop.NetworkManager.Device.OvsBridge.h" - #include "devices/nm-device-logging.h" -_LOG_DECLARE_SELF(NMDeviceOvsBridge); +_LOG_DECLARE_SELF (NMDeviceOvsBridge); /*****************************************************************************/ @@ -133,11 +131,24 @@ nm_device_ovs_bridge_init (NMDeviceOvsBridge *self) { } +static const NMDBusInterfaceInfoExtended interface_info_device_ovs_bridge = { + .parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT ( + NM_DBUS_INTERFACE_DEVICE_OVS_BRIDGE, + .signals = NM_DEFINE_GDBUS_SIGNAL_INFOS ( + &nm_signal_info_property_changed_legacy, + ), + ), + .legacy_property_changed = TRUE, +}; + static void nm_device_ovs_bridge_class_init (NMDeviceOvsBridgeClass *klass) { + NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (klass); NMDeviceClass *device_class = NM_DEVICE_CLASS (klass); + dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_device_ovs_bridge); + device_class->connection_type = NM_SETTING_OVS_BRIDGE_SETTING_NAME; device_class->is_master = TRUE; device_class->get_type_description = get_type_description; @@ -149,8 +160,4 @@ nm_device_ovs_bridge_class_init (NMDeviceOvsBridgeClass *klass) device_class->act_stage3_ip6_config_start = act_stage3_ip6_config_start; device_class->enslave_slave = enslave_slave; device_class->release_slave = release_slave; - - nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass), - NMDBUS_TYPE_DEVICE_OVS_BRIDGE_SKELETON, - NULL); } diff --git a/src/devices/ovs/nm-device-ovs-interface.c b/src/devices/ovs/nm-device-ovs-interface.c index ce32c2dd..eefe38c8 100644 --- a/src/devices/ovs/nm-device-ovs-interface.c +++ b/src/devices/ovs/nm-device-ovs-interface.c @@ -28,8 +28,6 @@ #include "nm-setting-ovs-interface.h" #include "nm-setting-ovs-port.h" -#include "introspection/org.freedesktop.NetworkManager.Device.OvsInterface.h" - #include "devices/nm-device-logging.h" _LOG_DECLARE_SELF(NMDeviceOvsInterface); @@ -185,13 +183,26 @@ nm_device_ovs_interface_init (NMDeviceOvsInterface *self) { } +static const NMDBusInterfaceInfoExtended interface_info_device_ovs_interface = { + .parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT ( + NM_DBUS_INTERFACE_DEVICE_OVS_INTERFACE, + .signals = NM_DEFINE_GDBUS_SIGNAL_INFOS ( + &nm_signal_info_property_changed_legacy, + ), + ), + .legacy_property_changed = TRUE, +}; + static void nm_device_ovs_interface_class_init (NMDeviceOvsInterfaceClass *klass) { + NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (klass); NMDeviceClass *device_class = NM_DEVICE_CLASS (klass); NM_DEVICE_CLASS_DECLARE_TYPES (klass, NULL, NM_LINK_TYPE_OPENVSWITCH); + dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_device_ovs_interface); + device_class->connection_type = NM_SETTING_OVS_INTERFACE_SETTING_NAME; device_class->get_type_description = get_type_description; device_class->create_and_realize = create_and_realize; @@ -202,8 +213,4 @@ nm_device_ovs_interface_class_init (NMDeviceOvsInterfaceClass *klass) device_class->act_stage3_ip4_config_start = act_stage3_ip4_config_start; device_class->act_stage3_ip6_config_start = act_stage3_ip6_config_start; device_class->can_unmanaged_external_down = can_unmanaged_external_down; - - nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass), - NMDBUS_TYPE_DEVICE_OVS_INTERFACE_SKELETON, - NULL); } diff --git a/src/devices/ovs/nm-device-ovs-port.c b/src/devices/ovs/nm-device-ovs-port.c index cb0915af..91cf4f4d 100644 --- a/src/devices/ovs/nm-device-ovs-port.c +++ b/src/devices/ovs/nm-device-ovs-port.c @@ -28,10 +28,8 @@ #include "nm-setting-ovs-port.h" #include "nm-setting-ovs-port.h" -#include "introspection/org.freedesktop.NetworkManager.Device.OvsPort.h" - #include "devices/nm-device-logging.h" -_LOG_DECLARE_SELF(NMDeviceOvsPort); +_LOG_DECLARE_SELF (NMDeviceOvsPort); /*****************************************************************************/ @@ -72,7 +70,6 @@ get_generic_capabilities (NMDevice *device) return NM_DEVICE_CAP_IS_SOFTWARE; } - static gboolean check_connection_compatible (NMDevice *device, NMConnection *connection) { @@ -180,11 +177,24 @@ nm_device_ovs_port_init (NMDeviceOvsPort *self) { } +static const NMDBusInterfaceInfoExtended interface_info_device_ovs_port = { + .parent = NM_DEFINE_GDBUS_INTERFACE_INFO_INIT ( + NM_DBUS_INTERFACE_DEVICE_OVS_PORT, + .signals = NM_DEFINE_GDBUS_SIGNAL_INFOS ( + &nm_signal_info_property_changed_legacy, + ), + ), + .legacy_property_changed = TRUE, +}; + static void nm_device_ovs_port_class_init (NMDeviceOvsPortClass *klass) { + NMDBusObjectClass *dbus_object_class = NM_DBUS_OBJECT_CLASS (klass); NMDeviceClass *device_class = NM_DEVICE_CLASS (klass); + dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_device_ovs_port); + device_class->connection_type = NM_SETTING_OVS_PORT_SETTING_NAME; device_class->is_master = TRUE; device_class->get_type_description = get_type_description; @@ -195,8 +205,4 @@ nm_device_ovs_port_class_init (NMDeviceOvsPortClass *klass) device_class->act_stage3_ip6_config_start = act_stage3_ip6_config_start; device_class->enslave_slave = enslave_slave; device_class->release_slave = release_slave; - - nm_exported_object_class_add_interface (NM_EXPORTED_OBJECT_CLASS (klass), - NMDBUS_TYPE_DEVICE_OVS_PORT_SKELETON, - NULL); } diff --git a/src/devices/ovs/nm-ovsdb.c b/src/devices/ovs/nm-ovsdb.c index 92fcfa01..a9cb5703 100644 --- a/src/devices/ovs/nm-ovsdb.c +++ b/src/devices/ovs/nm-ovsdb.c @@ -22,37 +22,20 @@ #include "nm-ovsdb.h" #include <string.h> -#include <jansson.h> #include <gmodule.h> #include <gio/gunixsocketaddress.h> +#include "nm-utils/nm-jansson.h" #include "devices/nm-device.h" #include "platform/nm-platform.h" #include "nm-core-internal.h" -/* Added in Jansson v2.4 (released Sep 23 2012), but travis.ci has v2.2. */ -#ifndef json_boolean -#define json_boolean(val) ((val) ? json_true() : json_false()) -#endif - -/* Added in Jansson v2.5 (released Sep 19 2013), but travis.ci has v2.2. */ -#ifndef json_array_foreach -#define json_array_foreach(array, index, value) \ - for (index = 0; \ - index < json_array_size(array) && (value = json_array_get(array, index)); \ - index++) -#endif +/*****************************************************************************/ -/* Added in Jansson v2.3 (released Jan 27 2012) */ -#ifndef json_object_foreach -#define json_object_foreach(object, key, value) \ - for(key = json_object_iter_key(json_object_iter(object)); \ - key && (value = json_object_iter_value(json_object_key_to_iter(key))); \ - key = json_object_iter_key(json_object_iter_next(object, json_object_key_to_iter(key)))) +#if JANSSON_VERSION_HEX < 0x020400 +#warning "requires at least libjansson 2.4" #endif -/*****************************************************************************/ - typedef struct { char *name; char *connection_uuid; @@ -95,7 +78,7 @@ typedef struct { GHashTable *interfaces; /* interface uuid => OpenvswitchInterface */ GHashTable *ports; /* port uuid => OpenvswitchPort */ GHashTable *bridges; /* bridge uuid => OpenvswitchBridge */ - const char *db_uuid; + char *db_uuid; } NMOvsdbPrivate; struct _NMOvsdb { @@ -144,7 +127,7 @@ typedef struct { OvsdbMethodCallback callback; gpointer user_data; union { - const char *ifname; + char *ifname; struct { NMConnection *bridge; NMConnection *port; @@ -380,7 +363,7 @@ _insert_interface (json_t *params, NMConnection *interface) json_pack ("{s:s, s:s, s:{s:s, s:s, s:o, s:[s, [[s, s]]]}, s:s}", "op", "insert", "table", "Interface", "row", "name", nm_connection_get_interface_name (interface), - "type", type ? type : "", + "type", type ?: "", "options", options, "external_ids", "map", "NM.connection.uuid", nm_connection_get_uuid (interface), "uuid-name", "rowInterface")); @@ -884,7 +867,7 @@ ovsdb_got_update (NMOvsdb *self, json_t *msg) if (ovs) { iter = json_object_iter (ovs); - priv->db_uuid = g_strdup (iter ? json_object_iter_key (iter) : NULL); + priv->db_uuid = iter ? g_strdup (json_object_iter_key (iter)) : NULL; } /* Interfaces */ @@ -908,7 +891,7 @@ ovsdb_got_update (NMOvsdb *self, json_t *msg) _LOGT ("removed an '%s' interface: %s%s%s", ovs_interface->type, ovs_interface->name, ovs_interface->connection_uuid ? ", " : "", - ovs_interface->connection_uuid ? ovs_interface->connection_uuid : ""); + ovs_interface->connection_uuid ?: ""); if (g_strcmp0 (ovs_interface->type, "internal") == 0) { /* Currently the factory only creates NMDevices for * internal interfaces. Ignore the rest. */ @@ -927,14 +910,14 @@ ovsdb_got_update (NMOvsdb *self, json_t *msg) if (old) { _LOGT ("changed an '%s' interface: %s%s%s", type, ovs_interface->name, ovs_interface->connection_uuid ? ", " : "", - ovs_interface->connection_uuid ? ovs_interface->connection_uuid : ""); + ovs_interface->connection_uuid ?: ""); g_signal_emit (self, signals[DEVICE_CHANGED], 0, "ovs-interface", ovs_interface->name); } else { _LOGT ("added an '%s' interface: %s%s%s", ovs_interface->type, ovs_interface->name, ovs_interface->connection_uuid ? ", " : "", - ovs_interface->connection_uuid ? ovs_interface->connection_uuid : ""); + ovs_interface->connection_uuid ?: ""); if (g_strcmp0 (ovs_interface->type, "internal") == 0) { /* Currently the factory only creates NMDevices for * internal interfaces. Ignore the rest. */ @@ -966,7 +949,7 @@ ovsdb_got_update (NMOvsdb *self, json_t *msg) old = FALSE; _LOGT ("removed a port: %s%s%s", ovs_port->name, ovs_port->connection_uuid ? ", " : "", - ovs_port->connection_uuid ? ovs_port->connection_uuid : ""); + ovs_port->connection_uuid ?: ""); g_signal_emit (self, signals[DEVICE_REMOVED], 0, ovs_port->name, NM_DEVICE_TYPE_OVS_PORT); } @@ -982,13 +965,13 @@ ovsdb_got_update (NMOvsdb *self, json_t *msg) if (old) { _LOGT ("changed a port: %s%s%s", ovs_port->name, ovs_port->connection_uuid ? ", " : "", - ovs_port->connection_uuid ? ovs_port->connection_uuid : ""); + ovs_port->connection_uuid ?: ""); g_signal_emit (self, signals[DEVICE_CHANGED], 0, NM_SETTING_OVS_PORT_SETTING_NAME, ovs_port->name); } else { _LOGT ("added a port: %s%s%s", ovs_port->name, ovs_port->connection_uuid ? ", " : "", - ovs_port->connection_uuid ? ovs_port->connection_uuid : ""); + ovs_port->connection_uuid ?: ""); g_signal_emit (self, signals[DEVICE_ADDED], 0, ovs_port->name, NM_DEVICE_TYPE_OVS_PORT); } @@ -1016,7 +999,7 @@ ovsdb_got_update (NMOvsdb *self, json_t *msg) old = FALSE; _LOGT ("removed a bridge: %s%s%s", ovs_bridge->name, ovs_bridge->connection_uuid ? ", " : "", - ovs_bridge->connection_uuid ? ovs_bridge->connection_uuid : ""); + ovs_bridge->connection_uuid ?: ""); g_signal_emit (self, signals[DEVICE_REMOVED], 0, ovs_bridge->name, NM_DEVICE_TYPE_OVS_BRIDGE); } @@ -1032,13 +1015,13 @@ ovsdb_got_update (NMOvsdb *self, json_t *msg) if (old) { _LOGT ("changed a bridge: %s%s%s", ovs_bridge->name, ovs_bridge->connection_uuid ? ", " : "", - ovs_bridge->connection_uuid ? ovs_bridge->connection_uuid : ""); + ovs_bridge->connection_uuid ?: ""); g_signal_emit (self, signals[DEVICE_CHANGED], 0, NM_SETTING_OVS_BRIDGE_SETTING_NAME, ovs_bridge->name); } else { _LOGT ("added a bridge: %s%s%s", ovs_bridge->name, ovs_bridge->connection_uuid ? ", " : "", - ovs_bridge->connection_uuid ? ovs_bridge->connection_uuid : ""); + ovs_bridge->connection_uuid ?: ""); g_signal_emit (self, signals[DEVICE_ADDED], 0, ovs_bridge->name, NM_DEVICE_TYPE_OVS_BRIDGE); } @@ -1170,7 +1153,6 @@ ovsdb_got_msg (NMOvsdb *self, json_t *msg) return; } - /* This is a message we are not interested in. */ _LOGW ("got an unknown message, ignoring"); } |