aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/drbd/drbd_receiver.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/block/drbd/drbd_receiver.c')
-rw-r--r--drivers/block/drbd/drbd_receiver.c46
1 files changed, 30 insertions, 16 deletions
diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
index 259c1351b152..f22a5283128a 100644
--- a/drivers/block/drbd/drbd_receiver.c
+++ b/drivers/block/drbd/drbd_receiver.c
@@ -878,9 +878,13 @@ retry:
878 878
879 if (mdev->cram_hmac_tfm) { 879 if (mdev->cram_hmac_tfm) {
880 /* drbd_request_state(mdev, NS(conn, WFAuth)); */ 880 /* drbd_request_state(mdev, NS(conn, WFAuth)); */
881 if (!drbd_do_auth(mdev)) { 881 switch (drbd_do_auth(mdev)) {
882 case -1:
882 dev_err(DEV, "Authentication of peer failed\n"); 883 dev_err(DEV, "Authentication of peer failed\n");
883 return -1; 884 return -1;
885 case 0:
886 dev_err(DEV, "Authentication of peer failed, trying again.\n");
887 return 0;
884 } 888 }
885 } 889 }
886 890
@@ -1201,10 +1205,11 @@ static int receive_Barrier(struct drbd_conf *mdev, struct p_header *h)
1201 1205
1202 case WO_bdev_flush: 1206 case WO_bdev_flush:
1203 case WO_drain_io: 1207 case WO_drain_io:
1204 D_ASSERT(rv == FE_STILL_LIVE); 1208 if (rv == FE_STILL_LIVE) {
1205 set_bit(DE_BARRIER_IN_NEXT_EPOCH_ISSUED, &mdev->current_epoch->flags); 1209 set_bit(DE_BARRIER_IN_NEXT_EPOCH_ISSUED, &mdev->current_epoch->flags);
1206 drbd_wait_ee_list_empty(mdev, &mdev->active_ee); 1210 drbd_wait_ee_list_empty(mdev, &mdev->active_ee);
1207 rv = drbd_flush_after_epoch(mdev, mdev->current_epoch); 1211 rv = drbd_flush_after_epoch(mdev, mdev->current_epoch);
1212 }
1208 if (rv == FE_RECYCLED) 1213 if (rv == FE_RECYCLED)
1209 return TRUE; 1214 return TRUE;
1210 1215
@@ -2865,7 +2870,7 @@ static int receive_sizes(struct drbd_conf *mdev, struct p_header *h)
2865 2870
2866 /* Never shrink a device with usable data during connect. 2871 /* Never shrink a device with usable data during connect.
2867 But allow online shrinking if we are connected. */ 2872 But allow online shrinking if we are connected. */
2868 if (drbd_new_dev_size(mdev, mdev->ldev) < 2873 if (drbd_new_dev_size(mdev, mdev->ldev, 0) <
2869 drbd_get_capacity(mdev->this_bdev) && 2874 drbd_get_capacity(mdev->this_bdev) &&
2870 mdev->state.disk >= D_OUTDATED && 2875 mdev->state.disk >= D_OUTDATED &&
2871 mdev->state.conn < C_CONNECTED) { 2876 mdev->state.conn < C_CONNECTED) {
@@ -2880,7 +2885,7 @@ static int receive_sizes(struct drbd_conf *mdev, struct p_header *h)
2880#undef min_not_zero 2885#undef min_not_zero
2881 2886
2882 if (get_ldev(mdev)) { 2887 if (get_ldev(mdev)) {
2883 dd = drbd_determin_dev_size(mdev); 2888 dd = drbd_determin_dev_size(mdev, 0);
2884 put_ldev(mdev); 2889 put_ldev(mdev);
2885 if (dd == dev_size_error) 2890 if (dd == dev_size_error)
2886 return FALSE; 2891 return FALSE;
@@ -3830,10 +3835,17 @@ static int drbd_do_auth(struct drbd_conf *mdev)
3830{ 3835{
3831 dev_err(DEV, "This kernel was build without CONFIG_CRYPTO_HMAC.\n"); 3836 dev_err(DEV, "This kernel was build without CONFIG_CRYPTO_HMAC.\n");
3832 dev_err(DEV, "You need to disable 'cram-hmac-alg' in drbd.conf.\n"); 3837 dev_err(DEV, "You need to disable 'cram-hmac-alg' in drbd.conf.\n");
3833 return 0; 3838 return -1;
3834} 3839}
3835#else 3840#else
3836#define CHALLENGE_LEN 64 3841#define CHALLENGE_LEN 64
3842
3843/* Return value:
3844 1 - auth succeeded,
3845 0 - failed, try again (network error),
3846 -1 - auth failed, don't try again.
3847*/
3848
3837static int drbd_do_auth(struct drbd_conf *mdev) 3849static int drbd_do_auth(struct drbd_conf *mdev)
3838{ 3850{
3839 char my_challenge[CHALLENGE_LEN]; /* 64 Bytes... */ 3851 char my_challenge[CHALLENGE_LEN]; /* 64 Bytes... */
@@ -3854,7 +3866,7 @@ static int drbd_do_auth(struct drbd_conf *mdev)
3854 (u8 *)mdev->net_conf->shared_secret, key_len); 3866 (u8 *)mdev->net_conf->shared_secret, key_len);
3855 if (rv) { 3867 if (rv) {
3856 dev_err(DEV, "crypto_hash_setkey() failed with %d\n", rv); 3868 dev_err(DEV, "crypto_hash_setkey() failed with %d\n", rv);
3857 rv = 0; 3869 rv = -1;
3858 goto fail; 3870 goto fail;
3859 } 3871 }
3860 3872
@@ -3877,14 +3889,14 @@ static int drbd_do_auth(struct drbd_conf *mdev)
3877 3889
3878 if (p.length > CHALLENGE_LEN*2) { 3890 if (p.length > CHALLENGE_LEN*2) {
3879 dev_err(DEV, "expected AuthChallenge payload too big.\n"); 3891 dev_err(DEV, "expected AuthChallenge payload too big.\n");
3880 rv = 0; 3892 rv = -1;
3881 goto fail; 3893 goto fail;
3882 } 3894 }
3883 3895
3884 peers_ch = kmalloc(p.length, GFP_NOIO); 3896 peers_ch = kmalloc(p.length, GFP_NOIO);
3885 if (peers_ch == NULL) { 3897 if (peers_ch == NULL) {
3886 dev_err(DEV, "kmalloc of peers_ch failed\n"); 3898 dev_err(DEV, "kmalloc of peers_ch failed\n");
3887 rv = 0; 3899 rv = -1;
3888 goto fail; 3900 goto fail;
3889 } 3901 }
3890 3902
@@ -3900,7 +3912,7 @@ static int drbd_do_auth(struct drbd_conf *mdev)
3900 response = kmalloc(resp_size, GFP_NOIO); 3912 response = kmalloc(resp_size, GFP_NOIO);
3901 if (response == NULL) { 3913 if (response == NULL) {
3902 dev_err(DEV, "kmalloc of response failed\n"); 3914 dev_err(DEV, "kmalloc of response failed\n");
3903 rv = 0; 3915 rv = -1;
3904 goto fail; 3916 goto fail;
3905 } 3917 }
3906 3918
@@ -3910,7 +3922,7 @@ static int drbd_do_auth(struct drbd_conf *mdev)
3910 rv = crypto_hash_digest(&desc, &sg, sg.length, response); 3922 rv = crypto_hash_digest(&desc, &sg, sg.length, response);
3911 if (rv) { 3923 if (rv) {
3912 dev_err(DEV, "crypto_hash_digest() failed with %d\n", rv); 3924 dev_err(DEV, "crypto_hash_digest() failed with %d\n", rv);
3913 rv = 0; 3925 rv = -1;
3914 goto fail; 3926 goto fail;
3915 } 3927 }
3916 3928
@@ -3944,9 +3956,9 @@ static int drbd_do_auth(struct drbd_conf *mdev)
3944 } 3956 }
3945 3957
3946 right_response = kmalloc(resp_size, GFP_NOIO); 3958 right_response = kmalloc(resp_size, GFP_NOIO);
3947 if (response == NULL) { 3959 if (right_response == NULL) {
3948 dev_err(DEV, "kmalloc of right_response failed\n"); 3960 dev_err(DEV, "kmalloc of right_response failed\n");
3949 rv = 0; 3961 rv = -1;
3950 goto fail; 3962 goto fail;
3951 } 3963 }
3952 3964
@@ -3955,7 +3967,7 @@ static int drbd_do_auth(struct drbd_conf *mdev)
3955 rv = crypto_hash_digest(&desc, &sg, sg.length, right_response); 3967 rv = crypto_hash_digest(&desc, &sg, sg.length, right_response);
3956 if (rv) { 3968 if (rv) {
3957 dev_err(DEV, "crypto_hash_digest() failed with %d\n", rv); 3969 dev_err(DEV, "crypto_hash_digest() failed with %d\n", rv);
3958 rv = 0; 3970 rv = -1;
3959 goto fail; 3971 goto fail;
3960 } 3972 }
3961 3973
@@ -3964,6 +3976,8 @@ static int drbd_do_auth(struct drbd_conf *mdev)
3964 if (rv) 3976 if (rv)
3965 dev_info(DEV, "Peer authenticated using %d bytes of '%s' HMAC\n", 3977 dev_info(DEV, "Peer authenticated using %d bytes of '%s' HMAC\n",
3966 resp_size, mdev->net_conf->cram_hmac_alg); 3978 resp_size, mdev->net_conf->cram_hmac_alg);
3979 else
3980 rv = -1;
3967 3981
3968 fail: 3982 fail:
3969 kfree(peers_ch); 3983 kfree(peers_ch);