[PATCH] Enable TruCluster support in interfaces.c
Tobias Burnus
tobias.burnus at physik.fu-berlin.de
Sun Aug 19 14:31:42 GMT 2001
Hi,
this patch enables Samba on a Compaq Tru64 Unix 5.x TrueCluster to
optain the IP of the Cluster.
Without this patch Samba uses the IP of the Cluster Member which makes
fail-over difficult. (That is if the Samba-serving cluster member goes
down, the requests to the cluster won't automatically answered by the
other member which takes over.)
Implementational Details:
On all OSF1/Digital Unix/Compaq Tru64Unix computer, running version 5.0
or higher of the operating system there exists "clu_is_member()" in
libc.so which returns either TRUE or FALSE depending whether this system
is a node in a TrueCluster or not.
Systems which can run as TrueClusters have an extra library called
libclua.so which provides additional functions to do
"clua_getaliasaddress" etc. In order to make linking possible on systems
which are not TruClusters and to use these binaries also on TruClusters,
we load the library on demand.
This causes Problems by the linker so we presently use:
"-expect_unresolved \*clua\*" as commandline to the Digital ld (this is
also an option to CC such as in DEC_CC='-DTruCluster -expect_unresolved
*clua*')
TODO:
-----
1. The TruCluster option must be set using configure.in -- either by
automatical testing (e.g. existance clu_is_member()) or by an extra option.
2. On needs to take care of the linker, for the Digital linker ld this
is not a problem, but for the GNU ld must be found a solution.
The patch was developed by Wolfram Klaus.
With warm regards,
Tobias
--
This above all: To thine own self be true / And it must follow as
the night the day / Thou canst not then be false to any man.
-------------- next part --------------
Index: interfaces.c
===================================================================
RCS file: /cvsroot/samba/source/lib/interfaces.c,v
retrieving revision 1.3
diff -u -r1.3 interfaces.c
--- interfaces.c 14 Jan 2000 01:41:03 -0000 1.3
+++ interfaces.c 19 Aug 2001 14:10:18 -0000
@@ -79,6 +79,27 @@
#define QSORT_CAST (int (*)(const void *, const void *))
#endif
+#ifdef TruCluster
+#include <sys/clu.h>
+#include <clua/clua.h>
+#include <dlfcn.h>
+struct in_addr find_cluster_nmask(struct in_addr ip1,
+ struct iface_struct *ifaces,
+ int total)
+{
+ uint i,net1,net2,nmask;
+ net1 = ntohl(ip1.s_addr);
+
+ for (i=0; i<total; i++)
+ {
+ nmask = ntohl(ifaces[i].netmask.s_addr);
+ net2 = ntohl(ifaces[i].ip.s_addr);
+ if ((net1 & nmask) == (net2 & nmask))
+ return ifaces[i].netmask;
+ }
+}
+#endif
+
#if HAVE_IFACE_IFCONF
/* this works for Linux 2.2, Solaris 2.5, SunOS4, HPUX 10.20, OSF1
@@ -148,6 +169,42 @@
close(fd);
+#ifdef TruCluster
+
+ if (clu_is_member())
+ {
+ int context=0;
+ struct clua_info outbuf;
+ clua_status_t result1, result2;
+ struct sockaddr addr;
+ void *handle;
+
+ handle=dlopen("libclua.so", RTLD_LAZY);
+
+ while ((result1=clua_getaliasaddress(&addr,
+ &context)) == CLUA_SUCCESS)
+ {
+ if ((result2=clua_getaliasinfo(&addr,
+ &outbuf)) == CLUA_SUCCESS)
+ {
+ sprintf(ifaces[total].name,"clu%d", outbuf.aliasid);
+ ifaces[total].ip=outbuf.addr;
+ ifaces[total].netmask=find_cluster_nmask(outbuf.addr,
+ ifaces,
+ total);
+ total++;
+ }
+ else {
+ print_clua_liberror(result2);
+ break;
+ }
+ }
+ if (result1 != CLUA_SUCCESS && result1 != CLUA_NOMOREALIASES)
+ print_clua_liberror(result1);
+ dlclose(handle);
+ }
+
+#endif
return total;
}
More information about the samba-technical
mailing list