[SCM] CTDB repository - branch master updated - ctdb-1.12-202-g650bb17
Michael Adam
obnox at samba.org
Sat Feb 18 04:35:48 MST 2012
The branch, master has been updated
via 650bb17335876f3e91e76a47b748c9236d0f3045 (commit)
via 89067e12b868974f9909b447ab5e202d612ac44f (commit)
via be5c3a57df39d85fbb7ee922924787340e2b0595 (commit)
via d657af4fb68ce3f7c462856f2934f6bf169e120b (commit)
from be8a153346ca7d40f09a6d03aad655aaa5c4a903 (commit)
http://gitweb.samba.org/?p=ctdb.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 650bb17335876f3e91e76a47b748c9236d0f3045
Author: Michael Adam <obnox at samba.org>
Date: Sat Feb 18 12:29:49 2012 +0100
Fix the build on freebsd9. (typo in flags?)
commit 89067e12b868974f9909b447ab5e202d612ac44f
Author: Volker Lendecke <vl at samba.org>
Date: Mon Feb 6 12:50:05 2012 +0100
Add common/system_freebsd.c
Signed-off-by: Michael Adam <obnox at samba.org>
commit be5c3a57df39d85fbb7ee922924787340e2b0595
Author: Volker Lendecke <vl at samba.org>
Date: Mon Feb 6 11:33:17 2012 +0100
Add includes required on FreeBSD
Signed-off-by: Michael Adam <obnox at samba.org>
commit d657af4fb68ce3f7c462856f2934f6bf169e120b
Author: Volker Lendecke <vl at samba.org>
Date: Mon Feb 6 11:01:47 2012 +0100
FreeBSD does not define s6_addr32, only s6_addr
Signed-off-by: Michael Adam <obnox at samba.org>
-----------------------------------------------------------------------
Summary of changes:
Makefile.in | 2 +-
common/ctdb_util.c | 2 +-
common/{system_kfreebsd.c => system_freebsd.c} | 119 +++++++++++++-----------
configure.ac | 9 ++
libctdb/control.c | 1 +
libctdb/ctdb.c | 2 +
libctdb/io_elem.c | 1 +
libctdb/local_tdb.c | 1 +
libctdb/logging.c | 1 +
libctdb/messages.c | 1 +
libctdb/sync.c | 1 +
server/ctdb_takeover.c | 35 ++++---
tools/ctdb.c | 12 ++-
13 files changed, 110 insertions(+), 77 deletions(-)
copy common/{system_kfreebsd.c => system_freebsd.c} (74%)
Changeset truncated at 500 lines:
diff --git a/Makefile.in b/Makefile.in
index 8000801..52b2ef1 100755
--- a/Makefile.in
+++ b/Makefile.in
@@ -35,7 +35,7 @@ PMDA_LIBS = -lpcp -lpcp_pmda
PMDA_INSTALL = @CTDB_PMDA_INSTALL@
PMDA_DEST_DIR = /var/lib/pcp/pmdas
-CFLAGS=-g -I$(srcdir)/include -Iinclude -Ilib -Ilib/util -I$(srcdir) \
+CFLAGS=@CPPFLAGS@ -g -I$(srcdir)/include -Iinclude -Ilib -Ilib/util -I$(srcdir) \
-I at tallocdir@ -I at tdbdir@/include -I at libreplacedir@ \
-DVARDIR=\"$(localstatedir)\" -DETCDIR=\"$(etcdir)\" \
-DLOGDIR=\"$(logdir)\" \
diff --git a/common/ctdb_util.c b/common/ctdb_util.c
index 1ff4c1f..bb32b6a 100644
--- a/common/ctdb_util.c
+++ b/common/ctdb_util.c
@@ -522,7 +522,7 @@ void ctdb_canonicalize_ip(const ctdb_sock_addr *ip, ctdb_sock_addr *cip)
#endif
cip->ip.sin_family = AF_INET;
cip->ip.sin_port = ip->ip6.sin6_port;
- memcpy(&cip->ip.sin_addr, &ip->ip6.sin6_addr.s6_addr32[3], 4);
+ memcpy(&cip->ip.sin_addr, &ip->ip6.sin6_addr.s6_addr[12], 4);
}
}
diff --git a/common/system_kfreebsd.c b/common/system_freebsd.c
similarity index 74%
copy from common/system_kfreebsd.c
copy to common/system_freebsd.c
index a6cd148..c72b6f8 100644
--- a/common/system_kfreebsd.c
+++ b/common/system_freebsd.c
@@ -1,9 +1,10 @@
/*
- ctdb system specific code to manage raw sockets on linux
+ ctdb system specific code to manage raw sockets on freebsd
Copyright (C) Ronnie Sahlberg 2007
Copyright (C) Andrew Tridgell 2007
- Copyright (C) Marc Dequènes (Duck) 2009
+ Copyright (C) Marc Dequènes (Duck) 2009
+ Copyright (C) Volker Lendecke 2012
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
@@ -83,15 +84,15 @@ int ctdb_sys_send_arp(const ctdb_sock_addr *addr, const char *iface)
/*
simple TCP checksum - assumes data is multiple of 2 bytes long
*/
-static uint16_t tcp_checksum(uint16_t *data, size_t n, struct iphdr *ip)
+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 *)(void *)&ip->saddr,
- sizeof(ip->saddr));
- sum += uint16_checksum((uint16_t *)(void *)&ip->daddr,
- sizeof(ip->daddr));
- sum += ip->protocol + n;
+ sum += uint16_checksum((uint16_t *)(void *)&ip->ip_src,
+ sizeof(ip->ip_src));
+ sum += uint16_checksum((uint16_t *)(void *)&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);
@@ -123,7 +124,7 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest,
uint16_t tmpport;
ctdb_sock_addr *tmpdest;
struct {
- struct iphdr ip;
+ struct ip ip;
struct tcphdr tcp;
} ip4pkt;
struct {
@@ -134,27 +135,28 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest,
switch (src->ip.sin_family) {
case AF_INET:
ZERO_STRUCT(ip4pkt);
- ip4pkt.ip.version = 4;
- ip4pkt.ip.ihl = sizeof(ip4pkt.ip)/4;
- ip4pkt.ip.tot_len = htons(sizeof(ip4pkt));
- ip4pkt.ip.ttl = 255;
- ip4pkt.ip.protocol = IPPROTO_TCP;
- ip4pkt.ip.saddr = src->ip.sin_addr.s_addr;
- ip4pkt.ip.daddr = dest->ip.sin_addr.s_addr;
- ip4pkt.ip.check = 0;
-
- ip4pkt.tcp.source = src->ip.sin_port;
- ip4pkt.tcp.dest = dest->ip.sin_port;
- ip4pkt.tcp.seq = seq;
- ip4pkt.tcp.ack_seq = ack;
- ip4pkt.tcp.ack = 1;
+ 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 = 0;
+ ip4pkt.tcp.th_flags |= TH_ACK;
if (rst) {
- ip4pkt.tcp.rst = 1;
+ ip4pkt.tcp.th_flags |= TH_RST;
}
- ip4pkt.tcp.doff = sizeof(ip4pkt.tcp)/4;
+ ip4pkt.tcp.th_off = sizeof(ip4pkt.tcp)/4;
/* this makes it easier to spot in a sniffer */
- ip4pkt.tcp.window = htons(1234);
- ip4pkt.tcp.check = tcp_checksum((uint16_t *)&ip4pkt.tcp, sizeof(ip4pkt.tcp), &ip4pkt.ip);
+ ip4pkt.tcp.th_win = htons(1234);
+ ip4pkt.tcp.th_sum = tcp_checksum((uint16_t *)&ip4pkt.tcp, sizeof(ip4pkt.tcp), &ip4pkt.ip);
/* open a raw socket to send this segment from */
s = socket(AF_INET, SOCK_RAW, htons(IPPROTO_RAW));
@@ -175,7 +177,9 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest,
set_nonblocking(s);
set_close_on_exec(s);
- ret = sendto(s, &ip4pkt, sizeof(ip4pkt), 0, &dest->ip, sizeof(dest->ip));
+ ret = sendto(s, &ip4pkt, sizeof(ip4pkt), 0,
+ (const struct sockaddr *)&dest->ip,
+ sizeof(dest->ip));
close(s);
if (ret != sizeof(ip4pkt)) {
DEBUG(DEBUG_CRIT,(__location__ " failed sendto (%s)\n", strerror(errno)));
@@ -191,18 +195,19 @@ int ctdb_sys_send_tcp(const ctdb_sock_addr *dest,
ip6pkt.ip6.ip6_src = src->ip6.sin6_addr;
ip6pkt.ip6.ip6_dst = dest->ip6.sin6_addr;
- ip6pkt.tcp.source = src->ip6.sin6_port;
- ip6pkt.tcp.dest = dest->ip6.sin6_port;
- ip6pkt.tcp.seq = seq;
- ip6pkt.tcp.ack_seq = ack;
- ip6pkt.tcp.ack = 1;
+ ip6pkt.tcp.th_sport = src->ip6.sin6_port;
+ ip6pkt.tcp.th_dport = dest->ip6.sin6_port;
+ ip6pkt.tcp.th_seq = seq;
+ ip6pkt.tcp.th_ack = ack;
+ ip6pkt.tcp.th_flags = 0;
+ ip6pkt.tcp.th_flags |= TH_ACK;
if (rst) {
- ip6pkt.tcp.rst = 1;
+ ip6pkt.tcp.th_flags |= TH_RST;
}
- ip6pkt.tcp.doff = sizeof(ip6pkt.tcp)/4;
+ ip6pkt.tcp.th_off = sizeof(ip6pkt.tcp)/4;
/* this makes it easier to spot in a sniffer */
- ip6pkt.tcp.window = htons(1234);
- ip6pkt.tcp.check = tcp_checksum6((uint16_t *)&ip6pkt.tcp, sizeof(ip6pkt.tcp), &ip6pkt.ip6);
+ ip6pkt.tcp.th_win = htons(1234);
+ ip6pkt.tcp.th_sum = tcp_checksum6((uint16_t *)&ip6pkt.tcp, sizeof(ip6pkt.tcp), &ip6pkt.ip6);
s = socket(PF_INET6, SOCK_RAW, IPPROTO_RAW);
if (s == -1) {
@@ -217,7 +222,9 @@ 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,
+ (const struct sockaddr *)&dest->ip6,
+ sizeof(dest->ip6));
tmpdest->ip6.sin6_port = tmpport;
close(s);
@@ -273,7 +280,7 @@ int ctdb_sys_read_tcp_packet(int s, void *private_data,
#define RCVPKTSIZE 100
char pkt[RCVPKTSIZE];
struct ether_header *eth;
- struct iphdr *ip;
+ struct ip *ip;
struct ip6_hdr *ip6;
struct tcphdr *tcp;
@@ -288,38 +295,38 @@ int ctdb_sys_read_tcp_packet(int s, void *private_data,
/* we want either IPv4 or IPv6 */
if (ntohs(eth->ether_type) == ETHERTYPE_IP) {
/* IP */
- ip = (struct iphdr *)(eth+1);
+ ip = (struct ip *)(eth+1);
/* We only want IPv4 packets */
- if (ip->version != 4) {
+ if (ip->ip_v != 4) {
return -1;
}
/* Dont look at fragments */
- if ((ntohs(ip->frag_off)&0x1fff) != 0) {
+ if ((ntohs(ip->ip_off)&0x1fff) != 0) {
return -1;
}
/* we only want TCP */
- if (ip->protocol != IPPROTO_TCP) {
+ if (ip->ip_p != IPPROTO_TCP) {
return -1;
}
/* make sure its not a short packet */
- if (offsetof(struct tcphdr, ack_seq) + 4 +
- (ip->ihl*4) + sizeof(*eth) > ret) {
+ if (offsetof(struct tcphdr, th_ack) + 4 +
+ (ip->ip_hl*4) + sizeof(*eth) > ret) {
return -1;
}
/* TCP */
- tcp = (struct tcphdr *)((ip->ihl*4) + (char *)ip);
+ tcp = (struct tcphdr *)((ip->ip_hl*4) + (char *)ip);
/* tell the caller which one we've found */
src->ip.sin_family = AF_INET;
- src->ip.sin_addr.s_addr = ip->saddr;
- src->ip.sin_port = tcp->source;
+ src->ip.sin_addr.s_addr = ip->ip_src.s_addr;
+ src->ip.sin_port = tcp->th_sport;
dst->ip.sin_family = AF_INET;
- dst->ip.sin_addr.s_addr = ip->daddr;
- dst->ip.sin_port = tcp->dest;
- *ack_seq = tcp->ack_seq;
- *seq = tcp->seq;
+ dst->ip.sin_addr.s_addr = ip->ip_dst.s_addr;
+ dst->ip.sin_port = tcp->th_dport;
+ *ack_seq = tcp->th_ack;
+ *seq = tcp->th_seq;
return 0;
} else if (ntohs(eth->ether_type) == ETHERTYPE_IP6) {
@@ -336,15 +343,15 @@ int ctdb_sys_read_tcp_packet(int s, void *private_data,
/* tell the caller which one we've found */
src->ip6.sin6_family = AF_INET6;
- src->ip6.sin6_port = tcp->source;
+ src->ip6.sin6_port = tcp->th_sport;
src->ip6.sin6_addr = ip6->ip6_src;
dst->ip6.sin6_family = AF_INET6;
- dst->ip6.sin6_port = tcp->dest;
+ dst->ip6.sin6_port = tcp->th_dport;
dst->ip6.sin6_addr = ip6->ip6_dst;
- *ack_seq = tcp->ack_seq;
- *seq = tcp->seq;
+ *ack_seq = tcp->th_ack;
+ *seq = tcp->th_seq;
return 0;
}
diff --git a/configure.ac b/configure.ac
index 8a3bd7e..50d20a0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -33,6 +33,15 @@ case `uname` in
CTDB_SCSI_IO=
CTDB_PCAP_LDFLAGS=-lpcap
;;
+ FreeBSD)
+ CTDB_SYSTEM_OBJ=common/system_freebsd.o
+ CTDB_SCSI_IO=
+ CTDB_PCAP_LDFLAGS=-lpcap
+ LDFLAGS="$LDFLAGS -L/usr/local/lib -lexecinfo"
+ AC_SUBST(LDFLAGS)
+ CPPFLAGS="$CPPFLAGS -I/usr/local/include -D_FREEBSD_=1"
+ AC_SUBST(CPPFLAGS)
+ ;;
GNU)
CTDB_SYSTEM_OBJ=common/system_gnu.o
CTDB_SCSI_IO=
diff --git a/libctdb/control.c b/libctdb/control.c
index 8741ad9..b4c54cd 100644
--- a/libctdb/control.c
+++ b/libctdb/control.c
@@ -16,6 +16,7 @@
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 <sys/socket.h>
#include <string.h>
#include <ctdb.h>
#include <ctdb_protocol.h>
diff --git a/libctdb/ctdb.c b/libctdb/ctdb.c
index 13ccf9e..191b097 100644
--- a/libctdb/ctdb.c
+++ b/libctdb/ctdb.c
@@ -17,6 +17,8 @@
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 <sys/socket.h>
+#include <string.h>
#include <ctdb.h>
#include <poll.h>
#include <errno.h>
diff --git a/libctdb/io_elem.c b/libctdb/io_elem.c
index 81d44e4..572237b 100644
--- a/libctdb/io_elem.c
+++ b/libctdb/io_elem.c
@@ -17,6 +17,7 @@
along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include <sys/types.h>
+#include <sys/socket.h>
#include <string.h>
#include <stdint.h>
#include <stdbool.h>
diff --git a/libctdb/local_tdb.c b/libctdb/local_tdb.c
index 705be2b..506e974 100644
--- a/libctdb/local_tdb.c
+++ b/libctdb/local_tdb.c
@@ -18,6 +18,7 @@
along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#include <sys/socket.h>
#include <ctdb.h>
#include <tdb.h>
#include <stdlib.h>
diff --git a/libctdb/logging.c b/libctdb/logging.c
index 83f4774..d897b6f 100644
--- a/libctdb/logging.c
+++ b/libctdb/logging.c
@@ -16,6 +16,7 @@
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 <sys/socket.h>
#include <stdio.h>
#include <errno.h>
#include <ctdb.h>
diff --git a/libctdb/messages.c b/libctdb/messages.c
index 66b41b5..254df02 100644
--- a/libctdb/messages.c
+++ b/libctdb/messages.c
@@ -17,6 +17,7 @@
along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
+#include <sys/socket.h>
#include "libctdb_private.h"
#include "messages.h"
#include "io_elem.h"
diff --git a/libctdb/sync.c b/libctdb/sync.c
index 4b68cd1..0e175f7 100644
--- a/libctdb/sync.c
+++ b/libctdb/sync.c
@@ -16,6 +16,7 @@
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 <sys/socket.h>
#include <ctdb.h>
#include <stdbool.h>
#include <poll.h>
diff --git a/server/ctdb_takeover.c b/server/ctdb_takeover.c
index 87e1b00..830b751 100644
--- a/server/ctdb_takeover.c
+++ b/server/ctdb_takeover.c
@@ -1222,12 +1222,14 @@ static uint32_t *ip_key(ctdb_sock_addr *ip)
case AF_INET:
key[3] = htonl(ip->ip.sin_addr.s_addr);
break;
- case AF_INET6:
- key[0] = htonl(ip->ip6.sin6_addr.s6_addr32[0]);
- key[1] = htonl(ip->ip6.sin6_addr.s6_addr32[1]);
- key[2] = htonl(ip->ip6.sin6_addr.s6_addr32[2]);
- key[3] = htonl(ip->ip6.sin6_addr.s6_addr32[3]);
+ case AF_INET6: {
+ uint32_t *s6_a32 = (uint32_t *)&(ip->ip6.sin6_addr.s6_addr);
+ key[0] = htonl(s6_a32[0]);
+ key[1] = htonl(s6_a32[1]);
+ key[2] = htonl(s6_a32[2]);
+ key[3] = htonl(s6_a32[3]);
break;
+ }
default:
DEBUG(DEBUG_ERR, (__location__ " ERROR, unknown family passed :%u\n", ip->sa.sa_family));
return key;
@@ -2800,18 +2802,23 @@ static uint32_t *killtcp_key(ctdb_sock_addr *src, ctdb_sock_addr *dst)
key[2] = dst->ip.sin_port;
key[3] = src->ip.sin_port;
break;
- case AF_INET6:
- key[0] = dst->ip6.sin6_addr.s6_addr32[3];
- key[1] = src->ip6.sin6_addr.s6_addr32[3];
- key[2] = dst->ip6.sin6_addr.s6_addr32[2];
- key[3] = src->ip6.sin6_addr.s6_addr32[2];
- key[4] = dst->ip6.sin6_addr.s6_addr32[1];
- key[5] = src->ip6.sin6_addr.s6_addr32[1];
- key[6] = dst->ip6.sin6_addr.s6_addr32[0];
- key[7] = src->ip6.sin6_addr.s6_addr32[0];
+ case AF_INET6: {
+ uint32_t *dst6_addr32 =
+ (uint32_t *)&(dst->ip6.sin6_addr.s6_addr);
+ uint32_t *src6_addr32 =
+ (uint32_t *)&(src->ip6.sin6_addr.s6_addr);
+ key[0] = dst6_addr32[3];
+ key[1] = src6_addr32[3];
+ key[2] = dst6_addr32[2];
+ key[3] = src6_addr32[2];
+ key[4] = dst6_addr32[1];
+ key[5] = src6_addr32[1];
+ key[6] = dst6_addr32[0];
+ key[7] = src6_addr32[0];
key[8] = dst->ip6.sin6_port;
key[9] = src->ip6.sin6_port;
break;
+ }
default:
DEBUG(DEBUG_ERR, (__location__ " ERROR, unknown family passed :%u\n", src->sa.sa_family));
return key;
diff --git a/tools/ctdb.c b/tools/ctdb.c
index aeb14c9..a9fbddc 100644
--- a/tools/ctdb.c
+++ b/tools/ctdb.c
@@ -1601,12 +1601,14 @@ static uint32_t *ip_key(ctdb_sock_addr *ip)
case AF_INET:
key[0] = ip->ip.sin_addr.s_addr;
break;
- case AF_INET6:
- key[0] = ip->ip6.sin6_addr.s6_addr32[3];
- key[1] = ip->ip6.sin6_addr.s6_addr32[2];
- key[2] = ip->ip6.sin6_addr.s6_addr32[1];
- key[3] = ip->ip6.sin6_addr.s6_addr32[0];
+ case AF_INET6: {
+ uint32_t *s6_a32 = (uint32_t *)&(ip->ip6.sin6_addr.s6_addr);
+ key[0] = s6_a32[3];
+ key[1] = s6_a32[2];
+ key[2] = s6_a32[1];
+ key[3] = s6_a32[0];
break;
+ }
default:
DEBUG(DEBUG_ERR, (__location__ " ERROR, unknown family passed :%u\n", ip->sa.sa_family));
return key;
--
CTDB repository
More information about the samba-cvs
mailing list