From: Ian Kent <raven@themaw.net>
To: autofs mailing list <autofs@vger.kernel.org>
Subject: [PATCH 18/35] autofs-5.1.3 - fix ipv6 proto option handling
Date: Mon, 16 Oct 2017 13:07:49 +0800 [thread overview]
Message-ID: <150813046950.25695.1103281677112793770.stgit@pluto.themaw.net> (raw)
In-Reply-To: <150813019190.25695.13810689562896522990.stgit@pluto.themaw.net>
If the option proto=(tcp6|udp6) is given on the NFS mount command line
autofs does not properly recognise it needs to probe only the given
protocol for matching address type.
Signed-off-by: Ian Kent <raven@themaw.net>
Reported-by: Andreas Steinmetz <ast@domdv.de>
---
CHANGELOG | 1 +
include/replicated.h | 2 ++
modules/mount_nfs.c | 15 ++++++++++++++-
modules/replicated.c | 29 +++++++++++++++++++++++++++++
4 files changed, 46 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 94e79a0c..af8b099c 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -16,6 +16,7 @@ xx/xx/2017 autofs-5.1.4
- fix some man page problems.
- add some more debug logging to get_nfs_info().
- add some more debug logging to get_supported_ver_and_cost().
+- fix ipv6 proto option handling.
24/05/2017 autofs-5.1.3
=======================
diff --git a/include/replicated.h b/include/replicated.h
index 5e142f4f..69ab7800 100644
--- a/include/replicated.h
+++ b/include/replicated.h
@@ -37,6 +37,8 @@
#define UDP_SUPPORTED 0x0002
#define TCP_REQUESTED TCP_SUPPORTED
#define UDP_REQUESTED UDP_SUPPORTED
+#define TCP6_REQUESTED 0x0100
+#define UDP6_REQUESTED 0x0200
#define NFS_PROTO_MASK (TCP_SUPPORTED|UDP_SUPPORTED)
#define NFS2_TCP_SUPPORTED NFS2_SUPPORTED
diff --git a/modules/mount_nfs.c b/modules/mount_nfs.c
index 97f12c4d..63f16b19 100644
--- a/modules/mount_nfs.c
+++ b/modules/mount_nfs.c
@@ -172,9 +172,17 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
} else if (_strncmp("proto=udp", cp, o_len) == 0 ||
_strncmp("udp", cp, o_len) == 0) {
vers &= ~TCP_SUPPORTED;
+ } else if (_strncmp("proto=udp6", cp, o_len) == 0 ||
+ _strncmp("udp6", cp, o_len) == 0) {
+ vers &= ~TCP_SUPPORTED;
+ vers |= UDP6_REQUESTED;
} else if (_strncmp("proto=tcp", cp, o_len) == 0 ||
_strncmp("tcp", cp, o_len) == 0) {
vers &= ~UDP_SUPPORTED;
+ } else if (_strncmp("proto=tcp6", cp, o_len) == 0 ||
+ _strncmp("tcp6", cp, o_len) == 0) {
+ vers &= ~UDP_SUPPORTED;
+ vers |= TCP6_REQUESTED;
}
/* Check for options that also make sense
with bind mounts */
@@ -214,11 +222,16 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
* configuration only probe NFSv4 and let mount.nfs(8) do fallback
* to NFSv3 (if it can). If the NFSv4 probe fails then probe as
* normal.
+ *
+ * Note: some NFS servers consider it a protocol violation to use
+ * NFSv4 over UDP so if it has been requested in the mount options
+ * we can't use this at all.
*/
if ((hosts && !hosts->next) &&
mount_default_proto == 4 &&
(vers & NFS_VERS_MASK) != 0 &&
- (vers & NFS4_VERS_MASK) != 0) {
+ (vers & NFS4_VERS_MASK) != 0 &&
+ !(vers & UDP6_REQUESTED)) {
unsigned int v4_probe_ok = 0;
struct host *tmp = new_host(hosts->name,
hosts->addr, hosts->addr_len,
diff --git a/modules/replicated.c b/modules/replicated.c
index 634275b8..de5a4b06 100644
--- a/modules/replicated.c
+++ b/modules/replicated.c
@@ -484,6 +484,29 @@ done_ver:
return supported;
}
+static int check_address_proto(unsigned logopt,
+ struct host *host, unsigned int version)
+{
+ int ipv6_requested = version & (TCP6_REQUESTED | UDP6_REQUESTED);
+ int ret = 1;
+
+ /* If a protocol has been explicitly requested then don't
+ * consider addresses that don't match the requested protocol.
+ */
+ if (ipv6_requested) {
+ if (host->addr_len == INET_ADDRSTRLEN)
+ ret = 0;
+ } else {
+ if (host->addr_len == INET6_ADDRSTRLEN)
+ ret = 0;
+ }
+
+ if (!ret)
+ debug(logopt, "requested protocol does not match address");
+
+ return ret;
+}
+
static int get_vers_and_cost(unsigned logopt, struct host *host,
unsigned int version, int port)
{
@@ -492,6 +515,9 @@ static int get_vers_and_cost(unsigned logopt, struct host *host,
unsigned int supported, vers = (NFS_VERS_MASK | NFS4_VERS_MASK);
int ret = 0;
+ if (!check_address_proto(logopt, host, version))
+ return 0;
+
memset(&pm_info, 0, sizeof(struct conn_info));
memset(&rpc_info, 0, sizeof(struct conn_info));
@@ -561,6 +587,9 @@ static int get_supported_ver_and_cost(unsigned logopt, struct host *host,
debug(logopt, "called with host %s version 0x%x",
host->name, version);
+ if (!check_address_proto(logopt, host, version))
+ return 0;
+
memset(&pm_info, 0, sizeof(struct conn_info));
memset(&rpc_info, 0, sizeof(struct conn_info));
--
To unsubscribe from this list: send the line "unsubscribe autofs" in
next prev parent reply other threads:[~2017-10-16 5:07 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-16 5:05 [PATCH 00/35] Current autofs patch queue (lets try again) Ian Kent
2017-10-16 5:05 ` [PATCH 01/35] autofs-5.1.3 - fix spec file url Ian Kent
2017-10-16 5:06 ` [PATCH 02/35] autofs-5.1.3 - fix unset tsd group name handling Ian Kent
2017-10-16 5:06 ` [PATCH 03/35] autofs-5.1.3 - Add -c option when calling /bin/umount - if supported Ian Kent
2017-10-16 5:06 ` [PATCH 04/35] autofs-5.1.3 - remove some redundant rpc library code Ian Kent
2017-10-16 5:06 ` [PATCH 05/35] autofs-5.1.3 - add port parameter to rpc_ping() Ian Kent
2017-10-16 5:06 ` [PATCH 06/35] autofs-5.1.3 - dont probe NFSv2 by default Ian Kent
2017-10-16 5:06 ` [PATCH 07/35] autofs-5.1.3 - add version parameter to rpc_ping() Ian Kent
2017-10-16 5:06 ` [PATCH 08/35] autofs-5.1.3 - fix typo in autofs config file comments Ian Kent
2017-10-16 5:06 ` [PATCH 09/35] autofs-5.1.3 - fix typos in autofs man pages Ian Kent
2017-10-16 5:06 ` [PATCH 10/35] autofs-5.1.3 - use pkg-config to search for libtirpc to fix cross-compilation Ian Kent
2017-10-16 5:07 ` [PATCH 11/35] autofs-5.1.3 - fix incorrect status return in get_nfs_info() Ian Kent
2017-10-16 5:07 ` [PATCH 12/35] autofs-5.1.3 - fix a couple of compiler warnings Ian Kent
2017-10-18 20:46 ` Jeff Mahoney
2017-10-18 20:57 ` [PATCH] autofs-5.1.3 - fix ordering of seteuid/setegid in do_spawn Jeff Mahoney
2017-10-18 21:07 ` Jeff Mahoney
2017-10-19 1:59 ` Ian Kent
2017-10-18 21:12 ` [PATCH v2] " Jeff Mahoney
2017-10-19 2:07 ` Ian Kent
2017-10-19 2:20 ` Jeff Mahoney
2017-10-19 2:29 ` Ian Kent
2017-10-16 5:07 ` [PATCH 13/35] autofs-5.1.3 - set systemd KillMode to process Ian Kent
2017-10-16 5:07 ` [PATCH 14/35] autofs-5.1.3 - fix mount.nfs blocks on first mount Ian Kent
2017-10-16 5:07 ` [PATCH 15/35] autofs-5.1.3 - fix some man page problems Ian Kent
2017-10-16 5:07 ` [PATCH 16/35] autofs-5.1.3 - add some more debug logging to get_nfs_info() Ian Kent
2017-10-16 5:46 ` Vincent McIntyre
2017-10-16 5:52 ` Ian Kent
2017-10-16 5:07 ` [PATCH 17/35] autofs-5.1.3 - add some more debug logging to get_supported_ver_and_cost() Ian Kent
2017-10-16 5:07 ` Ian Kent [this message]
2017-10-16 5:07 ` [PATCH 19/35] autofs-5.1.3 - also check flag file exe name Ian Kent
2017-10-16 5:08 ` [PATCH 20/35] autofs-5.1.3 - fix possible map instance memory leak Ian Kent
2017-10-16 5:08 ` [PATCH 21/35] autofs-5.1.3 - check map instances for staleness on map update Ian Kent
2017-10-16 5:08 ` [PATCH 22/35] autofs-5.1.3 - allow dot in OPTIONSTR value lexer pattern Ian Kent
2017-10-16 5:08 ` [PATCH 23/35] autofs-5.1.3 - fix autofs_use_lofs description Ian Kent
2017-10-16 5:08 ` [PATCH 24/35] autofs-5.1.3 - fix amd parser error buffer size Ian Kent
2017-10-16 5:08 ` [PATCH 25/35] autofs-5.1.3 - make spawn_bind_mount() use mount_wait as well Ian Kent
2017-10-16 5:08 ` [PATCH 26/35] autofs-5.1.3 - document ghost option in auto.master man page Ian Kent
2017-10-16 6:00 ` Vincent McIntyre
2017-10-16 6:07 ` Ian Kent
2017-10-16 5:08 ` [PATCH 27/35] autofs-5.1.3 - only take master map mutex for master map update Ian Kent
2017-10-16 5:08 ` [PATCH 28/35] autofs-5.1.3 - revert fix argc off by one in mount_autofs.c Ian Kent
2017-10-16 5:08 ` [PATCH 29/35] autofs-5.1.3 - fix nisplus lookup init not configured check Ian Kent
2017-10-16 5:09 ` [PATCH 30/35] autofs-5.1.3 - make open_lookup() error handling more consistent Ian Kent
2017-10-16 5:09 ` [PATCH 31/35] autofs-5.1.3 - be silent about sss library not found Ian Kent
2017-10-16 5:09 ` [PATCH 32/35] autofs-5.1.3 - be silent about nis domain not set Ian Kent
2017-10-16 5:09 ` [PATCH 33/35] autofs-5.1.3 - make map source reference message debug only Ian Kent
2017-10-16 5:09 ` [PATCH 34/35] autofs-5.1.3 - improve description of mount_nfs_default_protocol Ian Kent
2017-10-16 5:37 ` Vincent McIntyre
2017-10-16 5:51 ` Ian Kent
2017-10-16 5:09 ` [PATCH 35/35] autofs-5.1.3 - port option should not behave like nobind option Ian Kent
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=150813046950.25695.1103281677112793770.stgit@pluto.themaw.net \
--to=raven@themaw.net \
--cc=autofs@vger.kernel.org \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).