Commit ce9879cb authored by Andreas Gruenbacher's avatar Andreas Gruenbacher Committed by Philipp Reisner

drbd: conn_send_cmd2(): Return 0 upon success and an error code otherwise

Signed-off-by: default avatarPhilipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: default avatarLars Ellenberg <lars.ellenberg@linbit.com>
parent fb708e40
...@@ -769,21 +769,17 @@ int conn_send_cmd2(struct drbd_tconn *tconn, enum drbd_packet cmd, char *data, ...@@ -769,21 +769,17 @@ int conn_send_cmd2(struct drbd_tconn *tconn, enum drbd_packet cmd, char *data,
size_t size) size_t size)
{ {
struct p_header80 h; struct p_header80 h;
int ok; int err;
prepare_header80(&h, cmd, size); prepare_header80(&h, cmd, size);
err = drbd_get_data_sock(tconn);
if (drbd_get_data_sock(tconn)) if (!err) {
return 0; err = drbd_send_all(tconn, tconn->data.socket, &h, sizeof(h), 0);
if (!err)
ok = (sizeof(h) == err = drbd_send_all(tconn, tconn->data.socket, data, size, 0);
drbd_send(tconn, tconn->data.socket, &h, sizeof(h), 0)); drbd_put_data_sock(tconn);
ok = ok && (size == }
drbd_send(tconn, tconn->data.socket, data, size, 0)); return err;
drbd_put_data_sock(tconn);
return ok;
} }
int drbd_send_sync_param(struct drbd_conf *mdev) int drbd_send_sync_param(struct drbd_conf *mdev)
...@@ -882,7 +878,7 @@ int drbd_send_protocol(struct drbd_tconn *tconn) ...@@ -882,7 +878,7 @@ int drbd_send_protocol(struct drbd_tconn *tconn)
if (tconn->agreed_pro_version >= 87) if (tconn->agreed_pro_version >= 87)
strcpy(p->integrity_alg, tconn->net_conf->integrity_alg); strcpy(p->integrity_alg, tconn->net_conf->integrity_alg);
rv = conn_send_cmd2(tconn, P_PROTOCOL, p->head.payload, size - sizeof(struct p_header)); rv = !conn_send_cmd2(tconn, P_PROTOCOL, p->head.payload, size - sizeof(struct p_header));
kfree(p); kfree(p);
return rv; return rv;
} }
......
...@@ -4265,7 +4265,7 @@ static int drbd_do_auth(struct drbd_tconn *tconn) ...@@ -4265,7 +4265,7 @@ static int drbd_do_auth(struct drbd_tconn *tconn)
get_random_bytes(my_challenge, CHALLENGE_LEN); get_random_bytes(my_challenge, CHALLENGE_LEN);
rv = conn_send_cmd2(tconn, P_AUTH_CHALLENGE, my_challenge, CHALLENGE_LEN); rv = !conn_send_cmd2(tconn, P_AUTH_CHALLENGE, my_challenge, CHALLENGE_LEN);
if (!rv) if (!rv)
goto fail; goto fail;
...@@ -4320,7 +4320,7 @@ static int drbd_do_auth(struct drbd_tconn *tconn) ...@@ -4320,7 +4320,7 @@ static int drbd_do_auth(struct drbd_tconn *tconn)
goto fail; goto fail;
} }
rv = conn_send_cmd2(tconn, P_AUTH_RESPONSE, response, resp_size); rv = !conn_send_cmd2(tconn, P_AUTH_RESPONSE, response, resp_size);
if (!rv) if (!rv)
goto fail; goto fail;
......
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