[SCM] Samba Shared Repository - branch v4-17-test updated

Jule Anger janger at samba.org
Tue Aug 29 10:30:02 UTC 2023


The branch, v4-17-test has been updated
       via  8d1e4f1d4f1 ctdb-common: Set immediate mode for pcap capture
       via  bb905f04b50 ctdb-common: Replace pcap_open_live() by lower level calls
       via  74d43dd395b ctdb-common: Improve error handling
       via  ef212b021e5 ctdb-scripts: Add debugging variable CTDB_KILLTCP_DEBUGLEVEL
       via  c5bd0b20ad3 ctdb-common: Support IB in pcap-based capture
       via  6417651bf4b ctdb-common: Support "any" interface for pcap-based capture
       via  0f3864d7c59 ctdb-common: Add packet type detection to pcap-based capture
       via  f01d53d8848 ctdb-tools: Improve/add debug
       via  d37c3d14156 ctdb-common: Improve/add debug
       via  0adfd0cc0f6 ctdb-common: Use pcap_get_selectable_fd()
       via  8c1314aae60 ctdb-common: Stop a pcap-related crash on error
       via  98ee0c12578 ctdb-common: Fix a warning in the pcap code
       via  197f86f9a1c ctdb-common: Do not use raw socket when ENABLE_PCAP is defined
       via  027c9ef106a ctdb-common: Move a misplaced comment
       via  188e949fdf6 ctdb-build: Add --enable-pcap configure option
       via  f25b506a73d ctdb-build: Use pcap-config when available
      from  89231620287 s4-rpc_server/drsupai: Avoid looping with Azure AD Connect by not incrementing temp_highest_usn for the NC root

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-17-test


- Log -----------------------------------------------------------------
commit 8d1e4f1d4f183bde3a741e0ffccf2ac7c4f08d4e
Author: Martin Schwenke <mschwenke at ddn.com>
Date:   Tue Aug 15 12:34:20 2023 +1000

    ctdb-common: Set immediate mode for pcap capture
    
    Fix a problem where ctdb_killtcp (almost always) fails to capture
    packets with --enable-pcap and libpcap ≥ 1.9.1.  The problem is due to
    a gradual change in libpcap semantics when using
    pcap_get_selectable_fd(3PCAP) to get a file descriptor and then using
    that file descriptor in non-blocking mode.
    
    pcap_set_immediate_mode(3PCAP) says:
    
      pcap_set_immediate_mode() sets whether immediate mode should be set
      on a capture handle when the handle is activated.  In immediate
      mode, packets are always delivered as soon as they arrive, with no
      buffering.
    
    and
    
      On Linux, with previous releases of libpcap, capture devices are
      always in immediate mode; however, in 1.5.0 and later, they are, by
      default, not in immediate mode, so if pcap_set_immediate_mode() is
      available, it should be used.
    
    However, it wasn't until libpcap commit
    2ade7676101366983bd4f86bc039ffd25da8c126 (before libpcap 1.9.1) that
    it became a requirement to use pcap_set_immediate_mode(), even with a
    timeout of 0.
    
    More explanation in this libpcap issue comment:
    
      https://github.com/the-tcpdump-group/libpcap/issues/860#issuecomment-541204548
    
    Do a configure check for pcap_set_immediate_mode() even though it has
    existed for 10 years.  It is easy enough.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15451
    
    Signed-off-by: Martin Schwenke <mschwenke at ddn.com>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    Autobuild-User(master): Amitay Isaacs <amitay at samba.org>
    Autobuild-Date(master): Tue Aug 15 10:53:52 UTC 2023 on atb-devel-224
    
    (cherry picked from commit dc7b48c404337891b5105df4d6751cf549a533eb)
    
    Autobuild-User(v4-17-test): Jule Anger <janger at samba.org>
    Autobuild-Date(v4-17-test): Tue Aug 29 10:29:56 UTC 2023 on sn-devel-184

commit bb905f04b505369e805613e694c2cbb62bd91dee
Author: Martin Schwenke <mschwenke at ddn.com>
Date:   Tue Aug 15 10:57:59 2023 +1000

    ctdb-common: Replace pcap_open_live() by lower level calls
    
    A subsequent commit will insert an additional call before
    pcap_activate().
    
    This sequence of calls is taken from the source for pcap_open_live(),
    so there should be no change in behaviour.
    
    Given the defaults set by pcap_create_common(), it would be possible
    to omit the calls to pcap_set_promisc() and pcap_set_timeout().
    However, those defaults don't seem to be well documented, so continue
    to explicitly set everything that was set before.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15451
    
    Signed-off-by: Martin Schwenke <mschwenke at ddn.com>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit ffc2ae616d8fab7528fbdfd8c6b94c5b9a0e3a7c)

commit 74d43dd395b0481d1c7588e80a0e5cb542e7124b
Author: Martin Schwenke <mschwenke at ddn.com>
Date:   Tue Aug 15 10:43:57 2023 +1000

    ctdb-common: Improve error handling
    
    Factor out a failure label, which will get more use in subsequent
    commits, and only set private_data when success is certain.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15451
    
    Signed-off-by: Martin Schwenke <mschwenke at ddn.com>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit d87041d8968e91db9d257445321b85693303f95e)

commit ef212b021e5113a93fc65c9acf02ed5f683abd40
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Sep 6 11:59:11 2022 +1000

    ctdb-scripts: Add debugging variable CTDB_KILLTCP_DEBUGLEVEL
    
    To debug ctdb_killtcp failures, add
    
      CTDB_KILLTCP_DEBUGLEVEL=DEBUG
    
    to script.options.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    Autobuild-User(master): Amitay Isaacs <amitay at samba.org>
    Autobuild-Date(master): Tue Sep 20 11:42:16 UTC 2022 on sn-devel-184
    
    (cherry picked from commit d9dda4b7af284ecbee4d04a89bd16fc0098e2931)

commit c5bd0b20ad365a313581b7752b6d368a6a2ece5d
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Aug 15 10:52:27 2022 +1000

    ctdb-common: Support IB in pcap-based capture
    
    Add simple support for IPoIB via DLT_LINUX_SLL and DLT_LINUX_SLL2.
    This seems to work, even when an IB interface is specified.
    
    If this is later found to be insufficient, support for DLT_IPOIB can
    be implemented.  See https://www.tcpdump.org/linktypes.html for a
    starting point.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 9f7d69a05b6114efe18bf4c86ca8de7789e9a96d)

commit 6417651bf4ba217e6590f12e25f5fd48d76dc65a
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Aug 15 10:51:47 2022 +1000

    ctdb-common: Support "any" interface for pcap-based capture
    
    This uses Linux cooked capture link-layer headers.  See:
    
      https://www.tcpdump.org/linktypes/LINKTYPE_LINUX_SLL.html
      https://www.tcpdump.org/linktypes/LINKTYPE_LINUX_SLL2.html
    
    The header type needs to be checked to ensure the protocol
    type (i.e. ether type, for the protocols we might be interested in) is
    meaningful.  The size of the header needs to be known so it can be
    skipped, allowing the IP header to be found and parsed.
    
    It would be possible to define support for DLT_LINUX_SLL2 if it is
    missing.  However, if a platform is missing support in the header file
    then it is almost certainly missing in the run-time library too.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit e5541a7e0220a88d59d574d501626b0598050c52)

commit 0f3864d7c596d766cd223529f817d9232ce49908
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Aug 15 09:43:58 2022 +1000

    ctdb-common: Add packet type detection to pcap-based capture
    
    The current code will almost certainly generate ENOMSG for
    non-ethernet packets, even for ethernet packets when the "any"
    interface is used.
    
    pcap_datalink(3PCAP) says:
    
      Do NOT assume that the packets for a given capture or ``savefile``
      will have any given link-layer header type, such as DLT_EN10MB for
      Ethernet.  For example, the "any" device on Linux will have a
      link-layer header type of DLT_LINUX_SLL or DLT_LINUX_SLL2 even if
      all devices on the sys‐ tem at the time the "any" device is opened
      have some other data link type, such as DLT_EN10MB for Ethernet.
    
    So, pcap_datalink() must be used.
    
    Detect pcap packet types that are supported (currently only ethernet)
    in the open code. There is no use continuing if the read code can't
    parse packets.  The pattern of using switch statements supports future
    addition of other packet types.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 3bf20300ac5962e71069be3998ef7f0502045d24)

commit f01d53d8848ccd6e6a743ea42d5dd7846840d7a2
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Aug 15 09:41:09 2022 +1000

    ctdb-tools: Improve/add debug
    
    In particular, knowing the reason fetching the packet fails can help
    with debugging unsupported protocols in the pcap code.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 5dd964aa0297b6e9ab8e1d0ff9fa0565c97ea43e)

commit d37c3d141565b46c40456ebf16a78a57bae4344a
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Aug 15 14:30:09 2022 +1000

    ctdb-common: Improve/add debug
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 33a80c1d63fd2e6163ef6c704b2e714e71b01384)

commit 0adfd0cc0f6b06432b99624015f984ebb0bbf93d
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Aug 11 09:00:25 2022 +1000

    ctdb-common: Use pcap_get_selectable_fd()
    
    This is preferred because it will fail for devices that do not support
    epoll_wait() and similar.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 075414dc05455a5cd33a244efd51be60fc294e95)

commit 8c1314aae600de1c3292185b7a5ff41a76d711c0
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Aug 9 13:49:42 2022 +1000

    ctdb-common: Stop a pcap-related crash on error
    
    errbuf can't be NULL.  Might as well use it.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 40380a8042dfc2efa6f8f06ed7ac86c3c20a343f)

commit 98ee0c125781081bb98cdb78ed3a9df8478ee243
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Aug 8 11:31:03 2022 +1000

    ctdb-common: Fix a warning in the pcap code
    
    [173/416] Compiling ctdb/common/system_socket.c
    ../../common/system_socket.c: In function ‘ctdb_sys_read_tcp_packet’:
    ../../common/system_socket.c:1016:15: error: cast discards ‘const’ qualifier from pointer target type [-Werror=cast-qual]
     1016 |         eth = (struct ether_header *)buffer;
          |               ^
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 8b54587b1aed28aa2f3af7161a077aa9dd83894c)

commit 197f86f9a1c3d7e5e6e4ed6df75288f9847ee3d8
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Aug 8 11:30:15 2022 +1000

    ctdb-common: Do not use raw socket when ENABLE_PCAP is defined
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit ad445abebdea55f71b0c79eb31c0e6b0aee06763)

commit 027c9ef106aa226180268c8ddc3dd5ce05edc147
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Aug 8 11:29:36 2022 +1000

    ctdb-common: Move a misplaced comment
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit c522f4f6045b48bffe47a12a246f356e71fbeec0)

commit 188e949fdf687432b0a487c571fc140d66b0df11
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Aug 8 11:26:54 2022 +1000

    ctdb-build: Add --enable-pcap configure option
    
    This forces the use pcap for packet capture on Linux.
    
    It appears that using a raw socket for capture does not work with
    infiniband - pcap support for that to come.
    
    Don't (yet?) change the default capture method to pcap.  On some
    platforms (e.g. my personal Intel NUC, running Debian testing), pcap
    is much less reliable than the raw socket.  However, pcap seems fine
    on most other platforms.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit d1543d5c7889f3ac42f80fc5d1eddf54f9c5d0d6)

commit f25b506a73dea3a02c02e62b6979e108760dee00
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Jul 23 14:39:05 2021 +1000

    ctdb-build: Use pcap-config when available
    
    The build currently fails on AIX, which can't find the pcap headers
    because they're installed in a non-standard place.  However, there is
    a pcap-config script available.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit a83e9ca696a37b00231ce40cca5a043beb9b5590)

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

Summary of changes:
 ctdb/common/system_socket.c | 181 ++++++++++++++++++++++++++++++++++++--------
 ctdb/config/functions       |   8 +-
 ctdb/tools/ctdb_killtcp.c   |  13 ++--
 ctdb/wscript                |  14 +++-
 4 files changed, 178 insertions(+), 38 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ctdb/common/system_socket.c b/ctdb/common/system_socket.c
index bb513508353..273b9c3400e 100644
--- a/ctdb/common/system_socket.c
+++ b/ctdb/common/system_socket.c
@@ -747,13 +747,6 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest,
 	return 0;
 }
 
-/*
- * Packet capture
- *
- * If AF_PACKET is available then use a raw socket otherwise use pcap.
- * wscript has checked to make sure that pcap is available if needed.
- */
-
 static int tcp4_extract(const uint8_t *ip_pkt,
 			size_t pktlen,
 			struct sockaddr_in *src,
@@ -864,8 +857,14 @@ static int tcp6_extract(const uint8_t *ip_pkt,
 	return 0;
 }
 
+/*
+ * Packet capture
+ *
+ * If AF_PACKET is available then use a raw socket otherwise use pcap.
+ * wscript has checked to make sure that pcap is available if needed.
+ */
 
-#ifdef HAVE_AF_PACKET
+#if defined(HAVE_AF_PACKET) && !defined(ENABLE_PCAP)
 
 /*
  * This function is used to open a raw socket to capture from
@@ -881,7 +880,7 @@ int ctdb_sys_open_capture_socket(const char *iface, void **private_data)
 		return -1;
 	}
 
-	DBG_DEBUG("Created RAW SOCKET FD:%d for tcp tickle\n", s);
+	DBG_DEBUG("Opened raw socket for TCP tickle capture (fd=%d)\n", s);
 
 	ret = set_blocking(s, false);
 	if (ret != 0) {
@@ -964,22 +963,92 @@ int ctdb_sys_read_tcp_packet(int s, void *private_data,
 	return ENOMSG;
 }
 
-#else /* HAVE_AF_PACKET */
+#else /* defined(HAVE_AF_PACKET) && !defined(ENABLE_PCAP) */
 
 #include <pcap.h>
 
+/*
+ * Assume this exists if pcap.h exists - it has been around for a
+ * while
+ */
+#include <pcap/sll.h>
+
 int ctdb_sys_open_capture_socket(const char *iface, void **private_data)
 {
+	char errbuf[PCAP_ERRBUF_SIZE];
 	pcap_t *pt;
+	int pcap_packet_type;
+	const char *t = NULL;
+	int fd;
+	int ret;
 
-	pt=pcap_open_live(iface, 100, 0, 0, NULL);
+	pt = pcap_create(iface, errbuf);
 	if (pt == NULL) {
-		DBG_ERR("Failed to open capture device %s\n", iface);
+		DBG_ERR("Failed to open pcap capture device %s (%s)\n",
+			iface,
+			errbuf);
 		return -1;
 	}
+	/*
+	 * pcap isn't very clear about defaults...
+	 */
+	ret = pcap_set_snaplen(pt, 100);
+	if (ret < 0) {
+		DBG_ERR("Failed to set snaplen for pcap capture\n");
+		goto fail;
+	}
+	ret = pcap_set_promisc(pt, 0);
+	if (ret < 0) {
+		DBG_ERR("Failed to unset promiscuous mode for pcap capture\n");
+		goto fail;
+	}
+	ret = pcap_set_timeout(pt, 0);
+	if (ret < 0) {
+		DBG_ERR("Failed to set timeout for pcap capture\n");
+		goto fail;
+	}
+#ifdef HAVE_PCAP_SET_IMMEDIATE_MODE
+	ret = pcap_set_immediate_mode(pt, 1);
+	if (ret < 0) {
+		DBG_ERR("Failed to set immediate mode for pcap capture\n");
+		goto fail;
+	}
+#endif
+	ret = pcap_activate(pt);
+	if (ret < 0) {
+		DBG_ERR("Failed to activate pcap capture\n");
+		goto fail;
+	}
+
+	pcap_packet_type = pcap_datalink(pt);
+	switch (pcap_packet_type) {
+	case DLT_EN10MB:
+		t = "DLT_EN10MB";
+		break;
+	case DLT_LINUX_SLL:
+		t = "DLT_LINUX_SLL";
+		break;
+#ifdef DLT_LINUX_SLL2
+	case DLT_LINUX_SLL2:
+		t = "DLT_LINUX_SLL2";
+		break;
+#endif /* DLT_LINUX_SLL2 */
+	default:
+		DBG_ERR("Unknown pcap packet type %d\n", pcap_packet_type);
+		goto fail;
+	}
+
+	fd = pcap_get_selectable_fd(pt);
+	DBG_DEBUG("Opened pcap capture for TCP tickle (type=%s, fd=%d)\n",
+		  t,
+		  fd);
+
 	*((pcap_t **)private_data) = pt;
+	return fd;
 
-	return pcap_fileno(pt);
+fail:
+	pcap_close(pt);
+	return -1;
 }
 
 int ctdb_sys_close_capture_socket(void *private_data)
@@ -999,10 +1068,12 @@ int ctdb_sys_read_tcp_packet(int s,
 			     uint16_t *window)
 {
 	int ret;
-	struct ether_header *eth;
 	struct pcap_pkthdr pkthdr;
 	const u_char *buffer;
 	pcap_t *pt = (pcap_t *)private_data;
+	int pcap_packet_type;
+	uint16_t ether_type;
+	size_t ll_hdr_len;
 
 	buffer=pcap_next(pt, &pkthdr);
 	if (buffer==NULL) {
@@ -1012,36 +1083,86 @@ int ctdb_sys_read_tcp_packet(int s,
 	ZERO_STRUCTP(src);
 	ZERO_STRUCTP(dst);
 
-	/* Ethernet */
-	eth = (struct ether_header *)buffer;
+	pcap_packet_type = pcap_datalink(pt);
+	switch (pcap_packet_type) {
+	case DLT_EN10MB: {
+		const struct ether_header *eth =
+			(const struct ether_header *)buffer;
+		ether_type = ntohs(eth->ether_type);
+		ll_hdr_len = sizeof(struct ether_header);
+		break;
+	}
+	case DLT_LINUX_SLL: {
+		const struct sll_header *sll =
+			(const struct sll_header *)buffer;
+		uint16_t arphrd_type = ntohs(sll->sll_hatype);
+		switch (arphrd_type) {
+		case ARPHRD_ETHER:
+		case ARPHRD_INFINIBAND:
+			break;
+		default:
+			DBG_DEBUG("SLL: Unknown arphrd_type %"PRIu16"\n",
+				  arphrd_type);
+			return EPROTONOSUPPORT;
+		}
+		ether_type = ntohs(sll->sll_protocol);
+		ll_hdr_len = SLL_HDR_LEN;
+		break;
+	}
+#ifdef DLT_LINUX_SLL2
+	case DLT_LINUX_SLL2: {
+		const struct sll2_header *sll2 =
+			(const struct sll2_header *)buffer;
+		uint16_t arphrd_type = ntohs(sll2->sll2_hatype);
+		switch (arphrd_type) {
+		case ARPHRD_ETHER:
+		case ARPHRD_INFINIBAND:
+			break;
+		default:
+			DBG_DEBUG("SLL2: Unknown arphrd_type %"PRIu16"\n",
+				  arphrd_type);
+			return EPROTONOSUPPORT;
+		}
+		ether_type = ntohs(sll2->sll2_protocol);
+		ll_hdr_len = SLL2_HDR_LEN;
+		break;
+	}
+#endif /* DLT_LINUX_SLL2 */
+	default:
+		DBG_DEBUG("Unknown pcap packet type %d\n", pcap_packet_type);
+		return EPROTONOSUPPORT;
+	}
 
-	/* we want either IPv4 or IPv6 */
-	if (eth->ether_type == htons(ETHERTYPE_IP)) {
-		ret = tcp4_extract(buffer + sizeof(struct ether_header),
-				   (size_t)(pkthdr.caplen -
-					    sizeof(struct ether_header)),
+	switch (ether_type) {
+	case ETHERTYPE_IP:
+		ret = tcp4_extract(buffer + ll_hdr_len,
+				   (size_t)pkthdr.caplen - ll_hdr_len,
 				   &src->ip,
 				   &dst->ip,
 				   ack_seq,
 				   seq,
 				   rst,
 				   window);
-		return ret;
-
-	} else if (eth->ether_type == htons(ETHERTYPE_IP6)) {
-		ret = tcp6_extract(buffer + sizeof(struct ether_header),
-				   (size_t)(pkthdr.caplen -
-					    sizeof(struct ether_header)),
+		break;
+	case ETHERTYPE_IP6:
+		ret = tcp6_extract(buffer + ll_hdr_len,
+				   (size_t)pkthdr.caplen - ll_hdr_len,
 				   &src->ip6,
 				   &dst->ip6,
 				   ack_seq,
 				   seq,
 				   rst,
 				   window);
-		return ret;
+		break;
+	case ETHERTYPE_ARP:
+		/* Silently ignore ARP packets */
+		return EPROTO;
+	default:
+		DBG_DEBUG("Unknown ether type %"PRIu16"\n", ether_type);
+		return EPROTO;
 	}
 
-	return ENOMSG;
+	return ret;
 }
 
-#endif /* HAVE_AF_PACKET */
+#endif /* defined(HAVE_AF_PACKET) && !defined(ENABLE_PCAP) */
diff --git a/ctdb/config/functions b/ctdb/config/functions
index 82ed0957aa0..725993ca12f 100755
--- a/ctdb/config/functions
+++ b/ctdb/config/functions
@@ -452,8 +452,14 @@ kill_tcp_connections ()
 	    return
 	fi
 
+	if [ -n "$CTDB_KILLTCP_DEBUGLEVEL" ]; then
+		_debuglevel="$CTDB_KILLTCP_DEBUGLEVEL"
+	else
+		_debuglevel="$CTDB_DEBUGLEVEL"
+	fi
 	echo "$_connections" | \
-		"${CTDB_HELPER_BINDIR}/ctdb_killtcp" "$_iface" || {
+		CTDB_DEBUGLEVEL="$_debuglevel" \
+			"${CTDB_HELPER_BINDIR}/ctdb_killtcp" "$_iface" || {
 		echo "Failed to kill TCP connections"
 		return
 	}
diff --git a/ctdb/tools/ctdb_killtcp.c b/ctdb/tools/ctdb_killtcp.c
index bab81092058..007422f42fc 100644
--- a/ctdb/tools/ctdb_killtcp.c
+++ b/ctdb/tools/ctdb_killtcp.c
@@ -169,17 +169,18 @@ static void reset_connections_capture_tcp_handler(struct tevent_context *ev,
 				       &conn.server, &conn.client,
 				       &ack_seq, &seq, &rst, &window);
 	if (ret != 0) {
-		/* probably a non-tcp ACK packet */
+		/* Not a TCP-ACK?  Unexpected protocol? */
+		DBG_DEBUG("Failed to parse packet, errno=%d\n", ret);
 		return;
 	}
 
 	if (window == htons(1234) && (rst || seq == 0)) {
 		/* Ignore packets that we sent! */
-		D_DEBUG("Ignoring packet: %s, "
-			"seq=%"PRIu32", ack_seq=%"PRIu32", "
-			"rst=%d, window=%"PRIu16"\n",
-			ctdb_connection_to_string(state, &conn, false),
-			seq, ack_seq, rst, ntohs(window));
+		DBG_DEBUG("Ignoring sent packet: %s, "
+			  "seq=%"PRIu32", ack_seq=%"PRIu32", "
+			  "rst=%d, window=%"PRIu16"\n",
+			  ctdb_connection_to_string(state, &conn, false),
+			  seq, ack_seq, rst, ntohs(window));
 		return;
 	}
 
diff --git a/ctdb/wscript b/ctdb/wscript
index c082c3b7a7d..a7b04541014 100644
--- a/ctdb/wscript
+++ b/ctdb/wscript
@@ -98,6 +98,9 @@ def options(opt):
     opt.add_option('--enable-etcd-reclock',
                    help=("Enable etcd recovery lock helper (default=no)"),
                    action="store_true", dest='ctdb_etcd_reclock', default=False)
+    opt.add_option('--enable-pcap',
+                   help=("Use pcap for packet capture (default=no)"),
+                   action="store_true", dest='ctdb_pcap', default=False)
 
     opt.add_option('--with-libcephfs',
                    help=("Directory under which libcephfs is installed"),
@@ -201,15 +204,24 @@ def configure(conf):
     if not conf.CHECK_VARIABLE('ETIME', headers='errno.h'):
         conf.DEFINE('ETIME', 'ETIMEDOUT')
 
-    if sys.platform.startswith('linux'):
+    if Options.options.ctdb_pcap or not sys.platform.startswith('linux'):
+        conf.DEFINE('ENABLE_PCAP', 1)
+    if not conf.env.ENABLE_PCAP:
         conf.SET_TARGET_TYPE('pcap', 'EMPTY')
     else:
+        conf.find_program('pcap-config', var='PCAP_CONFIG')
+        if conf.env.PCAP_CONFIG:
+            conf.CHECK_CFG(path=conf.env.PCAP_CONFIG,
+                           args="--cflags --libs",
+                           package="",
+                           uselib_store="PCAP")
         if not conf.CHECK_HEADERS('pcap.h'):
             Logs.error('Need libpcap')
             sys.exit(1)
         if not conf.CHECK_FUNCS_IN('pcap_open_live', 'pcap', headers='pcap.h'):
             Logs.error('Need libpcap')
             sys.exit(1)
+        conf.CHECK_FUNCS_IN('pcap_set_immediate_mode', 'pcap', headers='pcap.h')
 
     if not conf.CHECK_FUNCS_IN('backtrace backtrace_symbols', 'execinfo',
                                checklibc=True, headers='execinfo.h'):


-- 
Samba Shared Repository



More information about the samba-cvs mailing list