summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2017-07-11 20:57:00 +0200
committerLubomir Rintel <lkundrak@v3.sk>2017-07-11 21:59:21 +0200
commitaa7f8915dd2bdc7d2384fdbe07368a4a1e0dcb99 (patch)
tree6bc9f304cf363aeccd590bc26e730170497d6e92
parent3cc51e4fa867d9a0ba40c806e4a1f3bad3a78c0e (diff)
downloadNetworkManager-lr/connectivity-per-af.tar.gz
dispatcher: indicate the connectivity state per device and AFlr/connectivity-per-af
-rw-r--r--dispatcher/nm-dispatcher-utils.c6
-rw-r--r--dispatcher/nm-dispatcher-utils.h2
-rw-r--r--dispatcher/nm-dispatcher.c6
-rw-r--r--dispatcher/nm-dispatcher.xml6
-rw-r--r--dispatcher/tests/dispatcher-connectivity-full2
-rw-r--r--dispatcher/tests/test-dispatcher-envp.c6
-rw-r--r--man/NetworkManager.xml30
-rw-r--r--src/nm-dispatcher.c76
-rw-r--r--src/nm-dispatcher.h4
-rw-r--r--src/nm-manager.c5
10 files changed, 94 insertions, 49 deletions
diff --git a/dispatcher/nm-dispatcher-utils.c b/dispatcher/nm-dispatcher-utils.c
index 64a4b9ef6c..812c379712 100644
--- a/dispatcher/nm-dispatcher-utils.c
+++ b/dispatcher/nm-dispatcher-utils.c
@@ -368,6 +368,8 @@ nm_dispatcher_utils_construct_envp (const char *action,
GVariant *device_ip6_props,
GVariant *device_dhcp4_props,
GVariant *device_dhcp6_props,
+ const char *connectivity_state4,
+ const char *connectivity_state6,
const char *connectivity_state,
const char *vpn_ip_iface,
GVariant *vpn_proxy_props,
@@ -515,6 +517,10 @@ nm_dispatcher_utils_construct_envp (const char *action,
/* The connectivity_state value will only be meaningful for 'connectivity-change' events
* (otherwise it will be "UNKNOWN"), so we only set the environment variable in those cases.
*/
+ if (connectivity_state4 && strcmp(connectivity_state4, "UNKNOWN"))
+ items = g_slist_prepend (items, g_strdup_printf ("IP4_CONNECTIVITY_STATE=%s", connectivity_state));
+ if (connectivity_state6 && strcmp(connectivity_state6, "UNKNOWN"))
+ items = g_slist_prepend (items, g_strdup_printf ("IP6_CONNECTIVITY_STATE=%s", connectivity_state));
if (connectivity_state && strcmp(connectivity_state, "UNKNOWN"))
items = g_slist_prepend (items, g_strdup_printf ("CONNECTIVITY_STATE=%s", connectivity_state));
diff --git a/dispatcher/nm-dispatcher-utils.h b/dispatcher/nm-dispatcher-utils.h
index a603432668..ab775ebd7c 100644
--- a/dispatcher/nm-dispatcher-utils.h
+++ b/dispatcher/nm-dispatcher-utils.h
@@ -31,6 +31,8 @@ nm_dispatcher_utils_construct_envp (const char *action,
GVariant *device_ip6_props,
GVariant *device_dhcp4_props,
GVariant *device_dhcp6_props,
+ const char *connectivity_state4,
+ const char *connectivity_state6,
const char *connectivity_state,
const char *vpn_ip_iface,
GVariant *vpn_proxy_props,
diff --git a/dispatcher/nm-dispatcher.c b/dispatcher/nm-dispatcher.c
index 6bb5221858..611168d03b 100644
--- a/dispatcher/nm-dispatcher.c
+++ b/dispatcher/nm-dispatcher.c
@@ -81,6 +81,8 @@ handle_action (NMDBusDispatcher *dbus_dispatcher,
GVariant *device_ip6_props,
GVariant *device_dhcp4_props,
GVariant *device_dhcp6_props,
+ const char *connectivity_state4,
+ const char *connectivity_state6,
const char *connectivity_state,
const char *vpn_ip_iface,
GVariant *vpn_proxy_props,
@@ -672,6 +674,8 @@ handle_action (NMDBusDispatcher *dbus_dispatcher,
GVariant *device_ip6_props,
GVariant *device_dhcp4_props,
GVariant *device_dhcp6_props,
+ const char *connectivity_state4,
+ const char *connectivity_state6,
const char *connectivity_state,
const char *vpn_ip_iface,
GVariant *vpn_proxy_props,
@@ -706,6 +710,8 @@ handle_action (NMDBusDispatcher *dbus_dispatcher,
device_ip6_props,
device_dhcp4_props,
device_dhcp6_props,
+ connectivity_state4,
+ connectivity_state6,
connectivity_state,
vpn_ip_iface,
vpn_proxy_props,
diff --git a/dispatcher/nm-dispatcher.xml b/dispatcher/nm-dispatcher.xml
index 0d9d28e2c2..3acae41023 100644
--- a/dispatcher/nm-dispatcher.xml
+++ b/dispatcher/nm-dispatcher.xml
@@ -14,7 +14,9 @@
@device_ip6_config: Properties of the device's IPv6 configuration.
@device_dhcp4_config: Properties of the device's DHCPv4 configuration.
@device_dhcp6_config: Properties of the device's DHCPv6 configuration.
- @connectivity_state: Current connectivity state: unknown, none, limited, portal or full.
+ @connectivity_state4: Result of the last connectivity state check using IPv4.
+ @connectivity_state6: Result of the last connectivity state check using IPv6.
+ @connectivity_state: Overall connectivity state: unknown, none, limited, portal or full.
@vpn_ip_iface: VPN interface name.
@vpn_proxy_properties: Properties of the VPN's proxy configuration.
@vpn_ip4_config: Properties of the VPN's IPv4 configuration.
@@ -34,6 +36,8 @@
<arg name="device_ip6_config" type="a{sv}" direction="in"/>
<arg name="device_dhcp4_config" type="a{sv}" direction="in"/>
<arg name="device_dhcp6_config" type="a{sv}" direction="in"/>
+ <arg name="connectivity_state4" type="s" direction="in"/>
+ <arg name="connectivity_state6" type="s" direction="in"/>
<arg name="connectivity_state" type="s" direction="in"/>
<arg name="vpn_ip_iface" type="s" direction="in"/>
<arg name="vpn_proxy_properties" type="a{sv}" direction="in"/>
diff --git a/dispatcher/tests/dispatcher-connectivity-full b/dispatcher/tests/dispatcher-connectivity-full
index 0b2796d12d..5872162ad1 100644
--- a/dispatcher/tests/dispatcher-connectivity-full
+++ b/dispatcher/tests/dispatcher-connectivity-full
@@ -20,4 +20,6 @@ CONNECTION_ID=Random Connection
CONNECTION_FILENAME=/dispatcher/tests/dispatcher-connectivity-full
DEVICE_IFACE=wlan0
DEVICE_IP_IFACE=wlan0
+IP4_CONNECTIVITY_STATE=FULL
+IP6_CONNECTIVITY_STATE=FULL
CONNECTIVITY_STATE=FULL
diff --git a/dispatcher/tests/test-dispatcher-envp.c b/dispatcher/tests/test-dispatcher-envp.c
index 6dd4db07b2..b479badc8a 100644
--- a/dispatcher/tests/test-dispatcher-envp.c
+++ b/dispatcher/tests/test-dispatcher-envp.c
@@ -493,7 +493,7 @@ test_generic (const char *file, const char *override_vpn_ip_iface)
gs_unref_variant GVariant *device_ip6_props = NULL;
gs_unref_variant GVariant *device_dhcp4_props = NULL;
gs_unref_variant GVariant *device_dhcp6_props = NULL;
- gs_free char *connectivity_change = NULL;
+ gs_free char *connectivity_state = NULL;
gs_free char *vpn_ip_iface = NULL;
gs_unref_variant GVariant *vpn_proxy_props = NULL;
gs_unref_variant GVariant *vpn_ip4_props = NULL;
@@ -520,7 +520,7 @@ test_generic (const char *file, const char *override_vpn_ip_iface)
&device_ip6_props,
&device_dhcp4_props,
&device_dhcp6_props,
- &connectivity_change,
+ &connectivity_state,
&vpn_ip_iface,
&vpn_proxy_props,
&vpn_ip4_props,
@@ -543,7 +543,7 @@ test_generic (const char *file, const char *override_vpn_ip_iface)
device_ip6_props,
device_dhcp4_props,
device_dhcp6_props,
- connectivity_change,
+ connectivity_state, connectivity_state, connectivity_state,
override_vpn_ip_iface ? override_vpn_ip_iface : vpn_ip_iface,
vpn_proxy_props,
vpn_ip4_props,
diff --git a/man/NetworkManager.xml b/man/NetworkManager.xml
index 86d8a3a369..faf8787e43 100644
--- a/man/NetworkManager.xml
+++ b/man/NetworkManager.xml
@@ -9,7 +9,7 @@
<!--
NetworkManager(8) manual page
- Copyright 2005 - 2016 Red Hat, Inc.
+ Copyright 2005 - 2017 Red Hat, Inc.
Copyright 2005 - 2009 Novell, Inc.
Copyright 2005 Robert Love
@@ -230,6 +230,25 @@
</para></listitem>
</varlistentry>
<varlistentry>
+ <term><varname>CONNECTIVITY_STATE</varname></term>
+ <listitem><para>The network connectivity state, which can
+ take the values defined by the NMConnectivityState type,
+ from the org.freedesktop.NetworkManager D-Bus API: unknown,
+ none, portal, limited or full. Note: this variable will only
+ be set for connectivity-change actions.
+ </para></listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><varname>IP4_CONNECTIVITY_STATE</varname></term>
+ <listitem><para>Reult of the last connectivity check using IPv4.
+ See <varname>CONNECTIVITY_STATE</varname> for details.
+ </para>
+ <para>For connectivity-change actions this variable will indicate the
+ state of overall connectivity (all devices considered), otherwise it's
+ relevant to the device specified by <varname>DEVICE_IFACE</varname>.
+ </para></listitem>
+ </varlistentry>
+ <varlistentry>
<term><varname>IP4_ADDRESS_N</varname></term>
<listitem><para>
The IPv4 address in the format "address/prefix gateway", where N is a number
@@ -290,15 +309,6 @@
<varname>IP6_</varname> and <varname>DHCP6_</varname> instead.
</para></listitem>
</varlistentry>
- <varlistentry>
- <term><varname>CONNECTIVITY_STATE</varname></term>
- <listitem><para> The network connectivity state, which can
- take the values defined by the NMConnectivityState type,
- from the org.freedesktop.NetworkManager D-Bus API: unknown,
- none, portal, limited or full. Note: this variable will only
- be set for connectivity-change actions.
- </para></listitem>
- </varlistentry>
</variablelist>
</para>
<para>
diff --git a/src/nm-dispatcher.c b/src/nm-dispatcher.c
index 2393e8035f..3b56c908c0 100644
--- a/src/nm-dispatcher.c
+++ b/src/nm-dispatcher.c
@@ -480,6 +480,8 @@ _dispatcher_call (NMDispatcherAction action,
NMSettingsConnection *settings_connection,
NMConnection *applied_connection,
gboolean activation_type_external,
+ NMConnectivityState connectivity_state4,
+ NMConnectivityState connectivity_state6,
NMConnectivityState connectivity_state,
const char *vpn_iface,
NMProxyConfig *vpn_proxy_config,
@@ -505,7 +507,10 @@ _dispatcher_call (NMDispatcherAction action,
GError *error = NULL;
static guint request_counter = 0;
guint reqid = ++request_counter;
+ const char *connectivity_state4_string = "UNKNOWN";
+ const char *connectivity_state6_string = "UNKNOWN";
const char *connectivity_state_string = "UNKNOWN";
+ GVariant *action_argument;
if (!dispatcher_proxy)
return FALSE;
@@ -617,30 +622,36 @@ _dispatcher_call (NMDispatcherAction action,
#if WITH_CONCHECK
connectivity_state_string = nm_connectivity_state_to_string (connectivity_state);
+ connectivity_state4_string = nm_connectivity_state_to_string (connectivity_state4);
+ connectivity_state6_string = nm_connectivity_state_to_string (connectivity_state6);
#endif
+ action_argument = g_variant_new ("(s@a{sa{sv}}a{sv}a{sv}a{sv}a{sv}a{sv}@a{sv}@a{sv}ssssa{sv}a{sv}a{sv}b)",
+ action_to_string (action),
+ connection_dict,
+ &connection_props,
+ &device_props,
+ &device_proxy_props,
+ &device_ip4_props,
+ &device_ip6_props,
+ device_dhcp4_props,
+ device_dhcp6_props,
+ connectivity_state4_string,
+ connectivity_state6_string,
+ connectivity_state_string,
+ vpn_iface ? vpn_iface : "",
+ &vpn_proxy_props,
+ &vpn_ip4_props,
+ &vpn_ip6_props,
+ nm_logging_enabled (LOGL_DEBUG, LOGD_DISPATCH));
+
/* Send the action to the dispatcher */
if (blocking) {
GVariant *ret;
GVariantIter *results;
ret = _nm_dbus_proxy_call_sync (dispatcher_proxy, "Action",
- g_variant_new ("(s@a{sa{sv}}a{sv}a{sv}a{sv}a{sv}a{sv}@a{sv}@a{sv}ssa{sv}a{sv}a{sv}b)",
- action_to_string (action),
- connection_dict,
- &connection_props,
- &device_props,
- &device_proxy_props,
- &device_ip4_props,
- &device_ip6_props,
- device_dhcp4_props,
- device_dhcp6_props,
- connectivity_state_string,
- vpn_iface ? vpn_iface : "",
- &vpn_proxy_props,
- &vpn_ip4_props,
- &vpn_ip6_props,
- nm_logging_enabled (LOGL_DEBUG, LOGD_DISPATCH)),
+ action_argument,
G_VARIANT_TYPE ("(a(sus))"),
G_DBUS_CALL_FLAGS_NONE, CALL_TIMEOUT,
NULL, &error);
@@ -663,22 +674,7 @@ _dispatcher_call (NMDispatcherAction action,
info->callback = callback;
info->user_data = user_data;
g_dbus_proxy_call (dispatcher_proxy, "Action",
- g_variant_new ("(s@a{sa{sv}}a{sv}a{sv}a{sv}a{sv}a{sv}@a{sv}@a{sv}ssa{sv}a{sv}a{sv}b)",
- action_to_string (action),
- connection_dict,
- &connection_props,
- &device_props,
- &device_proxy_props,
- &device_ip4_props,
- &device_ip6_props,
- device_dhcp4_props,
- device_dhcp6_props,
- connectivity_state_string,
- vpn_iface ? vpn_iface : "",
- &vpn_proxy_props,
- &vpn_ip4_props,
- &vpn_ip6_props,
- nm_logging_enabled (LOGL_DEBUG, LOGD_DISPATCH)),
+ action_argument,
G_DBUS_CALL_FLAGS_NONE, CALL_TIMEOUT,
NULL, dispatcher_done_cb, info);
success = TRUE;
@@ -718,6 +714,8 @@ nm_dispatcher_call_hostname (NMDispatcherFunc callback,
return _dispatcher_call (NM_DISPATCHER_ACTION_HOSTNAME, FALSE,
NULL, NULL, NULL, FALSE,
NM_CONNECTIVITY_UNKNOWN,
+ NM_CONNECTIVITY_UNKNOWN,
+ NM_CONNECTIVITY_UNKNOWN,
NULL, NULL, NULL, NULL,
callback, user_data, out_call_id);
}
@@ -758,6 +756,8 @@ nm_dispatcher_call_device (NMDispatcherAction action,
nm_act_request_get_settings_connection (act_request),
nm_act_request_get_applied_connection (act_request),
nm_active_connection_get_activation_type (NM_ACTIVE_CONNECTION (act_request)) == NM_ACTIVATION_TYPE_EXTERNAL,
+ nm_device_get_ip4_connectivity_state (device),
+ nm_device_get_ip6_connectivity_state (device),
NM_CONNECTIVITY_UNKNOWN,
NULL, NULL, NULL, NULL,
callback, user_data, out_call_id);
@@ -793,6 +793,8 @@ nm_dispatcher_call_device_sync (NMDispatcherAction action,
nm_act_request_get_applied_connection (act_request),
nm_active_connection_get_activation_type (NM_ACTIVE_CONNECTION (act_request)) == NM_ACTIVATION_TYPE_EXTERNAL,
NM_CONNECTIVITY_UNKNOWN,
+ NM_CONNECTIVITY_UNKNOWN,
+ NM_CONNECTIVITY_UNKNOWN,
NULL, NULL, NULL, NULL,
NULL, NULL, NULL);
}
@@ -836,6 +838,8 @@ nm_dispatcher_call_vpn (NMDispatcherAction action,
applied_connection,
FALSE,
NM_CONNECTIVITY_UNKNOWN,
+ NM_CONNECTIVITY_UNKNOWN,
+ NM_CONNECTIVITY_UNKNOWN,
vpn_iface, vpn_proxy_config, vpn_ip4_config, vpn_ip6_config,
callback, user_data, out_call_id);
}
@@ -872,6 +876,8 @@ nm_dispatcher_call_vpn_sync (NMDispatcherAction action,
applied_connection,
FALSE,
NM_CONNECTIVITY_UNKNOWN,
+ NM_CONNECTIVITY_UNKNOWN,
+ NM_CONNECTIVITY_UNKNOWN,
vpn_iface, vpn_proxy_config, vpn_ip4_config, vpn_ip6_config,
NULL, NULL, NULL);
}
@@ -889,13 +895,17 @@ nm_dispatcher_call_vpn_sync (NMDispatcherAction action,
* Returns: %TRUE if the action was dispatched, %FALSE on failure
*/
gboolean
-nm_dispatcher_call_connectivity (NMConnectivityState connectivity_state,
+nm_dispatcher_call_connectivity (NMConnectivityState connectivity_state4,
+ NMConnectivityState connectivity_state6,
+ NMConnectivityState connectivity_state,
NMDispatcherFunc callback,
gpointer user_data,
guint *out_call_id)
{
return _dispatcher_call (NM_DISPATCHER_ACTION_CONNECTIVITY_CHANGE, FALSE,
NULL, NULL, NULL, FALSE,
+ connectivity_state4,
+ connectivity_state6,
connectivity_state,
NULL, NULL, NULL, NULL,
callback, user_data, out_call_id);
diff --git a/src/nm-dispatcher.h b/src/nm-dispatcher.h
index 4448e8173f..ce253926c0 100644
--- a/src/nm-dispatcher.h
+++ b/src/nm-dispatcher.h
@@ -77,7 +77,9 @@ gboolean nm_dispatcher_call_vpn_sync (NMDispatcherAction action,
NMIP4Config *vpn_ip4_config,
NMIP6Config *vpn_ip6_config);
-gboolean nm_dispatcher_call_connectivity (NMConnectivityState state,
+gboolean nm_dispatcher_call_connectivity (NMConnectivityState state4,
+ NMConnectivityState state6,
+ NMConnectivityState state,
NMDispatcherFunc callback,
gpointer user_data,
guint *out_call_id);
diff --git a/src/nm-manager.c b/src/nm-manager.c
index fd56cd1488..1bb328414f 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -2060,7 +2060,10 @@ device_connectivity_changed (NMManager *self)
_notify (self, PROP_CONNECTIVITY);
nm_manager_update_state (self);
- nm_dispatcher_call_connectivity (priv->connectivity_state, NULL, NULL, NULL);
+ nm_dispatcher_call_connectivity (priv->connectivity_state4,
+ priv->connectivity_state6,
+ priv->connectivity_state,
+ NULL, NULL, NULL);
}
static void