diff options
author | Tristan Ye <tristan.ye@oracle.com> | 2010-08-01 22:00:26 -0400 |
---|---|---|
committer | Joel Becker <joel.becker@oracle.com> | 2010-08-07 13:50:33 -0400 |
commit | 415cf32c9cdfcc60f34d0ac17f29634e941ba7d2 (patch) | |
tree | 56675497e07772f99bd375a9f74542e3a12f2f37 /fs/ocfs2/cluster/tcp.c | |
parent | b11f1f1ab73fd358b1b734a9427744802202ba68 (diff) |
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.
Signed-off-by: Tristan Ye <tristan.ye@oracle.com>
Acked-by: Sunil Mushran <sunil.mushran@oracle.com>
Signed-off-by: Joel Becker <joel.becker@oracle.com>
Diffstat (limited to 'fs/ocfs2/cluster/tcp.c')
-rw-r--r-- | fs/ocfs2/cluster/tcp.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c index aa75ca3f78da..1361997cf205 100644 --- a/fs/ocfs2/cluster/tcp.c +++ b/fs/ocfs2/cluster/tcp.c | |||
@@ -1759,6 +1759,7 @@ static int o2net_accept_one(struct socket *sock) | |||
1759 | struct sockaddr_in sin; | 1759 | struct sockaddr_in sin; |
1760 | struct socket *new_sock = NULL; | 1760 | struct socket *new_sock = NULL; |
1761 | struct o2nm_node *node = NULL; | 1761 | struct o2nm_node *node = NULL; |
1762 | struct o2nm_node *local_node = NULL; | ||
1762 | struct o2net_sock_container *sc = NULL; | 1763 | struct o2net_sock_container *sc = NULL; |
1763 | struct o2net_node *nn; | 1764 | struct o2net_node *nn; |
1764 | 1765 | ||
@@ -1796,11 +1797,15 @@ static int o2net_accept_one(struct socket *sock) | |||
1796 | goto out; | 1797 | goto out; |
1797 | } | 1798 | } |
1798 | 1799 | ||
1799 | if (o2nm_this_node() > node->nd_num) { | 1800 | if (o2nm_this_node() >= node->nd_num) { |
1800 | mlog(ML_NOTICE, "unexpected connect attempted from a lower " | 1801 | local_node = o2nm_get_node_by_num(o2nm_this_node()); |
1801 | "numbered node '%s' at " "%pI4:%d with num %u\n", | 1802 | mlog(ML_NOTICE, "unexpected connect attempt seen at node '%s' (" |
1802 | node->nd_name, &sin.sin_addr.s_addr, | 1803 | "%u, %pI4:%d) from node '%s' (%u, %pI4:%d)\n", |
1803 | ntohs(sin.sin_port), node->nd_num); | 1804 | local_node->nd_name, local_node->nd_num, |
1805 | &(local_node->nd_ipv4_address), | ||
1806 | ntohs(local_node->nd_ipv4_port), | ||
1807 | node->nd_name, node->nd_num, &sin.sin_addr.s_addr, | ||
1808 | ntohs(sin.sin_port)); | ||
1804 | ret = -EINVAL; | 1809 | ret = -EINVAL; |
1805 | goto out; | 1810 | goto out; |
1806 | } | 1811 | } |
@@ -1857,6 +1862,8 @@ out: | |||
1857 | sock_release(new_sock); | 1862 | sock_release(new_sock); |
1858 | if (node) | 1863 | if (node) |
1859 | o2nm_node_put(node); | 1864 | o2nm_node_put(node); |
1865 | if (local_node) | ||
1866 | o2nm_node_put(local_node); | ||
1860 | if (sc) | 1867 | if (sc) |
1861 | sc_put(sc); | 1868 | sc_put(sc); |
1862 | return ret; | 1869 | return ret; |