Skip to contentSkip to conversation

O2net: Disallow o2net accept connection request from itself.

PATCH New Tristan Ye 2 participants 3 messages Jul 29, 2010 – Jul 30, 2010 OCFS2

lore
Share & tools
lore

Tristan Ye

author
#0 lore raw

PATCH 1/1 O2net: Disallow o2net accept connection request from itself.

Currently, o2net_accept_one() is allowed to accept a connection from listening node itself, such a fake connection will not be successfully established due to no handshake detected afterwards, and later end up with triggering connecting worker in a loop.

We're going to fix this by treating such connection request as 'invalid', since we've got no chance of requesting connection from a node to itself in a OCFS2 cluster.

The fix doesn't hurt user's scan for o2net-listener, it always gets a successful connection from userpace.

---
 fs/ocfs2/cluster/tcp.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
fs/ocfs2/cluster/tcp.c +2 -2
index aa75ca3..7e4e451 100644
@@ -1796,9 +1796,9 @@ static int o2net_accept_one(struct socket *sock)
 		goto out;
 	}
 
-	if (o2nm_this_node() > node->nd_num) {
+	if (o2nm_this_node() >= node->nd_num) {
 		mlog(ML_NOTICE, "unexpected connect attempted from a lower "
-		     "numbered node '%s' at " "%pI4:%d with num %u\n",
+		     "or same numbered node '%s' at " "%pI4:%d with num %u\n",
 		     node->nd_name, &sin.sin_addr.s_addr,
 		     ntohs(sin.sin_port), node->nd_num);
 		ret = -EINVAL;
Signature · 1 line
1.5.5
#1 lore raw

PATCH 1/1 O2net: Disallow o2net accept connection request from itself.

unexpected connect attempt seen at node x (num, ip:port) from node y (num, ip:port).

The above reads better, don't you think. Lower or same are software bugs. Not a user error.

Btw, one test you could do is race nc with mount. Run nc in a loop while mounting the first device. nc should ping a node that has it mounted. Test with higher to lower and reverse.

Quoted 41 lines · Tristan Ye

Currently, o2net_accept_one() is allowed to accept a connection from listening node itself, such a fake connection will not be successfully established due to no handshake detected afterwards, and later end up with triggering connecting worker in a loop.

We're going to fix this by treating such connection request as 'invalid', since we've got no chance of requesting connection from a node to itself in a OCFS2 cluster.

The fix doesn't hurt user's scan for o2net-listener, it always gets a successful connection from userpace.

---
fs/ocfs2/cluster/tcp.c | 4 ++--

1 files changed, 2 insertions(+), 2 deletions(-)
fs/ocfs2/cluster/tcp.c +2 -2
index aa75ca3..7e4e451 100644
@@ -1796,9 +1796,9 @@ static int o2net_accept_one(struct socket *sock)
       goto out;
   }
 
-    if (o2nm_this_node() > node->nd_num) {
+    if (o2nm_this_node() >= node->nd_num) {
       mlog(ML_NOTICE, "unexpected connect attempted from a lower "
-             "numbered node '%s' at " "%pI4:%d with num %u\n",
+             "or same numbered node '%s' at " "%pI4:%d with num %u\n",
            node->nd_name, &sin.sin_addr.s_addr,
            ntohs(sin.sin_port), node->nd_num);
       ret = -EINVAL;
Signature · 7 lines
1.5.5


_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel at oss.oracle.com
http://oss.oracle.com/mailman/listinfo/ocfs2-devel
author
#2 lore raw

PATCH 1/1 O2net: Disallow o2net accept connection request from itself.

Quoted 3 lines · Sunil Mushran

unexpected connect attempt seen at node x (num, ip:port) from node y (num, ip:port).

The above reads better, don't you think. Lower or same are software bugs. Not a user error.

That makes sense.

Quoted 2 lines

Btw, one test you could do is race nc with mount. Run nc in a loop while mounting the first device. nc should ping a node that has it mounted. Test with higher to lower and reverse.

Yeah, to stress and race nc with mount is a good way to test o2net's listening function.

Quoted 44 lines · Tristan Ye
Quoted 42 lines

Currently, o2net_accept_one() is allowed to accept a connection from listening node itself, such a fake connection will not be successfully established due to no handshake detected afterwards, and later end up with triggering connecting worker in a loop.

We're going to fix this by treating such connection request as 'invalid', since we've got no chance of requesting connection from a node to itself in a OCFS2 cluster.

The fix doesn't hurt user's scan for o2net-listener, it always gets a successful connection from userpace.

---
fs/ocfs2/cluster/tcp.c | 4 ++--

1 files changed, 2 insertions(+), 2 deletions(-)
fs/ocfs2/cluster/tcp.c +2 -2
index aa75ca3..7e4e451 100644
@@ -1796,9 +1796,9 @@ static int o2net_accept_one(struct socket *sock)
       goto out;
   }
 
-    if (o2nm_this_node() > node->nd_num) {
+    if (o2nm_this_node() >= node->nd_num) {
       mlog(ML_NOTICE, "unexpected connect attempted from a lower "
-             "numbered node '%s' at " "%pI4:%d with num %u\n",
+             "or same numbered node '%s' at " "%pI4:%d with num %u\n",
            node->nd_name, &sin.sin_addr.s_addr,
            ntohs(sin.sin_port), node->nd_num);
       ret = -EINVAL;
Signature · 7 lines
1.5.5


_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel at oss.oracle.com
http://oss.oracle.com/mailman/listinfo/ocfs2-devel