struct drbd_tl_epoch *oldest_tle;
struct list_head out_of_sequence_requests;
+ struct crypto_hash *cram_hmac_tfm;
+ struct crypto_hash *integrity_w_tfm; /* to be used by the worker thread */
+ struct crypto_hash *integrity_r_tfm; /* to be used by the receiver thread */
+ void *int_dig_out;
+ void *int_dig_in;
+ void *int_dig_vv;
+
struct drbd_thread receiver;
struct drbd_thread worker;
struct drbd_thread asender;
unsigned int al_tr_number;
int al_tr_cycle;
int al_tr_pos; /* position of the next transaction in the journal */
- struct crypto_hash *cram_hmac_tfm;
- struct crypto_hash *integrity_w_tfm; /* to be used by the worker thread */
- struct crypto_hash *integrity_r_tfm; /* to be used by the receiver thread */
- void *int_dig_out;
- void *int_dig_in;
- void *int_dig_vv;
wait_queue_head_t seq_wait;
atomic_t packet_seq;
unsigned int peer_seq;
int drbd_send_ack_dp(struct drbd_conf *mdev, enum drbd_packets cmd,
struct p_data *dp, int data_size)
{
- data_size -= (mdev->tconn->agreed_pro_version >= 87 && mdev->integrity_r_tfm) ?
- crypto_hash_digestsize(mdev->integrity_r_tfm) : 0;
+ data_size -= (mdev->tconn->agreed_pro_version >= 87 && mdev->tconn->integrity_r_tfm) ?
+ crypto_hash_digestsize(mdev->tconn->integrity_r_tfm) : 0;
return _drbd_send_ack(mdev, cmd, dp->sector, cpu_to_be32(data_size),
dp->block_id);
}
if (!drbd_get_data_sock(mdev))
return 0;
- dgs = (mdev->tconn->agreed_pro_version >= 87 && mdev->integrity_w_tfm) ?
- crypto_hash_digestsize(mdev->integrity_w_tfm) : 0;
+ dgs = (mdev->tconn->agreed_pro_version >= 87 && mdev->tconn->integrity_w_tfm) ?
+ crypto_hash_digestsize(mdev->tconn->integrity_w_tfm) : 0;
if (req->i.size <= DRBD_MAX_SIZE_H80_PACKET) {
p.head.h80.magic = cpu_to_be32(DRBD_MAGIC);
ok = (sizeof(p) ==
drbd_send(mdev, mdev->tconn->data.socket, &p, sizeof(p), dgs ? MSG_MORE : 0));
if (ok && dgs) {
- dgb = mdev->int_dig_out;
- drbd_csum_bio(mdev, mdev->integrity_w_tfm, req->master_bio, dgb);
+ dgb = mdev->tconn->int_dig_out;
+ drbd_csum_bio(mdev, mdev->tconn->integrity_w_tfm, req->master_bio, dgb);
ok = dgs == drbd_send(mdev, mdev->tconn->data.socket, dgb, dgs, 0);
}
if (ok) {
/* 64 byte, 512 bit, is the largest digest size
* currently supported in kernel crypto. */
unsigned char digest[64];
- drbd_csum_bio(mdev, mdev->integrity_w_tfm, req->master_bio, digest);
- if (memcmp(mdev->int_dig_out, digest, dgs)) {
+ drbd_csum_bio(mdev, mdev->tconn->integrity_w_tfm, req->master_bio, digest);
+ if (memcmp(mdev->tconn->int_dig_out, digest, dgs)) {
dev_warn(DEV,
"Digest mismatch, buffer modified by upper layers during write: %llus +%u\n",
(unsigned long long)req->i.sector, req->i.size);
void *dgb;
int dgs;
- dgs = (mdev->tconn->agreed_pro_version >= 87 && mdev->integrity_w_tfm) ?
- crypto_hash_digestsize(mdev->integrity_w_tfm) : 0;
+ dgs = (mdev->tconn->agreed_pro_version >= 87 && mdev->tconn->integrity_w_tfm) ?
+ crypto_hash_digestsize(mdev->tconn->integrity_w_tfm) : 0;
if (e->i.size <= DRBD_MAX_SIZE_H80_PACKET) {
p.head.h80.magic = cpu_to_be32(DRBD_MAGIC);
ok = sizeof(p) == drbd_send(mdev, mdev->tconn->data.socket, &p, sizeof(p), dgs ? MSG_MORE : 0);
if (ok && dgs) {
- dgb = mdev->int_dig_out;
- drbd_csum_ee(mdev, mdev->integrity_w_tfm, e, dgb);
+ dgb = mdev->tconn->int_dig_out;
+ drbd_csum_ee(mdev, mdev->tconn->integrity_w_tfm, e, dgb);
ok = dgs == drbd_send(mdev, mdev->tconn->data.socket, dgb, dgs, 0);
}
if (ok)
kfree(mdev->p_uuid);
/* mdev->p_uuid = NULL; */
- kfree(mdev->int_dig_out);
- kfree(mdev->int_dig_in);
- kfree(mdev->int_dig_vv);
+ kfree(mdev->tconn->int_dig_out);
+ kfree(mdev->tconn->int_dig_in);
+ kfree(mdev->tconn->int_dig_vv);
/* cleanup the rest that has been
* allocated from drbd_new_device
mdev->csums_tfm = NULL;
crypto_free_hash(mdev->verify_tfm);
mdev->verify_tfm = NULL;
- crypto_free_hash(mdev->cram_hmac_tfm);
- mdev->cram_hmac_tfm = NULL;
- crypto_free_hash(mdev->integrity_w_tfm);
- mdev->integrity_w_tfm = NULL;
- crypto_free_hash(mdev->integrity_r_tfm);
- mdev->integrity_r_tfm = NULL;
+ crypto_free_hash(mdev->tconn->cram_hmac_tfm);
+ mdev->tconn->cram_hmac_tfm = NULL;
+ crypto_free_hash(mdev->tconn->integrity_w_tfm);
+ mdev->tconn->integrity_w_tfm = NULL;
+ crypto_free_hash(mdev->tconn->integrity_r_tfm);
+ mdev->tconn->integrity_r_tfm = NULL;
drbd_free_sock(mdev);
mdev->send_cnt = 0;
mdev->recv_cnt = 0;
- crypto_free_hash(mdev->cram_hmac_tfm);
- mdev->cram_hmac_tfm = tfm;
+ crypto_free_hash(mdev->tconn->cram_hmac_tfm);
+ mdev->tconn->cram_hmac_tfm = tfm;
- crypto_free_hash(mdev->integrity_w_tfm);
- mdev->integrity_w_tfm = integrity_w_tfm;
+ crypto_free_hash(mdev->tconn->integrity_w_tfm);
+ mdev->tconn->integrity_w_tfm = integrity_w_tfm;
- crypto_free_hash(mdev->integrity_r_tfm);
- mdev->integrity_r_tfm = integrity_r_tfm;
+ crypto_free_hash(mdev->tconn->integrity_r_tfm);
+ mdev->tconn->integrity_r_tfm = integrity_r_tfm;
- kfree(mdev->int_dig_out);
- kfree(mdev->int_dig_in);
- kfree(mdev->int_dig_vv);
- mdev->int_dig_out=int_dig_out;
- mdev->int_dig_in=int_dig_in;
- mdev->int_dig_vv=int_dig_vv;
+ kfree(mdev->tconn->int_dig_out);
+ kfree(mdev->tconn->int_dig_in);
+ kfree(mdev->tconn->int_dig_vv);
+ mdev->tconn->int_dig_out=int_dig_out;
+ mdev->tconn->int_dig_in=int_dig_in;
+ mdev->tconn->int_dig_vv=int_dig_vv;
retcode = _drbd_set_state(_NS(mdev, conn, C_UNCONNECTED), CS_VERBOSE, NULL);
spin_unlock_irq(&mdev->tconn->req_lock);
if (h <= 0)
return h;
- if (mdev->cram_hmac_tfm) {
+ if (mdev->tconn->cram_hmac_tfm) {
/* drbd_request_state(mdev, NS(conn, WFAuth)); */
switch (drbd_do_auth(mdev)) {
case -1:
struct drbd_epoch_entry *e;
struct page *page;
int dgs, ds, rr;
- void *dig_in = mdev->int_dig_in;
- void *dig_vv = mdev->int_dig_vv;
+ void *dig_in = mdev->tconn->int_dig_in;
+ void *dig_vv = mdev->tconn->int_dig_vv;
unsigned long *data;
- dgs = (mdev->tconn->agreed_pro_version >= 87 && mdev->integrity_r_tfm) ?
- crypto_hash_digestsize(mdev->integrity_r_tfm) : 0;
+ dgs = (mdev->tconn->agreed_pro_version >= 87 && mdev->tconn->integrity_r_tfm) ?
+ crypto_hash_digestsize(mdev->tconn->integrity_r_tfm) : 0;
if (dgs) {
rr = drbd_recv(mdev, dig_in, dgs);
}
if (dgs) {
- drbd_csum_ee(mdev, mdev->integrity_r_tfm, e, dig_vv);
+ drbd_csum_ee(mdev, mdev->tconn->integrity_r_tfm, e, dig_vv);
if (memcmp(dig_in, dig_vv, dgs)) {
dev_err(DEV, "Digest integrity check FAILED: %llus +%u\n",
(unsigned long long)sector, data_size);
struct bio_vec *bvec;
struct bio *bio;
int dgs, rr, i, expect;
- void *dig_in = mdev->int_dig_in;
- void *dig_vv = mdev->int_dig_vv;
+ void *dig_in = mdev->tconn->int_dig_in;
+ void *dig_vv = mdev->tconn->int_dig_vv;
- dgs = (mdev->tconn->agreed_pro_version >= 87 && mdev->integrity_r_tfm) ?
- crypto_hash_digestsize(mdev->integrity_r_tfm) : 0;
+ dgs = (mdev->tconn->agreed_pro_version >= 87 && mdev->tconn->integrity_r_tfm) ?
+ crypto_hash_digestsize(mdev->tconn->integrity_r_tfm) : 0;
if (dgs) {
rr = drbd_recv(mdev, dig_in, dgs);
}
if (dgs) {
- drbd_csum_bio(mdev, mdev->integrity_r_tfm, bio, dig_vv);
+ drbd_csum_bio(mdev, mdev->tconn->integrity_r_tfm, bio, dig_vv);
if (memcmp(dig_in, dig_vv, dgs)) {
dev_err(DEV, "Digest integrity check FAILED. Broken NICs?\n");
return 0;
if (os.conn == C_DISCONNECTING) {
wait_event(mdev->tconn->net_cnt_wait, atomic_read(&mdev->tconn->net_cnt) == 0);
- crypto_free_hash(mdev->cram_hmac_tfm);
- mdev->cram_hmac_tfm = NULL;
+ crypto_free_hash(mdev->tconn->cram_hmac_tfm);
+ mdev->tconn->cram_hmac_tfm = NULL;
kfree(mdev->tconn->net_conf);
mdev->tconn->net_conf = NULL;
unsigned int length;
int rv;
- desc.tfm = mdev->cram_hmac_tfm;
+ desc.tfm = mdev->tconn->cram_hmac_tfm;
desc.flags = 0;
- rv = crypto_hash_setkey(mdev->cram_hmac_tfm,
+ rv = crypto_hash_setkey(mdev->tconn->cram_hmac_tfm,
(u8 *)mdev->tconn->net_conf->shared_secret, key_len);
if (rv) {
dev_err(DEV, "crypto_hash_setkey() failed with %d\n", rv);
goto fail;
}
- resp_size = crypto_hash_digestsize(mdev->cram_hmac_tfm);
+ resp_size = crypto_hash_digestsize(mdev->tconn->cram_hmac_tfm);
response = kmalloc(resp_size, GFP_NOIO);
if (response == NULL) {
dev_err(DEV, "kmalloc of response failed\n");