73 lines
2.4 KiB
Diff
73 lines
2.4 KiB
Diff
From 74ec0f7dc18939dd4a5992584527ab044b284fc0 Mon Sep 17 00:00:00 2001
|
|
From: Beniamino Galvani <bgalvani@redhat.com>
|
|
Date: Wed, 10 Jan 2024 09:31:48 +0100
|
|
Subject: [PATCH 3/5] service: don't send IPv4 config if mode config client is
|
|
disabled
|
|
|
|
If the mode config client is disabled (i.e. in server-to-server
|
|
scenario) we are not going to receive a dynamic IP. The IP address
|
|
already configured on the existing interface is enough.
|
|
---
|
|
src/nm-libreswan-service.c | 20 +++++++++++++++++++-
|
|
1 file changed, 19 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/src/nm-libreswan-service.c b/src/nm-libreswan-service.c
|
|
index 2aca78f..12cf6f2 100644
|
|
--- a/src/nm-libreswan-service.c
|
|
+++ b/src/nm-libreswan-service.c
|
|
@@ -1253,6 +1253,7 @@ handle_callback (NMDBusLibreswanHelper *object,
|
|
gpointer user_data)
|
|
{
|
|
NMLibreswanPluginPrivate *priv = NM_LIBRESWAN_PLUGIN_GET_PRIVATE (user_data);
|
|
+ NMSettingVpn *s_vpn;
|
|
GVariantBuilder config;
|
|
GVariantBuilder builder;
|
|
GVariant *val;
|
|
@@ -1260,7 +1261,9 @@ handle_callback (NMDBusLibreswanHelper *object,
|
|
guint i;
|
|
const char *verb;
|
|
const char *virt_if;
|
|
+ const char *str;
|
|
gboolean is_xfrmi = FALSE;
|
|
+ gboolean has_ip4;
|
|
|
|
_LOGI ("Configuration from the helper received.");
|
|
|
|
@@ -1273,10 +1276,21 @@ handle_callback (NMDBusLibreswanHelper *object,
|
|
/* First build and send the generic config */
|
|
g_variant_builder_init (&config, G_VARIANT_TYPE_VARDICT);
|
|
|
|
+ if ( priv->connection
|
|
+ && (s_vpn = nm_connection_get_setting_vpn (priv->connection))
|
|
+ && (str = nm_setting_vpn_get_data_item (s_vpn, NM_LIBRESWAN_KEY_LEFTMODECFGCLIENT))
|
|
+ && nm_streq (str, "no")) {
|
|
+ has_ip4 = FALSE;
|
|
+ } else {
|
|
+ has_ip4 = TRUE;
|
|
+ }
|
|
+
|
|
+ _LOGD ("Configuration has IPv4: %d", has_ip4);
|
|
+
|
|
/*
|
|
* Enabled address families
|
|
*/
|
|
- g_variant_builder_add (&config, "{sv}", NM_VPN_PLUGIN_CONFIG_HAS_IP4, g_variant_new_boolean (TRUE));
|
|
+ g_variant_builder_add (&config, "{sv}", NM_VPN_PLUGIN_CONFIG_HAS_IP4, g_variant_new_boolean (has_ip4));
|
|
g_variant_builder_add (&config, "{sv}", NM_VPN_PLUGIN_CONFIG_HAS_IP6, g_variant_new_boolean (FALSE));
|
|
|
|
/*
|
|
@@ -1306,6 +1320,10 @@ handle_callback (NMDBusLibreswanHelper *object,
|
|
|
|
nm_vpn_service_plugin_set_config (NM_VPN_SERVICE_PLUGIN (user_data),
|
|
g_variant_builder_end (&config));
|
|
+ if (!has_ip4) {
|
|
+ success = TRUE;
|
|
+ goto out;
|
|
+ }
|
|
|
|
/* Then build and send the IPv4 config */
|
|
g_variant_builder_init (&config, G_VARIANT_TYPE_VARDICT);
|
|
--
|
|
2.43.0
|
|
|