summaryrefslogtreecommitdiffstats
path: root/sbin/hastd/primary.c
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2011-03-21 08:54:59 +0000
committerpjd <pjd@FreeBSD.org>2011-03-21 08:54:59 +0000
commit3420a736119b646db3defc2c3e24d534e35d73a0 (patch)
treec174097a26c9fb50392210eb339837c6cf4e95d9 /sbin/hastd/primary.c
parentee6f63ce1774533a3602145d9627d54d14d70769 (diff)
downloadFreeBSD-src-3420a736119b646db3defc2c3e24d534e35d73a0.zip
FreeBSD-src-3420a736119b646db3defc2c3e24d534e35d73a0.tar.gz
In hast.conf we define the other node's address in 'remote' variable.
This way we know how to connect to secondary node when we are primary. The same variable is used by the secondary node - it only accepts connections from the address stored in 'remote' variable. In cluster configurations it is common that each node has its individual IP address and there is one addtional shared IP address which is assigned to primary node. It seems it is possible that if the shared IP address is from the same network as the individual IP address it might be choosen by the kernel as a source address for connection with the secondary node. Such connection will be rejected by secondary, as it doesn't come from primary node individual IP. Add 'source' variable that allows to specify source IP address we want to bind to before connecting to the secondary node. MFC after: 1 week
Diffstat (limited to 'sbin/hastd/primary.c')
-rw-r--r--sbin/hastd/primary.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/sbin/hastd/primary.c b/sbin/hastd/primary.c
index c9266e5..8beba48 100644
--- a/sbin/hastd/primary.c
+++ b/sbin/hastd/primary.c
@@ -86,7 +86,7 @@ struct hio {
*/
int *hio_errors;
/*
- * Structure used to comunicate with GEOM Gate class.
+ * Structure used to communicate with GEOM Gate class.
*/
struct g_gate_ctl_io hio_ggio;
TAILQ_ENTRY(hio) *hio_next;
@@ -808,7 +808,7 @@ hastd_primary(struct hast_resource *res)
* Create communication channel for sending control commands from
* parent to child.
*/
- if (proto_client("socketpair://", &res->hr_ctrl) < 0) {
+ if (proto_client(NULL, "socketpair://", &res->hr_ctrl) < 0) {
/* TODO: There's no need for this to be fatal error. */
KEEP_ERRNO((void)pidfile_remove(pfh));
pjdlog_exit(EX_OSERR,
@@ -817,7 +817,7 @@ hastd_primary(struct hast_resource *res)
/*
* Create communication channel for sending events from child to parent.
*/
- if (proto_client("socketpair://", &res->hr_event) < 0) {
+ if (proto_client(NULL, "socketpair://", &res->hr_event) < 0) {
/* TODO: There's no need for this to be fatal error. */
KEEP_ERRNO((void)pidfile_remove(pfh));
pjdlog_exit(EX_OSERR,
@@ -827,7 +827,7 @@ hastd_primary(struct hast_resource *res)
* Create communication channel for sending connection requests from
* child to parent.
*/
- if (proto_client("socketpair://", &res->hr_conn) < 0) {
+ if (proto_client(NULL, "socketpair://", &res->hr_conn) < 0) {
/* TODO: There's no need for this to be fatal error. */
KEEP_ERRNO((void)pidfile_remove(pfh));
pjdlog_exit(EX_OSERR,
@@ -1918,6 +1918,7 @@ primary_config_reload(struct hast_resource *res, struct nv *nv)
PJDLOG_ASSERT(res->hr_role == HAST_ROLE_PRIMARY);
PJDLOG_ASSERT(gres == res);
nv_assert(nv, "remoteaddr");
+ nv_assert(nv, "sourceaddr");
nv_assert(nv, "replication");
nv_assert(nv, "checksum");
nv_assert(nv, "compression");
@@ -1927,11 +1928,12 @@ primary_config_reload(struct hast_resource *res, struct nv *nv)
ncomps = HAST_NCOMPONENTS;
#define MODIFIED_REMOTEADDR 0x01
-#define MODIFIED_REPLICATION 0x02
-#define MODIFIED_CHECKSUM 0x04
-#define MODIFIED_COMPRESSION 0x08
-#define MODIFIED_TIMEOUT 0x10
-#define MODIFIED_EXEC 0x20
+#define MODIFIED_SOURCEADDR 0x02
+#define MODIFIED_REPLICATION 0x04
+#define MODIFIED_CHECKSUM 0x08
+#define MODIFIED_COMPRESSION 0x10
+#define MODIFIED_TIMEOUT 0x20
+#define MODIFIED_EXEC 0x40
modified = 0;
vstr = nv_get_string(nv, "remoteaddr");
@@ -1943,6 +1945,11 @@ primary_config_reload(struct hast_resource *res, struct nv *nv)
*/
modified |= MODIFIED_REMOTEADDR;
}
+ vstr = nv_get_string(nv, "sourceaddr");
+ if (strcmp(gres->hr_sourceaddr, vstr) != 0) {
+ strlcpy(gres->hr_sourceaddr, vstr, sizeof(gres->hr_sourceaddr));
+ modified |= MODIFIED_SOURCEADDR;
+ }
vint = nv_get_int32(nv, "replication");
if (gres->hr_replication != vint) {
gres->hr_replication = vint;
@@ -1974,7 +1981,8 @@ primary_config_reload(struct hast_resource *res, struct nv *nv)
* Don't bother if we need to reconnect.
*/
if ((modified & MODIFIED_TIMEOUT) != 0 &&
- (modified & (MODIFIED_REMOTEADDR | MODIFIED_REPLICATION)) == 0) {
+ (modified & (MODIFIED_REMOTEADDR | MODIFIED_SOURCEADDR |
+ MODIFIED_REPLICATION)) == 0) {
for (ii = 0; ii < ncomps; ii++) {
if (!ISREMOTE(ii))
continue;
@@ -1996,7 +2004,8 @@ primary_config_reload(struct hast_resource *res, struct nv *nv)
}
}
}
- if ((modified & (MODIFIED_REMOTEADDR | MODIFIED_REPLICATION)) != 0) {
+ if ((modified & (MODIFIED_REMOTEADDR | MODIFIED_SOURCEADDR |
+ MODIFIED_REPLICATION)) != 0) {
for (ii = 0; ii < ncomps; ii++) {
if (!ISREMOTE(ii))
continue;
@@ -2009,6 +2018,7 @@ primary_config_reload(struct hast_resource *res, struct nv *nv)
}
}
#undef MODIFIED_REMOTEADDR
+#undef MODIFIED_SOURCEADDR
#undef MODIFIED_REPLICATION
#undef MODIFIED_CHECKSUM
#undef MODIFIED_COMPRESSION
OpenPOWER on IntegriCloud