NetworkManager/0046-suppress-invalid-warnings.patch

286 lines
10 KiB
Diff
Raw Normal View History

From eec3d95eb286a6cb57430714d0f16a1a414251f4 Mon Sep 17 00:00:00 2001
From: Thomas Haller <thaller@redhat.com>
Date: Tue, 21 Jan 2014 11:23:16 +0100
Subject: [PATCH 1/3] platform: add parameter to nm_platform_sysctl_get() to
suppress logging error
In some cases, an error when reading the sysctl value can be expected.
In this case, we want to suppress the error message
(cherry picked from commit 634e4c99c3907f1b9fc0dbff4a6d4065182e9b09)
Signed-off-by: Thomas Haller <thaller@redhat.com>
---
src/platform/nm-fake-platform.c | 6 +++---
src/platform/nm-linux-platform.c | 15 ++++++++-------
src/platform/nm-platform.c | 8 +++++---
src/platform/nm-platform.h | 4 ++--
src/platform/tests/platform.c | 2 +-
5 files changed, 19 insertions(+), 16 deletions(-)
diff --git a/src/platform/nm-fake-platform.c b/src/platform/nm-fake-platform.c
index 803015c..dbad71e 100644
--- a/src/platform/nm-fake-platform.c
+++ b/src/platform/nm-fake-platform.c
@@ -72,7 +72,7 @@ sysctl_set (NMPlatform *platform, const char *path, const char *value)
}
static char *
-sysctl_get (NMPlatform *platform, const char *path)
+sysctl_get (NMPlatform *platform, const char *path, gboolean silent_on_error)
{
NMFakePlatformPrivate *priv = NM_FAKE_PLATFORM_GET_PRIVATE (platform);
@@ -566,7 +566,7 @@ master_get_option (NMPlatform *platform, int master, const char *option)
{
auto_g_free char *path = g_strdup_printf ("master:%d:%s", master, option);
- return sysctl_get (platform, path);
+ return sysctl_get (platform, path, FALSE);
}
static gboolean
@@ -582,7 +582,7 @@ slave_get_option (NMPlatform *platform, int slave, const char *option)
{
auto_g_free char *path = g_strdup_printf ("slave:%d:%s", slave, option);
- return sysctl_get (platform, path);
+ return sysctl_get (platform, path, FALSE);
}
static gboolean
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c
index df1b33a..f935af4 100644
--- a/src/platform/nm-linux-platform.c
+++ b/src/platform/nm-linux-platform.c
@@ -1454,13 +1454,14 @@ sysctl_set (NMPlatform *platform, const char *path, const char *value)
}
static char *
-sysctl_get (NMPlatform *platform, const char *path)
+sysctl_get (NMPlatform *platform, const char *path, gboolean silent_on_error)
{
GError *error = NULL;
char *contents;
if (!g_file_get_contents (path, &contents, NULL, &error)) {
- error ("error reading %s: %s", path, error->message);
+ if (!silent_on_error)
+ error ("error reading %s: %s", path, error->message);
g_clear_error (&error);
return NULL;
}
@@ -1869,7 +1870,7 @@ link_get_physical_port_id (NMPlatform *platform, int ifindex)
path = g_strdup_printf ("/sys/class/net/%s/phys_port_id", ifname);
if (g_file_test (path, G_FILE_TEST_EXISTS))
- id = sysctl_get (platform, path);
+ id = sysctl_get (platform, path, FALSE);
else
id = NULL;
g_free (path);
@@ -1990,7 +1991,7 @@ link_get_option (int master, const char *category, const char *option)
{
auto_g_free char *path = link_option_path (master, category, option);
- return path ? nm_platform_sysctl_get (path) : NULL;
+ return path ? nm_platform_sysctl_get (path, FALSE) : NULL;
}
static const char *
@@ -2116,7 +2117,7 @@ tun_get_properties (NMPlatform *platform, int ifindex, NMPlatformTunProperties *
return FALSE;
path = g_strdup_printf ("/sys/class/net/%s/owner", ifname);
- val = nm_platform_sysctl_get (path);
+ val = nm_platform_sysctl_get (path, FALSE);
g_free (path);
if (!val)
return FALSE;
@@ -2124,7 +2125,7 @@ tun_get_properties (NMPlatform *platform, int ifindex, NMPlatformTunProperties *
g_free (val);
path = g_strdup_printf ("/sys/class/net/%s/group", ifname);
- val = nm_platform_sysctl_get (path);
+ val = nm_platform_sysctl_get (path, FALSE);
g_free (path);
if (!val)
return FALSE;
@@ -2132,7 +2133,7 @@ tun_get_properties (NMPlatform *platform, int ifindex, NMPlatformTunProperties *
g_free (val);
path = g_strdup_printf ("/sys/class/net/%s/tun_flags", ifname);
- val = nm_platform_sysctl_get (path);
+ val = nm_platform_sysctl_get (path, FALSE);
g_free (path);
if (!val)
return FALSE;
diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c
index 87a7ef9..0b56464 100644
--- a/src/platform/nm-platform.c
+++ b/src/platform/nm-platform.c
@@ -267,18 +267,20 @@ nm_platform_sysctl_set (const char *path, const char *value)
/**
* nm_platform_sysctl_get:
* @path: Absolute path to sysctl
+ * @silent_on_error: don't log an error message when the value
+ * could not be read.
*
* Returns: (transfer full): Contents of the virtual sysctl file.
*/
char *
-nm_platform_sysctl_get (const char *path)
+nm_platform_sysctl_get (const char *path, gboolean silent_on_error)
{
reset_error ();
g_return_val_if_fail (path, NULL);
g_return_val_if_fail (klass->sysctl_get, NULL);
- return klass->sysctl_get (platform, path);
+ return klass->sysctl_get (platform, path, silent_on_error);
}
/**
@@ -300,7 +302,7 @@ nm_platform_sysctl_get_int32 (const char *path, gint32 fallback)
g_return_val_if_fail (path, fallback);
if (path)
- value = nm_platform_sysctl_get (path);
+ value = nm_platform_sysctl_get (path, FALSE);
if (!value) {
errno = EINVAL;
diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h
index d5b3672..9375148 100644
--- a/src/platform/nm-platform.h
+++ b/src/platform/nm-platform.h
@@ -231,7 +231,7 @@ typedef struct {
gboolean (*setup) (NMPlatform *);
gboolean (*sysctl_set) (NMPlatform *, const char *path, const char *value);
- char * (*sysctl_get) (NMPlatform *, const char *path);
+ char * (*sysctl_get) (NMPlatform *, const char *path, gboolean silent_on_error);
GArray *(*link_get_all) (NMPlatform *);
gboolean (*link_add) (NMPlatform *, const char *name, NMLinkType type);
@@ -350,7 +350,7 @@ const char *nm_platform_get_error_msg (void);
void nm_platform_query_devices (void);
gboolean nm_platform_sysctl_set (const char *path, const char *value);
-char *nm_platform_sysctl_get (const char *path);
+char *nm_platform_sysctl_get (const char *path, gboolean silent_on_error);
gint32 nm_platform_sysctl_get_int32 (const char *path, gint32 fallback);
GArray *nm_platform_link_get_all (void);
diff --git a/src/platform/tests/platform.c b/src/platform/tests/platform.c
index 7ca2cb5..3c636f5 100644
--- a/src/platform/tests/platform.c
+++ b/src/platform/tests/platform.c
@@ -47,7 +47,7 @@ do_sysctl_set (char **argv)
static gboolean
do_sysctl_get (char **argv)
{
- auto_g_free char *value = nm_platform_sysctl_get (argv[0]);
+ auto_g_free char *value = nm_platform_sysctl_get (argv[0], FALSE);
printf ("%s\n", value);
--
1.8.5.3
From 4901ef3d1259c7038c1011ced874773cfe4dfbaf Mon Sep 17 00:00:00 2001
From: Thomas Haller <thaller@redhat.com>
Date: Thu, 30 Jan 2014 16:33:55 +0100
Subject: [PATCH 2/3] core/platform: silence error about reading sysctl file
phys_port_id
It is common that the file exists, but cannot be read
(Operation not supported). So, silence any error when
reading the phys_port_id file.
(cherry picked from commit 2fd8d40a5a009aaf33365a9a985d1c72fb20324d)
Signed-off-by: Thomas Haller <thaller@redhat.com>
---
src/platform/nm-linux-platform.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c
index f935af4..55646d4 100644
--- a/src/platform/nm-linux-platform.c
+++ b/src/platform/nm-linux-platform.c
@@ -1869,10 +1869,7 @@ link_get_physical_port_id (NMPlatform *platform, int ifindex)
return NULL;
path = g_strdup_printf ("/sys/class/net/%s/phys_port_id", ifname);
- if (g_file_test (path, G_FILE_TEST_EXISTS))
- id = sysctl_get (platform, path, FALSE);
- else
- id = NULL;
+ id = sysctl_get (platform, path, TRUE);
g_free (path);
return id;
--
1.8.5.3
From 4f128334dad91cff426bc3ca44e5500ce3950277 Mon Sep 17 00:00:00 2001
From: Thomas Haller <thaller@redhat.com>
Date: Thu, 13 Feb 2014 12:32:58 +0100
Subject: [PATCH 3/3] core: suppress error message ZONE_ALREADY_SET when adding
firewalld zone
See also https://bugzilla.redhat.com/show_bug.cgi?id=886432, where
firewalld was changed, not to return ZONE_ALREADY_SET for 'changeZone'.
However, 'addInterface' can still fail with this error.
Suppress the following error lines:
<debug> [1392290031.179280] [firewall-manager/nm-firewall-manager.c:117] nm_firewall_manager_add_or_change_zone(): (em1) firewall zone add -> (null)
...
<warn> (em1) firewall zone add/change failed: (32) ZONE_ALREADY_SET
(cherry picked from commit 71cce80f1f54da76766af4105211608bd50ab44d)
Signed-off-by: Thomas Haller <thaller@redhat.com>
---
src/firewall-manager/nm-firewall-manager.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/firewall-manager/nm-firewall-manager.c b/src/firewall-manager/nm-firewall-manager.c
index d73069f..ffe0649 100644
--- a/src/firewall-manager/nm-firewall-manager.c
+++ b/src/firewall-manager/nm-firewall-manager.c
@@ -82,8 +82,13 @@ add_or_change_cb (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data
G_TYPE_STRING, &zone,
G_TYPE_INVALID)) {
g_assert (error);
- nm_log_warn (LOGD_FIREWALL, "(%s) firewall zone add/change failed: (%d) %s",
- info->iface, error->code, error->message);
+ if (g_strcmp0 (error->message, "ZONE_ALREADY_SET") != 0) {
+ nm_log_warn (LOGD_FIREWALL, "(%s) firewall zone add/change failed: (%d) %s",
+ info->iface, error->code, error->message);
+ } else {
+ nm_log_dbg (LOGD_FIREWALL, "(%s) firewall zone add/change failed: (%d) %s",
+ info->iface, error->code, error->message);
+ }
}
info->callback (error, info->user_data);
@@ -114,7 +119,8 @@ nm_firewall_manager_add_or_change_zone (NMFirewallManager *self,
info->callback = callback;
info->user_data = user_data;
- nm_log_dbg (LOGD_FIREWALL, "(%s) firewall zone %s -> %s", iface, add ? "add" : "change", zone);
+ nm_log_dbg (LOGD_FIREWALL, "(%s) firewall zone %s -> %s%s%s", iface, add ? "add" : "change",
+ zone?"\"":"", zone ? zone : "default", zone?"\"":"");
return dbus_g_proxy_begin_call_with_timeout (priv->proxy,
add ? "addInterface" : "changeZone",
add_or_change_cb,
--
1.8.5.3