From: lhh@sourceware.org <lhh@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] cluster ccs/ccs_tool/update.c ccs/daemon/clust ...
Date: 26 Oct 2007 20:15:39 -0000 [thread overview]
Message-ID: <20071026201539.8129.qmail@sourceware.org> (raw)
CVSROOT: /cvs/cluster
Module name: cluster
Branch: RHEL4
Changes by: lhh at sourceware.org 2007-10-26 20:15:37
Modified files:
ccs/ccs_tool : update.c
ccs/daemon : cluster_mgr.c
magma/lib : magmamsg.h memberlist.c message.c
rgmanager : ChangeLog
rgmanager/src/daemons: main.c
rgmanager/src/utils: clustat.c clusvcadm.c
Log message:
Fix bugzillas #298831, #298861, #354391 - apps using magmamsg don't connect from correct source IP on multi-homed hosts
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/ccs/ccs_tool/update.c.diff?cvsroot=cluster&only_with_tag=RHEL46&r1=1.1.2.4&r2=1.1.2.4.6.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/ccs/daemon/cluster_mgr.c.diff?cvsroot=cluster&only_with_tag=RHEL46&r1=1.10.2.8&r2=1.10.2.8.6.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/magma/lib/magmamsg.h.diff?cvsroot=cluster&only_with_tag=RHEL46&r1=1.5&r2=1.5.18.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/magma/lib/memberlist.c.diff?cvsroot=cluster&only_with_tag=RHEL46&r1=1.6&r2=1.6.18.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/magma/lib/message.c.diff?cvsroot=cluster&only_with_tag=RHEL46&r1=1.9.2.3&r2=1.9.2.3.10.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/ChangeLog.diff?cvsroot=cluster&only_with_tag=RHEL46&r1=1.5.2.32.2.1&r2=1.5.2.32.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/main.c.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.9.2.22&r2=1.9.2.23
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/utils/clustat.c.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.5.2.19&r2=1.5.2.20
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/utils/clusvcadm.c.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.2.2.9&r2=1.2.2.10
--- cluster/ccs/ccs_tool/update.c 2006/01/12 18:11:26 1.1.2.4
+++ cluster/ccs/ccs_tool/update.c 2007/10/26 20:15:37 1.1.2.4.6.1
@@ -80,6 +80,7 @@
}
int update(char *location){
+ uint64_t nid;
int error = 0;
int i, fd;
int cluster_fd = -1;
@@ -190,6 +191,8 @@
membership = clu_member_list(NULL);
msg_update(membership);
+ clu_local_nodeid(NULL, &nid);
+ msg_set_nodeid(nid);
memb_resolve_list(membership, NULL);
--- cluster/ccs/daemon/cluster_mgr.c 2006/02/16 20:12:26 1.10.2.8
+++ cluster/ccs/daemon/cluster_mgr.c 2007/10/26 20:15:37 1.10.2.8.6.1
@@ -306,6 +306,7 @@
static void cluster_communicator(void){
+ uint64_t nid;
int cluster_fd = -1;
int listen_fds[2], listeners;
int warn_user = 0;
@@ -371,6 +372,8 @@
membership = clu_member_list(NULL);
msg_update(membership);
+ clu_local_nodeid(NULL, &nid);
+ msg_set_nodeid(nid);
memb_resolve_list(membership, NULL);
while(1) {
--- cluster/magma/lib/Attic/magmamsg.h 2004/11/02 20:11:38 1.5
+++ cluster/magma/lib/Attic/magmamsg.h 2007/10/26 20:15:37 1.5.18.1
@@ -22,6 +22,7 @@
#include <magma.h>
int msg_update(cluster_member_list_t *membership);
+int msg_set_nodeid(uint64_t nodeid);
void msg_shutdown(void);
ssize_t msg_receive_timeout(int fd, void *buf, ssize_t count,
unsigned int timeout);
--- cluster/magma/lib/Attic/memberlist.c 2004/11/02 20:11:38 1.6
+++ cluster/magma/lib/Attic/memberlist.c 2007/10/26 20:15:37 1.6.18.1
@@ -234,7 +234,7 @@
{
int x;
- if (!list)
+ if (!list || nodeid == NODE_ID_NONE)
return NULL;
for (x = 0; x < list->cml_count; x++) {
--- cluster/magma/lib/Attic/message.c 2005/04/21 17:28:29 1.9.2.3
+++ cluster/magma/lib/Attic/message.c 2007/10/26 20:15:37 1.9.2.3.10.1
@@ -61,6 +61,7 @@
*/
static pthread_mutex_t ml_mutex = PTHREAD_MUTEX_INITIALIZER;
static cluster_member_list_t *ml_membership;
+static uint64_t _local_id = NODE_ID_NONE;
/* Mutex to prevent
thread1 thread2
@@ -104,6 +105,16 @@
}
+int
+msg_set_nodeid(uint64_t my_node_id)
+{
+ pthread_mutex_lock(&ml_mutex);
+ _local_id = my_node_id;
+ pthread_mutex_unlock(&ml_mutex);
+ return 0;
+}
+
+
/**
Shut down the mssage subsystem. Closes all file descriptors and cleans up
the membership list.
@@ -300,9 +311,12 @@
@see connect_nb, ipv4_connect
*/
static int
-ipv6_connect(struct in6_addr *in6_addr, uint16_t port, int timeout)
+ipv6_connect(struct in6_addr *in6_addr, uint16_t port, int timeout,
+ cluster_member_t *me)
{
struct sockaddr_in6 _sin6;
+ struct sockaddr_in6 srcaddr;
+ struct addrinfo *ai;
int fd, ret;
fd = socket(PF_INET6, SOCK_STREAM, 0);
@@ -315,6 +329,29 @@
_sin6.sin6_flowinfo = 0;
memcpy(&_sin6.sin6_addr, in6_addr, sizeof(_sin6.sin6_addr));
+ if (me) {
+ /* if we know the local node, bind to its resolved
+ interface so other nodes don't reject the connection
+ due to improper source-routing */
+ memset(&srcaddr, 0, sizeof(srcaddr));
+ srcaddr.sin6_family = AF_INET6;
+
+ for (ai = me->cm_addrs; ai; ai = ai->ai_next) {
+ if (ai->ai_family != AF_INET6)
+ continue;
+
+ if (ai->ai_socktype != SOCK_STREAM)
+ continue;
+
+ memcpy(&((struct sockaddr_in6 *)&srcaddr)->sin6_addr,
+ &((struct sockaddr_in6 *)ai->ai_addr)->sin6_addr,
+ sizeof(struct in6_addr));
+
+ bind(fd, (struct sockaddr *)&srcaddr,
+ sizeof(srcaddr));
+ }
+ }
+
ret = connect_nb(fd, (struct sockaddr *)&_sin6, sizeof(_sin6), timeout);
if (ret < 0) {
close(fd);
@@ -335,15 +372,41 @@
@see connect_nb, ipv6_connect
*/
static int
-ipv4_connect(struct in_addr *in_addr, uint16_t port, int timeout)
+ipv4_connect(struct in_addr *in_addr, uint16_t port, int timeout,
+ cluster_member_t *me)
{
struct sockaddr_in _sin;
+ struct sockaddr_in srcaddr;
+ struct addrinfo *ai;
int fd, ret;
fd = socket(PF_INET, SOCK_STREAM, 0);
if (fd < 0)
return -1;
+ if (me) {
+ /* if we know the local node, bind to its resolved
+ interface so other nodes don't reject the connection
+ due to improper source-routing */
+ memset(&srcaddr, 0, sizeof(srcaddr));
+ srcaddr.sin_family = AF_INET;
+
+ for (ai = me->cm_addrs; ai; ai = ai->ai_next) {
+ if (ai->ai_family != AF_INET)
+ continue;
+
+ if (ai->ai_socktype != SOCK_STREAM)
+ continue;
+
+ memcpy(&((struct sockaddr_in *)&srcaddr)->sin_addr,
+ &((struct sockaddr_in *)ai->ai_addr)->sin_addr,
+ sizeof(struct in_addr));
+
+ bind(fd, (struct sockaddr *)&srcaddr,
+ sizeof(srcaddr));
+ }
+ }
+
_sin.sin_family = AF_INET;
_sin.sin_port = htons(port);
memcpy(&_sin.sin_addr, in_addr, sizeof(_sin.sin_addr));
@@ -377,6 +440,7 @@
{
int fd;
cluster_member_t *nodep;
+ cluster_member_t *me;
struct addrinfo *ai;
pthread_mutex_lock(&ml_mutex);
@@ -387,6 +451,10 @@
return -1;
}
+ me = memb_id_to_p(ml_membership, _local_id);
+ if (me)
+ memb_resolve(me);
+
/* Try to resolve if we haven't done so */
if (!nodep->cm_addrs && (memb_resolve(nodep) < 0)) {
pthread_mutex_unlock(&ml_mutex);
@@ -404,7 +472,7 @@
fd = ipv6_connect(
&((struct sockaddr_in6 *)ai->ai_addr)->sin6_addr,
- baseport + IPV6_PORT_OFFSET, timeout);
+ baseport + IPV6_PORT_OFFSET, timeout, me);
if (fd >= 0) {
pthread_mutex_unlock(&ml_mutex);
@@ -428,7 +496,7 @@
fd = ipv4_connect(
&((struct sockaddr_in *)ai->ai_addr)->sin_addr,
- baseport, timeout);
+ baseport, timeout, me );
if (fd >= 0) {
pthread_mutex_unlock(&ml_mutex);
--- cluster/rgmanager/ChangeLog 2007/10/03 21:06:19 1.5.2.32.2.1
+++ cluster/rgmanager/ChangeLog 2007/10/26 20:15:37 1.5.2.32.2.2
@@ -1,3 +1,8 @@
+2007-10-26 Lon Hohberger <lhh@redhat.com>
+ * src/daemons/main.c, src/utils/clustat.c, clusvcadm.c: Call
+ msg_set_nodeid() to ensure we route from the right IP on a
+ host with multiple IPs on our cluster subnet.
+
2007-10-03 Lon hohberger <lhh@redhat.com>
* ChangeLog: Fix dates.
* include/reslist.h: Actually commit fix for #310981
--- cluster/rgmanager/src/daemons/main.c 2007/01/04 15:52:41 1.9.2.22
+++ cluster/rgmanager/src/daemons/main.c 2007/10/26 20:15:37 1.9.2.23
@@ -870,6 +870,7 @@
clu_local_nodeid(NULL, &myNodeID);
set_my_id(myNodeID);
+ msg_set_nodeid(myNodeID);
/*
Initialize the VF stuff.
--- cluster/rgmanager/src/utils/clustat.c 2007/02/06 20:18:48 1.5.2.19
+++ cluster/rgmanager/src/utils/clustat.c 2007/10/26 20:15:37 1.5.2.20
@@ -637,6 +637,7 @@
/* Grab the local node ID and flag it from the list of reported
online nodes */
clu_local_nodeid(NULL, lid);
+ msg_set_nodeid(*lid);
if (!all)
return NULL;
--- cluster/rgmanager/src/utils/clusvcadm.c 2007/01/04 15:52:41 1.2.2.9
+++ cluster/rgmanager/src/utils/clusvcadm.c 2007/10/26 20:15:37 1.2.2.10
@@ -324,6 +324,7 @@
membership = clu_member_list(RG_SERVICE_GROUP);
msg_update(membership);
clu_local_nodeid(RG_SERVICE_GROUP, &me);
+ msg_set_nodeid(me);
if (node_specified) {
msgtarget = memb_name_to_id(membership, nodename);
next reply other threads:[~2007-10-26 20:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-26 20:15 lhh [this message]
-- strict thread matches above, loose matches on Subject: below --
2007-11-07 19:08 [Cluster-devel] cluster ccs/ccs_tool/update.c ccs/daemon/clust lhh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071026201539.8129.qmail@sourceware.org \
--to=lhh@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.