提交 b10d96cb 编写于 作者: J Johannes Thoma 提交者: Philipp Reisner

drbd: Don't go into StandAlone mode when authentification failes because of network error

Signed-off-by: NPhilipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: NLars Ellenberg <lars.ellenberg@linbit.com>
上级 36bfc7e2
...@@ -878,9 +878,13 @@ static int drbd_connect(struct drbd_conf *mdev) ...@@ -878,9 +878,13 @@ static int drbd_connect(struct drbd_conf *mdev)
if (mdev->cram_hmac_tfm) { if (mdev->cram_hmac_tfm) {
/* drbd_request_state(mdev, NS(conn, WFAuth)); */ /* drbd_request_state(mdev, NS(conn, WFAuth)); */
if (!drbd_do_auth(mdev)) { switch (drbd_do_auth(mdev)) {
case -1:
dev_err(DEV, "Authentication of peer failed\n"); dev_err(DEV, "Authentication of peer failed\n");
return -1; return -1;
case 0:
dev_err(DEV, "Authentication of peer failed, trying again.\n");
return 0;
} }
} }
...@@ -3831,10 +3835,17 @@ static int drbd_do_auth(struct drbd_conf *mdev) ...@@ -3831,10 +3835,17 @@ static int drbd_do_auth(struct drbd_conf *mdev)
{ {
dev_err(DEV, "This kernel was build without CONFIG_CRYPTO_HMAC.\n"); dev_err(DEV, "This kernel was build without CONFIG_CRYPTO_HMAC.\n");
dev_err(DEV, "You need to disable 'cram-hmac-alg' in drbd.conf.\n"); dev_err(DEV, "You need to disable 'cram-hmac-alg' in drbd.conf.\n");
return 0; return -1;
} }
#else #else
#define CHALLENGE_LEN 64 #define CHALLENGE_LEN 64
/* Return value:
1 - auth succeeded,
0 - failed, try again (network error),
-1 - auth failed, don't try again.
*/
static int drbd_do_auth(struct drbd_conf *mdev) static int drbd_do_auth(struct drbd_conf *mdev)
{ {
char my_challenge[CHALLENGE_LEN]; /* 64 Bytes... */ char my_challenge[CHALLENGE_LEN]; /* 64 Bytes... */
...@@ -3855,7 +3866,7 @@ static int drbd_do_auth(struct drbd_conf *mdev) ...@@ -3855,7 +3866,7 @@ static int drbd_do_auth(struct drbd_conf *mdev)
(u8 *)mdev->net_conf->shared_secret, key_len); (u8 *)mdev->net_conf->shared_secret, key_len);
if (rv) { if (rv) {
dev_err(DEV, "crypto_hash_setkey() failed with %d\n", rv); dev_err(DEV, "crypto_hash_setkey() failed with %d\n", rv);
rv = 0; rv = -1;
goto fail; goto fail;
} }
...@@ -3878,14 +3889,14 @@ static int drbd_do_auth(struct drbd_conf *mdev) ...@@ -3878,14 +3889,14 @@ static int drbd_do_auth(struct drbd_conf *mdev)
if (p.length > CHALLENGE_LEN*2) { if (p.length > CHALLENGE_LEN*2) {
dev_err(DEV, "expected AuthChallenge payload too big.\n"); dev_err(DEV, "expected AuthChallenge payload too big.\n");
rv = 0; rv = -1;
goto fail; goto fail;
} }
peers_ch = kmalloc(p.length, GFP_NOIO); peers_ch = kmalloc(p.length, GFP_NOIO);
if (peers_ch == NULL) { if (peers_ch == NULL) {
dev_err(DEV, "kmalloc of peers_ch failed\n"); dev_err(DEV, "kmalloc of peers_ch failed\n");
rv = 0; rv = -1;
goto fail; goto fail;
} }
...@@ -3901,7 +3912,7 @@ static int drbd_do_auth(struct drbd_conf *mdev) ...@@ -3901,7 +3912,7 @@ static int drbd_do_auth(struct drbd_conf *mdev)
response = kmalloc(resp_size, GFP_NOIO); response = kmalloc(resp_size, GFP_NOIO);
if (response == NULL) { if (response == NULL) {
dev_err(DEV, "kmalloc of response failed\n"); dev_err(DEV, "kmalloc of response failed\n");
rv = 0; rv = -1;
goto fail; goto fail;
} }
...@@ -3911,7 +3922,7 @@ static int drbd_do_auth(struct drbd_conf *mdev) ...@@ -3911,7 +3922,7 @@ static int drbd_do_auth(struct drbd_conf *mdev)
rv = crypto_hash_digest(&desc, &sg, sg.length, response); rv = crypto_hash_digest(&desc, &sg, sg.length, response);
if (rv) { if (rv) {
dev_err(DEV, "crypto_hash_digest() failed with %d\n", rv); dev_err(DEV, "crypto_hash_digest() failed with %d\n", rv);
rv = 0; rv = -1;
goto fail; goto fail;
} }
...@@ -3947,7 +3958,7 @@ static int drbd_do_auth(struct drbd_conf *mdev) ...@@ -3947,7 +3958,7 @@ static int drbd_do_auth(struct drbd_conf *mdev)
right_response = kmalloc(resp_size, GFP_NOIO); right_response = kmalloc(resp_size, GFP_NOIO);
if (right_response == NULL) { if (right_response == NULL) {
dev_err(DEV, "kmalloc of right_response failed\n"); dev_err(DEV, "kmalloc of right_response failed\n");
rv = 0; rv = -1;
goto fail; goto fail;
} }
...@@ -3956,7 +3967,7 @@ static int drbd_do_auth(struct drbd_conf *mdev) ...@@ -3956,7 +3967,7 @@ static int drbd_do_auth(struct drbd_conf *mdev)
rv = crypto_hash_digest(&desc, &sg, sg.length, right_response); rv = crypto_hash_digest(&desc, &sg, sg.length, right_response);
if (rv) { if (rv) {
dev_err(DEV, "crypto_hash_digest() failed with %d\n", rv); dev_err(DEV, "crypto_hash_digest() failed with %d\n", rv);
rv = 0; rv = -1;
goto fail; goto fail;
} }
...@@ -3965,6 +3976,8 @@ static int drbd_do_auth(struct drbd_conf *mdev) ...@@ -3965,6 +3976,8 @@ static int drbd_do_auth(struct drbd_conf *mdev)
if (rv) if (rv)
dev_info(DEV, "Peer authenticated using %d bytes of '%s' HMAC\n", dev_info(DEV, "Peer authenticated using %d bytes of '%s' HMAC\n",
resp_size, mdev->net_conf->cram_hmac_alg); resp_size, mdev->net_conf->cram_hmac_alg);
else
rv = -1;
fail: fail:
kfree(peers_ch); kfree(peers_ch);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册