|
|
97acb4 |
From bc2e2d8562cc856442e6f449bc422d152527b8c9 Mon Sep 17 00:00:00 2001
|
|
|
871508 |
From: Beniamino Galvani <bgalvani@redhat.com>
|
|
|
871508 |
Date: Fri, 25 Oct 2019 10:36:52 +0200
|
|
|
871508 |
Subject: [PATCH 1/2] ovs: fix memory leak
|
|
|
871508 |
|
|
|
871508 |
(cherry picked from commit 508c7679cfb06f9d5149e637737d28a958f9131c)
|
|
|
871508 |
(cherry picked from commit ad17cfff249e7edde0011dc80f09f496ba2fe020)
|
|
|
871508 |
(cherry picked from commit 836b9e24a475fa9ef5b86d9ca34c751336da4b52)
|
|
|
871508 |
---
|
|
|
871508 |
src/devices/ovs/nm-ovsdb.c | 2 +-
|
|
|
871508 |
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
|
871508 |
|
|
|
871508 |
diff --git a/src/devices/ovs/nm-ovsdb.c b/src/devices/ovs/nm-ovsdb.c
|
|
|
871508 |
index 5b50f8406..8b6dca7a5 100644
|
|
|
871508 |
--- a/src/devices/ovs/nm-ovsdb.c
|
|
|
871508 |
+++ b/src/devices/ovs/nm-ovsdb.c
|
|
|
871508 |
@@ -1068,7 +1068,7 @@ ovsdb_got_msg (NMOvsdb *self, json_t *msg)
|
|
|
871508 |
OvsdbMethodCall *call = NULL;
|
|
|
871508 |
OvsdbMethodCallback callback;
|
|
|
871508 |
gpointer user_data;
|
|
|
871508 |
- GError *local = NULL;
|
|
|
871508 |
+ gs_free_error GError *local = NULL;
|
|
|
871508 |
|
|
|
871508 |
if (json_unpack_ex (msg, &json_error, 0, "{s?:o, s?:s, s?:o, s?:o, s?:o}",
|
|
|
871508 |
"id", &json_id,
|
|
|
871508 |
--
|
|
|
871508 |
2.21.0
|
|
|
871508 |
|
|
|
97acb4 |
From 014c1f0ea0cd1b2723d4f123eb43996a0cf37522 Mon Sep 17 00:00:00 2001
|
|
|
871508 |
From: Beniamino Galvani <bgalvani@redhat.com>
|
|
|
871508 |
Date: Thu, 24 Oct 2019 15:59:43 +0200
|
|
|
871508 |
Subject: [PATCH 2/2] ovs: allow changing mac address of bridges and interfaces
|
|
|
871508 |
|
|
|
871508 |
Allow changing the cloned MAC address for OVS bridges and
|
|
|
871508 |
interfaces. The MAC address set on the bridge is propagated by ovs to
|
|
|
871508 |
the local interface (the one with the same name as the bridge), while
|
|
|
871508 |
all other internal interfaces use the address defined in the interface
|
|
|
871508 |
connection.
|
|
|
871508 |
|
|
|
871508 |
https://bugzilla.redhat.com/show_bug.cgi?id=1763734
|
|
|
871508 |
https://bugzilla.redhat.com/show_bug.cgi?id=1740557
|
|
|
871508 |
|
|
|
871508 |
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/321
|
|
|
871508 |
(cherry picked from commit 101e65d2bb1920853da4621e220b4825860ec46d)
|
|
|
871508 |
(cherry picked from commit b366234a3a1deb4a6924744f6b7cafa9f2650e3e)
|
|
|
871508 |
(cherry picked from commit 5a4a5f637bb65e9833836e724b3beea19158e9f8)
|
|
|
871508 |
---
|
|
|
871508 |
clients/common/nm-meta-setting-desc.c | 1 +
|
|
|
871508 |
src/devices/ovs/nm-device-ovs-port.c | 5 ++
|
|
|
871508 |
src/devices/ovs/nm-ovsdb.c | 88 ++++++++++++++++++++++-----
|
|
|
871508 |
src/devices/ovs/nm-ovsdb.h | 1 +
|
|
|
871508 |
4 files changed, 79 insertions(+), 16 deletions(-)
|
|
|
871508 |
|
|
|
871508 |
diff --git a/clients/common/nm-meta-setting-desc.c b/clients/common/nm-meta-setting-desc.c
|
|
|
97acb4 |
index afeb69a52..e14b23438 100644
|
|
|
871508 |
--- a/clients/common/nm-meta-setting-desc.c
|
|
|
871508 |
+++ b/clients/common/nm-meta-setting-desc.c
|
|
|
97acb4 |
@@ -7871,6 +7871,7 @@ const NMMetaSettingInfoEditor nm_meta_setting_infos_editor[] = {
|
|
|
871508 |
.valid_parts = NM_META_SETTING_VALID_PARTS (
|
|
|
871508 |
NM_META_SETTING_VALID_PART_ITEM (CONNECTION, TRUE),
|
|
|
871508 |
NM_META_SETTING_VALID_PART_ITEM (OVS_BRIDGE, TRUE),
|
|
|
871508 |
+ NM_META_SETTING_VALID_PART_ITEM (WIRED, FALSE),
|
|
|
871508 |
),
|
|
|
871508 |
),
|
|
|
871508 |
SETTING_INFO (OVS_INTERFACE,
|
|
|
871508 |
diff --git a/src/devices/ovs/nm-device-ovs-port.c b/src/devices/ovs/nm-device-ovs-port.c
|
|
|
871508 |
index 8a93a5a9d..39e64b3f1 100644
|
|
|
871508 |
--- a/src/devices/ovs/nm-device-ovs-port.c
|
|
|
871508 |
+++ b/src/devices/ovs/nm-device-ovs-port.c
|
|
|
871508 |
@@ -102,6 +102,7 @@ enslave_slave (NMDevice *device, NMDevice *slave, NMConnection *connection, gboo
|
|
|
871508 |
{
|
|
|
871508 |
NMActiveConnection *ac_port = NULL;
|
|
|
871508 |
NMActiveConnection *ac_bridge = NULL;
|
|
|
871508 |
+ NMDevice *bridge_device;
|
|
|
871508 |
|
|
|
871508 |
if (!configure)
|
|
|
871508 |
return TRUE;
|
|
|
871508 |
@@ -111,10 +112,14 @@ enslave_slave (NMDevice *device, NMDevice *slave, NMConnection *connection, gboo
|
|
|
871508 |
if (!ac_bridge)
|
|
|
871508 |
ac_bridge = ac_port;
|
|
|
871508 |
|
|
|
871508 |
+ bridge_device = nm_active_connection_get_device (ac_bridge);
|
|
|
871508 |
+
|
|
|
871508 |
nm_ovsdb_add_interface (nm_ovsdb_get (),
|
|
|
871508 |
nm_active_connection_get_applied_connection (ac_bridge),
|
|
|
871508 |
nm_device_get_applied_connection (device),
|
|
|
871508 |
nm_device_get_applied_connection (slave),
|
|
|
871508 |
+ bridge_device,
|
|
|
871508 |
+ slave,
|
|
|
871508 |
add_iface_cb, g_object_ref (slave));
|
|
|
871508 |
|
|
|
871508 |
return TRUE;
|
|
|
871508 |
diff --git a/src/devices/ovs/nm-ovsdb.c b/src/devices/ovs/nm-ovsdb.c
|
|
|
871508 |
index 8b6dca7a5..82e25f396 100644
|
|
|
871508 |
--- a/src/devices/ovs/nm-ovsdb.c
|
|
|
871508 |
+++ b/src/devices/ovs/nm-ovsdb.c
|
|
|
871508 |
@@ -28,6 +28,7 @@
|
|
|
871508 |
#include "devices/nm-device.h"
|
|
|
871508 |
#include "platform/nm-platform.h"
|
|
|
871508 |
#include "nm-core-internal.h"
|
|
|
871508 |
+#include "devices/nm-device.h"
|
|
|
871508 |
|
|
|
871508 |
/*****************************************************************************/
|
|
|
871508 |
|
|
|
871508 |
@@ -131,6 +132,8 @@ typedef struct {
|
|
|
871508 |
NMConnection *bridge;
|
|
|
871508 |
NMConnection *port;
|
|
|
871508 |
NMConnection *interface;
|
|
|
871508 |
+ NMDevice *bridge_device;
|
|
|
871508 |
+ NMDevice *interface_device;
|
|
|
871508 |
};
|
|
|
871508 |
};
|
|
|
871508 |
} OvsdbMethodCall;
|
|
|
871508 |
@@ -183,6 +186,7 @@ static void
|
|
|
871508 |
ovsdb_call_method (NMOvsdb *self, OvsdbCommand command,
|
|
|
871508 |
const char *ifname,
|
|
|
871508 |
NMConnection *bridge, NMConnection *port, NMConnection *interface,
|
|
|
871508 |
+ NMDevice *bridge_device, NMDevice *interface_device,
|
|
|
871508 |
OvsdbMethodCallback callback, gpointer user_data)
|
|
|
871508 |
{
|
|
|
871508 |
NMOvsdbPrivate *priv = NM_OVSDB_GET_PRIVATE (self);
|
|
|
871508 |
@@ -205,6 +209,8 @@ ovsdb_call_method (NMOvsdb *self, OvsdbCommand command,
|
|
|
871508 |
call->bridge = nm_simple_connection_new_clone (bridge);
|
|
|
871508 |
call->port = nm_simple_connection_new_clone (port);
|
|
|
871508 |
call->interface = nm_simple_connection_new_clone (interface);
|
|
|
871508 |
+ call->bridge_device = g_object_ref (bridge_device);
|
|
|
871508 |
+ call->interface_device = g_object_ref (interface_device);
|
|
|
871508 |
break;
|
|
|
871508 |
case OVSDB_DEL_INTERFACE:
|
|
|
871508 |
call->ifname = g_strdup (ifname);
|
|
|
871508 |
@@ -337,17 +343,32 @@ _set_port_interfaces (json_t *params, const char *ifname, json_t *new_interfaces
|
|
|
871508 |
* Returns an commands that adds new interface from a given connection.
|
|
|
871508 |
*/
|
|
|
871508 |
static void
|
|
|
871508 |
-_insert_interface (json_t *params, NMConnection *interface)
|
|
|
871508 |
+_insert_interface (json_t *params, NMConnection *interface, NMDevice *interface_device)
|
|
|
871508 |
{
|
|
|
871508 |
const char *type = NULL;
|
|
|
871508 |
NMSettingOvsInterface *s_ovs_iface;
|
|
|
871508 |
NMSettingOvsPatch *s_ovs_patch;
|
|
|
871508 |
json_t *options = json_array ();
|
|
|
871508 |
+ gs_free char *cloned_mac = NULL;
|
|
|
871508 |
+ gs_free_error GError *error = NULL;
|
|
|
871508 |
+ json_t *row;
|
|
|
871508 |
|
|
|
871508 |
s_ovs_iface = nm_connection_get_setting_ovs_interface (interface);
|
|
|
871508 |
if (s_ovs_iface)
|
|
|
871508 |
type = nm_setting_ovs_interface_get_interface_type (s_ovs_iface);
|
|
|
871508 |
|
|
|
871508 |
+ if (!nm_device_hw_addr_get_cloned (interface_device,
|
|
|
871508 |
+ interface,
|
|
|
871508 |
+ FALSE,
|
|
|
871508 |
+ &cloned_mac,
|
|
|
871508 |
+ NULL,
|
|
|
871508 |
+ &error)) {
|
|
|
871508 |
+ _LOGW ("Cannot determine cloned mac for OVS %s '%s': %s",
|
|
|
871508 |
+ "interface",
|
|
|
871508 |
+ nm_connection_get_interface_name (interface),
|
|
|
871508 |
+ error->message);
|
|
|
871508 |
+ }
|
|
|
871508 |
+
|
|
|
871508 |
json_array_append_new (options, json_string ("map"));
|
|
|
871508 |
s_ovs_patch = nm_connection_get_setting_ovs_patch (interface);
|
|
|
871508 |
if (s_ovs_patch) {
|
|
|
871508 |
@@ -358,14 +379,22 @@ _insert_interface (json_t *params, NMConnection *interface)
|
|
|
871508 |
json_array_append_new (options, json_array ());
|
|
|
871508 |
}
|
|
|
871508 |
|
|
|
871508 |
+ row = json_pack ("{s:s, s:s, s:o, s:[s, [[s, s]]]}",
|
|
|
871508 |
+ "name", nm_connection_get_interface_name (interface),
|
|
|
871508 |
+ "type", type ?: "",
|
|
|
871508 |
+ "options", options,
|
|
|
871508 |
+ "external_ids", "map",
|
|
|
871508 |
+ "NM.connection.uuid", nm_connection_get_uuid (interface));
|
|
|
871508 |
+
|
|
|
871508 |
+ if (cloned_mac)
|
|
|
871508 |
+ json_object_set_new (row, "mac", json_string (cloned_mac));
|
|
|
871508 |
+
|
|
|
871508 |
json_array_append_new (params,
|
|
|
871508 |
- json_pack ("{s:s, s:s, s:{s:s, s:s, s:o, s:[s, [[s, s]]]}, s:s}",
|
|
|
871508 |
- "op", "insert", "table", "Interface", "row",
|
|
|
871508 |
- "name", nm_connection_get_interface_name (interface),
|
|
|
871508 |
- "type", type ?: "",
|
|
|
871508 |
- "options", options,
|
|
|
871508 |
- "external_ids", "map", "NM.connection.uuid", nm_connection_get_uuid (interface),
|
|
|
871508 |
- "uuid-name", "rowInterface"));
|
|
|
871508 |
+ json_pack ("{s:s, s:s, s:o, s:s}",
|
|
|
871508 |
+ "op", "insert",
|
|
|
871508 |
+ "table", "Interface",
|
|
|
871508 |
+ "row", row,
|
|
|
871508 |
+ "uuid-name", "rowInterface"));
|
|
|
871508 |
}
|
|
|
871508 |
|
|
|
871508 |
/**
|
|
|
871508 |
@@ -429,7 +458,7 @@ _insert_port (json_t *params, NMConnection *port, json_t *new_interfaces)
|
|
|
871508 |
* Returns an commands that adds new bridge from a given connection.
|
|
|
871508 |
*/
|
|
|
871508 |
static void
|
|
|
871508 |
-_insert_bridge (json_t *params, NMConnection *bridge, json_t *new_ports)
|
|
|
871508 |
+_insert_bridge (json_t *params, NMConnection *bridge, NMDevice *bridge_device, json_t *new_ports)
|
|
|
871508 |
{
|
|
|
871508 |
NMSettingOvsBridge *s_ovs_bridge;
|
|
|
871508 |
const char *fail_mode = NULL;
|
|
|
871508 |
@@ -437,9 +466,23 @@ _insert_bridge (json_t *params, NMConnection *bridge, json_t *new_ports)
|
|
|
871508 |
gboolean rstp_enable = FALSE;
|
|
|
871508 |
gboolean stp_enable = FALSE;
|
|
|
871508 |
json_t *row;
|
|
|
871508 |
+ gs_free_error GError *error = NULL;
|
|
|
871508 |
+ gs_free char *cloned_mac = NULL;
|
|
|
871508 |
|
|
|
871508 |
s_ovs_bridge = nm_connection_get_setting_ovs_bridge (bridge);
|
|
|
871508 |
|
|
|
871508 |
+ if (!nm_device_hw_addr_get_cloned (bridge_device,
|
|
|
871508 |
+ bridge,
|
|
|
871508 |
+ FALSE,
|
|
|
871508 |
+ &cloned_mac,
|
|
|
871508 |
+ NULL,
|
|
|
871508 |
+ &error)) {
|
|
|
871508 |
+ _LOGW ("Cannot determine cloned mac for OVS %s '%s': %s",
|
|
|
871508 |
+ "bridge",
|
|
|
871508 |
+ nm_connection_get_interface_name (bridge),
|
|
|
871508 |
+ error->message);
|
|
|
871508 |
+ }
|
|
|
871508 |
+
|
|
|
871508 |
row = json_object ();
|
|
|
871508 |
|
|
|
871508 |
if (s_ovs_bridge) {
|
|
|
871508 |
@@ -464,6 +507,12 @@ _insert_bridge (json_t *params, NMConnection *bridge, json_t *new_ports)
|
|
|
871508 |
json_pack ("[s, [[s, s]]]", "map",
|
|
|
871508 |
"NM.connection.uuid", nm_connection_get_uuid (bridge)));
|
|
|
871508 |
|
|
|
871508 |
+ if (cloned_mac) {
|
|
|
871508 |
+ json_object_set_new (row, "other_config",
|
|
|
871508 |
+ json_pack ("[s, [[s, s]]]", "map",
|
|
|
871508 |
+ "hwaddr", cloned_mac));
|
|
|
871508 |
+ }
|
|
|
871508 |
+
|
|
|
871508 |
/* Create a new one. */
|
|
|
871508 |
json_array_append_new (params,
|
|
|
871508 |
json_pack ("{s:s, s:s, s:o, s:s}", "op", "insert", "table", "Bridge",
|
|
|
871508 |
@@ -493,7 +542,8 @@ _inc_next_cfg (const char *db_uuid)
|
|
|
871508 |
*/
|
|
|
871508 |
static void
|
|
|
871508 |
_add_interface (NMOvsdb *self, json_t *params,
|
|
|
871508 |
- NMConnection *bridge, NMConnection *port, NMConnection *interface)
|
|
|
871508 |
+ NMConnection *bridge, NMConnection *port, NMConnection *interface,
|
|
|
871508 |
+ NMDevice *bridge_device, NMDevice *interface_device)
|
|
|
871508 |
{
|
|
|
871508 |
NMOvsdbPrivate *priv = NM_OVSDB_GET_PRIVATE (self);
|
|
|
871508 |
GHashTableIter iter;
|
|
|
871508 |
@@ -566,7 +616,7 @@ _add_interface (NMOvsdb *self, json_t *params,
|
|
|
871508 |
_expect_ovs_bridges (params, priv->db_uuid, bridges);
|
|
|
871508 |
json_array_append_new (new_bridges, json_pack ("[s, s]", "named-uuid", "rowBridge"));
|
|
|
871508 |
_set_ovs_bridges (params, priv->db_uuid, new_bridges);
|
|
|
871508 |
- _insert_bridge (params, bridge, new_ports);
|
|
|
871508 |
+ _insert_bridge (params, bridge, bridge_device, new_ports);
|
|
|
871508 |
} else {
|
|
|
871508 |
/* Bridge already exists. */
|
|
|
871508 |
g_return_if_fail (ovs_bridge);
|
|
|
871508 |
@@ -584,7 +634,7 @@ _add_interface (NMOvsdb *self, json_t *params,
|
|
|
871508 |
}
|
|
|
871508 |
|
|
|
871508 |
if (!has_interface) {
|
|
|
871508 |
- _insert_interface (params, interface);
|
|
|
871508 |
+ _insert_interface (params, interface, interface_device);
|
|
|
871508 |
json_array_append_new (new_interfaces, json_pack ("[s, s]", "named-uuid", "rowInterface"));
|
|
|
871508 |
}
|
|
|
871508 |
}
|
|
|
871508 |
@@ -733,7 +783,8 @@ ovsdb_next_command (NMOvsdb *self)
|
|
|
871508 |
json_array_append_new (params, json_string ("Open_vSwitch"));
|
|
|
871508 |
json_array_append_new (params, _inc_next_cfg (priv->db_uuid));
|
|
|
871508 |
|
|
|
871508 |
- _add_interface (self, params, call->bridge, call->port, call->interface);
|
|
|
871508 |
+ _add_interface (self, params, call->bridge, call->port, call->interface,
|
|
|
871508 |
+ call->bridge_device, call->interface_device);
|
|
|
871508 |
|
|
|
871508 |
msg = json_pack ("{s:i, s:s, s:o}",
|
|
|
871508 |
"id", call->id,
|
|
|
871508 |
@@ -1385,7 +1436,7 @@ ovsdb_try_connect (NMOvsdb *self)
|
|
|
871508 |
/* Queue a monitor call before any other command, ensuring that we have an up
|
|
|
871508 |
* to date view of existing bridged that we need for add and remove ops. */
|
|
|
871508 |
ovsdb_call_method (self, OVSDB_MONITOR, NULL,
|
|
|
871508 |
- NULL, NULL, NULL, _monitor_bridges_cb, NULL);
|
|
|
871508 |
+ NULL, NULL, NULL, NULL, NULL, _monitor_bridges_cb, NULL);
|
|
|
871508 |
}
|
|
|
871508 |
|
|
|
871508 |
/*****************************************************************************/
|
|
|
871508 |
@@ -1426,6 +1477,7 @@ out:
|
|
|
871508 |
void
|
|
|
871508 |
nm_ovsdb_add_interface (NMOvsdb *self,
|
|
|
871508 |
NMConnection *bridge, NMConnection *port, NMConnection *interface,
|
|
|
871508 |
+ NMDevice *bridge_device, NMDevice *interface_device,
|
|
|
871508 |
NMOvsdbCallback callback, gpointer user_data)
|
|
|
871508 |
{
|
|
|
871508 |
OvsdbCall *call;
|
|
|
871508 |
@@ -1435,7 +1487,9 @@ nm_ovsdb_add_interface (NMOvsdb *self,
|
|
|
871508 |
call->user_data = user_data;
|
|
|
871508 |
|
|
|
871508 |
ovsdb_call_method (self, OVSDB_ADD_INTERFACE, NULL,
|
|
|
871508 |
- bridge, port, interface, _transact_cb, call);
|
|
|
871508 |
+ bridge, port, interface,
|
|
|
871508 |
+ bridge_device, interface_device,
|
|
|
871508 |
+ _transact_cb, call);
|
|
|
871508 |
}
|
|
|
871508 |
|
|
|
871508 |
void
|
|
|
871508 |
@@ -1449,7 +1503,7 @@ nm_ovsdb_del_interface (NMOvsdb *self, const char *ifname,
|
|
|
871508 |
call->user_data = user_data;
|
|
|
871508 |
|
|
|
871508 |
ovsdb_call_method (self, OVSDB_DEL_INTERFACE, ifname,
|
|
|
871508 |
- NULL, NULL, NULL, _transact_cb, call);
|
|
|
871508 |
+ NULL, NULL, NULL, NULL, NULL, _transact_cb, call);
|
|
|
871508 |
}
|
|
|
871508 |
|
|
|
871508 |
/*****************************************************************************/
|
|
|
871508 |
@@ -1466,6 +1520,8 @@ _clear_call (gpointer data)
|
|
|
871508 |
g_clear_object (&call->bridge);
|
|
|
871508 |
g_clear_object (&call->port);
|
|
|
871508 |
g_clear_object (&call->interface);
|
|
|
871508 |
+ g_clear_object (&call->bridge_device);
|
|
|
871508 |
+ g_clear_object (&call->interface_device);
|
|
|
871508 |
break;
|
|
|
871508 |
case OVSDB_DEL_INTERFACE:
|
|
|
871508 |
g_clear_pointer (&call->ifname, g_free);
|
|
|
871508 |
diff --git a/src/devices/ovs/nm-ovsdb.h b/src/devices/ovs/nm-ovsdb.h
|
|
|
871508 |
index cf9fe2a21..f9dbabbb7 100644
|
|
|
871508 |
--- a/src/devices/ovs/nm-ovsdb.h
|
|
|
871508 |
+++ b/src/devices/ovs/nm-ovsdb.h
|
|
|
871508 |
@@ -42,6 +42,7 @@ GType nm_ovsdb_get_type (void);
|
|
|
871508 |
|
|
|
871508 |
void nm_ovsdb_add_interface (NMOvsdb *self,
|
|
|
871508 |
NMConnection *bridge, NMConnection *port, NMConnection *interface,
|
|
|
871508 |
+ NMDevice *bridge_device, NMDevice *interface_device,
|
|
|
871508 |
NMOvsdbCallback callback, gpointer user_data);
|
|
|
871508 |
|
|
|
871508 |
void nm_ovsdb_del_interface (NMOvsdb *self, const char *ifname,
|
|
|
871508 |
--
|
|
|
871508 |
2.21.0
|
|
|
871508 |
|