summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2020-03-31 17:54:41 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2020-03-31 17:54:41 +0000
commit50c03837646ecccc66680156273f954d93b284c4 (patch)
treedbc900fb9ede09cb1eaf464d6bba7aaccd2c35f3
parentAdding upstream version 3.0.2. (diff)
downloadcorosync-upstream.tar.xz
corosync-upstream.zip
Adding upstream version 3.0.3.upstream/3.0.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
-rw-r--r--.tarball-version2
-rw-r--r--.version2
-rw-r--r--ChangeLog307
-rwxr-xr-xconfigure186
-rw-r--r--configure.ac39
-rw-r--r--exec/cfg.c8
-rw-r--r--exec/cmap.c2
-rw-r--r--exec/cpg.c249
-rw-r--r--exec/icmap.c76
-rw-r--r--exec/main.c8
-rw-r--r--exec/sync.c4
-rw-r--r--exec/totemconfig.c21
-rw-r--r--exec/totemknet.c81
-rw-r--r--exec/totempg.c34
-rw-r--r--exec/totemsrp.c160
-rw-r--r--exec/votequorum.c33
-rw-r--r--exec/vsf_quorum.c2
-rw-r--r--include/corosync/config.h.in9
-rw-r--r--include/corosync/corotypes.h3
-rw-r--r--include/corosync/icmap.h1
-rwxr-xr-xinit/corosync.in13
-rw-r--r--man/corosync-cfgtool.85
-rw-r--r--man/corosync-notifyd.83
-rw-r--r--man/corosync.conf.54
-rw-r--r--pkgconfig/libtemplate.pc.in2
-rw-r--r--test/cpghum.c11
-rw-r--r--test/testcpg.c20
-rw-r--r--test/testcpg2.c7
-rw-r--r--test/testcpgzc.c11
-rw-r--r--test/testquorum.c5
-rw-r--r--test/testvotequorum1.c6
-rw-r--r--test/testvotequorum2.c2
-rw-r--r--test/testzcgc.c9
-rw-r--r--tools/corosync-cfgtool.c14
-rw-r--r--tools/corosync-notifyd.c146
-rw-r--r--tools/corosync-quorumtool.c12
-rw-r--r--vqsim/vqmain.c24
-rw-r--r--vqsim/vqsim_vq_engine.c4
38 files changed, 1132 insertions, 393 deletions
diff --git a/.tarball-version b/.tarball-version
index b502146..75a22a2 100644
--- a/.tarball-version
+++ b/.tarball-version
@@ -1 +1 @@
-3.0.2
+3.0.3
diff --git a/.version b/.version
index b502146..75a22a2 100644
--- a/.version
+++ b/.version
@@ -1 +1 @@
-3.0.2
+3.0.3
diff --git a/ChangeLog b/ChangeLog
index 1b79f3c..f43ebf2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,310 @@
+2019-11-18 Christine Caulfield <ccaulfie@redhat.com>
+
+ icmap: fix the icmap_get_*_r functions
+ Make the icmap*_r functions read from the specified map rather
+ than the global map.
+
+ Also include icmap_get_string_r() which seems to have been missed out.
+
+ Reviewed-by: Jan Friesse <jfriesse@redhat.com>
+
+2019-11-18 Fabio M. Di Nitto <fdinitto@redhat.com>
+
+ pkgconfig: Add libqb dependency
+ To make sure libqb dependency is visible across all libraries.
+
+ Reviewed-by: Jan Friesse <jfriesse@redhat.com>
+
+2019-11-08 Jan Friesse <jfriesse@redhat.com>
+
+ Initialize stack allocated memory
+ Some functions allocated memory on stack without clearing memory and
+ then send them on wire. This is not an issue, but valgrind reports this
+ as a problem so it is easy to miss real problem then.
+
+ Solution is to clear stack memory.
+
+ Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
+
+2019-10-17 Thomas Lamprecht <t.lamprecht@proxmox.com>
+
+ man: Fix corosync.conf knet pong count default
+ commit 029b8ebad60314d3daa285eb945c55355fade389 changed the default
+ of the KNET_PONG_COUNT from the kronosnet default of 5 to 2, as
+ corosync bring up was deemed to slow.
+
+ The documentation, and the comment stating that the totem config
+ default values match the knet ones were not updated, and thus now out
+ of date.
+
+ Fixhis by noting the correct default of 2 for KNET_PONG_COUNT and
+ note that all but that one are in sync with the korosync defaults in
+ the comment.
+
+ Reviewed-by: Jan Friesse <jfriesse@redhat.com>
+
+2019-10-09 Jan Friesse <jfriesse@redhat.com>
+
+ totemsrp: Reduce MTU to left room second mcast
+ Messages sent during recovery phase are encapsulated so such message has
+ extra size of mcast structure. This is not so big problem for UDPU,
+ because most of the switches are able to fragment and defragment packet
+ but it is problem for knet, because totempg is using maximum packet size
+ (65536 bytes) and when another header is added during retransmition,
+ then packet is too large.
+
+ Solution is to reduce mtu by 2 * sizeof (struct mcast).
+
+ Reviewed-by: Fabio M. Di Nitto <fdinitto@redhat.com>
+
+ totempg: Check sanity (length) of received message
+ Reviewed-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
+ Reviewed-by: Fabio M. Di Nitto <fdinitto@redhat.com>
+
+2019-10-09 Fabio M. Di Nitto <fdinitto@redhat.com>
+
+ build: add option for enabling sanitizer builds
+ --with-sanitizers= option is stricly meant for runtime debugging
+ purposes. Do NOT use in production.
+
+ Please check gcc/clang man pages on how to use ASAN/UBSAN/TSAN.
+
+ Also allow users to specificy SANITIZERS_CFLAGS and SANITIZERS_LDFLAGS
+ for advanced use.
+
+ Reviewed-by: Jan Friesse <jfriesse@redhat.com>
+
+2019-09-10 Jan Friesse <jfriesse@redhat.com>
+
+ totemknet: Add locking for log call
+ Knet callbacks may be called from different thread than main thread. If
+ this happens, log messages may be lost. Most prominent example is when
+ link goes up (logged by main thread) and host_change_callback_fn is
+ called.
+
+ Implemented solution is adding mutex for every log call in totemknet.
+
+ Reviewed-by: Fabio M. Di Nitto <fdinitto@redhat.com>
+
+2019-08-27 Jan Friesse <jfriesse@redhat.com>
+
+ man: Fix link_mode priority description
+ ... to match knet source code.
+
+ Reviewed-by: Fabio M. Di Nitto <fdinitto@redhat.com>
+
+2019-07-30 Jan Friesse <jfriesse@redhat.com>
+
+ notifyd: Don't dereference NULL key_name
+ This problem shouldn't really happen, but better safe than sorry.
+
+2019-07-15 Jan Friesse <jfriesse@redhat.com>
+
+ totem: Increase ring_id seq after load
+ This patch handles the situation where the leader
+ node (the node with lowest node_id) crashes and is started again
+ before token timeout of the rest of the cluster.
+ The newly restarted node restores the ringid of the old ring from
+ stable storage, so it has the same ringid as rest of the nodes,
+ but ARU is zero. If the node is able to create a singleton membership
+ before receiving the joinlist from rest of the cluster,
+ everything works as expected, because the ring id gets increased
+ correctly.
+
+ But if the node receives a joinlist from another cluster node before
+ its own joinlist, then it continues as it would had it never left
+ the cluster. This is not correct, because the new node should always
+ create a singleton configuration first.
+
+ During the recovery phase, ARUs are compared and because they differ
+ (the ARU of the old leader node is 0), the other nodes
+ try to sent all of their previous messages. This is impossible
+ (even if it was correct), because other nodes have already freed most
+ of those messages. The implementation uses an assert to limit maximum
+ number of messages sent during recovery (we could fix this,
+ but it's not really the point).
+
+ The solution here is to increase the ring_id sequence number by 1 after
+ loading it from storage. During creation of the commit token it is
+ always increased by 4, so it will not collide with an existing
+ sequence.
+
+ Thanks Christine Caulfield <ccaulfie@redhat.com> for clarify commit
+ message.
+
+ Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
+
+2019-07-08 Jan Friesse <jfriesse@redhat.com>
+
+ init: Use cpgtool instead of cfgtool
+ Init script used to use corosync-cfgtool -s to wait till
+ corosync accepts ipc connection. Problem with this approach
+ is that error code is returned not only if ipc cannot be initialized,
+ but also when one of the ring is marked as failed, making corosync
+ service not to start. Corosync with one failed ring can work just
+ fine and there is no need to fail startup.
+
+ Patch is changing call of corosync-cfgtool to corosync-cpgtool. Also to
+ make spotting of broken ring easier, corosync-cfgtool -s is called after
+ successful return of the cpgtool, and warning is issued if cfgtool
+ fails.
+
+ Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
+
+ notifyd: Fix warning produced by 32-bit compiler
+ time_t is platform dependent real type which is usually long int on
+ 64-bit platform, but only int on 32-bit platform and printing it with
+ %ld generated warning.
+
+ Solution seems to be ether retype time_t to long int or use functions
+ which works with time_t. Later option is used in this patch, which uses
+ localtime and strftime to print time_t value.
+
+ Also code is refactored to remove duplicate calls and add _cs_snmp
+ prefix to prevent snmp_ prefix collision.
+
+ Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
+
+ cfgtool: Remove unused code
+ corosync_cfg_ring_status_get returns string status, which is always OK
+ for UDP(U) and detailed status for Knet transport. Previously also
+ FAULTY status was returned for UDP(U) and cfgtool used to return error
+ code back to shell when one of the interfaces was faulty.
+
+ Because FAULTY is now not returned, it's not needed to have code for
+ handling it.
+
+ Also man page was misleading, so it is fixed too.
+
+ Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
+
+2019-07-03 Jan Friesse <jfriesse@redhat.com>
+
+ logging: Add CS_PRI_NODE_ID and CS_PRI_RING_ID
+ Previously node id was logged ether as a %d (most often), %u, %x or
+ PRI.32 and ring id ether as %lld, %llx with various separators (., :, /)
+ between rep nodeid and seq. This seems to cause confusion.
+
+ This patch adds macros CS_PRI_NODE_ID, CS_PRI_RING_ID and
+ CS_PRI_RING_ID_SEQ (CS prefix = corosync, PRI modeled in spirit of
+ inttypes.h PRIx32) and makes code use them.
+
+ Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
+
+2019-07-02 Jan Friesse <jfriesse@redhat.com>
+
+ vqsim: Fix gitignore
+
+2019-06-28 Jan Friesse <jfriesse@redhat.com>
+
+ totemknet: Disable forwarding on shutdown
+ Disabling forwarding will make knet flush the messages (especially
+ LEAVE one).
+
+ Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
+
+2019-06-17 Jan Friesse <jfriesse@redhat.com>
+
+ totemconfig: Fix compiler warning
+ Compiler is unable to understand relation between members and
+ num_configured and warns about uninitialized members. Instead of
+ initializing members to 0 and (potentially after some code
+ refactor) let code fall to display error message, more explicit method
+ of assert is used.
+
+ Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
+
+2019-06-17 Thomas Lamprecht <t.lamprecht@proxmox.com>
+
+ totem: fix check if all nodes have same number of links
+ configured links may not come in order in the interfaces array, which
+ holds an entry for _all_ possible links, not just configured ones.
+
+ So iterate through all interfaces, but skip those which are not
+ configured. This allows to start corosync with a configuration where
+ link 0 is currently not mentioned, as else it was checked but had
+ member_count = 0 from it's default initialization, which then made
+ this code report a false positive for the "Not all nodes have the
+ same number of links" check even on a correct config.
+
+ Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
+ Reviewed-by: Jan Friesse <jfriesse@redhat.com>
+
+ totem: fix check if all nodes have name attrs in multi-link setups
+ As totem_config->interfaces entries are _all_ possible links and not
+ only the configured ones we cannot trust that interface[0] is
+ configured at the time of checking, and thus has a valid
+ member_count. So set the members variable to the member_count entry
+ from an actually configured interface and loop over that one.
+
+ This fixes a case where the check for the name property on all nodes
+ for multi links was skipped if link 0 was not configured, as then its
+ member_count was 0.
+
+ Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
+ Reviewed-by: Jan Friesse <jfriesse@redhat.com>
+
+2019-06-14 dkutergin <dmytro.kutergin@harmonicinc.com>
+
+ corosync-notifyd: Add option to disable DNS lookup
+ New configuration option -n is added.
+
+ Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
+ Reviewed-by: Jan Friesse <jfriesse@redhat.com>
+
+2019-06-14 Jan Friesse <jfriesse@redhat.com>
+
+ totemsrp: Fix warnings produced by gcc 9.1
+ New gcc warn about passing posibly unaligned pointer from packed
+ structure. This shouldn't be problem for x86.
+
+ Implemented solution is to let compiler do its job (compiler knows if
+ pointer is aligned so accessing structure field is safe) and
+ use it together with support for asigning and returning of structure
+ (not a pointer to the structure).
+
+ - srp_addr_copy is removed and replaced by simple assignment
+ - srp_addr_copy_endian_convert is removed and replaced by
+ srp_addr_endian_convert function which takes srp_addr structure and
+ returns endian converted srp_addr structure
+ - functions which accepts srp_addr array are not changed because
+ (luckily) non-aligned pointer is always just one item array and
+ such item is always used as a source pointer so it's possible to use
+ temporary variable
+
+ Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
+
+2019-06-13 Jan Friesse <jfriesse@redhat.com>
+
+ cpg: Move filling of member_list to subfunction
+ Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
+ Reviewed-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
+
+ cpg: Add more comments to notify_lib_joinlist
+ And make handling of left_list more generic. Also free skiplist
+ allocated by joinlist_inform_clients function. Last (but not least)
+ remove czechlish founded (should have been pp of "find").
+
+ Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
+ Reviewed-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
+
+2019-06-13 Fabian Grünbichler <f.gruenbichler@proxmox.com>
+
+ cpg: send single confchg event per group on joinlist
+ using a similar approach to
+
+ 43bead364514e8ae2ba00bcf07c460e31d0b1765
+ "Send one confchg event per CPG group to CPG client"
+
+ which did the same for leave events on a network partition.
+
+ Reviewed-by: Jan Friesse <jfriesse@redhat.com>
+
+ cpg: notify_lib_joinlist: drop conn parameter
+ since it is always set to NULL.
+
+ Reviewed-by: Jan Friesse <jfriesse@redhat.com>
+
2019-06-12 Jan Friesse <jfriesse@redhat.com>
vqsim: Check length of copied optarg
diff --git a/configure b/configure
index d1ecde5..8cecb62 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for corosync 3.0.2.
+# Generated by GNU Autoconf 2.69 for corosync 3.0.3.
#
# Report bugs to <users@clusterlabs.org>.
#
@@ -590,8 +590,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='corosync'
PACKAGE_TARNAME='corosync'
-PACKAGE_VERSION='3.0.2'
-PACKAGE_STRING='corosync 3.0.2'
+PACKAGE_VERSION='3.0.3'
+PACKAGE_STRING='corosync 3.0.3'
PACKAGE_BUGREPORT='users@clusterlabs.org'
PACKAGE_URL=''
@@ -838,6 +838,7 @@ enable_interlib_deps
enable_ansi
enable_fatal_warnings
enable_debug
+with_sanitizers
enable_secure_build
enable_user_flags
enable_coverage
@@ -1423,7 +1424,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures corosync 3.0.2 to adapt to many kinds of systems.
+\`configure' configures corosync 3.0.3 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1493,7 +1494,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of corosync 3.0.2:";;
+ short | recursive ) echo "Configuration of corosync 3.0.3:";;
esac
cat <<\_ACEOF
@@ -1540,6 +1541,9 @@ Optional Packages:
--with-gnu-ld assume the C compiler uses GNU ld [default=no]
--with-sysroot=DIR Search for dependent libraries within DIR
(or the compiler's sysroot if not specified).
+ --with-sanitizers=...,...
+ enable SANitizer build, do *NOT* use for production.
+ Only ASAN/UBSAN/TSAN are currently supported
--with-initconfigdir=DIR
configuration directory [SYSCONFDIR/sysconfig]
--with-initddir=DIR : path to init script directory.
@@ -1650,7 +1654,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-corosync configure 3.0.2
+corosync configure 3.0.3
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2260,7 +2264,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by corosync $as_me 3.0.2, which was
+It was created by corosync $as_me 3.0.3, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -4439,7 +4443,7 @@ fi
# Define the identity of the package.
PACKAGE='corosync'
- VERSION='3.0.2'
+ VERSION='3.0.3'
cat >>confdefs.h <<_ACEOF
@@ -15630,6 +15634,15 @@ if test "${enable_debug+set}" = set; then :
fi
+
+# Check whether --with-sanitizers was given.
+if test "${with_sanitizers+set}" = set; then :
+ withval=$with_sanitizers; SANITIZERS="$withval"
+else
+ SANITIZERS=""
+fi
+
+
# Check whether --enable-secure-build was given.
if test "${enable_secure_build+set}" = set; then :
enableval=$enable_secure_build;
@@ -15846,6 +15859,155 @@ else
GDB_FLAGS="-g"
fi
+# --- ASAN/UBSAN/TSAN (see man gcc) ---
+# when using SANitizers, we need to pass the -fsanitize..
+# to both CFLAGS and LDFLAGS. The CFLAGS/LDFLAGS must be
+# specified as first in the list or there will be runtime
+# issues (for example user has to LD_PRELOAD asan for it to work
+# properly).
+
+if test -n "${SANITIZERS}"; then
+ SANITIZERS=$(echo $SANITIZERS | sed -e 's/,/ /g')
+ for SANITIZER in $SANITIZERS; do
+ case $SANITIZER in
+ asan|ASAN)
+ SANITIZERS_CFLAGS="$SANITIZERS_CFLAGS -fsanitize=address"
+ SANITIZERS_LDFLAGS="$SANITIZERS_LDFLAGS -fsanitize=address -lasan"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lasan" >&5
+$as_echo_n "checking for main in -lasan... " >&6; }
+if ${ac_cv_lib_asan_main+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lasan $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+
+int
+main ()
+{
+return main ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_asan_main=yes
+else
+ ac_cv_lib_asan_main=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_asan_main" >&5
+$as_echo "$ac_cv_lib_asan_main" >&6; }
+if test "x$ac_cv_lib_asan_main" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBASAN 1
+_ACEOF
+
+ LIBS="-lasan $LIBS"
+
+else
+ as_fn_error $? "Unable to find libasan" "$LINENO" 5
+fi
+
+ ;;
+ ubsan|UBSAN)
+ SANITIZERS_CFLAGS="$SANITIZERS_CFLAGS -fsanitize=undefined"
+ SANITIZERS_LDFLAGS="$SANITIZERS_LDFLAGS -fsanitize=undefined -lubsan"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lubsan" >&5
+$as_echo_n "checking for main in -lubsan... " >&6; }
+if ${ac_cv_lib_ubsan_main+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lubsan $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+
+int
+main ()
+{
+return main ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_ubsan_main=yes
+else
+ ac_cv_lib_ubsan_main=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ubsan_main" >&5
+$as_echo "$ac_cv_lib_ubsan_main" >&6; }
+if test "x$ac_cv_lib_ubsan_main" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBUBSAN 1
+_ACEOF
+
+ LIBS="-lubsan $LIBS"
+
+else
+ as_fn_error $? "Unable to find libubsan" "$LINENO" 5
+fi
+
+ ;;
+ tsan|TSAN)
+ SANITIZERS_CFLAGS="$SANITIZERS_CFLAGS -fsanitize=thread"
+ SANITIZERS_LDFLAGS="$SANITIZERS_LDFLAGS -fsanitize=thread -ltsan"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -ltsan" >&5
+$as_echo_n "checking for main in -ltsan... " >&6; }
+if ${ac_cv_lib_tsan_main+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ltsan $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+
+int
+main ()
+{
+return main ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_tsan_main=yes
+else
+ ac_cv_lib_tsan_main=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_tsan_main" >&5
+$as_echo "$ac_cv_lib_tsan_main" >&6; }
+if test "x$ac_cv_lib_tsan_main" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBTSAN 1
+_ACEOF
+
+ LIBS="-ltsan $LIBS"
+
+else
+ as_fn_error $? "Unable to find libtsan" "$LINENO" 5
+fi
+
+ ;;
+ esac
+ done
+fi
# Look for dbus-1
if test "x${enable_dbus}" = xyes; then
@@ -16791,12 +16953,12 @@ INCLUDE_DIRS="$INCLUDE_DIRS -I\$(top_builddir)/include -I\$(top_srcdir)/include"
INCLUDE_DIRS="$INCLUDE_DIRS -I\$(top_builddir)/include/corosync -I\$(top_srcdir)/include/corosync"
# final build of *FLAGS
-CFLAGS="$ENV_CFLAGS $lt_prog_compiler_pic $SEC_FLAGS $OPT_CFLAGS $GDB_FLAGS \
+CFLAGS="$SANITIZERS_CFLAGS $ENV_CFLAGS $lt_prog_compiler_pic $SEC_FLAGS $OPT_CFLAGS $GDB_FLAGS \
$COVERAGE_CFLAGS $EXTRA_WARNINGS \
$WERROR_CFLAGS $LIBQB_CFLAGS \
$SNMP_INCLUDES"
CPPFLAGS="$ENV_CPPFLAGS $ANSI_CPPFLAGS $INCLUDE_DIRS"
-LDFLAGS="$ENV_LDFLAGS $lt_prog_compiler_pic $SEC_LDFLAGS $COVERAGE_LDFLAGS"
+LDFLAGS="$SANITIZERS_LDFLAGS $ENV_LDFLAGS $lt_prog_compiler_pic $SEC_LDFLAGS $COVERAGE_LDFLAGS"
if test "$ap_cv_cc_as_needed" = "yes"; then
LDFLAGS="$LDFLAGS -Wl,--as-needed"
@@ -17460,7 +17622,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by corosync $as_me 3.0.2, which was
+This file was extended by corosync $as_me 3.0.3, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -17526,7 +17688,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-corosync config.status 3.0.2
+corosync config.status 3.0.3
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
diff --git a/configure.ac b/configure.ac
index 22b7898..a88d8af 100644
--- a/configure.ac
+++ b/configure.ac
@@ -325,6 +325,12 @@ AC_ARG_ENABLE([debug],
[ --enable-debug : enable debug build. ],
[ default="no" ])
+AC_ARG_WITH([sanitizers],
+ [AS_HELP_STRING([--with-sanitizers=...,...],
+ [enable SANitizer build, do *NOT* use for production. Only ASAN/UBSAN/TSAN are currently supported])],
+ [ SANITIZERS="$withval" ],
+ [ SANITIZERS="" ])
+
AC_ARG_ENABLE([secure-build],
[ --enable-secure-build : enable PIE/RELRO build. ],
[],
@@ -433,6 +439,35 @@ else
GDB_FLAGS="-g"
fi
+# --- ASAN/UBSAN/TSAN (see man gcc) ---
+# when using SANitizers, we need to pass the -fsanitize..
+# to both CFLAGS and LDFLAGS. The CFLAGS/LDFLAGS must be
+# specified as first in the list or there will be runtime
+# issues (for example user has to LD_PRELOAD asan for it to work
+# properly).
+
+if test -n "${SANITIZERS}"; then
+ SANITIZERS=$(echo $SANITIZERS | sed -e 's/,/ /g')
+ for SANITIZER in $SANITIZERS; do
+ case $SANITIZER in
+ asan|ASAN)
+ SANITIZERS_CFLAGS="$SANITIZERS_CFLAGS -fsanitize=address"
+ SANITIZERS_LDFLAGS="$SANITIZERS_LDFLAGS -fsanitize=address -lasan"
+ AC_CHECK_LIB([asan],[main],,AC_MSG_ERROR([Unable to find libasan]))
+ ;;
+ ubsan|UBSAN)
+ SANITIZERS_CFLAGS="$SANITIZERS_CFLAGS -fsanitize=undefined"
+ SANITIZERS_LDFLAGS="$SANITIZERS_LDFLAGS -fsanitize=undefined -lubsan"
+ AC_CHECK_LIB([ubsan],[main],,AC_MSG_ERROR([Unable to find libubsan]))
+ ;;
+ tsan|TSAN)
+ SANITIZERS_CFLAGS="$SANITIZERS_CFLAGS -fsanitize=thread"
+ SANITIZERS_LDFLAGS="$SANITIZERS_LDFLAGS -fsanitize=thread -ltsan"
+ AC_CHECK_LIB([tsan],[main],,AC_MSG_ERROR([Unable to find libtsan]))
+ ;;
+ esac
+ done
+fi
# Look for dbus-1
if test "x${enable_dbus}" = xyes; then
@@ -681,12 +716,12 @@ INCLUDE_DIRS="$INCLUDE_DIRS -I\$(top_builddir)/include -I\$(top_srcdir)/include"
INCLUDE_DIRS="$INCLUDE_DIRS -I\$(top_builddir)/include/corosync -I\$(top_srcdir)/include/corosync"
# final build of *FLAGS
-CFLAGS="$ENV_CFLAGS $lt_prog_compiler_pic $SEC_FLAGS $OPT_CFLAGS $GDB_FLAGS \
+CFLAGS="$SANITIZERS_CFLAGS $ENV_CFLAGS $lt_prog_compiler_pic $SEC_FLAGS $OPT_CFLAGS $GDB_FLAGS \
$COVERAGE_CFLAGS $EXTRA_WARNINGS \
$WERROR_CFLAGS $LIBQB_CFLAGS \
$SNMP_INCLUDES"
CPPFLAGS="$ENV_CPPFLAGS $ANSI_CPPFLAGS $INCLUDE_DIRS"
-LDFLAGS="$ENV_LDFLAGS $lt_prog_compiler_pic $SEC_LDFLAGS $COVERAGE_LDFLAGS"
+LDFLAGS="$SANITIZERS_LDFLAGS $ENV_LDFLAGS $lt_prog_compiler_pic $SEC_LDFLAGS $COVERAGE_LDFLAGS"
if test "$ap_cv_cc_as_needed" = "yes"; then
LDFLAGS="$LDFLAGS -Wl,--as-needed"
diff --git a/exec/cfg.c b/exec/cfg.c
index f42cb60..28ba58d 100644
--- a/exec/cfg.c
+++ b/exec/cfg.c
@@ -514,11 +514,11 @@ static void message_handler_req_exec_cfg_killnode (
cs_name_t reason;
ENTER();
- log_printf(LOGSYS_LEVEL_DEBUG, "request to kill node %d(us=%d)",
+ log_printf(LOGSYS_LEVEL_DEBUG, "request to kill node " CS_PRI_NODE_ID " (us=" CS_PRI_NODE_ID ")",
req_exec_cfg_killnode->nodeid, api->totem_nodeid_get());
if (req_exec_cfg_killnode->nodeid == api->totem_nodeid_get()) {
marshall_from_mar_name_t(&reason, &req_exec_cfg_killnode->reason);
- log_printf(LOGSYS_LEVEL_NOTICE, "Killed by node %d: %s",
+ log_printf(LOGSYS_LEVEL_NOTICE, "Killed by node " CS_PRI_NODE_ID " : %s",
nodeid, reason.value);
corosync_fatal_error(COROSYNC_FATAL_ERROR_EXIT);
}
@@ -534,7 +534,7 @@ static void message_handler_req_exec_cfg_shutdown (
{
ENTER();
- log_printf(LOGSYS_LEVEL_NOTICE, "Node %d was shut down by sysadmin", nodeid);
+ log_printf(LOGSYS_LEVEL_NOTICE, "Node " CS_PRI_NODE_ID " was shut down by sysadmin", nodeid);
if (nodeid == api->totem_nodeid_get()) {
api->shutdown_request();
}
@@ -674,7 +674,7 @@ static void message_handler_req_exec_cfg_reload_config (
ENTER();
- log_printf(LOGSYS_LEVEL_NOTICE, "Config reload requested by node %d", nodeid);
+ log_printf(LOGSYS_LEVEL_NOTICE, "Config reload requested by node " CS_PRI_NODE_ID, nodeid);
/*
* Set up a new hashtable as a staging area.
diff --git a/exec/cmap.c b/exec/cmap.c
index 5165670..f3e3637 100644
--- a/exec/cmap.c
+++ b/exec/cmap.c
@@ -1050,7 +1050,7 @@ static void message_handler_req_exec_cmap_mcast_reason_sync_nv(
}
}
- qb_log(LOG_TRACE, "Received config version %"PRIu64" from node %x", config_version, nodeid);
+ qb_log(LOG_TRACE, "Received config version %"PRIu64" from node " CS_PRI_NODE_ID, config_version, nodeid);
if (nodeid != api->totem_nodeid_get() &&
config_version > cmap_highest_config_version_received) {
diff --git a/exec/cpg.c b/exec/cpg.c
index e39ca34..e1ab085 100644
--- a/exec/cpg.c
+++ b/exec/cpg.c
@@ -194,6 +194,12 @@ struct join_list_entry {
mar_cpg_name_t group_name;
};
+struct join_list_confchg_data {
+ mar_cpg_name_t cpg_group;
+ mar_cpg_address_t join_list[CPG_MEMBERS_MAX];
+ int join_list_entries;
+};
+
/*
* Service Interfaces required by service_message_handler struct
*/
@@ -312,7 +318,8 @@ static void do_proc_join(
const mar_cpg_name_t *name,
uint32_t pid,
unsigned int nodeid,
- int reason);
+ int reason,
+ qb_map_t *group_notify_map);
static void do_proc_leave(
const mar_cpg_name_t *name,
@@ -645,43 +652,81 @@ static int notify_lib_totem_membership (
return CS_OK;
}
-static int notify_lib_joinlist(
+/*
+ * Helper function for notify_lib_joinlist which prepares member_list using
+ * process_info_list with removed left_list items.
+ * member_list_entries - When not NULL it contains number of member_list entries
+ * member_list - When not NULL it is used as pointer to start of preallocated
+ * array of members. Pointer is adjusted to the end of array on
+ * exit.
+ */
+static void notify_lib_joinlist_fill_member_list(
const mar_cpg_name_t *group_name,
- void *conn,
- int joined_list_entries,
- mar_cpg_address_t *joined_list,
int left_list_entries,
- mar_cpg_address_t *left_list,
- int id)
+ const mar_cpg_address_t *left_list,
+ int *member_list_entries,
+ mar_cpg_address_t **member_list)
{
- int size;
- char *buf;
struct qb_list_head *iter;
- int count;
- struct res_lib_cpg_confchg_callback *res;
- mar_cpg_address_t *retgi;
+ int i;
- count = 0;
+ if (member_list_entries != NULL) {
+ *member_list_entries = 0;
+ }
qb_list_for_each(iter, &process_info_list_head) {
struct process_info *pi = qb_list_entry (iter, struct process_info, list);
+
if (mar_name_compare (&pi->group, group_name) == 0) {
- int i;
- int founded = 0;
+ int in_left_list = 0;
for (i = 0; i < left_list_entries; i++) {
if (left_list[i].nodeid == pi->nodeid && left_list[i].pid == pi->pid) {
- founded++;
+ in_left_list = 1;
+ break ;
}
}
- if (!founded)
- count++;
+ if (!in_left_list) {
+ if (member_list_entries != NULL) {
+ (*member_list_entries)++;
+ }
+
+ if (member_list != NULL) {
+ (*member_list)->nodeid = pi->nodeid;
+ (*member_list)->pid = pi->pid;
+ (*member_list)->reason = CPG_REASON_UNDEFINED;
+ (*member_list)++;
+ }
+ }
}
}
+}
+
+static int notify_lib_joinlist(
+ const mar_cpg_name_t *group_name,
+ int joined_list_entries,
+ mar_cpg_address_t *joined_list,
+ int left_list_entries,
+ mar_cpg_address_t *left_list,
+ int id)
+{
+ int size;
+ char *buf;
+ struct qb_list_head *iter;
+ int member_list_entries;
+ struct res_lib_cpg_confchg_callback *res;
+ mar_cpg_address_t *retgi;
+ int i;
+
+ /*
+ * Find size of member_list (use process_info_list but remove items in left_list)
+ */
+ notify_lib_joinlist_fill_member_list(group_name, left_list_entries, left_list,
+ &member_list_entries, NULL);
size = sizeof(struct res_lib_cpg_confchg_callback) +
- sizeof(mar_cpg_address_t) * (count + left_list_entries + joined_list_entries);
+ sizeof(mar_cpg_address_t) * (member_list_entries + left_list_entries + joined_list_entries);
buf = alloca(size);
if (!buf)
return CS_ERR_LIBRARY;
@@ -689,69 +734,79 @@ static int notify_lib_joinlist(
res = (struct res_lib_cpg_confchg_callback *)buf;
res->joined_list_entries = joined_list_entries;
res->left_list_entries = left_list_entries;
- res->member_list_entries = count;
+ res->member_list_entries = member_list_entries;
retgi = res->member_list;
res->header.size = size;
res->header.id = id;
res->header.error = CS_OK;
memcpy(&res->group_name, group_name, sizeof(mar_cpg_name_t));
- qb_list_for_each(iter, &process_info_list_head) {
- struct process_info *pi=qb_list_entry (iter, struct process_info, list);
-
- if (mar_name_compare (&pi->group, group_name) == 0) {
- int i;
- int founded = 0;
-
- for (i = 0;i < left_list_entries; i++) {
- if (left_list[i].nodeid == pi->nodeid && left_list[i].pid == pi->pid) {
- founded++;
- }
- }
-
- if (!founded) {
- retgi->nodeid = pi->nodeid;
- retgi->pid = pi->pid;
- retgi->reason = CPG_REASON_UNDEFINED;
- retgi++;
- }
- }
- }
+ /*
+ * Fill res->memberlist. Use process_info_list but remove items in left_list.
+ */
+ notify_lib_joinlist_fill_member_list(group_name, left_list_entries, left_list,
+ NULL, &retgi);
+ /*
+ * Fill res->left_list
+ */
if (left_list_entries) {
memcpy (retgi, left_list, left_list_entries * sizeof(mar_cpg_address_t));
retgi += left_list_entries;
}
if (joined_list_entries) {
+ /*
+ * Fill res->joined_list
+ */
memcpy (retgi, joined_list, joined_list_entries * sizeof(mar_cpg_address_t));
retgi += joined_list_entries;
- }
- if (conn) {
- api->ipc_dispatch_send (conn, buf, size);
- } else {
- qb_list_for_each(iter, &cpg_pd_list_head) {
- struct cpg_pd *cpd = qb_list_entry (iter, struct cpg_pd, list);
- if (mar_name_compare (&cpd->group_name, group_name) == 0) {
- assert (joined_list_entries <= 1);
- if (joined_list_entries) {
- if (joined_list[0].pid == cpd->pid &&
- joined_list[0].nodeid == api->totem_nodeid_get()) {
+ /*
+ * Update cpd_state for all local joined processes in group
+ */
+ for (i = 0; i < joined_list_entries; i++) {
+ if (joined_list[i].nodeid == api->totem_nodeid_get()) {
+ qb_list_for_each(iter, &cpg_pd_list_head) {
+ struct cpg_pd *cpd = qb_list_entry (iter, struct cpg_pd, list);
+ if (joined_list[i].pid == cpd->pid &&
+ mar_name_compare (&cpd->group_name, group_name) == 0) {
cpd->cpd_state = CPD_STATE_JOIN_COMPLETED;
}
}
- if (cpd->cpd_state == CPD_STATE_JOIN_COMPLETED ||
- cpd->cpd_state == CPD_STATE_LEAVE_STARTED) {
+ }
+ }
+ }
- api->ipc_dispatch_send (cpd->conn, buf, size);
- cpd->transition_counter++;
- }
- if (left_list_entries) {
- if (left_list[0].pid == cpd->pid &&
- left_list[0].nodeid == api->totem_nodeid_get() &&
- left_list[0].reason == CONFCHG_CPG_REASON_LEAVE) {
+ /*
+ * Send notification to all ipc clients joined in group_name
+ */
+ qb_list_for_each(iter, &cpg_pd_list_head) {
+ struct cpg_pd *cpd = qb_list_entry (iter, struct cpg_pd, list);
+ if (mar_name_compare (&cpd->group_name, group_name) == 0) {
+ if (cpd->cpd_state == CPD_STATE_JOIN_COMPLETED ||
+ cpd->cpd_state == CPD_STATE_LEAVE_STARTED) {
+
+ api->ipc_dispatch_send (cpd->conn, buf, size);
+ cpd->transition_counter++;
+ }
+ }
+ }
+ if (left_list_entries) {
+ /*
+ * Zero internal cpd state for all local processes leaving group
+ * (this loop is not strictly needed because left_list always either
+ * contains exactly one process running on local node or more items
+ * but none of them is running on local node)
+ */
+ for (i = 0; i < joined_list_entries; i++) {
+ if (left_list[i].nodeid == api->totem_nodeid_get() &&
+ left_list[i].reason == CONFCHG_CPG_REASON_LEAVE) {
+ qb_list_for_each(iter, &cpg_pd_list_head) {
+ struct cpg_pd *cpd = qb_list_entry (iter, struct cpg_pd, list);
+ if (left_list[i].pid == cpd->pid &&
+ mar_name_compare (&cpd->group_name, group_name) == 0) {
cpd->pid = 0;
memset (&cpd->group_name, 0, sizeof(cpd->group_name));
cpd->cpd_state = CPD_STATE_UNJOINED;
@@ -761,7 +816,6 @@ static int notify_lib_joinlist(
}
}
-
/*
* Traverse thru cpds and send totem membership for cpd, where it is not send yet
*/
@@ -858,7 +912,7 @@ static void downlist_inform_clients (void)
}
/* send confchg event */
- notify_lib_joinlist(&group, NULL,
+ notify_lib_joinlist(&group,
0, NULL,
pcd->left_list_entries,
pcd->left_list,
@@ -921,6 +975,11 @@ static void joinlist_inform_clients (void)
struct joinlist_msg *stored_msg;
struct qb_list_head *iter;
unsigned int i;
+ qb_map_t *group_notify_map;
+ qb_map_iter_t *miter;
+ struct join_list_confchg_data *jld;
+
+ group_notify_map = qb_skiplist_create();
i = 0;
qb_list_for_each(iter, &joinlist_messages_head) {
@@ -937,9 +996,20 @@ static void joinlist_inform_clients (void)
}
do_proc_join (&stored_msg->group_name, stored_msg->pid, stored_msg->sender_nodeid,
- CONFCHG_CPG_REASON_NODEUP);
+ CONFCHG_CPG_REASON_NODEUP, group_notify_map);
}
+ miter = qb_map_iter_create(group_notify_map);
+ while (qb_map_iter_next(miter, (void **)&jld)) {
+ notify_lib_joinlist(&jld->cpg_group,
+ jld->join_list_entries, jld->join_list,
+ 0, NULL,
+ MESSAGE_RES_CPG_CONFCHG_CALLBACK);
+ free(jld);
+ }
+ qb_map_iter_free(miter);
+ qb_map_destroy(group_notify_map);
+
joinlist_remove_zombie_pi_entries ();
}
@@ -1016,6 +1086,8 @@ static int cpg_node_joinleave_send (unsigned int pid, const mar_cpg_name_t *grou
struct iovec req_exec_cpg_iovec;
int result;
+ memset(&req_exec_cpg_procjoin, 0, sizeof(req_exec_cpg_procjoin));
+
memcpy(&req_exec_cpg_procjoin.group_name, group_name, sizeof(mar_cpg_name_t));
req_exec_cpg_procjoin.pid = pid;
req_exec_cpg_procjoin.reason = reason;
@@ -1117,13 +1189,15 @@ static void do_proc_join(
const mar_cpg_name_t *name,
uint32_t pid,
unsigned int nodeid,
- int reason)
+ int reason,
+ qb_map_t *group_notify_map)
{
struct process_info *pi;
struct process_info *pi_entry;
mar_cpg_address_t notify_info;
struct qb_list_head *list;
struct qb_list_head *list_to_add = NULL;
+ int size;
if (process_info_find (name, pid, nodeid) != NULL) {
return ;
@@ -1157,10 +1231,24 @@ static void do_proc_join(
notify_info.nodeid = nodeid;
notify_info.reason = reason;
- notify_lib_joinlist(&pi->group, NULL,
- 1, &notify_info,
- 0, NULL,
- MESSAGE_RES_CPG_CONFCHG_CALLBACK);
+ if (group_notify_map == NULL) {
+ notify_lib_joinlist(&pi->group,
+ 1, &notify_info,
+ 0, NULL,
+ MESSAGE_RES_CPG_CONFCHG_CALLBACK);
+ } else {
+ struct join_list_confchg_data *jld = qb_map_get(group_notify_map, pi->group.value);
+ if (jld == NULL) {
+ jld = (struct join_list_confchg_data *)calloc(1, sizeof(struct join_list_confchg_data));
+ memcpy(&jld->cpg_group, &pi->group, sizeof(mar_cpg_name_t));
+ qb_map_put(group_notify_map, jld->cpg_group.value, jld);
+ }
+ size = jld->join_list_entries;
+ jld->join_list[size].nodeid = notify_info.nodeid;
+ jld->join_list[size].pid = notify_info.pid;
+ jld->join_list[size].reason = notify_info.reason;
+ jld->join_list_entries++;
+ }
}
static void do_proc_leave(
@@ -1177,7 +1265,7 @@ static void do_proc_leave(
notify_info.nodeid = nodeid;
notify_info.reason = reason;
- notify_lib_joinlist(name, NULL,
+ notify_lib_joinlist(name,
0, NULL,
1, &notify_info,
MESSAGE_RES_CPG_CONFCHG_CALLBACK);
@@ -1197,7 +1285,7 @@ static void message_handler_req_exec_cpg_downlist_old (
const void *message,
unsigned int nodeid)
{
- log_printf (LOGSYS_LEVEL_WARNING, "downlist OLD from node 0x%x",
+ log_printf (LOGSYS_LEVEL_WARNING, "downlist OLD from node " CS_PRI_NODE_ID,
nodeid);
}
@@ -1218,14 +1306,14 @@ static void message_handler_req_exec_cpg_procjoin (
{
const struct req_exec_cpg_procjoin *req_exec_cpg_procjoin = message;
- log_printf(LOGSYS_LEVEL_DEBUG, "got procjoin message from cluster node 0x%x (%s) for pid %u",
+ log_printf(LOGSYS_LEVEL_DEBUG, "got procjoin message from cluster node " CS_PRI_NODE_ID " (%s) for pid %u",
nodeid,
api->totem_ifaces_print(nodeid),
(unsigned int)req_exec_cpg_procjoin->pid);
do_proc_join (&req_exec_cpg_procjoin->group_name,
req_exec_cpg_procjoin->pid, nodeid,
- CONFCHG_CPG_REASON_JOIN);
+ CONFCHG_CPG_REASON_JOIN, NULL);
}
static void message_handler_req_exec_cpg_procleave (
@@ -1234,7 +1322,7 @@ static void message_handler_req_exec_cpg_procleave (
{
const struct req_exec_cpg_procjoin *req_exec_cpg_procjoin = message;
- log_printf(LOGSYS_LEVEL_DEBUG, "got procleave message from cluster node 0x%x (%s) for pid %u",
+ log_printf(LOGSYS_LEVEL_DEBUG, "got procleave message from cluster node " CS_PRI_NODE_ID " (%s) for pid %u",
nodeid,
api->totem_ifaces_print(nodeid),
(unsigned int)req_exec_cpg_procjoin->pid);
@@ -1255,7 +1343,7 @@ static void message_handler_req_exec_cpg_joinlist (
const struct join_list_entry *jle = (const struct join_list_entry *)(message + sizeof(struct qb_ipc_response_header));
struct joinlist_msg *stored_msg;
- log_printf(LOGSYS_LEVEL_DEBUG, "got joinlist message from node 0x%x",
+ log_printf(LOGSYS_LEVEL_DEBUG, "got joinlist message from node " CS_PRI_NODE_ID,
nodeid);
while ((const char*)jle < message + res->size) {
@@ -1336,7 +1424,7 @@ static void message_handler_req_exec_cpg_partial_mcast (
struct iovec iovec[2];
int known_node = 0;
- log_printf(LOGSYS_LEVEL_DEBUG, "Got fragmented message from node %d, size = %d bytes\n", nodeid, msglen);
+ log_printf(LOGSYS_LEVEL_DEBUG, "Got fragmented message from node " CS_PRI_NODE_ID ", size = %d bytes\n", nodeid, msglen);
res_lib_cpg_mcast.header.id = MESSAGE_RES_CPG_PARTIAL_DELIVER_CALLBACK;
res_lib_cpg_mcast.header.size = sizeof(res_lib_cpg_mcast) + msglen;
@@ -1404,7 +1492,8 @@ static int cpg_exec_send_joinlist(void)
int count = 0;
struct qb_list_head *iter;
struct qb_ipc_response_header *res;
- char *buf;
+ char *buf;
+ size_t buf_size;
struct join_list_entry *jle;
struct iovec req_exec_cpg_iovec;
@@ -1420,11 +1509,13 @@ static int cpg_exec_send_joinlist(void)
if (!count)
return 0;
- buf = alloca(sizeof(struct qb_ipc_response_header) + sizeof(struct join_list_entry) * count);
+ buf_size = sizeof(struct qb_ipc_response_header) + sizeof(struct join_list_entry) * count;
+ buf = alloca(buf_size);
if (!buf) {
log_printf(LOGSYS_LEVEL_WARNING, "Unable to allocate joinlist buffer");
return -1;
}
+ memset(buf, 0, buf_size);
jle = (struct join_list_entry *)(buf + sizeof(struct qb_ipc_response_header));
res = (struct qb_ipc_response_header *)buf;
@@ -1891,6 +1982,8 @@ static void message_handler_req_lib_cpg_mcast (void *conn, const void *message)
}
if (error == CS_OK) {
+ memset(&req_exec_cpg_mcast, 0, sizeof(req_exec_cpg_mcast));
+
req_exec_cpg_mcast.header.size = sizeof(req_exec_cpg_mcast) + msglen;
req_exec_cpg_mcast.header.id = SERVICE_ID_MAKE(CPG_SERVICE,
MESSAGE_REQ_EXEC_CPG_MCAST);
diff --git a/exec/icmap.c b/exec/icmap.c
index 97f8279..9bbf30f 100644
--- a/exec/icmap.c
+++ b/exec/icmap.c
@@ -730,6 +730,40 @@ cs_error_t icmap_get(
return (icmap_get_r(icmap_global_map, key_name, value, value_len, type));
}
+cs_error_t icmap_get_string_r(icmap_map_t map, const char *key_name, char **str)
+{
+ cs_error_t res;
+ size_t str_len;
+ icmap_value_types_t type;
+
+ res = icmap_get_r(map, key_name, NULL, &str_len, &type);
+ if (res != CS_OK || type != ICMAP_VALUETYPE_STRING) {
+ if (res == CS_OK) {
+ res = CS_ERR_INVALID_PARAM;
+ }
+
+ goto return_error;
+ }
+
+ *str = malloc(str_len);
+ if (*str == NULL) {
+ res = CS_ERR_NO_MEMORY;
+
+ goto return_error;
+ }
+
+ res = icmap_get_r(map, key_name, *str, &str_len, &type);
+ if (res != CS_OK) {
+ free(*str);
+ goto return_error;
+ }
+
+ return (CS_OK);
+
+return_error:
+ return (res);
+}
+
static cs_error_t icmap_get_int_r(
const icmap_map_t map,
const char *key_name,
@@ -744,7 +778,7 @@ static cs_error_t icmap_get_int_r(
key_size = sizeof(key_value);
memset(key_value, 0, key_size);
- err = icmap_get(key_name, key_value, &key_size, &key_type);
+ err = icmap_get_r(map, key_name, key_value, &key_size, &key_type);
if (err != CS_OK)
return (err);
@@ -817,6 +851,12 @@ cs_error_t icmap_get_double_r(const icmap_map_t map, const char *key_name, doubl
return (icmap_get_int_r(map, key_name, dbl, ICMAP_VALUETYPE_DOUBLE));
}
+cs_error_t icmap_get_string(const char *key_name, char **str)
+{
+
+ return (icmap_get_string_r(icmap_global_map, key_name, str));
+}
+
cs_error_t icmap_get_int8(const char *key_name, int8_t *i8)
{
@@ -877,40 +917,6 @@ cs_error_t icmap_get_double(const char *key_name, double *dbl)
return (icmap_get_double_r(icmap_global_map, key_name, dbl));
}
-cs_error_t icmap_get_string(const char *key_name, char **str)
-{
- cs_error_t res;
- size_t str_len;
- icmap_value_types_t type;
-
- res = icmap_get(key_name, NULL, &str_len, &type);
- if (res != CS_OK || type != ICMAP_VALUETYPE_STRING) {
- if (res == CS_OK) {
- res = CS_ERR_INVALID_PARAM;
- }
-
- goto return_error;
- }
-
- *str = malloc(str_len);
- if (*str == NULL) {
- res = CS_ERR_NO_MEMORY;
-
- goto return_error;
- }
-
- res = icmap_get(key_name, *str, &str_len, &type);
- if (res != CS_OK) {
- free(*str);
- goto return_error;
- }
-
- return (CS_OK);
-
-return_error:
- return (res);
-}
-
cs_error_t icmap_adjust_int_r(
const icmap_map_t map,
const char *key_name,
diff --git a/exec/main.c b/exec/main.c
index 06a519c..7a471a1 100644
--- a/exec/main.c
+++ b/exec/main.c
@@ -692,18 +692,18 @@ static void corosync_ring_id_store (
}
if (fd == -1) {
LOGSYS_PERROR(errno, LOGSYS_LEVEL_ERROR,
- "Couldn't store new ring id %llx to stable storage",
- memb_ring_id->seq);
+ "Couldn't store new ring id " CS_PRI_RING_ID_SEQ " to stable storage",
+ memb_ring_id->seq);
corosync_exit_error (COROSYNC_DONE_STORE_RINGID);
}
log_printf (LOGSYS_LEVEL_DEBUG,
- "Storing new sequence id for ring %llx", memb_ring_id->seq);
+ "Storing new sequence id for ring " CS_PRI_RING_ID_SEQ, memb_ring_id->seq);
res = write (fd, &memb_ring_id->seq, sizeof(memb_ring_id->seq));
close (fd);
if (res != sizeof(memb_ring_id->seq)) {
LOGSYS_PERROR(errno, LOGSYS_LEVEL_ERROR,
- "Couldn't store new ring id %llx to stable storage",
+ "Couldn't store new ring id " CS_PRI_RING_ID_SEQ " to stable storage",
memb_ring_id->seq);
corosync_exit_error (COROSYNC_DONE_STORE_RINGID);
diff --git a/exec/sync.c b/exec/sync.c
index 1efa357..06cb456 100644
--- a/exec/sync.c
+++ b/exec/sync.c
@@ -335,6 +335,8 @@ static void barrier_message_transmit (void)
struct iovec iovec;
struct req_exec_barrier_message req_exec_barrier_message;
+ memset(&req_exec_barrier_message, 0, sizeof(req_exec_barrier_message));
+
req_exec_barrier_message.header.size = sizeof (struct req_exec_barrier_message);
req_exec_barrier_message.header.id = MESSAGE_REQ_SYNC_BARRIER;
@@ -436,6 +438,8 @@ static void sync_servicelist_build_enter (
int res;
struct sync_callbacks sync_callbacks;
+ memset(&service_build, 0, sizeof(service_build));
+
my_state = SYNC_SERVICELIST_BUILD;
for (i = 0; i < member_list_entries; i++) {
my_processor_list[i].nodeid = member_list[i];
diff --git a/exec/totemconfig.c b/exec/totemconfig.c
index ff86e23..bd688e6 100644
--- a/exec/totemconfig.c
+++ b/exec/totemconfig.c
@@ -81,7 +81,7 @@
#define MISS_COUNT_CONST 5
#define BLOCK_UNLISTED_IPS 1
-/* These currently match the defaults in libknet.h */
+/* Currently all but PONG_COUNT match the defaults in libknet.h */
#define KNET_PING_INTERVAL 1000
#define KNET_PING_TIMEOUT 2000
#define KNET_PING_PRECISION 2048
@@ -447,16 +447,22 @@ static int totem_volatile_config_validate (
/* Check that we have nodelist 'name' if there is more than one link */
num_configured = 0;
+ members = -1;
for (i = 0; i < INTERFACE_MAX; i++) {
if (totem_config->interfaces[i].configured) {
+ if (num_configured == 0) {
+ members = totem_config->interfaces[i].member_count;
+ }
num_configured++;
}
}
if (num_configured > 1) {
- members = totem_config->interfaces[0].member_count;
-
- for (i=0; i<totem_config->interfaces[0].member_count; i++) {
+ /*
+ * This assert is here just to make compiler happy
+ */
+ assert(members != -1);
+ for (i=0; i < members; i++) {
snprintf(name_key, sizeof(name_key), "nodelist.node.%d.name", i);
if (icmap_get_string(name_key, &name_str) != CS_OK) {
@@ -466,7 +472,10 @@ static int totem_volatile_config_validate (
}
}
- for (i=0; i<num_configured; i++) {
+ for (i=0; i < INTERFACE_MAX; i++) {
+ if (!totem_config->interfaces[i].configured) {
+ continue;
+ }
if (totem_config->interfaces[i].member_count != members) {
snprintf (local_error_reason, sizeof(local_error_reason),
"Not all nodes have the same number of links");
@@ -1334,7 +1343,7 @@ static int put_nodelist_members_to_config(struct totem_config *totem_config, int
}
log_printf(LOGSYS_LEVEL_DEBUG,
- "Generated nodeid = 0x%x for %s", nodeid, str);
+ "Generated nodeid = " CS_PRI_NODE_ID " for %s", nodeid, str);
free(str);
}
}
diff --git a/exec/totemknet.c b/exec/totemknet.c
index e6e04d3..9e60273 100644
--- a/exec/totemknet.c
+++ b/exec/totemknet.c
@@ -51,6 +51,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
+#include <pthread.h>
#include <sched.h>
#include <time.h>
#include <sys/time.h>
@@ -171,6 +172,8 @@ struct totemknet_instance {
int logpipes[2];
int knet_fd;
+
+ pthread_mutex_t log_mutex;
#ifdef HAVE_LIBNOZZLE
char *nozzle_name;
char *nozzle_ipaddr;
@@ -203,20 +206,36 @@ static void log_flush_messages (
static void totemknet_instance_initialize (struct totemknet_instance *instance)
{
+ int res;
+
memset (instance, 0, sizeof (struct totemknet_instance));
+ res = pthread_mutex_init(&instance->log_mutex, NULL);
+ /*
+ * There is not too much else what can be done.
+ */
+ assert(res == 0);
}
+#define knet_log_printf_lock(level, subsys, function, file, line, format, args...) \
+do { \
+ (void)pthread_mutex_lock(&instance->log_mutex); \
+ instance->totemknet_log_printf ( \
+ level, subsys, function, file, line, \
+ (const char *)format, ##args); \
+ (void)pthread_mutex_unlock(&instance->log_mutex); \
+} while (0);
+
#define knet_log_printf(level, format, args...) \
do { \
- instance->totemknet_log_printf ( \
+ knet_log_printf_lock ( \
level, instance->totemknet_subsys_id, \
__FUNCTION__, __FILE__, __LINE__, \
(const char *)format, ##args); \
} while (0);
-#define libknet_log_printf(level, format, args...) \
+#define libknet_log_printf(level, format, args...) \
do { \
- instance->totemknet_log_printf ( \
+ knet_log_printf_lock ( \
level, instance->knet_subsys_id, \
__FUNCTION__, "libknet.h", __LINE__, \
(const char *)format, ##args); \
@@ -324,7 +343,7 @@ static void host_change_callback_fn(void *private_data, knet_node_id_t host_id,
struct totemknet_instance *instance = (struct totemknet_instance *)private_data;
// TODO: what? if anything.
- knet_log_printf (LOGSYS_LEVEL_DEBUG, "Knet host change callback. nodeid: %d reachable: %d", host_id, reachable);
+ knet_log_printf (LOGSYS_LEVEL_DEBUG, "Knet host change callback. nodeid: " CS_PRI_NODE_ID " reachable: %d", host_id, reachable);
}
static void pmtu_change_callback_fn(void *private_data, unsigned int data_mtu)
@@ -554,6 +573,14 @@ int totemknet_finalize (
qb_loop_poll_del (instance->poll_handle, instance->logpipes[0]);
qb_loop_poll_del (instance->poll_handle, instance->knet_fd);
+ /*
+ * Disable forwarding to make knet flush send queue. This ensures that the LEAVE message will be sent.
+ */
+ res = knet_handle_setfwd(instance->knet_handle, 0);
+ if (res) {
+ knet_log_printf (LOGSYS_LEVEL_CRIT, "totemknet: knet_handle_setfwd failed: %s", strerror(errno));
+ }
+
res = knet_host_get_host_list(instance->knet_handle, nodes, &num_nodes);
if (res) {
knet_log_printf (LOGSYS_LEVEL_ERROR, "Cannot get knet node list for shutdown: %s", strerror(errno));
@@ -561,35 +588,31 @@ int totemknet_finalize (
goto finalise_error;
}
- /* Tidily shut down all nodes & links. This ensures that the LEAVE message will be sent */
+ /* Tidily shut down all nodes & links. */
for (i=0; i<num_nodes; i++) {
res = knet_link_get_link_list(instance->knet_handle, nodes[i], links, &num_links);
if (res) {
- knet_log_printf (LOGSYS_LEVEL_ERROR, "Cannot get knet link list for node %d: %s", nodes[i], strerror(errno));
+ knet_log_printf (LOGSYS_LEVEL_ERROR, "Cannot get knet link list for node " CS_PRI_NODE_ID ": %s", nodes[i], strerror(errno));
goto finalise_error;
}
for (j=0; j<num_links; j++) {
res = knet_link_set_enable(instance->knet_handle, nodes[i], links[j], 0);
if (res) {
- knet_log_printf (LOGSYS_LEVEL_ERROR, "totemknet: knet_link_set_enable(node %d, link %d) failed: %s", nodes[i], links[j], strerror(errno));
+ knet_log_printf (LOGSYS_LEVEL_ERROR, "totemknet: knet_link_set_enable(node " CS_PRI_NODE_ID ", link %d) failed: %s", nodes[i], links[j], strerror(errno));
}
res = knet_link_clear_config(instance->knet_handle, nodes[i], links[j]);
if (res) {
- knet_log_printf (LOGSYS_LEVEL_ERROR, "totemknet: knet_link_clear_config(node %d, link %d) failed: %s", nodes[i], links[j], strerror(errno));
+ knet_log_printf (LOGSYS_LEVEL_ERROR, "totemknet: knet_link_clear_config(node " CS_PRI_NODE_ID ", link %d) failed: %s", nodes[i], links[j], strerror(errno));
}
}
res = knet_host_remove(instance->knet_handle, nodes[i]);
if (res) {
- knet_log_printf (LOGSYS_LEVEL_ERROR, "totemknet: knet_host_remove(node %d) failed: %s", nodes[i], strerror(errno));
+ knet_log_printf (LOGSYS_LEVEL_ERROR, "totemknet: knet_host_remove(node " CS_PRI_NODE_ID ") failed: %s", nodes[i], strerror(errno));
}
}
finalise_error:
- res = knet_handle_setfwd(instance->knet_handle, 0);
- if (res) {
- knet_log_printf (LOGSYS_LEVEL_CRIT, "totemknet: knet_handle_setfwd failed: %s", strerror(errno));
- }
res = knet_handle_free(instance->knet_handle);
if (res) {
knet_log_printf (LOGSYS_LEVEL_CRIT, "totemknet: knet_handle_free failed: %s", strerror(errno));
@@ -599,6 +622,11 @@ finalise_error:
log_flush_messages(instance);
+ /*
+ * Error is deliberately ignored
+ */
+ (void)pthread_mutex_destroy(&instance->log_mutex);
+
return (res);
}
@@ -810,17 +838,17 @@ static void totemknet_refresh_config(
instance->totem_config->interfaces[link_no].knet_ping_timeout,
instance->totem_config->interfaces[link_no].knet_ping_precision);
if (err) {
- KNET_LOGSYS_PERROR(errno, LOGSYS_LEVEL_ERROR, "knet_link_set_ping_timers for node %d link %d failed", host_ids[i], link_no);
+ KNET_LOGSYS_PERROR(errno, LOGSYS_LEVEL_ERROR, "knet_link_set_ping_timers for node " CS_PRI_NODE_ID " link %d failed", host_ids[i], link_no);
}
err = knet_link_set_pong_count(instance->knet_handle, host_ids[i], link_no,
instance->totem_config->interfaces[link_no].knet_pong_count);
if (err) {
- KNET_LOGSYS_PERROR(errno, LOGSYS_LEVEL_ERROR, "knet_link_set_pong_count for node %d link %d failed",host_ids[i], link_no);
+ KNET_LOGSYS_PERROR(errno, LOGSYS_LEVEL_ERROR, "knet_link_set_pong_count for node " CS_PRI_NODE_ID " link %d failed",host_ids[i], link_no);
}
err = knet_link_set_priority(instance->knet_handle, host_ids[i], link_no,
instance->totem_config->interfaces[link_no].knet_link_priority);
if (err) {
- KNET_LOGSYS_PERROR(errno, LOGSYS_LEVEL_ERROR, "knet_link_set_priority for node %d link %d failed", host_ids[i], link_no);
+ KNET_LOGSYS_PERROR(errno, LOGSYS_LEVEL_ERROR, "knet_link_set_priority for node " CS_PRI_NODE_ID " link %d failed", host_ids[i], link_no);
}
}
@@ -1263,8 +1291,8 @@ int totemknet_member_add (
}
}
- knet_log_printf (LOGSYS_LEVEL_DEBUG, "knet: member_add: %d (%s), link=%d", member->nodeid, totemip_print(member), link_no);
- knet_log_printf (LOGSYS_LEVEL_DEBUG, "knet: local: %d (%s)", local->nodeid, totemip_print(local));
+ knet_log_printf (LOGSYS_LEVEL_DEBUG, "knet: member_add: " CS_PRI_NODE_ID " (%s), link=%d", member->nodeid, totemip_print(member), link_no);
+ knet_log_printf (LOGSYS_LEVEL_DEBUG, "knet: local: " CS_PRI_NODE_ID " (%s)", local->nodeid, totemip_print(local));
/* Only add the host if it doesn't already exist in knet */
@@ -1286,7 +1314,7 @@ int totemknet_member_add (
return -1;
}
} else {
- knet_log_printf (LOGSYS_LEVEL_DEBUG, "nodeid %d already added", member->nodeid);
+ knet_log_printf (LOGSYS_LEVEL_DEBUG, "nodeid " CS_PRI_NODE_ID " already added", member->nodeid);
}
@@ -1298,6 +1326,7 @@ int totemknet_member_add (
}
memset(&local_ss, 0, sizeof(local_ss));
+ memset(&remote_ss, 0, sizeof(remote_ss));
/* Casts to remove const */
totemip_totemip_to_sockaddr_convert((struct totem_ip_address *)member, port, &remote_ss, &addrlen);
totemip_totemip_to_sockaddr_convert((struct totem_ip_address *)local, port, &local_ss, &addrlen);
@@ -1325,7 +1354,7 @@ int totemknet_member_add (
err = knet_link_set_priority(instance->knet_handle, member->nodeid, link_no,
instance->totem_config->interfaces[link_no].knet_link_priority);
if (err) {
- KNET_LOGSYS_PERROR(errno, LOGSYS_LEVEL_ERROR, "knet_link_set_priority for nodeid %d, link %d failed", member->nodeid, link_no);
+ KNET_LOGSYS_PERROR(errno, LOGSYS_LEVEL_ERROR, "knet_link_set_priority for nodeid " CS_PRI_NODE_ID ", link %d failed", member->nodeid, link_no);
}
/* ping timeouts maybe 0 here for a newly added interface so we leave this till later, it will
@@ -1336,18 +1365,18 @@ int totemknet_member_add (
instance->totem_config->interfaces[link_no].knet_ping_timeout,
instance->totem_config->interfaces[link_no].knet_ping_precision);
if (err) {
- KNET_LOGSYS_PERROR(errno, LOGSYS_LEVEL_ERROR, "knet_link_set_ping_timers for nodeid %d, link %d failed", member->nodeid, link_no);
+ KNET_LOGSYS_PERROR(errno, LOGSYS_LEVEL_ERROR, "knet_link_set_ping_timers for nodeid " CS_PRI_NODE_ID ", link %d failed", member->nodeid, link_no);
}
err = knet_link_set_pong_count(instance->knet_handle, member->nodeid, link_no,
instance->totem_config->interfaces[link_no].knet_pong_count);
if (err) {
- KNET_LOGSYS_PERROR(errno, LOGSYS_LEVEL_ERROR, "knet_link_set_pong_count for nodeid %d, link %d failed", member->nodeid, link_no);
+ KNET_LOGSYS_PERROR(errno, LOGSYS_LEVEL_ERROR, "knet_link_set_pong_count for nodeid " CS_PRI_NODE_ID ", link %d failed", member->nodeid, link_no);
}
}
err = knet_link_set_enable(instance->knet_handle, member->nodeid, link_no, 1);
if (err) {
- KNET_LOGSYS_PERROR(errno, LOGSYS_LEVEL_ERROR, "knet_link_set_enable for nodeid %d, link %d failed", member->nodeid, link_no);
+ KNET_LOGSYS_PERROR(errno, LOGSYS_LEVEL_ERROR, "knet_link_set_enable for nodeid " CS_PRI_NODE_ID ", link %d failed", member->nodeid, link_no);
return -1;
}
@@ -1366,7 +1395,7 @@ int totemknet_member_remove (
uint8_t link_list[KNET_MAX_LINK];
size_t num_links;
- knet_log_printf (LOGSYS_LEVEL_DEBUG, "knet: member_remove: %d, link=%d", token_target->nodeid, link_no);
+ knet_log_printf (LOGSYS_LEVEL_DEBUG, "knet: member_remove: " CS_PRI_NODE_ID ", link=%d", token_target->nodeid, link_no);
/* Don't remove the link with the loopback on it until we shut down */
if (token_target->nodeid == instance->our_nodeid) {
@@ -1379,13 +1408,13 @@ int totemknet_member_remove (
/* Remove the link first */
res = knet_link_set_enable(instance->knet_handle, token_target->nodeid, link_no, 0);
if (res != 0) {
- KNET_LOGSYS_PERROR(errno, LOGSYS_LEVEL_ERROR, "knet_link_set enable(off) for nodeid %d, link %d failed", token_target->nodeid, link_no);
+ KNET_LOGSYS_PERROR(errno, LOGSYS_LEVEL_ERROR, "knet_link_set enable(off) for nodeid " CS_PRI_NODE_ID ", link %d failed", token_target->nodeid, link_no);
return res;
}
res = knet_link_clear_config(instance->knet_handle, token_target->nodeid, link_no);
if (res != 0) {
- KNET_LOGSYS_PERROR(errno, LOGSYS_LEVEL_ERROR, "knet_link_clear_config for nodeid %d, link %d failed", token_target->nodeid, link_no);
+ KNET_LOGSYS_PERROR(errno, LOGSYS_LEVEL_ERROR, "knet_link_clear_config for nodeid " CS_PRI_NODE_ID ", link %d failed", token_target->nodeid, link_no);
return res;
}
diff --git a/exec/totempg.c b/exec/totempg.c
index 6b3c590..d9a79e2 100644
--- a/exec/totempg.c
+++ b/exec/totempg.c
@@ -603,10 +603,18 @@ static void totempg_deliver_fn (
const char *data;
int datasize;
struct iovec iov_delv;
+ size_t expected_msg_len;
assembly = assembly_ref (nodeid);
assert (assembly);
+ if (msg_len < sizeof(struct totempg_mcast)) {
+ log_printf(LOG_WARNING,
+ "Message (totempg_mcast) received from node " CS_PRI_NODE_ID " is too short... Ignoring.", nodeid);
+
+ return ;
+ }
+
/*
* Assemble the header into one block of data and
* assemble the packet contents into one block of data to simplify delivery
@@ -621,14 +629,34 @@ static void totempg_deliver_fn (
datasize = sizeof (struct totempg_mcast) +
msg_count * sizeof (unsigned short);
+ if (msg_len < datasize) {
+ log_printf(LOG_WARNING,
+ "Message (totempg_mcast datasize) received from node " CS_PRI_NODE_ID
+ " is too short... Ignoring.", nodeid);
+
+ return ;
+ }
+
memcpy (header, msg, datasize);
data = msg;
msg_lens = (unsigned short *) (header + sizeof (struct totempg_mcast));
- if (endian_conversion_required) {
- for (i = 0; i < mcast->msg_count; i++) {
+ expected_msg_len = datasize;
+ for (i = 0; i < mcast->msg_count; i++) {
+ if (endian_conversion_required) {
msg_lens[i] = swab16 (msg_lens[i]);
}
+
+ expected_msg_len += msg_lens[i];
+ }
+
+ if (msg_len != expected_msg_len) {
+ log_printf(LOG_WARNING,
+ "Message (totempg_mcast) received from node " CS_PRI_NODE_ID
+ " doesn't have expected length of %zu (has %u) bytes... Ignoring.",
+ nodeid, expected_msg_len, msg_len);
+
+ return ;
}
assert((assembly->index+msg_len) < sizeof(assembly->data));
@@ -892,6 +920,8 @@ static int mcast_msg (
return(-1);
}
+ memset(&mcast, 0, sizeof(mcast));
+
mcast.header.version = 0;
for (i = 0; i < iov_len; ) {
mcast.fragmented = 0;
diff --git a/exec/totemsrp.c b/exec/totemsrp.c
index a48d97b..d8e960a 100644
--- a/exec/totemsrp.c
+++ b/exec/totemsrp.c
@@ -616,8 +616,6 @@ static int message_handler_token_hold_cancel (
static void totemsrp_instance_initialize (struct totemsrp_instance *instance);
-static void srp_addr_copy (struct srp_addr *dest, const struct srp_addr *src);
-
static void srp_addr_to_nodeid (
struct totemsrp_instance *instance,
unsigned int *nodeid_out,
@@ -651,7 +649,7 @@ static void mcast_endian_convert (const struct mcast *in, struct mcast *out);
static void memb_merge_detect_endian_convert (
const struct memb_merge_detect *in,
struct memb_merge_detect *out);
-static void srp_addr_copy_endian_convert (struct srp_addr *out, const struct srp_addr *in);
+static struct srp_addr srp_addr_endian_convert (struct srp_addr in);
static void timer_function_orf_token_timeout (void *data);
static void timer_function_orf_token_warning (void *data);
static void timer_function_pause_timeout (void *data);
@@ -805,7 +803,7 @@ static void totempg_mtu_changed(void *context, int net_mtu)
{
struct totemsrp_instance *instance = context;
- instance->totem_config->net_mtu = net_mtu - sizeof (struct mcast);
+ instance->totem_config->net_mtu = net_mtu - 2 * sizeof (struct mcast);
log_printf (instance->totemsrp_log_level_debug,
"Net MTU changed to %d, new value is %d",
@@ -1132,11 +1130,6 @@ static int srp_addr_equal (const struct srp_addr *a, const struct srp_addr *b)
return 0;
}
-static void srp_addr_copy (struct srp_addr *dest, const struct srp_addr *src)
-{
- dest->nodeid = src->nodeid;
-}
-
static void srp_addr_to_nodeid (
struct totemsrp_instance *instance,
unsigned int *nodeid_out,
@@ -1150,9 +1143,13 @@ static void srp_addr_to_nodeid (
}
}
-static void srp_addr_copy_endian_convert (struct srp_addr *out, const struct srp_addr *in)
+static struct srp_addr srp_addr_endian_convert (struct srp_addr in)
{
- out->nodeid = swab32 (in->nodeid);
+ struct srp_addr res;
+
+ res.nodeid = swab32 (in.nodeid);
+
+ return (res);
}
static void memb_consensus_reset (struct totemsrp_instance *instance)
@@ -1179,7 +1176,7 @@ static void memb_set_subtract (
}
}
if (found == 0) {
- srp_addr_copy (&out_list[*out_list_entries], &one_list[i]);
+ out_list[*out_list_entries] = one_list[i];
*out_list_entries = *out_list_entries + 1;
}
found = 0;
@@ -1202,7 +1199,7 @@ static void memb_consensus_set (
break; /* found entry */
}
}
- srp_addr_copy (&instance->consensus_list[i].addr, addr);
+ instance->consensus_list[i].addr = *addr;
instance->consensus_list[i].set = 1;
if (found == 0) {
instance->consensus_list_entries++;
@@ -1276,7 +1273,7 @@ static void memb_consensus_notset (
for (i = 0; i < instance->my_proc_list_entries; i++) {
if (memb_consensus_isset (instance, &instance->my_proc_list[i]) == 0) {
- srp_addr_copy (&no_consensus_list[*no_consensus_list_entries], &instance->my_proc_list[i]);
+ no_consensus_list[*no_consensus_list_entries] = instance->my_proc_list[i];
*no_consensus_list_entries = *no_consensus_list_entries + 1;
}
}
@@ -1358,7 +1355,7 @@ static void memb_set_merge (
}
}
if (found == 0) {
- srp_addr_copy (&fullset[*fullset_entries], &subset[i]);
+ fullset[*fullset_entries] = subset[i];
*fullset_entries = *fullset_entries + 1;
}
found = 0;
@@ -1392,7 +1389,7 @@ static void memb_set_and_with_ring_id (
}
}
if (found) {
- srp_addr_copy (&and[*and_entries], &set1[j]);
+ and[*and_entries] = set1[j];
*and_entries = *and_entries + 1;
}
found = 0;
@@ -1415,9 +1412,9 @@ static void memb_set_log(
for (i = 0; i < list_entries; i++) {
if (i == 0) {
- snprintf(int_buf, sizeof(int_buf), "%u", list[i].nodeid);
+ snprintf(int_buf, sizeof(int_buf), CS_PRI_NODE_ID, list[i].nodeid);
} else {
- snprintf(int_buf, sizeof(int_buf), ",%u", list[i].nodeid);
+ snprintf(int_buf, sizeof(int_buf), "," CS_PRI_NODE_ID, list[i].nodeid);
}
if (strlen(list_str) + strlen(int_buf) >= sizeof(list_str)) {
@@ -1471,7 +1468,7 @@ static void my_leave_memb_set(
instance->my_leave_memb_entries++;
} else {
log_printf (instance->totemsrp_log_level_warning,
- "Cannot set LEAVE nodeid=%d", nodeid);
+ "Cannot set LEAVE nodeid=" CS_PRI_NODE_ID, nodeid);
}
}
@@ -1871,8 +1868,8 @@ static void deliver_messages_from_recovery_to_regular (struct totemsrp_instance
}
log_printf (instance->totemsrp_log_level_debug,
- "comparing if ring id is for this processors old ring seqno %d",
- mcast->seq);
+ "comparing if ring id is for this processors old ring seqno " CS_PRI_RING_ID_SEQ,
+ (uint64_t)mcast->seq);
/*
* Only add this message to the regular sort
@@ -1892,7 +1889,7 @@ static void deliver_messages_from_recovery_to_regular (struct totemsrp_instance
}
} else {
log_printf (instance->totemsrp_log_level_debug,
- "-not adding msg with seq no %x", mcast->seq);
+ "-not adding msg with seq no " CS_PRI_RING_ID_SEQ, (uint64_t)mcast->seq);
}
}
}
@@ -2056,7 +2053,7 @@ static void memb_state_operational_enter (struct totemsrp_instance *instance)
int sptr = 0;
sptr += snprintf(joined_node_msg, sizeof(joined_node_msg)-sptr, " joined:");
for (i=0; i< joined_list_entries; i++) {
- sptr += snprintf(joined_node_msg+sptr, sizeof(joined_node_msg)-sptr, " %u", joined_list_totemip[i]);
+ sptr += snprintf(joined_node_msg+sptr, sizeof(joined_node_msg)-sptr, " " CS_PRI_NODE_ID, joined_list_totemip[i]);
}
}
else {
@@ -2068,14 +2065,14 @@ static void memb_state_operational_enter (struct totemsrp_instance *instance)
int sptr2 = 0;
sptr += snprintf(left_node_msg, sizeof(left_node_msg)-sptr, " left:");
for (i=0; i< instance->my_left_memb_entries; i++) {
- sptr += snprintf(left_node_msg+sptr, sizeof(left_node_msg)-sptr, " %u", left_list[i]);
+ sptr += snprintf(left_node_msg+sptr, sizeof(left_node_msg)-sptr, " " CS_PRI_NODE_ID, left_list[i]);
}
for (i=0; i< instance->my_left_memb_entries; i++) {
if (my_leave_memb_match(instance, left_list[i]) == 0) {
if (sptr2 == 0) {
sptr2 += snprintf(failed_node_msg, sizeof(failed_node_msg)-sptr2, " failed:");
}
- sptr2 += snprintf(failed_node_msg+sptr2, sizeof(left_node_msg)-sptr2, " %u", left_list[i]);
+ sptr2 += snprintf(failed_node_msg+sptr2, sizeof(left_node_msg)-sptr2, " " CS_PRI_NODE_ID, left_list[i]);
}
}
if (sptr2 == 0) {
@@ -2092,9 +2089,9 @@ static void memb_state_operational_enter (struct totemsrp_instance *instance)
log_printf (instance->totemsrp_log_level_debug,
"entering OPERATIONAL state.");
log_printf (instance->totemsrp_log_level_notice,
- "A new membership (%u:%lld) was formed. Members%s%s",
+ "A new membership (" CS_PRI_RING_ID ") was formed. Members%s%s",
instance->my_ring_id.rep,
- instance->my_ring_id.seq,
+ (uint64_t)instance->my_ring_id.seq,
joined_node_msg,
left_node_msg);
@@ -2313,15 +2310,14 @@ static void memb_state_recovery_enter (
for (i = 0; i < instance->my_trans_memb_entries; i++) {
log_printf (instance->totemsrp_log_level_debug,
- "TRANS [%d] member %u:", i, instance->my_trans_memb_list[i].nodeid);
+ "TRANS [%d] member " CS_PRI_NODE_ID ":", i, instance->my_trans_memb_list[i].nodeid);
}
for (i = 0; i < instance->my_new_memb_entries; i++) {
log_printf (instance->totemsrp_log_level_debug,
- "position [%d] member %u:", i, addr[i].nodeid);
+ "position [%d] member " CS_PRI_NODE_ID ":", i, addr[i].nodeid);
log_printf (instance->totemsrp_log_level_debug,
- "previous ring seq %llx rep %u",
- memb_list[i].ring_id.seq,
- memb_list[i].ring_id.rep);
+ "previous ringid (" CS_PRI_RING_ID ")",
+ memb_list[i].ring_id.rep, (uint64_t)memb_list[i].ring_id.seq);
log_printf (instance->totemsrp_log_level_debug,
"aru %x high delivered %x received flag %d",
@@ -2405,10 +2401,11 @@ static void memb_state_recovery_enter (
// TODO LEAK
message_item.mcast = totemsrp_buffer_alloc (instance);
assert (message_item.mcast);
+ memset(message_item.mcast, 0, sizeof (struct mcast));
message_item.mcast->header.magic = TOTEM_MH_MAGIC;
message_item.mcast->header.version = TOTEM_MH_VERSION;
message_item.mcast->header.type = MESSAGE_TYPE_MCAST;
- srp_addr_copy (&message_item.mcast->system_from, &instance->my_id);
+ message_item.mcast->system_from = instance->my_id;
message_item.mcast->header.encapsulated = MESSAGE_ENCAPSULATED;
message_item.mcast->header.nodeid = instance->my_id.nodeid;
@@ -2503,7 +2500,7 @@ int totemsrp_mcast (
assert (message_item.mcast->header.nodeid);
message_item.mcast->guarantee = guarantee;
- srp_addr_copy (&message_item.mcast->system_from, &instance->my_id);
+ message_item.mcast->system_from = instance->my_id;
addr = (char *)message_item.mcast;
addr_idx = sizeof (struct mcast);
@@ -3311,7 +3308,7 @@ static void memb_join_message_send (struct totemsrp_instance *instance)
memb_join->ring_seq = instance->my_ring_id.seq;
memb_join->proc_list_entries = instance->my_proc_list_entries;
memb_join->failed_list_entries = instance->my_failed_list_entries;
- srp_addr_copy (&memb_join->system_from, &instance->my_id);
+ memb_join->system_from = instance->my_id;
/*
* This mess adds the joined and failed processor lists into the join
@@ -3390,7 +3387,7 @@ static void memb_leave_message_send (struct totemsrp_instance *instance)
memb_join->ring_seq = instance->my_ring_id.seq;
memb_join->proc_list_entries = active_memb_entries;
memb_join->failed_list_entries = instance->my_failed_list_entries;
- srp_addr_copy (&memb_join->system_from, &instance->my_id);
+ memb_join->system_from = instance->my_id;
// TODO: CC Maybe use the actual join send routine.
/*
@@ -3435,7 +3432,7 @@ static void memb_merge_detect_transmit (struct totemsrp_instance *instance)
memb_merge_detect.header.type = MESSAGE_TYPE_MEMB_MERGE_DETECT;
memb_merge_detect.header.encapsulated = 0;
memb_merge_detect.header.nodeid = instance->my_id.nodeid;
- srp_addr_copy (&memb_merge_detect.system_from, &instance->my_id);
+ memb_merge_detect.system_from = instance->my_id;
memcpy (&memb_merge_detect.ring_id, &instance->my_ring_id,
sizeof (struct memb_ring_id));
assert (memb_merge_detect.header.nodeid);
@@ -4124,7 +4121,7 @@ static void messages_deliver_to_app (
unsigned int range = 0;
int endian_conversion_required;
unsigned int my_high_delivered_stored = 0;
-
+ struct srp_addr aligned_system_from;
range = end_point - instance->my_high_delivered;
@@ -4181,11 +4178,13 @@ static void messages_deliver_to_app (
memcpy (&mcast_header, mcast_in, sizeof (struct mcast));
}
+ aligned_system_from = mcast_header.system_from;
+
/*
* Skip messages not originated in instance->my_deliver_memb
*/
if (skip &&
- memb_set_subset (&mcast_header.system_from,
+ memb_set_subset (&aligned_system_from,
1,
instance->my_deliver_memb_list,
instance->my_deliver_memb_entries) == 0) {
@@ -4225,6 +4224,7 @@ static int message_handler_mcast (
struct sort_queue_item sort_queue_item;
struct sq *sort_queue;
struct mcast mcast_header;
+ struct srp_addr aligned_system_from;
if (check_mcast_sanity(instance, msg, msg_len, endian_conversion_needed) == -1) {
return (0);
@@ -4256,22 +4256,24 @@ static int message_handler_mcast (
if (memcmp (&instance->my_ring_id, &mcast_header.ring_id,
sizeof (struct memb_ring_id)) != 0) {
+ aligned_system_from = mcast_header.system_from;
+
switch (instance->memb_state) {
case MEMB_STATE_OPERATIONAL:
memb_set_merge (
- &mcast_header.system_from, 1,
+ &aligned_system_from, 1,
instance->my_proc_list, &instance->my_proc_list_entries);
memb_state_gather_enter (instance, TOTEMSRP_GSFROM_FOREIGN_MESSAGE_IN_OPERATIONAL_STATE);
break;
case MEMB_STATE_GATHER:
if (!memb_set_subset (
- &mcast_header.system_from,
+ &aligned_system_from,
1,
instance->my_proc_list,
instance->my_proc_list_entries)) {
- memb_set_merge (&mcast_header.system_from, 1,
+ memb_set_merge (&aligned_system_from, 1,
instance->my_proc_list, &instance->my_proc_list_entries);
memb_state_gather_enter (instance, TOTEMSRP_GSFROM_FOREIGN_MESSAGE_IN_GATHER_STATE);
return (0);
@@ -4292,9 +4294,9 @@ static int message_handler_mcast (
}
log_printf (instance->totemsrp_log_level_trace,
- "Received ringid(%u:%lld) seq %x",
+ "Received ringid (" CS_PRI_RING_ID ") seq %x",
mcast_header.ring_id.rep,
- mcast_header.ring_id.seq,
+ (uint64_t)mcast_header.ring_id.seq,
mcast_header.seq);
/*
@@ -4340,6 +4342,7 @@ static int message_handler_memb_merge_detect (
int endian_conversion_needed)
{
struct memb_merge_detect memb_merge_detect;
+ struct srp_addr aligned_system_from;
if (check_memb_merge_detect_sanity(instance, msg, msg_len, endian_conversion_needed) == -1) {
return (0);
@@ -4361,24 +4364,26 @@ static int message_handler_memb_merge_detect (
return (0);
}
+ aligned_system_from = memb_merge_detect.system_from;
+
/*
* Execute merge operation
*/
switch (instance->memb_state) {
case MEMB_STATE_OPERATIONAL:
- memb_set_merge (&memb_merge_detect.system_from, 1,
+ memb_set_merge (&aligned_system_from, 1,
instance->my_proc_list, &instance->my_proc_list_entries);
memb_state_gather_enter (instance, TOTEMSRP_GSFROM_MERGE_DURING_OPERATIONAL_STATE);
break;
case MEMB_STATE_GATHER:
if (!memb_set_subset (
- &memb_merge_detect.system_from,
+ &aligned_system_from,
1,
instance->my_proc_list,
instance->my_proc_list_entries)) {
- memb_set_merge (&memb_merge_detect.system_from, 1,
+ memb_set_merge (&aligned_system_from, 1,
instance->my_proc_list, &instance->my_proc_list_entries);
memb_state_gather_enter (instance, TOTEMSRP_GSFROM_MERGE_DURING_GATHER_STATE);
return (0);
@@ -4405,9 +4410,11 @@ static void memb_join_process (
int gather_entered = 0;
int fail_minus_memb_entries = 0;
struct srp_addr fail_minus_memb[PROCESSOR_COUNT_MAX];
+ struct srp_addr aligned_system_from;
proc_list = (struct srp_addr *)memb_join->end_of_memb_join;
failed_list = proc_list + memb_join->proc_list_entries;
+ aligned_system_from = memb_join->system_from;
log_printf(instance->totemsrp_log_level_trace, "memb_join_process");
memb_set_log(instance, instance->totemsrp_log_level_trace,
@@ -4423,20 +4430,20 @@ static void memb_join_process (
if (instance->flushing) {
if (memb_join->header.nodeid == LEAVE_DUMMY_NODEID) {
log_printf (instance->totemsrp_log_level_warning,
- "Discarding LEAVE message during flush, nodeid=%u",
+ "Discarding LEAVE message during flush, nodeid=" CS_PRI_NODE_ID,
memb_join->failed_list_entries > 0 ? failed_list[memb_join->failed_list_entries - 1 ].nodeid : LEAVE_DUMMY_NODEID);
if (memb_join->failed_list_entries > 0) {
my_leave_memb_set(instance, failed_list[memb_join->failed_list_entries - 1 ].nodeid);
}
} else {
log_printf (instance->totemsrp_log_level_warning,
- "Discarding JOIN message during flush, nodeid=%d", memb_join->header.nodeid);
+ "Discarding JOIN message during flush, nodeid=" CS_PRI_NODE_ID, memb_join->header.nodeid);
}
return;
} else {
if (memb_join->header.nodeid == LEAVE_DUMMY_NODEID) {
log_printf (instance->totemsrp_log_level_debug,
- "Received LEAVE message from %u", memb_join->failed_list_entries > 0 ? failed_list[memb_join->failed_list_entries - 1 ].nodeid : LEAVE_DUMMY_NODEID);
+ "Received LEAVE message from " CS_PRI_NODE_ID, memb_join->failed_list_entries > 0 ? failed_list[memb_join->failed_list_entries - 1 ].nodeid : LEAVE_DUMMY_NODEID);
if (memb_join->failed_list_entries > 0) {
my_leave_memb_set(instance, failed_list[memb_join->failed_list_entries - 1 ].nodeid);
}
@@ -4456,13 +4463,12 @@ static void memb_join_process (
instance->my_failed_list_entries)) {
if (memb_join->header.nodeid != LEAVE_DUMMY_NODEID) {
- memb_consensus_set (instance, &memb_join->system_from);
+ memb_consensus_set (instance, &aligned_system_from);
}
if (memb_consensus_agreed (instance) && instance->failed_to_recv == 1) {
instance->failed_to_recv = 0;
- srp_addr_copy (&instance->my_proc_list[0],
- &instance->my_id);
+ instance->my_proc_list[0] = instance->my_id;
instance->my_proc_list_entries = 1;
instance->my_failed_list_entries = 0;
@@ -4493,7 +4499,7 @@ static void memb_join_process (
goto out;
} else
- if (memb_set_subset (&memb_join->system_from, 1,
+ if (memb_set_subset (&aligned_system_from, 1,
instance->my_failed_list, instance->my_failed_list_entries)) {
goto out;
@@ -4507,16 +4513,16 @@ static void memb_join_process (
failed_list, memb_join->failed_list_entries)) {
memb_set_merge (
- &memb_join->system_from, 1,
+ &aligned_system_from, 1,
instance->my_failed_list, &instance->my_failed_list_entries);
} else {
if (memb_set_subset (
- &memb_join->system_from, 1,
+ &aligned_system_from, 1,
instance->my_memb_list,
instance->my_memb_entries)) {
if (memb_set_subset (
- &memb_join->system_from, 1,
+ &aligned_system_from, 1,
instance->my_failed_list,
instance->my_failed_list_entries) == 0) {
@@ -4562,7 +4568,7 @@ static void memb_join_endian_convert (const struct memb_join *in, struct memb_jo
out->header.version = TOTEM_MH_VERSION;
out->header.type = in->header.type;
out->header.nodeid = swab32 (in->header.nodeid);
- srp_addr_copy_endian_convert (&out->system_from, &in->system_from);
+ out->system_from = srp_addr_endian_convert(in->system_from);
out->proc_list_entries = swab32 (in->proc_list_entries);
out->failed_list_entries = swab32 (in->failed_list_entries);
out->ring_seq = swab64 (in->ring_seq);
@@ -4573,10 +4579,10 @@ static void memb_join_endian_convert (const struct memb_join *in, struct memb_jo
out_failed_list = out_proc_list + out->proc_list_entries;
for (i = 0; i < out->proc_list_entries; i++) {
- srp_addr_copy_endian_convert (&out_proc_list[i], &in_proc_list[i]);
+ out_proc_list[i] = srp_addr_endian_convert (in_proc_list[i]);
}
for (i = 0; i < out->failed_list_entries; i++) {
- srp_addr_copy_endian_convert (&out_failed_list[i], &in_failed_list[i]);
+ out_failed_list[i] = srp_addr_endian_convert (in_failed_list[i]);
}
}
@@ -4602,7 +4608,7 @@ static void memb_commit_token_endian_convert (const struct memb_commit_token *in
in_memb_list = (struct memb_commit_token_memb_entry *)(in_addr + out->addr_entries);
out_memb_list = (struct memb_commit_token_memb_entry *)(out_addr + out->addr_entries);
for (i = 0; i < out->addr_entries; i++) {
- srp_addr_copy_endian_convert (&out_addr[i], &in_addr[i]);
+ out_addr[i] = srp_addr_endian_convert (in_addr[i]);
/*
* Only convert the memb entry if it has been set
@@ -4658,7 +4664,7 @@ static void mcast_endian_convert (const struct mcast *in, struct mcast *out)
out->ring_id.seq = swab64 (in->ring_id.seq);
out->node_id = swab32 (in->node_id);
out->guarantee = swab32 (in->guarantee);
- srp_addr_copy_endian_convert (&out->system_from, &in->system_from);
+ out->system_from = srp_addr_endian_convert(in->system_from);
}
static void memb_merge_detect_endian_convert (
@@ -4671,7 +4677,7 @@ static void memb_merge_detect_endian_convert (
out->header.nodeid = swab32 (in->header.nodeid);
out->ring_id.rep = swab32(in->ring_id.rep);
out->ring_id.seq = swab64 (in->ring_id.seq);
- srp_addr_copy_endian_convert (&out->system_from, &in->system_from);
+ out->system_from = srp_addr_endian_convert (in->system_from);
}
static int ignore_join_under_operational (
@@ -4681,10 +4687,12 @@ static int ignore_join_under_operational (
struct srp_addr *proc_list;
struct srp_addr *failed_list;
unsigned long long ring_seq;
+ struct srp_addr aligned_system_from;
proc_list = (struct srp_addr *)memb_join->end_of_memb_join;
failed_list = proc_list + memb_join->proc_list_entries;
ring_seq = memb_join->ring_seq;
+ aligned_system_from = memb_join->system_from;
if (memb_set_subset (&instance->my_id, 1,
failed_list, memb_join->failed_list_entries)) {
@@ -4695,7 +4703,7 @@ static int ignore_join_under_operational (
* In operational state, my_proc_list is exactly the same as
* my_memb_list.
*/
- if ((memb_set_subset (&memb_join->system_from, 1,
+ if ((memb_set_subset (&aligned_system_from, 1,
instance->my_memb_list, instance->my_memb_entries)) &&
(ring_seq < instance->my_ring_id.seq)) {
return (1);
@@ -4712,6 +4720,7 @@ static int message_handler_memb_join (
{
const struct memb_join *memb_join;
struct memb_join *memb_join_convert = alloca (msg_len);
+ struct srp_addr aligned_system_from;
if (check_memb_join_sanity(instance, msg, msg_len, endian_conversion_needed) == -1) {
return (0);
@@ -4724,6 +4733,9 @@ static int message_handler_memb_join (
} else {
memb_join = msg;
}
+
+ aligned_system_from = memb_join->system_from;
+
/*
* If the process paused because it wasn't scheduled in a timely
* fashion, flush the join messages because they may be queued
@@ -4748,7 +4760,7 @@ static int message_handler_memb_join (
break;
case MEMB_STATE_COMMIT:
- if (memb_set_subset (&memb_join->system_from,
+ if (memb_set_subset (&aligned_system_from,
1,
instance->my_new_memb_list,
instance->my_new_memb_entries) &&
@@ -4761,7 +4773,7 @@ static int message_handler_memb_join (
break;
case MEMB_STATE_RECOVERY:
- if (memb_set_subset (&memb_join->system_from,
+ if (memb_set_subset (&aligned_system_from,
1,
instance->my_new_memb_list,
instance->my_new_memb_entries) &&
@@ -5061,12 +5073,20 @@ void main_iface_change_fn (
if (instance->iface_changes++ == 0) {
instance->memb_ring_id_create_or_load (&instance->my_ring_id, instance->my_id.nodeid);
+ /*
+ * Increase the ring_id sequence number. This doesn't follow specification.
+ * Solves problem with restarted leader node (node with lowest nodeid) before
+ * rest of the cluster forms new membership and guarantees unique ring_id for
+ * new singleton configuration.
+ */
+ instance->my_ring_id.seq++;
+
instance->token_ring_id_seq = instance->my_ring_id.seq;
log_printf (
instance->totemsrp_log_level_debug,
- "Created or loaded sequence id %llx.%u for this ring.",
- instance->my_ring_id.seq,
- instance->my_ring_id.rep);
+ "Created or loaded sequence id " CS_PRI_RING_ID " for this ring.",
+ instance->my_ring_id.rep,
+ (uint64_t)instance->my_ring_id.seq);
if (instance->totemsrp_service_ready_fn) {
instance->totemsrp_service_ready_fn ();
@@ -5093,7 +5113,7 @@ void main_iface_change_fn (
}
void totemsrp_net_mtu_adjust (struct totem_config *totem_config) {
- totem_config->net_mtu -= sizeof (struct mcast);
+ totem_config->net_mtu -= 2 * sizeof (struct mcast);
}
void totemsrp_service_ready_register (
diff --git a/exec/votequorum.c b/exec/votequorum.c
index 6c6e3b1..f78b3f9 100644
--- a/exec/votequorum.c
+++ b/exec/votequorum.c
@@ -475,7 +475,7 @@ static struct cluster_node *allocate_node(unsigned int nodeid)
* this should never happen
*/
if (!cl) {
- log_printf(LOGSYS_LEVEL_CRIT, "Unable to find memory for node %u data!!", nodeid);
+ log_printf(LOGSYS_LEVEL_CRIT, "Unable to find memory for node " CS_PRI_NODE_ID " data!!", nodeid);
goto out;
}
qb_list_del(tmp);
@@ -538,7 +538,7 @@ static void get_lowest_node_id(void)
lowest_node_id = node->node_id;
}
}
- log_printf(LOGSYS_LEVEL_DEBUG, "lowest node id: %d us: %d", lowest_node_id, us->node_id);
+ log_printf(LOGSYS_LEVEL_DEBUG, "lowest node id: " CS_PRI_NODE_ID " us: " CS_PRI_NODE_ID, lowest_node_id, us->node_id);
icmap_set_uint32("runtime.votequorum.lowest_node_id", lowest_node_id);
LEAVE();
@@ -560,7 +560,7 @@ static void get_highest_node_id(void)
highest_node_id = node->node_id;
}
}
- log_printf(LOGSYS_LEVEL_DEBUG, "highest node id: %d us: %d", highest_node_id, us->node_id);
+ log_printf(LOGSYS_LEVEL_DEBUG, "highest node id: " CS_PRI_NODE_ID " us: " CS_PRI_NODE_ID, highest_node_id, us->node_id);
icmap_set_uint32("runtime.votequorum.highest_node_id", highest_node_id);
LEAVE();
@@ -664,7 +664,7 @@ static int check_auto_tie_breaker(void)
*/
for (j=0; j<i; j++) {
if (is_in_nodelist(atb_nodelist[j], previous_quorum_members, previous_quorum_members_entries)) {
- log_printf(LOGSYS_LEVEL_DEBUG, "ATB_LIST found node %d in previous partition but not here, quorum denied", atb_nodelist[j]);
+ log_printf(LOGSYS_LEVEL_DEBUG, "ATB_LIST found node " CS_PRI_NODE_ID " in previous partition but not here, quorum denied", atb_nodelist[j]);
LEAVE();
return 0;
}
@@ -674,7 +674,7 @@ static int check_auto_tie_breaker(void)
* None of the other list nodes were in the previous partition, if there
* are enough votes, we can be quorate
*/
- log_printf(LOGSYS_LEVEL_DEBUG, "ATB_LIST found node %d in current partition, we can be quorate", atb_nodelist[i]);
+ log_printf(LOGSYS_LEVEL_DEBUG, "ATB_LIST found node " CS_PRI_NODE_ID " in current partition, we can be quorate", atb_nodelist[i]);
LEAVE();
return 1;
}
@@ -920,7 +920,7 @@ static int calculate_quorum(int allow_decrease, unsigned int max_expected, unsig
qb_list_for_each(nodelist, &cluster_members_list) {
node = qb_list_entry(nodelist, struct cluster_node, list);
- log_printf(LOGSYS_LEVEL_DEBUG, "node %u state=%d, votes=%u, expected=%u",
+ log_printf(LOGSYS_LEVEL_DEBUG, "node " CS_PRI_NODE_ID " state=%d, votes=%u, expected=%u",
node->node_id, node->state, node->votes, node->expected_votes);
if (node->state == NODESTATE_MEMBER) {
@@ -1682,6 +1682,7 @@ static int votequorum_exec_send_nodeinfo(uint32_t nodeid)
return -1;
}
+ memset(&req_exec_quorum_nodeinfo, 0, sizeof(req_exec_quorum_nodeinfo));
req_exec_quorum_nodeinfo.nodeid = nodeid;
req_exec_quorum_nodeinfo.votes = node->votes;
req_exec_quorum_nodeinfo.expected_votes = node->expected_votes;
@@ -1819,7 +1820,7 @@ static int votequorum_exec_send_nodelist_notification(void *conn, uint64_t conte
ENTER();
- log_printf(LOGSYS_LEVEL_DEBUG, "Sending nodelist callback. ring_id = %d/%lld", quorum_ringid.nodeid, quorum_ringid.seq);
+ log_printf(LOGSYS_LEVEL_DEBUG, "Sending nodelist callback. ring_id = " CS_PRI_RING_ID, quorum_ringid.nodeid, quorum_ringid.seq);
size = sizeof(struct res_lib_votequorum_nodelist_notification) + sizeof(uint32_t) * quorum_members_entries;
@@ -1897,7 +1898,7 @@ static void message_handler_req_exec_votequorum_qdevice_reconfigure (
ENTER();
- log_printf(LOGSYS_LEVEL_DEBUG, "Received qdevice name change req from node %u [from: %s to: %s]",
+ log_printf(LOGSYS_LEVEL_DEBUG, "Received qdevice name change req from node " CS_PRI_NODE_ID " [from: %s to: %s]",
nodeid,
req_exec_quorum_qdevice_reconfigure->oldname,
req_exec_quorum_qdevice_reconfigure->newname);
@@ -1940,7 +1941,7 @@ static void message_handler_req_exec_votequorum_qdevice_reg (
ENTER();
- log_printf(LOGSYS_LEVEL_DEBUG, "Received qdevice op %u req from node %u [%s]",
+ log_printf(LOGSYS_LEVEL_DEBUG, "Received qdevice op %u req from node " CS_PRI_NODE_ID " [%s]",
req_exec_quorum_qdevice_reg->operation,
nodeid, req_exec_quorum_qdevice_reg->qdevice_name);
@@ -2052,8 +2053,8 @@ static void message_handler_req_exec_votequorum_nodeinfo (
ENTER();
- log_printf(LOGSYS_LEVEL_DEBUG, "got nodeinfo message from cluster node %u", sender_nodeid);
- log_printf(LOGSYS_LEVEL_DEBUG, "nodeinfo message[%u]: votes: %d, expected: %d flags: %d",
+ log_printf(LOGSYS_LEVEL_DEBUG, "got nodeinfo message from cluster node " CS_PRI_NODE_ID, sender_nodeid);
+ log_printf(LOGSYS_LEVEL_DEBUG, "nodeinfo message[" CS_PRI_NODE_ID "]: votes: %d, expected: %d flags: %d",
nodeid,
req_exec_quorum_nodeinfo->votes,
req_exec_quorum_nodeinfo->expected_votes,
@@ -2174,7 +2175,7 @@ static void message_handler_req_exec_votequorum_reconfigure (
ENTER();
- log_printf(LOGSYS_LEVEL_DEBUG, "got reconfigure message from cluster node %u for %u",
+ log_printf(LOGSYS_LEVEL_DEBUG, "got reconfigure message from cluster node " CS_PRI_NODE_ID " for " CS_PRI_NODE_ID,
nodeid, req_exec_quorum_reconfigure->nodeid);
switch(req_exec_quorum_reconfigure->param)
@@ -2201,7 +2202,7 @@ static void message_handler_req_exec_votequorum_reconfigure (
case VOTEQUORUM_RECONFIG_PARAM_CANCEL_WFA:
update_wait_for_all_status(0);
- log_printf(LOGSYS_LEVEL_INFO, "wait_for_all_status reset by user on node %d.",
+ log_printf(LOGSYS_LEVEL_INFO, "wait_for_all_status reset by user on node " CS_PRI_NODE_ID ".",
req_exec_quorum_reconfigure->nodeid);
recalculate_quorum(0, 0);
@@ -2551,7 +2552,7 @@ static void message_handler_req_lib_votequorum_getinfo (void *conn, const void *
ENTER();
- log_printf(LOGSYS_LEVEL_DEBUG, "got getinfo request on %p for node %u", conn, req_lib_votequorum_getinfo->nodeid);
+ log_printf(LOGSYS_LEVEL_DEBUG, "got getinfo request on %p for node " CS_PRI_NODE_ID, conn, req_lib_votequorum_getinfo->nodeid);
if (nodeid == VOTEQUORUM_QDEVICE_NODEID) {
nodeid = us->node_id;
@@ -2953,8 +2954,8 @@ static void message_handler_req_lib_votequorum_qdevice_poll (void *conn,
if (us->flags & NODE_FLAGS_QDEVICE_REGISTERED) {
if (!(req_lib_votequorum_qdevice_poll->ring_id.nodeid == quorum_ringid.nodeid &&
req_lib_votequorum_qdevice_poll->ring_id.seq == quorum_ringid.seq)) {
- log_printf(LOGSYS_LEVEL_DEBUG, "Received poll ring id (%u.%"PRIu64") != last sync "
- "ring id (%u.%"PRIu64"). Ignoring poll call.",
+ log_printf(LOGSYS_LEVEL_DEBUG, "Received poll ring id (" CS_PRI_RING_ID ") != last sync "
+ "ring id (" CS_PRI_RING_ID "). Ignoring poll call.",
req_lib_votequorum_qdevice_poll->ring_id.nodeid, req_lib_votequorum_qdevice_poll->ring_id.seq,
quorum_ringid.nodeid, quorum_ringid.seq);
error = CS_ERR_MESSAGE_ERROR;
diff --git a/exec/vsf_quorum.c b/exec/vsf_quorum.c
index f93eaf5..f62ffa8 100644
--- a/exec/vsf_quorum.c
+++ b/exec/vsf_quorum.c
@@ -122,7 +122,7 @@ static void log_view_list(const unsigned int *view_list, size_t view_list_entrie
memset(view_buf, 0, len);
for (; i < total; i++) {
- ret = snprintf(view_buf + pos, len - pos, " %u", view_list[i]);
+ ret = snprintf(view_buf + pos, len - pos, " " CS_PRI_NODE_ID, view_list[i]);
if (ret >= len - pos)
break;
pos += ret;
diff --git a/include/corosync/config.h.in b/include/corosync/config.h.in
index af5409e..c7855c1 100644
--- a/include/corosync/config.h.in
+++ b/include/corosync/config.h.in
@@ -121,6 +121,9 @@
/* have knet access list */
#undef HAVE_KNET_ACCESS_LIST
+/* Define to 1 if you have the `asan' library (-lasan). */
+#undef HAVE_LIBASAN
+
/* have nozzle */
#undef HAVE_LIBNOZZLE
@@ -142,6 +145,12 @@
/* have systemd interface library */
#undef HAVE_LIBSYSTEMD
+/* Define to 1 if you have the `tsan' library (-ltsan). */
+#undef HAVE_LIBTSAN
+
+/* Define to 1 if you have the `ubsan' library (-lubsan). */
+#undef HAVE_LIBUBSAN
+
/* Define to 1 if you have the <limits.h> header file. */
#undef HAVE_LIMITS_H
diff --git a/include/corosync/corotypes.h b/include/corosync/corotypes.h
index c8ef1d4..12b61eb 100644
--- a/include/corosync/corotypes.h
+++ b/include/corosync/corotypes.h
@@ -56,6 +56,9 @@ typedef int64_t cs_time_t;
#define CS_TIME_END ((cs_time_t)0x7FFFFFFFFFFFFFFFULL)
#define CS_MAX(x, y) (((x) > (y)) ? (x) : (y))
+#define CS_PRI_NODE_ID "%" PRIu32
+#define CS_PRI_RING_ID_SEQ "%" PRIx64
+#define CS_PRI_RING_ID "%" PRIx32 ".%" PRIx64
/**
* @brief The cs_name_t struct
*/
diff --git a/include/corosync/icmap.h b/include/corosync/icmap.h
index 37bac1a..b168376 100644
--- a/include/corosync/icmap.h
+++ b/include/corosync/icmap.h
@@ -315,6 +315,7 @@ extern cs_error_t icmap_get_int64_r(const icmap_map_t map, const char *key_name,
extern cs_error_t icmap_get_uint64_r(const icmap_map_t map, const char *key_name, uint64_t *u64);
extern cs_error_t icmap_get_float_r(const icmap_map_t map, const char *key_name, float *flt);
extern cs_error_t icmap_get_double_r(const icmap_map_t map, const char *key_name, double *dbl);
+extern cs_error_t icmap_get_string_r(const icmap_map_t map, const char *key_name, char **str);
/**
* @brief Shortcut for icmap_get for string type.
diff --git a/init/corosync.in b/init/corosync.in
index dec7452..1debe55 100755
--- a/init/corosync.in
+++ b/init/corosync.in
@@ -37,6 +37,11 @@ failure()
echo -ne "[FAILED]\r"
}
+warning()
+{
+ echo -ne "[WARNING]\r"
+}
+
# pid_var_run pid_file
# Echo pid from given pid_file.
# Returns LSB exit code for the 'status' action.
@@ -124,7 +129,7 @@ wait_for_ipc()
[ "$max_try" -le "0" ] && max_try=120
while [ "$try" -le "$max_try" ]; do
- if corosync-cfgtool -s > /dev/null 2>&1; then
+ if corosync-cpgtool > /dev/null 2>&1; then
return 0
fi
sleep 0.5
@@ -156,7 +161,11 @@ start()
rtrn=1
else
touch $LOCK_FILE
- success
+ if corosync-cfgtool -s > /dev/null 2>&1; then
+ success
+ else
+ warning
+ fi
fi
fi
echo
diff --git a/man/corosync-cfgtool.8 b/man/corosync-cfgtool.8
index 07e63b4..5c53791 100644
--- a/man/corosync-cfgtool.8
+++ b/man/corosync-cfgtool.8
@@ -31,7 +31,7 @@
.\" * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
.\" * THE POSSIBILITY OF SUCH DAMAGE.
.\" */
-.TH "COROSYNC-CFGTOOL" "8" "2019-02-13" "" ""
+.TH "COROSYNC-CFGTOOL" "8" "2019-07-04" "" ""
.SH "NAME"
corosync-cfgtool \- An administrative tool for corosync.
.SH "SYNOPSIS"
@@ -46,8 +46,7 @@ Finds only information about the specified interface IP address or link id with
.TP
.B -s
Displays the status of the current links on this node for UDP/UDPU, with extended status
-for KNET. If any interfaces are faulty, 1 is returned by the binary. If all interfaces are
-active 0 is returned to the shell.
+for KNET.
After each link, the nodes on that link are displayed in order with their status,
for example there are 3 nodes with KNET transportation:
LINK ID 0:
diff --git a/man/corosync-notifyd.8 b/man/corosync-notifyd.8
index 40d8d79..05a91a2 100644
--- a/man/corosync-notifyd.8
+++ b/man/corosync-notifyd.8
@@ -57,6 +57,9 @@ Send SNMP traps on all events.
.B -m
Set the SNMP Manager IP address (defaults to localhost).
.TP
+.B -n
+No reverse DNS lookup on cmap member change events.
+.TP
.B -d
Send DBUS signals on all events.
.TP
diff --git a/man/corosync.conf.5 b/man/corosync.conf.5
index 3b77733..3e6f629 100644
--- a/man/corosync.conf.5
+++ b/man/corosync.conf.5
@@ -112,7 +112,7 @@ the average link latency. (default 2048 samples)
.TP
knet_pong_count
-How many valid ping/pongs before a link is marked UP. (default 5)
+How many valid ping/pongs before a link is marked UP. (default 2)
.TP
knet_transport
@@ -254,7 +254,7 @@ link_mode
This specifies the Kronosnet mode, which may be passive, active, or
rr (round-robin).
.B passive:
-the active link with the lowest priority will be used. If one or more
+the active link with the highest priority will be used. If one or more
links share the same priority the one with the lowest link ID will
be used.
.B active:
diff --git a/pkgconfig/libtemplate.pc.in b/pkgconfig/libtemplate.pc.in
index 4a8a7e0..49d08fd 100644
--- a/pkgconfig/libtemplate.pc.in
+++ b/pkgconfig/libtemplate.pc.in
@@ -6,6 +6,6 @@ includedir=${prefix}/include
Name: @LIB@
Version: @LIBVERSION@
Description: @LIB@
-Requires:
+Requires: libqb
Libs: -L${libdir} -l@LIB@
Cflags: -I${includedir}
diff --git a/test/cpghum.c b/test/cpghum.c
index 3cc2119..7c007d0 100644
--- a/test/cpghum.c
+++ b/test/cpghum.c
@@ -44,6 +44,7 @@
#include <ctype.h>
#include <syslog.h>
#include <stdarg.h>
+#include <inttypes.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
@@ -249,7 +250,7 @@ static void cpg_bm_deliver_fn (
unsigned int datalen;
if (nodeid > MAX_NODEID) {
- cpgh_log_printf(CPGH_LOG_ERR, "Got message from invalid nodeid %d (too high for us). Quitting\n", nodeid);
+ cpgh_log_printf(CPGH_LOG_ERR, "Got message from invalid nodeid " CS_PRI_NODE_ID " (too high for us). Quitting\n", nodeid);
exit(1);
}
@@ -280,7 +281,7 @@ static void cpg_bm_deliver_fn (
// Basic check, packets should all be the right size
if (msg_len != header->size) {
length_errors++;
- cpgh_log_printf(CPGH_LOG_ERR, "%s: message sizes don't match. got %zu, expected %u from node %d\n", group_name->value, msg_len, header->size, nodeid);
+ cpgh_log_printf(CPGH_LOG_ERR, "%s: message sizes don't match. got %zu, expected %u from node " CS_PRI_NODE_ID "\n", group_name->value, msg_len, header->size, nodeid);
if (abort_on_error) {
exit(2);
@@ -294,7 +295,7 @@ static void cpg_bm_deliver_fn (
/* Don't report the first mismatch or a newly restarted sender, we're just catching up */
if (g_recv_counter[nodeid] && header->counter) {
sequence_errors++;
- cpgh_log_printf(CPGH_LOG_ERR, "%s: counters don't match. got %d, expected %d from node %d\n", group_name->value, header->counter, g_recv_counter[nodeid], nodeid);
+ cpgh_log_printf(CPGH_LOG_ERR, "%s: counters don't match. got %d, expected %d from node " CS_PRI_NODE_ID "\n", group_name->value, header->counter, g_recv_counter[nodeid], nodeid);
if (abort_on_error) {
exit(2);
@@ -316,7 +317,7 @@ static void cpg_bm_deliver_fn (
crc = crc32(crc, (Bytef *)dataint, datalen) & 0xFFFFFFFF;
if (crc != recv_crc) {
crc_errors++;
- cpgh_log_printf(CPGH_LOG_ERR, "%s: CRCs don't match. got %lx, expected %lx from nodeid %d\n", group_name->value, recv_crc, crc, nodeid);
+ cpgh_log_printf(CPGH_LOG_ERR, "%s: CRCs don't match. got %lx, expected %lx from nodeid " CS_PRI_NODE_ID "\n", group_name->value, recv_crc, crc, nodeid);
if (abort_on_error) {
exit(2);
@@ -750,7 +751,7 @@ int main (int argc, char *argv[]) {
if (!machine_readable) {
for (i=1; i<MAX_NODEID; i++) {
if (g_recv_counter[i]) {
- cpgh_log_printf(CPGH_LOG_INFO, "%s: %5d message%s of %d bytes received from node %d\n",
+ cpgh_log_printf(CPGH_LOG_INFO, "%s: %5d message%s of %d bytes received from node " CS_PRI_NODE_ID "\n",
group_name.value, g_recv_counter[i] - g_recv_start[i],
g_recv_counter[i]==1?"":"s",
g_recv_size[i], i);
diff --git a/test/testcpg.c b/test/testcpg.c
index 3316f7b..e48f3cc 100644
--- a/test/testcpg.c
+++ b/test/testcpg.c
@@ -92,7 +92,7 @@ static char * node_pid_format(unsigned int nodeid, unsigned int pid) {
sprintf(buffer, "node/pid %s/%d", inet_ntoa(saddr),pid);
}
else {
- sprintf(buffer, "node/pid %d/%d", nodeid, pid);
+ sprintf(buffer, "node/pid " CS_PRI_NODE_ID "/%d", nodeid, pid);
}
return buffer;
}
@@ -193,17 +193,17 @@ static void ConfchgCallback (
/* report dynamic nature of nodeid returned from local_get */
/* local get of nodeid might change identity from original! */
if(htonl((uint32_t)nodeid) == INADDR_LOOPBACK) {
- printf("We probably left the building switched identity? start nodeid %d nodeid %d current nodeid %d pid %d\n", nodeidStart, left_list[0].nodeid, nodeid, left_list[0].pid);
+ printf("We probably left the building switched identity? start nodeid " CS_PRI_NODE_ID " nodeid " CS_PRI_NODE_ID " current nodeid " CS_PRI_NODE_ID " pid %d\n", nodeidStart, left_list[0].nodeid, nodeid, left_list[0].pid);
} else if(htonl((uint32_t)left_list[0].nodeid) == INADDR_LOOPBACK) {
- printf("We probably left the building started alone? start nodeid %d nodeid %d current nodeid %d pid %d\n", nodeidStart, left_list[0].nodeid, nodeid, left_list[0].pid);
+ printf("We probably left the building started alone? start nodeid " CS_PRI_NODE_ID " nodeid " CS_PRI_NODE_ID " current nodeid " CS_PRI_NODE_ID " pid %d\n", nodeidStart, left_list[0].nodeid, nodeid, left_list[0].pid);
}
/* a possibly reliable way to check is based on original address */
if(left_list[0].nodeid == nodeidStart) {
- printf("We have left the building direct match start nodeid %d nodeid %d local get current nodeid %d pid %d\n", nodeidStart, left_list[0].nodeid, nodeid, left_list[0].pid);
+ printf("We have left the building direct match start nodeid " CS_PRI_NODE_ID " nodeid " CS_PRI_NODE_ID " local get current nodeid " CS_PRI_NODE_ID " pid %d\n", nodeidStart, left_list[0].nodeid, nodeid, left_list[0].pid);
// quit = 1;
restart = 1;
} else {
- printf("Probably another node with matching pid start nodeid %d nodeid %d current nodeid %d pid %d\n", nodeidStart, left_list[0].nodeid, nodeid, left_list[0].pid);
+ printf("Probably another node with matching pid start nodeid " CS_PRI_NODE_ID " nodeid " CS_PRI_NODE_ID " current nodeid " CS_PRI_NODE_ID " pid %d\n", nodeidStart, left_list[0].nodeid, nodeid, left_list[0].pid);
}
}
}
@@ -219,13 +219,13 @@ static void TotemConfchgCallback (
printf("\n");
print_time();
- printf ("TotemConfchgCallback: ringid (%u.%"PRIu64")\n",
+ printf ("TotemConfchgCallback: ringid (" CS_PRI_RING_ID ")\n",
ring_id.nodeid, ring_id.seq);
printf("active processors %lu: ",
(unsigned long int) member_list_entries);
for (i=0; i<member_list_entries; i++) {
- printf("%d ", member_list[i]);
+ printf(CS_PRI_NODE_ID " ", member_list[i]);
}
printf ("\n");
}
@@ -289,7 +289,7 @@ static void print_localnodeid(cpg_handle_t handle)
addrStr, (socklen_t)sizeof(addrStr)) == NULL) {
addrStr[0] = 0;
}
- printf ("Local node id is %s/%x result %d\n", addrStr, nodeid, result);
+ printf ("Local node id is %s/" CS_PRI_NODE_ID " result %d\n", addrStr, nodeid, result);
}
}
@@ -362,7 +362,7 @@ int main (int argc, char *argv[]) {
printf ("Could not get local node id\n");
retrybackoff(recnt);
}
- printf ("Local node id is %x\n", nodeid);
+ printf ("Local node id is " CS_PRI_NODE_ID "\n", nodeid);
nodeidStart = nodeid;
retries = 0;
@@ -383,7 +383,7 @@ int main (int argc, char *argv[]) {
printf ("membership list\n");
for (i = 0; i < member_list_entries; i++) {
- printf ("node id %d pid %d\n", member_list[i].nodeid,
+ printf ("node id " CS_PRI_NODE_ID " pid %d\n", member_list[i].nodeid,
member_list[i].pid);
}
diff --git a/test/testcpg2.c b/test/testcpg2.c
index 3d7763a..d779cf3 100644
--- a/test/testcpg2.c
+++ b/test/testcpg2.c
@@ -37,6 +37,7 @@
#include <assert.h>
#include <stdio.h>
#include <poll.h>
+#include <inttypes.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/uio.h>
@@ -52,7 +53,7 @@ static void deliver(
void *msg,
size_t msg_len)
{
- printf("self delivered nodeid: %x\n", nodeid);
+ printf("self delivered nodeid: " CS_PRI_NODE_ID "\n", nodeid);
}
static void confch(
@@ -62,7 +63,7 @@ static void confch(
const struct cpg_address *left_list, size_t left_list_entries,
const struct cpg_address *joined_list, size_t joined_list_entries)
{
- printf("confchg nodeid %x\n", member_list[0].nodeid);
+ printf("confchg nodeid " CS_PRI_NODE_ID "\n", member_list[0].nodeid);
}
int main(int argc, char** argv) {
@@ -78,7 +79,7 @@ int main(int argc, char** argv) {
printf ("All of the nodeids should match on a single node configuration\n for the test to pass.");
assert(CS_OK==cpg_initialize(&handle, &cb));
assert(CS_OK==cpg_local_get(handle,&nodeid));
- printf("local_get: %x\n", nodeid);
+ printf("local_get: " CS_PRI_NODE_ID "\n", nodeid);
assert(CS_OK==cpg_join(handle, &group));
assert(CS_OK==cpg_mcast_joined(handle,CPG_TYPE_AGREED,&msg,1));
cpg_fd_get (handle, &fd);
diff --git a/test/testcpgzc.c b/test/testcpgzc.c
index 2a6a9a8..6da36a1 100644
--- a/test/testcpgzc.c
+++ b/test/testcpgzc.c
@@ -39,6 +39,7 @@
#include <errno.h>
#include <unistd.h>
#include <string.h>
+#include <inttypes.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/select.h>
@@ -80,7 +81,7 @@ static void DeliverCallback (
inet_ntoa(saddr), pid, (const char *)msg);
}
else {
- printf("DeliverCallback: message (len=%lu)from node/pid %d/%d: '%s'\n",
+ printf("DeliverCallback: message (len=%lu)from node/pid " CS_PRI_NODE_ID "/%d: '%s'\n",
(unsigned long int) msg_len, nodeid, pid,
(const char *)msg);
}
@@ -107,7 +108,7 @@ static void ConfchgCallback (
joined_list[i].reason);
}
else {
- printf("joined node/pid: %d/%d reason: %d\n",
+ printf("joined node/pid: " CS_PRI_NODE_ID "/%d reason: %d\n",
joined_list[i].nodeid, joined_list[i].pid,
joined_list[i].reason);
}
@@ -121,7 +122,7 @@ static void ConfchgCallback (
left_list[i].reason);
}
else {
- printf("left node/pid: %d/%d reason: %d\n",
+ printf("left node/pid: " CS_PRI_NODE_ID "/%d reason: %d\n",
left_list[i].nodeid, left_list[i].pid,
left_list[i].reason);
}
@@ -136,7 +137,7 @@ static void ConfchgCallback (
inet_ntoa (saddr), member_list[i].pid);
}
else {
- printf("node/pid: %d/%d\n",
+ printf("node/pid: " CS_PRI_NODE_ID "/%d\n",
member_list[i].nodeid, member_list[i].pid);
}
}
@@ -204,7 +205,7 @@ int main (int argc, char *argv[]) {
exit (1);
}
- printf ("Local node id is %x\n", nodeid);
+ printf ("Local node id is " CS_PRI_NODE_ID "\n", nodeid);
result = cpg_join(handle, &group_name);
if (result != CS_OK) {
printf ("Could not join process group, error %d\n", result);
diff --git a/test/testquorum.c b/test/testquorum.c
index 52ae562..ebcbf07 100644
--- a/test/testquorum.c
+++ b/test/testquorum.c
@@ -2,6 +2,7 @@
#include <sys/types.h>
#include <stdio.h>
+#include <inttypes.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
@@ -21,11 +22,11 @@ static void quorum_notification_fn(
printf("quorum notification called \n");
printf(" quorate = %lu\n", (long unsigned int) quorate);
- printf(" ring id = %llu\n", (long long unsigned int) ring_id);
+ printf(" ring id = " CS_PRI_RING_ID_SEQ "\n", ring_id);
printf(" num nodes = %lu ", (long unsigned int) view_list_entries);
for (i=0; i<view_list_entries; i++) {
- printf(" %d ", view_list[i]);
+ printf(" " CS_PRI_NODE_ID, view_list[i]);
}
printf("\n");
}
diff --git a/test/testvotequorum1.c b/test/testvotequorum1.c
index d9110ca..f87c79b 100644
--- a/test/testvotequorum1.c
+++ b/test/testvotequorum1.c
@@ -91,7 +91,7 @@ static void votequorum_quorum_notification_fn(
printf(" quorate = %d\n", quorate);
for (i = 0; i< node_list_entries; i++) {
- printf(" %d: %s\n", node_list[i].nodeid, node_state(node_list[i].state));
+ printf(" " CS_PRI_NODE_ID ": %s\n", node_list[i].nodeid, node_state(node_list[i].state));
}
}
@@ -108,11 +108,11 @@ static void votequorum_nodelist_notification_fn(
printf("votequorum nodelist notification called \n");
printf(" number of nodes = %d\n", node_list_entries);
- printf(" current ringid = (%u.%"PRIu64")\n", ring_id.nodeid, ring_id.seq);
+ printf(" current ringid = (" CS_PRI_RING_ID ")\n", ring_id.nodeid, ring_id.seq);
printf(" nodes: ");
for (i = 0; i< node_list_entries; i++) {
- printf("%d ", node_list[i]);
+ printf(CS_PRI_NODE_ID " ", node_list[i]);
}
printf("\n\n");
}
diff --git a/test/testvotequorum2.c b/test/testvotequorum2.c
index a30e853..1e8c13f 100644
--- a/test/testvotequorum2.c
+++ b/test/testvotequorum2.c
@@ -85,7 +85,7 @@ static void votequorum_nodelist_notification_fn(
{
printf("votequorum nodelist notification called \n");
- printf(" current ringid = (%u.%"PRIu64")\n", ring_id.nodeid, ring_id.seq);
+ printf(" current ringid = (" CS_PRI_RING_ID ")\n", ring_id.nodeid, ring_id.seq);
printf("\n");
memcpy(&last_received_ring_id, &ring_id, sizeof(ring_id));
diff --git a/test/testzcgc.c b/test/testzcgc.c
index 15ab56b..ca177f4 100644
--- a/test/testzcgc.c
+++ b/test/testzcgc.c
@@ -39,6 +39,7 @@
#include <errno.h>
#include <unistd.h>
#include <string.h>
+#include <inttypes.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/select.h>
@@ -77,7 +78,7 @@ static void DeliverCallback (
inet_ntoa(saddr), pid, (const char *)msg);
}
else {
- printf("DeliverCallback: message (len=%lu)from node/pid %d/%d: '%s'\n",
+ printf("DeliverCallback: message (len=%lu)from node/pid " CS_PRI_NODE_ID "/%d: '%s'\n",
(unsigned long int) msg_len, nodeid, pid,
(const char *)msg);
}
@@ -104,7 +105,7 @@ static void ConfchgCallback (
joined_list[i].reason);
}
else {
- printf("joined node/pid: %d/%d reason: %d\n",
+ printf("joined node/pid: " CS_PRI_NODE_ID "/%d reason: %d\n",
joined_list[i].nodeid, joined_list[i].pid,
joined_list[i].reason);
}
@@ -118,7 +119,7 @@ static void ConfchgCallback (
left_list[i].reason);
}
else {
- printf("left node/pid: %d/%d reason: %d\n",
+ printf("left node/pid: " CS_PRI_NODE_ID "/%d reason: %d\n",
left_list[i].nodeid, left_list[i].pid,
left_list[i].reason);
}
@@ -133,7 +134,7 @@ static void ConfchgCallback (
inet_ntoa (saddr), member_list[i].pid);
}
else {
- printf("node/pid: %d/%d\n",
+ printf("node/pid: " CS_PRI_NODE_ID "/%d\n",
member_list[i].nodeid, member_list[i].pid);
}
}
diff --git a/tools/corosync-cfgtool.c b/tools/corosync-cfgtool.c
index f51b9d4..52aa6f9 100644
--- a/tools/corosync-cfgtool.c
+++ b/tools/corosync-cfgtool.c
@@ -153,7 +153,7 @@ linkstatusget_do (char *interface_name, int brief)
printf ("Could not get the local node id, the error is: %d\n", result);
}
else {
- printf ("Local node ID %u\n", nodeid);
+ printf ("Local node ID " CS_PRI_NODE_ID "\n", nodeid);
}
result = corosync_cfg_ring_status_get (handle,
@@ -187,8 +187,11 @@ linkstatusget_do (char *interface_name, int brief)
if (show_current_iface) {
printf ("LINK ID %s\n", interface_names[i]);
printf ("\taddr\t= %s\n", cur_iface_name_space + 1);
- if((!brief) && (strcmp(interface_status[i], "OK") != 0) &&
- (!strstr(interface_status[i], "FAULTY"))) {
+ /*
+ * UDP(U) interface_status is always OK and doesn't contain
+ * detailed information (only knet does).
+ */
+ if ((!brief) && (strcmp(interface_status[i], "OK") != 0)) {
len = strlen(interface_status[i]);
printf ("\tstatus:\n");
while (s < len) {
@@ -201,9 +204,6 @@ linkstatusget_do (char *interface_name, int brief)
}
} else {
printf ("\tstatus\t= %s\n", interface_status[i]);
- if (strstr(interface_status[i], "FAULTY")) {
- rc = 1;
- }
}
}
}
@@ -350,7 +350,7 @@ static void killnode_do(unsigned int nodeid)
cs_error_t result;
corosync_cfg_handle_t handle;
- printf ("Killing node %d\n", nodeid);
+ printf ("Killing node " CS_PRI_NODE_ID "\n", nodeid);
result = corosync_cfg_initialize (&handle, NULL);
if (result != CS_OK) {
printf ("Could not initialize corosync configuration API error %d\n", result);
diff --git a/tools/corosync-notifyd.c b/tools/corosync-notifyd.c
index 6338fe0..8f467f9 100644
--- a/tools/corosync-notifyd.c
+++ b/tools/corosync-notifyd.c
@@ -73,6 +73,7 @@ enum {
CS_NTF_SNMP,
CS_NTF_DBUS,
CS_NTF_FG,
+ CS_NTF_NODNS,
CS_NTF_MAX,
};
static int conf[CS_NTF_MAX];
@@ -237,6 +238,7 @@ static void _cs_cmap_members_key_changed (
if (NULL == key_name) {
qb_log(LOG_ERR, "key_name: nil");
+ return ;
}
res = sscanf(key_name, "runtime.members.%u.%s", &nodeid, tmp_key);
@@ -249,7 +251,7 @@ static void _cs_cmap_members_key_changed (
res = snprintf(tmp_key, CMAP_KEYNAME_MAXLEN, "runtime.members.%u.ip", nodeid);
if (res <= 0 || res >= CMAP_KEYNAME_MAXLEN) {
- qb_log(LOG_ERR, "temp_key: failed, res: %d, nodeid: %u", res, nodeid);
+ qb_log(LOG_ERR, "temp_key: failed, res: %d, nodeid: " CS_PRI_NODE_ID, res, nodeid);
return ;
}
no_retries = 0;
@@ -278,11 +280,14 @@ static void _cs_cmap_members_key_changed (
return ;
}
*close_bracket = '\0';
- res = _cs_ip_to_hostname(open_bracket, nodename);
- if (res) {
+ if(conf[CS_NTF_NODNS]) {
strncpy(nodename, open_bracket, CS_MAX_NAME_LENGTH-1);
+ } else {
+ res = _cs_ip_to_hostname(open_bracket, nodename);
+ if (res) {
+ strncpy(nodename, open_bracket, CS_MAX_NAME_LENGTH-1);
+ }
}
-
_cs_node_membership_event(nodename, nodeid, (char *)new_value.data, open_bracket);
free(ip_str);
}
@@ -761,7 +766,7 @@ _cs_dbus_init(void)
#endif /* HAVE_DBUS */
#ifdef ENABLE_SNMP
-static netsnmp_session *snmp_init (const char *target)
+static netsnmp_session *_cs_snmp_session_init (const char *target)
{
static netsnmp_session *session = NULL;
#ifndef NETSNMPV54
@@ -801,7 +806,7 @@ static netsnmp_session *snmp_init (const char *target)
return (session);
}
-static inline void add_field (
+static void _cs_snmp_add_field (
netsnmp_pdu *trap_pdu,
u_char asn_type,
const char *prefix,
@@ -815,38 +820,63 @@ static inline void add_field (
}
}
-static void
-_cs_snmp_node_membership_event(char *nodename, uint32_t nodeid, char *state, char* ip)
+static netsnmp_pdu *_cs_snmp_trap_pdu_init (const char *trap_oid)
{
- int ret;
- char csysuptime[CS_TIMESTAMP_STR_LEN];
static oid snmptrap_oid[] = { 1,3,6,1,6,3,1,1,4,1,0 };
static oid sysuptime_oid[] = { 1,3,6,1,2,1,1,3,0 };
- time_t now = time (NULL);
-
+ char csysuptime[CS_TIMESTAMP_STR_LEN];
+ time_t now;
+ struct tm *now_tm;
netsnmp_pdu *trap_pdu;
- netsnmp_session *session = snmp_init (snmp_manager);
- if (session == NULL) {
- qb_log(LOG_NOTICE, "Failed to init SNMP session.");
- return ;
+
+ now = time (NULL);
+ if (now == ((time_t)-1)) {
+ qb_log(LOG_NOTICE, "Failed to get timestamp.");
+ return (NULL);
+ }
+
+ /* format uptime */
+ now_tm = localtime(&now);
+ if (now_tm == NULL || strftime (csysuptime, sizeof(csysuptime), "%s", now_tm) == 0) {
+ qb_log(LOG_NOTICE, "Failed to format timestamp.");
+ return (NULL);
}
trap_pdu = snmp_pdu_create (SNMP_MSG_TRAP2);
if (!trap_pdu) {
qb_log(LOG_NOTICE, "Failed to create SNMP notification.");
- return ;
+ return (NULL);
}
/* send uptime */
- snprintf (csysuptime, CS_TIMESTAMP_STR_LEN, "%ld", now);
snmp_add_var (trap_pdu, sysuptime_oid, sizeof (sysuptime_oid) / sizeof (oid), 't', csysuptime);
- snmp_add_var (trap_pdu, snmptrap_oid, sizeof (snmptrap_oid) / sizeof (oid), 'o', SNMP_OID_TRAPS_NODE);
+ snmp_add_var (trap_pdu, snmptrap_oid, sizeof (snmptrap_oid) / sizeof (oid), 'o', trap_oid);
+
+ return (trap_pdu);
+}
+
+static void
+_cs_snmp_node_membership_event(char *nodename, uint32_t nodeid, char *state, char* ip)
+{
+ int ret;
+ netsnmp_pdu *trap_pdu;
+ netsnmp_session *session = _cs_snmp_session_init (snmp_manager);
+
+ if (session == NULL) {
+ qb_log(LOG_NOTICE, "Failed to init SNMP session.");
+ return ;
+ }
+
+ trap_pdu = _cs_snmp_trap_pdu_init(SNMP_OID_TRAPS_NODE);
+ if (trap_pdu == NULL) {
+ return ;
+ }
/* Add extries to the trap */
- add_field (trap_pdu, ASN_OCTET_STR, SNMP_OID_OBJECT_NODE_NAME, (void*)nodename, strlen (nodename));
- add_field (trap_pdu, ASN_UNSIGNED, SNMP_OID_OBJECT_NODE_ID, (void*)&nodeid, sizeof (nodeid));
- add_field (trap_pdu, ASN_OCTET_STR, SNMP_OID_OBJECT_NODE_ADDR, (void*)ip, strlen (ip));
- add_field (trap_pdu, ASN_OCTET_STR, SNMP_OID_OBJECT_NODE_STATUS, (void*)state, strlen (state));
+ _cs_snmp_add_field (trap_pdu, ASN_OCTET_STR, SNMP_OID_OBJECT_NODE_NAME, (void*)nodename, strlen (nodename));
+ _cs_snmp_add_field (trap_pdu, ASN_UNSIGNED, SNMP_OID_OBJECT_NODE_ID, (void*)&nodeid, sizeof (nodeid));
+ _cs_snmp_add_field (trap_pdu, ASN_OCTET_STR, SNMP_OID_OBJECT_NODE_ADDR, (void*)ip, strlen (ip));
+ _cs_snmp_add_field (trap_pdu, ASN_OCTET_STR, SNMP_OID_OBJECT_NODE_STATUS, (void*)state, strlen (state));
/* Send and cleanup */
ret = snmp_send (session, trap_pdu);
@@ -862,33 +892,23 @@ _cs_snmp_node_quorum_event(char *nodename, uint32_t nodeid,
const char *state)
{
int ret;
- char csysuptime[20];
- static oid snmptrap_oid[] = { 1,3,6,1,6,3,1,1,4,1,0 };
- static oid sysuptime_oid[] = { 1,3,6,1,2,1,1,3,0 };
- time_t now = time (NULL);
-
netsnmp_pdu *trap_pdu;
- netsnmp_session *session = snmp_init (snmp_manager);
+ netsnmp_session *session = _cs_snmp_session_init (snmp_manager);
+
if (session == NULL) {
qb_log(LOG_NOTICE, "Failed to init SNMP session.");
return ;
}
- trap_pdu = snmp_pdu_create (SNMP_MSG_TRAP2);
- if (!trap_pdu) {
- qb_log(LOG_NOTICE, "Failed to create SNMP notification.");
+ trap_pdu = _cs_snmp_trap_pdu_init(SNMP_OID_TRAPS_QUORUM);
+ if (trap_pdu == NULL) {
return ;
}
- /* send uptime */
- sprintf (csysuptime, "%ld", now);
- snmp_add_var (trap_pdu, sysuptime_oid, sizeof (sysuptime_oid) / sizeof (oid), 't', csysuptime);
- snmp_add_var (trap_pdu, snmptrap_oid, sizeof (snmptrap_oid) / sizeof (oid), 'o', SNMP_OID_TRAPS_QUORUM);
-
/* Add extries to the trap */
- add_field (trap_pdu, ASN_OCTET_STR, SNMP_OID_OBJECT_NODE_NAME, (void*)nodename, strlen (nodename));
- add_field (trap_pdu, ASN_UNSIGNED, SNMP_OID_OBJECT_NODE_ID, (void*)&nodeid, sizeof (nodeid));
- add_field (trap_pdu, ASN_OCTET_STR, SNMP_OID_OBJECT_QUORUM, (void*)state, strlen (state));
+ _cs_snmp_add_field (trap_pdu, ASN_OCTET_STR, SNMP_OID_OBJECT_NODE_NAME, (void*)nodename, strlen (nodename));
+ _cs_snmp_add_field (trap_pdu, ASN_UNSIGNED, SNMP_OID_OBJECT_NODE_ID, (void*)&nodeid, sizeof (nodeid));
+ _cs_snmp_add_field (trap_pdu, ASN_OCTET_STR, SNMP_OID_OBJECT_QUORUM, (void*)state, strlen (state));
/* Send and cleanup */
ret = snmp_send (session, trap_pdu);
@@ -904,35 +924,25 @@ _cs_snmp_link_faulty_event(char *nodename, uint32_t local_nodeid, uint32_t nodei
uint32_t iface_no, const char *state)
{
int ret;
- char csysuptime[20];
- static oid snmptrap_oid[] = { 1,3,6,1,6,3,1,1,4,1,0 };
- static oid sysuptime_oid[] = { 1,3,6,1,2,1,1,3,0 };
- time_t now = time (NULL);
-
netsnmp_pdu *trap_pdu;
- netsnmp_session *session = snmp_init (snmp_manager);
+ netsnmp_session *session = _cs_snmp_session_init (snmp_manager);
+
if (session == NULL) {
qb_log(LOG_NOTICE, "Failed to init SNMP session.");
return ;
}
- trap_pdu = snmp_pdu_create (SNMP_MSG_TRAP2);
- if (!trap_pdu) {
- qb_log(LOG_NOTICE, "Failed to create SNMP notification.");
+ trap_pdu = _cs_snmp_trap_pdu_init(SNMP_OID_TRAPS_LINK);
+ if (trap_pdu == NULL) {
return ;
}
- /* send uptime */
- sprintf (csysuptime, "%ld", now);
- snmp_add_var (trap_pdu, sysuptime_oid, sizeof (sysuptime_oid) / sizeof (oid), 't', csysuptime);
- snmp_add_var (trap_pdu, snmptrap_oid, sizeof (snmptrap_oid) / sizeof (oid), 'o', SNMP_OID_TRAPS_LINK);
-
/* Add extries to the trap */
- add_field (trap_pdu, ASN_OCTET_STR, SNMP_OID_OBJECT_NODE_NAME, (void*)nodename, strlen (nodename));
- add_field (trap_pdu, ASN_UNSIGNED, SNMP_OID_OBJECT_LOCAL_NODE_ID, (void*)&local_nodeid, sizeof (local_nodeid));
- add_field (trap_pdu, ASN_UNSIGNED, SNMP_OID_OBJECT_NODE_ID, (void*)&nodeid, sizeof (nodeid));
- add_field (trap_pdu, ASN_INTEGER, SNMP_OID_OBJECT_LINK_IFACE_NO, (void*)&iface_no, sizeof (iface_no));
- add_field (trap_pdu, ASN_OCTET_STR, SNMP_OID_OBJECT_LINK_STATUS, (void*)state, strlen (state));
+ _cs_snmp_add_field (trap_pdu, ASN_OCTET_STR, SNMP_OID_OBJECT_NODE_NAME, (void*)nodename, strlen (nodename));
+ _cs_snmp_add_field (trap_pdu, ASN_UNSIGNED, SNMP_OID_OBJECT_LOCAL_NODE_ID, (void*)&local_nodeid, sizeof (local_nodeid));
+ _cs_snmp_add_field (trap_pdu, ASN_UNSIGNED, SNMP_OID_OBJECT_NODE_ID, (void*)&nodeid, sizeof (nodeid));
+ _cs_snmp_add_field (trap_pdu, ASN_INTEGER, SNMP_OID_OBJECT_LINK_IFACE_NO, (void*)&iface_no, sizeof (iface_no));
+ _cs_snmp_add_field (trap_pdu, ASN_OCTET_STR, SNMP_OID_OBJECT_LINK_STATUS, (void*)state, strlen (state));
/* Send and cleanup */
ret = snmp_send (session, trap_pdu);
@@ -965,16 +975,16 @@ _cs_snmp_init(void)
static void
_cs_syslog_node_membership_event(char *nodename, uint32_t nodeid, char *state, char* ip)
{
- qb_log(LOG_NOTICE, "%s[%d] ip:%s %s", nodename, nodeid, ip, state);
+ qb_log(LOG_NOTICE, "%s[" CS_PRI_NODE_ID "] ip:%s %s", nodename, nodeid, ip, state);
}
static void
_cs_syslog_node_quorum_event(char *nodename, uint32_t nodeid, const char *state)
{
if (strcmp(state, "quorate") == 0) {
- qb_log(LOG_NOTICE, "%s[%d] is now %s", nodename, nodeid, state);
+ qb_log(LOG_NOTICE, "%s[" CS_PRI_NODE_ID "] is now %s", nodename, nodeid, state);
} else {
- qb_log(LOG_NOTICE, "%s[%d] has lost quorum", nodename, nodeid);
+ qb_log(LOG_NOTICE, "%s[" CS_PRI_NODE_ID "] has lost quorum", nodename, nodeid);
}
}
@@ -982,16 +992,16 @@ static void
_cs_syslog_application_connection_event(char *nodename, uint32_t nodeid, char* app_name, const char *state)
{
if (strcmp(state, "connected") == 0) {
- qb_log(LOG_NOTICE, "%s[%d] %s is now %s to corosync", nodename, nodeid, app_name, state);
+ qb_log(LOG_NOTICE, "%s[" CS_PRI_NODE_ID "] %s is now %s to corosync", nodename, nodeid, app_name, state);
} else {
- qb_log(LOG_NOTICE, "%s[%d] %s is now %s from corosync", nodename, nodeid, app_name, state);
+ qb_log(LOG_NOTICE, "%s[" CS_PRI_NODE_ID "] %s is now %s from corosync", nodename, nodeid, app_name, state);
}
}
static void
_cs_syslog_link_faulty_event(char *nodename, uint32_t our_nodeid, uint32_t nodeid, uint32_t iface_no, const char *state)
{
- qb_log(LOG_NOTICE, "%s[%d] link %u to node %u is now %s", nodename, our_nodeid, iface_no, nodeid, state);
+ qb_log(LOG_NOTICE, "%s[" CS_PRI_NODE_ID "] link %u to node " CS_PRI_NODE_ID " is now %s", nodename, our_nodeid, iface_no, nodeid, state);
}
static void
@@ -1258,6 +1268,7 @@ _cs_usage(void)
" -o : Print events to stdout (turns on -l).\n"\
" -s : Send SNMP traps on all events.\n"\
" -m : Set the SNMP Manager IP address (defaults to localhost).\n"\
+ " -n : No reverse DNS lookup on cmap member change events.\n"\
" -d : Send DBUS signals on all events.\n"\
" -h : Print this help.\n\n");
}
@@ -1273,7 +1284,7 @@ main(int argc, char *argv[])
conf[CS_NTF_SNMP] = QB_FALSE;
conf[CS_NTF_DBUS] = QB_FALSE;
- while ((ch = getopt (argc, argv, "c:floshdm:")) != EOF) {
+ while ((ch = getopt (argc, argv, "c:floshdnm:")) != EOF) {
switch (ch) {
case 'c':
strncpy(snmp_community_buf, optarg, sizeof (snmp_community_buf));
@@ -1292,6 +1303,9 @@ main(int argc, char *argv[])
snmp_manager_buf[sizeof (snmp_manager_buf) - 1] = '\0';
snmp_manager = snmp_manager_buf;
break;
+ case 'n':
+ conf[CS_NTF_NODNS] = QB_TRUE;
+ break;
case 'o':
conf[CS_NTF_LOG] = QB_TRUE;
conf[CS_NTF_STDOUT] = QB_TRUE;
diff --git a/tools/corosync-quorumtool.c b/tools/corosync-quorumtool.c
index 4819951..baaa447 100644
--- a/tools/corosync-quorumtool.c
+++ b/tools/corosync-quorumtool.c
@@ -236,7 +236,7 @@ static int set_votes(uint32_t nodeid, int votes)
int err;
if ((err=votequorum_setvotes(v_handle, nodeid, votes)) != CS_OK) {
- fprintf(stderr, "Unable to set votes %d for nodeid: %u: %s\n",
+ fprintf(stderr, "Unable to set votes %d for nodeid: " CS_PRI_NODE_ID ": %s\n",
votes, nodeid, cs_strerror(err));
}
@@ -340,7 +340,7 @@ static const char *node_name(uint32_t nodeid, name_format_t name_format)
err = corosync_cfg_get_node_addrs(c_handle, nodeid, INTERFACE_MAX, &numaddrs, addrs);
if (err != CS_OK) {
- fprintf(stderr, "Unable to get node address for nodeid %u: %s\n", nodeid, cs_strerror(err));
+ fprintf(stderr, "Unable to get node address for nodeid " CS_PRI_NODE_ID ": %s\n", nodeid, cs_strerror(err));
return "";
}
@@ -473,7 +473,7 @@ static void display_nodes_data(nodeid_format_t nodeid_format, name_format_t name
if (v_handle) {
for (i=0; i < g_view_list_entries; i++) {
if (votequorum_getinfo(v_handle, g_view_list[i].node_id, &info[i]) != CS_OK) {
- printf("Unable to get node %u info\n", g_view_list[i].node_id);
+ printf("Unable to get node " CS_PRI_NODE_ID " info\n", g_view_list[i].node_id);
}
g_view_list[i].vq_info = &info[i];
if (info[i].flags & VOTEQUORUM_INFO_QDEVICE_REGISTERED) {
@@ -600,16 +600,16 @@ static int display_quorum_data(int is_quorate,
printf("Quorum provider: %s\n", quorumtype);
printf("Nodes: %d\n", g_view_list_entries);
if (nodeid_format == NODEID_FORMAT_DECIMAL) {
- printf("Node ID: %u\n", our_nodeid);
+ printf("Node ID: " CS_PRI_NODE_ID "\n", our_nodeid);
} else {
printf("Node ID: 0x%08x\n", our_nodeid);
}
if (v_handle) {
- printf("Ring ID: %d/%" PRIu64 "\n", g_ring_id_rep_node, g_ring_id);
+ printf("Ring ID: " CS_PRI_RING_ID "\n", g_ring_id_rep_node, g_ring_id);
}
else {
- printf("Ring ID: %" PRIu64 "\n", g_ring_id);
+ printf("Ring ID: " CS_PRI_RING_ID_SEQ "\n", g_ring_id);
}
printf("Quorate: %s\n", is_quorate?"Yes":"No");
diff --git a/vqsim/vqmain.c b/vqsim/vqmain.c
index 25d0fad..e42ce9f 100644
--- a/vqsim/vqmain.c
+++ b/vqsim/vqmain.c
@@ -117,19 +117,19 @@ static void print_quorum_state(struct vq_node *node)
int i;
if (node->last_quorate < 0) {
- fprintf(output_file, "%d:%02d: q=UNINITIALIZED\n",
+ fprintf(output_file, "%d:" CS_PRI_NODE_ID ": q=UNINITIALIZED\n",
node->partition->num, node->nodeid);
return;
}
- fprintf(output_file, "%d:%02d: q=%d ring=[%d/%lld] ", node->partition->num, node->nodeid, node->last_quorate,
- node->last_ring_id.nodeid, node->last_ring_id.seq);
+ fprintf(output_file, "%d:" CS_PRI_NODE_ID ": q=%d ring=[" CS_PRI_RING_ID "] ", node->partition->num, node->nodeid, node->last_quorate,
+ node->last_ring_id.nodeid, (uint64_t)node->last_ring_id.seq);
fprintf(output_file, "nodes=[");
for (i = 0; i < node->last_view_list_entries; i++) {
if (i) {
fprintf(output_file, " ");
}
- fprintf(output_file, "%d", node->last_view_list[i]);
+ fprintf(output_file, CS_PRI_NODE_ID, node->last_view_list[i]);
}
fprintf(output_file, "]\n");
@@ -265,7 +265,7 @@ static int vq_parent_read_fn(int32_t fd, int32_t revents, void *data)
}
}
if (revents == POLLERR) {
- fprintf(stderr, "pollerr on %d\n", vqn->nodeid);
+ fprintf(stderr, "pollerr on " CS_PRI_NODE_ID "\n", vqn->nodeid);
}
return 0;
}
@@ -342,7 +342,7 @@ static int32_t sigchld_handler(int32_t sig, void *data)
sprintf(text, "(exit code %d)", WEXITSTATUS(status));
break;
}
- printf("%d:%02d: Quit %s\n", vqn->partition->num, vqn->nodeid, exit_status);
+ printf("%d:" CS_PRI_NODE_ID ": Quit %s\n", vqn->partition->num, vqn->nodeid, exit_status);
remove_node(vqn);
}
@@ -353,7 +353,7 @@ static int32_t sigchld_handler(int32_t sig, void *data)
if (WIFSIGNALED(status)) {
vqn = find_by_pid(pid);
if (vqn) {
- printf("%d:%02d exited on signal %d%s\n", vqn->partition->num, vqn->nodeid, WTERMSIG(status), WCOREDUMP(status)?" (core dumped)":"");
+ printf("%d:" CS_PRI_NODE_ID " exited on signal %d%s\n", vqn->partition->num, vqn->nodeid, WTERMSIG(status), WCOREDUMP(status)?" (core dumped)":"");
remove_node(vqn);
}
else {
@@ -411,7 +411,7 @@ static pid_t create_node(int nodeid, int partno)
newvq->instance = vq_create_instance(poll_loop, nodeid);
if (!newvq->instance) {
fprintf(stderr,
- "ERR: could not create vq instance nodeid %d\n",
+ "ERR: could not create vq instance nodeid " CS_PRI_NODE_ID "\n",
nodeid);
free(newvq);
return (pid_t) -1;
@@ -467,7 +467,7 @@ static size_t create_nodes_from_config(void)
pid = create_node(nodeid, 0);
if (pid == (pid_t) -1) {
fprintf(stderr,
- "ERR: nodeid %d could not be spawned\n",
+ "ERR: nodeid " CS_PRI_NODE_ID " could not be spawned\n",
nodeid);
exit(1);
}
@@ -537,7 +537,7 @@ int cmd_start_new_node(int nodeid, int partition)
node = find_node(nodeid);
if (node) {
- fprintf(stderr, "ERR: nodeid %d already exists in partition %d\n", nodeid, node->partition->num);
+ fprintf(stderr, "ERR: nodeid " CS_PRI_NODE_ID " already exists in partition %d\n", nodeid, node->partition->num);
return -1;
}
if (create_node(nodeid, partition) == -1) {
@@ -577,7 +577,7 @@ int cmd_stop_node(int nodeid)
node = find_node(nodeid);
if (!node) {
- fprintf(stderr, "ERR: nodeid %d is not up\n", nodeid);
+ fprintf(stderr, "ERR: nodeid " CS_PRI_NODE_ID " is not up\n", nodeid);
return -1;
}
@@ -613,7 +613,7 @@ void cmd_move_nodes(int partition, int num_nodes, int *nodelist)
node->partition = &partitions[partition];
}
else {
- printf("ERR: node %d does not exist\n", nodelist[i]);
+ printf("ERR: node " CS_PRI_NODE_ID " does not exist\n", nodelist[i]);
}
}
}
diff --git a/vqsim/vqsim_vq_engine.c b/vqsim/vqsim_vq_engine.c
index b8460f3..e0bb0bd 100644
--- a/vqsim/vqsim_vq_engine.c
+++ b/vqsim/vqsim_vq_engine.c
@@ -313,7 +313,7 @@ static int poll_qdevice(int onoff)
res = send_lib_msg(MESSAGE_REQ_VOTEQUORUM_QDEVICE_POLL, &pollmsg);
if (res != CS_OK) {
- fprintf(stderr, "%d: qdevice poll failed: %d\n", our_nodeid, res);
+ fprintf(stderr, CS_PRI_NODE_ID ": qdevice poll failed: %d\n", our_nodeid, res);
}
return res;
}
@@ -362,7 +362,7 @@ static void do_qdevice(int onoff)
start_qdevice_poll(1);
}
else {
- fprintf(stderr, "%d: qdevice registration failed: %d\n", our_nodeid, res);
+ fprintf(stderr, CS_PRI_NODE_ID ": qdevice registration failed: %d\n", our_nodeid, res);
}
}
else {