Skip to content

Commit

Permalink
libceph: allow addrvecs with a single NONE/blank address
Browse files Browse the repository at this point in the history
BugLink: https://bugs.launchpad.net/bugs/1928857

commit 3f1c6f2 upstream.

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: stable@vger.kernel.org # 5.11+
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
  • Loading branch information
idryomov authored and smb49 committed May 19, 2021
1 parent 209ad12 commit c6a457e
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions net/ceph/decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <linux/inet.h>

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

static int
ceph_decode_entity_addr_versioned(void **p, void *end,
Expand Down Expand Up @@ -110,13 +111,15 @@ int ceph_decode_entity_addrvec(void **p, void *end, bool msgr2,
}

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

found = false;
for (i = 0; i < addr_cnt; i++) {
ret = ceph_decode_entity_addr(p, end, &tmp_addr);
if (ret)
return ret;

dout("%s i %d addr %s\n", __func__, i, ceph_pr_addr(&tmp_addr));
if (tmp_addr.type == my_type) {
if (found) {
pr_err("another match of type %d in addrvec\n",
Expand All @@ -128,13 +131,18 @@ int ceph_decode_entity_addrvec(void **p, void *end, bool msgr2,
found = true;
}
}
if (!found && addr_cnt != 0) {
pr_err("no match of type %d in addrvec\n",
le32_to_cpu(my_type));
return -ENOENT;
}

return 0;
if (found)
return 0;

if (!addr_cnt)
return 0; /* normal -- e.g. unused OSD id/slot */

if (addr_cnt == 1 && !memchr_inv(&tmp_addr, 0, sizeof(tmp_addr)))
return 0; /* weird but effectively the same as !addr_cnt */

pr_err("no match of type %d in addrvec\n", le32_to_cpu(my_type));
return -ENOENT;

e_inval:
return -EINVAL;
Expand Down

0 comments on commit c6a457e

Please sign in to comment.