Commit Graph

75 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
Christine Caulfield
33fa5dcb85 config: Fail to start if ping timers are invalid
This required adding a lot of return values to two previously
'void' functions. I did two rather than just the one that was
needed because it seemed to make sense to do them both together.

Although these functions now return errors, they are probably
still ignored higher up. this really needs a comprehensive audit.

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2023-10-05 15:53:55 +02:00
Christine Caulfield
3e4eba6548 knet: use knet TRACE logging level if available
Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2023-04-03 16:13:23 +02:00
Jan Friesse
91348f8659 totemconfig: Add support for knet_mtu
totem.knet_mtu is new configuration option which allows setting
of automatic or manual knet MTU.

Also reload of totem.knet_pmtud_interval is fixed now, so it works when
key is deleted (and set back default value).

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2022-10-24 16:57:27 +02:00
Christine Caulfield
7b96a937df log: Configure knet logging to the same as corosync
Before this, all knet messages, including debug, were sent
over the pipe from knet to corosync and filtered in corosync.
This was obviously a waste, so now we tell knet the logging
level we need from it and so only get the messages that the
user has requested.

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2022-03-31 17:29:20 +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
Fabio M. Di Nitto
650a3f15cf knet: pass correct handle to knet_handle_compress
totemknet_configure_compression was using knet_context
just to gather the knet handle / instance.

On first time config knet_contex is not initialized till
much later in the code, passing some random garbage pointers
to knet_handle_compress, that would crash later trying
to acquire a mutex lock.

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2021-04-06 11:08:28 +02:00
Dan Streetman
4f171ea584 totemknet: retry knet_handle_new if it fails
Retry knet_handle_new without privileged operations if it fails

knet_handle_new can fail with ENAMETOOLONG if its privileged operations
fail, which can happen if we're running as a user process or in an
unprivileged container.

This adds a cmap key 'allow_knet_handle_fallback' that defaults to no,
which is the current behavior of exiting with error if the knet_handle
can't be created with privileged operations. If the new cmap key is set
to 'yes' and the knet_handle creation fails, fallback to creating the
handle using unprivileged operations is tried.

Signed-off-by: Dan Streetman <ddstreet@canonical.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2021-03-18 17:21:06 +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
Jan Friesse
4a2f48b17b totemknet: Check both cipher and hash for crypto
Previously only crypto cipher was used as a way to find out if crypto is
enabled or disabled.

This usually works ok until cipher is set to none and hash to some other
value (like sha1). Such config is perfectly valid and it was not
supported correctly.

As a solution, check both cipher and hash.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2020-11-12 13:47:15 +01:00
Christine Caulfield
5f71445be0 config: Allow reconfiguration of crypto options
Needs new knet crypto API.

If it's not available, then fall back to the old
API and forbid changing crypto while running.

To avoid us being dependant on the leader node, each
node sends its own crypto_reconfig_phase messages so
we can guarantee that the reconfiguration always completes
on each node.

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2020-07-09 16:54:16 +02:00
Christine Caulfield
f8b63083e1 config: Fix crash when a reload fails twice
Have string values stored in char arrays in totem_config
so we don't get into a mess with the pointers.

Also remove vsftype (which hasn't been used since corosync 1)

Use strncpy even though we know the string is fine. Keep covscan happy

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2020-04-24 16:27:18 +02: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
Hideo Yamauchi
0143ee9a2f totemknet: Change the initial value of the status
Signed-off-by: Hideo Yamauchi <renayama19661014@ybb.ne.jp>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2020-02-10 16:41:22 +01:00
Jan Friesse
29109683cf totemknet: Assert strcpy length
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
2019-11-28 09:44:44 +01:00
Jan Friesse
0c118d8ff4 totemknet: Check result of fcntl O_NONBLOCK call
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
2019-11-28 09:44:44 +01:00
Jan Friesse
380b744ec8 totemknet: Don't mix corosync and knet error codes
And use correct return code in stats.c.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
2019-11-28 09:44:44 +01:00
Jan Friesse
6ba9870f69 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.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2019-11-08 11:20:18 +01:00
Jan Friesse
1cf1558fe7 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.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Fabio M. Di Nitto <fdinitto@redhat.com>
2019-09-10 11:29:54 +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
Jan Friesse
d59a18d4a1 totemknet: Disable forwarding on shutdown
Disabling forwarding will make knet flush the messages (especially
LEAVE one).

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2019-06-28 08:27:18 +02:00
Jan Friesse
0839d3af82 totemknet: Initialize return value in setup_nozzle
Also add comment why return value is currently not used.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2019-06-12 15:40:51 +02:00
Jan Friesse
0d82e23517 totemknet: macaddr_str is always set
Check for NULL was invalid, because macaddr_str is ether defined in cmap
or set to "54:54:01:00:00:00".

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2019-06-12 15:40:51 +02:00
Jan Friesse
9b809383e6 totemknet: Ignore icmap_get_string result
... and add comment why it is not a bug.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2019-06-12 15:40:51 +02:00
Jan Friesse
9a0e7b584e totemknet: create_nozzle_device simplify check
ipaddr existence is checked for being not NULL by caller setup_nozzle.
Also ipaddr was passed to reparse_nozzle_ip_address function unchecked
so code would crash before reaching the actual check.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2019-06-12 15:40:50 +02:00
Jan Friesse
9bba026bcd knet: Use block_unlisted_ips
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2019-05-29 16:30:18 +02:00
Christine Caulfield
482df5d67b knet: Fix initialising of knet access lists.
It needs to be done at both reload and initialize time.
Also disable access lists if the config key is removed.

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2019-05-29 16:29:56 +02:00
Fabio M. Di Nitto
5c9a2b1c06 knet: allow corosync to use knet access lists
currently knet acl are only available on master
but they might be backported
to stable1 as they don´t break onwire protocol.

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2019-05-29 16:29:35 +02:00
Christine Caulfield
01ce5a96ef knet: Fix a couple of errors when adding a new link
When adding a new link for the first time you will often see:
1) knet_link_set_ping_timers for nodeid 1, link 1 failed: Invalid
argument (22)
2) New config has different knet transport for link 1. Internal value
was NOT changed. To reconfigure an interface it must be deleted and
recreated. A working interface needs to be available to corosync at all
times

1) is caused by setting the ping timers twice, once in
totemknet_member_add() and once in totemknet_refresh_config().
The first time we don't know the value
so it's zero and thus display an error. For this we simply check
for the zero and skip the knet API call. It's not ideal, but
totemconfig needs a lot of reconfiguring itself before we can
make this more sane.

2) was caused by simply comparing an unconfigured link with
a configured one, so OF COURSE, they are going to be different!

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2019-05-02 16:42:03 +02:00
Christine Caulfield
eab55e7384 nozzle: Add support for libnozzle devices
A nozzle device is a pseudo ethernet device that routes network
traffic through a channel on the corosync knet network (NOT cpg or any
corosync internal service) to other nodes in the cluster. It allows
applications to take advantage of knet features such as multipathing,
automatic failover, link switching etc.

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2019-02-26 13:11:35 +01:00
Fabio M. Di Nitto
ff7ace7655 [totemknet] update for libknet.so.2.0.0 init API
more changes are to be expected on this front as the API evolves in
knet master.

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2019-01-03 10:10:38 +01:00
Jan Friesse
844a76e775 totemknet: Free instance on failure exit
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2018-08-13 09:00:35 +02:00
Christine Caulfield
137b31397c knet: Don't try to create loopback interface twice
It wasn't hardmful, but it generated an annoying message

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2018-07-02 08:00:36 +02:00
Christine Caulfield
5dda71ae29 knet: Fix knet log buffer size
knet sends log messages as struct knet_log_msg, not a string
of KNET_MAX_LOG_MSG_SIZE (which is only part of that structure).
So we were both losing and corrupting messages.

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2018-07-02 08:00:15 +02:00
Jan Friesse
69857efb5b totem: Display IP of sender
To make finding victim of incompatible messages easier, IP of sender is
logged. Propagating IP in layers makes patch slightly larger.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2018-03-16 13:58:15 +01:00
Christine Caulfield
066525efd3 knet: Fix display of links with unconfigured link0
because totemknet always configures link0 as loopback even
if it's not known to corosync, we need to filter it
out when returning the link status, as things get misaligned
in cfg.

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2018-03-16 13:11:13 +01:00
Christine Caulfield
2c20590d16 knet: Always use link0 for loopback
Even if it's not used for anything else.

Also, make cfgtool show the correct link ID when links are not
contiguous

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2018-03-01 14:23:20 +01:00
Christine Caulfield
111bfbc11d totem: Fix debug warnings printed by knet
Fix crash introduced a couple of commits ago in iface_get

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2018-03-01 14:22:22 +01:00
Christine Caulfield
386d710ed1 cfg: Fix cfg_get_node_addrs so that DLM works
Also update copyright dates

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2018-03-01 14:19:45 +01:00
Christine Caulfield
fc8580bdbf totem: Use nodeid ONLY in srp_addr
This shrinks the srp_addr (and consequently every packet sent by
corosync) so that instead of containing loads of IP addresses to
identify a node, it just sends the nodeid.

This then allows us to make ring0 optional and replaceable when running
knet.

It also means that we need some other way of identifying the local
node in corosync.conf, so the nodelist.node.name entry is now mandatory
and is mapped to the local host using the same algorithm as used in
cman.

This code needs LOTS of testing as it touches a huge amount of totemsrp
and totemconfig.

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2018-03-01 14:18:51 +01:00
Christine Caulfield
31ddba64a2 config: Don't fudge port numbers
When I was adding knet I wanted the port numbers to default to the
base port number + the linknumber.

However I seem to have messed this up such that any port number
specified in the config file has the link number added to it. Which
is almost certainly not what people would expect.

This patch sets it right. If a port number is not specified
then 5405+linknumber is used. If a port number IS specified
then that actual number is used.

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2018-01-18 16:31:24 +01:00
Christine Caulfield
22ae4cacda knet: Allow ping_timers to be auto-configured
knet ping_timers are auto-configured according to token value.

This patch also fixes some knet config bugs that resulted in defaults
not being applied when values were removed from corosync.conf.

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2018-01-15 15:08:19 +01:00
Jan Friesse
96cb977880 totemknet: Drop truncated packets on receive
This is backport of part of "totemudpu: Scale receive buffer" patch.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
2018-01-09 17:46:31 +01:00
Christine Caulfield
98bb0c78c8 config: Allow selection of crypto_model
KNET has options for nss or openssl crpyto libraries, make this
available to corosync.

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2018-01-05 15:25:17 +01:00
Christine Caulfield
45fe19ed86 stats: Don't display errors when reading knet stat
Only add the knet handle stat keys if we are actually running knet. This
prevents errors occurring when iterating through all of the stats keys

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2017-11-03 13:40:41 +01:00
Christine Caulfield
d9dfd41e4e stats: Add cmap key to clear the various stats.
Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2017-10-31 17:39:14 +01:00
Christine Caulfield
16f616b65d knet: Add support for knet compression
Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2017-10-23 17:30:25 +02:00
Fabio M. Di Nitto
76591baa4a totem: Remove unnecessary NSS headers
Also fix corosync.spec.in to depend on libknet.

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2017-09-22 10:27:01 +02:00
Christine Caulfield
294a629fb5 config: Allow dynamic link configuration
Now we are using knet, it's possible to dynamically add, remove and
reconfigure links on the fly.

Also print 'n' for non-existant knet links. This will show up
only on loopback links >0. But it looks better than 'status ='

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2017-09-21 17:16:21 +02:00
Jonathan Davies
3296a0d41a totemknet: fix debug message typo
Signed-off-by: Jonathan Davies <jonathan.davies@citrix.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
2017-09-11 11:51:16 +02:00