Accepting request 571270 from home:BinLiu:branches:network:ha-clustering:Factory

- corosync exposes itself for a self-crash under rare circumstance(bsc#1078412)
    Added: 0013-logging-Make-blackbox-configurable.patch
           0014-logging-Close-before-and-open-blackbox-after-fork.patch
    Modified: remove unncessary git commit messages
           0001-coroapi-Use-size_t-for-private_data_size.patch
           0002-fix-ifdown-udp.patch
           0005-do-not-convert-empty-uid-gid-to-0.patch
           0008-wd-fix-snprintf-warnings.patch
           0010-qdevice-mv-free-str-after-port-validation.patch
           0011-libcpg-Fix-issue-with-partial-big-packet-assembly.patch
           0012-totemudp-u-Drop-truncated-packets-on-receive.patch

OBS-URL: https://build.opensuse.org/request/show/571270
OBS-URL: https://build.opensuse.org/package/show/network:ha-clustering:Factory/corosync?expand=0&rev=133
This commit is contained in:
Bin Liu 2018-01-31 06:32:47 +00:00 committed by Git OBS Bridge
parent 1cb59d8095
commit 868d6de717
11 changed files with 282 additions and 114 deletions

View File

@ -1,19 +1,3 @@
From afd97d788494007462b95a237161310af4c6e233 Mon Sep 17 00:00:00 2001
From: Michael Jones <jonesmz@jonesmz.com>
Date: Thu, 25 May 2017 13:29:19 -0500
Subject: [PATCH 6/6] coroapi: Use size_t for private_data_size
Unsigned int and size_t represent two different concepts.
Same problem was present in ipc_glue.
Signed-off-by: Michael Jones <jonesmz@jonesmz.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
---
exec/ipc_glue.c | 2 +-
include/corosync/coroapi.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/exec/ipc_glue.c b/exec/ipc_glue.c
index d0a25d98..8b34d495 100644
--- a/exec/ipc_glue.c

View File

@ -1,22 +1,3 @@
From 790794bc1f654fd1b4c8c2904c8d5c60374b99c1 Mon Sep 17 00:00:00 2001
From: Jan Friesse <jfriesse@redhat.com>
Date: Mon, 31 Jul 2017 18:05:18 +0200
Subject: [PATCH] totemudp: Add local loop support for unicast msgs
This patch intends to solve long time ifdown corosync problem. Idea is
to use multicast local socket also for sending unicast messages.
Together with testing what is current bind state it's possible to keep
pretending existence of old IP address instead of rebinding to localhost
what breaks a lot things badly.
Heavilly based on Yu, Zou <zouyu@shiqichuban.com> work. Also big thanks
to Bin Liu <bliu@suse.com> for testing and bringing some ideas.
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
---
exec/totemudp.c | 215 +++++++++++++++++++++++++++++++++-----------------------
1 file changed, 128 insertions(+), 87 deletions(-)
diff --git a/exec/totemudp.c b/exec/totemudp.c
index 31d05704..47830e4b 100644
--- a/exec/totemudp.c

View File

@ -1,12 +1,3 @@
From a7a13690db8fc7508177138265c6930fa11ade3e Mon Sep 17 00:00:00 2001
From: Bin Liu <bliu@suse.com>
Date: Tue, 21 Nov 2017 11:03:10 +0800
Subject: [PATCH] do not convert empty uid gid to 0
---
exec/coroparse.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/exec/coroparse.c b/exec/coroparse.c
index 374ed7dd..ac654a11 100644
--- a/exec/coroparse.c

View File

@ -1,17 +1,3 @@
From 0906e5717cce87ac8db25ac9a335a63530dba839 Mon Sep 17 00:00:00 2001
From: Bin Liu <bliu@suse.com>
Date: Fri, 1 Dec 2017 10:58:50 +0800
Subject: [PATCH] wd: fix snprintf warnings
When running ./configure --enable-watchdog, gcc 7.2.1 will report
warnings for snprintf. This patch fixes the warnings.
Signed-off-by: Bin Liu <bliu@suse.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
---
exec/wd.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/exec/wd.c b/exec/wd.c
index 8d0734c9..042d2046 100644
--- a/exec/wd.c

View File

@ -1,21 +1,3 @@
From 60d419917ac5a64abe8539bedb9fd57af1451ff5 Mon Sep 17 00:00:00 2001
From: Bin Liu <bliu@suse.com>
Date: Wed, 27 Dec 2017 18:21:34 +0800
Subject: [PATCH] qdevice: mv free(str) after port validation
in the previous code of qdevice_net_instance_init_from_cmap:
host_port = strtol(str, &ep, 10);
free(str);
if (host_port <= 0 || host_port > ((uint16_t)~0) || *ep != '\0')
before free, *ep is '\0'. But after free, *ep changed to 'U', so mv
free behind the comparison.
---
qdevices/qdevice-net-instance.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/qdevices/qdevice-net-instance.c b/qdevices/qdevice-net-instance.c
index 7adcaa3f..e4b7b04d 100644
--- a/qdevices/qdevice-net-instance.c

View File

@ -1,23 +1,3 @@
From 86579ff5f8f8d93e3173731bdf632827d4d1c711 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rytis=20Karpu=C5=A1ka?= <rytisk@neurotechnology.com>
Date: Thu, 28 Dec 2017 15:17:12 +0200
Subject: [PATCH 1/2] libcpg: Fix issue with partial big packet assembly
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Packet assembly is done seperately for each nodeid, pid pair,
therefore multiple packets are not mixed into single buffer.
(backported from master c9dd11772cd6660d7651b6781df963efa914652e)
Signed-off-by: Rytis Karpuška <rytisk@neurotechnology.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
---
lib/cpg.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 76 insertions(+), 20 deletions(-)
diff --git a/lib/cpg.c b/lib/cpg.c
index c831390b..a0e662f0 100644
--- a/lib/cpg.c

View File

@ -1,21 +1,3 @@
From 89d36a80a4899cb9536ad22cb16615c9eff043de Mon Sep 17 00:00:00 2001
From: Jan Friesse <jfriesse@redhat.com>
Date: Fri, 5 Jan 2018 16:38:43 +0100
Subject: [PATCH 1/2] totemudp[u]: Drop truncated packets on receive
This is backport of part of "totemudpu: Scale receive buffer" patch in
master branch.
We shouldn't not need to enlarge buffer because maximum number of nodes
for needle is 2 so join message is smaller.
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
---
exec/totemudp.c | 26 ++++++++++++++++++++++++++
exec/totemudpu.c | 26 ++++++++++++++++++++++++++
2 files changed, 52 insertions(+)
diff --git a/exec/totemudp.c b/exec/totemudp.c
index 2f36b5d9..40e99f93 100644
--- a/exec/totemudp.c

View File

@ -0,0 +1,201 @@
diff --git a/exec/logconfig.c b/exec/logconfig.c
index 6d0bed6a..ccbffae6 100644
--- a/exec/logconfig.c
+++ b/exec/logconfig.c
@@ -127,7 +127,7 @@ static int insert_into_buffer(
}
/*
- * format set is the only global specific option that
+ * format set is global specific option that
* doesn't apply at system/subsystem level.
*/
static int corosync_main_config_format_set (
@@ -228,6 +228,40 @@ parse_error:
return (-1);
}
+/*
+ * blackbox is another global specific option that
+ * doesn't apply at system/subsystem level.
+ */
+static int corosync_main_config_blackbox_set (
+ const char **error_string)
+{
+ const char *error_reason;
+ char *value = NULL;
+
+ if (map_get_string("logging.blackbox", &value) == CS_OK) {
+ if (strcmp (value, "on") == 0) {
+ (void)logsys_blackbox_set(QB_TRUE);
+ } else if (strcmp (value, "off") == 0) {
+ (void)logsys_blackbox_set(QB_FALSE);
+ } else {
+ error_reason = "unknown value for blackbox";
+ free(value);
+ goto parse_error;
+ }
+
+ free(value);
+ } else {
+ (void)logsys_blackbox_set(QB_TRUE);
+ }
+
+ return (0);
+
+parse_error:
+ *error_string = error_reason;
+
+ return (-1);
+}
+
static int corosync_main_config_log_destination_set (
const char *path,
const char *key,
@@ -522,6 +556,10 @@ static int corosync_main_config_read_logging (
goto parse_error;
}
+ if (corosync_main_config_blackbox_set(&error_reason) < 0) {
+ goto parse_error;
+ }
+
if (corosync_main_config_set ("logging", NULL, &error_reason) < 0) {
goto parse_error;
}
diff --git a/exec/logsys.c b/exec/logsys.c
index 6b4995dd..a38cc5e8 100644
--- a/exec/logsys.c
+++ b/exec/logsys.c
@@ -119,6 +119,8 @@ static char *format_buffer=NULL;
static int logsys_thread_started = 0;
+static int logsys_blackbox_enabled = 1;
+
static int _logsys_config_subsys_get_unlocked (const char *subsys)
{
unsigned int i;
@@ -309,7 +311,6 @@ int _logsys_system_setup(
int i;
int32_t fidx;
char tempsubsys[LOGSYS_MAX_SUBSYS_NAMELEN];
- int blackbox_enable_res;
if ((mainsystem == NULL) ||
(strlen(mainsystem) >= LOGSYS_MAX_SUBSYS_NAMELEN)) {
@@ -371,7 +372,12 @@ int _logsys_system_setup(
QB_LOG_FILTER_FILE, "*", LOG_TRACE);
qb_log_ctl(QB_LOG_BLACKBOX, QB_LOG_CONF_SIZE, IPC_LOGSYS_SIZE);
qb_log_ctl(QB_LOG_BLACKBOX, QB_LOG_CONF_THREADED, QB_FALSE);
- blackbox_enable_res = qb_log_ctl(QB_LOG_BLACKBOX, QB_LOG_CONF_ENABLED, QB_TRUE);
+
+ /*
+ * Blackbox is disabled at the init and enabled later based
+ * on config (logging.blackbox) value.
+ */
+ qb_log_ctl(QB_LOG_BLACKBOX, QB_LOG_CONF_ENABLED, QB_FALSE);
if (logsys_format_set(NULL) == -1) {
return -1;
@@ -397,14 +403,6 @@ int _logsys_system_setup(
}
}
- if (blackbox_enable_res < 0) {
- LOGSYS_PERROR (-blackbox_enable_res, LOGSYS_LEVEL_WARNING,
- "Unable to initialize log flight recorder. "\
- "The most common cause of this error is " \
- "not enough space on /dev/shm. Corosync will continue work, " \
- "but blackbox will not be available");
- }
-
pthread_mutex_unlock (&logsys_config_mutex);
return (0);
@@ -767,10 +765,26 @@ static void _logsys_config_apply_per_subsys(int32_t s)
logsys_loggers[s].dirty = QB_FALSE;
}
+static void _logsys_config_apply_blackbox(void) {
+ int blackbox_enable_res;
+
+ blackbox_enable_res = qb_log_ctl(QB_LOG_BLACKBOX, QB_LOG_CONF_ENABLED, logsys_blackbox_enabled);
+
+ if (blackbox_enable_res < 0) {
+ LOGSYS_PERROR (-blackbox_enable_res, LOGSYS_LEVEL_WARNING,
+ "Unable to initialize log flight recorder. "\
+ "The most common cause of this error is " \
+ "not enough space on /dev/shm. Corosync will continue work, " \
+ "but blackbox will not be available");
+ }
+}
+
void logsys_config_apply(void)
{
int32_t s;
+ _logsys_config_apply_blackbox();
+
for (s = 0; s <= LOGSYS_MAX_SUBSYS_COUNT; s++) {
if (strcmp(logsys_loggers[s].subsys, "") == 0) {
continue;
@@ -838,3 +852,13 @@ int logsys_thread_start (void)
return (0);
}
+
+void logsys_blackbox_set(int enable)
+{
+
+ pthread_mutex_lock (&logsys_config_mutex);
+
+ logsys_blackbox_enabled = enable;
+
+ pthread_mutex_unlock (&logsys_config_mutex);
+}
diff --git a/exec/main.c b/exec/main.c
index 7fe24e2e..cd587dc8 100644
--- a/exec/main.c
+++ b/exec/main.c
@@ -220,6 +220,7 @@ static void corosync_blackbox_write_to_file (void)
if ((res = qb_log_blackbox_write_to_file(fname)) < 0) {
LOGSYS_PERROR(-res, LOGSYS_LEVEL_ERROR, "Can't store blackbox file");
+ return ;
}
snprintf(fdata_fname, sizeof(fdata_fname), "%s/fdata", get_run_dir());
unlink(fdata_fname);
diff --git a/include/corosync/logsys.h b/include/corosync/logsys.h
index 0b2fbff8..ec38d2cb 100644
--- a/include/corosync/logsys.h
+++ b/include/corosync/logsys.h
@@ -256,6 +256,8 @@ extern int _logsys_subsys_create (const char *subsys, const char *filename);
*/
extern int logsys_thread_start (void);
+extern void logsys_blackbox_set(int enable);
+
/**
* @brief logsys_subsys_id
*/
diff --git a/man/corosync.conf.5 b/man/corosync.conf.5
index 06390281..68103d0e 100644
--- a/man/corosync.conf.5
+++ b/man/corosync.conf.5
@@ -539,6 +539,12 @@ This specifies that the code function name should be printed.
The default is off.
+.TP
+blackbox
+This specifies that blackbox functionality should be enabled.
+
+The defualt is on.
+
.PP
The following options are valid both for top level logging directive
and they can be overridden in logger_subsys entries.
--
2.13.6

View File

@ -0,0 +1,61 @@
diff --git a/exec/logsys.c b/exec/logsys.c
index a38cc5e8..8c9c222c 100644
--- a/exec/logsys.c
+++ b/exec/logsys.c
@@ -862,3 +862,19 @@ void logsys_blackbox_set(int enable)
pthread_mutex_unlock (&logsys_config_mutex);
}
+
+/*
+ * To set correct pid to qb blackbox filename after tty dettach (fork) we have to
+ * close (this function) and (if needed) reopen blackbox (logsys_blackbox_postfork function).
+ */
+void logsys_blackbox_prefork(void)
+{
+
+ (void)qb_log_ctl(QB_LOG_BLACKBOX, QB_LOG_CONF_ENABLED, QB_FALSE);
+}
+
+void logsys_blackbox_postfork(void)
+{
+
+ _logsys_config_apply_blackbox();
+}
diff --git a/exec/main.c b/exec/main.c
index cd587dc8..426e56d0 100644
--- a/exec/main.c
+++ b/exec/main.c
@@ -1460,7 +1460,13 @@ int main (int argc, char **argv, char **envp)
* Now we are fully initialized.
*/
if (background) {
+ logsys_blackbox_prefork();
+
corosync_tty_detach ();
+
+ logsys_blackbox_postfork();
+
+ log_printf (LOGSYS_LEVEL_DEBUG, "Corosync TTY detached");
}
/*
diff --git a/include/corosync/logsys.h b/include/corosync/logsys.h
index ec38d2cb..a4aad69b 100644
--- a/include/corosync/logsys.h
+++ b/include/corosync/logsys.h
@@ -258,6 +258,11 @@ extern int logsys_thread_start (void);
extern void logsys_blackbox_set(int enable);
+extern void logsys_blackbox_prefork(void);
+
+extern void logsys_blackbox_postfork(void);
+
+
/**
* @brief logsys_subsys_id
*/
--
2.13.6

View File

@ -1,3 +1,19 @@
-------------------------------------------------------------------
Wed Jan 31 05:59:06 UTC 2018 - bliu@suse.com
- corosync exposes itself for a self-crash under rare circumstance(bsc#1078412)
Added: 0013-logging-Make-blackbox-configurable.patch
0014-logging-Close-before-and-open-blackbox-after-fork.patch
Modified: remove unncessary git commit messages
0001-coroapi-Use-size_t-for-private_data_size.patch
0002-fix-ifdown-udp.patch
0005-do-not-convert-empty-uid-gid-to-0.patch
0008-wd-fix-snprintf-warnings.patch
0010-qdevice-mv-free-str-after-port-validation.patch
0011-libcpg-Fix-issue-with-partial-big-packet-assembly.patch
0012-totemudp-u-Drop-truncated-packets-on-receive.patch
-------------------------------------------------------------------
Wed Jan 10 02:36:24 UTC 2018 - bliu@suse.com

View File

@ -74,6 +74,8 @@ Patch16: 0009-add-config-for-corosync-qnetd.patch
Patch17: 0010-qdevice-mv-free-str-after-port-validation.patch
Patch18: 0011-libcpg-Fix-issue-with-partial-big-packet-assembly.patch
Patch19: 0012-totemudp-u-Drop-truncated-packets-on-receive.patch
Patch20: 0013-logging-Make-blackbox-configurable.patch
Patch21: 0014-logging-Close-before-and-open-blackbox-after-fork.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
# openais is indeed gone and should be uninstalled. Yes, we do not
@ -158,6 +160,8 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-build
%patch17 -p1
%patch18 -p1
%patch19 -p1
%patch20 -p1
%patch21 -p1
%build
%if %{with runautogen}