Whamcloud - gitweb
LU-521 lnet: Fix endian issue introduced by change 1338
authorDoug Oucharek <doug@whamcloud.com>
Tue, 4 Sep 2012 19:35:35 +0000 (12:35 -0700)
committerOleg Drokin <green@whamcloud.com>
Mon, 10 Sep 2012 19:58:39 +0000 (15:58 -0400)
In change 1338 done for LU-521, an endian issue was introduced
when the magic number for the RPC header was swapped before
the body has been swapped. We use the magic number to
determine if the body needs swapping.

Signed-off-by: Doug Oucharek <doug.s.oucharek@intel.com>
Change-Id: I0a64ca13dbdc04169d59a1bd531b4877e8736993
Reviewed-on: http://review.whamcloud.com/3831
Reviewed-by: Isaac Huang <he.huang@intel.com>
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Liang Zhen <liang@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Tested-by: Oleg Drokin <green@whamcloud.com>
lnet/selftest/rpc.c
lnet/selftest/rpc.h

index 20358fe..ab7cee6 100644 (file)
@@ -1267,7 +1267,8 @@ srpc_send_rpc (swi_workitem_t *wi)
 
                srpc_unpack_msg_hdr(reply);
                if (reply->msg_type != type ||
-                   reply->msg_magic != SRPC_MSG_MAGIC) {
+                   (reply->msg_magic != SRPC_MSG_MAGIC &&
+                    reply->msg_magic != __swab32(SRPC_MSG_MAGIC))) {
                         CWARN ("Bad message from %s: type %u (%d expected),"
                                " magic %u (%d expected).\n",
                                libcfs_id2str(rpc->crpc_dest),
index 25a37d0..accceb7 100644 (file)
@@ -290,7 +290,9 @@ srpc_unpack_msg_hdr(srpc_msg_t *msg)
        if (msg->msg_magic == SRPC_MSG_MAGIC)
                return; /* no flipping needed */
 
-       __swab32s(&msg->msg_magic);
+       /* We do not swap the magic number here as it is needed to
+          determine whether the body needs to be swapped. */
+       /* __swab32s(&msg->msg_magic); */
        __swab32s(&msg->msg_type);
        __swab32s(&msg->msg_version);
        __swab32s(&msg->msg_ses_feats);