[SCM] Samba Shared Repository - branch master updated

Martin Schwenke martins at samba.org
Mon Jul 2 09:31:02 UTC 2018


The branch, master has been updated
       via  0b4a071 ctdb-tests: Teach strace packet parser about non-octal escapes
       via  63255ef ctdb-daemon: Only consider client ID for local database attach
       via  af446d5 ctdb-docs: Fix the documentation for VNN map
       via  36938bf ctdb-server: Rename CTDB_BROADCAST_VNNMAP -> CTDB_BROADCAST_ACTIVE
       via  ec72fad ctdb-tests: Add a simple test for database traverses
       via  4b00855 ctdb-tests: Add check for non-lmaster node status in integration tests
       via  77db0b1 ctdb-client: Fix typo where CTDB_BROADCAST_ALL is repeated
       via  b318cf2 ctdb-recoverd: Set the process name correctly
       via  cd9930e ctdb-scripts: Drop 99.timeout event script
       via  ff181a8 ctdb-tests: Switch 90_debug_hung_script.sh to be a simple test
       via  dfd39c9 ctdb-tests: Enable event script debugging in local daemon tests
       via  9f09579 ctdb-tests: Support CTDB_RUN_TIMEOUT_MONITOR=yes in simple tests
       via  9e1cbd9 ctdb-tests: Clean up startup event in 00.test event script
       via  673b0e7 ctdb-tests: Add generic logging of event details in 00.test event script
       via  8888711 ctdb-tests: Drop unnecessary code in 00.test event script
       via  acd10a5 ctdb-tests: Clean up argument validation in 00.test event script
       via  23adbaa ctdb-tests: Drop check for invalid event in 00.test event script
       via  edffe4d tdb: Fix build on AIX
       via  40a8ab1 ctdb: Fix build on AIX
       via  05a908d ctdb-tests: Switch fake_ctdbd to use ctdb_get_peer_pid()
       via  fa94a49 ctdb-common: Move capture_socket functions to ctdb_socket.[ch]
       via  eafcc98 ctdb-common: Move ctdb_sys_send_tcp() to ctdb_socket.[ch]
       via  9c51b27 ctdb-common: Move ctdb_sys_send_arp() to ctdb_socket.[ch]
       via  1d7d804 ctdb-common: Move ctdb_get_peer_pid() to system.[ch]
       via  8fcd12b ctdb-common: Move ctdb_system_check_iface_exists() to system.[ch]
       via  2f0a4d2 ctdb-common: Move parse_ip_mask() to system_socket.[ch]
       via  57834c6 ctdb-common: Rename system utility files
       via  f697c2e ctdb-build: Add ipv6 headers check for packet details
       via  14868df ctdb-build: Add checks for raw pkt handling support
       via  79992db ctdb-common: Use sin6_len only if the structure supports it
       via  7eeba9c replace: Add test for sin6_len in sockaddr_in6 structure
      from  e84b502 ctdb-common: Correctly handle conf->reload()

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


- Log -----------------------------------------------------------------
commit 0b4a071ed1817bbc5523b259ca41c62a9e9b1f0b
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Jun 26 19:51:00 2018 +1000

    ctdb-tests: Teach strace packet parser about non-octal escapes
    
    strace output also encodes characters 7 to 13 as \a, \b, \t, \n, \v,
    \f, \r.
    
    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): Mon Jul  2 11:30:29 CEST 2018 on sn-devel-144

commit 63255ef92552da92956c05160f33622d0bbc3a28
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Jun 26 20:12:23 2018 +1000

    ctdb-daemon: Only consider client ID for local database attach
    
    The comment immediately above this code says "don't allow local
    clients to attach" and then looks up the client ID regardless of
    whether the request is local or remote.
    
    This means that an intentional remote attach from a client will not
    work correctly.  No real client should ever do that since clients
    attach so they an access databases locally.  Perhaps some sanity
    checks should be added.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13500
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit af446d5209e37a38363911e5f339869b73d87963
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Jun 15 06:07:54 2018 +1000

    ctdb-docs: Fix the documentation for VNN map
    
    It is incorrectly says that nodes not in the VNN map can not be
    DMASTER.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13499
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 36938bfdd075a174daecb466085702adfe6a6c09
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Jun 15 06:01:52 2018 +1000

    ctdb-server: Rename CTDB_BROADCAST_VNNMAP -> CTDB_BROADCAST_ACTIVE
    
    This broadcast is misnamed.  Both places where this type of broadcast
    is used expect the broadcast to go to all active nodes.
    
    Make the corresponding change to the semantics in the daemon by
    sending to all active nodes.
    
    There is a mismatch between the ideas of VNN map and active nodes.  A
    node that is not in the VNN map but is active can still host database
    records.  These were the same until the LMASTER capability was
    introduced and then the logic was not updated.
    
    The only place where the VNN map is relevant is when finding the
    location master of a record in the migration code.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13499
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit ec72fadecd5233234947633360fe46a3a4053c07
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Jun 15 05:51:45 2018 +1000

    ctdb-tests: Add a simple test for database traverses
    
    This tests that volatile databases traverse correctly, including the
    case where a record was updated on a non-lmaster node.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13499
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 4b008556d6b1f07fd5057af845526bf941497f18
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Jun 15 05:51:17 2018 +1000

    ctdb-tests: Add check for non-lmaster node status in integration tests
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13499
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 77db0b15b56f9921961bd753c210e6fdbaf97f6d
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Jun 14 16:17:09 2018 +1000

    ctdb-client: Fix typo where CTDB_BROADCAST_ALL is repeated
    
    Surely this is meant to be CTDB_BROADCAST_CONNECTED?
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13499
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit b318cf22bad5ca2da54518e989b49b8e92f74646
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Jun 19 16:50:41 2018 +1000

    ctdb-recoverd: Set the process name correctly
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit cd9930ea1d1cabbfa1a97c484c13b6773560dbbe
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Jun 12 05:30:46 2018 +1000

    ctdb-scripts: Drop 99.timeout event script
    
    This is now implemented in local daemon testing.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit ff181a82f2b5907b6d98768f72ff2769c358c2c3
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Jun 12 04:44:54 2018 +1000

    ctdb-tests: Switch 90_debug_hung_script.sh to be a simple test
    
    This test only runs against local daemons.  Configuration is done via
    script.options, which simplifies things quite a bit.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit dfd39c9cd71648126f66be3c3b66c9589c3021b3
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Jun 12 04:48:45 2018 +1000

    ctdb-tests: Enable event script debugging in local daemon tests
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 9f09579a5cddec2b678c8b1520d7ce7136b305ab
Author: Martin Schwenke <martin at meltin.net>
Date:   Sun Jun 10 13:42:33 2018 +1000

    ctdb-tests: Support CTDB_RUN_TIMEOUT_MONITOR=yes in simple tests
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 9e1cbd922e10622511aec430a97d923f444aee58
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Jun 12 06:48:37 2018 +1000

    ctdb-tests: Clean up startup event in 00.test event script
    
    Rewrite interface initialisation to avoid an error when there are no
    interfaces configured.  Re-indent case label.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 673b0e78e1c13bbf78a6a78698de1ca7a450c023
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Jun 12 06:12:25 2018 +1000

    ctdb-tests: Add generic logging of event details in 00.test event script
    
    No need for a separate case for each event just to log details.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 8888711e5749b2d949b819cc8142951c475adc51
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Jun 12 06:07:07 2018 +1000

    ctdb-tests: Drop unnecessary code in 00.test event script
    
    This script is only used with local daemons.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit acd10a5d47bd3aae18bbe60c44481c7d2e264813
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Jun 12 05:54:07 2018 +1000

    ctdb-tests: Clean up argument validation in 00.test event script
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 23adbaad998eef1d5dd327b77f83de290e18bb20
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Jun 12 06:15:40 2018 +1000

    ctdb-tests: Drop check for invalid event in 00.test event script
    
    This isn't necessary and complicates the code.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit edffe4d16514fa0c87655e040842f6c20d89791c
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Jun 29 16:12:30 2018 +1000

    tdb: Fix build on AIX
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13493
    
    Here is the build error on AIX 7.1.
    
    ../../lib/tdb/tools/tdbtool.c:39:12: error: 'disable_lock' redeclared as different kind of symbol
     static int disable_lock;
                ^~~~~~~~~~~~
    In file included from /usr/include/sys/gfs.h:24:0,
                     from /usr/include/sys/vfs.h:27,
                     from ../../lib/replace/system/filesys.h:48,
                     from ../../lib/tdb/tools/tdbtool.c:26:
    /usr/include/sys/lock_def.h:314:5: note: previous declaration of 'disable_lock' was here
     int disable_lock(int,simple_lock_t);
         ^~~~~~~~~~~~
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 40a8ab1ce0c1b291af7263da13c25c37cee69670
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Jun 29 15:55:49 2018 +1000

    ctdb: Fix build on AIX
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13493
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 05a908d71c4b7484ba0243fa51bc05c79c8fb357
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Jun 8 22:31:48 2018 +1000

    ctdb-tests: Switch fake_ctdbd to use ctdb_get_peer_pid()
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit fa94a49dbbec4a65c368a533a534f952a9f147a7
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Jun 28 21:12:04 2018 +1000

    ctdb-common: Move capture_socket functions to ctdb_socket.[ch]
    
    The system_<os>.c files contain a lot of duplication, making
    maintenance difficult.  These functions are being merged into
    system_socket.c and system.c.
    
    Bring across ctdb_sys_open_capture_socket(),
    ctdb_sys_close_capture_socket() and ctdb_sys_read_tcp_packet().
    
    Remove empty system_<os>.c files.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit eafcc98b03f59e242d0bb004f765005a35190b6d
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Jun 28 21:06:58 2018 +1000

    ctdb-common: Move ctdb_sys_send_tcp() to ctdb_socket.[ch]
    
    The system_<os>.c files contain a lot of duplication, making
    maintenance difficult.  These functions are being merged into
    system_socket.c and system.c.
    
    Bring across tcp_checksum(), renamed to ip_checksum().
    uint16_checksum() becomes static.
    
    Use the BSD struct tcphdr field names for portability.  See the
    comment in the code for more details about how we get this to compile
    on older glibc versions.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 9c51b278b1700cd5f3e2addc19b7c711cc2ea10b
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Jun 28 20:57:08 2018 +1000

    ctdb-common: Move ctdb_sys_send_arp() to ctdb_socket.[ch]
    
    The system_<os>.c files contain a lot of duplication, making
    maintenance difficult.  These functions are being merged into
    system_socket.c and system.c.
    
    Bring a copy of tcp_checksum6(), renamed to ip6_checksum().
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 1d7d80451bc4fea12d313b911924ae89901d99a7
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Jun 28 20:35:56 2018 +1000

    ctdb-common: Move ctdb_get_peer_pid() to system.[ch]
    
    The system_<os>.c files contain a lot of duplication, making
    maintenance difficult.  These functions are being merged into
    system_socket.c and system.c.
    
    This function doesn't need ctdb_sock_addr so put it with general
    system utilities.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 8fcd12ba29cd1d23e0283cad187ae8d35c8c6fcc
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Jun 28 20:30:32 2018 +1000

    ctdb-common: Move ctdb_system_check_iface_exists() to system.[ch]
    
    The system_<os>.c files contain a lot of duplication, making
    maintenance difficult.  These functions are being merged into
    system_socket.[ch] and system.[ch].
    
    This function doesn't need ctdb_sock_addr so put it with general
    system utilities.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 2f0a4d20954bdcd5a6e8ea5c11224f5a2d4fe3d9
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Jun 28 20:24:10 2018 +1000

    ctdb-common: Move parse_ip_mask() to system_socket.[ch]
    
    This uses ctdb_sock_addr so belongs here.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 57834c64bef96d67dabe1ce22ced67e6544b8035
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Jun 28 20:15:37 2018 +1000

    ctdb-common: Rename system utility files
    
    system_socket.[ch] will contain all the raw socket code and other
    functions that use ctdb_sock_addr.  system.[ch] will contain other
    platform dependent functions.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit f697c2e1c6aa481b3619f4c3dfefcc850af69eb4
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Jun 29 14:54:17 2018 +1000

    ctdb-build: Add ipv6 headers check for packet details
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 14868df9e5669eba3918f3bc27b73c8adcae432b
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Jun 29 13:17:01 2018 +1000

    ctdb-build: Add checks for raw pkt handling support
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 79992dbb73ac9749ac987cb6a88964fa600b4c35
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed Jun 27 13:41:38 2018 +1000

    ctdb-common: Use sin6_len only if the structure supports it
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13493
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

commit 7eeba9c5a4541e581b062fb9ee26f13b7373c541
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed Jun 27 13:41:10 2018 +1000

    replace: Add test for sin6_len in sockaddr_in6 structure
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13493
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>

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

Summary of changes:
 ctdb/client/client_tunnel.c                        |   4 +-
 ctdb/common/ctdb_util.c                            |   4 +-
 ctdb/common/{system_util.c => system.c}            | 215 ++---
 ctdb/common/system.h                               |  26 +-
 ctdb/common/system_aix.c                           | 398 ---------
 ctdb/common/system_common.c                        |  82 --
 ctdb/common/system_freebsd.c                       | 396 ---------
 ctdb/common/system_gnu.c                           | 391 ---------
 ctdb/common/system_kfreebsd.c                      | 391 ---------
 ctdb/common/system_linux.c                         | 639 --------------
 ctdb/common/system_socket.c                        | 974 +++++++++++++++++++++
 ctdb/common/{system.h => system_socket.h}          |  56 +-
 ctdb/config/events/legacy/99.timeout.script        |  25 -
 ctdb/doc/ctdb.1.xml                                |   7 +-
 ctdb/include/ctdb_private.h                        |   7 +-
 ctdb/protocol/protocol.h                           |   2 +-
 ctdb/protocol/protocol_debug.c                     |   4 +-
 ctdb/protocol/protocol_util.c                      |   2 +-
 ctdb/server/ctdb_cluster_mutex.c                   |   4 +-
 ctdb/server/ctdb_control.c                         |  36 +-
 ctdb/server/ctdb_ltdb_server.c                     |  21 +-
 ctdb/server/ctdb_recoverd.c                        |   4 +-
 ctdb/server/ctdb_server.c                          |  16 +-
 ctdb/server/ctdb_takeover.c                        |   1 +
 ctdb/server/ctdb_traverse.c                        |   4 +-
 ctdb/server/ipalloc.c                              |   4 +-
 ctdb/tests/cunit/porting_tests_001.sh              |   9 +-
 ctdb/tests/scripts/integration.bash                |   1 +
 ctdb/tests/simple/79_volatile_db_traverse.sh       |  94 ++
 .../{complex => simple}/90_debug_hung_script.sh    |  55 +-
 .../simple/etc-ctdb/events/legacy/00.test.script   | 109 +--
 ctdb/tests/simple/scripts/local_daemons.bash       |   5 +-
 ctdb/tests/src/ctdb_packet_parse.c                 |  52 +-
 ctdb/tests/src/ctdb_takeover_tests.c               |   6 +-
 ctdb/tests/src/fake_ctdbd.c                        |  10 +-
 ctdb/tests/src/ipalloc_read_known_ips.c            |   4 +-
 ctdb/tools/ctdb.c                                  |   2 +-
 ctdb/tools/ctdb_killtcp.c                          |   8 +-
 ctdb/wscript                                       |  32 +-
 lib/replace/wscript                                |   4 +
 lib/tdb/tools/tdbtool.c                            |   8 +-
 41 files changed, 1378 insertions(+), 2734 deletions(-)
 rename ctdb/common/{system_util.c => system.c} (57%)
 delete mode 100644 ctdb/common/system_aix.c
 delete mode 100644 ctdb/common/system_common.c
 delete mode 100644 ctdb/common/system_freebsd.c
 delete mode 100644 ctdb/common/system_gnu.c
 delete mode 100644 ctdb/common/system_kfreebsd.c
 delete mode 100644 ctdb/common/system_linux.c
 create mode 100644 ctdb/common/system_socket.c
 copy ctdb/common/{system.h => system_socket.h} (52%)
 delete mode 100755 ctdb/config/events/legacy/99.timeout.script
 create mode 100755 ctdb/tests/simple/79_volatile_db_traverse.sh
 rename ctdb/tests/{complex => simple}/90_debug_hung_script.sh (52%)


Changeset truncated at 500 lines:

diff --git a/ctdb/client/client_tunnel.c b/ctdb/client/client_tunnel.c
index 0bd7a3a..a783afe 100644
--- a/ctdb/client/client_tunnel.c
+++ b/ctdb/client/client_tunnel.c
@@ -431,8 +431,8 @@ struct tevent_req *ctdb_tunnel_request_send(TALLOC_CTX *mem_ctx,
 	};
 
 	if (destnode == CTDB_BROADCAST_ALL ||
-	    destnode == CTDB_BROADCAST_VNNMAP ||
-	    destnode == CTDB_BROADCAST_ALL) {
+	    destnode == CTDB_BROADCAST_ACTIVE ||
+	    destnode == CTDB_BROADCAST_CONNECTED) {
 		state->wait_for_reply = false;
 	}
 	if (! state->wait_for_reply) {
diff --git a/ctdb/common/ctdb_util.c b/ctdb/common/ctdb_util.c
index cbab367..0f367c2 100644
--- a/ctdb/common/ctdb_util.c
+++ b/ctdb/common/ctdb_util.c
@@ -359,8 +359,8 @@ void ctdb_canonicalize_ip(const ctdb_sock_addr *ip, ctdb_sock_addr *cip)
 			       sizeof(cip->ip.sin_addr));
 		} else {
 			cip->ip6.sin6_family = AF_INET6;
-#ifdef HAVE_SOCK_SIN_LEN
-			cip->ip6.sin_len = sizeof(ctdb_sock_addr);
+#ifdef HAVE_SOCK_SIN6_LEN
+			cip->ip6.sin6_len = sizeof(ctdb_sock_addr);
 #endif
 			cip->ip6.sin6_port   = ip->ip6.sin6_port;
 			memcpy(&cip->ip6.sin6_addr,
diff --git a/ctdb/common/system_util.c b/ctdb/common/system.c
similarity index 57%
rename from ctdb/common/system_util.c
rename to ctdb/common/system.c
index f27eed7..a95f314 100644
--- a/ctdb/common/system_util.c
+++ b/ctdb/common/system.c
@@ -116,137 +116,6 @@ void reset_scheduler(void)
 #endif
 }
 
-static bool parse_ipv4(const char *s, unsigned port, struct sockaddr_in *sin)
-{
-	sin->sin_family = AF_INET;
-	sin->sin_port   = htons(port);
-
-	if (inet_pton(AF_INET, s, &sin->sin_addr) != 1) {
-		DEBUG(DEBUG_ERR, (__location__ " Failed to translate %s into sin_addr\n", s));
-		return false;
-	}
-
-#ifdef HAVE_SOCK_SIN_LEN
-	sin->sin_len = sizeof(*sin);
-#endif
-	return true;
-}
-
-static bool parse_ipv6(const char *s, const char *ifaces, unsigned port, ctdb_sock_addr *saddr)
-{
-	saddr->ip6.sin6_family   = AF_INET6;
-	saddr->ip6.sin6_port     = htons(port);
-	saddr->ip6.sin6_flowinfo = 0;
-	saddr->ip6.sin6_scope_id = 0;
-
-	if (inet_pton(AF_INET6, s, &saddr->ip6.sin6_addr) != 1) {
-		DEBUG(DEBUG_ERR, (__location__ " Failed to translate %s into sin6_addr\n", s));
-		return false;
-	}
-
-	if (ifaces && IN6_IS_ADDR_LINKLOCAL(&saddr->ip6.sin6_addr)) {
-		if (strchr(ifaces, ',')) {
-			DEBUG(DEBUG_ERR, (__location__ " Link local address %s "
-					  "is specified for multiple ifaces %s\n",
-					  s, ifaces));
-			return false;
-		}
-		saddr->ip6.sin6_scope_id = if_nametoindex(ifaces);
-	}
-
-#ifdef HAVE_SOCK_SIN_LEN
-	saddr->ip6.sin6_len = sizeof(*saddr);
-#endif
-	return true;
-}
-
-/*
-  parse an ip
- */
-static bool parse_ip(const char *addr, const char *ifaces, unsigned port,
-		     ctdb_sock_addr *saddr)
-{
-	char *p;
-	bool ret;
-
-	ZERO_STRUCTP(saddr); /* valgrind :-) */
-
-	/* IPv4 or IPv6 address?
-	 *
-	 * Use rindex() because we need the right-most ':' below for
-	 * IPv4-mapped IPv6 addresses anyway...
-	 */
-	p = rindex(addr, ':');
-	if (p == NULL) {
-		ret = parse_ipv4(addr, port, &saddr->ip);
-	} else {
-		uint8_t ipv4_mapped_prefix[12] = {
-			0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff
-		};
-
-		ret = parse_ipv6(addr, ifaces, port, saddr);
-		if (! ret) {
-			return ret;
-		}
-
-		/*
-		 * Check for IPv4-mapped IPv6 address
-		 * (e.g. ::ffff:192.0.2.128) - reparse as IPv4 if
-		 * necessary
-		 */
-		if (memcmp(&saddr->ip6.sin6_addr.s6_addr[0],
-			   ipv4_mapped_prefix,
-			   sizeof(ipv4_mapped_prefix)) == 0) {
-			/* Reparse as IPv4 */
-			ret = parse_ipv4(p+1, port, &saddr->ip);
-		}
-	}
-
-	return ret;
-}
-
-/*
-  parse a ip/mask pair
- */
-bool parse_ip_mask(const char *str, const char *ifaces, ctdb_sock_addr *addr, unsigned *mask)
-{
-	char *p;
-	char s[64]; /* Much longer than INET6_ADDRSTRLEN */
-	char *endp = NULL;
-	ssize_t len;
-	bool ret;
-
-	ZERO_STRUCT(*addr);
-
-	len = strlen(str);
-	if (len >= sizeof(s)) {
-		DEBUG(DEBUG_ERR, ("Address %s is unreasonably long\n", str));
-		return false;
-	}
-
-	strncpy(s, str, len+1);
-
-	p = rindex(s, '/');
-	if (p == NULL) {
-		DEBUG(DEBUG_ERR, (__location__ " This addr: %s does not contain a mask\n", s));
-		return false;
-	}
-
-	*mask = strtoul(p+1, &endp, 10);
-	if (endp == NULL || *endp != 0) {
-		/* trailing garbage */
-		DEBUG(DEBUG_ERR, (__location__ " Trailing garbage after the mask in %s\n", s));
-		return false;
-	}
-	*p = 0;
-
-
-	/* now is this a ipv4 or ipv6 address ?*/
-	ret = parse_ip(s, ifaces, 0, addr);
-
-	return ret;
-}
-
 /* we don't lock future pages here; it would increase the chance that
  * we'd fail to mmap later on. */
 void lockdown_memory(bool valgrinding)
@@ -294,3 +163,87 @@ void ctdb_wait_for_process_to_exit(pid_t pid)
 		sleep(5);
 	}
 }
+
+#ifdef HAVE_AF_PACKET
+
+bool ctdb_sys_check_iface_exists(const char *iface)
+{
+	int s;
+	struct ifreq ifr;
+
+	s = socket(AF_PACKET, SOCK_RAW, 0);
+	if (s == -1){
+		/* We don't know if the interface exists, so assume yes */
+		DBG_ERR("Failed to open raw socket\n");
+		return true;
+	}
+
+	strlcpy(ifr.ifr_name, iface, sizeof(ifr.ifr_name));
+	if (ioctl(s, SIOCGIFINDEX, &ifr) < 0 && errno == ENODEV) {
+		DBG_ERR("Interface '%s' not found\n", iface);
+		close(s);
+		return false;
+	}
+	close(s);
+
+	return true;
+}
+
+#else /* HAVE_AF_PACKET */
+
+bool ctdb_sys_check_iface_exists(const char *iface)
+{
+	/* Not implemented: Interface always considered present */
+	return true;
+}
+
+#endif /* HAVE_AF_PACKET */
+
+#ifdef HAVE_PEERCRED
+
+int ctdb_get_peer_pid(const int fd, pid_t *peer_pid)
+{
+	struct ucred cr;
+	socklen_t crl = sizeof(struct ucred);
+	int ret;
+
+	ret = getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &cr, &crl);
+	if (ret == 0) {
+		*peer_pid = cr.pid;
+	} else {
+		*peer_pid = -1;
+	}
+	return ret;
+}
+
+#else /* HAVE_PEERCRED */
+
+#ifdef _AIX_
+
+int ctdb_get_peer_pid(const int fd, pid_t *peer_pid)
+{
+	struct peercred_struct cr;
+	socklen_t crl = sizeof(struct peercred_struct);
+	int ret;
+
+	ret = getsockopt(fd, SOL_SOCKET, SO_PEERID, &cr, &crl);
+	if (ret == 0) {
+		*peer_pid = cr.pid;
+	} else {
+		*peer_pid = -1;
+	}
+	return ret;
+}
+
+#else /* _AIX_ */
+
+int ctdb_get_peer_pid(const int fd, pid_t *peer_pid)
+{
+	/* Not implemented */
+	*peer_pid = -1;
+	return ENOSYS;
+}
+
+#endif /* _AIX_ */
+
+#endif /* HAVE_PEERCRED */
diff --git a/ctdb/common/system.h b/ctdb/common/system.h
index 5865a1a..8d558e2 100644
--- a/ctdb/common/system.h
+++ b/ctdb/common/system.h
@@ -22,38 +22,18 @@
 
 #include <talloc.h>
 
-/* From system_common.c */
-
-uint32_t uint16_checksum(uint16_t *data, size_t n);
-bool ctdb_sys_have_ip(ctdb_sock_addr *_addr);
-
-/* From system_<os>.c */
-
-int ctdb_sys_send_arp(const ctdb_sock_addr *addr, const char *iface);
-int ctdb_sys_send_tcp(const ctdb_sock_addr *dest,
-		      const ctdb_sock_addr *src,
-		      uint32_t seq, uint32_t ack, int rst);
-int ctdb_sys_open_capture_socket(const char *iface, void **private_data);
-int ctdb_sys_close_capture_socket(void *private_data);
-int ctdb_sys_read_tcp_packet(int s, void *private_data,
-			     ctdb_sock_addr *src, ctdb_sock_addr *dst,
-			     uint32_t *ack_seq, uint32_t *seq,
-			     int *rst, uint16_t *window);
-bool ctdb_sys_check_iface_exists(const char *iface);
-int ctdb_get_peer_pid(const int fd, pid_t *peer_pid);
-
 /* From system_util.c */
 
 bool set_scheduler(void);
 void reset_scheduler(void);
 
-bool parse_ip_mask(const char *str, const char *ifaces, ctdb_sock_addr *addr,
-		   unsigned *mask);
-
 void lockdown_memory(bool valgrinding);
 
 void mkdir_p_or_die(const char *dir, int mode);
 
 void ctdb_wait_for_process_to_exit(pid_t pid);
 
+bool ctdb_sys_check_iface_exists(const char *iface);
+int ctdb_get_peer_pid(const int fd, pid_t *peer_pid);
+
 #endif /* __CTDB_SYSTEM_H__ */
diff --git a/ctdb/common/system_aix.c b/ctdb/common/system_aix.c
deleted file mode 100644
index f0a0a62..0000000
--- a/ctdb/common/system_aix.c
+++ /dev/null
@@ -1,398 +0,0 @@
-/* 
-   ctdb system specific code to manage raw sockets on aix
-
-   Copyright (C) Ronnie Sahlberg  2007
-   Copyright (C) Andrew Tridgell  2007
-
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-   
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-   
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, see <http://www.gnu.org/licenses/>.
-*/
-
-
-#include "replace.h"
-#include "system/network.h"
-#include "system/filesys.h"
-#include "system/wait.h"
-
-#include "lib/util/debug.h"
-#include "lib/util/blocking.h"
-
-#include "protocol/protocol.h"
-
-#include <netinet/if_ether.h>
-#include <netinet/ip6.h>
-#include <net/if_arp.h>
-#include <sys/ndd_var.h>
-#include <sys/kinfo.h>
-#include <pcap.h>
-
-#include "common/logging.h"
-#include "common/system.h"
-
-
-#if 0
-This function is no longer used and its code should be moved into
-send tcp packet   after that function has been enhanced to do ipv6 as well.
-
-/* This function is used to open a raw socket to send tickles from
- */
-int ctdb_sys_open_sending_socket(void)
-{
-	int s, ret;
-	uint32_t one = 1;
-
-	s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
-	if (s == -1) {
-		DEBUG(DEBUG_CRIT,(" failed to open raw socket (%s)\n",
-			 strerror(errno)));
-		return -1;
-	}
-
-	ret = setsockopt(s, IPPROTO_IP, IP_HDRINCL, &one, sizeof(one));
-	if (ret != 0) {
-		DEBUG(DEBUG_CRIT, (" failed to setup IP headers (%s)\n",
-			 strerror(errno)));
-		close(s);
-		return -1;
-	}
-
-	set_blocking(s, false);
-	set_close_on_exec(s);
-
-	return s;
-}
-#endif
-
-/*
-  simple TCP checksum - assumes data is multiple of 2 bytes long
- */
-static uint16_t tcp_checksum(uint16_t *data, size_t n, struct ip *ip)
-{
-	uint32_t sum = uint16_checksum(data, n);
-	uint16_t sum2;
-
-	sum += uint16_checksum((uint16_t *)&ip->ip_src, sizeof(ip->ip_src));
-	sum += uint16_checksum((uint16_t *)&ip->ip_dst, sizeof(ip->ip_dst));
-	sum += ip->ip_p + n;
-	sum = (sum & 0xFFFF) + (sum >> 16);
-	sum = (sum & 0xFFFF) + (sum >> 16);
-	sum2 = htons(sum);
-	sum2 = ~sum2;
-	if (sum2 == 0) {
-		return 0xFFFF;
-	}
-	return sum2;
-}
-
-/*
-  Send tcp segment from the specified IP/port to the specified
-  destination IP/port. 
-
-  This is used to trigger the receiving host into sending its own ACK,
-  which should trigger early detection of TCP reset by the client
-  after IP takeover
-
-  This can also be used to send RST segments (if rst is true) and also
-  if correct seq and ack numbers are provided.
- */
-int ctdb_sys_send_tcp(const ctdb_sock_addr *dest,
-		      const ctdb_sock_addr *src,
-		      uint32_t seq, uint32_t ack, int rst)
-{
-	int s;
-  	int ret;
-	uint32_t one = 1;
-	ctdb_sock_addr *tmpdest;
-	
-	struct {
-		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) {
-		DEBUG(DEBUG_CRIT,(__location__ " not an ipv4 address\n"));
-		return -1;
-	}
-
-
-
-	s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
-	if (s == -1) {
-		DEBUG(DEBUG_CRIT,(" failed to open raw socket (%s)\n",
-			 strerror(errno)));
-		return -1;
-	}
-
-	ret = setsockopt(s, IPPROTO_IP, IP_HDRINCL, &one, sizeof(one));
-	if (ret != 0) {
-		DEBUG(DEBUG_CRIT, (" failed to setup IP headers (%s)\n",
-			 strerror(errno)));
-		close(s);
-		return -1;
-	}
-
-	memset(&ip4pkt, 0, sizeof(ip4pkt));
-	ip4pkt.ip.ip_v     = 4;
-	ip4pkt.ip.ip_hl    = sizeof(ip4pkt.ip)/4;
-	ip4pkt.ip.ip_len   = htons(sizeof(ip4pkt));
-	ip4pkt.ip.ip_ttl   = 255;
-	ip4pkt.ip.ip_p     = IPPROTO_TCP;
-	ip4pkt.ip.ip_src.s_addr   = src->ip.sin_addr.s_addr;
-	ip4pkt.ip.ip_dst.s_addr   = dest->ip.sin_addr.s_addr;
-	ip4pkt.ip.ip_sum   = 0;
-
-	ip4pkt.tcp.th_sport   = src->ip.sin_port;
-	ip4pkt.tcp.th_dport     = dest->ip.sin_port;
-	ip4pkt.tcp.th_seq      = seq;
-	ip4pkt.tcp.th_ack    = ack;
-	ip4pkt.tcp.th_flags  = TH_ACK;
-	if (rst) {
-		ip4pkt.tcp.th_flags      = TH_RST;
-	}
-	ip4pkt.tcp.th_off    = sizeof(ip4pkt.tcp)/4;
-	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));
-	saved_errno = errno;
-	close(s);
-	if (ret != sizeof(ip4pkt)) {
-		DEBUG(DEBUG_ERR,
-		      ("Failed sendto (%s)\n", strerror(saved_errno)));
-		return -1;
-	}
-
-	return 0;
-}
-
-/* This function is used to open a raw socket to capture from
- */
-int ctdb_sys_open_capture_socket(const char *iface, void **private_data)
-{
-	pcap_t *pt;


-- 
Samba Shared Repository



More information about the samba-cvs mailing list