From 964ae8cc391520440cf5aa13e2b9cc34850ea6c2 Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Tue, 26 Feb 2019 19:01:41 +0100 Subject: New upstream version 1.14.6 --- src/devices/ovs/nm-ovsdb.c | 78 ++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 41 deletions(-) (limited to 'src/devices/ovs') diff --git a/src/devices/ovs/nm-ovsdb.c b/src/devices/ovs/nm-ovsdb.c index b00397cf..494e2ea0 100644 --- a/src/devices/ovs/nm-ovsdb.c +++ b/src/devices/ovs/nm-ovsdb.c @@ -349,14 +349,14 @@ _insert_interface (json_t *params, NMConnection *interface) if (s_ovs_iface) type = nm_setting_ovs_interface_get_interface_type (s_ovs_iface); - json_array_append (options, json_string ("map")); + json_array_append_new (options, json_string ("map")); s_ovs_patch = nm_connection_get_setting_ovs_patch (interface); if (s_ovs_patch) { - json_array_append (options, json_pack ("[[s, s]]", + json_array_append_new (options, json_pack ("[[s, s]]", "peer", nm_setting_ovs_patch_get_peer (s_ovs_patch))); } else { - json_array_append (options, json_array ()); + json_array_append_new (options, json_array ()); } json_array_append_new (params, @@ -504,12 +504,15 @@ _add_interface (NMOvsdb *self, json_t *params, OpenvswitchBridge *ovs_bridge = NULL; OpenvswitchPort *ovs_port = NULL; OpenvswitchInterface *ovs_interface = NULL; + nm_auto_decref_json json_t *bridges = NULL; + nm_auto_decref_json json_t *new_bridges = NULL; + nm_auto_decref_json json_t *ports = NULL; + nm_auto_decref_json json_t *new_ports = NULL; + nm_auto_decref_json json_t *interfaces = NULL; + nm_auto_decref_json json_t *new_interfaces = NULL; + gboolean has_interface = FALSE; int pi; int ii; - json_t *bridges, *new_bridges; - json_t *ports, *new_ports; - json_t *interfaces, *new_interfaces; - gboolean has_interface = FALSE; bridges = json_array (); ports = json_array (); @@ -585,14 +588,6 @@ _add_interface (NMOvsdb *self, json_t *params, _insert_interface (params, interface); json_array_append_new (new_interfaces, json_pack ("[s, s]", "named-uuid", "rowInterface")); } - - json_decref (interfaces); - json_decref (ports); - json_decref (bridges); - - json_decref (new_interfaces); - json_decref (new_ports); - json_decref (new_bridges); } /** @@ -612,14 +607,13 @@ _delete_interface (NMOvsdb *self, json_t *params, const char *ifname) OpenvswitchBridge *ovs_bridge; OpenvswitchPort *ovs_port; OpenvswitchInterface *ovs_interface; - int pi; - int ii; - json_t *bridges, *new_bridges; - json_t *ports, *new_ports; - json_t *interfaces, *new_interfaces; + nm_auto_decref_json json_t *bridges = NULL; + nm_auto_decref_json json_t *new_bridges = NULL; gboolean bridges_changed; gboolean ports_changed; gboolean interfaces_changed; + int pi; + int ii; bridges = json_array (); new_bridges = json_array (); @@ -627,20 +621,26 @@ _delete_interface (NMOvsdb *self, json_t *params, const char *ifname) g_hash_table_iter_init (&iter, priv->bridges); while (g_hash_table_iter_next (&iter, (gpointer) &bridge_uuid, (gpointer) &ovs_bridge)) { - json_array_append_new (bridges, json_pack ("[s,s]", "uuid", bridge_uuid)); + nm_auto_decref_json json_t *ports = NULL; + nm_auto_decref_json json_t *new_ports = NULL; ports = json_array (); new_ports = json_array (); ports_changed = FALSE; + json_array_append_new (bridges, json_pack ("[s,s]", "uuid", bridge_uuid)); + for (pi = 0; pi < ovs_bridge->ports->len; pi++) { + nm_auto_decref_json json_t *interfaces = NULL; + nm_auto_decref_json json_t *new_interfaces = NULL; + + interfaces = json_array (); + new_interfaces = json_array (); port_uuid = g_ptr_array_index (ovs_bridge->ports, pi); ovs_port = g_hash_table_lookup (priv->ports, port_uuid); json_array_append_new (ports, json_pack ("[s,s]", "uuid", port_uuid)); - interfaces = json_array (); - new_interfaces = json_array (); interfaces_changed = FALSE; for (ii = 0; ii < ovs_port->interfaces->len; ii++) { @@ -667,9 +667,6 @@ _delete_interface (NMOvsdb *self, json_t *params, const char *ifname) } json_array_append_new (new_ports, json_pack ("[s,s]", "uuid", port_uuid)); } - - json_decref (interfaces); - json_decref (new_interfaces); } if (json_array_size (new_ports) == 0) { @@ -681,9 +678,6 @@ _delete_interface (NMOvsdb *self, json_t *params, const char *ifname) } json_array_append_new (new_bridges, json_pack ("[s,s]", "uuid", bridge_uuid)); } - - json_decref (ports); - json_decref (new_ports); } if (bridges_changed) { @@ -708,7 +702,7 @@ ovsdb_next_command (NMOvsdb *self) NMOvsdbPrivate *priv = NM_OVSDB_GET_PRIVATE (self); OvsdbMethodCall *call = NULL; char *cmd; - json_t *msg = NULL; + nm_auto_decref_json json_t *msg = NULL; json_t *params; if (!priv->conn) @@ -764,7 +758,6 @@ ovsdb_next_command (NMOvsdb *self) cmd = json_dumps (msg, 0); g_string_append (priv->output, cmd); - json_decref (msg); free (cmd); ovsdb_write (self); @@ -1041,7 +1034,7 @@ static void ovsdb_got_echo (NMOvsdb *self, json_int_t id, json_t *data) { NMOvsdbPrivate *priv = NM_OVSDB_GET_PRIVATE (self); - json_t *msg; + nm_auto_decref_json json_t *msg = NULL; char *reply; gboolean output_was_empty; @@ -1050,7 +1043,6 @@ ovsdb_got_echo (NMOvsdb *self, json_int_t id, json_t *data) msg = json_pack ("{s:I, s:O}", "id", id, "result", data); reply = json_dumps (msg, 0); g_string_append (priv->output, reply); - json_decref (msg); free (reply); if (output_was_empty) @@ -1300,6 +1292,9 @@ ovsdb_disconnect (NMOvsdb *self, gboolean is_disposing) gpointer user_data; gs_free_error GError *error = NULL; + if (!priv->client) + return; + _LOGD ("disconnecting from ovsdb"); nm_utils_error_set_cancelled (&error, is_disposing, "NMOvsdb"); @@ -1317,6 +1312,7 @@ ovsdb_disconnect (NMOvsdb *self, gboolean is_disposing) g_clear_object (&priv->client); g_clear_object (&priv->conn); g_clear_pointer (&priv->db_uuid, g_free); + nm_clear_g_cancellable (&priv->cancellable); } static void @@ -1535,11 +1531,14 @@ dispose (GObject *object) ovsdb_disconnect (self, TRUE); - g_string_free (priv->input, TRUE); - priv->input = NULL; - g_string_free (priv->output, TRUE); - priv->output = NULL; - + if (priv->input) { + g_string_free (priv->input, TRUE); + priv->input = NULL; + } + if (priv->output) { + g_string_free (priv->output, TRUE); + priv->output = NULL; + } if (priv->calls) { g_array_free (priv->calls, TRUE); priv->calls = NULL; @@ -1549,9 +1548,6 @@ dispose (GObject *object) g_clear_pointer (&priv->ports, g_hash_table_destroy); g_clear_pointer (&priv->interfaces, g_hash_table_destroy); - g_cancellable_cancel (priv->cancellable); - g_clear_object (&priv->cancellable); - G_OBJECT_CLASS (nm_ovsdb_parent_class)->dispose (object); } -- cgit 1.3.0-6-gf8a5 From 9a6dcbf895f9da01768e64b73cec88c16157d91e Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Tue, 26 Mar 2019 23:25:23 +0100 Subject: New upstream version 1.16.0 --- src/devices/ovs/meson.build | 6 ++--- src/devices/ovs/nm-device-ovs-bridge.c | 18 ++++---------- src/devices/ovs/nm-device-ovs-interface.c | 39 +++++++++---------------------- src/devices/ovs/nm-device-ovs-port.c | 18 ++++---------- src/devices/ovs/nm-ovsdb.c | 3 +-- 5 files changed, 25 insertions(+), 59 deletions(-) (limited to 'src/devices/ovs') diff --git a/src/devices/ovs/meson.build b/src/devices/ovs/meson.build index 9d637fe9..834b27b0 100644 --- a/src/devices/ovs/meson.build +++ b/src/devices/ovs/meson.build @@ -3,12 +3,12 @@ sources = files( 'nm-device-ovs-interface.c', 'nm-device-ovs-port.c', 'nm-ovsdb.c', - 'nm-ovs-factory.c' + 'nm-ovs-factory.c', ) deps = [ jansson_dep, - nm_dep + nm_dep, ] libnm_device_plugin_ovs = shared_module( @@ -18,7 +18,7 @@ libnm_device_plugin_ovs = shared_module( link_args: ldflags_linker_script_devices, link_depends: linker_script_devices, install: true, - install_dir: nm_plugindir + install_dir: nm_plugindir, ) core_plugins += libnm_device_plugin_ovs diff --git a/src/devices/ovs/nm-device-ovs-bridge.c b/src/devices/ovs/nm-device-ovs-bridge.c index eff355a3..be707e7a 100644 --- a/src/devices/ovs/nm-device-ovs-bridge.c +++ b/src/devices/ovs/nm-device-ovs-bridge.c @@ -77,17 +77,10 @@ get_generic_capabilities (NMDevice *device) } static NMActStageReturn -act_stage3_ip4_config_start (NMDevice *device, - NMIP4Config **out_config, - NMDeviceStateReason *out_failure_reason) -{ - return NM_ACT_STAGE_RETURN_IP_FAIL; -} - -static NMActStageReturn -act_stage3_ip6_config_start (NMDevice *device, - NMIP6Config **out_config, - NMDeviceStateReason *out_failure_reason) +act_stage3_ip_config_start (NMDevice *device, + int addr_family, + gpointer *out_config, + NMDeviceStateReason *out_failure_reason) { return NM_ACT_STAGE_RETURN_IP_FAIL; } @@ -146,8 +139,7 @@ nm_device_ovs_bridge_class_init (NMDeviceOvsBridgeClass *klass) device_class->create_and_realize = create_and_realize; device_class->unrealize = unrealize; device_class->get_generic_capabilities = get_generic_capabilities; - 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->act_stage3_ip_config_start = act_stage3_ip_config_start; device_class->enslave_slave = enslave_slave; device_class->release_slave = release_slave; } diff --git a/src/devices/ovs/nm-device-ovs-interface.c b/src/devices/ovs/nm-device-ovs-interface.c index 2b48fae6..e3d3f9ee 100644 --- a/src/devices/ovs/nm-device-ovs-interface.c +++ b/src/devices/ovs/nm-device-ovs-interface.c @@ -121,48 +121,32 @@ link_changed (NMDevice *device, static gboolean _is_internal_interface (NMDevice *device) { - NMConnection *connection = nm_device_get_applied_connection (device); - NMSettingOvsInterface *s_ovs_iface = nm_connection_get_setting_ovs_interface (connection); - - g_return_val_if_fail (s_ovs_iface, FALSE); - - return strcmp (nm_setting_ovs_interface_get_interface_type (s_ovs_iface), "internal") == 0; -} - -static NMActStageReturn -act_stage3_ip4_config_start (NMDevice *device, - NMIP4Config **out_config, - NMDeviceStateReason *out_failure_reason) -{ - NMDeviceOvsInterfacePrivate *priv = NM_DEVICE_OVS_INTERFACE_GET_PRIVATE (device); + NMSettingOvsInterface *s_ovs_iface; - if (!_is_internal_interface (device)) - return NM_ACT_STAGE_RETURN_IP_FAIL; + s_ovs_iface = nm_device_get_applied_setting (device, NM_TYPE_SETTING_OVS_INTERFACE); - if (!nm_device_get_ip_ifindex (device)) { - priv->waiting_for_interface = TRUE; - return NM_ACT_STAGE_RETURN_POSTPONE; - } + g_return_val_if_fail (s_ovs_iface, FALSE); - return NM_DEVICE_CLASS (nm_device_ovs_interface_parent_class)->act_stage3_ip4_config_start (device, out_config, out_failure_reason); + return nm_streq (nm_setting_ovs_interface_get_interface_type (s_ovs_iface), "internal"); } static NMActStageReturn -act_stage3_ip6_config_start (NMDevice *device, - NMIP6Config **out_config, - NMDeviceStateReason *out_failure_reason) +act_stage3_ip_config_start (NMDevice *device, + int addr_family, + gpointer *out_config, + NMDeviceStateReason *out_failure_reason) { NMDeviceOvsInterfacePrivate *priv = NM_DEVICE_OVS_INTERFACE_GET_PRIVATE (device); if (!_is_internal_interface (device)) return NM_ACT_STAGE_RETURN_IP_FAIL; - if (!nm_device_get_ip_ifindex (device)) { + if (nm_device_get_ip_ifindex (device) <= 0) { priv->waiting_for_interface = TRUE; return NM_ACT_STAGE_RETURN_POSTPONE; } - return NM_DEVICE_CLASS (nm_device_ovs_interface_parent_class)->act_stage3_ip6_config_start (device, out_config, out_failure_reason); + return NM_DEVICE_CLASS (nm_device_ovs_interface_parent_class)->act_stage3_ip_config_start (device, addr_family, out_config, out_failure_reason); } static gboolean @@ -206,7 +190,6 @@ nm_device_ovs_interface_class_init (NMDeviceOvsInterfaceClass *klass) device_class->is_available = is_available; device_class->check_connection_compatible = check_connection_compatible; device_class->link_changed = link_changed; - 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->act_stage3_ip_config_start = act_stage3_ip_config_start; device_class->can_unmanaged_external_down = can_unmanaged_external_down; } diff --git a/src/devices/ovs/nm-device-ovs-port.c b/src/devices/ovs/nm-device-ovs-port.c index 1f9afbab..b96eba68 100644 --- a/src/devices/ovs/nm-device-ovs-port.c +++ b/src/devices/ovs/nm-device-ovs-port.c @@ -71,17 +71,10 @@ get_generic_capabilities (NMDevice *device) } static NMActStageReturn -act_stage3_ip4_config_start (NMDevice *device, - NMIP4Config **out_config, - NMDeviceStateReason *out_failure_reason) -{ - return NM_ACT_STAGE_RETURN_IP_FAIL; -} - -static NMActStageReturn -act_stage3_ip6_config_start (NMDevice *device, - NMIP6Config **out_config, - NMDeviceStateReason *out_failure_reason) +act_stage3_ip_config_start (NMDevice *device, + int addr_family, + gpointer *out_config, + NMDeviceStateReason *out_failure_reason) { return NM_ACT_STAGE_RETURN_IP_FAIL; } @@ -186,8 +179,7 @@ nm_device_ovs_port_class_init (NMDeviceOvsPortClass *klass) device_class->get_type_description = get_type_description; device_class->create_and_realize = create_and_realize; device_class->get_generic_capabilities = get_generic_capabilities; - 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->act_stage3_ip_config_start = act_stage3_ip_config_start; device_class->enslave_slave = enslave_slave; device_class->release_slave = release_slave; } diff --git a/src/devices/ovs/nm-ovsdb.c b/src/devices/ovs/nm-ovsdb.c index 494e2ea0..9d73c3ac 100644 --- a/src/devices/ovs/nm-ovsdb.c +++ b/src/devices/ovs/nm-ovsdb.c @@ -21,7 +21,6 @@ #include "nm-ovsdb.h" -#include #include #include @@ -1118,7 +1117,7 @@ ovsdb_got_msg (NMOvsdb *self, json_t *msg) ovsdb_disconnect (self, FALSE); return; } - /* Cool, we found a corresponsing call. Finish it. */ + /* Cool, we found a corresponding call. Finish it. */ _call_trace ("response", call, msg); -- cgit 1.3.0-6-gf8a5 From 85563b7fc7ec2cd21e38debb9b28db342e2e8e7c Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Sun, 21 Apr 2019 21:09:51 +0200 Subject: New upstream version 1.18.0 --- src/devices/ovs/nm-device-ovs-port.c | 6 ++++++ src/devices/ovs/nm-ovs-factory.c | 2 +- src/devices/ovs/nm-ovsdb.c | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) (limited to 'src/devices/ovs') diff --git a/src/devices/ovs/nm-device-ovs-port.c b/src/devices/ovs/nm-device-ovs-port.c index b96eba68..35eb739f 100644 --- a/src/devices/ovs/nm-device-ovs-port.c +++ b/src/devices/ovs/nm-device-ovs-port.c @@ -20,6 +20,7 @@ #include "nm-default.h" #include "nm-device-ovs-port.h" +#include "nm-device-ovs-interface.h" #include "nm-ovsdb.h" #include "devices/nm-device-private.h" @@ -141,6 +142,11 @@ release_slave (NMDevice *device, NMDevice *slave, gboolean configure) { nm_ovsdb_del_interface (nm_ovsdb_get (), nm_device_get_iface (slave), del_iface_cb, g_object_ref (slave)); + + /* Open VSwitch is going to delete this one. We must ignore what happens + * next with the interface. */ + if (NM_IS_DEVICE_OVS_INTERFACE (slave)) + nm_device_update_from_platform_link (slave, NULL); } /*****************************************************************************/ diff --git a/src/devices/ovs/nm-ovs-factory.c b/src/devices/ovs/nm-ovs-factory.c index 766c650b..2124b2a0 100644 --- a/src/devices/ovs/nm-ovs-factory.c +++ b/src/devices/ovs/nm-ovs-factory.c @@ -132,7 +132,7 @@ ovsdb_device_removed (NMOvsdb *ovsdb, const char *name, NMDeviceType device_type && device_state < NM_DEVICE_STATE_DEACTIVATING) { nm_device_state_changed (device, NM_DEVICE_STATE_DEACTIVATING, - NM_DEVICE_STATE_REASON_REMOVED); + NM_DEVICE_STATE_REASON_DEPENDENCY_FAILED); } else if (device_state == NM_DEVICE_STATE_UNMANAGED) { nm_device_unrealize (device, TRUE, NULL); } diff --git a/src/devices/ovs/nm-ovsdb.c b/src/devices/ovs/nm-ovsdb.c index 9d73c3ac..5b50f840 100644 --- a/src/devices/ovs/nm-ovsdb.c +++ b/src/devices/ovs/nm-ovsdb.c @@ -24,7 +24,7 @@ #include #include -#include "nm-utils/nm-jansson.h" +#include "nm-glib-aux/nm-jansson.h" #include "devices/nm-device.h" #include "platform/nm-platform.h" #include "nm-core-internal.h" -- cgit 1.3.0-6-gf8a5