Re: [PATCH] convert dm_ulog_request data to little endian

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




v5_endian_from_network() only gets called if it is needed.  I suspect there is a bug here, 'clog_request_to_network' should detect if big endian is being used and switch it to little endian.  In-coming communication must always be little endian.  I'm not sure which end the problem is on (I think the send side).  You could add some prints to detect the issue.

lvm2/daemons/cmirrord/cluster.c:cluster_send() sets two version numbers - one is forced to be little endian via xlate64().  'clog_request_to_network()' is then called and compares the two version numbers.  If they are different, the machine is big endian and the contents must be converted.  If this is not happening, it is bad.  Then, *from_network() performs a similar action and test and then must xlate back to big endian.  If this is not happening, it is bad.  So, for big endian machines, ensure that v5_endian_*_network() is being called.  (For little endian, it should not be.)

  brassow
hi,  brassow ,

      There might be a bug in v5_endian_to_network when sending packet.
If the machine were big-endian, v5_endian_to_network will convert request_type to little endian. But in v5_data_endian_switch, it will check request_type again, and this check will failed because request_type is already converted to little endian. So my solution to this is to delay xlate32 of u_rq->request_type.

On the other hand, when receiving package in clog_request_from_network. I think the vp[0] will always be little endian. we could use xlate64(vp[0]) == vp[0] to decide if the local node is little endian or not. if local node is little endian, we do nothing, if the local node is big endian, we have to call v5_endian_from_network to convert little endian to big endian.

     But for now, I have not had a chance to test this patch on s390


here's the patch:

diff --git a/daemons/cmirrord/compat.c b/daemons/cmirrord/compat.c
index 3f7a9b5..c9cb803 100644
--- a/daemons/cmirrord/compat.c
+++ b/daemons/cmirrord/compat.c
@@ -126,13 +126,14 @@ static int v5_endian_to_network(struct clog_request *rq)

        u_rq->error = xlate32(u_rq->error);
        u_rq->seq = xlate32(u_rq->seq);
-       u_rq->request_type = xlate32(u_rq->request_type);
        u_rq->data_size = xlate64(u_rq->data_size);

        rq->originator = xlate32(rq->originator);

        v5_data_endian_switch(rq, 1);

+       rq->u_rq.request_type = xlate32(rq->u_rq.request_type);
+
        return size;
 }

@@ -187,7 +188,7 @@ int clog_request_from_network(void *data, size_t data_len)

        switch (version) {
        case 5: /* Upstream */
-               if (version == unconverted_version)
+               if (version == vp[0])
                        return 0;
                break;
        case 4: /* RHEL 5.[45] */



Dongmao Zhang





--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel




[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux