[SCM] Samba Shared Repository - branch master updated

Martin Schwenke martins at samba.org
Thu Aug 18 00:51:03 UTC 2016


The branch, master has been updated
       via  2fd20cf ctdb-tests: Validate that TAKE_IP works with IP already on an interface
       via  59b6f8f ctdb-tests: Validate that unexpected IP on interface is properly released
       via  abe5445 ctdb-recoverd: Don't directly release rogue IP addresses
       via  12f9e33 ctdb-daemon: Fix takeover of incorrectly assigned public IP address
       via  2210337 ctdb-daemon: Avoid referencing NULL pointer due to unknown old interface
       via  81cba90 Revert "When adding an ip at runtime, it might not yet have an iface assigned to it, so ensure that the next takover_ip call will fall through to accept the ip and add it."
       via  162857e ctdb-scripts: Add early exit for redundant updateip
       via  a10545a ctdb-daemon: Drop special case handling for new IP already on interface
       via  d2a9139 ctdb-daemon: Use release_ip_post() when releasing all IP addresses
       via  46c5136 ctdb-daemon: Factor out new function release_ip_post()
       via  e653c8b ctdb-daemon: Do not copy address for RELEASE_IP message
       via  ca22373 ctdb-daemon: Do not update the VNN state on RELEASE_IP failure
       via  509491a ctdb-daemon: Try to release IP address even if interface is unknown
       via  225575e ctdb-common: Save errno before closing file to keep debug accurate
       via  2400189 ctdb-tools: Consistently use db_name
       via  af502fa ctdb-tools: Fix CID 1125618 String not null terminated (STRING_NULL)
       via  254d554 ctdb-logging: Fix CID 1272823 Unchecked return value from library
       via  1de8948 ctdb-daemon: Fix CID 1362723 Unchecked return value from library
       via  bacf57c ctdb-tcp: Fix CID 1362724 Unchecked return value from library
       via  1710b14 ctdb-client: Print error message before next syscall to avoid losing errno
       via  9401830 ctdb-client: Fix CID 1362725 Unchecked return value from library
       via  0de5242 ctdb-daemon: Fix CID 1362726 Unchecked return value from library
       via  0e73734 ctdb-tcp: Set file descriptor to -1 after close.
       via  ce451c7 ctdb-tcp: Fix CID 1362727 Unchecked return value from library
       via  4bc934f ctdb-common: Fix CID 1362728 Unchecked return value from library
       via  6d1099a ctdb-common: Fix CID 1362729 Unchecked return value from library
       via  198ca88 ctdb-tests: Update porting test to be more flexible about line numbers
       via  518683a ctdb-daemon: Fix CID 1125574 Operands don't affect result
       via  1be2cd9 ctdb-daemon: Fix CID 1125575 Operands don't affect result
       via  b92c78a ctdb-daemon: Fix CID 1272855 Operands don't affect result
      from  47e6c37 ctdb-tools: Drop "ctdb rebalancenode"

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 2fd20cfd8515ab8c047149fdcbf5471d8c58a0af
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Aug 1 16:00:55 2016 +1000

    ctdb-tests: Validate that TAKE_IP works with IP already on an interface
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    Autobuild-User(master): Martin Schwenke <martins at samba.org>
    Autobuild-Date(master): Thu Aug 18 02:50:16 CEST 2016 on sn-devel-144

commit 59b6f8f13961503da14410b5318aeb31d94cd917
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Aug 2 21:02:08 2016 +1000

    ctdb-tests: Validate that unexpected IP on interface is properly released
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit abe5445c24ffc423cc7a15be1c37e499730cdb24
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Aug 2 12:18:15 2016 +1000

    ctdb-recoverd: Don't directly release rogue IP addresses
    
    This is inconsistent with the rest of the local IP verification.  It
    should notice problems but not try to fix them directly.  Like other
    cases, it should use an IP takeover run to try to fix the problem.  In
    this case the address might have just been added and an out-of-band
    RELEASE_IP might cause conflicts (i.e. "another change is in flight")
    with a scheduled IP takeover run.
    
    This effectively reverts commit
    694c1b269edc95df446b2e171919be0c266383c4.  Not sure why this was
    needed after c7e648c2d11f9785f2493a3dd67567a635633489.  More recently
    commit 6471541d6d2bc9f2af0ff92b280abbd1d933cf88 moves responsibility
    for determining interface/netmask to 10.interface so this should
    continue to work just fine.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 12f9e332e9bc3eedb0daf8927eafe11fc9ec63b5
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Aug 3 11:05:06 2016 +1000

    ctdb-daemon: Fix takeover of incorrectly assigned public IP address
    
    Cause an "updateip" instead of just logging a message.
    
    This may reset existing connections.  However, CTDB doesn't think the
    address should already be hosted on the node so there should be no
    connections.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 2210337ce8166561e27bf7c4bad8efaab766032b
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Jul 29 19:48:37 2016 +1000

    ctdb-daemon: Avoid referencing NULL pointer due to unknown old interface
    
    This doesn't currently happen but it will in a subsequent commit.
    That commit and this one could be squashed but then the functional
    change gets lost in amongst this one.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 81cba9054e438faf5ba3be6fe4893ad92350bd61
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Jul 29 19:41:01 2016 +1000

    Revert "When adding an ip at runtime, it might not yet have an iface assigned to it, so ensure that the next takover_ip call will fall through to accept the ip and add it."
    
    This reverts commit 4136f2714578a9bc0e5632a21d287a50f9ec137a.
    
    If the IP address is on an interface then it won't help to pretend
    that it isn't.  This will simply cause a takeip event, which will fail
    because the address can't be added.  Note that the IP address isn't
    necessarily new - something unexpected may have happened.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 162857eff164923c428b8bfe7dc3f5d110237a7f
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Jul 29 19:29:23 2016 +1000

    ctdb-scripts: Add early exit for redundant updateip
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit a10545ab6bd8a1b9ca87b0fdba8381cb8af0e284
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Aug 17 14:43:05 2016 +1000

    ctdb-daemon: Drop special case handling for new IP already on interface
    
    The address may already be assigned to another node, so this is wrong.
    It also leaves the interface unknown.
    
    This is better left to code that handles rogue IP addresses.  A
    takeover run should correctly takeover the address if it is assigned
    to this node or release it if it is assigned to another node.  Coming
    soon...
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit d2a91394f55a2e0152bf470dac2608618db13b1f
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Aug 11 14:07:44 2016 +1000

    ctdb-daemon: Use release_ip_post() when releasing all IP addresses
    
    This has the advantage of using common code.  Also, if there was
    previously a failed attempt to release the IP address as part of a
    delete, then this will finish processing the delete.
    
    Extra care needs to be taken when a VNN is actually deleted.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12158
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 46c5136e4e4bd291cbb96395374c9b133f5d8ad8
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Aug 11 13:57:43 2016 +1000

    ctdb-daemon: Factor out new function release_ip_post()
    
    This contains the cleanup that needs to be done after an IP address is
    released from an interface.
    
    state->vnn is set to the return value from release_ip_post(), which is
    either the original VNN, or NULL if it was deleted.  This allows
    correct handling of the in-flight flag in the destructor for state.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12158
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit e653c8bb4a7bd712351a4ead3997c61b22c46f8d
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Aug 11 13:41:12 2016 +1000

    ctdb-daemon: Do not copy address for RELEASE_IP message
    
    If there's an allocation failure then the implicit early return in
    CTDB_NO_MEMORY_VOID() means that no reply is sent to the control.
    ctdb_daemon_send_message() makes a copy of the data, so don't copy it
    here and remove an unnecessary chance of failure.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12158
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit ca22373231918dab4e94cf1bab03253aadd61993
Author: Martin Schwenke <martin at meltin.net>
Date:   Sat Jul 30 11:12:19 2016 +1000

    ctdb-daemon: Do not update the VNN state on RELEASE_IP failure
    
    If RELEASE_IP fails then updating the VNN makes it inconsistent with
    reality.  Instead, log the failure and move on to the next IP
    address.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12158
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 509491a868ed01bfc5a970bd36eea4b01130853a
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Aug 8 07:09:38 2016 +1000

    ctdb-daemon: Try to release IP address even if interface is unknown
    
    The "releaseip" event in 10.interface will determine the interface and
    do the right thing.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12158
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 225575e7e7d154ac24fef71e503e0cccd69f7463
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Aug 15 15:22:54 2016 +1000

    ctdb-common: Save errno before closing file to keep debug accurate
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12157
    
    In the AIX case, also add the close of the file.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 24001891dd3d990bf1096cbdd83df4d7bc823f8d
Author: Martin Schwenke <martin at meltin.net>
Date:   Sat Aug 13 10:29:24 2016 +1000

    ctdb-tools: Consistently use db_name
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12157
    
    CID 1364703: Resource leak (RESOURCE_LEAK)
    
    However, this would already be fixed by the fix for CID 1125618, so
    this is probably just a minor bug fix.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit af502fade13652009e3cf523672ab5e320520042
Author: Martin Schwenke <martin at meltin.net>
Date:   Sat Aug 13 10:29:15 2016 +1000

    ctdb-tools: Fix CID 1125618 String not null terminated (STRING_NULL)
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12157
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 254d5545f45f97afc737f00542dff985cd76a08e
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Aug 10 17:45:35 2016 +1000

    ctdb-logging: Fix CID 1272823 Unchecked return value from library
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12157
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 1de8948cb5f4d904dd0d5520c3f13034ed522cb2
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Aug 10 17:35:22 2016 +1000

    ctdb-daemon: Fix CID 1362723 Unchecked return value from library
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12157
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit bacf57c0658a220c9da6d2dfdf8dd42b9a491556
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Aug 10 17:31:52 2016 +1000

    ctdb-tcp: Fix CID 1362724 Unchecked return value from library
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12157
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 1710b14a3cfac8f6e768c51f7a510b4ed6aac5c7
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Aug 15 14:50:09 2016 +1000

    ctdb-client: Print error message before next syscall to avoid losing errno
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12157
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 94018302fd75c079369fff9492c1e09408e848af
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Aug 10 17:18:55 2016 +1000

    ctdb-client: Fix CID 1362725 Unchecked return value from library
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12157
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 0de52420b8735a50e8681655a49c59d3dab8a61f
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Aug 10 17:16:34 2016 +1000

    ctdb-daemon: Fix CID 1362726 Unchecked return value from library
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12157
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 0e737348227252d2c0d1708be40753775a9b17ad
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Aug 15 09:43:46 2016 +1000

    ctdb-tcp: Set file descriptor to -1 after close.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12157
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit ce451c7cc670dad3066ee11c69245d841662844e
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Aug 10 17:12:21 2016 +1000

    ctdb-tcp: Fix CID 1362727 Unchecked return value from library
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12157
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 4bc934f13234ece7fae0d533c23fd879e55b8ad2
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Aug 10 17:04:45 2016 +1000

    ctdb-common: Fix CID 1362728 Unchecked return value from library
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12157
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 6d1099a522de129cee8cdf9183ab3aaabe0592db
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Aug 11 11:15:58 2016 +1000

    ctdb-common: Fix CID 1362729 Unchecked return value from library
    
    Drop setting socket non-blocking and close-on-exec.  The socket is
    closed soon after.  Only a single packet is sent, making it almost
    impossible for it to block.  Also, note that sockets aren't setup this
    way for IPv6.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12157
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 198ca8839175e93988ee52e033195238064aaba5
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Aug 10 17:02:22 2016 +1000

    ctdb-tests: Update porting test to be more flexible about line numbers
    
    This way the test doesn't need to be changed every time the code is
    moved around.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12157
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 518683abfec163a6186c8502c2f9abae6dccb487
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Aug 10 16:53:54 2016 +1000

    ctdb-daemon: Fix CID 1125574 Operands don't affect result
    
    Interfaces going up or down are always interesting, so log these at
    error level.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12157
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 1be2cd9dd2fc5093121c12aabf25116a840581f8
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Aug 10 16:46:51 2016 +1000

    ctdb-daemon: Fix CID 1125575 Operands don't affect result
    
    This is related to an error, so repeatedly log at error level instead
    of trying to avoid repetition.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12157
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit b92c78a043d20d5d94f5dbb0fed750b820b2f248
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Aug 10 16:42:13 2016 +1000

    ctdb-daemon: Fix CID 1272855 Operands don't affect result
    
    Failures are already logged at alert/error level above, so just log
    the summary at notice level.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=12157
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

-----------------------------------------------------------------------

Summary of changes:
 ctdb/client/ctdb_client.c                  |  18 +++-
 ctdb/common/system_aix.c                   |  13 +--
 ctdb/common/system_freebsd.c               |  12 ++-
 ctdb/common/system_gnu.c                   |  18 ++--
 ctdb/common/system_kfreebsd.c              |  18 ++--
 ctdb/common/system_linux.c                 |  25 +++--
 ctdb/config/events.d/10.interface          |   7 ++
 ctdb/server/ctdb_daemon.c                  |  23 +++-
 ctdb/server/ctdb_logging_syslog.c          |   8 +-
 ctdb/server/ctdb_ltdb_server.c             |   2 +-
 ctdb/server/ctdb_monitor.c                 |   2 +-
 ctdb/server/ctdb_recoverd.c                |  11 +-
 ctdb/server/ctdb_takeover.c                | 166 +++++++++++++++--------------
 ctdb/tcp/tcp_connect.c                     |  29 ++++-
 ctdb/tests/complex/60_rogueip_releaseip.sh |  59 ++++++++++
 ctdb/tests/complex/61_rogueip_takeip.sh    |  45 ++++++++
 ctdb/tests/cunit/porting_tests_001.sh      |   9 +-
 ctdb/tools/ctdb.c                          |   4 +-
 18 files changed, 334 insertions(+), 135 deletions(-)
 create mode 100755 ctdb/tests/complex/60_rogueip_releaseip.sh
 create mode 100755 ctdb/tests/complex/61_rogueip_takeip.sh


Changeset truncated at 500 lines:

diff --git a/ctdb/client/ctdb_client.c b/ctdb/client/ctdb_client.c
index bad38b6..1661d2a 100644
--- a/ctdb/client/ctdb_client.c
+++ b/ctdb/client/ctdb_client.c
@@ -276,6 +276,7 @@ done:
 int ctdb_socket_connect(struct ctdb_context *ctdb)
 {
 	struct sockaddr_un addr;
+	int ret;
 
 	memset(&addr, 0, sizeof(addr));
 	addr.sun_family = AF_UNIX;
@@ -288,13 +289,26 @@ int ctdb_socket_connect(struct ctdb_context *ctdb)
 	}
 
 	if (connect(ctdb->daemon.sd, (struct sockaddr *)&addr, sizeof(addr)) == -1) {
+		DEBUG(DEBUG_ERR,
+		      (__location__
+		       "Failed to connect client socket to daemon (%s)\n",
+		       strerror(errno)));
+		close(ctdb->daemon.sd);
+		ctdb->daemon.sd = -1;
+		return -1;
+	}
+
+	ret = set_blocking(ctdb->daemon.sd, false);
+	if (ret != 0) {
+		DEBUG(DEBUG_ERR,
+		      (__location__
+		       " failed to set socket non-blocking (%s)\n",
+		       strerror(errno)));
 		close(ctdb->daemon.sd);
 		ctdb->daemon.sd = -1;
-		DEBUG(DEBUG_ERR,(__location__ " Failed to connect client socket to daemon. Errno:%s(%d)\n", strerror(errno), errno));
 		return -1;
 	}
 
-	set_blocking(ctdb->daemon.sd, false);
 	set_close_on_exec(ctdb->daemon.sd);
 
 	ctdb->daemon.queue = ctdb_queue_setup(ctdb, ctdb, ctdb->daemon.sd, 
diff --git a/ctdb/common/system_aix.c b/ctdb/common/system_aix.c
index 48cd781..e44d1d6 100644
--- a/ctdb/common/system_aix.c
+++ b/ctdb/common/system_aix.c
@@ -118,7 +118,7 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest,
 		struct ip ip;
 		struct tcphdr tcp;
 	} ip4pkt;
-
+	int saved_errno;
 
 	/* for now, we only handle AF_INET addresses */
 	if (src->ip.sin_family != AF_INET || dest->ip.sin_family != AF_INET) {
@@ -143,9 +143,6 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest,
 		return -1;
 	}
 
-	set_blocking(s, false);
-	set_close_on_exec(s);
-
 	memset(&ip4pkt, 0, sizeof(ip4pkt));
 	ip4pkt.ip.ip_v     = 4;
 	ip4pkt.ip.ip_hl    = sizeof(ip4pkt.ip)/4;
@@ -168,9 +165,13 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest,
 	ip4pkt.tcp.th_win   = htons(1234);
 	ip4pkt.tcp.th_sum    = tcp_checksum((uint16_t *)&ip4pkt.tcp, sizeof(ip4pkt.tcp), &ip4pkt.ip);
 
-	ret = sendto(s, &ip4pkt, sizeof(ip4pkt), 0, (struct sockaddr *)dest, sizeof(*dest));
+	ret = sendto(s, &ip4pkt, sizeof(ip4pkt), 0,
+		     (struct sockaddr *)dest, sizeof(*dest));
+	saved_errno = errno;
+	close(s);
 	if (ret != sizeof(ip4pkt)) {
-		DEBUG(DEBUG_CRIT,(__location__ " failed sendto (%s)\n", strerror(errno)));
+		DEBUG(DEBUG_ERR,
+		      ("Failed sendto (%s)\n", strerror(saved_errno)));
 		return -1;
 	}
 
diff --git a/ctdb/common/system_freebsd.c b/ctdb/common/system_freebsd.c
index a03b97a..e72fbbd 100644
--- a/ctdb/common/system_freebsd.c
+++ b/ctdb/common/system_freebsd.c
@@ -137,6 +137,7 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest,
 		struct ip6_hdr ip6;
 		struct tcphdr tcp;
 	} ip6pkt;
+	int saved_errno;
 
 	switch (src->ip.sin_family) {
 	case AF_INET:
@@ -180,15 +181,14 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest,
 			return -1;
 		}
 
-		set_blocking(s, false);
-		set_close_on_exec(s);
-
 		ret = sendto(s, &ip4pkt, sizeof(ip4pkt), 0,
 			     (const struct sockaddr *)&dest->ip,
 			     sizeof(dest->ip));
+		saved_errno = errno;
 		close(s);
 		if (ret != sizeof(ip4pkt)) {
-			DEBUG(DEBUG_CRIT,(__location__ " failed sendto (%s)\n", strerror(errno)));
+			DEBUG(DEBUG_ERR,
+			      ("Failed sendto (%s)\n", strerror(saved_errno)));
 			return -1;
 		}
 		break;
@@ -231,11 +231,13 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest,
 		ret = sendto(s, &ip6pkt, sizeof(ip6pkt), 0,
 			     (const struct sockaddr *)&dest->ip6,
 			     sizeof(dest->ip6));
+		saved_errno = errno;
 		tmpdest->ip6.sin6_port = tmpport;
 		close(s);
 
 		if (ret != sizeof(ip6pkt)) {
-			DEBUG(DEBUG_CRIT,(__location__ " failed sendto (%s)\n", strerror(errno)));
+			DEBUG(DEBUG_ERR,
+			      ("Failed sendto (%s)\n", strerror(saved_errno)));
 			return -1;
 		}
 		break;
diff --git a/ctdb/common/system_gnu.c b/ctdb/common/system_gnu.c
index 09c4ffe..603345d 100644
--- a/ctdb/common/system_gnu.c
+++ b/ctdb/common/system_gnu.c
@@ -136,6 +136,7 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest,
 		struct ip6_hdr ip6;
 		struct tcphdr tcp;
 	} ip6pkt;
+	int saved_errno;
 
 	switch (src->ip.sin_family) {
 	case AF_INET:
@@ -178,13 +179,13 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest,
 			return -1;
 		}
 
-		set_blocking(s, false);
-		set_close_on_exec(s);
-
-		ret = sendto(s, &ip4pkt, sizeof(ip4pkt), 0, &dest->ip, sizeof(dest->ip));
+		ret = sendto(s, &ip4pkt, sizeof(ip4pkt), 0,
+			     &dest->ip, sizeof(dest->ip));
+		saved_errno = errno;
 		close(s);
 		if (ret != sizeof(ip4pkt)) {
-			DEBUG(DEBUG_CRIT,(__location__ " failed sendto (%s)\n", strerror(errno)));
+			DEBUG(DEBUG_ERR,
+			      ("Failed sendto (%s)\n", strerror(saved_errno)));
 			return -1;
 		}
 		break;
@@ -223,12 +224,15 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest,
 		tmpport = tmpdest->ip6.sin6_port;
 
 		tmpdest->ip6.sin6_port = 0;
-		ret = sendto(s, &ip6pkt, sizeof(ip6pkt), 0, &dest->ip6, sizeof(dest->ip6));
+		ret = sendto(s, &ip6pkt, sizeof(ip6pkt), 0,
+			     &dest->ip6, sizeof(dest->ip6));
+		saved_errno = errno;
 		tmpdest->ip6.sin6_port = tmpport;
 		close(s);
 
 		if (ret != sizeof(ip6pkt)) {
-			DEBUG(DEBUG_CRIT,(__location__ " failed sendto (%s)\n", strerror(errno)));
+			DEBUG(DEBUG_ERR,
+			      ("Failed sendto (%s)\n", strerror(saved_errno)));
 			return -1;
 		}
 		break;
diff --git a/ctdb/common/system_kfreebsd.c b/ctdb/common/system_kfreebsd.c
index 56f7c1c..7e33990 100644
--- a/ctdb/common/system_kfreebsd.c
+++ b/ctdb/common/system_kfreebsd.c
@@ -136,6 +136,7 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest,
 		struct ip6_hdr ip6;
 		struct tcphdr tcp;
 	} ip6pkt;
+	int saved_errno;
 
 	switch (src->ip.sin_family) {
 	case AF_INET:
@@ -178,13 +179,13 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest,
 			return -1;
 		}
 
-		set_blocking(s, false);
-		set_close_on_exec(s);
-
-		ret = sendto(s, &ip4pkt, sizeof(ip4pkt), 0, &dest->ip, sizeof(dest->ip));
+		ret = sendto(s, &ip4pkt, sizeof(ip4pkt), 0,
+			     &dest->ip, sizeof(dest->ip));
+		saved_errno = errno;
 		close(s);
 		if (ret != sizeof(ip4pkt)) {
-			DEBUG(DEBUG_CRIT,(__location__ " failed sendto (%s)\n", strerror(errno)));
+			DEBUG(DEBUG_ERR,
+			      ("Failed sendto (%s)\n", strerror(saved_errno)));
 			return -1;
 		}
 		break;
@@ -223,12 +224,15 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest,
 		tmpport = tmpdest->ip6.sin6_port;
 
 		tmpdest->ip6.sin6_port = 0;
-		ret = sendto(s, &ip6pkt, sizeof(ip6pkt), 0, &dest->ip6, sizeof(dest->ip6));
+		ret = sendto(s, &ip6pkt, sizeof(ip6pkt), 0,
+			     &dest->ip6, sizeof(dest->ip6));
+		saved_errno = errno;
 		tmpdest->ip6.sin6_port = tmpport;
 		close(s);
 
 		if (ret != sizeof(ip6pkt)) {
-			DEBUG(DEBUG_CRIT,(__location__ " failed sendto (%s)\n", strerror(errno)));
+			DEBUG(DEBUG_ERR,
+			      ("Failed sendto (%s)\n", strerror(saved_errno)));
 			return -1;
 		}
 		break;
diff --git a/ctdb/common/system_linux.c b/ctdb/common/system_linux.c
index b66ce67..3647de9 100644
--- a/ctdb/common/system_linux.c
+++ b/ctdb/common/system_linux.c
@@ -344,6 +344,7 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest,
 		struct ip6_hdr ip6;
 		struct tcphdr tcp;
 	} ip6pkt;
+	int saved_errno;
 
 	switch (src->ip.sin_family) {
 	case AF_INET:
@@ -386,15 +387,14 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest,
 			return -1;
 		}
 
-		set_blocking(s, false);
-		set_close_on_exec(s);
-
 		ret = sendto(s, &ip4pkt, sizeof(ip4pkt), 0,
 			     (const struct sockaddr *)&dest->ip,
 			     sizeof(dest->ip));
+		saved_errno = errno;
 		close(s);
 		if (ret != sizeof(ip4pkt)) {
-			DEBUG(DEBUG_CRIT,(__location__ " failed sendto (%s)\n", strerror(errno)));
+			DEBUG(DEBUG_ERR,
+			      ("Failed sendto (%s)\n", strerror(saved_errno)));
 			return -1;
 		}
 		break;
@@ -436,11 +436,13 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest,
 		ret = sendto(s, &ip6pkt, sizeof(ip6pkt), 0,
 			     (const struct sockaddr *)&dest->ip6,
 			     sizeof(dest->ip6));
+		saved_errno = errno;
 		tmpdest->ip6.sin6_port = tmpport;
 		close(s);
 
 		if (ret != sizeof(ip6pkt)) {
-			DEBUG(DEBUG_CRIT,(__location__ " failed sendto (%s)\n", strerror(errno)));
+			DEBUG(DEBUG_ERR,
+			      ("Failed sendto (%s)\n", strerror(saved_errno)));
 			return -1;
 		}
 		break;
@@ -458,7 +460,7 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest,
  */
 int ctdb_sys_open_capture_socket(const char *iface, void **private_data)
 {
-	int s;
+	int s, ret;
 
 	/* Open a socket to capture all traffic */
 	s = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
@@ -469,7 +471,16 @@ int ctdb_sys_open_capture_socket(const char *iface, void **private_data)
 
 	DEBUG(DEBUG_DEBUG, (__location__ " Created RAW SOCKET FD:%d for tcp tickle\n", s));
 
-	set_blocking(s, false);
+	ret = set_blocking(s, false);
+	if (ret != 0) {
+		DEBUG(DEBUG_ERR,
+		      (__location__
+		       " failed to set socket non-blocking (%s)\n",
+		       strerror(errno)));
+		close(s);
+		return -1;
+	}
+
 	set_close_on_exec(s);
 
 	return s;
diff --git a/ctdb/config/events.d/10.interface b/ctdb/config/events.d/10.interface
index 51abc44..073bc85 100755
--- a/ctdb/config/events.d/10.interface
+++ b/ctdb/config/events.d/10.interface
@@ -225,6 +225,13 @@ updateip)
 	get_iface_ip_maskbits "$_oiface" "$_ip" "$_maskbits"
 	oiface="$iface"
 
+	# Could check maskbits too.  However, that should never change
+	# so we want to notice if it does.
+	if [ "$oiface" = "$niface" ] ; then
+		echo "Redundant \"updateip\" - ${ip} already on ${niface}"
+		exit 0
+	fi
+
 	ip_block "$ip" "$oiface"
 
 	delete_ip_from_iface "$oiface" "$ip" "$maskbits" 2>/dev/null
diff --git a/ctdb/server/ctdb_daemon.c b/ctdb/server/ctdb_daemon.c
index 267d899..47e49df 100644
--- a/ctdb/server/ctdb_daemon.c
+++ b/ctdb/server/ctdb_daemon.c
@@ -930,6 +930,7 @@ static void ctdb_accept_client(struct tevent_context *ev,
 	struct ctdb_client *client;
 	struct ctdb_client_pid_list *client_pid;
 	pid_t peer_pid = 0;
+	int ret;
 
 	memset(&addr, 0, sizeof(addr));
 	len = sizeof(addr);
@@ -938,7 +939,16 @@ static void ctdb_accept_client(struct tevent_context *ev,
 		return;
 	}
 
-	set_blocking(fd, false);
+	ret = set_blocking(fd, false);
+	if (ret != 0) {
+		DEBUG(DEBUG_ERR,
+		      (__location__
+		       " failed to set socket non-blocking (%s)\n",
+		       strerror(errno)));
+		close(fd);
+		return;
+	}
+
 	set_close_on_exec(fd);
 
 	DEBUG(DEBUG_DEBUG,(__location__ " Created SOCKET FD:%d to connected child\n", fd));
@@ -984,6 +994,7 @@ static void ctdb_accept_client(struct tevent_context *ev,
 static int ux_socket_bind(struct ctdb_context *ctdb)
 {
 	struct sockaddr_un addr;
+	int ret;
 
 	ctdb->daemon.sd = socket(AF_UNIX, SOCK_STREAM, 0);
 	if (ctdb->daemon.sd == -1) {
@@ -1007,7 +1018,15 @@ static int ux_socket_bind(struct ctdb_context *ctdb)
 	unlink(ctdb->daemon.name);
 
 	set_close_on_exec(ctdb->daemon.sd);
-	set_blocking(ctdb->daemon.sd, false);
+
+	ret = set_blocking(ctdb->daemon.sd, false);
+	if (ret != 0) {
+		DEBUG(DEBUG_ERR,
+		      (__location__
+		       " failed to set socket non-blocking (%s)\n",
+		       strerror(errno)));
+		goto failed;
+	}
 
 	if (bind(ctdb->daemon.sd, (struct sockaddr *)&addr, sizeof(addr)) == -1) {
 		DEBUG(DEBUG_CRIT,("Unable to bind on ctdb socket '%s'\n", ctdb->daemon.name));
diff --git a/ctdb/server/ctdb_logging_syslog.c b/ctdb/server/ctdb_logging_syslog.c
index 54643e2..6d84587 100644
--- a/ctdb/server/ctdb_logging_syslog.c
+++ b/ctdb/server/ctdb_logging_syslog.c
@@ -216,7 +216,13 @@ static int ctdb_log_setup_syslog_un(TALLOC_CTX *mem_ctx,
 		talloc_free(state);
 		return save_errno;
 	}
-	set_blocking(state->fd, false);
+
+	ret = set_blocking(state->fd, false);
+	if (ret != 0) {
+		int save_errno = errno;
+		talloc_free(state);
+		return save_errno;
+	}
 
 	state->hostname = NULL; /* Make this explicit */
 	state->format = format_rfc3164;
diff --git a/ctdb/server/ctdb_ltdb_server.c b/ctdb/server/ctdb_ltdb_server.c
index 6b391b0..8feaff1 100644
--- a/ctdb/server/ctdb_ltdb_server.c
+++ b/ctdb/server/ctdb_ltdb_server.c
@@ -630,7 +630,7 @@ int ctdb_recheck_persistent_health(struct ctdb_context *ctdb)
 				   ctdb_db->db_path,
 				   ctdb_db->unhealthy_reason));
 	}
-	DEBUG((fail!=0)?DEBUG_ALERT:DEBUG_NOTICE,
+	DEBUG(DEBUG_NOTICE,
 	      ("ctdb_recheck_persistent_health: OK[%d] FAIL[%d]\n",
 	       ok, fail));
 
diff --git a/ctdb/server/ctdb_monitor.c b/ctdb/server/ctdb_monitor.c
index 87a38c7..00f6524 100644
--- a/ctdb/server/ctdb_monitor.c
+++ b/ctdb/server/ctdb_monitor.c
@@ -354,7 +354,7 @@ static void ctdb_wait_until_recovered(struct tevent_context *ev,
 	if (ret != 0) {
 		ctdb->db_persistent_check_errors++;
 		if (ctdb->db_persistent_check_errors < ctdb->max_persistent_check_errors) {
-			DEBUG(ctdb->db_persistent_check_errors==1?DEBUG_ERR:DEBUG_WARNING,
+			DEBUG(DEBUG_ERR,
 			      (__location__ "ctdb_recheck_persistent_health() "
 			      "failed (%llu of %llu times) - retry later\n",
 			      (unsigned long long)ctdb->db_persistent_check_errors,
diff --git a/ctdb/server/ctdb_recoverd.c b/ctdb/server/ctdb_recoverd.c
index d233817..ba4d8a2 100644
--- a/ctdb/server/ctdb_recoverd.c
+++ b/ctdb/server/ctdb_recoverd.c
@@ -2360,16 +2360,9 @@ static int verify_local_ip_allocation(struct ctdb_context *ctdb,
 		} else {
 			if (ctdb_sys_have_ip(&ips->ips[j].addr)) {
 				DEBUG(DEBUG_ERR,
-				      ("IP %s incorrectly on an interface - releasing\n",
+				      ("IP %s incorrectly on an interface\n",
 				       ctdb_addr_to_str(&ips->ips[j].addr)));
-				ret = ctdb_ctrl_release_ip(ctdb,
-							   CONTROL_TIMEOUT(),
-							   CTDB_CURRENT_NODE,
-							   &ips->ips[j]);
-				if (ret != 0) {
-					DEBUG(DEBUG_ERR,
-					      ("Failed to release IP address\n"));
-				}
+				need_takeover_run = true;
 			}
 		}
 	}
diff --git a/ctdb/server/ctdb_takeover.c b/ctdb/server/ctdb_takeover.c
index 6d182de..a02076d 100644
--- a/ctdb/server/ctdb_takeover.c
+++ b/ctdb/server/ctdb_takeover.c
@@ -88,13 +88,14 @@ struct ctdb_vnn {
 	bool delete_pending;
 };
 
-static const char *ctdb_vnn_iface_string(const struct ctdb_vnn *vnn)
+static const char *iface_string(const struct ctdb_interface *iface)
 {
-	if (vnn->iface) {
-		return vnn->iface->name;
-	}
+	return (iface != NULL ? iface->name : "__none__");
+}
 
-	return "__none__";
+static const char *ctdb_vnn_iface_string(const struct ctdb_vnn *vnn)
+{
+	return iface_string(vnn->iface);
 }
 
 static int ctdb_add_local_iface(struct ctdb_context *ctdb, const char *iface)
@@ -580,10 +581,11 @@ static void ctdb_do_updateip_callback(struct ctdb_context *ctdb, int status,
 		if (status == -ETIME) {
 			ctdb_ban_self(ctdb);
 		}
-		DEBUG(DEBUG_ERR,(__location__ " Failed to move IP %s from interface %s to %s\n",
-			ctdb_addr_to_str(&state->vnn->public_address),
-			state->old->name,
-			ctdb_vnn_iface_string(state->vnn)));
+		DEBUG(DEBUG_ERR,
+		      ("Failed update of IP %s from interface %s to %s\n",
+		       ctdb_addr_to_str(&state->vnn->public_address),
+		       iface_string(state->old),
+		       ctdb_vnn_iface_string(state->vnn)));
 
 		/*
 		 * All we can do is reset the old interface
@@ -631,6 +633,7 @@ static int32_t ctdb_do_updateip(struct ctdb_context *ctdb,
 	int ret;
 	struct ctdb_do_updateip_state *state;
 	struct ctdb_interface *old = vnn->iface;
+	const char *old_name = iface_string(old);
 	const char *new_name;
 
 	if (vnn->update_in_flight) {
@@ -644,16 +647,17 @@ static int32_t ctdb_do_updateip(struct ctdb_context *ctdb,
 	ctdb_vnn_unassign_iface(ctdb, vnn);
 	ret = ctdb_vnn_assign_iface(ctdb, vnn);
 	if (ret != 0) {
-		DEBUG(DEBUG_ERR,("update of IP %s/%u failed to "
-				 "assin a usable interface (old iface '%s')\n",
+		DEBUG(DEBUG_ERR,("Update of IP %s/%u failed to "
+				 "assign a usable interface (old iface '%s')\n",
 				 ctdb_addr_to_str(&vnn->public_address),
 				 vnn->public_netmask_bits,
-				 old->name));
+				 old_name));
 		return -1;
 	}


-- 
Samba Shared Repository



More information about the samba-cvs mailing list