Commit ab81afd3 authored by Sunil Mushran's avatar Sunil Mushran Committed by Mark Fasheh

ocfs2: Binds listener to the configured ip address

This patch binds the o2net listener to the configured ip address
instead of INADDR_ANY for security. Fixes oss.oracle.com bugzilla#814.
Signed-off-by: default avatarSunil Mushran <sunil.mushran@oracle.com>
Signed-off-by: default avatarMark Fasheh <mark.fasheh@oracle.com>
parent 3b8118cf
...@@ -1805,13 +1805,13 @@ static void o2net_listen_data_ready(struct sock *sk, int bytes) ...@@ -1805,13 +1805,13 @@ static void o2net_listen_data_ready(struct sock *sk, int bytes)
ready(sk, bytes); ready(sk, bytes);
} }
static int o2net_open_listening_sock(__be16 port) static int o2net_open_listening_sock(__be32 addr, __be16 port)
{ {
struct socket *sock = NULL; struct socket *sock = NULL;
int ret; int ret;
struct sockaddr_in sin = { struct sockaddr_in sin = {
.sin_family = PF_INET, .sin_family = PF_INET,
.sin_addr = { .s_addr = (__force u32)htonl(INADDR_ANY) }, .sin_addr = { .s_addr = (__force u32)addr },
.sin_port = (__force u16)port, .sin_port = (__force u16)port,
}; };
...@@ -1834,15 +1834,15 @@ static int o2net_open_listening_sock(__be16 port) ...@@ -1834,15 +1834,15 @@ static int o2net_open_listening_sock(__be16 port)
sock->sk->sk_reuse = 1; sock->sk->sk_reuse = 1;
ret = sock->ops->bind(sock, (struct sockaddr *)&sin, sizeof(sin)); ret = sock->ops->bind(sock, (struct sockaddr *)&sin, sizeof(sin));
if (ret < 0) { if (ret < 0) {
mlog(ML_ERROR, "unable to bind socket to port %d, ret=%d\n", mlog(ML_ERROR, "unable to bind socket at %u.%u.%u.%u:%u, "
ntohs(port), ret); "ret=%d\n", NIPQUAD(addr), ntohs(port), ret);
goto out; goto out;
} }
ret = sock->ops->listen(sock, 64); ret = sock->ops->listen(sock, 64);
if (ret < 0) { if (ret < 0) {
mlog(ML_ERROR, "unable to listen on port %d, ret=%d\n", mlog(ML_ERROR, "unable to listen on %u.%u.%u.%u:%u, ret=%d\n",
ntohs(port), ret); NIPQUAD(addr), ntohs(port), ret);
} }
out: out:
...@@ -1875,7 +1875,8 @@ int o2net_start_listening(struct o2nm_node *node) ...@@ -1875,7 +1875,8 @@ int o2net_start_listening(struct o2nm_node *node)
return -ENOMEM; /* ? */ return -ENOMEM; /* ? */
} }
ret = o2net_open_listening_sock(node->nd_ipv4_port); ret = o2net_open_listening_sock(node->nd_ipv4_address,
node->nd_ipv4_port);
if (ret) { if (ret) {
destroy_workqueue(o2net_wq); destroy_workqueue(o2net_wq);
o2net_wq = NULL; o2net_wq = NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment