extern "C" void mount_ceph_get_config_info(const char *config_file,
const char *name,
+ bool v2_addrs,
struct ceph_config_info *cci)
{
int err;
for (const auto& mon : monc.monmap.addr_mons) {
auto& eaddr = mon.first;
- // For now, kernel client only accepts legacy addrs
- if (!eaddr.is_legacy())
- continue;
+ /*
+ * Filter v1 addrs if we're running in ms_mode=legacy. Filter
+ * v2 addrs for any other ms_mode.
+ */
+ if (v2_addrs) {
+ if (!eaddr.is_msgr2())
+ continue;
+ } else {
+ if (!eaddr.is_legacy())
+ continue;
+ }
std::string addr;
addr += eaddr.ip_only_to_str();
bool verboseflag = false;
bool skip_mtab_flag = false;
+bool v2_addrs = false;
static const char * const EMPTY_STRING = "";
/* TODO duplicates logic from kernel */
ret = drop_capabilities();
if (ret)
exit(1);
- mount_ceph_get_config_info(cmi->cmi_conf, cmi->cmi_name, cci);
+ mount_ceph_get_config_info(cmi->cmi_conf, cmi->cmi_name, v2_addrs, cci);
exit(0);
} else {
/* parent */
/* keep pointer to value */
name = value;
skip = false;
+ } else if (strcmp(data, "ms_mode") == 0) {
+ if (!value || !*value) {
+ fprintf(stderr, "mount option ms_mode requires a value.\n");
+ return -EINVAL;
+ }
+ /* Only legacy ms_mode needs v1 addrs */
+ v2_addrs = strcmp(value, "legacy");
+ skip = false;
} else {
/* unrecognized mount options, passing to kernel */
skip = false;
};
void mount_ceph_get_config_info(const char *config_file, const char *name,
- struct ceph_config_info *cci);
+ bool v2_addrs, struct ceph_config_info *cci);
#ifdef __cplusplus
}