Skip to content

Commit b7668c7

Browse files
Sunil MushranMark Fasheh
authored andcommitted
[PATCH] ocfs2: added source addr to bind() in o2net_start_connect()
to prevent confusion when a virtual ip is created on the same interface Signed-off-by: Sunil Mushran <sunil.mushran@oracle.com> Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>
1 parent 110ba90 commit b7668c7

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

‎fs/ocfs2/cluster/tcp.c‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,7 +1318,7 @@ static void o2net_start_connect(void *arg)
13181318
{
13191319
struct o2net_node *nn = arg;
13201320
struct o2net_sock_container *sc = NULL;
1321-
struct o2nm_node *node = NULL;
1321+
struct o2nm_node *node = NULL, *mynode = NULL;
13221322
struct socket *sock = NULL;
13231323
struct sockaddr_in myaddr = {0, }, remoteaddr = {0, };
13241324
int ret = 0;
@@ -1334,6 +1334,12 @@ static void o2net_start_connect(void *arg)
13341334
goto out;
13351335
}
13361336

1337+
mynode = o2nm_get_node_by_num(o2nm_this_node());
1338+
if (mynode == NULL) {
1339+
ret = 0;
1340+
goto out;
1341+
}
1342+
13371343
spin_lock(&nn->nn_lock);
13381344
/* see if we already have one pending or have given up */
13391345
if (nn->nn_sc || nn->nn_persistent_error)
@@ -1361,12 +1367,14 @@ static void o2net_start_connect(void *arg)
13611367
sock->sk->sk_allocation = GFP_ATOMIC;
13621368

13631369
myaddr.sin_family = AF_INET;
1370+
myaddr.sin_addr.s_addr = (__force u32)mynode->nd_ipv4_address;
13641371
myaddr.sin_port = (__force u16)htons(0); /* any port */
13651372

13661373
ret = sock->ops->bind(sock, (struct sockaddr *)&myaddr,
13671374
sizeof(myaddr));
13681375
if (ret) {
1369-
mlog(0, "bind failed: %d\n", ret);
1376+
mlog(ML_ERROR, "bind failed with %d at address %u.%u.%u.%u\n",
1377+
ret, NIPQUAD(mynode->nd_ipv4_address));
13701378
goto out;
13711379
}
13721380

@@ -1407,6 +1415,8 @@ static void o2net_start_connect(void *arg)
14071415
sc_put(sc);
14081416
if (node)
14091417
o2nm_node_put(node);
1418+
if (mynode)
1419+
o2nm_node_put(mynode);
14101420

14111421
return;
14121422
}

0 commit comments

Comments
 (0)