O2net: Disallow o2net accept connection request from itself.
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 | 17 ++++++++++++----- 1 files changed, 12 insertions(+), 5 deletions(-)
fs/ocfs2/cluster/tcp.c +12 -5
@@ -1759,6 +1759,7 @@ static int o2net_accept_one(struct socket *sock)struct sockaddr_in sin;struct socket *new_sock =NULL ;struct o2nm_node *node =NULL ; +struct o2nm_node *local_node =NULL ;struct o2net_sock_container *sc =NULL ;struct o2net_node *nn;
@@ -1796,11 +1797,15 @@ static int o2net_accept_one(struct socket *sock) goto out; } -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" , - node->nd_name, &sin.sin_addr.s_addr, -ntohs (sin.sin_port), node->nd_num); +if (o2nm_this_node () >= node->nd_num) { + local_node =o2nm_get_node_by_num (o2nm_this_node ()); +mlog (ML_NOTICE ,"unexpected connect attempt seen at node '%s' (" +"%u, %pI4:%d) from node '%s' (%u, %pI4:%d)\n" , + local_node->nd_name, local_node->nd_num, + &(local_node->nd_ipv4_address), +ntohs (local_node->nd_ipv4_port), + node->nd_name, node->nd_num, &sin.sin_addr.s_addr, +ntohs (sin.sin_port)); ret = -EINVAL ; goto out; }
@@ -1857,6 +1862,8 @@ out:sock_release (new_sock);if (node)o2nm_node_put (node); +if (local_node) +o2nm_node_put (local_node);if (sc)sc_put (sc);return ret;
Signature · 1 line
1.5.5
PATCH 1/1 O2net: Disallow o2net accept connection request from itself.
Acked
Quoted 68 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.
Signed-off-by Tristan Ye <[email protected]>Acked-by Sunil Mushran <[email protected]>---
fs/ocfs2/cluster/tcp.c| 17 ++++++++++++-----1 files changed, 12 insertions(+), 5 deletions(-)fs/ocfs2/cluster/tcp.c +12
-5@@ -1759,6 +1759,7 @@ static int o2net_accept_one(struct socket *sock)struct sockaddr_in sin;struct socket *new_sock =NULL ;struct o2nm_node *node =NULL ; +struct o2nm_node *local_node =NULL ;struct o2net_sock_container *sc =NULL ;struct o2net_node *nn;@@ -1796,11 +1797,15 @@ static int o2net_accept_one(struct socket *sock) goto out; } -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" , - node->nd_name, &sin.sin_addr.s_addr, -ntohs (sin.sin_port), node->nd_num); +if (o2nm_this_node () >= node->nd_num) { + local_node =o2nm_get_node_by_num (o2nm_this_node ()); +mlog (ML_NOTICE ,"unexpected connect attempt seen at node '%s' (" +"%u, %pI4:%d) from node '%s' (%u, %pI4:%d)\n" , + local_node->nd_name, local_node->nd_num, + &(local_node->nd_ipv4_address), +ntohs (local_node->nd_ipv4_port), + node->nd_name, node->nd_num, &sin.sin_addr.s_addr, +ntohs (sin.sin_port)); ret = -EINVAL ; goto out; }@@ -1857,6 +1862,8 @@ out:sock_release (new_sock);if (node)o2nm_node_put (node); +if (local_node) +o2nm_node_put (local_node);if (sc)sc_put (sc);return ret;Signature · 7 lines
1.5.5 _______________________________________________ Ocfs2-devel mailing list Ocfs2-devel at oss.oracle.com http://oss.oracle.com/mailman/listinfo/ocfs2-devel
PATCH 1/1 O2net: Disallow o2net accept connection request from itself.
In reply to Tristan YeQuoted 9 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.
Quoted 5 lines
The fix doesn't hurt user's scan for o2net-listener, it always gets a successful connection from userpace.
Signed-off-by Tristan Ye <[email protected]>Acked-by Sunil Mushran <[email protected]>
This patch is now in the fixes branch of ocfs2.git.
Joel
Signature · 9 lines
"There are only two ways to live your life. One is as though nothing
is a miracle. The other is as though everything is a miracle."
- Albert Einstein
Joel Becker
Consulting Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127