Commit 3735b4b9 authored by Bob Peterson's avatar Bob Peterson Committed by David Teigland

dlm: don't save callbacks after accept

When DLM calls accept() on a socket, the comm code copies the sk
after we've saved its callbacks. Afterward, it calls add_sock which
saves the callbacks a second time. Since the error reporting function
lowcomms_error_report calls the previous callback too, this results
in a recursive call to itself. This patch adds a new parameter to
function add_sock to tell whether to save the callbacks. Function
tcp_accept_from_sock (and its sctp counterpart) then calls it with
false to avoid the recursion.
Signed-off-by: default avatarBob Peterson <rpeterso@redhat.com>
Signed-off-by: default avatarDavid Teigland <teigland@redhat.com>
parent 7963b8a5
...@@ -541,7 +541,7 @@ static void restore_callbacks(struct connection *con, struct sock *sk) ...@@ -541,7 +541,7 @@ static void restore_callbacks(struct connection *con, struct sock *sk)
} }
/* Make a socket active */ /* Make a socket active */
static void add_sock(struct socket *sock, struct connection *con) static void add_sock(struct socket *sock, struct connection *con, bool save_cb)
{ {
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
...@@ -549,7 +549,7 @@ static void add_sock(struct socket *sock, struct connection *con) ...@@ -549,7 +549,7 @@ static void add_sock(struct socket *sock, struct connection *con)
con->sock = sock; con->sock = sock;
sk->sk_user_data = con; sk->sk_user_data = con;
if (!test_bit(CF_IS_OTHERCON, &con->flags)) if (save_cb)
save_callbacks(con, sk); save_callbacks(con, sk);
/* Install a data_ready callback */ /* Install a data_ready callback */
sk->sk_data_ready = lowcomms_data_ready; sk->sk_data_ready = lowcomms_data_ready;
...@@ -806,7 +806,7 @@ static int tcp_accept_from_sock(struct connection *con) ...@@ -806,7 +806,7 @@ static int tcp_accept_from_sock(struct connection *con)
newcon->othercon = othercon; newcon->othercon = othercon;
othercon->sock = newsock; othercon->sock = newsock;
newsock->sk->sk_user_data = othercon; newsock->sk->sk_user_data = othercon;
add_sock(newsock, othercon); add_sock(newsock, othercon, false);
addcon = othercon; addcon = othercon;
} }
else { else {
...@@ -819,7 +819,10 @@ static int tcp_accept_from_sock(struct connection *con) ...@@ -819,7 +819,10 @@ static int tcp_accept_from_sock(struct connection *con)
else { else {
newsock->sk->sk_user_data = newcon; newsock->sk->sk_user_data = newcon;
newcon->rx_action = receive_from_sock; newcon->rx_action = receive_from_sock;
add_sock(newsock, newcon); /* accept copies the sk after we've saved the callbacks, so we
don't want to save them a second time or comm errors will
result in calling sk_error_report recursively. */
add_sock(newsock, newcon, false);
addcon = newcon; addcon = newcon;
} }
...@@ -919,7 +922,7 @@ static int sctp_accept_from_sock(struct connection *con) ...@@ -919,7 +922,7 @@ static int sctp_accept_from_sock(struct connection *con)
newcon->othercon = othercon; newcon->othercon = othercon;
othercon->sock = newsock; othercon->sock = newsock;
newsock->sk->sk_user_data = othercon; newsock->sk->sk_user_data = othercon;
add_sock(newsock, othercon); add_sock(newsock, othercon, false);
addcon = othercon; addcon = othercon;
} else { } else {
printk("Extra connection from node %d attempted\n", nodeid); printk("Extra connection from node %d attempted\n", nodeid);
...@@ -930,7 +933,7 @@ static int sctp_accept_from_sock(struct connection *con) ...@@ -930,7 +933,7 @@ static int sctp_accept_from_sock(struct connection *con)
} else { } else {
newsock->sk->sk_user_data = newcon; newsock->sk->sk_user_data = newcon;
newcon->rx_action = receive_from_sock; newcon->rx_action = receive_from_sock;
add_sock(newsock, newcon); add_sock(newsock, newcon, false);
addcon = newcon; addcon = newcon;
} }
...@@ -1058,7 +1061,7 @@ static void sctp_connect_to_sock(struct connection *con) ...@@ -1058,7 +1061,7 @@ static void sctp_connect_to_sock(struct connection *con)
sock->sk->sk_user_data = con; sock->sk->sk_user_data = con;
con->rx_action = receive_from_sock; con->rx_action = receive_from_sock;
con->connect_action = sctp_connect_to_sock; con->connect_action = sctp_connect_to_sock;
add_sock(sock, con); add_sock(sock, con, true);
/* Bind to all addresses. */ /* Bind to all addresses. */
if (sctp_bind_addrs(con, 0)) if (sctp_bind_addrs(con, 0))
...@@ -1146,7 +1149,7 @@ static void tcp_connect_to_sock(struct connection *con) ...@@ -1146,7 +1149,7 @@ static void tcp_connect_to_sock(struct connection *con)
sock->sk->sk_user_data = con; sock->sk->sk_user_data = con;
con->rx_action = receive_from_sock; con->rx_action = receive_from_sock;
con->connect_action = tcp_connect_to_sock; con->connect_action = tcp_connect_to_sock;
add_sock(sock, con); add_sock(sock, con, true);
/* Bind to our cluster-known address connecting to avoid /* Bind to our cluster-known address connecting to avoid
routing problems */ routing problems */
...@@ -1366,7 +1369,7 @@ static int tcp_listen_for_all(void) ...@@ -1366,7 +1369,7 @@ static int tcp_listen_for_all(void)
sock = tcp_create_listen_sock(con, dlm_local_addr[0]); sock = tcp_create_listen_sock(con, dlm_local_addr[0]);
if (sock) { if (sock) {
add_sock(sock, con); add_sock(sock, con, true);
result = 0; result = 0;
} }
else { else {
......
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