mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
libceph, ceph: get and handle cluster maps with addrvecs
In preparation for msgr2, make the cluster send us maps with addrvecs
including both LEGACY and MSGR2 addrs instead of a single LEGACY addr.
This means advertising support for SERVER_NAUTILUS and also some older
features: SERVER_MIMIC, MONENC and MONNAMES.
MONNAMES and MONENC are actually pre-argonaut, we just never updated
ceph_monmap_decode() for them. Decoding is unconditional, see commit
23c625ce30
("libceph: assume argonaut on the server side").
SERVER_MIMIC doesn't bear any meaning for the kernel client.
Since ceph_decode_entity_addrvec() is guarded by encoding version
checks (and in msgr2 case it is guarded implicitly by the fact that
server is speaking msgr2), we assume MSG_ADDR2 for it.
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
This commit is contained in:
parent
8921f25116
commit
a5cbd5fc22
10 changed files with 222 additions and 72 deletions
|
@ -1,4 +1,5 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
#include <linux/ceph/ceph_debug.h>
|
||||
|
||||
#include <linux/ceph/decode.h>
|
||||
|
||||
|
@ -82,3 +83,58 @@ bad:
|
|||
}
|
||||
EXPORT_SYMBOL(ceph_decode_entity_addr);
|
||||
|
||||
/*
|
||||
* Return addr of desired type (MSGR2 or LEGACY) or error.
|
||||
* Make sure there is only one match.
|
||||
*
|
||||
* Assume encoding with MSG_ADDR2.
|
||||
*/
|
||||
int ceph_decode_entity_addrvec(void **p, void *end, bool msgr2,
|
||||
struct ceph_entity_addr *addr)
|
||||
{
|
||||
__le32 my_type = msgr2 ? CEPH_ENTITY_ADDR_TYPE_MSGR2 :
|
||||
CEPH_ENTITY_ADDR_TYPE_LEGACY;
|
||||
struct ceph_entity_addr tmp_addr;
|
||||
int addr_cnt;
|
||||
bool found;
|
||||
u8 marker;
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
ceph_decode_8_safe(p, end, marker, e_inval);
|
||||
if (marker != 2) {
|
||||
pr_err("bad addrvec marker %d\n", marker);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ceph_decode_32_safe(p, end, addr_cnt, e_inval);
|
||||
|
||||
found = false;
|
||||
for (i = 0; i < addr_cnt; i++) {
|
||||
ret = ceph_decode_entity_addr(p, end, &tmp_addr);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (tmp_addr.type == my_type) {
|
||||
if (found) {
|
||||
pr_err("another match of type %d in addrvec\n",
|
||||
le32_to_cpu(my_type));
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
memcpy(addr, &tmp_addr, sizeof(*addr));
|
||||
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;
|
||||
|
||||
e_inval:
|
||||
return -EINVAL;
|
||||
}
|
||||
EXPORT_SYMBOL(ceph_decode_entity_addrvec);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue