cluster: RHEL55 - fence: Allow IP addresses as node names

Christine Caulfield chrissie at fedoraproject.org
Tue Oct 6 08:11:47 UTC 2009


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=d3557114c74a96710e0612fb1aed77513835ee90
Commit:        d3557114c74a96710e0612fb1aed77513835ee90
Parent:        1c038cf24c960ffb1d2d9ec40ddbe1a688ed5e07
Author:        Christine Caulfield <ccaulfie at redhat.com>
AuthorDate:    Thu Jun 4 16:55:39 2009 +0100
Committer:     Christine Caulfield <ccaulfie at redhat.com>
CommitterDate: Tue Oct 6 08:57:13 2009 +0100

fence: Allow IP addresses as node names

When checking if a node is a member of the cluster, fenced does a full-string
check of the name. If that doesn't match it then assumes that one of the
names is a FQDN and one is truncated so it starts checking the bit before the
first dot.

If the node names are IP addresses then this will match all of the time for
most clusters. eg: 192.168.2.1 will match 192.168.2.2 because it just
matches the 192. This makes fenced think that the node has rejoined the cluster
because it sees the name in the list of active nodes, and won't fence it.

This patch abandons the match check afer the full-string one if the node
name is found to be an IP address.

bz#504158

Signed-off-by: Christine Caulfield <ccaulfie at redhat.com>
---
 fence/fenced/member_cman.c |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/fence/fenced/member_cman.c b/fence/fenced/member_cman.c
index 3994283..9e22ece 100644
--- a/fence/fenced/member_cman.c
+++ b/fence/fenced/member_cman.c
@@ -1,7 +1,7 @@
 /******************************************************************************
 *******************************************************************************
 **
-**  Copyright (C) 2005 Red Hat, Inc.  All rights reserved.
+**  Copyright (C) 2005-2009 Red Hat, Inc.  All rights reserved.
 **
 **  This copyrighted material is made available to anyone wishing to use,
 **  modify, copy, or redistribute it subject to the terms and conditions
@@ -11,6 +11,7 @@
 ******************************************************************************/
 
 #include <libcman.h>
+#include <arpa/inet.h>
 #include "fd.h"
 
 #define BUFLEN		128
@@ -30,6 +31,7 @@ int			our_nodeid;
 static int name_equal(char *name1, char *name2)
 {
 	char name3[BUFLEN], name4[BUFLEN];
+	char addr1[INET6_ADDRSTRLEN];
 	int i, len1, len2;
 
 	len1 = strlen(name1);
@@ -38,6 +40,16 @@ static int name_equal(char *name1, char *name2)
 	if (len1 == len2 && !strncmp(name1, name2, len1))
 		return TRUE;
 
+	/*
+	 * If the names are IP addresses then don't compare
+	 * what is in front of the dots.
+	 */
+	if (inet_pton(AF_INET, name1, addr1) == 0)
+		return FALSE;
+
+	if (inet_pton(AF_INET6, name1, addr1) == 0)
+		return FALSE;
+
 	memset(name3, 0, BUFLEN);
 	memset(name4, 0, BUFLEN);
 


More information about the cluster-commits mailing list