308 lines
9.4 KiB
Diff
308 lines
9.4 KiB
Diff
From 8304a62ea7847ba6934d44c1b5b7acef9667750d Mon Sep 17 00:00:00 2001
|
|
From: Martin Schwenke <martin@meltin.net>
|
|
Date: Fri, 8 Jun 2018 19:57:20 +1000
|
|
Subject: [PATCH 1/2] ctdb-common: New include file common/system_network.h
|
|
|
|
Contains declarations for functions that need ctdb_sock_addr.
|
|
|
|
Signed-off-by: Martin Schwenke <martin@meltin.net>
|
|
---
|
|
ctdb/common/system.h | 16 ------------
|
|
ctdb/common/system_aix.c | 1 +
|
|
ctdb/common/system_common.c | 2 +-
|
|
ctdb/common/system_freebsd.c | 1 +
|
|
ctdb/common/system_gnu.c | 1 +
|
|
ctdb/common/system_kfreebsd.c | 1 +
|
|
ctdb/common/system_linux.c | 1 +
|
|
ctdb/common/system_network.h | 46 ++++++++++++++++++++++++++++++++++
|
|
ctdb/server/ctdb_daemon.c | 1 +
|
|
ctdb/server/ctdb_recoverd.c | 2 +-
|
|
ctdb/server/ctdb_takeover.c | 1 +
|
|
ctdb/tests/src/porting_tests.c | 1 +
|
|
ctdb/tools/ctdb.c | 1 +
|
|
ctdb/tools/ctdb_killtcp.c | 2 +-
|
|
14 files changed, 58 insertions(+), 19 deletions(-)
|
|
create mode 100644 ctdb/common/system_network.h
|
|
|
|
diff --git a/ctdb/common/system.h b/ctdb/common/system.h
|
|
index e6f65b5e621..38ae67d2ab1 100644
|
|
--- a/ctdb/common/system.h
|
|
+++ b/ctdb/common/system.h
|
|
@@ -22,24 +22,8 @@
|
|
|
|
#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);
|
|
-char *ctdb_sys_find_ifname(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);
|
|
|
|
diff --git a/ctdb/common/system_aix.c b/ctdb/common/system_aix.c
|
|
index f0a0a62efc0..7be54c7a46b 100644
|
|
--- a/ctdb/common/system_aix.c
|
|
+++ b/ctdb/common/system_aix.c
|
|
@@ -38,6 +38,7 @@
|
|
|
|
#include "common/logging.h"
|
|
#include "common/system.h"
|
|
+#include "common/system_network.h"
|
|
|
|
|
|
#if 0
|
|
diff --git a/ctdb/common/system_common.c b/ctdb/common/system_common.c
|
|
index a80189cd6c8..2618bf88c7f 100644
|
|
--- a/ctdb/common/system_common.c
|
|
+++ b/ctdb/common/system_common.c
|
|
@@ -26,7 +26,7 @@
|
|
#include "protocol/protocol.h"
|
|
|
|
#include "common/logging.h"
|
|
-#include "common/system.h"
|
|
+#include "common/system_network.h"
|
|
|
|
/*
|
|
uint16 checksum for n bytes
|
|
diff --git a/ctdb/common/system_freebsd.c b/ctdb/common/system_freebsd.c
|
|
index b709a5c75c1..e5a6522c08f 100644
|
|
--- a/ctdb/common/system_freebsd.c
|
|
+++ b/ctdb/common/system_freebsd.c
|
|
@@ -41,6 +41,7 @@
|
|
|
|
#include "common/logging.h"
|
|
#include "common/system.h"
|
|
+#include "common/system_network.h"
|
|
|
|
#ifndef ETHERTYPE_IP6
|
|
#define ETHERTYPE_IP6 0x86dd
|
|
diff --git a/ctdb/common/system_gnu.c b/ctdb/common/system_gnu.c
|
|
index 38ccd13988b..683843a6b76 100644
|
|
--- a/ctdb/common/system_gnu.c
|
|
+++ b/ctdb/common/system_gnu.c
|
|
@@ -40,6 +40,7 @@
|
|
|
|
#include "common/logging.h"
|
|
#include "common/system.h"
|
|
+#include "common/system_network.h"
|
|
|
|
#ifndef ETHERTYPE_IP6
|
|
#define ETHERTYPE_IP6 0x86dd
|
|
diff --git a/ctdb/common/system_kfreebsd.c b/ctdb/common/system_kfreebsd.c
|
|
index d02f28659cb..cdf13572b2b 100644
|
|
--- a/ctdb/common/system_kfreebsd.c
|
|
+++ b/ctdb/common/system_kfreebsd.c
|
|
@@ -40,6 +40,7 @@
|
|
|
|
#include "common/logging.h"
|
|
#include "common/system.h"
|
|
+#include "common/system_network.h"
|
|
|
|
#ifndef ETHERTYPE_IP6
|
|
#define ETHERTYPE_IP6 0x86dd
|
|
diff --git a/ctdb/common/system_linux.c b/ctdb/common/system_linux.c
|
|
index fa77a45460f..beacbf34138 100644
|
|
--- a/ctdb/common/system_linux.c
|
|
+++ b/ctdb/common/system_linux.c
|
|
@@ -37,6 +37,7 @@
|
|
|
|
#include "common/logging.h"
|
|
#include "common/system.h"
|
|
+#include "common/system_network.h"
|
|
|
|
#ifndef ETHERTYPE_IP6
|
|
#define ETHERTYPE_IP6 0x86dd
|
|
diff --git a/ctdb/common/system_network.h b/ctdb/common/system_network.h
|
|
new file mode 100644
|
|
index 00000000000..b6761d29c76
|
|
--- /dev/null
|
|
+++ b/ctdb/common/system_network.h
|
|
@@ -0,0 +1,46 @@
|
|
+/*
|
|
+ System specific network code
|
|
+
|
|
+ Copyright (C) Amitay Isaacs 2015
|
|
+
|
|
+ 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/>.
|
|
+*/
|
|
+
|
|
+#ifndef __CTDB_SYSTEM_NETWORK_H__
|
|
+#define __CTDB_SYSTEM_NETWORK_H__
|
|
+
|
|
+#include <talloc.h>
|
|
+
|
|
+#include "protocol/protocol.h"
|
|
+
|
|
+/* From system_common.c */
|
|
+
|
|
+uint32_t uint16_checksum(uint16_t *data, size_t n);
|
|
+bool ctdb_sys_have_ip(ctdb_sock_addr *_addr);
|
|
+char *ctdb_sys_find_ifname(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);
|
|
+
|
|
+#endif /* __CTDB_SYSTEM_H__ */
|
|
diff --git a/ctdb/server/ctdb_daemon.c b/ctdb/server/ctdb_daemon.c
|
|
index 35c1ab639b5..37a93ec6de1 100644
|
|
--- a/ctdb/server/ctdb_daemon.c
|
|
+++ b/ctdb/server/ctdb_daemon.c
|
|
@@ -43,6 +43,7 @@
|
|
#include "common/rb_tree.h"
|
|
#include "common/reqid.h"
|
|
#include "common/system.h"
|
|
+#include "common/system_network.h"
|
|
#include "common/common.h"
|
|
#include "common/logging.h"
|
|
#include "common/pidfile.h"
|
|
diff --git a/ctdb/server/ctdb_recoverd.c b/ctdb/server/ctdb_recoverd.c
|
|
index 2b94fed7478..73451711845 100644
|
|
--- a/ctdb/server/ctdb_recoverd.c
|
|
+++ b/ctdb/server/ctdb_recoverd.c
|
|
@@ -38,7 +38,7 @@
|
|
#include "ctdb_private.h"
|
|
#include "ctdb_client.h"
|
|
|
|
-#include "common/system.h"
|
|
+#include "common/system_network.h"
|
|
#include "common/common.h"
|
|
#include "common/logging.h"
|
|
|
|
diff --git a/ctdb/server/ctdb_takeover.c b/ctdb/server/ctdb_takeover.c
|
|
index cd240875ba2..a97ce2b6de6 100644
|
|
--- a/ctdb/server/ctdb_takeover.c
|
|
+++ b/ctdb/server/ctdb_takeover.c
|
|
@@ -39,6 +39,7 @@
|
|
#include "common/rb_tree.h"
|
|
#include "common/reqid.h"
|
|
#include "common/system.h"
|
|
+#include "common/system_network.h"
|
|
#include "common/common.h"
|
|
#include "common/logging.h"
|
|
|
|
diff --git a/ctdb/tests/src/porting_tests.c b/ctdb/tests/src/porting_tests.c
|
|
index 74dbf0781b4..b7ad5256fdc 100644
|
|
--- a/ctdb/tests/src/porting_tests.c
|
|
+++ b/ctdb/tests/src/porting_tests.c
|
|
@@ -32,6 +32,7 @@
|
|
|
|
#include "protocol/protocol.h"
|
|
#include "common/system.h"
|
|
+#include "common/system_network.h"
|
|
#include "common/logging.h"
|
|
|
|
|
|
diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c
|
|
index 2cb46b057f0..8cbe706ab54 100644
|
|
--- a/ctdb/tools/ctdb.c
|
|
+++ b/ctdb/tools/ctdb.c
|
|
@@ -41,6 +41,7 @@
|
|
#include "protocol/protocol_api.h"
|
|
#include "protocol/protocol_util.h"
|
|
#include "common/system.h"
|
|
+#include "common/system_network.h"
|
|
#include "client/client.h"
|
|
#include "client/client_sync.h"
|
|
|
|
diff --git a/ctdb/tools/ctdb_killtcp.c b/ctdb/tools/ctdb_killtcp.c
|
|
index 71b5999b10e..408a7b4e121 100644
|
|
--- a/ctdb/tools/ctdb_killtcp.c
|
|
+++ b/ctdb/tools/ctdb_killtcp.c
|
|
@@ -30,7 +30,7 @@
|
|
#include "protocol/protocol_util.h"
|
|
|
|
#include "common/db_hash.h"
|
|
-#include "common/system.h"
|
|
+#include "common/system_network.h"
|
|
#include "common/logging.h"
|
|
|
|
|
|
--
|
|
2.17.1
|
|
|
|
|
|
From fb350f80cc072d4b699759a432217211986926be Mon Sep 17 00:00:00 2001
|
|
From: Martin Schwenke <martin@meltin.net>
|
|
Date: Fri, 8 Jun 2018 22:31:48 +1000
|
|
Subject: [PATCH 2/2] ctdb-tests: Switch fake_ctdbd to use ctdb_get_peer_pid()
|
|
|
|
This potentially improves portability.
|
|
|
|
Signed-off-by: Martin Schwenke <martin@meltin.net>
|
|
---
|
|
ctdb/tests/src/fake_ctdbd.c | 6 ++----
|
|
1 file changed, 2 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/ctdb/tests/src/fake_ctdbd.c b/ctdb/tests/src/fake_ctdbd.c
|
|
index 2f4e87f6f6c..0e33f8c02e0 100644
|
|
--- a/ctdb/tests/src/fake_ctdbd.c
|
|
+++ b/ctdb/tests/src/fake_ctdbd.c
|
|
@@ -40,6 +40,7 @@
|
|
#include "common/logging.h"
|
|
#include "common/tunable.h"
|
|
#include "common/srvid.h"
|
|
+#include "common/system.h"
|
|
|
|
#include "ipalloc_read_known_ips.h"
|
|
|
|
@@ -3050,8 +3051,6 @@ static struct tevent_req *client_send(TALLOC_CTX *mem_ctx,
|
|
{
|
|
struct tevent_req *req;
|
|
struct client_state *state;
|
|
- struct ucred cr;
|
|
- socklen_t crl = sizeof(struct ucred);
|
|
int ret;
|
|
|
|
req = tevent_req_create(mem_ctx, &state, struct client_state);
|
|
@@ -3064,12 +3063,11 @@ static struct tevent_req *client_send(TALLOC_CTX *mem_ctx,
|
|
state->ctdb = ctdb;
|
|
state->pnn = pnn;
|
|
|
|
- ret = getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &cr, &crl);
|
|
+ ret = ctdb_get_peer_pid(fd, &state->pid);
|
|
if (ret != 0) {
|
|
tevent_req_error(req, ret);
|
|
return tevent_req_post(req, ev);
|
|
}
|
|
- state->pid = cr.pid;
|
|
|
|
ret = comm_setup(state, ev, fd, client_read_handler, req,
|
|
client_dead_handler, req, &state->comm);
|
|
--
|
|
2.17.1
|
|
|