Commit 2d7c86a8 authored by Venky Shankar's avatar Venky Shankar Committed by Ilya Dryomov
Browse files

libceph: generalize addr/ip parsing based on delimiter



... and remove hardcoded function name in ceph_parse_ips().

[ idryomov: delim parameter, drop CEPH_ADDR_PARSE_DEFAULT_DELIM ]

Signed-off-by: default avatarVenky Shankar <vshankar@redhat.com>
Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
parent df0cc57e
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -6497,7 +6497,8 @@ static int rbd_add_parse_args(const char *buf,
	pctx.opts->exclusive = RBD_EXCLUSIVE_DEFAULT;
	pctx.opts->trim = RBD_TRIM_DEFAULT;

	ret = ceph_parse_mon_ips(mon_addrs, mon_addrs_size, pctx.copts, NULL);
	ret = ceph_parse_mon_ips(mon_addrs, mon_addrs_size, pctx.copts, NULL,
				 ',');
	if (ret)
		goto out_err;

+1 −1
Original line number Diff line number Diff line
@@ -272,7 +272,7 @@ static int ceph_parse_source(struct fs_parameter *param, struct fs_context *fc)
		dout("server path '%s'\n", fsopt->server_path);

	ret = ceph_parse_mon_ips(param->string, dev_name_end - dev_name,
				 pctx->copts, fc->log.log);
				 pctx->copts, fc->log.log, ',');
	if (ret)
		return ret;

+1 −1
Original line number Diff line number Diff line
@@ -301,7 +301,7 @@ struct fs_parameter;
struct fc_log;
struct ceph_options *ceph_alloc_options(void);
int ceph_parse_mon_ips(const char *buf, size_t len, struct ceph_options *opt,
		       struct fc_log *l);
		       struct fc_log *l, char delim);
int ceph_parse_param(struct fs_parameter *param, struct ceph_options *opt,
		     struct fc_log *l);
int ceph_print_client_options(struct seq_file *m, struct ceph_client *client,
+1 −1
Original line number Diff line number Diff line
@@ -532,7 +532,7 @@ extern const char *ceph_pr_addr(const struct ceph_entity_addr *addr);

extern int ceph_parse_ips(const char *c, const char *end,
			  struct ceph_entity_addr *addr,
			  int max_count, int *count);
			  int max_count, int *count, char delim);

extern int ceph_msgr_init(void);
extern void ceph_msgr_exit(void);
+4 −5
Original line number Diff line number Diff line
@@ -422,14 +422,14 @@ static int get_secret(struct ceph_crypto_key *dst, const char *name,
}

int ceph_parse_mon_ips(const char *buf, size_t len, struct ceph_options *opt,
		       struct fc_log *l)
		       struct fc_log *l, char delim)
{
	struct p_log log = {.prefix = "libceph", .log = l};
	int ret;

	/* ip1[:port1][,ip2[:port2]...] */
	/* ip1[:port1][<delim>ip2[:port2]...] */
	ret = ceph_parse_ips(buf, buf + len, opt->mon_addr, CEPH_MAX_MON,
			     &opt->num_mon);
			     &opt->num_mon, delim);
	if (ret) {
		error_plog(&log, "Failed to parse monitor IPs: %d", ret);
		return ret;
@@ -455,8 +455,7 @@ int ceph_parse_param(struct fs_parameter *param, struct ceph_options *opt,
	case Opt_ip:
		err = ceph_parse_ips(param->string,
				     param->string + param->size,
				     &opt->my_addr,
				     1, NULL);
				     &opt->my_addr, 1, NULL, ',');
		if (err) {
			error_plog(&log, "Failed to parse ip: %d", err);
			return err;
Loading