* [PATCH 1/2] exportfs: Refactor exportfs() and unexportfs()
2014-03-12 17:47 [PATCH 0/2] command line IPv6 support for exportfs Chuck Lever
@ 2014-03-12 17:47 ` Chuck Lever
2014-03-12 17:47 ` [PATCH 2/2] exportfs: Support raw IPv6 addresses with "client:/path" Chuck Lever
2014-03-17 14:39 ` [PATCH 0/2] command line IPv6 support for exportfs Steve Dickson
2 siblings, 0 replies; 4+ messages in thread
From: Chuck Lever @ 2014-03-12 17:47 UTC (permalink / raw)
To: linux-nfs
Separate parsing the "client:/path" argument from the actual
processing.
BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=817557
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
utils/exportfs/exportfs.c | 74 +++++++++++++++++++++++++++++++--------------
1 file changed, 51 insertions(+), 23 deletions(-)
diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c
index 8c86790..771d6eb 100644
--- a/utils/exportfs/exportfs.c
+++ b/utils/exportfs/exportfs.c
@@ -299,23 +299,13 @@ export_all(int verbose)
static void
-exportfs(char *arg, char *options, int verbose)
+exportfs_parsed(char *hname, char *path, char *options, int verbose)
{
struct exportent *eep;
nfs_export *exp = NULL;
struct addrinfo *ai = NULL;
- char *path;
- char *hname = arg;
int htype;
- if ((path = strchr(arg, ':')) != NULL)
- *path++ = '\0';
-
- if (!path || *path != '/') {
- xlog(L_ERROR, "Invalid exporting option: %s", arg);
- return;
- }
-
if ((htype = client_gettype(hname)) == MCL_FQDN) {
ai = host_addrinfo(hname);
if (ai != NULL) {
@@ -345,24 +335,38 @@ out:
freeaddrinfo(ai);
}
+static int exportfs_legacy(char *arg, char *options, int verbose)
+{
+ char *path;
+
+ if ((path = strchr(arg, ':')) != NULL)
+ *path++ = '\0';
+
+ if (!path || *path != '/')
+ return 1;
+
+ exportfs_parsed(arg, path, options, verbose);
+ return 0;
+}
+
static void
-unexportfs(char *arg, int verbose)
+exportfs(char *arg, char *options, int verbose)
+{
+ int failed;
+
+ failed = exportfs_legacy(arg, options, verbose);
+ if (failed)
+ xlog(L_ERROR, "Invalid export syntax: %s", arg);
+}
+
+static void
+unexportfs_parsed(char *hname, char *path, int verbose)
{
nfs_export *exp;
struct addrinfo *ai = NULL;
- char *path;
- char *hname = arg;
int htype;
int success = 0;
- if ((path = strchr(arg, ':')) != NULL)
- *path++ = '\0';
-
- if (!path || *path != '/') {
- xlog(L_ERROR, "Invalid unexporting option: %s", arg);
- return;
- }
-
if ((htype = client_gettype(hname)) == MCL_FQDN) {
ai = host_addrinfo(hname);
if (ai)
@@ -403,11 +407,35 @@ unexportfs(char *arg, int verbose)
success = 1;
}
if (!success)
- xlog(L_ERROR, "Could not find '%s:%s' to unexport.", arg, path);
+ xlog(L_ERROR, "Could not find '%s:%s' to unexport.", hname, path);
freeaddrinfo(ai);
}
+static int unexportfs_legacy(char *arg, int verbose)
+{
+ char *path;
+
+ if ((path = strchr(arg, ':')) != NULL)
+ *path++ = '\0';
+
+ if (!path || *path != '/')
+ return 1;
+
+ unexportfs_parsed(arg, path, verbose);
+ return 0;
+}
+
+static void
+unexportfs(char *arg, int verbose)
+{
+ int failed;
+
+ failed = unexportfs_legacy(arg, verbose);
+ if (failed)
+ xlog(L_ERROR, "Invalid export syntax: %s", arg);
+}
+
static int can_test(void)
{
char buf[1024];
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 2/2] exportfs: Support raw IPv6 addresses with "client:/path"
2014-03-12 17:47 [PATCH 0/2] command line IPv6 support for exportfs Chuck Lever
2014-03-12 17:47 ` [PATCH 1/2] exportfs: Refactor exportfs() and unexportfs() Chuck Lever
@ 2014-03-12 17:47 ` Chuck Lever
2014-03-17 14:39 ` [PATCH 0/2] command line IPv6 support for exportfs Steve Dickson
2 siblings, 0 replies; 4+ messages in thread
From: Chuck Lever @ 2014-03-12 17:47 UTC (permalink / raw)
To: linux-nfs
Wrap IPv6 presentation addresses in square brackets. This echoes
the same syntax used when specifying IPv6 server addresses with the
mount.nfs command.
BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=817557
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
utils/exportfs/exportfs.c | 64 ++++++++++++++++++++++++++++++++++++++++++-
utils/exportfs/exportfs.man | 16 +++++++++++
2 files changed, 78 insertions(+), 2 deletions(-)
diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c
index 771d6eb..2c8d64a 100644
--- a/utils/exportfs/exportfs.c
+++ b/utils/exportfs/exportfs.c
@@ -349,12 +349,42 @@ static int exportfs_legacy(char *arg, char *options, int verbose)
return 0;
}
+static int exportfs_ipv6(char *arg, char *options, int verbose)
+{
+ char *path, *c, hname[NI_MAXHOST + strlen("/128")];
+
+ arg++;
+ c = strchr(arg, ']');
+ if (c == NULL)
+ return 1;
+ strncpy(hname, arg, c - arg);
+
+ /* no colon means this is a wildcarded DNS hostname */
+ if (strchr(hname, ':') == NULL)
+ return exportfs_legacy(--arg, options, verbose);
+
+ path = strstr(c, ":/");
+ if (path == NULL)
+ return 1;
+ *path++ = '\0';
+
+ /* if there's anything between the closing brace and the
+ * path separator, it's probably a prefix length */
+ strcat(hname, ++c);
+
+ exportfs_parsed(hname, path, options, verbose);
+ return 0;
+}
+
static void
exportfs(char *arg, char *options, int verbose)
{
int failed;
- failed = exportfs_legacy(arg, options, verbose);
+ if (*arg == '[')
+ failed = exportfs_ipv6(arg, options, verbose);
+ else
+ failed = exportfs_legacy(arg, options, verbose);
if (failed)
xlog(L_ERROR, "Invalid export syntax: %s", arg);
}
@@ -426,12 +456,42 @@ static int unexportfs_legacy(char *arg, int verbose)
return 0;
}
+static int unexportfs_ipv6(char *arg, int verbose)
+{
+ char *path, *c, hname[NI_MAXHOST + strlen("/128")];
+
+ arg++;
+ c = strchr(arg, ']');
+ if (c == NULL)
+ return 1;
+ strncpy(hname, arg, c - arg);
+
+ /* no colon means this is a wildcarded DNS hostname */
+ if (strchr(hname, ':') == NULL)
+ return unexportfs_legacy(--arg, verbose);
+
+ path = strstr(c, ":/");
+ if (path == NULL)
+ return 1;
+ *path++ = '\0';
+
+ /* if there's anything between the closing brace and the
+ * path separator, it's probably a prefix length */
+ strcat(hname, ++c);
+
+ unexportfs_parsed(hname, path, verbose);
+ return 0;
+}
+
static void
unexportfs(char *arg, int verbose)
{
int failed;
- failed = unexportfs_legacy(arg, verbose);
+ if (*arg == '[')
+ failed = unexportfs_ipv6(arg, verbose);
+ else
+ failed = unexportfs_legacy(arg, verbose);
if (failed)
xlog(L_ERROR, "Invalid export syntax: %s", arg);
}
diff --git a/utils/exportfs/exportfs.man b/utils/exportfs/exportfs.man
index d481645..75d952a 100644
--- a/utils/exportfs/exportfs.man
+++ b/utils/exportfs/exportfs.man
@@ -159,6 +159,14 @@ along with the client or clients who are permitted to access it.
See
.B exports(5)
for a description of supported options and access list formats.
+.PP
+IPv6 presentation addresses contain colons, which are already used
+to separate the "host" and "path" command line arguments.
+When specifying a client using a raw IPv6 address,
+enclose the address in square brackets.
+For IPv6 network addresses, place the prefix just after the closing
+bracket.
+.PP
To export a directory to the world, simply specify
.IR :/path .
.PP
@@ -244,6 +252,14 @@ and files under
.nf
.B "# exportfs -au
.fi
+.PP
+To export the
+.I /usr/tmp
+directory to IPv6 link-local clients:
+.PP
+.nf
+.B "# exportfs [fe80::]/64:/usr/tmp
+.fi
.SH USAGE NOTES
Exporting to IP networks or DNS and NIS domains does not enable clients
from these groups to access NFS immediately.
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH 0/2] command line IPv6 support for exportfs
2014-03-12 17:47 [PATCH 0/2] command line IPv6 support for exportfs Chuck Lever
2014-03-12 17:47 ` [PATCH 1/2] exportfs: Refactor exportfs() and unexportfs() Chuck Lever
2014-03-12 17:47 ` [PATCH 2/2] exportfs: Support raw IPv6 addresses with "client:/path" Chuck Lever
@ 2014-03-17 14:39 ` Steve Dickson
2 siblings, 0 replies; 4+ messages in thread
From: Steve Dickson @ 2014-03-17 14:39 UTC (permalink / raw)
To: Chuck Lever, linux-nfs
On 03/12/2014 01:47 PM, Chuck Lever wrote:
> Though /etc/exports can contain IPv6 literals as client names, the
> exportfs command doesn't allow an IPv6 literal when adding or
> removing a temporary export.
>
> exportfs [-u] client:/path
>
> If "client" is an IPv6 presentation address, it contains colons.
> The problem is that exportfs already uses a colon to separate the
> client identifier from the export pathname.
>
> To escape colons in the client name, adopt the same mechanism that
> is used for mount.nfs. Users wrap IPv6 literals in square brackets.
>
> exportfs has to be a little more complicated than mount.nfs,
> however. It must still be able to distinguish hostname wildcards
> that use brackets, and be able to deal with network address
> prefixes.
>
> With this patch series,
>
> [abc]-machine.example.org:/export
>
> 192.168.76.16:/share
>
> [2604:8800:100:81fc:82ee:73ff:fe43:d64f]:/export/home
>
> [fe80::]/64:/var/tmp
>
> are now all accepted by exportfs.
>
> ---
>
> Chuck Lever (2):
> exportfs: Refactor exportfs() and unexportfs()
> exportfs: Support raw IPv6 addresses with "client:/path"
Both were committed...
steved.
>
>
> utils/exportfs/exportfs.c | 134 ++++++++++++++++++++++++++++++++++++-------
> utils/exportfs/exportfs.man | 16 +++++
> 2 files changed, 127 insertions(+), 23 deletions(-)
>
^ permalink raw reply [flat|nested] 4+ messages in thread