[Openais] openais netmask and its relationship to how Totem binds
to NICs
Angus Salkeld
ahsalkeld at gmail.com
Fri Apr 27 02:23:50 PDT 2007
Hi
Here is a little patch I used to figure this out the first time.
It might be useful to others...
If the netmask is not quite right it logs it (you could log a more
useful message).
-Angus
Index: exec/totemip.c
===================================================================
--- exec/totemip.c (revision 1369)
+++ exec/totemip.c (working copy)
@@ -80,6 +80,7 @@
#endif
#include "totemip.h"
+#include "print.h"
#include "swab.h"
#define LOCALHOST_IPV4 "127.0.0.1"
@@ -552,14 +553,23 @@
if (!found_if && tb[IFA_BROADCAST] && ifa->ifa_family == AF_INET) {
uint32_t network;
uint32_t addr;
+ uint32_t addr_cmp;
uint32_t netmask = htonl(~((1<<(32-ifa->ifa_prefixlen))-1));
+ char buf[INET_ADDRSTRLEN];
+ char buf2[INET_ADDRSTRLEN];
memcpy(&network, RTA_DATA(tb[IFA_BROADCAST]), sizeof(uint32_t));
memcpy(&addr, bindnet->addr, sizeof(uint32_t));
+ addr_cmp = (network & netmask);
- if (addr == (network & netmask)) {
+ if (addr == addr_cmp) {
memcpy(ipaddr.addr, RTA_DATA(tb[IFA_ADDRESS]), TOTEMIP_ADDRLEN);
found_if = 1;
+ } else if (addr_cmp == (addr & netmask)) {
+ log_printf(LOG_LEVEL_ALERT,
+ "Re-check your network addresses: totem ip(%s) interface
ip(%s)\n",
+ inet_ntop(AF_INET, &addr, buf, sizeof(buf)),
+ inet_ntop(AF_INET, &addr_cmp, buf2, sizeof(buf2)));
}
}
More information about the Openais
mailing list