From: "Aurélien Aptel" <aaptel@suse.com>
To: Paulo Alcantara <pc@cjr.nz>,
linux-cifs@vger.kernel.org, piastryyy@gmail.com
Cc: Paulo Alcantara <pc@cjr.nz>
Subject: Re: [PATCH cifs-utils] mount.cifs: handle multiple ip addresses per hostname
Date: Tue, 11 May 2021 19:46:31 +0200 [thread overview]
Message-ID: <8735uttb7s.fsf@suse.com> (raw)
In-Reply-To: <20210511163952.11670-1-pc@cjr.nz>
I would put in the commit msg that this requires recent kernel.
We should probably merge kernel code first so we can reference it here
in the commit msg, and say in the man page when did the kernel change.
There can be cases where cifs-utils is more recent than kernel and
mount.cifs will pass all the ip instead of trying them before passing
the good one to the kernel but since it's an old kernel it won't try
them all. We could add an option to enable new behavior or check the
kernel version from within mount.cifs.. thoughts?
Paulo Alcantara <pc@cjr.nz> writes:
>
> +static void set_ip_params(char *options, size_t options_size, char *addrlist)
> +{
> + char *s = addrlist + strlen(addrlist), *q = s;
> + char tmp;
> +
> + do {
> + for (; s >= addrlist && *s != ','; s--);
> + tmp = *q;
> + *q = '\0';
> + strlcat(options, *options ? ",ip=" : "ip=", options_size);
> + strlcat(options, s + 1, options_size);
> + *q = tmp;
> + } while (q = s--, s >= addrlist);
> +}
I think you should write this in a clearer way and comment, this is hard
to read. What does addrlist value looks like for example? Why are we
copying things backward?
Why is the last 'q' in the while condition instead of the end of the while block?
I was going to say should we return errors if we truncate the ips, but
none of the mount.cifs.c code checks for truncation so I guess we can
ignore.
> +
> int main(int argc, char **argv)
> {
> int c;
> @@ -2043,7 +2058,6 @@ int main(int argc, char **argv)
> char *mountpoint = NULL;
> char *options = NULL;
> char *orig_dev = NULL;
> - char *currentaddress, *nextaddress;
> char *value = NULL;
> char *ep = NULL;
> int rc = 0;
> @@ -2201,20 +2215,10 @@ assemble_retry:
> goto mount_exit;
> }
>
> - currentaddress = parsed_info->addrlist;
> - nextaddress = strchr(currentaddress, ',');
> - if (nextaddress)
> - *nextaddress++ = '\0';
> -
> mount_retry:
> options[0] = '\0';
> - if (!currentaddress) {
> - fprintf(stderr, "Unable to find suitable address.\n");
> - rc = parsed_info->nofail ? 0 : EX_FAIL;
> - goto mount_exit;
> - }
> - strlcpy(options, "ip=", options_size);
> - strlcat(options, currentaddress, options_size);
> +
> + set_ip_params(options, options_size, parsed_info->addrlist);
>
> strlcat(options, ",unc=\\\\", options_size);
> strlcat(options, parsed_info->host, options_size);
> @@ -2266,17 +2270,9 @@ mount_retry:
> switch (errno) {
> case ECONNREFUSED:
> case EHOSTUNREACH:
> - if (currentaddress) {
> - fprintf(stderr, "mount error(%d): could not connect to %s",
> - errno, currentaddress);
> - }
> - currentaddress = nextaddress;
> - if (currentaddress) {
> - nextaddress = strchr(currentaddress, ',');
> - if (nextaddress)
> - *nextaddress++ = '\0';
> - }
> - goto mount_retry;
> + fprintf(stderr, "mount error(%d): could not connect to: %s", errno, parsed_info->addrlist);
> + rc = parsed_info->nofail ? 0 : EX_FAIL;
> + break;
> case ENODEV:
> fprintf(stderr,
> "mount error: %s filesystem not supported by the system\n", cifs_fstype);
Ok, so now we pass all IPs to mount() and we don't retry.
I would add a comment before the break to say that the kernel will try
all the IPs so if we get these errors none of them worked.
Cheers,
--
Aurélien Aptel / SUSE Labs Samba Team
GPG: 1839 CB5F 9F5B FB9B AA97 8C99 03C8 A49B 521B D5D3
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg, DE
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 247165 (AG München)
next prev parent reply other threads:[~2021-05-11 17:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-11 16:39 [PATCH cifs-utils] mount.cifs: handle multiple ip addresses per hostname Paulo Alcantara
2021-05-11 17:46 ` Aurélien Aptel [this message]
2021-05-11 18:06 ` Steve French
2021-05-11 18:20 ` Paulo Alcantara
2021-07-08 23:00 ` Pavel Shilovsky
2021-07-09 14:50 ` Paulo Alcantara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8735uttb7s.fsf@suse.com \
--to=aaptel@suse.com \
--cc=linux-cifs@vger.kernel.org \
--cc=pc@cjr.nz \
--cc=piastryyy@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox