public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libceph: accept addrvecs with multiple entries of the same type
@ 2026-04-23 10:09 Kefu Chai
  2026-04-23 10:35 ` Ilya Dryomov
  0 siblings, 1 reply; 3+ messages in thread
From: Kefu Chai @ 2026-04-23 10:09 UTC (permalink / raw)
  To: ceph-devel
  Cc: Ilya Dryomov, Alex Markuze, Viacheslav Dubeyko, linux-kernel,
	Kefu Chai

ceph_decode_entity_addrvec() rejects any addrvec containing more than
one entry that matches the requested msgr type (LEGACY or MSGR2),
logging "another match of type N in addrvec" and returning -EINVAL.
This breaks legitimate deployments where a daemon advertises multiple
addresses of the same type, most notably dual-stack (IPv4 + IPv6)
clusters and multi-subnet deployments where tooling picks one address
per listed public_network.

The monmap decoder fails, the client enters a reconnect loop:

  libceph: mon0 (1)10.10.10.15:6789 session established
  libceph: another match of type 1 in addrvec
  libceph: problem decoding monmap, -22

Match the userspace messenger, which since Nautilus picks the first
entry of the requested type and silently tolerates subsequent entries.

Link: https://tracker.ceph.com/issues/49581
Link: https://tracker.ceph.com/issues/64068
Link: https://bugzilla.proxmox.com/show_bug.cgi?id=7518
Signed-off-by: Kefu Chai <k.chai@proxmox.com>
---

Tested by reproducing the Proxmox BZ 7518 scenario against a vstart
cluster whose mon addrvec was edited to contain two v1 + two v2 entries:

    ceph mon set-addrs a \\
        '[v2:$ip1:$p2/0,v1:$ip1:$p1/0,v2:$ip2:$p2/0,v1:$ip2:$p1/0]'

A Debian VM booted with the patched kernel via 'qemu -kernel' then
ran 'mount -t ceph ...:$p1:/ /mnt -o name=admin'.  Pre-patch kernels
fail at monmap decode with "another match of type 1 in addrvec"
(-EINVAL).  Post-patch, decode succeeds and the mount proceeds to
the auth / MDS-discovery stages.

Also verified the decoder logic on the monmap.bin attached to BZ 7518
using a userspace port of ceph_decode_entity_addrvec(): the pre-patch
form returns -EINVAL on both msgr1 and msgr2 lookups; the post-patch
form returns 0 and picks the first matching entry.

 net/ceph/decode.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/net/ceph/decode.c b/net/ceph/decode.c
index bc109a1a4616..b17bc082b4fc 100644
--- a/net/ceph/decode.c
+++ b/net/ceph/decode.c
@@ -88,7 +88,8 @@ EXPORT_SYMBOL(ceph_decode_entity_addr);
 
 /*
  * Return addr of desired type (MSGR2 or LEGACY) or error.
- * Make sure there is only one match.
+ * If multiple entries of the desired type are present, use the
+ * first one.
  *
  * Assume encoding with MSG_ADDR2.
  */
@@ -120,13 +121,7 @@ int ceph_decode_entity_addrvec(void **p, void *end, bool msgr2,
 			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",
-				       le32_to_cpu(my_type));
-				return -EINVAL;
-			}
-
+		if (tmp_addr.type == my_type && !found) {
 			memcpy(addr, &tmp_addr, sizeof(*addr));
 			found = true;
 		}
-- 
2.47.3



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] libceph: accept addrvecs with multiple entries of the same type
  2026-04-23 10:09 [PATCH] libceph: accept addrvecs with multiple entries of the same type Kefu Chai
@ 2026-04-23 10:35 ` Ilya Dryomov
  2026-04-23 11:44   ` Kefu Chai
  0 siblings, 1 reply; 3+ messages in thread
From: Ilya Dryomov @ 2026-04-23 10:35 UTC (permalink / raw)
  To: Kefu Chai; +Cc: ceph-devel, Alex Markuze, Viacheslav Dubeyko, linux-kernel

On Thu, Apr 23, 2026 at 12:09 PM Kefu Chai <k.chai@proxmox.com> wrote:
>
> ceph_decode_entity_addrvec() rejects any addrvec containing more than
> one entry that matches the requested msgr type (LEGACY or MSGR2),
> logging "another match of type N in addrvec" and returning -EINVAL.
> This breaks legitimate deployments where a daemon advertises multiple
> addresses of the same type, most notably dual-stack (IPv4 + IPv6)
> clusters

Hi Kefu,

My understanding is that dual-stack isn't supported in general:
https://tracker.ceph.com/issues/65631.  The respective references were
purged from the documentation with Radoslaw (offline?) ack.

> and multi-subnet deployments where tooling picks one address
> per listed public_network.

Can you elaborate on when such tooling kicks in, what exactly does it
do and the use case in general?  It's not immediately obvious to me how
having two addresses of the same type/stack and simply ignoring the
second one is better than insisting on having a just single address.

> Match the userspace messenger, which since Nautilus picks the first
> entry of the requested type and silently tolerates subsequent entries.

Do you have a reference to a specific commit?  I'm wondering if it
isn't on that "merged more or less accidentally" list.

Thanks,

                Ilya

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] libceph: accept addrvecs with multiple entries of the same type
  2026-04-23 10:35 ` Ilya Dryomov
@ 2026-04-23 11:44   ` Kefu Chai
  0 siblings, 0 replies; 3+ messages in thread
From: Kefu Chai @ 2026-04-23 11:44 UTC (permalink / raw)
  To: Ilya Dryomov; +Cc: ceph-devel, Alex Markuze, Viacheslav Dubeyko, linux-kernel

Ilya Dryomov <idryomov@gmail.com> writes:

> On Thu, Apr 23, 2026 at 12:09 PM Kefu Chai <k.chai@proxmox.com> wrote:
>>
>> ceph_decode_entity_addrvec() rejects any addrvec containing more than
>> one entry that matches the requested msgr type (LEGACY or MSGR2),
>> logging "another match of type N in addrvec" and returning -EINVAL.
>> This breaks legitimate deployments where a daemon advertises multiple
>> addresses of the same type, most notably dual-stack (IPv4 + IPv6)
>> clusters
>
> Hi Kefu,
>

Hi Ilya,

>
> My understanding is that dual-stack isn't supported in general:
> https://tracker.ceph.com/issues/65631.  The respective references were
> purged from the documentation with Radoslaw (offline?) ack.
>

Yeah, you are right. I was overreaching. Dual-stack and
heterogeneous-subnet clients are not served by multi-entry addrvecs, and
the patch does not change that.

>
>> and multi-subnet deployments where tooling picks one address
>> per listed public_network.
>
> Can you elaborate on when such tooling kicks in, what exactly does it
> do and the use case in general?  It's not immediately obvious to me how
> having two addresses of the same type/stack and simply ignoring the
> second one is better than insisting on having a just single address.
>

Sure. The narrow case that remains is compatibility. Admin tooling built
around public_addrv and ceph mon set-addrs produces addrvecs with more
than one entry of the same type on the back of that behavior, and the
kernel's strict guard rejects the whole monmap. The handshake contains()
check is the one concrete reason the extra entries need to be listed in
the addrvec rather than dropped at advertise time.

>
>> Match the userspace messenger, which since Nautilus picks the first
>> entry of the requested type and silently tolerates subsequent entries.
>
> Do you have a reference to a specific commit?  I'm wondering if it
> isn't on that "merged more or less accidentally" list.
>

The pick-first selector in AsyncMessenger::create_connect() landed in
Sage's commit d1a783a5f733, and Xie Xingguo's commit 50d8c8a3cce3 fixed
the loop to actually honor the "pick whichever is listed first" comment.
Both shipped in Nautilus.
  
Would you be willing to take this as a compatibility fix, with the
commit message and the comment in ceph_decode_entity_addrvec() rewritten
to state exactly that and nothing more? If you would rather keep the
strict check and handle this on the tooling side instead, I am happy to
withdraw the patch. Either way, thanks for the review.

Thanks,
Kefu

> Thanks,
>
>                 Ilya


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-04-23 11:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-23 10:09 [PATCH] libceph: accept addrvecs with multiple entries of the same type Kefu Chai
2026-04-23 10:35 ` Ilya Dryomov
2026-04-23 11:44   ` Kefu Chai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox