1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00
Commit Graph

9256 Commits

Author SHA1 Message Date
Samuel Thibault
a7071565b0 ctdb: Include replace.h for PATH_MAX
Fixes build on GNU/Hurd.

Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Mon Nov 11 10:28:24 UTC 2024 on atb-devel-224
2024-11-11 10:28:23 +00:00
Martin Schwenke
4569c65288 ctdb-scripts: Add configuration variable CTDB_KILLTCP_USE_SS_KILL
This allows CTDB to be configured to use "ss -K" to reset TCP
connections on "releaseip".  This is only supported when the kernel is
configured with CONFIG_INET_DIAG_DESTROY enabled.

From the documentation:

   ss -K has been supported in ss since iproute 4.5 in March 2016 and
   in the Linux kernel since 4.4 in December 2015.  However, the
   required kernel configuration item CONFIG_INET_DIAG_DESTROY is
   disabled by default.  Although enabled in Debian kernels since
   ~2017 and in Ubuntu since at least 18.04,, this has only recently
   been enabled in distributions such as RHEL.  There seems to be no
   way, including running ss -K, to determine if this is supported, so
   use of this feature needs to be configurable.  When available, it
   should be the fastest, most reliable way of killing connections.

For RHEL and derivatives, this was enabled as follows:

* RHEL 8 via https://bugzilla.redhat.com/show_bug.cgi?id=2230213,
  arriving in version kernel-4.18.0-513.5.1.el8_9

* RHEL 9 via https://issues.redhat.com/browse/RHEL-212, arriving in
  kernel-5.14.0-360.el9

Enabling this option results in a small behaviour change because ss -K
always does a 2-way kill (i.e. it also sends a RST to the client).
Only a 1-way kill is done for SMB connections when ctdb_killtcp is
used - the reasons for this are shrouded in history and the 2-way kill
seems to work fine.

For the summary that is logged, when CTDB_KILLTCP_USE_SS_KILL is "yes"
or "try", always log the method used, even the fallback to
ctdb_killtcp.  However, when set to "no", maintain the existing
output.

The decision to use -K rather than --kill is because short options are
trivial to implement in test stubs.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>

Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Thu Nov  7 00:12:34 UTC 2024 on atb-devel-224
2024-11-07 00:12:34 +00:00
Martin Schwenke
19e65f4012 ctdb-scripts: Factor out function kill_tcp_summarise()
This will be used in a slightly different context in a subsequent
commit.  In that case, the number of killed connections will be passed
instead of the total number of connections, so support this here via
different modes instead of churning later.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
2024-11-06 23:03:42 +00:00
Martin Schwenke
590a86dbe4 ctdb-scripts: Track connections for all ports for public IPs
Currently TCP ports like NFS lock manager are not tracked.  It is
easier to track all connections than to add a configuration system to
try to track specified ports, so do that.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
2024-11-06 23:03:42 +00:00
Martin Schwenke
c3695722b6 ctdb-scripts: Get connections after tickle list
Running ss to get current connections before running ctdb gettickles
means the ss output might be out of date when the 2 lists are
compared.  Some tickles might have been added after ss was run by some
other means (e.g. SMB tickles, added internally) and they would be
deleted according to the stale ss output.

This isn't currently a problem because update_tickles() is currently
only called with port 2049, so all tickles are managed by this code.
That will change in a subsequent commit.

Changing the order means the reverse problem can occur, where
update_tickles() attempts to delete an already deleted tickle.  That
may happen occasionally but is harmless because it doesn't result in
missing information.  It (currently) just causes a message to be
logged at DEBUG level.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
2024-11-06 23:03:42 +00:00
Martin Schwenke
9683bb3ac2 ctdb-scripts: Move connection tracking to 10.interface
This should really be done for all connections to public IP addresses.
Leave the port number there for now - this is just the first step.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
2024-11-06 23:03:42 +00:00
Martin Schwenke
d39a1cc1d4 ctdb-server: Use ctdb_connection_same() to simplify
Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
2024-11-06 23:03:42 +00:00
Volker Lendecke
1b1fd5c228 ctdb: Don't leak a pointer on talloc_realloc failure
We should not directly overwrite the pointer we are realloc'ing

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2024-11-06 23:03:42 +00:00
Volker Lendecke
e080add68a ctdb: Save a few lines with talloc_zero()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2024-11-06 23:03:42 +00:00
Martin Schwenke
762f5f5ca6 ctdb-server: Remove duplicate logic
Initialise the pointer to NULL and fall through to let
talloc_realloc() do the allocation.  talloc_realloc() does the right
thing with a NULL pointer...

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
2024-11-06 23:03:42 +00:00
Martin Schwenke
5af8627feb ctdb-server: Handle pre-existing connection first
This is cheap when tcparray is NULL and let's the code that now
follows be simplified.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
2024-11-06 23:03:42 +00:00
Martin Schwenke
9838b4d0d6 ctdb-server: Drop an unnecessary variable
Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
2024-11-06 23:03:42 +00:00
Martin Schwenke
f4a8f84328 ctdb-server: Drop a log message to DEBUG level
This is harmless, so it doesn't generally need to be logged.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
2024-11-06 23:03:42 +00:00
Martin Schwenke
3c19c8df77 ctdb-server: Clean up connection tracking functions
Apply README.Coding, modernise logging, pre-render connection as a
string for logging, switch terminology from "tickle" to "connection",
tidy up comments.

No changes in functionality.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
2024-11-06 23:03:42 +00:00
Martin Schwenke
0505d06b12 ctdb-scripts: Use ss -H option to simplify
This option has been available since ~2018 and has been implemented in
the stub since then.  I guess we didn't use it because CentOS 7?

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
2024-11-06 23:03:42 +00:00
Martin Schwenke
32e4f78660 ctdb-scripts: Remove superseded compatibility code
Since commit 224e99804e, square brackets
have been parsed by daemon and tool code, so drop the compatibility
code from here.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
2024-11-06 23:03:42 +00:00
Martin Schwenke
b3e2c69ad9 ctdb-scripts: update_tickles() should use the public IPs cache
This avoids duplicating logic.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
2024-11-06 23:03:42 +00:00
Martin Schwenke
1a4a6c46f1 ctdb-scripts: Don't list connections when not hosting IPs
With an empty IP filter, all incoming connections to port 2049 will be
listed, not just those to public IP addresses.  This causes error
messages like the following to be logged:

  ctdb-eventd[...]: 60.nfs: Failed to add 1 tickles

since the connection being added seems to be for a random NFS mount
that doesn't use a public IP addresses.

This has been a problem for a long time (probably since commit
04fe9e2074 in 2015).  It isn't currently
a huge deal because it only affects NFS connections.  However, this
code will soon be used to track connections to public IP addresses on
all ports.  This would result in a constant stream of log messages,
since there will always be some active connections.

The theory behind the fix is that if a node hosts no public IPs then
it should have no relevant connections and has no business changing
the list of registered tickles.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
2024-11-06 23:03:42 +00:00
Martin Schwenke
3410eddd93 ctdb-scripts: Reformat with "shfmt -w -p -i 0 -fn"
Massage a couple of lines manually so they're formatted sanely given
the new indentation.   Re-run shfmt to ensure no further changes.

Best reviewed with "git show -w".

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
2024-11-06 23:03:42 +00:00
Martin Schwenke
025bd34dfc ctdb-doc: Improve 10.interface documentation and comments
Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
2024-11-06 23:03:42 +00:00
Martin Schwenke
60067e2a74 ctdb-tests: Fix ss -a not supported
This is currently just a series of typos.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
2024-11-06 23:03:42 +00:00
Martin Schwenke
4817e32c1d ctdb-tests: Drop unsupported long options from ss stub usage
These have not been supported since commit
896c77df1c in 2018.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
2024-11-06 23:03:42 +00:00
Martin Schwenke
557b034200 ctdb-tests: Ensure ss stub handles square brackets around addresses
It isn't unreasonable for unit test cases to use square brackets in
their input.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jerry Heyman <jheyman@ddn.com>
2024-11-06 23:03:42 +00:00
Douglas Bagnall
076c284d6f ctdb:tests: s/the the\b/the/ in comments
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Volker Lendecke <vl@samba.org>
2024-11-06 10:57:34 +00:00
Martin Schwenke
919510d86b ctdb-scripts: Don't set arp_filter=1 by default in 10.interface
That is, no longer set sysctl net.ipv4.conf.all.arp_filter=1 in
10.interface.  Only do this in 13.per_ip_routing.

This effectively reverts commit
0ebd7beb4b by Ronnie Sahlberg from 2007.
I have discussed this with Ronnie.  This setting was originally added
to force incoming traffic to the interface hosting each IP.  This
would spread the load across multiple interfaces hosting the same
subnet.  Without the setting, incoming traffic would go to the first
interface to answer an ARP request, so could be unbalanced if one
interface tended to answer more quickly.

However, networks are now faster and interface bonding/teaming works
well in Linux, so it is less likely that multiple interfaces will be
used in this way.

Also, problems are occurring in exactly the case this is meant to
help: when multiple interfaces host the same subnet.

The Linux kernel documentation for this option says:

  arp_filter - BOOLEAN
        - 1 - Allows you to have multiple network interfaces on the same
          subnet, and have the ARPs for each interface be answered
          based on whether or not the kernel would route a packet from
          the ARP'd IP out that interface (therefore you must use source
          based routing for this to work). In other words it allows control
          of which cards (usually 1) will respond to an arp request.

        - 0 - (default) The kernel can respond to arp requests with addresses
          from other interfaces. This may seem wrong but it usually makes
          sense, because it increases the chance of successful communication.
          IP addresses are owned by the complete host on Linux, not by
          particular interfaces. Only for more complex setups like load-
          balancing, does this behaviour cause problems.

        arp_filter for the interface will be enabled if at least one of
        conf/{all,interface}/arp_filter is set to TRUE,
        it will be disabled otherwise

Note the part for arp_filter=1 that says "you must use source based
routing for this to work".  The problems are probably due to a lack of
source-based routing when this is only used with 10.interface.  In
this case, outbound packets can come from a different
interface (corresponding to the first matching route), with a
different MAC address.  There is clearly some infrastructure or packet
filtering out there that objects to such asymmetric packet flows.

So, drop this setting from 10.interface because it isn't working as
intended.  Continue to enable it in 13.per_ip_routing, which exists to
set up the required source-based routing.

This change may affect balancing of packet flows when public IP
addresses can be hosted by multiple interfaces, but does not stop that
feature from working.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>

Autobuild-User(master): Anoop C S <anoopcs@samba.org>
Autobuild-Date(master): Thu Oct 17 18:53:32 UTC 2024 on atb-devel-224
2024-10-17 18:53:32 +00:00
Anoop C S
9ad287ed9c ctdb-build: Add missing ctdb-tcp dependency
Since 02c9e7a63f, common/path.h is
included within ctdb/tcp/tcp_connect.c. Therefore add ctdb-util
as a dependency for ctdb-tcp.

Signed-off-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>

Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Tue Oct  8 12:27:17 UTC 2024 on atb-devel-224
2024-10-08 12:27:17 +00:00
Martin Schwenke
9a2249c990 ctdb-server: Use find_public_ip_vnn() in a couple of extra places
Reorder code to use early returns, modernise debug.

Best reviewed with "git show -w".

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>

Autobuild-User(master): Anoop C S <anoopcs@samba.org>
Autobuild-Date(master): Tue Oct  8 06:42:04 UTC 2024 on atb-devel-224
2024-10-08 06:42:04 +00:00
Martin Schwenke
2167261b0e ctdb-server: Clean up find_public_ip_vnn()
Fix the comment (NULL versus -1), apply some README.Coding.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-10-08 05:34:30 +00:00
Martin Schwenke
d268c605c1 ctdb-daemon: Ensure CTDB_BASE is set, don't fetch it
Uses of CTDB_BASE in the subsequent code are now handled by the path
module, so there is no point getting the value of CTDB_BASE.  Instead,
check that the attempt to set it worked, noting that:

  [...] if overwrite is zero, then the value of name is not
  changed (and setenv() returns a success status).

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-10-08 05:34:30 +00:00
Martin Schwenke
b6151faf45 ctdb-daemon: Use path_etcdir_append() to construct some paths
No need to use CTDB_BASE directly.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-10-08 05:34:30 +00:00
Martin Schwenke
3b613a085b ctdb-daemon: Replace remaining uses of CTDB_NO_MEMORY() in this file
Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-10-08 05:34:30 +00:00
Martin Schwenke
01cc3f0784 ctdb-daemon: Clean up error handling and debug
Add some missing error handling and error messages.

Remove a use of CTDB_NO_MEMORY(), which then renders the caller's use
of ctdb_errstr() pointless, so remove that too.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-10-08 05:34:30 +00:00
Martin Schwenke
3429ba764c ctdb-daemon: Use ctdb_vnn_address_string() in old-style debugging
Modernise the debug macros along the way.

These are done separately because they will require a little more
patience to review.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-10-08 05:34:30 +00:00
Martin Schwenke
c17e629a8a ctdb-daemon: Add ctdb_vnn_address_string() and use in trivial places
Define a static function to return the string.  This clearly doesn't
need a ctdb_ prefix, but it matches ctdb_vnn_iface_string(), so
doesn't look out of place.

Use it in the places where review is trivial.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-10-08 05:34:30 +00:00
Martin Schwenke
766e6d35c4 ctdb-daemon: Store public address string in VNN
These are currently converted to strings constantly in log messages
and other places.  This clutters the code and probably has a minor
performance impact.

Add a new string field to the VNN structure.  Populate it when a
public address is added and the VNN structure is allocated.  This is
consistent with how node addresses are handled.

Don't use it yet, or this commit becomes huge.

A short-term goal is that each VNN public address will be converted to
a string only once.  A longer-term goal is to reduce use of
ctdb_addr_to_str().

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-10-08 05:34:30 +00:00
Martin Schwenke
ef3d9c227f ctdb-daemon: Fix a comment
The word "no" was accidentally dropped in commit
1e47a1b3f6.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-10-08 05:34:30 +00:00
Martin Schwenke
7b4447b4d3 ctdb-daemon: Drop unused arguments
Unused since commit a10545ab6b.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-10-08 05:34:30 +00:00
Martin Schwenke
46f6b50f7a ctdb-daemon: Improve error handling when releasing all IPs
Currently, event failures are completely ignored in favour of checking
if the IP is on an interface.  This misses the case where event
scripts up to and including 10.interface succeed, but something later
fails.  When that occurs, count is incremented, so the failure is
counted as a success in the summary that is logged.

Fail when releaseip fails even though 10.interface succeeded in
releasing the IP.  This may result in the IP address coming back, but
that's a different problem.

Underlying this is a design question about when releaseip is
successful.  Should releaseip be a distinct operation, with subsequent
reconfigurations considered separately?

Update logging to clearly identify each of the 3 possible errors.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-10-08 05:34:30 +00:00
Martin Schwenke
d1cb6dca72 ctdb-tcp: Modernise a DEBUG
This is last old-style one in this file.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>

Autobuild-User(master): Anoop C S <anoopcs@samba.org>
Autobuild-Date(master): Mon Oct  7 17:12:18 UTC 2024 on atb-devel-224
2024-10-07 17:12:18 +00:00
Martin Schwenke
939e5bdfd2 ctdb-tcp: Only attempt to automatically bind to local IPs
Automatic node address selection in the TCP transport does not work if
net.ipv4.ip_nonlocal_bind=1 because all nodes will be able to bind()
to the first address in the nodes list.

Before getting to the bind() step, add a check to see if an address is
local (i.e. on an interface).  If not, it is not considered.

This is defensively coded so that this step is skipped if local
addresses can not be retrieved.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-10-07 15:58:38 +00:00
Martin Schwenke
5af2f09a1f ctdb-server: Optimise local IP verification
It is more efficient calling ctdb_sys_local_ip_check() inside a loop
compared to calling ctdb_sys_have_ip().  There is a chance that this
is premature optimisation... but it sure is easy.  Fall back to
checking with bind().

I think these checks really exist because of the weirdness fixed by
commit 4b4e4d8870.  However, we might as
well do what we can.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-10-07 15:58:38 +00:00
Martin Schwenke
0536d7a98b ctdb-common: Reimplement ctdb_sys_have_ip() using new infrastructure
It can now be used when net.ipv4.ip_nonlocal_bind=1.

This makes the recovery daemon's local IP verification inefficient.
It can be optimised in a subsequent commit.

Fall back to bind() if unable to fetch IPs.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-10-07 15:58:38 +00:00
Martin Schwenke
a489b6699d ctdb-common: Make the argument to ctdb_sys_have_ip() const
Arguably, this would have made sense back in commit
bf86562144.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-10-07 15:58:38 +00:00
Martin Schwenke
a15167aafe ctdb-server: Add some local variables
Improve readability by not repeating the complex expression now
assigned to addr.  ctdb_sys_have_ip() is called in both arms of the
if/else, so call it once when declaring the new variable.

Modernise debug macros while touching lines.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-10-07 15:58:38 +00:00
Martin Schwenke
33e28deeef ctdb-tests: Add test code for ctdb_sys_have_ip()
Do not add any automated test cases because they will always be racy.
This allows manual testing of the function.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-10-07 15:58:38 +00:00
Martin Schwenke
cc99d0047d ctdb-common: Add functions for local IP address checking
This is a wrapper around getifaddrs(2), which is in libreplace, so
should always be available.

Some users want to set net.ipv4.ip_nonlocal_bind = 1.  So, CTDB needs
a way of testing if public IPs are present, without using bind(2).

Doing all of this unconditionally in ctdb_sys_have_ip() will be
inefficient in the recovery daemon's local IP verification if there
are a lot of IP addresses.  Split it this way so the interface
information can be retrieved once and used multiple times.

This doesn't appear to need IP canonicalisation for IPv4-mapped IPv6
addresses.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-10-07 15:58:38 +00:00
Martin Schwenke
aab763d659 ctdb-protocol: Add function ctdb_sock_addr_from_sockaddr()
Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: John Mulligan <jmulligan@redhat.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-10-07 15:58:38 +00:00
Martin Schwenke
250947611c ctdb-tests: Fix test failure when tests are installed
This currently works when tests are run in-tree.

However, when installed, use of an incorrect variable means it fails
to find statd_callout in the tests/ subdirectory.  Switch to using the
correct variable.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>

Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Sun Oct  6 11:07:05 UTC 2024 on atb-devel-224
2024-10-06 11:07:05 +00:00
Martin Schwenke
18b0ea3e9a ctdb-tests: Add missing quotes in test output
These should have caused test failure since commit
ef921bdbdb.  However, the test failure
occurred in a sub-shell, which covered the failure.  So, add an error
exit if the sub-shell fails.

While here, add an error exit for another potential uncaught
sub-shell-related failure in a related test.

Signed-off-by: Martin Schwenke <mschwenke@ddn.com>
Reviewed-by: Anoop C S <anoopcs@samba.org>
2024-10-06 09:52:35 +00:00
Volker Lendecke
25a222225d ctdb: Use str_list_add_printf() in lock_helper_args()
Saves lines, str_list_add_printf takes care of NULL checks

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>

Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Sun Sep 22 10:44:59 UTC 2024 on atb-devel-224
2024-09-22 10:44:59 +00:00