Commit Graph

297 Commits

Author SHA1 Message Date
Christine Caulfield
ce03c68394 Report crypto errors back to cfg reload
Because crypto changing happens in the 'commit' phase
of the reload and we can't get sure that knet will
allow the new parameters, the result gets ignored.
This can happen in FIPS mode if a non-FIPS cipher
is requested.

This patch reports the errors back in a cmap key
so that the command-line can spot those errors
and report them back to the user.

It also restores the internal values for crypto
so that subsequent attempts to change things have
predictable results. Otherwise further attempts can
do nothing but not report any errors back.

I've also added some error reporting back for the
knet ping counters using this mechanism.

The alternative to all of this would be to check for FIPS
in totemconfig.c and then exclude certain options, but this
would be duplicating code that could easily get out of sync.

This system could also be a useful mechanism for reporting
back other 'impossible' errors.

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2024-02-05 15:20:08 +01:00
Jan Friesse
384d168b0e build: Add explicit dependency for used libraries
Don't rely on implicit symbol finding (cs_strerror being most prominent
example) but rather use explicit one.

This makes current debian experimental happy (compile source)

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Fabio M. Di Nitto <fdinitto@redhat.com>
2021-11-10 08:24:20 +01:00
Jan Friesse
49999d0692 cfgtool: Use CS_PRI_NODE_ID for formatting nodeid
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2021-08-02 15:13:45 +02:00
Jan Friesse
2856a6d85e cfgtool: Fix brief mode display of localhost
Show 'n' also for first localhost link, so all localhost links
are marked consistently with non-brief display.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2021-08-02 15:13:38 +02:00
Jan Friesse
d2d159a8ac cfgtool: Set nodeid indexes after sort
Needed for having correct index of localhost

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2021-08-02 15:13:31 +02:00
Jan Friesse
3928c22fd7 cfgtool: Check existence of at least one of nodeid
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2021-08-02 15:13:13 +02:00
Christine Caulfield
1d217b9a34 knet: Fix node status display
Currently if there is a gap in the links (eg link0 is missing)
corosync-cfgtool -s will still display the links as 0,1,2,3...
even if they are 1,2,5,6...

Also display the KNET transport type with the link in
corosync-cfgtool -s & -n

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2021-07-29 14:38:53 +02:00
Christine Caulfield
461cf49467 cfg: Reinstate cfg tracking
CFG tracking was removed in 815375411e,
probably as a mistake, as part of the tidy up of cfg and the removal of
dynamic loading. This means that shutdown tracking (using
cfg_try_shutdown()) stopped working.

This patch restores the trackstart & trackstop API calls (renamed to be
more consistent with the exiting libraries) so that shutdown tracking
can be used again.

Change cfg.shutdown_timeout to be in milliseconds rather than seconds
nd use libqb macros for conversion.

Add --force option to corosync-cfgtool -H

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2021-01-14 16:09:46 +01:00
Jan Friesse
d76fc6ab85 cfg: Improve nodestatusget versioning
Patch tries to make nodestatusget really extendable. Following changes
are implemented:
- corosync_cfg_node_status_version_t is added with (for now) single
  value CFG_NODE_STATUS_V1
- corosync_knet_node_status renamed to corosync_cfg_node_status_v1 (it
  isn't really knet because it works as well for udp(u()
- struct res_lib_cfg_nodestatusget_version is added which holds only ipc
  result header and version on same position as for
  corosync_cfg_node_status_v1
- corosync_cfg_node_status_get requires version and pointer to one of
  corosync_cfg_node_status_v structures
- request is handled in case switches to make adding new version easier

Also fix following bugs:
- totempg_nodestatus_get error was retyped to cs_error_t without any
  meaning.
- header.error was not checked at all in the library

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2020-11-26 16:16:49 +01:00
Christine Caulfield
9e7f62d27d cfg: New API to get extended node/link infomation
Current we horribly over-use totempg_ifaces_get() to
retrieve information about knet interfaces. This is an attempt to
improve on that.

All transports are supported (so not only Knet but also UDP(U)).

This patch builds best against the "onwire-upgrade" branch of knet
as that's what sparked my interest in getting more information out.

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2020-11-26 16:15:50 +01:00
liangxin1300
ad2f1c6272 cfg: enhance message_handler_req_lib_cfg_killnode
While execute corosync-cfgtool -k <nodeid> to kill node:
* Check whether nodeid exists
* Check whether the node was joined

Signed-off-by: liangxin1300 <XLiang@suse.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2020-09-17 15:26:10 +02:00
liangxin1300
7f64a1dc0f cmapctl: return error on no result of print prefix
return  EXIT_FAILURE if no result print for ACTION_PRINT_PREFIX.

Signed-off-by: liangxin1300 <XLiang@suse.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2020-08-21 11:22:09 +02:00
liangxin1300
ec889e89c6 cmapctl: check NULL for key type and value for -p
To avoid segmentation fault.

Signed-off-by: liangxin1300 <XLiang@suse.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2020-08-21 11:20:21 +02:00
liangxin1300
56f9f19154 quorumtool: strict check for -o option
Signed-off-by: liangxin1300 <XLiang@suse.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2020-08-20 14:28:19 +02:00
liangxin1300
303c869259 quorumtool: Help shouldn't require running service
Do not require corosync running when usage is requested.

Signed-off-by: liangxin1300 <XLiang@suse.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2020-08-19 17:29:34 +02:00
liangxin1300
c02a69a988 cfgtool: Return error when -i doesn't match
Give error message and EXIT_FAILURE return code when -i
option doesn't match.

Signed-off-by: liangxin1300 <XLiang@suse.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2020-08-18 18:15:48 +02:00
liangxin1300
9105d94a80 cmapctl: return EXIT_FAILURE on failure
For -g and -d option return EXIT_FAILURE when error occurs (most often
because key does not exist).

Signed-off-by: liangxin1300 <XLiang@suse.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2020-08-17 14:59:13 +02:00
liangxin1300
fb5e0fae92 tools: use util_strtonum for options checking
Function atoi is not safe since miss validation;
Function strtol is better but need to consider empty string and overflows
Function util_strtonum is a safer wrapper of strtoll

Use util_strtonum to check nodeid option and strict checking condition.

Signed-off-by: liangxin1300 <XLiang@suse.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2020-08-12 16:56:34 +02:00
liangxin1300
e741f6a612 cfgtool: enhancement -a option
* Add return code
  * Give error message when nodeid not exist

Signed-off-by: liangxin1300 <XLiang@suse.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2020-08-11 09:45:10 +02:00
liangxin1300
06d530dbf5 cfgtool: output error messages to stderr
... and standardize the return code

Signed-off-by: liangxin1300 <XLiang@suse.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2020-08-07 11:39:52 +02:00
Hideo Yamauchi
0d0febbc94 cfgtool: Fix error code as described in MP
If all links are connected 0 is returned to the shell, otherwise it's
error code 1.

Signed-off-by: Hideo Yamauchi <renayama19661014@ybb.ne.jp>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2020-03-30 18:05:56 +02:00
Jan Friesse
5f543465bb quorumtool: exit on invalid expected votes
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2020-03-13 09:14:56 +01:00
Jan Friesse
15c25a286d cfgtool: Simplify output a bit for link status
Display words connected/disconnected instead of 1/0 and show enabled
status only when link is not enabled (shouldn't happen).

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2020-03-04 15:19:13 +01:00
Jan Friesse
720a892751 cfgtool: Improve link status display
Totemknet is enhanced to use 'n' character for localhost and not adding
status, because it is safe to expect that localhost link is always
connectd. corosync-cfgtool is enhanced to properly decode 'n', '?' and
'd' characters and display its meaning for extended status. Special
characters are also documented in man page.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2020-02-12 13:08:25 +01:00
Christine Caulfield
48b6894ef4 stats: Add stats for scheduler misses
This patch add a stats.schedmiss.* set of entries that
are a record of the last 10 times corosync was not scheduled
in time.

These entries are keypt in reverse order (so stats.schedmiss.0.* is
always the latest one kept) and the values, including the timestamp,
are in milliseconds.

It's also possible to use a cmap tracker to follow these events, which
might be useful.

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2020-01-22 17:06:10 +01:00
Jan Friesse
56ee850301 quorumtool: Assert copied string length
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
2019-11-28 09:44:45 +01:00
Jan Friesse
1fb095b0af notifyd: Check cmap_track_add result
And assert length of key_name to strcpy.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
2019-11-28 09:44:45 +01:00
Jan Friesse
8ff7760ce5 cmapctl: Free bin_value on error
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
2019-11-28 09:44:45 +01:00
Jan Friesse
21e1c71169 cfgtool: Remove unused callbacks
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
2019-11-28 09:44:45 +01:00
Jan Friesse
41a7b18ded notifyd: Don't dereference NULL key_name
This problem shouldn't really happen, but better safe than sorry.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
2019-07-30 14:24:32 +02:00
Jan Friesse
257a4fd377 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.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2019-07-08 15:13:45 +02:00
Jan Friesse
d7f5478b32 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.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2019-07-08 13:00:58 +02:00
Jan Friesse
5731af2782 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.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2019-07-03 10:53:52 +02:00
dkutergin
2183b9aa4a corosync-notifyd: Add option to disable DNS lookup
New configuration option -n is added.

Signed-off-by: dkutergin <dmytro.kutergin@harmonicinc.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2019-06-14 10:56:13 +02:00
Fabian Grünbichler
ef2569d323 cfgtool: Fix link status display
instead of the nodeid, this displayed arbitrary values (usually '1')
from other cmap keys under nodelist.node.XX.

sscanf returns the number of conversions even on mismatch, e.g. it also
returns 1 for

nodelist.node.2.quorum_votes
nodelist.node.2.ring0_addr
nodelist.node.2.name
...

instead of just

nodelist.node.2.nodeid

which leads to the value of (at least) quorum_votes being stored in
nodeid_list in addition to the actual nodeid.

storing the returned int in a cs_error_t enum also potentially masks
errors, so just compare the result with the expectation directly.

Fixes: c0d14485c3

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2019-05-30 15:23:37 +02:00
Jan Friesse
c260bce45b keygen: Reflect change in knet
Knet commit 1cb36f0cffd4559971826ca4774a88c5b05882fb reduced minimal
key length to 1024-bit. Keygen should keep compatibility with already
released 3.0.[0-1] so default key length should be 2048 bits. It's
possible to use -s argument to generate shorter key - keygen respects
minimum/maximum as defined by knet.

Also fix man page to reflect this change.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2019-04-11 15:14:06 +02:00
Jan Friesse
db38e3958c quorumtool: Fix exit status codes
1. Use EXIT_SUCCESS and EXIT_FAILURE when possible
2. For -s option return EXIT_SUCCESS when no problem appeared and node
   is quorate, EXIT_FAILURE if problem appeared and exit code 2
   (EXIT_NOT_QUORATE) when no problem appeared but node is not quorate.
3. Document exit codes in the man page

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2019-02-15 17:12:59 +01:00
Jan Friesse
4f9e46e7a8 corosync-cfgtool: Fix -i matching
Previously it was required to use link id together with IP address (ex.
"0 127.0.0.1") as a -i parameter.

This was reported as not very user friendly. Solution is to split
returned interface name and try match link id and ip address
separately.

Also fix typo in description of parameter -s.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2019-02-14 13:46:57 +01:00
Ferenc Wágner
6a476017b9 build: Use the SED variable provided by configure
Signed-off-by: Ferenc Wágner <wferi@debian.org>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2019-02-06 16:04:55 +01:00
Christine Caulfield
c0d14485c3 cfgtool: Improve link status display
Now show the nodeids properly, rather than node indexes which were
annoying and unhelpful.

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2019-02-04 08:06:01 +01:00
Jan Friesse
c41ab89b38 notifyd: Delete registered tracking keys
Forward port of needle 70fd667674 by Hideo
Yamauchi <renayama19661014@ybb.ne.jp>.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2018-11-16 11:47:29 +01:00
Jan Friesse
82f35f1720 log: Implement support for reopening log files
Feature depends on existence of libqb function qb_log_file_reopen.

New function call is added into CFG service API. This function is
used by corosync-cfgtool which now accepts -L parameter.

Finally, logrotate "postrotate" script is calling
corosync-cfgtool -L to notify corosync, instead of using
copytruncate option.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2018-10-16 14:46:52 +02:00
Jan Friesse
e313bbf8cb notifyd: Propagate error to exit code
When it's impossible to dispatch cmap/quorum messages exit code of
corosync-notifyd shouldn't be success.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2018-09-05 14:04:00 +02:00
Jan Friesse
deab940c88 corosync-notifyd: Rename global local_nodeid
To prevent warning in functions where local_nodeid is also passed as
local parameter.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2018-08-13 09:00:49 +02:00
Jan Friesse
f286388275 cmap: Fix strncpy warning in cmap_iter_next
cmap_iter_next in contrast of it's icmap counterpart copies key name
into user preallocated space. In the worst case, key name may be
CMAP_KEYNAME_MAXLEN, so cmap_iter_next then need CMAP_KEYNAME_MAXLEN +
additional byte to store zero. strncpy was copying only
CMAP_KEYNAME_MAXLEN characters so there was possibility of unterminated
string.

Patch solves this by using memcpy and always add trailing zero.
Documentation was improved suggesting minimum size of keyname buffer to
be CMAP_KEYNAME_MAXLEN + 1.

Also sam and quorumtool were using too short buffer so they are fixed too.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2018-08-13 09:00:41 +02:00
Chris Walker
bde247677b Add option for quiet operation to corosync-cmapctl
Signed-off-by: Chris Walker <cwalker@cray.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2018-08-09 10:05:48 +02:00
Jan Friesse
cc81696ff5 Fix snprintf warnings
Compiler shows warnings about possible not large enough buffer, so check
snprintf return value properly.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2018-07-02 08:08:33 +02:00
Ferenc Wágner
21b80818c5 tools: don't distribute what we can easily make
Signed-off-by: Ferenc Wágner <wferi@debian.org>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2018-04-23 11:30:14 +02:00
Jan Friesse
4ec3d590fa quorumtool: Don't set our_flags without v_handle
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2018-03-02 17:29:20 +01:00
Jan Friesse
883dbeb953 blackbox: Quote subshell result properly
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2018-03-02 17:29:16 +01:00