NetworkManager/0001-upstream.patch

2758 lines
102 KiB
Diff

From e88bc2cee02b32d0ec6c05ea8a65b5b00a395f9e Mon Sep 17 00:00:00 2001
From: Thomas Haller <thaller@redhat.com>
Date: Thu, 8 Dec 2016 13:24:42 +0100
Subject: [PATCH 01/19] device: fix activation_source_schedule() for
rescheduling the same function
Fixes: 78ca961c0fd0e5b563e33306299bd1058fa2e289
(cherry picked from commit 994f1ca96ea7d675b61006f8199a003354e8d12a)
(cherry picked from commit baac746abbcc8170022cafaf34798f1e946e947b)
(cherry picked from commit 5d5367462d16869790c2110f6b623c182069f843)
---
src/devices/nm-device.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 03fc31c..f88e99f 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -3441,7 +3441,7 @@ activation_source_schedule (NMDevice *self, ActivationHandleFunc func, int famil
act_data = activation_source_get_by_family (self, family, &source_func);
- if (act_data->id && act_data->func != func) {
+ if (act_data->id && act_data->func == func) {
/* Don't bother rescheduling the same function that's about to
* run anyway. Fixes issues with crappy wireless drivers sending
* streams of associate events before NM has had a chance to process
--
2.9.3
From 4216fb76017f348fa8a98ded445eab8e9c2a980f Mon Sep 17 00:00:00 2001
From: Thomas Haller <thaller@redhat.com>
Date: Thu, 16 Jun 2016 18:06:16 +0200
Subject: [PATCH 02/19] shared: add also
"shared/nm-utils/nm-vpn-plugin-macros.h"
It has the very similar purpose as "nm-utils/nm-vpn-plugin-utils.[ch]", except
that is is header-only.
(cherry picked from commit af507cd0893f8140a5c62a176ba70f12b642a0fa)
(cherry picked from commit 11b667bdc21ee6b045cd624b7d6f44e58b478ed6)
---
shared/Makefile.am | 3 ++-
shared/nm-vpn-plugin-macros.h | 43 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 45 insertions(+), 1 deletion(-)
create mode 100644 shared/nm-vpn-plugin-macros.h
diff --git a/shared/Makefile.am b/shared/Makefile.am
index c6ede00..097f8bc 100644
--- a/shared/Makefile.am
+++ b/shared/Makefile.am
@@ -10,6 +10,7 @@ EXTRA_DIST = \
nm-test-libnm-utils.h \
nm-test-utils.h \
nm-test-utils-impl.c \
- nm-version-macros.h.in
+ nm-version-macros.h.in \
+ nm-vpn-plugin-macros.h
CLEANFILES=nm-version.h
diff --git a/shared/nm-vpn-plugin-macros.h b/shared/nm-vpn-plugin-macros.h
new file mode 100644
index 0000000..d685934
--- /dev/null
+++ b/shared/nm-vpn-plugin-macros.h
@@ -0,0 +1,43 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+
+/*
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA.
+ *
+ * Copyright 2016 Red Hat, Inc.
+ */
+
+#ifndef __NM_VPN_PLUGIN_MACROS_H__
+#define __NM_VPN_PLUGIN_MACROS_H__
+
+#include <syslog.h>
+
+static inline const char *
+nm_utils_syslog_to_str (int syslog_level)
+{
+ /* Maps the levels the same way as NetworkManager's nm-logging.c does */
+ if (syslog_level >= LOG_DEBUG)
+ return "<trace>";
+ if (syslog_level >= LOG_INFO)
+ return "<debug>";
+ if (syslog_level >= LOG_NOTICE)
+ return "<info>";
+ if (syslog_level >= LOG_WARNING)
+ return "<warn>";
+ return "<error>";
+}
+
+#endif /* __NM_VPN_PLUGIN_MACROS_H__ */
+
--
2.9.3
From fc9e5e3febab8de68b4880d628de103f4d67a0c9 Mon Sep 17 00:00:00 2001
From: Thomas Haller <thaller@redhat.com>
Date: Sun, 10 Jul 2016 12:34:34 +0200
Subject: [PATCH 03/19] dhcp: prefix logging messages with "dhcp"
(cherry picked from commit 1c58ce0d748174b5b3a27dd077192b45fed2d0a4)
(cherry picked from commit 58c6c12f471137dbba5292d5436188bb76bda650)
---
src/dhcp-manager/nm-dhcp-client-logging.h | 23 ++++++
src/dhcp-manager/nm-dhcp-client.c | 33 ++++----
src/dhcp-manager/nm-dhcp-listener.c | 10 +--
src/dhcp-manager/nm-dhcp-manager.c | 10 +--
src/dhcp-manager/nm-dhcp-systemd.c | 2 +-
src/dhcp-manager/nm-dhcp-utils.c | 126 ++++++++++++++++--------------
6 files changed, 116 insertions(+), 88 deletions(-)
diff --git a/src/dhcp-manager/nm-dhcp-client-logging.h b/src/dhcp-manager/nm-dhcp-client-logging.h
index bb4f2f4..96b6358 100644
--- a/src/dhcp-manager/nm-dhcp-client-logging.h
+++ b/src/dhcp-manager/nm-dhcp-client-logging.h
@@ -52,4 +52,27 @@
} \
} G_STMT_END
+#define _NMLOG2(level, domain, ifname, ...) \
+ G_STMT_START { \
+ const NMLogLevel _level = (level); \
+ const NMLogDomain _domain = (domain); \
+ \
+ /* we check first for LOGD_DHCP instead of the correct domain.
+ * In the worst case, we guess wrong and enter the block.
+ *
+ * Same for the _NMLOG_ENABLED() macro. Probably it would be more
+ * expensive to determine the correct value then what we could
+ * safe. */ \
+ if (nm_logging_enabled (_level, _domain)) { \
+ const char *__ifname = (ifname); \
+ \
+ nm_log (_level, _domain, \
+ "%s%s%s%s%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
+ _NMLOG_PREFIX_NAME, \
+ (_domain == LOGD_DHCP4 ? "4" : (_domain == LOGD_DHCP6 ? "6" : "")), \
+ NM_PRINT_FMT_QUOTED (__ifname, " (", __ifname, ")", "") \
+ _NM_UTILS_MACRO_REST (__VA_ARGS__)); \
+ } \
+ } G_STMT_END
+
#endif /* __NETWORKMANAGER_DHCP_CLIENT_LOGGING_H__ */
diff --git a/src/dhcp-manager/nm-dhcp-client.c b/src/dhcp-manager/nm-dhcp-client.c
index c102581..1802df8 100644
--- a/src/dhcp-manager/nm-dhcp-client.c
+++ b/src/dhcp-manager/nm-dhcp-client.c
@@ -448,6 +448,7 @@ generate_duid_from_machine_id (void)
GRand *generator;
guint i;
gs_free char *machine_id_s = NULL;
+ gs_free char *str = NULL;
machine_id_s = nm_utils_machine_id_read ();
if (nm_utils_machine_id_parse (machine_id_s, uuid)) {
@@ -457,7 +458,7 @@ generate_duid_from_machine_id (void)
g_checksum_get_digest (sum, buffer, &sumlen);
g_checksum_free (sum);
} else {
- nm_log_warn (LOGD_DHCP6, "dhcp6: failed to read " SYSCONFDIR "/machine-id "
+ nm_log_warn (LOGD_DHCP, "dhcp: failed to read " SYSCONFDIR "/machine-id "
"or " LOCALSTATEDIR "/lib/dbus/machine-id to generate "
"DHCPv6 DUID; creating non-persistent random DUID.");
@@ -481,6 +482,8 @@ generate_duid_from_machine_id (void)
*/
g_byte_array_append (duid, buffer, 16);
+ nm_log_dbg (LOGD_DHCP, "dhcp: generated DUID %s",
+ (str = nm_dhcp_utils_duid_to_string (duid)));
return duid;
}
@@ -489,17 +492,12 @@ get_duid (NMDhcpClient *self)
{
static GByteArray *duid = NULL;
GByteArray *copy = NULL;
- char *str;
if (G_UNLIKELY (duid == NULL)) {
+ gs_free char *str = NULL;
+
duid = generate_duid_from_machine_id ();
g_assert (duid);
-
- if (nm_logging_enabled (LOGL_DEBUG, LOGD_DHCP6)) {
- str = nm_dhcp_utils_duid_to_string (duid);
- _LOGD ("generated DUID %s", str);
- g_free (str);
- }
}
if (G_LIKELY (duid)) {
@@ -519,7 +517,7 @@ nm_dhcp_client_start_ip6 (NMDhcpClient *self,
NMSettingIP6ConfigPrivacy privacy)
{
NMDhcpClientPrivate *priv;
- char *str;
+ gs_free char *str = NULL;
g_return_val_if_fail (NM_IS_DHCP_CLIENT (self), FALSE);
@@ -534,11 +532,7 @@ nm_dhcp_client_start_ip6 (NMDhcpClient *self,
if (!priv->duid)
priv->duid = NM_DHCP_CLIENT_GET_CLASS (self)->get_duid (self);
- if (nm_logging_enabled (LOGL_DEBUG, LOGD_DHCP6)) {
- str = nm_dhcp_utils_duid_to_string (priv->duid);
- _LOGD ("DUID is '%s'", str);
- g_free (str);
- }
+ _LOGD ("DUID is '%s'", (str = nm_dhcp_utils_duid_to_string (priv->duid)));
g_clear_pointer (&priv->hostname, g_free);
priv->hostname = g_strdup (hostname);
@@ -631,7 +625,7 @@ nm_dhcp_client_stop (NMDhcpClient *self, gboolean release)
/********************************************/
static char *
-bytearray_variant_to_string (GVariant *value, const char *key)
+bytearray_variant_to_string (NMDhcpClient *self, GVariant *value, const char *key)
{
const guint8 *array;
gsize length;
@@ -662,7 +656,7 @@ bytearray_variant_to_string (GVariant *value, const char *key)
converted = str->str;
if (!g_utf8_validate (converted, -1, NULL))
- nm_log_warn (LOGD_DHCP, "dhcp: option '%s' couldn't be converted to UTF-8", key);
+ _LOGW ("option '%s' couldn't be converted to UTF-8", key);
g_string_free (str, FALSE);
return converted;
}
@@ -671,7 +665,8 @@ bytearray_variant_to_string (GVariant *value, const char *key)
#define NEW_TAG "new_"
static void
-maybe_add_option (GHashTable *hash,
+maybe_add_option (NMDhcpClient *self,
+ GHashTable *hash,
const char *key,
GVariant *value)
{
@@ -701,7 +696,7 @@ maybe_add_option (GHashTable *hash,
if (!key[0])
return;
- str_value = bytearray_variant_to_string (value, key);
+ str_value = bytearray_variant_to_string (self, value, key);
if (str_value)
g_hash_table_insert (hash, g_strdup (key), str_value);
}
@@ -747,7 +742,7 @@ nm_dhcp_client_handle_event (gpointer unused,
str_options = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
g_variant_iter_init (&iter, options);
while (g_variant_iter_next (&iter, "{&sv}", &name, &value)) {
- maybe_add_option (str_options, name, value);
+ maybe_add_option (self, str_options, name, value);
g_variant_unref (value);
}
diff --git a/src/dhcp-manager/nm-dhcp-listener.c b/src/dhcp-manager/nm-dhcp-listener.c
index 595b209..eadff3e 100644
--- a/src/dhcp-manager/nm-dhcp-listener.c
+++ b/src/dhcp-manager/nm-dhcp-listener.c
@@ -111,20 +111,20 @@ handle_event (GDBusConnection *connection,
iface = get_option (options, "interface");
if (iface == NULL) {
- nm_log_warn (LOGD_DHCP, "DHCP event: didn't have associated interface.");
+ nm_log_warn (LOGD_DHCP, "dhcp-event: didn't have associated interface.");
goto out;
}
pid_str = get_option (options, "pid");
pid = _nm_utils_ascii_str_to_int64 (pid_str, 10, 0, G_MAXINT32, -1);
if (pid == -1) {
- nm_log_warn (LOGD_DHCP, "DHCP event: couldn't convert PID '%s' to an integer", pid_str ? pid_str : "(null)");
+ nm_log_warn (LOGD_DHCP, "dhcp-event: couldn't convert PID '%s' to an integer", pid_str ? pid_str : "(null)");
goto out;
}
reason = get_option (options, "reason");
if (reason == NULL) {
- nm_log_warn (LOGD_DHCP, "(pid %d) DHCP event didn't have a reason", pid);
+ nm_log_warn (LOGD_DHCP, "dhcp-event: (pid %d) DHCP event didn't have a reason", pid);
goto out;
}
@@ -132,9 +132,9 @@ handle_event (GDBusConnection *connection,
if (!handled) {
if (g_ascii_strcasecmp (reason, "RELEASE") == 0) {
/* Ignore event when the dhcp client gets killed and we receive its last message */
- nm_log_dbg (LOGD_DHCP, "(pid %d) unhandled RELEASE DHCP event for interface %s", pid, iface);
+ nm_log_dbg (LOGD_DHCP, "dhcp-event: (pid %d) unhandled RELEASE DHCP event for interface %s", pid, iface);
} else
- nm_log_warn (LOGD_DHCP, "(pid %d) unhandled DHCP event for interface %s", pid, iface);
+ nm_log_warn (LOGD_DHCP, "dhcp-event: (pid %d) unhandled DHCP event for interface %s", pid, iface);
}
out:
diff --git a/src/dhcp-manager/nm-dhcp-manager.c b/src/dhcp-manager/nm-dhcp-manager.c
index fe723e9..50469c5 100644
--- a/src/dhcp-manager/nm-dhcp-manager.c
+++ b/src/dhcp-manager/nm-dhcp-manager.c
@@ -372,7 +372,7 @@ nm_dhcp_manager_init (NMDhcpManager *self)
for (iter = client_descs; iter; iter = iter->next) {
ClientDesc *desc = iter->data;
- nm_log_dbg (LOGD_DHCP, "Registered DHCP client '%s' (%s)",
+ nm_log_dbg (LOGD_DHCP, "dhcp-init: Registered DHCP client '%s' (%s)",
desc->name, g_type_name (desc->gtype));
}
@@ -380,7 +380,7 @@ nm_dhcp_manager_init (NMDhcpManager *self)
client = nm_config_get_dhcp_client (config);
if (nm_config_get_configure_and_quit (config)) {
if (g_strcmp0 (client, "internal") != 0)
- nm_log_warn (LOGD_DHCP, "Using internal DHCP client since configure-and-quit is set.");
+ nm_log_warn (LOGD_DHCP, "dhcp-init: Using internal DHCP client since configure-and-quit is set.");
client = "internal";
}
@@ -389,7 +389,7 @@ nm_dhcp_manager_init (NMDhcpManager *self)
if (type == G_TYPE_INVALID) {
if (client)
- nm_log_warn (LOGD_DHCP, "DHCP client '%s' not available", client);
+ nm_log_warn (LOGD_DHCP, "dhcp-init: DHCP client '%s' not available", client);
type = is_client_enabled ("dhclient");
if (type == G_TYPE_INVALID)
@@ -399,9 +399,9 @@ nm_dhcp_manager_init (NMDhcpManager *self)
}
if (type == G_TYPE_INVALID)
- nm_log_warn (LOGD_DHCP, "No usable DHCP client found! DHCP configurations will fail");
+ nm_log_warn (LOGD_DHCP, "dhcp-init: No usable DHCP client found! DHCP configurations will fail");
else
- nm_log_info (LOGD_DHCP, "Using DHCP client '%s'", find_client_desc (NULL, type)->name);
+ nm_log_info (LOGD_DHCP, "dhcp-init: Using DHCP client '%s'", find_client_desc (NULL, type)->name);
priv->client_type = type;
priv->clients = g_hash_table_new_full (g_direct_hash, g_direct_equal,
diff --git a/src/dhcp-manager/nm-dhcp-systemd.c b/src/dhcp-manager/nm-dhcp-systemd.c
index 82cb335..73d6a0f 100644
--- a/src/dhcp-manager/nm-dhcp-systemd.c
+++ b/src/dhcp-manager/nm-dhcp-systemd.c
@@ -193,7 +193,7 @@ add_requests_to_options (GHashTable *options, const ReqOption *requests)
#define LOG_LEASE(domain, ...) \
G_STMT_START { \
if (log_lease) { \
- nm_log (LOGL_INFO, (domain), __VA_ARGS__); \
+ _LOG2I ((domain), (iface), __VA_ARGS__); \
} \
} G_STMT_END
diff --git a/src/dhcp-manager/nm-dhcp-utils.c b/src/dhcp-manager/nm-dhcp-utils.c
index a88a7e6..3807481 100644
--- a/src/dhcp-manager/nm-dhcp-utils.c
+++ b/src/dhcp-manager/nm-dhcp-utils.c
@@ -28,11 +28,13 @@
#include "nm-utils.h"
#include "NetworkManagerUtils.h"
#include "nm-platform.h"
+#include "nm-dhcp-client-logging.h"
/********************************************/
static gboolean
-ip4_process_dhcpcd_rfc3442_routes (const char *str,
+ip4_process_dhcpcd_rfc3442_routes (const char *iface,
+ const char *str,
guint32 priority,
NMIP4Config *ip4_config,
guint32 *gwaddr)
@@ -45,7 +47,7 @@ ip4_process_dhcpcd_rfc3442_routes (const char *str,
goto out;
if ((g_strv_length (routes) % 2) != 0) {
- nm_log_warn (LOGD_DHCP4, " classless static routes provided, but invalid");
+ _LOG2W (LOGD_DHCP4, iface, " classless static routes provided, but invalid");
goto out;
}
@@ -61,16 +63,16 @@ ip4_process_dhcpcd_rfc3442_routes (const char *str,
errno = 0;
rt_cidr = strtol (slash + 1, NULL, 10);
if (errno || rt_cidr > 32) {
- nm_log_warn (LOGD_DHCP4, "DHCP provided invalid classless static route cidr: '%s'", slash + 1);
+ _LOG2W (LOGD_DHCP4, iface, "DHCP provided invalid classless static route cidr: '%s'", slash + 1);
continue;
}
}
if (inet_pton (AF_INET, *r, &rt_addr) <= 0) {
- nm_log_warn (LOGD_DHCP4, "DHCP provided invalid classless static route address: '%s'", *r);
+ _LOG2W (LOGD_DHCP4, iface, "DHCP provided invalid classless static route address: '%s'", *r);
continue;
}
if (inet_pton (AF_INET, *(r + 1), &rt_route) <= 0) {
- nm_log_warn (LOGD_DHCP4, "DHCP provided invalid classless static route gateway: '%s'", *(r + 1));
+ _LOG2W (LOGD_DHCP4, iface, "DHCP provided invalid classless static route gateway: '%s'", *(r + 1));
continue;
}
@@ -79,7 +81,7 @@ ip4_process_dhcpcd_rfc3442_routes (const char *str,
/* FIXME: how to handle multiple routers? */
*gwaddr = rt_route;
} else {
- nm_log_info (LOGD_DHCP4, " classless static route %s/%d gw %s", *r, rt_cidr, *(r + 1));
+ _LOG2I (LOGD_DHCP4, iface, " classless static route %s/%d gw %s", *r, rt_cidr, *(r + 1));
memset (&route, 0, sizeof (route));
route.network = rt_addr;
route.plen = rt_cidr;
@@ -160,7 +162,8 @@ error:
}
static gboolean
-ip4_process_dhclient_rfc3442_routes (const char *str,
+ip4_process_dhclient_rfc3442_routes (const char *iface,
+ const char *str,
guint32 priority,
NMIP4Config *ip4_config,
guint32 *gwaddr)
@@ -172,7 +175,7 @@ ip4_process_dhclient_rfc3442_routes (const char *str,
o = octets = g_strsplit_set (str, " .", 0);
if (g_strv_length (octets) < 5) {
- nm_log_warn (LOGD_DHCP4, "ignoring invalid classless static routes '%s'", str);
+ _LOG2W (LOGD_DHCP4, iface, "ignoring invalid classless static routes '%s'", str);
goto out;
}
@@ -180,7 +183,7 @@ ip4_process_dhclient_rfc3442_routes (const char *str,
memset (&route, 0, sizeof (route));
o = (char **) process_dhclient_rfc3442_route ((const char **) o, &route, &success);
if (!success) {
- nm_log_warn (LOGD_DHCP4, "ignoring invalid classless static routes");
+ _LOG2W (LOGD_DHCP4, iface, "ignoring invalid classless static routes");
break;
}
@@ -196,9 +199,9 @@ ip4_process_dhclient_rfc3442_routes (const char *str,
route.metric = priority;
nm_ip4_config_add_route (ip4_config, &route);
- nm_log_info (LOGD_DHCP4, " classless static route %s/%d gw %s",
- nm_utils_inet4_ntop (route.network, addr), route.plen,
- nm_utils_inet4_ntop (route.gateway, NULL));
+ _LOG2I (LOGD_DHCP4, iface, " classless static route %s/%d gw %s",
+ nm_utils_inet4_ntop (route.network, addr), route.plen,
+ nm_utils_inet4_ntop (route.gateway, NULL));
}
}
@@ -208,7 +211,8 @@ out:
}
static gboolean
-ip4_process_classless_routes (GHashTable *options,
+ip4_process_classless_routes (const char *iface,
+ GHashTable *options,
guint32 priority,
NMIP4Config *ip4_config,
guint32 *gwaddr)
@@ -257,7 +261,7 @@ ip4_process_classless_routes (GHashTable *options,
p = str;
while (*p) {
if (!g_ascii_isdigit (*p) && (*p != ' ') && (*p != '.') && (*p != '/')) {
- nm_log_warn (LOGD_DHCP4, "ignoring invalid classless static routes '%s'", str);
+ _LOG2W (LOGD_DHCP4, iface, "ignoring invalid classless static routes '%s'", str);
return FALSE;
}
p++;
@@ -265,14 +269,17 @@ ip4_process_classless_routes (GHashTable *options,
if (strchr (str, '/')) {
/* dhcpcd format */
- return ip4_process_dhcpcd_rfc3442_routes (str, priority, ip4_config, gwaddr);
+ return ip4_process_dhcpcd_rfc3442_routes (iface, str, priority, ip4_config, gwaddr);
}
- return ip4_process_dhclient_rfc3442_routes (str, priority, ip4_config, gwaddr);
+ return ip4_process_dhclient_rfc3442_routes (iface, str, priority, ip4_config, gwaddr);
}
static void
-process_classful_routes (GHashTable *options, guint32 priority, NMIP4Config *ip4_config)
+process_classful_routes (const char *iface,
+ GHashTable *options,
+ guint32 priority,
+ NMIP4Config *ip4_config)
{
const char *str;
char **searches, **s;
@@ -283,7 +290,7 @@ process_classful_routes (GHashTable *options, guint32 priority, NMIP4Config *ip4
searches = g_strsplit (str, " ", 0);
if ((g_strv_length (searches) % 2)) {
- nm_log_info (LOGD_DHCP, " static routes provided, but invalid");
+ _LOG2I (LOGD_DHCP, iface, " static routes provided, but invalid");
goto out;
}
@@ -292,11 +299,11 @@ process_classful_routes (GHashTable *options, guint32 priority, NMIP4Config *ip4
guint32 rt_addr, rt_route;
if (inet_pton (AF_INET, *s, &rt_addr) <= 0) {
- nm_log_warn (LOGD_DHCP, "DHCP provided invalid static route address: '%s'", *s);
+ _LOG2W (LOGD_DHCP, iface, "DHCP provided invalid static route address: '%s'", *s);
continue;
}
if (inet_pton (AF_INET, *(s + 1), &rt_route) <= 0) {
- nm_log_warn (LOGD_DHCP, "DHCP provided invalid static route gateway: '%s'", *(s + 1));
+ _LOG2W (LOGD_DHCP, iface, "DHCP provided invalid static route gateway: '%s'", *(s + 1));
continue;
}
@@ -318,7 +325,7 @@ process_classful_routes (GHashTable *options, guint32 priority, NMIP4Config *ip4
route.metric = priority;
nm_ip4_config_add_route (ip4_config, &route);
- nm_log_info (LOGD_DHCP, " static route %s",
+ _LOG2I (LOGD_DHCP, iface, " static route %s",
nm_platform_ip4_route_to_string (&route, NULL, 0));
}
@@ -327,7 +334,10 @@ out:
}
static void
-process_domain_search (const char *str, GFunc add_func, gpointer user_data)
+process_domain_search (const char *iface,
+ const char *str,
+ GFunc add_func,
+ gpointer user_data)
{
char **searches, **s;
char *unescaped, *p;
@@ -348,14 +358,14 @@ process_domain_search (const char *str, GFunc add_func, gpointer user_data)
} while (*p++);
if (strchr (unescaped, '\\')) {
- nm_log_warn (LOGD_DHCP, " invalid domain search: '%s'", unescaped);
+ _LOG2W (LOGD_DHCP, iface, " invalid domain search: '%s'", unescaped);
goto out;
}
searches = g_strsplit (unescaped, " ", 0);
for (s = searches; *s; s++) {
if (strlen (*s)) {
- nm_log_info (LOGD_DHCP, " domain search '%s'", *s);
+ _LOG2I (LOGD_DHCP, iface, " domain search '%s'", *s);
add_func (*s, user_data);
}
}
@@ -393,29 +403,29 @@ nm_dhcp_utils_ip4_config_from_options (int ifindex,
str = g_hash_table_lookup (options, "ip_address");
if (str && (inet_pton (AF_INET, str, &addr) > 0))
- nm_log_info (LOGD_DHCP4, " address %s", str);
+ _LOG2I (LOGD_DHCP4, iface, " address %s", str);
else
goto error;
str = g_hash_table_lookup (options, "subnet_mask");
if (str && (inet_pton (AF_INET, str, &tmp_addr) > 0)) {
plen = nm_utils_ip4_netmask_to_prefix (tmp_addr);
- nm_log_info (LOGD_DHCP4, " plen %d (%s)", plen, str);
+ _LOG2I (LOGD_DHCP4, iface, " plen %d (%s)", plen, str);
} else {
/* Get default netmask for the IP according to appropriate class. */
plen = nm_utils_ip4_get_default_prefix (addr);
- nm_log_info (LOGD_DHCP4, " plen %d (default)", plen);
+ _LOG2I (LOGD_DHCP4, iface, " plen %d (default)", plen);
}
nm_platform_ip4_address_set_addr (&address, addr, plen);
/* Routes: if the server returns classless static routes, we MUST ignore
* the 'static_routes' option.
*/
- if (!ip4_process_classless_routes (options, priority, ip4_config, &gwaddr))
- process_classful_routes (options, priority, ip4_config);
+ if (!ip4_process_classless_routes (iface, options, priority, ip4_config, &gwaddr))
+ process_classful_routes (iface, options, priority, ip4_config);
if (gwaddr) {
- nm_log_info (LOGD_DHCP4, " gateway %s", nm_utils_inet4_ntop (gwaddr, NULL));
+ _LOG2I (LOGD_DHCP4, iface, " gateway %s", nm_utils_inet4_ntop (gwaddr, NULL));
nm_ip4_config_set_gateway (ip4_config, gwaddr);
} else {
/* If the gateway wasn't provided as a classless static route with a
@@ -430,10 +440,10 @@ nm_dhcp_utils_ip4_config_from_options (int ifindex,
/* FIXME: how to handle multiple routers? */
if (inet_pton (AF_INET, *s, &gwaddr) > 0) {
nm_ip4_config_set_gateway (ip4_config, gwaddr);
- nm_log_info (LOGD_DHCP4, " gateway %s", *s);
+ _LOG2I (LOGD_DHCP4, iface, " gateway %s", *s);
break;
} else
- nm_log_warn (LOGD_DHCP4, "ignoring invalid gateway '%s'", *s);
+ _LOG2W (LOGD_DHCP4, iface, "ignoring invalid gateway '%s'", *s);
}
g_strfreev (routers);
}
@@ -455,7 +465,7 @@ nm_dhcp_utils_ip4_config_from_options (int ifindex,
if (str) {
if (inet_pton (AF_INET, str, &tmp_addr) > 0) {
- nm_log_info (LOGD_DHCP4, " server identifier %s", str);
+ _LOG2I (LOGD_DHCP4, iface, " server identifier %s", str);
if ( nm_utils_ip4_address_clear_host_address(tmp_addr, address.plen) != nm_utils_ip4_address_clear_host_address(address.address, address.plen)
&& !nm_ip4_config_get_direct_route_for_host (ip4_config, tmp_addr)) {
/* DHCP server not on assigned subnet and the no direct route was returned. Add route */
@@ -468,18 +478,18 @@ nm_dhcp_utils_ip4_config_from_options (int ifindex,
route.source = NM_IP_CONFIG_SOURCE_DHCP;
route.metric = priority;
nm_ip4_config_add_route (ip4_config, &route);
- nm_log_dbg (LOGD_IP, "adding route for server identifier: %s",
- nm_platform_ip4_route_to_string (&route, NULL, 0));
+ _LOG2D (LOGD_IP, iface, "adding route for server identifier: %s",
+ nm_platform_ip4_route_to_string (&route, NULL, 0));
}
}
else
- nm_log_warn (LOGD_DHCP4, "ignoring invalid server identifier '%s'", str);
+ _LOG2W (LOGD_DHCP4, iface, "ignoring invalid server identifier '%s'", str);
}
str = g_hash_table_lookup (options, "dhcp_lease_time");
if (str) {
address.lifetime = address.preferred = strtoul (str, NULL, 10);
- nm_log_info (LOGD_DHCP4, " lease time %u", address.lifetime);
+ _LOG2I (LOGD_DHCP4, iface, " lease time %u", address.lifetime);
}
address.source = NM_IP_CONFIG_SOURCE_DHCP;
@@ -487,7 +497,7 @@ nm_dhcp_utils_ip4_config_from_options (int ifindex,
str = g_hash_table_lookup (options, "host_name");
if (str)
- nm_log_info (LOGD_DHCP4, " hostname '%s'", str);
+ _LOG2I (LOGD_DHCP4, iface, " hostname '%s'", str);
str = g_hash_table_lookup (options, "domain_name_servers");
if (str) {
@@ -498,10 +508,10 @@ nm_dhcp_utils_ip4_config_from_options (int ifindex,
if (inet_pton (AF_INET, *s, &tmp_addr) > 0) {
if (tmp_addr) {
nm_ip4_config_add_nameserver (ip4_config, tmp_addr);
- nm_log_info (LOGD_DHCP4, " nameserver '%s'", *s);
+ _LOG2I (LOGD_DHCP4, iface, " nameserver '%s'", *s);
}
} else
- nm_log_warn (LOGD_DHCP4, "ignoring invalid nameserver '%s'", *s);
+ _LOG2W (LOGD_DHCP4, iface, "ignoring invalid nameserver '%s'", *s);
}
g_strfreev (dns);
}
@@ -512,7 +522,7 @@ nm_dhcp_utils_ip4_config_from_options (int ifindex,
char **s;
for (s = domains; *s; s++) {
- nm_log_info (LOGD_DHCP4, " domain name '%s'", *s);
+ _LOG2I (LOGD_DHCP4, iface, " domain name '%s'", *s);
nm_ip4_config_add_domain (ip4_config, *s);
}
g_strfreev (domains);
@@ -520,7 +530,7 @@ nm_dhcp_utils_ip4_config_from_options (int ifindex,
str = g_hash_table_lookup (options, "domain_search");
if (str)
- process_domain_search (str, ip4_add_domain_search, ip4_config);
+ process_domain_search (iface, str, ip4_add_domain_search, ip4_config);
str = g_hash_table_lookup (options, "netbios_name_servers");
if (str) {
@@ -531,10 +541,10 @@ nm_dhcp_utils_ip4_config_from_options (int ifindex,
if (inet_pton (AF_INET, *s, &tmp_addr) > 0) {
if (tmp_addr) {
nm_ip4_config_add_wins (ip4_config, tmp_addr);
- nm_log_info (LOGD_DHCP4, " wins '%s'", *s);
+ _LOG2I (LOGD_DHCP4, iface, " wins '%s'", *s);
}
} else
- nm_log_warn (LOGD_DHCP4, "ignoring invalid WINS server '%s'", *s);
+ _LOG2W (LOGD_DHCP4, iface, "ignoring invalid WINS server '%s'", *s);
}
g_strfreev (nbns);
}
@@ -554,7 +564,7 @@ nm_dhcp_utils_ip4_config_from_options (int ifindex,
str = g_hash_table_lookup (options, "nis_domain");
if (str) {
- nm_log_info (LOGD_DHCP4, " NIS domain '%s'", str);
+ _LOG2I (LOGD_DHCP4, iface, " NIS domain '%s'", str);
nm_ip4_config_set_nis_domain (ip4_config, str);
}
@@ -567,10 +577,10 @@ nm_dhcp_utils_ip4_config_from_options (int ifindex,
if (inet_pton (AF_INET, *s, &tmp_addr) > 0) {
if (tmp_addr) {
nm_ip4_config_add_nis_server (ip4_config, tmp_addr);
- nm_log_info (LOGD_DHCP4, " nis '%s'", *s);
+ _LOG2I (LOGD_DHCP4, iface, " nis '%s'", *s);
}
} else
- nm_log_warn (LOGD_DHCP4, "ignoring invalid NIS server '%s'", *s);
+ _LOG2W (LOGD_DHCP4, iface, "ignoring invalid NIS server '%s'", *s);
}
g_strfreev (nis);
}
@@ -615,8 +625,8 @@ nm_dhcp_utils_ip6_config_from_options (int ifindex,
g_hash_table_iter_init (&iter, options);
while (g_hash_table_iter_next (&iter, &key, &value)) {
- nm_log_dbg (LOGD_DHCP6, "(%s): option '%s'=>'%s'",
- iface, (const char *) key, (const char *) value);
+ _LOG2D (LOGD_DHCP6, iface, "(%s): option '%s'=>'%s'",
+ iface, (const char *) key, (const char *) value);
}
ip6_config = nm_ip6_config_new (ifindex);
@@ -624,27 +634,27 @@ nm_dhcp_utils_ip6_config_from_options (int ifindex,
str = g_hash_table_lookup (options, "max_life");
if (str) {
address.lifetime = strtoul (str, NULL, 10);
- nm_log_info (LOGD_DHCP6, " valid_lft %u", address.lifetime);
+ _LOG2I (LOGD_DHCP6, iface, " valid_lft %u", address.lifetime);
}
str = g_hash_table_lookup (options, "preferred_life");
if (str) {
address.preferred = strtoul (str, NULL, 10);
- nm_log_info (LOGD_DHCP6, " preferred_lft %u", address.preferred);
+ _LOG2I (LOGD_DHCP6, iface, " preferred_lft %u", address.preferred);
}
str = g_hash_table_lookup (options, "ip6_address");
if (str) {
if (!inet_pton (AF_INET6, str, &tmp_addr)) {
- nm_log_warn (LOGD_DHCP6, "(%s): DHCP returned invalid address '%s'",
- iface, str);
+ _LOG2W (LOGD_DHCP6, iface, "(%s): DHCP returned invalid address '%s'",
+ iface, str);
goto error;
}
address.address = tmp_addr;
address.source = NM_IP_CONFIG_SOURCE_DHCP;
nm_ip6_config_add_address (ip6_config, &address);
- nm_log_info (LOGD_DHCP6, " address %s", str);
+ _LOG2I (LOGD_DHCP6, iface, " address %s", str);
} else if (info_only == FALSE) {
/* No address in Managed mode is a hard error */
goto error;
@@ -652,7 +662,7 @@ nm_dhcp_utils_ip6_config_from_options (int ifindex,
str = g_hash_table_lookup (options, "host_name");
if (str)
- nm_log_info (LOGD_DHCP6, " hostname '%s'", str);
+ _LOG2I (LOGD_DHCP6, iface, " hostname '%s'", str);
str = g_hash_table_lookup (options, "dhcp6_name_servers");
if (str) {
@@ -663,17 +673,17 @@ nm_dhcp_utils_ip6_config_from_options (int ifindex,
if (inet_pton (AF_INET6, *s, &tmp_addr) > 0) {
if (!IN6_IS_ADDR_UNSPECIFIED (&tmp_addr)) {
nm_ip6_config_add_nameserver (ip6_config, &tmp_addr);
- nm_log_info (LOGD_DHCP6, " nameserver '%s'", *s);
+ _LOG2I (LOGD_DHCP6, iface, " nameserver '%s'", *s);
}
} else
- nm_log_warn (LOGD_DHCP6, "ignoring invalid nameserver '%s'", *s);
+ _LOG2W (LOGD_DHCP6, iface, "ignoring invalid nameserver '%s'", *s);
}
g_strfreev (dns);
}
str = g_hash_table_lookup (options, "dhcp6_domain_search");
if (str)
- process_domain_search (str, ip6_add_domain_search, ip6_config);
+ process_domain_search (iface, str, ip6_add_domain_search, ip6_config);
return ip6_config;
--
2.9.3
From 11f30226a96661f138ae19ebfbc93895d8ac9113 Mon Sep 17 00:00:00 2001
From: Thomas Haller <thaller@redhat.com>
Date: Mon, 5 Sep 2016 14:12:41 +0200
Subject: [PATCH 04/19] shared: add NM_MIN()/NM_MAX() macros to replace glib's
MIN()/MAX()
(cherry picked from commit b2016fd2a52b82d45324526c965e7545d026cebe)
(cherry picked from commit a2c39cddbfeca7ee4e5e2d09411368c855d5b037)
---
shared/nm-macros-internal.h | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/shared/nm-macros-internal.h b/shared/nm-macros-internal.h
index fe27b76..155d88f 100644
--- a/shared/nm-macros-internal.h
+++ b/shared/nm-macros-internal.h
@@ -475,6 +475,50 @@ nm_strstrip (char *str)
/*****************************************************************************/
+/* Taken from systemd's UNIQ_T and UNIQ macros. */
+
+#define NM_UNIQ_T(x, uniq) G_PASTE(__unique_prefix_, G_PASTE(x, uniq))
+#define NM_UNIQ __COUNTER__
+
+/*****************************************************************************/
+
+/* glib's MIN()/MAX() macros don't have function-like behavior, in that they evaluate
+ * the argument possibly twice.
+ *
+ * Taken from systemd's MIN()/MAX() macros. */
+
+#define NM_MIN(a, b) __NM_MIN(NM_UNIQ, a, NM_UNIQ, b)
+#define __NM_MIN(aq, a, bq, b) \
+ ({ \
+ typeof (a) NM_UNIQ_T(A, aq) = (a); \
+ typeof (b) NM_UNIQ_T(B, bq) = (b); \
+ ((NM_UNIQ_T(A, aq) < NM_UNIQ_T(B, bq)) ? NM_UNIQ_T(A, aq) : NM_UNIQ_T(B, bq)); \
+ })
+
+#define NM_MAX(a, b) __NM_MAX(NM_UNIQ, a, NM_UNIQ, b)
+#define __NM_MAX(aq, a, bq, b) \
+ ({ \
+ typeof (a) NM_UNIQ_T(A, aq) = (a); \
+ typeof (b) NM_UNIQ_T(B, bq) = (b); \
+ ((NM_UNIQ_T(A, aq) > NM_UNIQ_T(B, bq)) ? NM_UNIQ_T(A, aq) : NM_UNIQ_T(B, bq)); \
+ })
+
+#define NM_CLAMP(x, low, high) __NM_CLAMP(NM_UNIQ, x, NM_UNIQ, low, NM_UNIQ, high)
+#define __NM_CLAMP(xq, x, lowq, low, highq, high) \
+ ({ \
+ typeof(x)NM_UNIQ_T(X,xq) = (x); \
+ typeof(low) NM_UNIQ_T(LOW,lowq) = (low); \
+ typeof(high) NM_UNIQ_T(HIGH,highq) = (high); \
+ \
+ ( (NM_UNIQ_T(X,xq) > NM_UNIQ_T(HIGH,highq)) \
+ ? NM_UNIQ_T(HIGH,highq) \
+ : (NM_UNIQ_T(X,xq) < NM_UNIQ_T(LOW,lowq)) \
+ ? NM_UNIQ_T(LOW,lowq) \
+ : NM_UNIQ_T(X,xq)); \
+ })
+
+/*****************************************************************************/
+
static inline guint
nm_encode_version (guint major, guint minor, guint micro) {
/* analog to the preprocessor macro NM_ENCODE_VERSION(). */
--
2.9.3
From 0ec53b4dd94009299e803e147a87b721e5b0cae4 Mon Sep 17 00:00:00 2001
From: Thomas Haller <thaller@redhat.com>
Date: Mon, 5 Sep 2016 16:49:50 +0200
Subject: [PATCH 05/19] shared: add _NM_GET_PRIVATE() macro
(cherry picked from commit 2cae9ba348ed6ea4d41ebd714d8c55f4d49feae9)
(cherry picked from commit 3c690e751f74a928b24f7a118e84e0d3f94d33c5)
---
shared/nm-macros-internal.h | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/shared/nm-macros-internal.h b/shared/nm-macros-internal.h
index 155d88f..a7df92f 100644
--- a/shared/nm-macros-internal.h
+++ b/shared/nm-macros-internal.h
@@ -335,6 +335,24 @@ _notify (obj_type *obj, _PropertyEnums prop) \
/*****************************************************************************/
+#define __NM_GET_PRIVATE(self, type, is_check, result_cmd) \
+ ({ \
+ /* preserve the const-ness of self. Unfortunately, that
+ * way, @self cannot be a void pointer */ \
+ typeof (self) _self = (self); \
+ \
+ /* Get compiler error if variable is of wrong type */ \
+ _nm_unused const type *_self2 = (_self); \
+ \
+ nm_assert (is_check (_self)); \
+ ( result_cmd ); \
+ })
+
+#define _NM_GET_PRIVATE(self, type, is_check) __NM_GET_PRIVATE(self, type, is_check, &_self->_priv)
+#define _NM_GET_PRIVATE_PTR(self, type, is_check) __NM_GET_PRIVATE(self, type, is_check, _self->_priv)
+
+/*****************************************************************************/
+
static inline gpointer
nm_g_object_ref (gpointer obj)
{
--
2.9.3
From 4dec41b83f09bc36a5d8d38a678d6245816eb64e Mon Sep 17 00:00:00 2001
From: Thomas Haller <thaller@redhat.com>
Date: Mon, 5 Sep 2016 16:42:59 +0200
Subject: [PATCH 06/19] dhcp-listener: refactor type definition and embed
private data in @self
(cherry picked from commit 822f01a8fdb63831c887d5db9fb06eb840f53c88)
(cherry picked from commit 20406d1a1dd81c9092024d35dc3d5acc378e4638)
---
src/dhcp-manager/nm-dhcp-listener.c | 50 +++++++++++++++++++++----------------
src/dhcp-manager/nm-dhcp-listener.h | 4 +--
2 files changed, 31 insertions(+), 23 deletions(-)
diff --git a/src/dhcp-manager/nm-dhcp-listener.c b/src/dhcp-manager/nm-dhcp-listener.c
index eadff3e..d3616cb 100644
--- a/src/dhcp-manager/nm-dhcp-listener.c
+++ b/src/dhcp-manager/nm-dhcp-listener.c
@@ -13,12 +13,14 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Copyright 2014 Red Hat, Inc.
+ * Copyright 2014 - 2016 Red Hat, Inc.
*
*/
#include "nm-default.h"
+#include "nm-dhcp-listener.h"
+
#include <sys/socket.h>
#include <sys/wait.h>
#include <signal.h>
@@ -27,7 +29,6 @@
#include <errno.h>
#include <unistd.h>
-#include "nm-dhcp-listener.h"
#include "nm-core-internal.h"
#include "nm-bus-manager.h"
#include "NetworkManagerUtils.h"
@@ -36,6 +37,8 @@
#define PRIV_SOCK_PATH NMRUNDIR "/private-dhcp"
#define PRIV_SOCK_TAG "dhcp"
+/*****************************************************************************/
+
typedef struct {
NMBusManager * dbus_mgr;
gulong new_conn_id;
@@ -43,17 +46,26 @@ typedef struct {
GHashTable * signal_handlers;
} NMDhcpListenerPrivate;
-#define NM_DHCP_LISTENER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DHCP_LISTENER, NMDhcpListenerPrivate))
+struct _NMDhcpListener {
+ GObject parent;
+ NMDhcpListenerPrivate _priv;
+};
+
+struct _NMDhcpListenerClass {
+ GObjectClass parent_class;
+};
G_DEFINE_TYPE (NMDhcpListener, nm_dhcp_listener, G_TYPE_OBJECT)
+#define NM_DHCP_LISTENER_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMDhcpListener, NM_IS_DHCP_LISTENER)
+
enum {
EVENT,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL] = { 0 };
-/***************************************************/
+/*****************************************************************************/
static char *
get_option (GVariant *options, const char *key)
@@ -188,7 +200,7 @@ nm_dhcp_listener_init (NMDhcpListener *self)
{
NMDhcpListenerPrivate *priv = NM_DHCP_LISTENER_GET_PRIVATE (self);
- /* Maps GDBusConnection :: GDBusProxy */
+ /* Maps GDBusConnection :: signal-id */
priv->signal_handlers = g_hash_table_new (NULL, NULL);
priv->dbus_mgr = nm_bus_manager_get ();
@@ -208,7 +220,7 @@ nm_dhcp_listener_init (NMDhcpListener *self)
static void
dispose (GObject *object)
{
- NMDhcpListenerPrivate *priv = NM_DHCP_LISTENER_GET_PRIVATE (object);
+ NMDhcpListenerPrivate *priv = NM_DHCP_LISTENER_GET_PRIVATE ((NMDhcpListener *) object);
nm_clear_g_signal_handler (priv->dbus_mgr, &priv->new_conn_id);
nm_clear_g_signal_handler (priv->dbus_mgr, &priv->dis_conn_id);
@@ -224,22 +236,18 @@ nm_dhcp_listener_class_init (NMDhcpListenerClass *listener_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (listener_class);
- g_type_class_add_private (listener_class, sizeof (NMDhcpListenerPrivate));
-
- /* virtual methods */
object_class->dispose = dispose;
- /* signals */
signals[EVENT] =
- g_signal_new (NM_DHCP_LISTENER_EVENT,
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST, 0,
- g_signal_accumulator_true_handled,
- NULL, NULL,
- G_TYPE_BOOLEAN, /* listeners return TRUE if handled */
- 4,
- G_TYPE_STRING, /* iface */
- G_TYPE_INT, /* pid */
- G_TYPE_VARIANT, /* options */
- G_TYPE_STRING); /* reason */
+ g_signal_new (NM_DHCP_LISTENER_EVENT,
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST, 0,
+ g_signal_accumulator_true_handled,
+ NULL, NULL,
+ G_TYPE_BOOLEAN, /* listeners return TRUE if handled */
+ 4,
+ G_TYPE_STRING, /* iface */
+ G_TYPE_INT, /* pid */
+ G_TYPE_VARIANT, /* options */
+ G_TYPE_STRING); /* reason */
}
diff --git a/src/dhcp-manager/nm-dhcp-listener.h b/src/dhcp-manager/nm-dhcp-listener.h
index b2631ac..e558047 100644
--- a/src/dhcp-manager/nm-dhcp-listener.h
+++ b/src/dhcp-manager/nm-dhcp-listener.h
@@ -28,8 +28,8 @@
#define NM_DHCP_LISTENER_EVENT "event"
-typedef GObject NMDhcpListener;
-typedef GObjectClass NMDhcpListenerClass;
+typedef struct _NMDhcpListener NMDhcpListener;
+typedef struct _NMDhcpListenerClass NMDhcpListenerClass;
GType nm_dhcp_listener_get_type (void);
--
2.9.3
From d96350502bf14924f47d2b726ac7636881fee749 Mon Sep 17 00:00:00 2001
From: Thomas Haller <thaller@redhat.com>
Date: Mon, 5 Sep 2016 17:17:09 +0200
Subject: [PATCH 07/19] dhcp-listener: add logging macros to nm-dhcp-listener.c
(cherry picked from commit d37cd04fe059e9d99c7103f4e22a9a945f8d4d98)
(cherry picked from commit b63ef470afb598bd152a4bb22e264439add9caf0)
---
src/dhcp-manager/nm-dhcp-listener.c | 39 ++++++++++++++++++++++++++-----------
1 file changed, 28 insertions(+), 11 deletions(-)
diff --git a/src/dhcp-manager/nm-dhcp-listener.c b/src/dhcp-manager/nm-dhcp-listener.c
index d3616cb..79d3513 100644
--- a/src/dhcp-manager/nm-dhcp-listener.c
+++ b/src/dhcp-manager/nm-dhcp-listener.c
@@ -55,16 +55,35 @@ struct _NMDhcpListenerClass {
GObjectClass parent_class;
};
-G_DEFINE_TYPE (NMDhcpListener, nm_dhcp_listener, G_TYPE_OBJECT)
-
-#define NM_DHCP_LISTENER_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMDhcpListener, NM_IS_DHCP_LISTENER)
-
enum {
EVENT,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL] = { 0 };
+G_DEFINE_TYPE (NMDhcpListener, nm_dhcp_listener, G_TYPE_OBJECT)
+
+#define NM_DHCP_LISTENER_GET_PRIVATE(self) _NM_GET_PRIVATE(self, NMDhcpListener, NM_IS_DHCP_LISTENER)
+
+NM_DEFINE_SINGLETON_GETTER (NMDhcpListener, nm_dhcp_listener_get, NM_TYPE_DHCP_LISTENER);
+
+/*****************************************************************************/
+
+#define _NMLOG_PREFIX_NAME "dhcp-listener"
+#define _NMLOG_DOMAIN LOGD_DHCP
+#define _NMLOG(level, ...) \
+ G_STMT_START { \
+ const NMDhcpListener *_self = (self); \
+ char _prefix[64]; \
+ \
+ nm_log ((level), (_NMLOG_DOMAIN), \
+ "%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
+ (_self != singleton_instance \
+ ? nm_sprintf_buf (_prefix, "%s[%p]", _NMLOG_PREFIX_NAME, _self) \
+ : _NMLOG_PREFIX_NAME )\
+ _NM_UTILS_MACRO_REST(__VA_ARGS__)); \
+ } G_STMT_END
+
/*****************************************************************************/
static char *
@@ -123,20 +142,20 @@ handle_event (GDBusConnection *connection,
iface = get_option (options, "interface");
if (iface == NULL) {
- nm_log_warn (LOGD_DHCP, "dhcp-event: didn't have associated interface.");
+ _LOGW ("dhcp-event: didn't have associated interface.");
goto out;
}
pid_str = get_option (options, "pid");
pid = _nm_utils_ascii_str_to_int64 (pid_str, 10, 0, G_MAXINT32, -1);
if (pid == -1) {
- nm_log_warn (LOGD_DHCP, "dhcp-event: couldn't convert PID '%s' to an integer", pid_str ? pid_str : "(null)");
+ _LOGW ("dhcp-event: couldn't convert PID '%s' to an integer", pid_str ? pid_str : "(null)");
goto out;
}
reason = get_option (options, "reason");
if (reason == NULL) {
- nm_log_warn (LOGD_DHCP, "dhcp-event: (pid %d) DHCP event didn't have a reason", pid);
+ _LOGW ("dhcp-event: (pid %d) DHCP event didn't have a reason", pid);
goto out;
}
@@ -144,9 +163,9 @@ handle_event (GDBusConnection *connection,
if (!handled) {
if (g_ascii_strcasecmp (reason, "RELEASE") == 0) {
/* Ignore event when the dhcp client gets killed and we receive its last message */
- nm_log_dbg (LOGD_DHCP, "dhcp-event: (pid %d) unhandled RELEASE DHCP event for interface %s", pid, iface);
+ _LOGD ("dhcp-event: (pid %d) unhandled RELEASE DHCP event for interface %s", pid, iface);
} else
- nm_log_warn (LOGD_DHCP, "dhcp-event: (pid %d) unhandled DHCP event for interface %s", pid, iface);
+ _LOGW ("dhcp-event: (pid %d) unhandled DHCP event for interface %s", pid, iface);
}
out:
@@ -193,8 +212,6 @@ dis_connection_cb (NMBusManager *mgr,
/***************************************************/
-NM_DEFINE_SINGLETON_GETTER (NMDhcpListener, nm_dhcp_listener_get, NM_TYPE_DHCP_LISTENER);
-
static void
nm_dhcp_listener_init (NMDhcpListener *self)
{
--
2.9.3
From b3a4e1cd6c6da05f732db3435487f93be4d1dce8 Mon Sep 17 00:00:00 2001
From: Thomas Haller <thaller@redhat.com>
Date: Mon, 5 Sep 2016 17:24:28 +0200
Subject: [PATCH 08/19] dhcp-listener/trivial: rename field to track
connections in NMDhcpListener
It's not "signal-handles", as it currently tracks the registration ID of
type int. Rename it, it is effectively the list of connections that we
track.
(cherry picked from commit 2dd3a5245f91a7c25ae1a36a86638195500f00a8)
(cherry picked from commit 99ec04debd421f57d4087bcbd110e7c63051633e)
---
src/dhcp-manager/nm-dhcp-listener.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/dhcp-manager/nm-dhcp-listener.c b/src/dhcp-manager/nm-dhcp-listener.c
index 79d3513..b09bc20 100644
--- a/src/dhcp-manager/nm-dhcp-listener.c
+++ b/src/dhcp-manager/nm-dhcp-listener.c
@@ -43,7 +43,7 @@ typedef struct {
NMBusManager * dbus_mgr;
gulong new_conn_id;
gulong dis_conn_id;
- GHashTable * signal_handlers;
+ GHashTable * connections;
} NMDhcpListenerPrivate;
struct _NMDhcpListener {
@@ -192,7 +192,7 @@ new_connection_cb (NMBusManager *mgr,
NULL,
G_DBUS_SIGNAL_FLAGS_NONE,
handle_event, self, NULL);
- g_hash_table_insert (priv->signal_handlers, connection, GUINT_TO_POINTER (id));
+ g_hash_table_insert (priv->connections, connection, GUINT_TO_POINTER (id));
}
static void
@@ -203,10 +203,10 @@ dis_connection_cb (NMBusManager *mgr,
NMDhcpListenerPrivate *priv = NM_DHCP_LISTENER_GET_PRIVATE (self);
guint id;
- id = GPOINTER_TO_UINT (g_hash_table_lookup (priv->signal_handlers, connection));
+ id = GPOINTER_TO_UINT (g_hash_table_lookup (priv->connections, connection));
if (id) {
g_dbus_connection_signal_unsubscribe (connection, id);
- g_hash_table_remove (priv->signal_handlers, connection);
+ g_hash_table_remove (priv->connections, connection);
}
}
@@ -218,7 +218,7 @@ nm_dhcp_listener_init (NMDhcpListener *self)
NMDhcpListenerPrivate *priv = NM_DHCP_LISTENER_GET_PRIVATE (self);
/* Maps GDBusConnection :: signal-id */
- priv->signal_handlers = g_hash_table_new (NULL, NULL);
+ priv->connections = g_hash_table_new (NULL, NULL);
priv->dbus_mgr = nm_bus_manager_get ();
@@ -243,7 +243,7 @@ dispose (GObject *object)
nm_clear_g_signal_handler (priv->dbus_mgr, &priv->dis_conn_id);
priv->dbus_mgr = NULL;
- g_clear_pointer (&priv->signal_handlers, g_hash_table_destroy);
+ g_clear_pointer (&priv->connections, g_hash_table_destroy);
G_OBJECT_CLASS (nm_dhcp_listener_parent_class)->dispose (object);
}
--
2.9.3
From 0a493fa4011f28f3cf5054c60bed0284a78ff74e Mon Sep 17 00:00:00 2001
From: Thomas Haller <thaller@redhat.com>
Date: Mon, 5 Sep 2016 11:06:04 +0200
Subject: [PATCH 09/19] dhcp-helper: refactor error handling
Don't exit(1) from fatal_error() because that skips destroying
local variables in main(). Just return regularly.
(cherry picked from commit bb489163db36889a6fb80789e4e5b9dd8a15dbdd)
(cherry picked from commit 602163346e8d6b5db366a8ce04c01c23b3802523)
---
src/dhcp-manager/nm-dhcp-helper.c | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)
diff --git a/src/dhcp-manager/nm-dhcp-helper.c b/src/dhcp-manager/nm-dhcp-helper.c
index 7667084..8c512e7 100644
--- a/src/dhcp-manager/nm-dhcp-helper.c
+++ b/src/dhcp-manager/nm-dhcp-helper.c
@@ -74,26 +74,26 @@ build_signal_parameters (void)
}
static void
-fatal_error (void)
+kill_pid (void)
{
- const char *pid_str = getenv ("pid");
- int pid = 0;
+ const char *pid_str;
+ pid_t pid = 0;
+ pid_str = getenv ("pid");
if (pid_str)
pid = strtol (pid_str, NULL, 10);
if (pid) {
g_printerr ("Fatal error occured, killing dhclient instance with pid %d.\n", pid);
kill (pid, SIGTERM);
}
-
- exit (1);
}
int
main (int argc, char *argv[])
{
- GDBusConnection *connection;
- GError *error = NULL;
+ gs_unref_object GDBusConnection *connection = NULL;
+ gs_free_error GError *error = NULL;
+ gboolean success = FALSE;
nm_g_type_init ();
@@ -104,8 +104,7 @@ main (int argc, char *argv[])
g_dbus_error_strip_remote_error (error);
g_printerr ("Error: could not connect to NetworkManager D-Bus socket: %s\n",
error->message);
- g_error_free (error);
- fatal_error ();
+ goto out;
}
if (!g_dbus_connection_emit_signal (connection,
@@ -117,18 +116,19 @@ main (int argc, char *argv[])
&error)) {
g_dbus_error_strip_remote_error (error);
g_printerr ("Error: Could not send DHCP Event signal: %s\n", error->message);
- g_error_free (error);
- fatal_error ();
+ goto out;
}
if (!g_dbus_connection_flush_sync (connection, NULL, &error)) {
g_dbus_error_strip_remote_error (error);
g_printerr ("Error: Could not flush D-Bus connection: %s\n", error->message);
- g_error_free (error);
- fatal_error ();
+ goto out;
}
- g_object_unref (connection);
- return 0;
+ success = TRUE;
+out:
+ if (!success)
+ kill_pid ();
+ return success ? EXIT_SUCCESS : EXIT_FAILURE;
}
--
2.9.3
From bcf3ff0a0c6265b8e117c9ac6554fb9e6d18788a Mon Sep 17 00:00:00 2001
From: Thomas Haller <thaller@redhat.com>
Date: Mon, 5 Sep 2016 13:38:58 +0200
Subject: [PATCH 10/19] dhcp-helper: refactor logging to use logging macros
(cherry picked from commit cc89996c9e826c9c8d12d5fb7bc8a2a578209eb0)
(cherry picked from commit 704e5a7709efd86733337deeaf1534af41223b29)
---
src/dhcp-manager/nm-dhcp-helper.c | 45 ++++++++++++++++++++++++++++++++++-----
1 file changed, 40 insertions(+), 5 deletions(-)
diff --git a/src/dhcp-manager/nm-dhcp-helper.c b/src/dhcp-manager/nm-dhcp-helper.c
index 8c512e7..c42112a 100644
--- a/src/dhcp-manager/nm-dhcp-helper.c
+++ b/src/dhcp-manager/nm-dhcp-helper.c
@@ -25,8 +25,43 @@
#include <string.h>
#include <signal.h>
+#include "nm-vpn-plugin-macros.h"
+
#define NM_DHCP_CLIENT_DBUS_IFACE "org.freedesktop.nm_dhcp_client"
+/*****************************************************************************/
+
+#ifdef NM_MORE_LOGGING
+#define _NMLOG_ENABLED(level) TRUE
+#else
+#define _NMLOG_ENABLED(level) ((level) <= LOG_ERR)
+#endif
+
+#define _NMLOG(always_enabled, level, ...) \
+ G_STMT_START { \
+ if ((always_enabled) || _NMLOG_ENABLED (level)) { \
+ GTimeVal _tv; \
+ \
+ g_get_current_time (&_tv); \
+ g_print ("nm-dhcp-helper[%ld] %-7s [%ld.%04ld] " _NM_UTILS_MACRO_FIRST (__VA_ARGS__) "\n", \
+ (long) getpid (), \
+ nm_utils_syslog_to_str (level), \
+ _tv.tv_sec, _tv.tv_usec / 100 \
+ _NM_UTILS_MACRO_REST (__VA_ARGS__)); \
+ } \
+ } G_STMT_END
+
+#define _LOGD(...) _NMLOG(TRUE, LOG_INFO, __VA_ARGS__)
+#define _LOGI(...) _NMLOG(TRUE, LOG_NOTICE, __VA_ARGS__)
+#define _LOGW(...) _NMLOG(TRUE, LOG_WARNING, __VA_ARGS__)
+#define _LOGE(...) _NMLOG(TRUE, LOG_ERR, __VA_ARGS__)
+
+#define _LOGd(...) _NMLOG(FALSE, LOG_INFO, __VA_ARGS__)
+#define _LOGi(...) _NMLOG(FALSE, LOG_NOTICE, __VA_ARGS__)
+#define _LOGw(...) _NMLOG(FALSE, LOG_WARNING, __VA_ARGS__)
+
+/*****************************************************************************/
+
static const char * ignore[] = {"PATH", "SHLVL", "_", "PWD", "dhc_dbus", NULL};
static GVariant *
@@ -83,7 +118,7 @@ kill_pid (void)
if (pid_str)
pid = strtol (pid_str, NULL, 10);
if (pid) {
- g_printerr ("Fatal error occured, killing dhclient instance with pid %d.\n", pid);
+ _LOGI ("a fatal error occured, kill dhclient instance with pid %d\n", pid);
kill (pid, SIGTERM);
}
}
@@ -102,8 +137,8 @@ main (int argc, char *argv[])
NULL, NULL, &error);
if (!connection) {
g_dbus_error_strip_remote_error (error);
- g_printerr ("Error: could not connect to NetworkManager D-Bus socket: %s\n",
- error->message);
+ _LOGE ("could not connect to NetworkManager D-Bus socket: %s",
+ error->message);
goto out;
}
@@ -115,13 +150,13 @@ main (int argc, char *argv[])
build_signal_parameters (),
&error)) {
g_dbus_error_strip_remote_error (error);
- g_printerr ("Error: Could not send DHCP Event signal: %s\n", error->message);
+ _LOGE ("could not send DHCP Event signal: %s", error->message);
goto out;
}
if (!g_dbus_connection_flush_sync (connection, NULL, &error)) {
g_dbus_error_strip_remote_error (error);
- g_printerr ("Error: Could not flush D-Bus connection: %s\n", error->message);
+ _LOGE ("could not flush D-Bus connection: %s", error->message);
goto out;
}
--
2.9.3
From 86f2af78ed57570de7c894157ec022001896285b Mon Sep 17 00:00:00 2001
From: Thomas Haller <thaller@redhat.com>
Date: Mon, 5 Sep 2016 11:54:46 +0200
Subject: [PATCH 11/19] dhcp: add new header "nm-dhcp-helper-api.h"
(cherry picked from commit 7684b68c49812ed7b2ec493889fae04db066b665)
(cherry picked from commit cb0d31229c50a22a06486da17ada1e0f54d59005)
---
src/Makefile.am | 1 +
src/dhcp-manager/Makefile.am | 5 ++++-
src/dhcp-manager/nm-dhcp-helper-api.h | 31 +++++++++++++++++++++++++++++++
src/dhcp-manager/nm-dhcp-helper.c | 2 +-
src/dhcp-manager/nm-dhcp-listener.c | 2 +-
5 files changed, 38 insertions(+), 3 deletions(-)
create mode 100644 src/dhcp-manager/nm-dhcp-helper-api.h
diff --git a/src/Makefile.am b/src/Makefile.am
index 48af5a0..529f0af 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -290,6 +290,7 @@ libNetworkManager_la_SOURCES = \
dhcp-manager/nm-dhcp-client.c \
dhcp-manager/nm-dhcp-client.h \
dhcp-manager/nm-dhcp-client-logging.h \
+ dhcp-manager/nm-dhcp-helper-api.h \
dhcp-manager/nm-dhcp-utils.c \
dhcp-manager/nm-dhcp-utils.h \
dhcp-manager/nm-dhcp-listener.c \
diff --git a/src/dhcp-manager/Makefile.am b/src/dhcp-manager/Makefile.am
index b4590b4..4295412 100644
--- a/src/dhcp-manager/Makefile.am
+++ b/src/dhcp-manager/Makefile.am
@@ -1,6 +1,9 @@
libexec_PROGRAMS = nm-dhcp-helper
-nm_dhcp_helper_SOURCES = nm-dhcp-helper.c
+nm_dhcp_helper_SOURCES = \
+ nm-dhcp-helper.c \
+ nm-dhcp-helper-api.h \
+ $(NULL)
nm_dhcp_helper_CPPFLAGS = \
$(GLIB_CFLAGS) \
diff --git a/src/dhcp-manager/nm-dhcp-helper-api.h b/src/dhcp-manager/nm-dhcp-helper-api.h
new file mode 100644
index 0000000..a6323db
--- /dev/null
+++ b/src/dhcp-manager/nm-dhcp-helper-api.h
@@ -0,0 +1,31 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/* NetworkManager -- Network link manager
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA.
+ *
+ * (C) Copyright 2016 Red Hat, Inc.
+ */
+
+#ifndef __NM_DHCP_HELPER_API_H__
+#define __NM_DHCP_HELPER_API_H__
+
+/******************************************************************************/
+
+#define NM_DHCP_CLIENT_DBUS_IFACE "org.freedesktop.nm_dhcp_client"
+
+/******************************************************************************/
+
+#endif /* __NM_DHCP_HELPER_API_H__ */
diff --git a/src/dhcp-manager/nm-dhcp-helper.c b/src/dhcp-manager/nm-dhcp-helper.c
index c42112a..e467cfe 100644
--- a/src/dhcp-manager/nm-dhcp-helper.c
+++ b/src/dhcp-manager/nm-dhcp-helper.c
@@ -27,7 +27,7 @@
#include "nm-vpn-plugin-macros.h"
-#define NM_DHCP_CLIENT_DBUS_IFACE "org.freedesktop.nm_dhcp_client"
+#include "nm-dhcp-helper-api.h"
/*****************************************************************************/
diff --git a/src/dhcp-manager/nm-dhcp-listener.c b/src/dhcp-manager/nm-dhcp-listener.c
index b09bc20..7e9de49 100644
--- a/src/dhcp-manager/nm-dhcp-listener.c
+++ b/src/dhcp-manager/nm-dhcp-listener.c
@@ -29,11 +29,11 @@
#include <errno.h>
#include <unistd.h>
+#include "nm-dhcp-helper-api.h"
#include "nm-core-internal.h"
#include "nm-bus-manager.h"
#include "NetworkManagerUtils.h"
-#define NM_DHCP_CLIENT_DBUS_IFACE "org.freedesktop.nm_dhcp_client"
#define PRIV_SOCK_PATH NMRUNDIR "/private-dhcp"
#define PRIV_SOCK_TAG "dhcp"
--
2.9.3
From fb964577a5b204d851890e95ca00e9aa5cd21539 Mon Sep 17 00:00:00 2001
From: Thomas Haller <thaller@redhat.com>
Date: Mon, 5 Sep 2016 12:32:40 +0200
Subject: [PATCH 12/19] dhcp: call synchronous Notify D-Bus method from
nm-dhcp-helper
A D-Bus signal is asynchronous and it can happen that nm-dhcp-helper
emits the "Event" signal before the server is able to register a handler:
NM_DHCP_HELPER=/usr/libexec/nm-dhcp-helper
nmcli general logging level TRACE
for i in `seq 1 500`; do $NM_DHCP_HELPER & done
journalctl -u NetworkManager --since '1 min ago' | grep "didn't have associated interface" | wc -l
499
Avoid that, by calling the synchronous D-Bus method "Notify".
Interestingly, this race seem to exist since 2007.
Actually, we called g_dbus_connection_signal_subscribe() from inside
GDBusServer:new-connection signal. So it is not clear how such a race
could exist. I was not able to reproduce it by putting a sleep
before g_dbus_connection_signal_subscribe(). On the other hand, there
is bug rh#1372854 and above reproducer which strongly indicates that
events can be lost under certain circumstances.
Now we instead g_dbus_connection_register_object() from the
new-connection signal. According to my tests there was no more race
as also backed by glib's documentation. Still, keep a simple retry-loop
in nm-dhcp-helper just to be sure.
https://bugzilla.redhat.com/show_bug.cgi?id=1372854
https://bugzilla.redhat.com/show_bug.cgi?id=1373276
(cherry picked from commit 2856a658b38df88494187c811415a198a424e1f2)
(cherry picked from commit d6ee12bd7c5dcfd87e085ce0fcc289fea89ec6f4)
---
src/dhcp-manager/nm-dhcp-helper-api.h | 5 ++
src/dhcp-manager/nm-dhcp-helper.c | 78 +++++++++++++++++++++++-----
src/dhcp-manager/nm-dhcp-listener.c | 97 ++++++++++++++++++++++++++++-------
src/nm-bus-manager.c | 6 ++-
4 files changed, 153 insertions(+), 33 deletions(-)
diff --git a/src/dhcp-manager/nm-dhcp-helper-api.h b/src/dhcp-manager/nm-dhcp-helper-api.h
index a6323db..a3eb171 100644
--- a/src/dhcp-manager/nm-dhcp-helper-api.h
+++ b/src/dhcp-manager/nm-dhcp-helper-api.h
@@ -26,6 +26,11 @@
#define NM_DHCP_CLIENT_DBUS_IFACE "org.freedesktop.nm_dhcp_client"
+#define NM_DHCP_HELPER_SERVER_BUS_NAME "org.freedesktop.nm_dhcp_server"
+#define NM_DHCP_HELPER_SERVER_OBJECT_PATH "/org/freedesktop/nm_dhcp_server"
+#define NM_DHCP_HELPER_SERVER_INTERFACE_NAME "org.freedesktop.nm_dhcp_server"
+#define NM_DHCP_HELPER_SERVER_METHOD_NOTIFY "Notify"
+
/******************************************************************************/
#endif /* __NM_DHCP_HELPER_API_H__ */
diff --git a/src/dhcp-manager/nm-dhcp-helper.c b/src/dhcp-manager/nm-dhcp-helper.c
index e467cfe..cdbc740 100644
--- a/src/dhcp-manager/nm-dhcp-helper.c
+++ b/src/dhcp-manager/nm-dhcp-helper.c
@@ -105,7 +105,7 @@ build_signal_parameters (void)
g_free (name);
}
- return g_variant_new ("(a{sv})", &builder);
+ return g_variant_ref_sink (g_variant_new ("(a{sv})", &builder));
}
static void
@@ -128,7 +128,11 @@ main (int argc, char *argv[])
{
gs_unref_object GDBusConnection *connection = NULL;
gs_free_error GError *error = NULL;
+ gs_unref_variant GVariant *parameters = NULL;
+ gs_unref_variant GVariant *result = NULL;
gboolean success = FALSE;
+ guint try_count = 0;
+ gint64 time_end;
nm_g_type_init ();
@@ -142,25 +146,73 @@ main (int argc, char *argv[])
goto out;
}
- if (!g_dbus_connection_emit_signal (connection,
- NULL,
- "/",
- NM_DHCP_CLIENT_DBUS_IFACE,
- "Event",
- build_signal_parameters (),
- &error)) {
- g_dbus_error_strip_remote_error (error);
- _LOGE ("could not send DHCP Event signal: %s", error->message);
- goto out;
- }
+ parameters = build_signal_parameters ();
+
+ time_end = g_get_monotonic_time () + (200 * 1000L); /* retry for at most 200 milliseconds */
+
+do_notify:
+ try_count++;
+ result = g_dbus_connection_call_sync (connection,
+ NULL,
+ NM_DHCP_HELPER_SERVER_OBJECT_PATH,
+ NM_DHCP_HELPER_SERVER_INTERFACE_NAME,
+ NM_DHCP_HELPER_SERVER_METHOD_NOTIFY,
+ parameters,
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ 1000,
+ NULL,
+ &error);
+
+ if (!result) {
+ gs_free char *s_err = NULL;
+
+ s_err = g_dbus_error_get_remote_error (error);
+ if (NM_IN_STRSET (s_err, "org.freedesktop.DBus.Error.UnknownMethod")) {
+ gint64 remaining_time = time_end - g_get_monotonic_time ();
+
+ /* I am not sure that a race can actually happen, as we register the object
+ * on the server side during GDBusServer:new-connection signal.
+ *
+ * However, there was also a race for subscribing to an event, so let's just
+ * do some retry. */
+ if (remaining_time > 0) {
+ _LOGi ("failure to call notify: %s (retry %u)", error->message, try_count);
+ g_usleep (NM_MIN (NM_CLAMP ((gint64) (100L * (1L << try_count)), 5000, 25000), remaining_time));
+ g_clear_error (&error);
+ goto do_notify;
+ }
+ }
+ _LOGW ("failure to call notify: %s (try signal via Event)", error->message);
+ g_clear_error (&error);
+
+ /* for backward compatibilty, try to emit the signal. There is no stable
+ * API between the dhcp-helper and NetworkManager. However, while upgrading
+ * the NetworkManager package, a newer helper might want to notify an
+ * older server, which still uses the "Event". */
+ if (!g_dbus_connection_emit_signal (connection,
+ NULL,
+ "/",
+ NM_DHCP_CLIENT_DBUS_IFACE,
+ "Event",
+ parameters,
+ &error)) {
+ g_dbus_error_strip_remote_error (error);
+ _LOGE ("could not send DHCP Event signal: %s", error->message);
+ goto out;
+ }
+ /* We were able to send the asynchronous Event. Consider that a success. */
+ success = TRUE;
+ } else
+ success = TRUE;
if (!g_dbus_connection_flush_sync (connection, NULL, &error)) {
g_dbus_error_strip_remote_error (error);
_LOGE ("could not flush D-Bus connection: %s", error->message);
+ success = FALSE;
goto out;
}
- success = TRUE;
out:
if (!success)
kill_pid ();
diff --git a/src/dhcp-manager/nm-dhcp-listener.c b/src/dhcp-manager/nm-dhcp-listener.c
index 7e9de49..0df4197 100644
--- a/src/dhcp-manager/nm-dhcp-listener.c
+++ b/src/dhcp-manager/nm-dhcp-listener.c
@@ -119,13 +119,14 @@ get_option (GVariant *options, const char *key)
}
static void
-handle_event (GDBusConnection *connection,
- const char *sender_name,
- const char *object_path,
- const char *interface_name,
- const char *signal_name,
- GVariant *parameters,
- gpointer user_data)
+_method_call (GDBusConnection *connection,
+ const char *sender,
+ const char *object_path,
+ const char *interface_name,
+ const char *method_name,
+ GVariant *parameters,
+ GDBusMethodInvocation *invocation,
+ gpointer user_data)
{
NMDhcpListener *self = NM_DHCP_LISTENER (user_data);
char *iface = NULL;
@@ -135,8 +136,12 @@ handle_event (GDBusConnection *connection,
gboolean handled = FALSE;
GVariant *options;
+ if (!nm_streq0 (interface_name, NM_DHCP_HELPER_SERVER_INTERFACE_NAME))
+ g_return_if_reached ();
+ if (!nm_streq0 (method_name, NM_DHCP_HELPER_SERVER_METHOD_NOTIFY))
+ g_return_if_reached ();
if (!g_variant_is_of_type (parameters, G_VARIANT_TYPE ("(a{sv})")))
- return;
+ g_return_if_reached ();
g_variant_get (parameters, "(@a{sv})", &options);
@@ -173,6 +178,57 @@ out:
g_free (pid_str);
g_free (reason);
g_variant_unref (options);
+ g_dbus_method_invocation_return_value (invocation, NULL);
+}
+
+static guint
+_dbus_connection_register_object (NMDhcpListener *self,
+ GDBusConnection *connection,
+ GError **error)
+{
+ static GDBusArgInfo arg_info_notify_in = {
+ .ref_count = -1,
+ .name = "data",
+ .signature = "a{sv}",
+ .annotations = NULL,
+ };
+ static GDBusArgInfo *arg_infos_notify[] = {
+ &arg_info_notify_in,
+ NULL,
+ };
+ static GDBusMethodInfo method_info_notify = {
+ .ref_count = -1,
+ .name = NM_DHCP_HELPER_SERVER_METHOD_NOTIFY,
+ .in_args = arg_infos_notify,
+ .out_args = NULL,
+ .annotations = NULL,
+ };
+ static GDBusMethodInfo *method_infos[] = {
+ &method_info_notify,
+ NULL,
+ };
+ static GDBusInterfaceInfo interface_info = {
+ .ref_count = -1,
+ .name = NM_DHCP_HELPER_SERVER_INTERFACE_NAME,
+ .methods = method_infos,
+ .signals = NULL,
+ .properties = NULL,
+ .annotations = NULL,
+ };
+
+ static GDBusInterfaceVTable interface_vtable = {
+ .method_call = _method_call,
+ .get_property = NULL,
+ .set_property = NULL,
+ };
+
+ return g_dbus_connection_register_object (connection,
+ NM_DHCP_HELPER_SERVER_OBJECT_PATH,
+ &interface_info,
+ &interface_vtable,
+ self,
+ NULL,
+ error);
}
static void
@@ -182,17 +238,20 @@ new_connection_cb (NMBusManager *mgr,
NMDhcpListener *self)
{
NMDhcpListenerPrivate *priv = NM_DHCP_LISTENER_GET_PRIVATE (self);
- guint id;
+ guint registration_id;
+ GError *error = NULL;
+
+ /* it is important to register the object during the new-connection signal,
+ * as this avoids races with the connecting object. */
+ registration_id = _dbus_connection_register_object (self, connection, &error);
+ if (!registration_id) {
+ _LOGE ("failure to register %s for connection %p: %s",
+ NM_DHCP_HELPER_SERVER_OBJECT_PATH, connection, error->message);
+ g_error_free (error);
+ return;
+ }
- id = g_dbus_connection_signal_subscribe (connection,
- NULL,
- NM_DHCP_CLIENT_DBUS_IFACE,
- "Event",
- NULL,
- NULL,
- G_DBUS_SIGNAL_FLAGS_NONE,
- handle_event, self, NULL);
- g_hash_table_insert (priv->connections, connection, GUINT_TO_POINTER (id));
+ g_hash_table_insert (priv->connections, connection, GUINT_TO_POINTER (registration_id));
}
static void
@@ -205,7 +264,7 @@ dis_connection_cb (NMBusManager *mgr,
id = GPOINTER_TO_UINT (g_hash_table_lookup (priv->connections, connection));
if (id) {
- g_dbus_connection_signal_unsubscribe (connection, id);
+ g_dbus_connection_unregister_object (connection, id);
g_hash_table_remove (priv->connections, connection);
}
}
diff --git a/src/nm-bus-manager.c b/src/nm-bus-manager.c
index 656e7db..699df54 100644
--- a/src/nm-bus-manager.c
+++ b/src/nm-bus-manager.c
@@ -221,7 +221,11 @@ private_server_new_connection (GDBusServer *server,
_LOGD ("(%s) accepted connection %p on private socket", s->tag, conn);
- /* Emit this for the manager */
+ /* Emit this for the manager.
+ *
+ * It is essential to do this from the "new-connection" signal handler, as
+ * at that point no messages from the connection are yet processed
+ * (which avoids races with registering objects). */
g_signal_emit (s->manager,
signals[PRIVATE_CONNECTION_NEW],
s->detail,
--
2.9.3
From 134ded258018a12134a0a61382e954fc45546435 Mon Sep 17 00:00:00 2001
From: Dan Williams <dcbw@redhat.com>
Date: Fri, 16 Dec 2016 11:34:29 -0600
Subject: [PATCH 13/19] wifi: don't request new PSK for locally-generated
WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY errors
This usually indicates that the driver missed beacons from the AP, due to driver bugs
or faulty power-save management. It doesn't mean that the PSK is wrong.
(cherry picked from commit 0c5aa6e48b713a5626c20303c683f7d96ee13184)
(cherry picked from commit 3b225f893ef036bf6c39389769a2c4e996a17b58)
---
src/devices/wifi/nm-device-wifi.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c
index 17f5b14..a0afb0e 100644
--- a/src/devices/wifi/nm-device-wifi.c
+++ b/src/devices/wifi/nm-device-wifi.c
@@ -1760,6 +1760,7 @@ need_new_8021x_secrets (NMDeviceWifi *self,
static gboolean
need_new_wpa_psk (NMDeviceWifi *self,
guint32 old_state,
+ gint disconnect_reason,
const char **setting_name)
{
NMSettingWirelessSecurity *s_wsec;
@@ -1780,6 +1781,15 @@ need_new_wpa_psk (NMDeviceWifi *self,
key_mgmt = nm_setting_wireless_security_get_key_mgmt (s_wsec);
if (g_strcmp0 (key_mgmt, "wpa-psk") == 0) {
+ /* -4 (locally-generated WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY) usually
+ * means the driver missed beacons from the AP. This usually happens
+ * due to driver bugs or faulty power-save management. It doesn't
+ * indicate that the PSK is wrong.
+ */
+ #define LOCAL_WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY -4
+ if (disconnect_reason == LOCAL_WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY)
+ return FALSE;
+
*setting_name = NM_SETTING_WIRELESS_SECURITY_SETTING_NAME;
return TRUE;
}
@@ -1805,7 +1815,7 @@ handle_8021x_or_psk_auth_fail (NMDeviceWifi *self,
g_return_val_if_fail (req != NULL, FALSE);
if ( need_new_8021x_secrets (self, old_state, &setting_name)
- || need_new_wpa_psk (self, old_state, &setting_name)) {
+ || need_new_wpa_psk (self, old_state, disconnect_reason, &setting_name)) {
nm_act_request_clear_secrets (req);
--
2.9.3
From 1f41e8bcb91daf3618bd11afa2767d15d4416b7d Mon Sep 17 00:00:00 2001
From: Beniamino Galvani <bgalvani@redhat.com>
Date: Mon, 22 Aug 2016 21:37:21 +0200
Subject: [PATCH 14/19] libnm: make waiting objects fail when an object
initialization fails
Previously, when the load of an object failed and there were other
objects waiting for it, those objects would remain waiting
forever. Make them fail as well.
(cherry picked from commit f4a0ab757fca8c9ea7900f6259e8ca51a4b0a571)
(cherry picked from commit e4d263f1dbaa71d6b3a89cc388eb27b5694c816c)
---
libnm/nm-object.c | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/libnm/nm-object.c b/libnm/nm-object.c
index 3b41041..337ca69 100644
--- a/libnm/nm-object.c
+++ b/libnm/nm-object.c
@@ -488,14 +488,29 @@ create_async_complete (GObject *object, NMObjectTypeAsyncData *async_data)
static void
create_async_inited (GObject *object, GAsyncResult *result, gpointer user_data)
{
+ NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (object);
+ NMObjectPrivate *odata_priv;
NMObjectTypeAsyncData *async_data = user_data;
GError *error = NULL;
+ ObjectCreatedData *odata;
- NM_OBJECT_GET_PRIVATE (object)->inited = TRUE;
+ priv->inited = TRUE;
if (!g_async_initable_init_finish (G_ASYNC_INITABLE (object), result, &error)) {
dbgmsg ("Could not create object for %s: %s",
nm_object_get_path (NM_OBJECT (object)),
error->message);
+
+ while (priv->waiters) {
+ odata = priv->waiters->data;
+ odata_priv = NM_OBJECT_GET_PRIVATE (odata->self);
+
+ priv->waiters = g_slist_remove (priv->waiters, odata);
+ if (!odata_priv->reload_error)
+ odata_priv->reload_error = g_error_copy (error);
+ odata_priv->reload_remaining--;
+ reload_complete (odata->self, FALSE);
+ }
+
g_error_free (error);
g_clear_object (&object);
}
@@ -503,15 +518,13 @@ create_async_inited (GObject *object, GAsyncResult *result, gpointer user_data)
create_async_complete (object, async_data);
if (object) {
- NMObjectPrivate *priv = NM_OBJECT_GET_PRIVATE (object);
-
/* There are some object properties whose creation couldn't proceed
* because it depended on this object. */
while (priv->waiters) {
- ObjectCreatedData *odata = priv->waiters->data;
-
+ odata = priv->waiters->data;
priv->waiters = g_slist_remove (priv->waiters, odata);
object_property_maybe_complete (odata);
+
}
}
}
--
2.9.3
From c710a8209890dce85894868d7afa0c3a29903450 Mon Sep 17 00:00:00 2001
From: Thomas Haller <thaller@redhat.com>
Date: Wed, 4 Jan 2017 09:30:38 +0100
Subject: [PATCH 15/19] docs: fix handling enums without explicit numeric value
in "tools/enums-to-docbook.pl"
Previously, an enum that didn't explicitly specify a numeric value
would wrongly start counting at 1.
E.g.
typedef enum {
MY_VAL,
} Name;
would result in documentation with MY_VAL=1.
https://bugzilla.gnome.org/show_bug.cgi?id=776848
(cherry picked from commit 36ec46e8f86db03a9777c5885ff685ad8cf74957)
(cherry picked from commit 26f0d68e826b9936d82446b451cc0bb69d336685)
(cherry picked from commit 70d14820e696e34429f71efe164b8024930be19e)
---
tools/enums-to-docbook.pl | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/tools/enums-to-docbook.pl b/tools/enums-to-docbook.pl
index d3d8c33..845598a 100755
--- a/tools/enums-to-docbook.pl
+++ b/tools/enums-to-docbook.pl
@@ -62,8 +62,11 @@ sub inc
{
my $val = shift;
- if ($val =~ /^\d+$/) {
+ if ($val =~ /^-?\d+$/) {
my $len = length $val;
+ if ($val =~ /^-/ && ($val + 1 == 0)) {
+ $len = $len - 1
+ }
return sprintf "%0${len}d", $val + 1;
} elsif ($val =~ /^0x(.+)$/) {
my $len = length $1;
@@ -117,7 +120,7 @@ if (/^\/\*\*$/) {
$choice = undef;
} elsif (/^typedef enum/) {
# Start of an enum
- $val = 0;
+ $val = -1;
} elsif (/^\s+(\S+)\s+=\s+([^,\s]+)/) {
# A choice with a literal value
next unless @choices;
--
2.9.3
From 4040bbb42041435bd43d12b9f197555270bf1a2a Mon Sep 17 00:00:00 2001
From: Thomas Haller <thaller@redhat.com>
Date: Wed, 4 Jan 2017 09:10:10 +0100
Subject: [PATCH 16/19] libnm: explicitly set enum values in public
nm-dbus-interface.h headers
Previously, due to a bug in "tools/enums-to-docbook.pl", enum values
without explicit numeric value were wrongly parsed. That is fixed,
but still explicitly set the value in the public header.
(cherry picked from commit 9d2207b46d0f2808e9a59712862faf5c59d9fa86)
(cherry picked from commit 4369f102f6874f879c9c6ec0325056be480279c6)
(cherry picked from commit 205f4ce025378469acb9ec3eb5fab459e748f6d1)
---
libnm-core/nm-dbus-interface.h | 206 ++++++++++++++++++++---------------------
libnm-util/NetworkManager.h | 162 ++++++++++++++++----------------
2 files changed, 184 insertions(+), 184 deletions(-)
diff --git a/libnm-core/nm-dbus-interface.h b/libnm-core/nm-dbus-interface.h
index 1e0fbe6..e334526 100644
--- a/libnm-core/nm-dbus-interface.h
+++ b/libnm-core/nm-dbus-interface.h
@@ -103,7 +103,7 @@ typedef enum {
NM_STATE_CONNECTING = 40,
NM_STATE_CONNECTED_LOCAL = 50,
NM_STATE_CONNECTED_SITE = 60,
- NM_STATE_CONNECTED_GLOBAL = 70
+ NM_STATE_CONNECTED_GLOBAL = 70,
} NMState;
/**
@@ -118,11 +118,11 @@ typedef enum {
* appears to be able to reach the full Internet.
*/
typedef enum {
- NM_CONNECTIVITY_UNKNOWN,
- NM_CONNECTIVITY_NONE,
- NM_CONNECTIVITY_PORTAL,
- NM_CONNECTIVITY_LIMITED,
- NM_CONNECTIVITY_FULL
+ NM_CONNECTIVITY_UNKNOWN = 0,
+ NM_CONNECTIVITY_NONE = 1,
+ NM_CONNECTIVITY_PORTAL = 2,
+ NM_CONNECTIVITY_LIMITED = 3,
+ NM_CONNECTIVITY_FULL = 4,
} NMConnectivityState;
/**
@@ -237,7 +237,7 @@ typedef enum { /*< flags >*/
**/
typedef enum { /*< underscore_name=nm_802_11_ap_flags, flags >*/
NM_802_11_AP_FLAGS_NONE = 0x00000000,
- NM_802_11_AP_FLAGS_PRIVACY = 0x00000001
+ NM_802_11_AP_FLAGS_PRIVACY = 0x00000001,
} NM80211ApFlags;
/**
@@ -276,7 +276,7 @@ typedef enum { /*< underscore_name=nm_802_11_ap_security_flags, flags >*/
NM_802_11_AP_SEC_GROUP_TKIP = 0x00000040,
NM_802_11_AP_SEC_GROUP_CCMP = 0x00000080,
NM_802_11_AP_SEC_KEY_MGMT_PSK = 0x00000100,
- NM_802_11_AP_SEC_KEY_MGMT_802_1X = 0x00000200
+ NM_802_11_AP_SEC_KEY_MGMT_802_1X = 0x00000200,
} NM80211ApSecurityFlags;
/**
@@ -296,9 +296,9 @@ typedef enum { /*< underscore_name=nm_802_11_ap_security_flags, flags >*/
**/
typedef enum { /*< underscore_name=nm_802_11_mode >*/
NM_802_11_MODE_UNKNOWN = 0,
- NM_802_11_MODE_ADHOC,
- NM_802_11_MODE_INFRA,
- NM_802_11_MODE_AP
+ NM_802_11_MODE_ADHOC = 1,
+ NM_802_11_MODE_INFRA = 2,
+ NM_802_11_MODE_AP = 3,
} NM80211Mode;
/**
@@ -353,7 +353,7 @@ typedef enum {
NM_WIMAX_NSP_NETWORK_TYPE_UNKNOWN = 0,
NM_WIMAX_NSP_NETWORK_TYPE_HOME = 1,
NM_WIMAX_NSP_NETWORK_TYPE_PARTNER = 2,
- NM_WIMAX_NSP_NETWORK_TYPE_ROAMING_PARTNER = 3
+ NM_WIMAX_NSP_NETWORK_TYPE_ROAMING_PARTNER = 3,
} NMWimaxNspNetworkType;
/**
@@ -407,7 +407,7 @@ typedef enum {
NM_DEVICE_STATE_SECONDARIES = 90,
NM_DEVICE_STATE_ACTIVATED = 100,
NM_DEVICE_STATE_DEACTIVATING = 110,
- NM_DEVICE_STATE_FAILED = 120
+ NM_DEVICE_STATE_FAILED = 120,
} NMDeviceState;
/**
@@ -479,69 +479,69 @@ typedef enum {
* Device state change reason codes
*/
typedef enum {
- NM_DEVICE_STATE_REASON_NONE = 0,
- NM_DEVICE_STATE_REASON_UNKNOWN = 1,
- NM_DEVICE_STATE_REASON_NOW_MANAGED = 2,
- NM_DEVICE_STATE_REASON_NOW_UNMANAGED = 3,
- NM_DEVICE_STATE_REASON_CONFIG_FAILED = 4,
- NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE = 5,
- NM_DEVICE_STATE_REASON_IP_CONFIG_EXPIRED = 6,
- NM_DEVICE_STATE_REASON_NO_SECRETS = 7,
- NM_DEVICE_STATE_REASON_SUPPLICANT_DISCONNECT = 8,
- NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED = 9,
- NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED = 10,
- NM_DEVICE_STATE_REASON_SUPPLICANT_TIMEOUT = 11,
- NM_DEVICE_STATE_REASON_PPP_START_FAILED = 12,
- NM_DEVICE_STATE_REASON_PPP_DISCONNECT = 13,
- NM_DEVICE_STATE_REASON_PPP_FAILED = 14,
- NM_DEVICE_STATE_REASON_DHCP_START_FAILED = 15,
- NM_DEVICE_STATE_REASON_DHCP_ERROR = 16,
- NM_DEVICE_STATE_REASON_DHCP_FAILED = 17,
- NM_DEVICE_STATE_REASON_SHARED_START_FAILED = 18,
- NM_DEVICE_STATE_REASON_SHARED_FAILED = 19,
- NM_DEVICE_STATE_REASON_AUTOIP_START_FAILED = 20,
- NM_DEVICE_STATE_REASON_AUTOIP_ERROR = 21,
- NM_DEVICE_STATE_REASON_AUTOIP_FAILED = 22,
- NM_DEVICE_STATE_REASON_MODEM_BUSY = 23,
- NM_DEVICE_STATE_REASON_MODEM_NO_DIAL_TONE = 24,
- NM_DEVICE_STATE_REASON_MODEM_NO_CARRIER = 25,
- NM_DEVICE_STATE_REASON_MODEM_DIAL_TIMEOUT = 26,
- NM_DEVICE_STATE_REASON_MODEM_DIAL_FAILED = 27,
- NM_DEVICE_STATE_REASON_MODEM_INIT_FAILED = 28,
- NM_DEVICE_STATE_REASON_GSM_APN_FAILED = 29,
+ NM_DEVICE_STATE_REASON_NONE = 0,
+ NM_DEVICE_STATE_REASON_UNKNOWN = 1,
+ NM_DEVICE_STATE_REASON_NOW_MANAGED = 2,
+ NM_DEVICE_STATE_REASON_NOW_UNMANAGED = 3,
+ NM_DEVICE_STATE_REASON_CONFIG_FAILED = 4,
+ NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE = 5,
+ NM_DEVICE_STATE_REASON_IP_CONFIG_EXPIRED = 6,
+ NM_DEVICE_STATE_REASON_NO_SECRETS = 7,
+ NM_DEVICE_STATE_REASON_SUPPLICANT_DISCONNECT = 8,
+ NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED = 9,
+ NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED = 10,
+ NM_DEVICE_STATE_REASON_SUPPLICANT_TIMEOUT = 11,
+ NM_DEVICE_STATE_REASON_PPP_START_FAILED = 12,
+ NM_DEVICE_STATE_REASON_PPP_DISCONNECT = 13,
+ NM_DEVICE_STATE_REASON_PPP_FAILED = 14,
+ NM_DEVICE_STATE_REASON_DHCP_START_FAILED = 15,
+ NM_DEVICE_STATE_REASON_DHCP_ERROR = 16,
+ NM_DEVICE_STATE_REASON_DHCP_FAILED = 17,
+ NM_DEVICE_STATE_REASON_SHARED_START_FAILED = 18,
+ NM_DEVICE_STATE_REASON_SHARED_FAILED = 19,
+ NM_DEVICE_STATE_REASON_AUTOIP_START_FAILED = 20,
+ NM_DEVICE_STATE_REASON_AUTOIP_ERROR = 21,
+ NM_DEVICE_STATE_REASON_AUTOIP_FAILED = 22,
+ NM_DEVICE_STATE_REASON_MODEM_BUSY = 23,
+ NM_DEVICE_STATE_REASON_MODEM_NO_DIAL_TONE = 24,
+ NM_DEVICE_STATE_REASON_MODEM_NO_CARRIER = 25,
+ NM_DEVICE_STATE_REASON_MODEM_DIAL_TIMEOUT = 26,
+ NM_DEVICE_STATE_REASON_MODEM_DIAL_FAILED = 27,
+ NM_DEVICE_STATE_REASON_MODEM_INIT_FAILED = 28,
+ NM_DEVICE_STATE_REASON_GSM_APN_FAILED = 29,
NM_DEVICE_STATE_REASON_GSM_REGISTRATION_NOT_SEARCHING = 30,
- NM_DEVICE_STATE_REASON_GSM_REGISTRATION_DENIED = 31,
- NM_DEVICE_STATE_REASON_GSM_REGISTRATION_TIMEOUT = 32,
- NM_DEVICE_STATE_REASON_GSM_REGISTRATION_FAILED = 33,
- NM_DEVICE_STATE_REASON_GSM_PIN_CHECK_FAILED = 34,
- NM_DEVICE_STATE_REASON_FIRMWARE_MISSING = 35,
- NM_DEVICE_STATE_REASON_REMOVED = 36,
- NM_DEVICE_STATE_REASON_SLEEPING = 37,
- NM_DEVICE_STATE_REASON_CONNECTION_REMOVED = 38,
- NM_DEVICE_STATE_REASON_USER_REQUESTED = 39,
- NM_DEVICE_STATE_REASON_CARRIER = 40,
- NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED = 41,
- NM_DEVICE_STATE_REASON_SUPPLICANT_AVAILABLE = 42,
- NM_DEVICE_STATE_REASON_MODEM_NOT_FOUND = 43,
- NM_DEVICE_STATE_REASON_BT_FAILED = 44,
- NM_DEVICE_STATE_REASON_GSM_SIM_NOT_INSERTED = 45,
- NM_DEVICE_STATE_REASON_GSM_SIM_PIN_REQUIRED = 46,
- NM_DEVICE_STATE_REASON_GSM_SIM_PUK_REQUIRED = 47,
- NM_DEVICE_STATE_REASON_GSM_SIM_WRONG = 48,
- NM_DEVICE_STATE_REASON_INFINIBAND_MODE = 49,
- NM_DEVICE_STATE_REASON_DEPENDENCY_FAILED = 50,
- NM_DEVICE_STATE_REASON_BR2684_FAILED = 51,
- NM_DEVICE_STATE_REASON_MODEM_MANAGER_UNAVAILABLE = 52,
- NM_DEVICE_STATE_REASON_SSID_NOT_FOUND = 53,
- NM_DEVICE_STATE_REASON_SECONDARY_CONNECTION_FAILED = 54,
- NM_DEVICE_STATE_REASON_DCB_FCOE_FAILED = 55,
- NM_DEVICE_STATE_REASON_TEAMD_CONTROL_FAILED = 56,
- NM_DEVICE_STATE_REASON_MODEM_FAILED = 57,
- NM_DEVICE_STATE_REASON_MODEM_AVAILABLE = 58,
- NM_DEVICE_STATE_REASON_SIM_PIN_INCORRECT = 59,
- NM_DEVICE_STATE_REASON_NEW_ACTIVATION = 60,
- NM_DEVICE_STATE_REASON_PARENT_CHANGED = 61,
- NM_DEVICE_STATE_REASON_PARENT_MANAGED_CHANGED = 62,
+ NM_DEVICE_STATE_REASON_GSM_REGISTRATION_DENIED = 31,
+ NM_DEVICE_STATE_REASON_GSM_REGISTRATION_TIMEOUT = 32,
+ NM_DEVICE_STATE_REASON_GSM_REGISTRATION_FAILED = 33,
+ NM_DEVICE_STATE_REASON_GSM_PIN_CHECK_FAILED = 34,
+ NM_DEVICE_STATE_REASON_FIRMWARE_MISSING = 35,
+ NM_DEVICE_STATE_REASON_REMOVED = 36,
+ NM_DEVICE_STATE_REASON_SLEEPING = 37,
+ NM_DEVICE_STATE_REASON_CONNECTION_REMOVED = 38,
+ NM_DEVICE_STATE_REASON_USER_REQUESTED = 39,
+ NM_DEVICE_STATE_REASON_CARRIER = 40,
+ NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED = 41,
+ NM_DEVICE_STATE_REASON_SUPPLICANT_AVAILABLE = 42,
+ NM_DEVICE_STATE_REASON_MODEM_NOT_FOUND = 43,
+ NM_DEVICE_STATE_REASON_BT_FAILED = 44,
+ NM_DEVICE_STATE_REASON_GSM_SIM_NOT_INSERTED = 45,
+ NM_DEVICE_STATE_REASON_GSM_SIM_PIN_REQUIRED = 46,
+ NM_DEVICE_STATE_REASON_GSM_SIM_PUK_REQUIRED = 47,
+ NM_DEVICE_STATE_REASON_GSM_SIM_WRONG = 48,
+ NM_DEVICE_STATE_REASON_INFINIBAND_MODE = 49,
+ NM_DEVICE_STATE_REASON_DEPENDENCY_FAILED = 50,
+ NM_DEVICE_STATE_REASON_BR2684_FAILED = 51,
+ NM_DEVICE_STATE_REASON_MODEM_MANAGER_UNAVAILABLE = 52,
+ NM_DEVICE_STATE_REASON_SSID_NOT_FOUND = 53,
+ NM_DEVICE_STATE_REASON_SECONDARY_CONNECTION_FAILED = 54,
+ NM_DEVICE_STATE_REASON_DCB_FCOE_FAILED = 55,
+ NM_DEVICE_STATE_REASON_TEAMD_CONTROL_FAILED = 56,
+ NM_DEVICE_STATE_REASON_MODEM_FAILED = 57,
+ NM_DEVICE_STATE_REASON_MODEM_AVAILABLE = 58,
+ NM_DEVICE_STATE_REASON_SIM_PIN_INCORRECT = 59,
+ NM_DEVICE_STATE_REASON_NEW_ACTIVATION = 60,
+ NM_DEVICE_STATE_REASON_PARENT_CHANGED = 61,
+ NM_DEVICE_STATE_REASON_PARENT_MANAGED_CHANGED = 62,
} NMDeviceStateReason;
/**
@@ -578,11 +578,11 @@ typedef enum {
* network.
**/
typedef enum {
- NM_ACTIVE_CONNECTION_STATE_UNKNOWN = 0,
- NM_ACTIVE_CONNECTION_STATE_ACTIVATING,
- NM_ACTIVE_CONNECTION_STATE_ACTIVATED,
- NM_ACTIVE_CONNECTION_STATE_DEACTIVATING,
- NM_ACTIVE_CONNECTION_STATE_DEACTIVATED
+ NM_ACTIVE_CONNECTION_STATE_UNKNOWN = 0,
+ NM_ACTIVE_CONNECTION_STATE_ACTIVATING = 1,
+ NM_ACTIVE_CONNECTION_STATE_ACTIVATED = 2,
+ NM_ACTIVE_CONNECTION_STATE_DEACTIVATING = 3,
+ NM_ACTIVE_CONNECTION_STATE_DEACTIVATED = 4,
} NMActiveConnectionState;
/**
@@ -609,14 +609,14 @@ typedef enum {
* #NMSecretAgentGetSecretsFlags values modify the behavior of a GetSecrets request.
*/
typedef enum { /*< flags >*/
- NM_SECRET_AGENT_GET_SECRETS_FLAG_NONE = 0x0,
+ NM_SECRET_AGENT_GET_SECRETS_FLAG_NONE = 0x0,
NM_SECRET_AGENT_GET_SECRETS_FLAG_ALLOW_INTERACTION = 0x1,
- NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW = 0x2,
- NM_SECRET_AGENT_GET_SECRETS_FLAG_USER_REQUESTED = 0x4,
+ NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW = 0x2,
+ NM_SECRET_AGENT_GET_SECRETS_FLAG_USER_REQUESTED = 0x4,
/* Internal to NM; not part of the D-Bus API */
- NM_SECRET_AGENT_GET_SECRETS_FLAG_ONLY_SYSTEM = 0x80000000,
- NM_SECRET_AGENT_GET_SECRETS_FLAG_NO_ERRORS = 0x40000000,
+ NM_SECRET_AGENT_GET_SECRETS_FLAG_ONLY_SYSTEM = 0x80000000,
+ NM_SECRET_AGENT_GET_SECRETS_FLAG_NO_ERRORS = 0x40000000,
} NMSecretAgentGetSecretsFlags;
/**
@@ -629,33 +629,33 @@ typedef enum { /*< flags >*/
* #NMSecretAgentCapabilities indicate various capabilities of the agent.
*/
typedef enum /*< flags >*/ {
- NM_SECRET_AGENT_CAPABILITY_NONE = 0x0,
+ NM_SECRET_AGENT_CAPABILITY_NONE = 0x0,
NM_SECRET_AGENT_CAPABILITY_VPN_HINTS = 0x1,
/* boundary value */
- NM_SECRET_AGENT_CAPABILITY_LAST = NM_SECRET_AGENT_CAPABILITY_VPN_HINTS
+ NM_SECRET_AGENT_CAPABILITY_LAST = NM_SECRET_AGENT_CAPABILITY_VPN_HINTS,
} NMSecretAgentCapabilities;
#ifndef NM_VERSION_H
#undef NM_AVAILABLE_IN_1_2
#endif
-#define NM_LLDP_ATTR_DESTINATION "destination"
-#define NM_LLDP_ATTR_CHASSIS_ID_TYPE "chassis-id-type"
-#define NM_LLDP_ATTR_CHASSIS_ID "chassis-id"
-#define NM_LLDP_ATTR_PORT_ID_TYPE "port-id-type"
-#define NM_LLDP_ATTR_PORT_ID "port-id"
-#define NM_LLDP_ATTR_PORT_DESCRIPTION "port-description"
-#define NM_LLDP_ATTR_SYSTEM_NAME "system-name"
-#define NM_LLDP_ATTR_SYSTEM_DESCRIPTION "system-description"
-#define NM_LLDP_ATTR_SYSTEM_CAPABILITIES "system-capabilities"
-#define NM_LLDP_ATTR_IEEE_802_1_PVID "ieee-802-1-pvid"
-#define NM_LLDP_ATTR_IEEE_802_1_PPVID "ieee-802-1-ppvid"
-#define NM_LLDP_ATTR_IEEE_802_1_PPVID_FLAGS "ieee-802-1-ppvid-flags"
-#define NM_LLDP_ATTR_IEEE_802_1_VID "ieee-802-1-vid"
-#define NM_LLDP_ATTR_IEEE_802_1_VLAN_NAME "ieee-802-1-vlan-name"
-
-#define NM_LLDP_DEST_NEAREST_BRIDGE "nearest-bridge"
+#define NM_LLDP_ATTR_DESTINATION "destination"
+#define NM_LLDP_ATTR_CHASSIS_ID_TYPE "chassis-id-type"
+#define NM_LLDP_ATTR_CHASSIS_ID "chassis-id"
+#define NM_LLDP_ATTR_PORT_ID_TYPE "port-id-type"
+#define NM_LLDP_ATTR_PORT_ID "port-id"
+#define NM_LLDP_ATTR_PORT_DESCRIPTION "port-description"
+#define NM_LLDP_ATTR_SYSTEM_NAME "system-name"
+#define NM_LLDP_ATTR_SYSTEM_DESCRIPTION "system-description"
+#define NM_LLDP_ATTR_SYSTEM_CAPABILITIES "system-capabilities"
+#define NM_LLDP_ATTR_IEEE_802_1_PVID "ieee-802-1-pvid"
+#define NM_LLDP_ATTR_IEEE_802_1_PPVID "ieee-802-1-ppvid"
+#define NM_LLDP_ATTR_IEEE_802_1_PPVID_FLAGS "ieee-802-1-ppvid-flags"
+#define NM_LLDP_ATTR_IEEE_802_1_VID "ieee-802-1-vid"
+#define NM_LLDP_ATTR_IEEE_802_1_VLAN_NAME "ieee-802-1-vlan-name"
+
+#define NM_LLDP_DEST_NEAREST_BRIDGE "nearest-bridge"
#define NM_LLDP_DEST_NEAREST_NON_TPMR_BRIDGE "nearest-non-tpmr-bridge"
#define NM_LLDP_DEST_NEAREST_CUSTOMER_BRIDGE "nearest-customer-bridge"
diff --git a/libnm-util/NetworkManager.h b/libnm-util/NetworkManager.h
index 9053fad..77c09ae 100644
--- a/libnm-util/NetworkManager.h
+++ b/libnm-util/NetworkManager.h
@@ -101,7 +101,7 @@ typedef enum {
NM_STATE_CONNECTING = 40,
NM_STATE_CONNECTED_LOCAL = 50,
NM_STATE_CONNECTED_SITE = 60,
- NM_STATE_CONNECTED_GLOBAL = 70
+ NM_STATE_CONNECTED_GLOBAL = 70,
} NMState;
/* For backwards compat */
@@ -121,11 +121,11 @@ typedef enum {
* Since: 0.9.8.6
*/
typedef enum {
- NM_CONNECTIVITY_UNKNOWN,
- NM_CONNECTIVITY_NONE,
- NM_CONNECTIVITY_PORTAL,
- NM_CONNECTIVITY_LIMITED,
- NM_CONNECTIVITY_FULL
+ NM_CONNECTIVITY_UNKNOWN = 0,
+ NM_CONNECTIVITY_NONE = 1,
+ NM_CONNECTIVITY_PORTAL = 2,
+ NM_CONNECTIVITY_LIMITED = 3,
+ NM_CONNECTIVITY_FULL = 4,
} NMConnectivityState;
/**
@@ -240,7 +240,7 @@ typedef enum { /*< flags >*/
**/
typedef enum { /*< underscore_name=nm_802_11_ap_flags, flags >*/
NM_802_11_AP_FLAGS_NONE = 0x00000000,
- NM_802_11_AP_FLAGS_PRIVACY = 0x00000001
+ NM_802_11_AP_FLAGS_PRIVACY = 0x00000001,
} NM80211ApFlags;
/**
@@ -279,7 +279,7 @@ typedef enum { /*< underscore_name=nm_802_11_ap_security_flags, flags >*/
NM_802_11_AP_SEC_GROUP_TKIP = 0x00000040,
NM_802_11_AP_SEC_GROUP_CCMP = 0x00000080,
NM_802_11_AP_SEC_KEY_MGMT_PSK = 0x00000100,
- NM_802_11_AP_SEC_KEY_MGMT_802_1X = 0x00000200
+ NM_802_11_AP_SEC_KEY_MGMT_802_1X = 0x00000200,
} NM80211ApSecurityFlags;
/**
@@ -299,9 +299,9 @@ typedef enum { /*< underscore_name=nm_802_11_ap_security_flags, flags >*/
**/
typedef enum { /*< underscore_name=nm_802_11_mode >*/
NM_802_11_MODE_UNKNOWN = 0,
- NM_802_11_MODE_ADHOC,
- NM_802_11_MODE_INFRA,
- NM_802_11_MODE_AP
+ NM_802_11_MODE_ADHOC = 1,
+ NM_802_11_MODE_INFRA = 2,
+ NM_802_11_MODE_AP = 3,
} NM80211Mode;
/**
@@ -395,7 +395,7 @@ typedef enum {
NM_DEVICE_STATE_SECONDARIES = 90,
NM_DEVICE_STATE_ACTIVATED = 100,
NM_DEVICE_STATE_DEACTIVATING = 110,
- NM_DEVICE_STATE_FAILED = 120
+ NM_DEVICE_STATE_FAILED = 120,
} NMDeviceState;
@@ -468,71 +468,71 @@ typedef enum {
* Device state change reason codes
*/
typedef enum {
- NM_DEVICE_STATE_REASON_NONE = 0,
- NM_DEVICE_STATE_REASON_UNKNOWN = 1,
- NM_DEVICE_STATE_REASON_NOW_MANAGED = 2,
- NM_DEVICE_STATE_REASON_NOW_UNMANAGED = 3,
- NM_DEVICE_STATE_REASON_CONFIG_FAILED = 4,
- NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE = 5,
- NM_DEVICE_STATE_REASON_IP_CONFIG_EXPIRED = 6,
- NM_DEVICE_STATE_REASON_NO_SECRETS = 7,
- NM_DEVICE_STATE_REASON_SUPPLICANT_DISCONNECT = 8,
- NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED = 9,
- NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED = 10,
- NM_DEVICE_STATE_REASON_SUPPLICANT_TIMEOUT = 11,
- NM_DEVICE_STATE_REASON_PPP_START_FAILED = 12,
- NM_DEVICE_STATE_REASON_PPP_DISCONNECT = 13,
- NM_DEVICE_STATE_REASON_PPP_FAILED = 14,
- NM_DEVICE_STATE_REASON_DHCP_START_FAILED = 15,
- NM_DEVICE_STATE_REASON_DHCP_ERROR = 16,
- NM_DEVICE_STATE_REASON_DHCP_FAILED = 17,
- NM_DEVICE_STATE_REASON_SHARED_START_FAILED = 18,
- NM_DEVICE_STATE_REASON_SHARED_FAILED = 19,
- NM_DEVICE_STATE_REASON_AUTOIP_START_FAILED = 20,
- NM_DEVICE_STATE_REASON_AUTOIP_ERROR = 21,
- NM_DEVICE_STATE_REASON_AUTOIP_FAILED = 22,
- NM_DEVICE_STATE_REASON_MODEM_BUSY = 23,
- NM_DEVICE_STATE_REASON_MODEM_NO_DIAL_TONE = 24,
- NM_DEVICE_STATE_REASON_MODEM_NO_CARRIER = 25,
- NM_DEVICE_STATE_REASON_MODEM_DIAL_TIMEOUT = 26,
- NM_DEVICE_STATE_REASON_MODEM_DIAL_FAILED = 27,
- NM_DEVICE_STATE_REASON_MODEM_INIT_FAILED = 28,
- NM_DEVICE_STATE_REASON_GSM_APN_FAILED = 29,
+ NM_DEVICE_STATE_REASON_NONE = 0,
+ NM_DEVICE_STATE_REASON_UNKNOWN = 1,
+ NM_DEVICE_STATE_REASON_NOW_MANAGED = 2,
+ NM_DEVICE_STATE_REASON_NOW_UNMANAGED = 3,
+ NM_DEVICE_STATE_REASON_CONFIG_FAILED = 4,
+ NM_DEVICE_STATE_REASON_IP_CONFIG_UNAVAILABLE = 5,
+ NM_DEVICE_STATE_REASON_IP_CONFIG_EXPIRED = 6,
+ NM_DEVICE_STATE_REASON_NO_SECRETS = 7,
+ NM_DEVICE_STATE_REASON_SUPPLICANT_DISCONNECT = 8,
+ NM_DEVICE_STATE_REASON_SUPPLICANT_CONFIG_FAILED = 9,
+ NM_DEVICE_STATE_REASON_SUPPLICANT_FAILED = 10,
+ NM_DEVICE_STATE_REASON_SUPPLICANT_TIMEOUT = 11,
+ NM_DEVICE_STATE_REASON_PPP_START_FAILED = 12,
+ NM_DEVICE_STATE_REASON_PPP_DISCONNECT = 13,
+ NM_DEVICE_STATE_REASON_PPP_FAILED = 14,
+ NM_DEVICE_STATE_REASON_DHCP_START_FAILED = 15,
+ NM_DEVICE_STATE_REASON_DHCP_ERROR = 16,
+ NM_DEVICE_STATE_REASON_DHCP_FAILED = 17,
+ NM_DEVICE_STATE_REASON_SHARED_START_FAILED = 18,
+ NM_DEVICE_STATE_REASON_SHARED_FAILED = 19,
+ NM_DEVICE_STATE_REASON_AUTOIP_START_FAILED = 20,
+ NM_DEVICE_STATE_REASON_AUTOIP_ERROR = 21,
+ NM_DEVICE_STATE_REASON_AUTOIP_FAILED = 22,
+ NM_DEVICE_STATE_REASON_MODEM_BUSY = 23,
+ NM_DEVICE_STATE_REASON_MODEM_NO_DIAL_TONE = 24,
+ NM_DEVICE_STATE_REASON_MODEM_NO_CARRIER = 25,
+ NM_DEVICE_STATE_REASON_MODEM_DIAL_TIMEOUT = 26,
+ NM_DEVICE_STATE_REASON_MODEM_DIAL_FAILED = 27,
+ NM_DEVICE_STATE_REASON_MODEM_INIT_FAILED = 28,
+ NM_DEVICE_STATE_REASON_GSM_APN_FAILED = 29,
NM_DEVICE_STATE_REASON_GSM_REGISTRATION_NOT_SEARCHING = 30,
- NM_DEVICE_STATE_REASON_GSM_REGISTRATION_DENIED = 31,
- NM_DEVICE_STATE_REASON_GSM_REGISTRATION_TIMEOUT = 32,
- NM_DEVICE_STATE_REASON_GSM_REGISTRATION_FAILED = 33,
- NM_DEVICE_STATE_REASON_GSM_PIN_CHECK_FAILED = 34,
- NM_DEVICE_STATE_REASON_FIRMWARE_MISSING = 35,
- NM_DEVICE_STATE_REASON_REMOVED = 36,
- NM_DEVICE_STATE_REASON_SLEEPING = 37,
- NM_DEVICE_STATE_REASON_CONNECTION_REMOVED = 38,
- NM_DEVICE_STATE_REASON_USER_REQUESTED = 39,
- NM_DEVICE_STATE_REASON_CARRIER = 40,
- NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED = 41,
- NM_DEVICE_STATE_REASON_SUPPLICANT_AVAILABLE = 42,
- NM_DEVICE_STATE_REASON_MODEM_NOT_FOUND = 43,
- NM_DEVICE_STATE_REASON_BT_FAILED = 44,
- NM_DEVICE_STATE_REASON_GSM_SIM_NOT_INSERTED = 45,
- NM_DEVICE_STATE_REASON_GSM_SIM_PIN_REQUIRED = 46,
- NM_DEVICE_STATE_REASON_GSM_SIM_PUK_REQUIRED = 47,
- NM_DEVICE_STATE_REASON_GSM_SIM_WRONG = 48,
- NM_DEVICE_STATE_REASON_INFINIBAND_MODE = 49,
- NM_DEVICE_STATE_REASON_DEPENDENCY_FAILED = 50,
- NM_DEVICE_STATE_REASON_BR2684_FAILED = 51,
- NM_DEVICE_STATE_REASON_MODEM_MANAGER_UNAVAILABLE = 52,
- NM_DEVICE_STATE_REASON_SSID_NOT_FOUND = 53,
- NM_DEVICE_STATE_REASON_SECONDARY_CONNECTION_FAILED = 54,
- NM_DEVICE_STATE_REASON_DCB_FCOE_FAILED = 55,
- NM_DEVICE_STATE_REASON_TEAMD_CONTROL_FAILED = 56,
- NM_DEVICE_STATE_REASON_MODEM_FAILED = 57,
- NM_DEVICE_STATE_REASON_MODEM_AVAILABLE = 58,
- NM_DEVICE_STATE_REASON_SIM_PIN_INCORRECT = 59,
- NM_DEVICE_STATE_REASON_NEW_ACTIVATION = 60,
- NM_DEVICE_STATE_REASON_PARENT_CHANGED = 61,
- NM_DEVICE_STATE_REASON_PARENT_MANAGED_CHANGED = 62,
-
- NM_DEVICE_STATE_REASON_LAST = 0xFFFF
+ NM_DEVICE_STATE_REASON_GSM_REGISTRATION_DENIED = 31,
+ NM_DEVICE_STATE_REASON_GSM_REGISTRATION_TIMEOUT = 32,
+ NM_DEVICE_STATE_REASON_GSM_REGISTRATION_FAILED = 33,
+ NM_DEVICE_STATE_REASON_GSM_PIN_CHECK_FAILED = 34,
+ NM_DEVICE_STATE_REASON_FIRMWARE_MISSING = 35,
+ NM_DEVICE_STATE_REASON_REMOVED = 36,
+ NM_DEVICE_STATE_REASON_SLEEPING = 37,
+ NM_DEVICE_STATE_REASON_CONNECTION_REMOVED = 38,
+ NM_DEVICE_STATE_REASON_USER_REQUESTED = 39,
+ NM_DEVICE_STATE_REASON_CARRIER = 40,
+ NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED = 41,
+ NM_DEVICE_STATE_REASON_SUPPLICANT_AVAILABLE = 42,
+ NM_DEVICE_STATE_REASON_MODEM_NOT_FOUND = 43,
+ NM_DEVICE_STATE_REASON_BT_FAILED = 44,
+ NM_DEVICE_STATE_REASON_GSM_SIM_NOT_INSERTED = 45,
+ NM_DEVICE_STATE_REASON_GSM_SIM_PIN_REQUIRED = 46,
+ NM_DEVICE_STATE_REASON_GSM_SIM_PUK_REQUIRED = 47,
+ NM_DEVICE_STATE_REASON_GSM_SIM_WRONG = 48,
+ NM_DEVICE_STATE_REASON_INFINIBAND_MODE = 49,
+ NM_DEVICE_STATE_REASON_DEPENDENCY_FAILED = 50,
+ NM_DEVICE_STATE_REASON_BR2684_FAILED = 51,
+ NM_DEVICE_STATE_REASON_MODEM_MANAGER_UNAVAILABLE = 52,
+ NM_DEVICE_STATE_REASON_SSID_NOT_FOUND = 53,
+ NM_DEVICE_STATE_REASON_SECONDARY_CONNECTION_FAILED = 54,
+ NM_DEVICE_STATE_REASON_DCB_FCOE_FAILED = 55,
+ NM_DEVICE_STATE_REASON_TEAMD_CONTROL_FAILED = 56,
+ NM_DEVICE_STATE_REASON_MODEM_FAILED = 57,
+ NM_DEVICE_STATE_REASON_MODEM_AVAILABLE = 58,
+ NM_DEVICE_STATE_REASON_SIM_PIN_INCORRECT = 59,
+ NM_DEVICE_STATE_REASON_NEW_ACTIVATION = 60,
+ NM_DEVICE_STATE_REASON_PARENT_CHANGED = 61,
+ NM_DEVICE_STATE_REASON_PARENT_MANAGED_CHANGED = 62,
+
+ NM_DEVICE_STATE_REASON_LAST = 0xFFFF,
} NMDeviceStateReason;
@@ -551,11 +551,11 @@ typedef enum {
* network.
**/
typedef enum {
- NM_ACTIVE_CONNECTION_STATE_UNKNOWN = 0,
- NM_ACTIVE_CONNECTION_STATE_ACTIVATING,
- NM_ACTIVE_CONNECTION_STATE_ACTIVATED,
- NM_ACTIVE_CONNECTION_STATE_DEACTIVATING,
- NM_ACTIVE_CONNECTION_STATE_DEACTIVATED
+ NM_ACTIVE_CONNECTION_STATE_UNKNOWN = 0,
+ NM_ACTIVE_CONNECTION_STATE_ACTIVATING = 1,
+ NM_ACTIVE_CONNECTION_STATE_ACTIVATED = 2,
+ NM_ACTIVE_CONNECTION_STATE_DEACTIVATING = 3,
+ NM_ACTIVE_CONNECTION_STATE_DEACTIVATED = 4,
} NMActiveConnectionState;
#endif /* NETWORK_MANAGER_H */
--
2.9.3
From 1f509972d8c2e92af0e20dae30f82fd5d9db77b9 Mon Sep 17 00:00:00 2001
From: Lubomir Rintel <lkundrak@v3.sk>
Date: Wed, 13 Jul 2016 12:26:15 +0200
Subject: [PATCH 17/19] dhcp: drop an unused fariable
Fixes: 1c58ce0d748174b5b3a27dd077192b45fed2d0a4
Fixes: 58c6c12f471137dbba5292d5436188bb76bda650
(cherry picked from commit f9821a1669a0b21ecb96e19b14be35cd99f74638)
(cherry picked from commit 3807e2b3bc2636cac0ff4b56a600ef3801052554)
---
src/dhcp-manager/nm-dhcp-client.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/src/dhcp-manager/nm-dhcp-client.c b/src/dhcp-manager/nm-dhcp-client.c
index 1802df8..c77c2dd 100644
--- a/src/dhcp-manager/nm-dhcp-client.c
+++ b/src/dhcp-manager/nm-dhcp-client.c
@@ -494,8 +494,6 @@ get_duid (NMDhcpClient *self)
GByteArray *copy = NULL;
if (G_UNLIKELY (duid == NULL)) {
- gs_free char *str = NULL;
-
duid = generate_duid_from_machine_id ();
g_assert (duid);
}
--
2.9.3
From 3a0112658dfc1e449eff5f1289d949eae07d8363 Mon Sep 17 00:00:00 2001
From: Thomas Haller <thaller@redhat.com>
Date: Wed, 21 Dec 2016 20:19:13 +0100
Subject: [PATCH 18/19] keyfile: fix memleak in keyfile reader's
read_array_of_uint()
Fixes: 9559a7a26021efa7ef49681b93a3b3bd4eadcef6
(cherry picked from commit 8239edbb9b903dc802957763a8bab04480a491e1)
(cherry picked from commit 8a281bf7b40c25c67e49661d69b38401d64b03c9)
(cherry picked from commit 92f057ca1d1957d1009111536ecb76b74cd47559)
---
libnm-core/nm-keyfile-reader.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libnm-core/nm-keyfile-reader.c b/libnm-core/nm-keyfile-reader.c
index 4a17d2c..dab6d4b 100644
--- a/libnm-core/nm-keyfile-reader.c
+++ b/libnm-core/nm-keyfile-reader.c
@@ -110,7 +110,7 @@ read_array_of_uint (GKeyFile *file,
GArray *array = NULL;
gsize length;
int i;
- gint *tmp;
+ gs_free int *tmp = NULL;
tmp = nm_keyfile_plugin_kf_get_integer_list (file, nm_setting_get_name (setting), key, &length, NULL);
array = g_array_sized_new (FALSE, FALSE, sizeof (guint32), length);
--
2.9.3
From 23fa36bea74acc6295143ef0f746772d20b08886 Mon Sep 17 00:00:00 2001
From: Beniamino Galvani <bgalvani@redhat.com>
Date: Thu, 5 Jan 2017 13:59:50 +0100
Subject: [PATCH 19/19] vpn: add device route to VPN gateway if parent has no
gateway
We set a dedicated route to reach the VPN gateway only if the parent
device has a gateway. If the parent device doesn't have a gateway (for
example in case of GSM connections) and the VPN gets the default
route, the VPN gateway will be contacted through the VPN itself, which
obviously doesn't work.
Set up a device route if the parent device doesn't provide a gateway.
https://bugzilla.redhat.com/show_bug.cgi?id=1403660
(cherry picked from commit ae5adc9e21c642a198868b519b2a278b0b108ab8)
(cherry picked from commit 48db5806f3a99f6cac526fecd6df5a090b53c192)
(cherry picked from commit ff6ef0d696a09f0ebbb5b956c129ce64c3ecae0c)
---
src/vpn-manager/nm-vpn-connection.c | 30 ++++++++++++++++--------------
1 file changed, 16 insertions(+), 14 deletions(-)
diff --git a/src/vpn-manager/nm-vpn-connection.c b/src/vpn-manager/nm-vpn-connection.c
index cb8474a..c9f8913 100644
--- a/src/vpn-manager/nm-vpn-connection.c
+++ b/src/vpn-manager/nm-vpn-connection.c
@@ -660,12 +660,9 @@ add_ip4_vpn_gateway_route (NMIP4Config *config, NMDevice *parent_device, guint32
/* Set up a route to the VPN gateway's public IP address through the default
* network device if the VPN gateway is on a different subnet.
*/
-
parent_config = nm_device_get_ip4_config (parent_device);
g_return_if_fail (parent_config != NULL);
parent_gw = nm_ip4_config_get_gateway (parent_config);
- if (!parent_gw)
- return;
route_metric = nm_device_get_ip4_route_metric (parent_device);
@@ -673,6 +670,9 @@ add_ip4_vpn_gateway_route (NMIP4Config *config, NMDevice *parent_device, guint32
route.network = vpn_gw;
route.plen = 32;
route.gateway = parent_gw;
+ /* Set up a device route if the parent device has no gateway */
+ if (!parent_gw)
+ route.ifindex = nm_device_get_ip_ifindex (parent_device);
/* If the VPN gateway is in the same subnet as one of the parent device's
* IP addresses, don't add the host route to it, but a route through the
@@ -685,18 +685,20 @@ add_ip4_vpn_gateway_route (NMIP4Config *config, NMDevice *parent_device, guint32
route.metric = route_metric;
nm_ip4_config_add_route (config, &route);
- /* Ensure there's a route to the parent device's gateway through the
- * parent device, since if the VPN claims the default route and the VPN
- * routes include a subnet that matches the parent device's subnet,
- * the parent device's gateway would get routed through the VPN and fail.
- */
- memset (&route, 0, sizeof (route));
- route.network = parent_gw;
- route.plen = 32;
- route.source = NM_IP_CONFIG_SOURCE_VPN;
- route.metric = route_metric;
+ if (parent_gw) {
+ /* Ensure there's a route to the parent device's gateway through the
+ * parent device, since if the VPN claims the default route and the VPN
+ * routes include a subnet that matches the parent device's subnet,
+ * the parent device's gateway would get routed through the VPN and fail.
+ */
+ memset (&route, 0, sizeof (route));
+ route.network = parent_gw;
+ route.plen = 32;
+ route.source = NM_IP_CONFIG_SOURCE_VPN;
+ route.metric = route_metric;
- nm_ip4_config_add_route (config, &route);
+ nm_ip4_config_add_route (config, &route);
+ }
}
static void
--
2.9.3