[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gluster-devel] [PATCH BUG:393 10/10] transport/encryption: fix encrypti
From: |
Corentin Chary |
Subject: |
[Gluster-devel] [PATCH BUG:393 10/10] transport/encryption: fix encryption when used with afr |
Date: |
Wed, 18 Nov 2009 12:14:02 +0100 |
afr (and others) use the same vector for each write,
this resulted in double encrypted messages, because the original
vector was modified.
Signed-off-by: Corentin Chary <address@hidden>
---
libglusterfs/src/transport.c | 40 +++++++++++++++++++++++++++++++---------
1 files changed, 31 insertions(+), 9 deletions(-)
diff --git a/libglusterfs/src/transport.c b/libglusterfs/src/transport.c
index b88de9f..ad557b4 100644
--- a/libglusterfs/src/transport.c
+++ b/libglusterfs/src/transport.c
@@ -319,7 +319,8 @@ transport_submit (transport_t *this, char *buf, int32_t len,
{
int32_t ret = -1;
transport_t *peer_trans = NULL;
- struct iobuf *iobuf = NULL;
+ struct iobuf *iobuf = NULL;
+ struct iobuf *iobufc = NULL;
struct transport_msg *msg = NULL;
gf_hdr_common_t *hdr;
@@ -327,6 +328,21 @@ transport_submit (transport_t *this, char *buf, int32_t
len,
hdr->crypto = hton32 (this->crypto.magic);
if (this->crypto.ops && this->crypto.ops->encrypt) {
+ if (vector) {
+ iobufc = iobuf_get (this->xl->ctx->iobuf_pool);
+ if (!iobufc)
+ return -ENOMEM;
+
+ vector = iov_dup (vector, count);
+ if (!vector) {
+ ret = -ENOMEM;
+ goto fail;
+ }
+
+ iov_unload (iobufc->ptr, vector, count);
+ iov_link (vector, count, iobufc->ptr);
+ }
+
ret = this->crypto.ops->encrypt (&this->crypto, buf,
len, vector, count);
if (ret)
@@ -338,7 +354,8 @@ transport_submit (transport_t *this, char *buf, int32_t len,
msg = CALLOC (1, sizeof (*msg));
if (!msg) {
- return -ENOMEM;
+ ret = -ENOMEM;
+ goto fail;
}
msg->hdr = buf;
@@ -349,7 +366,8 @@ transport_submit (transport_t *this, char *buf, int32_t len,
if (!iobuf) {
FREE (msg->hdr);
FREE (msg);
- return -ENOMEM;
+ ret = -ENOMEM;
+ goto fail;
}
iov_unload (iobuf->ptr, vector, count);
@@ -364,14 +382,18 @@ transport_submit (transport_t *this, char *buf, int32_t
len,
}
pthread_mutex_unlock (&peer_trans->handover.mutex);
- return 0;
- }
-
- GF_VALIDATE_OR_GOTO("transport", this, fail);
- GF_VALIDATE_OR_GOTO("transport", this->ops, fail);
+ ret = 0;
+ } else {
+ GF_VALIDATE_OR_GOTO("transport", this, fail);
+ GF_VALIDATE_OR_GOTO("transport", this->ops, fail);
- ret = this->ops->submit (this, buf, len, vector, count, iobref);
+ ret = this->ops->submit (this, buf, len, vector, count, iobref);
+ }
fail:
+ if (iobufc) {
+ iobuf_unref (iobufc);
+ FREE (vector);
+ }
return ret;
}
--
1.6.4.4
- [Gluster-devel] [PATCH BUG:393 00/10] Add transport encryption translators, Corentin Chary, 2009/11/18
- [Gluster-devel] [PATCH BUG:393 01/10] transport/encryption: add infrastructure, Corentin Chary, 2009/11/18
- [Gluster-devel] [PATCH BUG:393 02/10] transport/encryption: add directory and base Makefile.am, Corentin Chary, 2009/11/18
- [Gluster-devel] [PATCH BUG:393 03/10] transport/encryption: add rot-13 demo, Corentin Chary, 2009/11/18
- [Gluster-devel] [PATCH BUG:393 04/10] transport/encryption: keep xlator reference, Corentin Chary, 2009/11/18
- [Gluster-devel] [PATCH BUG:393 05/10] transport/encryption: pass transport_crypto_t instead of transport_t, Corentin Chary, 2009/11/18
- [Gluster-devel] [PATCH BUG:393 06/10] libglusterfs: add iov_load function, Corentin Chary, 2009/11/18
- [Gluster-devel] [PATCH BUG:393 07/10] transport/encryption: add NaCl encryptor, Corentin Chary, 2009/11/18
- [Gluster-devel] [PATCH BUG:393 08/10] transport/ib-verbs: add missing buflen_p parameter, Corentin Chary, 2009/11/18
- [Gluster-devel] [PATCH BUG:393 09/10] libglusterfs: add iov_link, Corentin Chary, 2009/11/18
- [Gluster-devel] [PATCH BUG:393 10/10] transport/encryption: fix encryption when used with afr,
Corentin Chary <=