Skip to content

Commit 3f1c6f2

Browse files
committed
libceph: allow addrvecs with a single NONE/blank address
Normally, an unused OSD id/slot is represented by an empty addrvec. However, it also appears to be possible to generate an osdmap where an unused OSD id/slot has an addrvec with a single blank address of type NONE. Allow such addrvecs and make the end result be exactly the same as for the empty addrvec case -- leave addr intact. Cc: [email protected] # 5.11+ Signed-off-by: Ilya Dryomov <[email protected]> Reviewed-by: Jeff Layton <[email protected]>
1 parent 61ca49a commit 3f1c6f2

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

net/ceph/decode.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <linux/inet.h>
55

66
#include <linux/ceph/decode.h>
7+
#include <linux/ceph/messenger.h> /* for ceph_pr_addr() */
78

89
static int
910
ceph_decode_entity_addr_versioned(void **p, void *end,
@@ -110,13 +111,15 @@ int ceph_decode_entity_addrvec(void **p, void *end, bool msgr2,
110111
}
111112

112113
ceph_decode_32_safe(p, end, addr_cnt, e_inval);
114+
dout("%s addr_cnt %d\n", __func__, addr_cnt);
113115

114116
found = false;
115117
for (i = 0; i < addr_cnt; i++) {
116118
ret = ceph_decode_entity_addr(p, end, &tmp_addr);
117119
if (ret)
118120
return ret;
119121

122+
dout("%s i %d addr %s\n", __func__, i, ceph_pr_addr(&tmp_addr));
120123
if (tmp_addr.type == my_type) {
121124
if (found) {
122125
pr_err("another match of type %d in addrvec\n",
@@ -128,13 +131,18 @@ int ceph_decode_entity_addrvec(void **p, void *end, bool msgr2,
128131
found = true;
129132
}
130133
}
131-
if (!found && addr_cnt != 0) {
132-
pr_err("no match of type %d in addrvec\n",
133-
le32_to_cpu(my_type));
134-
return -ENOENT;
135-
}
136134

137-
return 0;
135+
if (found)
136+
return 0;
137+
138+
if (!addr_cnt)
139+
return 0; /* normal -- e.g. unused OSD id/slot */
140+
141+
if (addr_cnt == 1 && !memchr_inv(&tmp_addr, 0, sizeof(tmp_addr)))
142+
return 0; /* weird but effectively the same as !addr_cnt */
143+
144+
pr_err("no match of type %d in addrvec\n", le32_to_cpu(my_type));
145+
return -ENOENT;
138146

139147
e_inval:
140148
return -EINVAL;

0 commit comments

Comments
 (0)