[Cluster-devel] cluster/fence/agents/xvm debug.c fence_xvm.c i ...
lhh at sourceware.org
lhh at sourceware.org
Wed Oct 10 16:23:20 UTC 2007
CVSROOT: /cvs/cluster
Module name: cluster
Branch: RHEL4
Changes by: lhh at sourceware.org 2007-10-10 16:23:20
Modified files:
fence/agents/xvm: debug.c fence_xvm.c ip_lookup.c mcast.c
simple_auth.c tcp.c xvm.h
Added files:
fence/agents/xvm: debug.h
Log message:
Fix #326531 - fence_xvm using dprintf for debugging can cause corruption
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/agents/xvm/debug.h.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=NONE&r2=1.1.4.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/agents/xvm/debug.c.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.1.6.1&r2=1.1.6.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/agents/xvm/fence_xvm.c.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.4.2.2&r2=1.4.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/agents/xvm/ip_lookup.c.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.3.2.1&r2=1.3.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/agents/xvm/mcast.c.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.2.2.1&r2=1.2.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/agents/xvm/simple_auth.c.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.3.2.2&r2=1.3.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/agents/xvm/tcp.c.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.2.2.1&r2=1.2.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/agents/xvm/xvm.h.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.2.2.1&r2=1.2.2.2
--- cluster/fence/agents/xvm/debug.c 2006/12/01 15:49:38 1.1.6.1
+++ cluster/fence/agents/xvm/debug.c 2007/10/10 16:23:19 1.1.6.2
@@ -16,7 +16,8 @@
Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
MA 02139, USA.
*/
-#include "xvm.h"
+#include <stdio.h>
+#include "debug.h"
static int _debug = 0;
@@ -24,7 +25,7 @@
dset(int threshold)
{
_debug = threshold;
- dprintf(3, "Debugging threshold is now %d\n", threshold);
+ dbg_printf(3, "Debugging threshold is now %d\n", threshold);
}
inline int
--- cluster/fence/agents/xvm/fence_xvm.c 2007/03/06 15:30:11 1.4.2.2
+++ cluster/fence/agents/xvm/fence_xvm.c 2007/10/10 16:23:19 1.4.2.3
@@ -53,6 +53,7 @@
#include "options.h"
#include "tcp.h"
#include "mcast.h"
+#include "debug.h"
int
@@ -63,7 +64,7 @@
int n;
struct timeval tv;
- dprintf(3, "Waiting for connection from XVM host daemon.\n");
+ dbg_printf(3, "Waiting for connection from XVM host daemon.\n");
FD_ZERO(&rfds);
FD_SET(lfd, &rfds);
tv.tv_sec = retry_tenths / 10;
@@ -94,7 +95,7 @@
struct timeval tv;
/* Ok, we're connected */
- dprintf(3, "Issuing TCP challenge\n");
+ dbg_printf(3, "Issuing TCP challenge\n");
if (tcp_challenge(fd, auth, key, key_len, timeout) <= 0) {
/* Challenge failed */
printf("Invalid response to challenge\n");
@@ -102,13 +103,13 @@
}
/* Now they'll send us one, so we need to respond here */
- dprintf(3, "Responding to TCP challenge\n");
+ dbg_printf(3, "Responding to TCP challenge\n");
if (tcp_response(fd, auth, key, key_len, timeout) <= 0) {
printf("Invalid response to challenge\n");
return 0;
}
- dprintf(2, "TCP Exchange + Authentication done... \n");
+ dbg_printf(2, "TCP Exchange + Authentication done... \n");
FD_ZERO(&rfds);
FD_SET(fd, &rfds);
@@ -116,7 +117,7 @@
tv.tv_usec = 0;
ret = 1;
- dprintf(3, "Waiting for return value from XVM host\n");
+ dbg_printf(3, "Waiting for return value from XVM host\n");
if (select(fd + 1, &rfds, NULL, NULL, &tv) <= 0)
return -1;
@@ -146,7 +147,7 @@
for (ipa = ipl->tqh_first; ipa; ipa = ipa->ipa_entries.tqe_next) {
if (ipa->ipa_family != args->family) {
- dprintf(2, "Ignoring %s: wrong family\n", ipa->ipa_address);
+ dbg_printf(2, "Ignoring %s: wrong family\n", ipa->ipa_address);
continue;
}
@@ -166,7 +167,7 @@
tgt = (struct sockaddr *)&tgt6;
tgt_len = sizeof(tgt6);
} else {
- dprintf(2, "Unsupported family %d\n", args->family);
+ dbg_printf(2, "Unsupported family %d\n", args->family);
return -1;
}
@@ -198,7 +199,7 @@
sign_request(&freq, key, key_len);
- dprintf(3, "Sending to %s via %s\n", args->addr,
+ dbg_printf(3, "Sending to %s via %s\n", args->addr,
ipa->ipa_address);
sendto(mc_sock, &freq, sizeof(freq), 0,
--- cluster/fence/agents/xvm/ip_lookup.c 2006/12/01 15:49:38 1.3.2.1
+++ cluster/fence/agents/xvm/ip_lookup.c 2007/10/10 16:23:19 1.3.2.2
@@ -38,6 +38,7 @@
/* Local includes */
#include "ip_lookup.h"
+#include "debug.h"
static int
send_addr_dump(int fd, int family)
@@ -85,7 +86,7 @@
return -1;
}
- dprintf(4, "Adding IP %s to list (family %d)\n", ipaddr, family);
+ dbg_printf(4, "Adding IP %s to list (family %d)\n", ipaddr, family);
ipa = malloc(sizeof(*ipa));
memset(ipa, 0, sizeof(*ipa));
@@ -110,25 +111,25 @@
char outbuf[256];
int x, fd, len;
- dprintf(5, "Connecting to Netlink...\n");
+ dbg_printf(5, "Connecting to Netlink...\n");
fd = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_ROUTE);
if (fd < 0) {
perror("socket");
exit(1);
}
- dprintf(5, "Sending address dump request\n");
+ dbg_printf(5, "Sending address dump request\n");
send_addr_dump(fd, family);
memset(buf, 0, sizeof(buf));
- dprintf(5, "Waiting for response\n");
+ dbg_printf(5, "Waiting for response\n");
x = recvfrom(fd, buf, sizeof(buf), 0, NULL, 0);
if (x < 0) {
perror("recvfrom");
return -1;
}
- dprintf(5, "Received %d bytes\n", x);
+ dbg_printf(5, "Received %d bytes\n", x);
nh = (struct nlmsghdr *)buf;
while (NLMSG_OK(nh, x)) {
@@ -173,7 +174,7 @@
do {
/* Make sure we've got a valid rtaddr field */
if (!RTA_OK(rta, len)) {
- dprintf(5, "!RTA_OK(rta, len)\n");
+ dbg_printf(5, "!RTA_OK(rta, len)\n");
break;
}
@@ -184,7 +185,7 @@
}
if (rta->rta_type == IFA_LABEL) {
- dprintf(5, "Skipping label: %s\n",
+ dbg_printf(5, "Skipping label: %s\n",
(char *)RTA_DATA(rta));
}
@@ -199,7 +200,7 @@
nh = NLMSG_NEXT(nh, x);
}
- dprintf(5, "Closing Netlink connection\n");
+ dbg_printf(5, "Closing Netlink connection\n");
close(fd);
return 0;
}
@@ -210,15 +211,15 @@
{
ip_addr_t *ipa;
- dprintf(5, "Looking for IP address %s in IP list %p...", ip_name, ipl);
+ dbg_printf(5, "Looking for IP address %s in IP list %p...", ip_name, ipl);
ipa = ipl->tqh_first;
for (ipa = ipl->tqh_first; ipa; ipa = ipa->ipa_entries.tqe_next) {
if (!strcmp(ip_name, ipa->ipa_address)) {
- dprintf(4,"Found\n");
+ dbg_printf(4,"Found\n");
return 0;
}
}
- dprintf(5, "Not found\n");
+ dbg_printf(5, "Not found\n");
return 1;
}
@@ -228,7 +229,7 @@
{
ip_addr_t *ipa;
- dprintf(5, "Tearing down IP list @ %p\n", ipl);
+ dbg_printf(5, "Tearing down IP list @ %p\n", ipl);
while ((ipa = ipl->tqh_first)) {
TAILQ_REMOVE(ipl, ipa, ipa_entries);
free(ipa->ipa_address);
@@ -241,7 +242,7 @@
int
ip_build_list(ip_list_t *ipl)
{
- dprintf(5, "Build IP address list\n");
+ dbg_printf(5, "Build IP address list\n");
TAILQ_INIT(ipl);
if (add_ip_addresses(PF_INET6, ipl) < 0) {
ip_free_list(ipl);
@@ -275,7 +276,7 @@
ip_list_t ipl;
int ret = -1;
- dprintf(5, "Looking for IP matching %s\n", nodename);
+ dbg_printf(5, "Looking for IP matching %s\n", nodename);
/* Build list of IP addresses configured locally */
if (ip_build_list(&ipl) < 0)
return -1;
--- cluster/fence/agents/xvm/mcast.c 2006/12/01 15:49:38 1.2.2.1
+++ cluster/fence/agents/xvm/mcast.c 2007/10/10 16:23:19 1.2.2.2
@@ -41,6 +41,7 @@
/* Local includes */
#include "mcast.h"
+#include "debug.h"
/**
Sets up a multicast receive socket
@@ -62,7 +63,7 @@
/********************************
* SET UP MULTICAST RECV SOCKET *
********************************/
- dprintf(4, "Setting up ipv4 multicast receive (%s:%d)\n", addr, port);
+ dbg_printf(4, "Setting up ipv4 multicast receive (%s:%d)\n", addr, port);
sock = socket(PF_INET, SOCK_DGRAM, 0);
if (sock < 0) {
printf("socket: %s\n", strerror(errno));
@@ -90,7 +91,7 @@
*/
/* mreq.imr_multiaddr.s_addr is set above */
mreq.imr_interface.s_addr = htonl(INADDR_ANY);
- dprintf(4, "Joining multicast group\n");
+ dbg_printf(4, "Joining multicast group\n");
if (setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP,
&mreq, sizeof(mreq)) == -1) {
printf("Failed to bind multicast receive socket to "
@@ -100,7 +101,7 @@
return -1;
}
- dprintf(4, "%s: success, fd = %d\n", __FUNCTION__, sock);
+ dbg_printf(4, "%s: success, fd = %d\n", __FUNCTION__, sock);
return sock;
}
@@ -147,7 +148,7 @@
/*************************
* SET UP MULTICAST SEND *
*************************/
- dprintf(4, "Setting up ipv4 multicast send (%s:%d)\n", addr, port);
+ dbg_printf(4, "Setting up ipv4 multicast send (%s:%d)\n", addr, port);
sock = socket(PF_INET, SOCK_DGRAM, 0);
if (sock < 0) {
perror("socket");
@@ -157,7 +158,7 @@
/*
* Join Multicast group.
*/
- dprintf(4, "Joining IP Multicast group (pass 1)\n");
+ dbg_printf(4, "Joining IP Multicast group (pass 1)\n");
if (setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq,
sizeof(mreq)) == -1) {
printf("Failed to add multicast membership to transmit "
@@ -169,7 +170,7 @@
/*
* Join Multicast group.
*/
- dprintf(4, "Joining IP Multicast group (pass 2)\n");
+ dbg_printf(4, "Joining IP Multicast group (pass 2)\n");
if (setsockopt(sock, IPPROTO_IP, IP_MULTICAST_IF, &src.sin_addr,
sizeof(src.sin_addr)) == -1) {
printf("Failed to bind multicast transmit socket to "
@@ -181,7 +182,7 @@
/*
* set time to live to 2 hops.
*/
- dprintf(4, "Setting TTL to 2 for fd%d\n", sock);
+ dbg_printf(4, "Setting TTL to 2 for fd%d\n", sock);
val = 2;
if (setsockopt(sock, SOL_IP, IP_MULTICAST_TTL, &val,
sizeof(val)))
@@ -189,7 +190,7 @@
memcpy((struct sockaddr_in *)tgt, &mcast, sizeof(struct sockaddr_in));
- dprintf(4, "%s: success, fd = %d\n", __FUNCTION__, sock);
+ dbg_printf(4, "%s: success, fd = %d\n", __FUNCTION__, sock);
return sock;
}
@@ -222,7 +223,7 @@
/********************************
* SET UP MULTICAST RECV SOCKET *
********************************/
- dprintf(4, "Setting up ipv6 multicast receive (%s:%d)\n", addr, port);
+ dbg_printf(4, "Setting up ipv6 multicast receive (%s:%d)\n", addr, port);
sock = socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP);
if (sock < 0) {
printf("socket: %s\n", strerror(errno));
@@ -246,7 +247,7 @@
return -1;
}
- dprintf(4, "Disabling IP Multicast loopback\n");
+ dbg_printf(4, "Disabling IP Multicast loopback\n");
val = 1;
if (setsockopt(sock, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, &val,
sizeof(val)) != 0) {
@@ -258,7 +259,7 @@
/*
* Join multicast group
*/
- dprintf(4, "Joining IP Multicast group\n");
+ dbg_printf(4, "Joining IP Multicast group\n");
if (setsockopt(sock, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, &mreq,
sizeof(mreq)) == -1) {
printf("Failed to add multicast to socket %s: %s\n",
@@ -267,7 +268,7 @@
return -1;
}
- dprintf(4, "%s: success, fd = %d\n", __FUNCTION__, sock);
+ dbg_printf(4, "%s: success, fd = %d\n", __FUNCTION__, sock);
return sock;
}
@@ -316,14 +317,14 @@
/*************************
* SET UP MULTICAST SEND *
*************************/
- dprintf(4, "Setting up ipv6 multicast send (%s:%d)\n", addr, port);
+ dbg_printf(4, "Setting up ipv6 multicast send (%s:%d)\n", addr, port);
sock = socket(PF_INET6, SOCK_DGRAM, 0);
if (sock < 0) {
perror("socket");
return -1;
}
- dprintf(4, "Disabling IP Multicast loopback\n");
+ dbg_printf(4, "Disabling IP Multicast loopback\n");
val = 1;
if (setsockopt(sock, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, &val,
sizeof(val)) != 0) {
@@ -335,7 +336,7 @@
/*
* Join Multicast group.
*/
- dprintf(4, "Joining IP Multicast group\n");
+ dbg_printf(4, "Joining IP Multicast group\n");
if (setsockopt(sock, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, &mreq,
sizeof(mreq)) == -1) {
printf("Failed to add multicast membership to transmit "
@@ -367,6 +368,6 @@
memcpy((struct sockaddr_in *)tgt, &mcast, sizeof(struct sockaddr_in6));
- dprintf(4, "%s: success, fd = %d\n", __FUNCTION__, sock);
+ dbg_printf(4, "%s: success, fd = %d\n", __FUNCTION__, sock);
return sock;
}
--- cluster/fence/agents/xvm/simple_auth.c 2007/03/06 23:01:35 1.3.2.2
+++ cluster/fence/agents/xvm/simple_auth.c 2007/10/10 16:23:19 1.3.2.3
@@ -29,6 +29,7 @@
/* Local includes */
#include "xvm.h"
#include "simple_auth.h"
+#include "debug.h"
void
@@ -64,7 +65,7 @@
return;
}
- dprintf(4, "Opening /dev/urandom\n");
+ dbg_printf(4, "Opening /dev/urandom\n");
devrand = open("/dev/urandom", O_RDONLY);
if (devrand >= 0) {
if (read(devrand, req->random, sizeof(req->random)) < 0) {
@@ -109,7 +110,7 @@
ht = HASH_AlgSHA512;
break;
default:
- dprintf(3, "%s: no-op (HASH_NONE)\n", __FUNCTION__);
+ dbg_printf(3, "%s: no-op (HASH_NONE)\n", __FUNCTION__);
return 0;
}
@@ -148,7 +149,7 @@
memset(req->hash, 0, sizeof(req->hash));
switch(req->hashtype) {
case HASH_NONE:
- dprintf(3, "%s: no-op (HASH_NONE)\n", __FUNCTION__);
+ dbg_printf(3, "%s: no-op (HASH_NONE)\n", __FUNCTION__);
return 0;
case HASH_SHA1:
case HASH_SHA256:
@@ -305,7 +306,7 @@
ht = HASH_AlgSHA512;
break;
default:
- dprintf(3, "%s: no-op (AUTH_NONE)\n", __FUNCTION__);
+ dbg_printf(3, "%s: no-op (AUTH_NONE)\n", __FUNCTION__);
return 0;
}
@@ -335,7 +336,7 @@
{
switch(auth) {
case AUTH_NONE:
- dprintf(3, "%s: no-op (AUTH_NONE)\n", __FUNCTION__);
+ dbg_printf(3, "%s: no-op (AUTH_NONE)\n", __FUNCTION__);
return 1;
case AUTH_SHA1:
case AUTH_SHA256:
@@ -354,7 +355,7 @@
{
switch(auth) {
case AUTH_NONE:
- dprintf(3, "%s: no-op (AUTH_NONE)\n", __FUNCTION__);
+ dbg_printf(3, "%s: no-op (AUTH_NONE)\n", __FUNCTION__);
return 1;
case AUTH_SHA1:
case AUTH_SHA256:
@@ -374,7 +375,7 @@
int nread, remain = max_len;
char *p;
- dprintf(3, "Reading in key file %s into %p (%d len)",
+ dbg_printf(3, "Reading in key file %s into %p (%d len)",
file, key, (int)max_len);
fd = open(file, O_RDONLY);
if (fd < 0) {
@@ -388,13 +389,13 @@
while (remain) {
nread = read(fd, p, remain);
if (nread < 0) {
- dprintf(2, "Error from read: %s\n", strerror(errno));
+ dbg_printf(2, "Error from read: %s\n", strerror(errno));
close(fd);
return -1;
}
if (nread == 0) {
- dprintf(3, "Stopped reading @ %d bytes",
+ dbg_printf(3, "Stopped reading @ %d bytes",
(int)max_len-remain);
break;
}
@@ -404,7 +405,7 @@
}
close(fd);
- dprintf(3, "Actual key length = %d bytes", (int)max_len-remain);
+ dbg_printf(3, "Actual key length = %d bytes", (int)max_len-remain);
return (int)(max_len - remain);
}
--- cluster/fence/agents/xvm/tcp.c 2006/12/01 15:49:38 1.2.2.1
+++ cluster/fence/agents/xvm/tcp.c 2007/10/10 16:23:19 1.2.2.2
@@ -33,6 +33,8 @@
#include <sys/types.h>
#include <arpa/inet.h>
+#include "debug.h"
+
static int connect_nb(int fd, struct sockaddr *dest, socklen_t len, int timeout);
/**
@@ -65,7 +67,7 @@
struct sockaddr_in6 _sin6;
int fd, ret;
- dprintf(4, "%s: Setting up ipv6 listen socket\n", __FUNCTION__);
+ dbg_printf(4, "%s: Setting up ipv6 listen socket\n", __FUNCTION__);
fd = socket(PF_INET6, SOCK_STREAM, 0);
if (fd < 0)
return -1;
@@ -96,7 +98,7 @@
return -1;
}
- dprintf(4, "%s: Success; fd = %d\n", __FUNCTION__, fd);
+ dbg_printf(4, "%s: Success; fd = %d\n", __FUNCTION__, fd);
return fd;
}
@@ -115,7 +117,7 @@
struct sockaddr_in _sin;
int fd, ret;
- dprintf(4, "%s: Setting up ipv4 listen socket\n", __FUNCTION__);
+ dbg_printf(4, "%s: Setting up ipv4 listen socket\n", __FUNCTION__);
fd = socket(PF_INET, SOCK_STREAM, 0);
if (fd < 0)
return -1;
@@ -144,7 +146,7 @@
return -1;
}
- dprintf(4, "%s: Success; fd = %d\n", __FUNCTION__, fd);
+ dbg_printf(4, "%s: Success; fd = %d\n", __FUNCTION__, fd);
return fd;
}
@@ -166,7 +168,7 @@
struct sockaddr_in6 _sin6;
int fd, ret;
- dprintf(4, "%s: Connecting to client\n", __FUNCTION__);
+ dbg_printf(4, "%s: Connecting to client\n", __FUNCTION__);
fd = socket(PF_INET6, SOCK_STREAM, 0);
if (fd < 0)
return -1;
@@ -182,7 +184,7 @@
close(fd);
return -1;
}
- dprintf(4, "%s: Success; fd = %d\n", __FUNCTION__, fd);
+ dbg_printf(4, "%s: Success; fd = %d\n", __FUNCTION__, fd);
return fd;
}
@@ -203,7 +205,7 @@
struct sockaddr_in _sin;
int fd, ret;
- dprintf(4, "%s: Connecting to client\n", __FUNCTION__);
+ dbg_printf(4, "%s: Connecting to client\n", __FUNCTION__);
fd = socket(PF_INET, SOCK_STREAM, 0);
if (fd < 0)
return -1;
@@ -218,7 +220,7 @@
return -1;
}
- dprintf(4, "%s: Success; fd = %d\n", __FUNCTION__, fd);
+ dbg_printf(4, "%s: Success; fd = %d\n", __FUNCTION__, fd);
return fd;
}
--- cluster/fence/agents/xvm/xvm.h 2006/12/01 15:49:38 1.2.2.1
+++ cluster/fence/agents/xvm/xvm.h 2007/10/10 16:23:19 1.2.2.2
@@ -73,14 +73,4 @@
} fence_req_t;
-inline void dset(int);
-inline int dget(void);
-
-#define dprintf(level, fmt, args...) \
-do { \
- if (dget()>=level) \
- printf(fmt, ##args); \
-} while(0)
-
-
#endif
More information about the Cluster-devel
mailing list