multipath-tools/0009-bugfix-change-reservation-key-to-uint8-for-memcmp.patch

46 lines
1.5 KiB
Diff
Raw Normal View History

2020-11-04 21:19:44 +08:00
From 30ea73e8896765854fdf845fbb12b6eb85531527 Mon Sep 17 00:00:00 2001
2020-01-10 17:13:17 +08:00
From: sunguoshuai <sunguoshuai@huawei.com>
Date: Wed, 23 Jan 2019 02:21:31 -0500
2020-11-04 21:19:44 +08:00
Subject: [PATCH] fix change reservation key to uint8 for memcmp
2020-01-10 17:13:17 +08:00
reason:fix change reservation key to uint8 for memcmp
---
libmpathpersist/mpath_persist.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/libmpathpersist/mpath_persist.c b/libmpathpersist/mpath_persist.c
2020-11-04 21:19:44 +08:00
index 1f9817e..557d582 100644
2020-01-10 17:13:17 +08:00
--- a/libmpathpersist/mpath_persist.c
+++ b/libmpathpersist/mpath_persist.c
2020-11-04 21:19:44 +08:00
@@ -249,6 +249,9 @@ int __mpath_persistent_reserve_out ( int fd, int rq_servact, int rq_scope,
2020-01-10 17:13:17 +08:00
int ret;
uint64_t prkey;
struct config *conf;
+ uint8_t uitmp[8] = {0};
+ uint64_t uireservation = {0};
+ int j;
2020-07-16 18:51:36 +08:00
ret = mpath_get_map(fd, &alias, &mpp);
if (ret != MPATH_PR_SUCCESS)
2020-11-04 21:19:44 +08:00
@@ -274,8 +277,15 @@ int __mpath_persistent_reserve_out ( int fd, int rq_servact, int rq_scope,
2020-01-10 17:13:17 +08:00
}
}
- if (memcmp(paramp->key, &mpp->reservation_key, 8) &&
- memcmp(paramp->sa_key, &mpp->reservation_key, 8)) {
+ uireservation = get_be64(mpp->reservation_key);
+ for (j = 7; j >= 0; --j) {
+ uitmp[j] = (uireservation & 0xff);
+ uireservation >>= 8;
+ }
+
+ if (memcmp(paramp->key, uitmp, 8) &&
+ memcmp(paramp->sa_key, uitmp, 8)) {
+
condlog(0, "%s: configured reservation key doesn't match: 0x%" PRIx64, alias, get_be64(mpp->reservation_key));
ret = MPATH_PR_SYNTAX_ERROR;
goto out1;
--
1.8.3.1