* [PATCH 1/5] nfs-utils: make getnameinfo() required for --enable-gss
2009-04-05 13:42 [PATCH 0/5] nfs-utils: convert gssd to TI-RPC and add IPv6 support (try #3) Jeff Layton
@ 2009-04-05 13:42 ` Jeff Layton
2009-04-06 15:05 ` Chuck Lever
2009-04-05 13:43 ` [PATCH 2/5] nfs-utils: store the address given in the upcall for later use Jeff Layton
` (3 subsequent siblings)
4 siblings, 1 reply; 15+ messages in thread
From: Jeff Layton @ 2009-04-05 13:42 UTC (permalink / raw)
To: linux-nfs, nfsv4; +Cc: chuck.lever, kwc
Systems that are so old that they don't have getnameinfo() in glibc are
probably also running kernels that are so old that they don't support
gssapi upcalls anyway.
Make --enable-gss dependent on the presence of the getnameinfo()
function. This allows us to reduce some conditional compilation.
Signed-off-by: Jeff Layton <jlayton@redhat.com>
---
configure.ac | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/configure.ac b/configure.ac
index e34b7e2..00aee35 100644
--- a/configure.ac
+++ b/configure.ac
@@ -207,6 +207,8 @@ if test "$enable_nfsv4" = yes; then
dnl but we need to make sure we get the right version
if test "$enable_gss" = yes; then
AC_RPCSEC_VERSION
+ AC_CHECK_FUNC([getnameinfo], ,
+ [AC_MSG_ERROR([Function 'getnameinfo' not found.])])
fi
fi
--
1.6.0.6
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH 1/5] nfs-utils: make getnameinfo() required for --enable-gss
2009-04-05 13:42 ` [PATCH 1/5] nfs-utils: make getnameinfo() required for --enable-gss Jeff Layton
@ 2009-04-06 15:05 ` Chuck Lever
0 siblings, 0 replies; 15+ messages in thread
From: Chuck Lever @ 2009-04-06 15:05 UTC (permalink / raw)
To: Jeff Layton; +Cc: linux-nfs, nfsv4
On Apr 5, 2009, at 9:42 AM, Jeff Layton wrote:
> Systems that are so old that they don't have getnameinfo() in glibc
> are
> probably also running kernels that are so old that they don't support
> gssapi upcalls anyway.
>
> Make --enable-gss dependent on the presence of the getnameinfo()
> function. This allows us to reduce some conditional compilation.
>
> Signed-off-by: Jeff Layton <jlayton@redhat.com>
> ---
> configure.ac | 2 ++
> 1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index e34b7e2..00aee35 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -207,6 +207,8 @@ if test "$enable_nfsv4" = yes; then
> dnl but we need to make sure we get the right version
> if test "$enable_gss" = yes; then
> AC_RPCSEC_VERSION
> + AC_CHECK_FUNC([getnameinfo], ,
> + [AC_MSG_ERROR([Function 'getnameinfo' not found.])])
> fi
> fi
This check is only done when enable_nfsv4 is set. Probably a better
place for this is in the enable_gss test that is always done, a few
paragraphs lower.
--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 2/5] nfs-utils: store the address given in the upcall for later use
2009-04-05 13:42 [PATCH 0/5] nfs-utils: convert gssd to TI-RPC and add IPv6 support (try #3) Jeff Layton
2009-04-05 13:42 ` [PATCH 1/5] nfs-utils: make getnameinfo() required for --enable-gss Jeff Layton
@ 2009-04-05 13:43 ` Jeff Layton
2009-04-06 15:35 ` Chuck Lever
2009-04-05 13:43 ` [PATCH 3/5] nfs-utils: skip getaddrinfo in create_auth_rpc_client unless we need port Jeff Layton
` (2 subsequent siblings)
4 siblings, 1 reply; 15+ messages in thread
From: Jeff Layton @ 2009-04-05 13:43 UTC (permalink / raw)
To: linux-nfs, nfsv4
The current upcall could be more efficient. We first convert the address
to a hostname, and then later when we set up the RPC client, we do a
hostname lookup to convert it back to an address.
Begin to change this by keeping the address in the clnt_info that we get
out of the upcall. Since a sockaddr has a port field, we can also
eliminate the port from the clnt_info.
Finally, switch to getnameinfo() instead of gethostbyaddr(). We'll need
to use that call anyway when we add support for IPv6.
Signed-off-by: Jeff Layton <jlayton@redhat.com>
---
utils/gssd/gssd.h | 2 +-
utils/gssd/gssd_proc.c | 92 +++++++++++++++++++++++++++++++++++++++--------
2 files changed, 77 insertions(+), 17 deletions(-)
diff --git a/utils/gssd/gssd.h b/utils/gssd/gssd.h
index 082039a..3c52f46 100644
--- a/utils/gssd/gssd.h
+++ b/utils/gssd/gssd.h
@@ -83,7 +83,7 @@ struct clnt_info {
int krb5_poll_index;
int spkm3_fd;
int spkm3_poll_index;
- int port;
+ struct sockaddr_storage addr;
};
void init_client_list(void);
diff --git a/utils/gssd/gssd_proc.c b/utils/gssd/gssd_proc.c
index 509946e..be17019 100644
--- a/utils/gssd/gssd_proc.c
+++ b/utils/gssd/gssd_proc.c
@@ -102,10 +102,65 @@ struct pollfd * pollarray;
int pollsize; /* the size of pollaray (in pollfd's) */
+/*
+ * convert an address string to a sockaddr_storage struct. Returns true
+ * on success and false on failure.
+ */
+static int
+addrstr_to_sockaddr(struct sockaddr *sa, const char *addr, const int port)
+{
+ struct sockaddr_in *s4 = (struct sockaddr_in *) sa;
+
+ if (inet_pton(AF_INET, addr, &s4->sin_addr)) {
+ s4->sin_family = AF_INET;
+ s4->sin_port = htons(port);
+ } else {
+ printerr(0, "ERROR: unable to convert %s to address\n", addr);
+ return 0;
+ }
+
+ return 1;
+}
+
+/*
+ * convert a sockaddr to a hostname
+ */
+static char *
+sockaddr_to_hostname(const struct sockaddr *sa, const char *addr)
+{
+ socklen_t addrlen;
+ int err;
+ char *hostname;
+ char hbuf[NI_MAXHOST];
+
+ switch (sa->sa_family) {
+ case AF_INET:
+ addrlen = sizeof(struct sockaddr_in);
+ break;
+ default:
+ printerr(0, "ERROR: unrecognized addr family %d\n",
+ sa->sa_family);
+ return NULL;
+ }
+
+ err = getnameinfo(sa, addrlen, hbuf, sizeof(hbuf), NULL, 0,
+ NI_NAMEREQD);
+ if (err) {
+ printerr(0, "ERROR: unable to resolve %s to hostname: %s\n",
+ addr, gai_strerror(err));
+ return NULL;
+ }
+
+ hostname = strdup(hbuf);
+
+ return hostname;
+}
+
/* XXX buffer problems: */
static int
read_service_info(char *info_file_name, char **servicename, char **servername,
- int *prog, int *vers, char **protocol, int *port) {
+ int *prog, int *vers, char **protocol,
+ struct sockaddr *addr) {
#define INFOBUFLEN 256
char buf[INFOBUFLEN + 1];
static char dummy[128];
@@ -117,10 +172,9 @@ read_service_info(char *info_file_name, char **servicename, char **servername,
char protoname[16];
char cb_port[128];
char *p;
- in_addr_t inaddr;
int fd = -1;
- struct hostent *ent = NULL;
int numfields;
+ int port = 0;
*servicename = *servername = *protocol = NULL;
@@ -160,21 +214,26 @@ read_service_info(char *info_file_name, char **servicename, char **servername,
if((*prog != 100003) || ((*vers != 2) && (*vers != 3) && (*vers != 4)))
goto fail;
- /* create service name */
- inaddr = inet_addr(address);
- if (!(ent = gethostbyaddr(&inaddr, sizeof(inaddr), AF_INET))) {
- printerr(0, "ERROR: can't resolve server %s name\n", address);
- goto fail;
+ if (cb_port[0] != '\0') {
+ port = atoi(cb_port);
+ if (port < 0 || port > 65535)
+ goto fail;
}
- if (!(*servername = calloc(strlen(ent->h_name) + 1, 1)))
+
+ if (!addrstr_to_sockaddr(addr, address, port))
+ goto fail;
+
+ *servername = sockaddr_to_hostname(addr, address);
+ if (*servername == NULL)
goto fail;
- memcpy(*servername, ent->h_name, strlen(ent->h_name));
- snprintf(buf, INFOBUFLEN, "%s@%s", service, ent->h_name);
+
+ nbytes = snprintf(buf, INFOBUFLEN, "%s@%s", service, *servername);
+ if (nbytes > INFOBUFLEN)
+ goto fail;
+
if (!(*servicename = calloc(strlen(buf) + 1, 1)))
goto fail;
memcpy(*servicename, buf, strlen(buf));
- if (cb_port[0] != '\0')
- *port = atoi(cb_port);
if (!(*protocol = strdup(protoname)))
goto fail;
@@ -251,7 +310,7 @@ process_clnt_dir_files(struct clnt_info * clp)
if ((clp->servicename == NULL) &&
read_service_info(info_file_name, &clp->servicename,
&clp->servername, &clp->prog, &clp->vers,
- &clp->protocol, &clp->port))
+ &clp->protocol, (struct sockaddr *) &clp->addr))
return -1;
return 0;
}
@@ -599,8 +658,9 @@ int create_auth_rpc_client(struct clnt_info *clp,
clp->servername, uid);
goto out_fail;
}
- if (clp->port)
- ((struct sockaddr_in *)a->ai_addr)->sin_port = htons(clp->port);
+ if (((struct sockaddr_in) clp->addr).sin_port != 0)
+ ((struct sockaddr_in *) a->ai_addr)->sin_port =
+ ((struct sockaddr_in) clp->addr).sin_port;
if (a->ai_protocol == IPPROTO_TCP) {
if ((rpc_clnt = clnttcp_create(
(struct sockaddr_in *) a->ai_addr,
--
1.6.0.6
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH 2/5] nfs-utils: store the address given in the upcall for later use
2009-04-05 13:43 ` [PATCH 2/5] nfs-utils: store the address given in the upcall for later use Jeff Layton
@ 2009-04-06 15:35 ` Chuck Lever
2009-04-06 16:31 ` Jeff Layton
0 siblings, 1 reply; 15+ messages in thread
From: Chuck Lever @ 2009-04-06 15:35 UTC (permalink / raw)
To: Jeff Layton; +Cc: linux-nfs, nfsv4
On Apr 5, 2009, at 9:43 AM, Jeff Layton wrote:
> The current upcall could be more efficient. We first convert the
> address
> to a hostname, and then later when we set up the RPC client, we do a
> hostname lookup to convert it back to an address.
>
> Begin to change this by keeping the address in the clnt_info that we
> get
> out of the upcall. Since a sockaddr has a port field, we can also
> eliminate the port from the clnt_info.
>
> Finally, switch to getnameinfo() instead of gethostbyaddr(). We'll
> need
> to use that call anyway when we add support for IPv6.
gethostbyaddr(3) supports AF_INET6, too, by the way.
> Signed-off-by: Jeff Layton <jlayton@redhat.com>
> ---
> utils/gssd/gssd.h | 2 +-
> utils/gssd/gssd_proc.c | 92 ++++++++++++++++++++++++++++++++++++++
> +--------
> 2 files changed, 77 insertions(+), 17 deletions(-)
>
> diff --git a/utils/gssd/gssd.h b/utils/gssd/gssd.h
> index 082039a..3c52f46 100644
> --- a/utils/gssd/gssd.h
> +++ b/utils/gssd/gssd.h
> @@ -83,7 +83,7 @@ struct clnt_info {
> int krb5_poll_index;
> int spkm3_fd;
> int spkm3_poll_index;
> - int port;
> + struct sockaddr_storage addr;
> };
>
> void init_client_list(void);
> diff --git a/utils/gssd/gssd_proc.c b/utils/gssd/gssd_proc.c
> index 509946e..be17019 100644
> --- a/utils/gssd/gssd_proc.c
> +++ b/utils/gssd/gssd_proc.c
> @@ -102,10 +102,65 @@ struct pollfd * pollarray;
>
> int pollsize; /* the size of pollaray (in pollfd's) */
>
> +/*
> + * convert an address string to a sockaddr_storage struct. Returns
> true
> + * on success and false on failure.
I usually use the term "presentation address string" since that
specifically means an IP address expressed as a C string. I guess
that's pretty obvious because you use inet_pton() here.
> + */
> +static int
> +addrstr_to_sockaddr(struct sockaddr *sa, const char *addr, const
> int port)
> +{
> + struct sockaddr_in *s4 = (struct sockaddr_in *) sa;
> +
> + if (inet_pton(AF_INET, addr, &s4->sin_addr)) {
> + s4->sin_family = AF_INET;
> + s4->sin_port = htons(port);
> + } else {
> + printerr(0, "ERROR: unable to convert %s to address\n", addr);
> + return 0;
> + }
I've handled these with a switch statement, as you do later in
populate_port(). It's merely a question about consistent coding
style, but any reason not to take that approach here?
> +
> + return 1;
> +}
> +
> +/*
> + * convert a sockaddr to a hostname
> + */
> +static char *
> +sockaddr_to_hostname(const struct sockaddr *sa, const char *addr)
> +{
> + socklen_t addrlen;
> + int err;
> + char *hostname;
> + char hbuf[NI_MAXHOST];
> +
> + switch (sa->sa_family) {
> + case AF_INET:
> + addrlen = sizeof(struct sockaddr_in);
> + break;
> + default:
> + printerr(0, "ERROR: unrecognized addr family %d\n",
> + sa->sa_family);
> + return NULL;
> + }
> +
> + err = getnameinfo(sa, addrlen, hbuf, sizeof(hbuf), NULL, 0,
> + NI_NAMEREQD);
> + if (err) {
> + printerr(0, "ERROR: unable to resolve %s to hostname: %s\n",
> + addr, gai_strerror(err));
> + return NULL;
> + }
getnameinfo(3) can return EAI_SYSTEM, in which case the real error
value is stored in errno Browsing the gai_strerror(3) implementation
in glibc-2.7 seems to show that it's just a simple static char table
lookup, so it might be good to handle EAI_SYSTEM explicitly here.
Looks like you already do that in populate_port().
> +
> + hostname = strdup(hbuf);
> +
> + return hostname;
> +}
> +
> /* XXX buffer problems: */
> static int
> read_service_info(char *info_file_name, char **servicename, char
> **servername,
> - int *prog, int *vers, char **protocol, int *port) {
> + int *prog, int *vers, char **protocol,
> + struct sockaddr *addr) {
> #define INFOBUFLEN 256
> char buf[INFOBUFLEN + 1];
> static char dummy[128];
> @@ -117,10 +172,9 @@ read_service_info(char *info_file_name, char
> **servicename, char **servername,
> char protoname[16];
> char cb_port[128];
> char *p;
> - in_addr_t inaddr;
> int fd = -1;
> - struct hostent *ent = NULL;
> int numfields;
> + int port = 0;
>
> *servicename = *servername = *protocol = NULL;
>
> @@ -160,21 +214,26 @@ read_service_info(char *info_file_name, char
> **servicename, char **servername,
> if((*prog != 100003) || ((*vers != 2) && (*vers != 3) && (*vers !=
> 4)))
> goto fail;
>
> - /* create service name */
> - inaddr = inet_addr(address);
> - if (!(ent = gethostbyaddr(&inaddr, sizeof(inaddr), AF_INET))) {
> - printerr(0, "ERROR: can't resolve server %s name\n", address);
> - goto fail;
> + if (cb_port[0] != '\0') {
> + port = atoi(cb_port);
> + if (port < 0 || port > 65535)
> + goto fail;
> }
> - if (!(*servername = calloc(strlen(ent->h_name) + 1, 1)))
> +
> + if (!addrstr_to_sockaddr(addr, address, port))
> + goto fail;
> +
> + *servername = sockaddr_to_hostname(addr, address);
> + if (*servername == NULL)
> goto fail;
> - memcpy(*servername, ent->h_name, strlen(ent->h_name));
> - snprintf(buf, INFOBUFLEN, "%s@%s", service, ent->h_name);
> +
> + nbytes = snprintf(buf, INFOBUFLEN, "%s@%s", service, *servername);
> + if (nbytes > INFOBUFLEN)
> + goto fail;
> +
> if (!(*servicename = calloc(strlen(buf) + 1, 1)))
> goto fail;
> memcpy(*servicename, buf, strlen(buf));
> - if (cb_port[0] != '\0')
> - *port = atoi(cb_port);
>
> if (!(*protocol = strdup(protoname)))
> goto fail;
> @@ -251,7 +310,7 @@ process_clnt_dir_files(struct clnt_info * clp)
> if ((clp->servicename == NULL) &&
> read_service_info(info_file_name, &clp->servicename,
> &clp->servername, &clp->prog, &clp->vers,
> - &clp->protocol, &clp->port))
> + &clp->protocol, (struct sockaddr *) &clp->addr))
> return -1;
> return 0;
> }
> @@ -599,8 +658,9 @@ int create_auth_rpc_client(struct clnt_info *clp,
> clp->servername, uid);
> goto out_fail;
> }
> - if (clp->port)
> - ((struct sockaddr_in *)a->ai_addr)->sin_port = htons(clp->port);
> + if (((struct sockaddr_in) clp->addr).sin_port != 0)
> + ((struct sockaddr_in *) a->ai_addr)->sin_port =
> + ((struct sockaddr_in) clp->addr).sin_port;
> if (a->ai_protocol == IPPROTO_TCP) {
> if ((rpc_clnt = clnttcp_create(
> (struct sockaddr_in *) a->ai_addr,
--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH 2/5] nfs-utils: store the address given in the upcall for later use
2009-04-06 15:35 ` Chuck Lever
@ 2009-04-06 16:31 ` Jeff Layton
2009-04-06 16:39 ` Chuck Lever
0 siblings, 1 reply; 15+ messages in thread
From: Jeff Layton @ 2009-04-06 16:31 UTC (permalink / raw)
To: Chuck Lever; +Cc: linux-nfs, nfsv4, kwc
On Mon, 6 Apr 2009 11:35:50 -0400
Chuck Lever <chuck.lever@oracle.com> wrote:
> On Apr 5, 2009, at 9:43 AM, Jeff Layton wrote:
> > The current upcall could be more efficient. We first convert the
> > address
> > to a hostname, and then later when we set up the RPC client, we do a
> > hostname lookup to convert it back to an address.
> >
> > Begin to change this by keeping the address in the clnt_info that we
> > get
> > out of the upcall. Since a sockaddr has a port field, we can also
> > eliminate the port from the clnt_info.
> >
> > Finally, switch to getnameinfo() instead of gethostbyaddr(). We'll
> > need
> > to use that call anyway when we add support for IPv6.
>
> gethostbyaddr(3) supports AF_INET6, too, by the way.
>
> > Signed-off-by: Jeff Layton <jlayton@redhat.com>
> > ---
> > utils/gssd/gssd.h | 2 +-
> > utils/gssd/gssd_proc.c | 92 ++++++++++++++++++++++++++++++++++++++
> > +--------
> > 2 files changed, 77 insertions(+), 17 deletions(-)
> >
> > diff --git a/utils/gssd/gssd.h b/utils/gssd/gssd.h
> > index 082039a..3c52f46 100644
> > --- a/utils/gssd/gssd.h
> > +++ b/utils/gssd/gssd.h
> > @@ -83,7 +83,7 @@ struct clnt_info {
> > int krb5_poll_index;
> > int spkm3_fd;
> > int spkm3_poll_index;
> > - int port;
> > + struct sockaddr_storage addr;
> > };
> >
> > void init_client_list(void);
> > diff --git a/utils/gssd/gssd_proc.c b/utils/gssd/gssd_proc.c
> > index 509946e..be17019 100644
> > --- a/utils/gssd/gssd_proc.c
> > +++ b/utils/gssd/gssd_proc.c
> > @@ -102,10 +102,65 @@ struct pollfd * pollarray;
> >
> > int pollsize; /* the size of pollaray (in pollfd's) */
> >
> > +/*
> > + * convert an address string to a sockaddr_storage struct. Returns
> > true
> > + * on success and false on failure.
>
> I usually use the term "presentation address string" since that
> specifically means an IP address expressed as a C string. I guess
> that's pretty obvious because you use inet_pton() here.
>
Sounds reasonable.
> > + */
> > +static int
> > +addrstr_to_sockaddr(struct sockaddr *sa, const char *addr, const
> > int port)
> > +{
> > + struct sockaddr_in *s4 = (struct sockaddr_in *) sa;
> > +
> > + if (inet_pton(AF_INET, addr, &s4->sin_addr)) {
> > + s4->sin_family = AF_INET;
> > + s4->sin_port = htons(port);
> > + } else {
> > + printerr(0, "ERROR: unable to convert %s to address\n", addr);
> > + return 0;
> > + }
>
> I've handled these with a switch statement, as you do later in
> populate_port(). It's merely a question about consistent coding
> style, but any reason not to take that approach here?
>
Yes. switch statements are really only suitable when you have a simple
value to compare against. We're not comparing the address family here
because it's not yet known. We have to try and convert this opaque
string to an address first.
In the last patch, I add an "else if" where we try to convert it to an
ipv6 addr, but we can't really do "try this and if that fails then try
this" in the context of a switch.
In other places I try to use switches where it's suitable...
> > +
> > + return 1;
> > +}
> > +
> > +/*
> > + * convert a sockaddr to a hostname
> > + */
> > +static char *
> > +sockaddr_to_hostname(const struct sockaddr *sa, const char *addr)
> > +{
> > + socklen_t addrlen;
> > + int err;
> > + char *hostname;
> > + char hbuf[NI_MAXHOST];
> > +
> > + switch (sa->sa_family) {
> > + case AF_INET:
> > + addrlen = sizeof(struct sockaddr_in);
> > + break;
> > + default:
> > + printerr(0, "ERROR: unrecognized addr family %d\n",
> > + sa->sa_family);
> > + return NULL;
> > + }
> > +
> > + err = getnameinfo(sa, addrlen, hbuf, sizeof(hbuf), NULL, 0,
> > + NI_NAMEREQD);
> > + if (err) {
> > + printerr(0, "ERROR: unable to resolve %s to hostname: %s\n",
> > + addr, gai_strerror(err));
> > + return NULL;
> > + }
>
> getnameinfo(3) can return EAI_SYSTEM, in which case the real error
> value is stored in errno Browsing the gai_strerror(3) implementation
> in glibc-2.7 seems to show that it's just a simple static char table
> lookup, so it might be good to handle EAI_SYSTEM explicitly here.
>
> Looks like you already do that in populate_port().
>
Good catch. Will fix...
> > +
> > + hostname = strdup(hbuf);
> > +
> > + return hostname;
> > +}
> > +
> > /* XXX buffer problems: */
> > static int
> > read_service_info(char *info_file_name, char **servicename, char
> > **servername,
> > - int *prog, int *vers, char **protocol, int *port) {
> > + int *prog, int *vers, char **protocol,
> > + struct sockaddr *addr) {
> > #define INFOBUFLEN 256
> > char buf[INFOBUFLEN + 1];
> > static char dummy[128];
> > @@ -117,10 +172,9 @@ read_service_info(char *info_file_name, char
> > **servicename, char **servername,
> > char protoname[16];
> > char cb_port[128];
> > char *p;
> > - in_addr_t inaddr;
> > int fd = -1;
> > - struct hostent *ent = NULL;
> > int numfields;
> > + int port = 0;
> >
> > *servicename = *servername = *protocol = NULL;
> >
> > @@ -160,21 +214,26 @@ read_service_info(char *info_file_name, char
> > **servicename, char **servername,
> > if((*prog != 100003) || ((*vers != 2) && (*vers != 3) && (*vers !=
> > 4)))
> > goto fail;
> >
> > - /* create service name */
> > - inaddr = inet_addr(address);
> > - if (!(ent = gethostbyaddr(&inaddr, sizeof(inaddr), AF_INET))) {
> > - printerr(0, "ERROR: can't resolve server %s name\n", address);
> > - goto fail;
> > + if (cb_port[0] != '\0') {
> > + port = atoi(cb_port);
> > + if (port < 0 || port > 65535)
> > + goto fail;
> > }
> > - if (!(*servername = calloc(strlen(ent->h_name) + 1, 1)))
> > +
> > + if (!addrstr_to_sockaddr(addr, address, port))
> > + goto fail;
> > +
> > + *servername = sockaddr_to_hostname(addr, address);
> > + if (*servername == NULL)
> > goto fail;
> > - memcpy(*servername, ent->h_name, strlen(ent->h_name));
> > - snprintf(buf, INFOBUFLEN, "%s@%s", service, ent->h_name);
> > +
> > + nbytes = snprintf(buf, INFOBUFLEN, "%s@%s", service, *servername);
> > + if (nbytes > INFOBUFLEN)
> > + goto fail;
> > +
> > if (!(*servicename = calloc(strlen(buf) + 1, 1)))
> > goto fail;
> > memcpy(*servicename, buf, strlen(buf));
> > - if (cb_port[0] != '\0')
> > - *port = atoi(cb_port);
> >
> > if (!(*protocol = strdup(protoname)))
> > goto fail;
> > @@ -251,7 +310,7 @@ process_clnt_dir_files(struct clnt_info * clp)
> > if ((clp->servicename == NULL) &&
> > read_service_info(info_file_name, &clp->servicename,
> > &clp->servername, &clp->prog, &clp->vers,
> > - &clp->protocol, &clp->port))
> > + &clp->protocol, (struct sockaddr *) &clp->addr))
> > return -1;
> > return 0;
> > }
> > @@ -599,8 +658,9 @@ int create_auth_rpc_client(struct clnt_info *clp,
> > clp->servername, uid);
> > goto out_fail;
> > }
> > - if (clp->port)
> > - ((struct sockaddr_in *)a->ai_addr)->sin_port = htons(clp->port);
> > + if (((struct sockaddr_in) clp->addr).sin_port != 0)
> > + ((struct sockaddr_in *) a->ai_addr)->sin_port =
> > + ((struct sockaddr_in) clp->addr).sin_port;
> > if (a->ai_protocol == IPPROTO_TCP) {
> > if ((rpc_clnt = clnttcp_create(
> > (struct sockaddr_in *) a->ai_addr,
>
> --
> Chuck Lever
> chuck[dot]lever[at]oracle[dot]com
--
Jeff Layton <jlayton@redhat.com>
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH 2/5] nfs-utils: store the address given in the upcall for later use
2009-04-06 16:31 ` Jeff Layton
@ 2009-04-06 16:39 ` Chuck Lever
0 siblings, 0 replies; 15+ messages in thread
From: Chuck Lever @ 2009-04-06 16:39 UTC (permalink / raw)
To: Jeff Layton; +Cc: linux-nfs, nfsv4
On Apr 6, 2009, at 12:31 PM, Jeff Layton wrote:
> On Mon, 6 Apr 2009 11:35:50 -0400
> Chuck Lever <chuck.lever@oracle.com> wrote:
>> On Apr 5, 2009, at 9:43 AM, Jeff Layton wrote:
>>> + */
>>> +static int
>>> +addrstr_to_sockaddr(struct sockaddr *sa, const char *addr, const
>>> int port)
>>> +{
>>> + struct sockaddr_in *s4 = (struct sockaddr_in *) sa;
>>> +
>>> + if (inet_pton(AF_INET, addr, &s4->sin_addr)) {
>>> + s4->sin_family = AF_INET;
>>> + s4->sin_port = htons(port);
>>> + } else {
>>> + printerr(0, "ERROR: unable to convert %s to address\n", addr);
>>> + return 0;
>>> + }
>>
>> I've handled these with a switch statement, as you do later in
>> populate_port(). It's merely a question about consistent coding
>> style, but any reason not to take that approach here?
>>
>
> Yes. switch statements are really only suitable when you have a simple
> value to compare against. We're not comparing the address family here
> because it's not yet known. We have to try and convert this opaque
> string to an address first.
>
> In the last patch, I add an "else if" where we try to convert it to an
> ipv6 addr, but we can't really do "try this and if that fails then try
> this" in the context of a switch.
Just avoid doing the "break;" if inet_ntop(AF_INET6) fails. Just a
suggestion. Some might feel that's too clever.
> In other places I try to use switches where it's suitable...
--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 3/5] nfs-utils: skip getaddrinfo in create_auth_rpc_client unless we need port
2009-04-05 13:42 [PATCH 0/5] nfs-utils: convert gssd to TI-RPC and add IPv6 support (try #3) Jeff Layton
2009-04-05 13:42 ` [PATCH 1/5] nfs-utils: make getnameinfo() required for --enable-gss Jeff Layton
2009-04-05 13:43 ` [PATCH 2/5] nfs-utils: store the address given in the upcall for later use Jeff Layton
@ 2009-04-05 13:43 ` Jeff Layton
2009-04-05 13:43 ` [PATCH 4/5] nfs-utils: switch gssd to use standard function for getting an RPC client Jeff Layton
2009-04-05 13:43 ` [PATCH 5/5] nfs-utils: add IPv6 code to gssd Jeff Layton
4 siblings, 0 replies; 15+ messages in thread
From: Jeff Layton @ 2009-04-05 13:43 UTC (permalink / raw)
To: linux-nfs, nfsv4; +Cc: chuck.lever, kwc
We already have the server's address from the upcall, so we don't really
need to look it up again. Move the getaddrinfo call in
create_auth_rpc_client to a new function. Skip it if we already have the
port in the sockaddr that we saved from the info in the upcall. If
we need to get the port, don't bother looking up the hostname, just do
the getaddrinfo with AI_NUMERICHOST set.
This should reduce the amount of lookups that are needed.
Signed-off-by: Jeff Layton <jlayton@redhat.com>
---
utils/gssd/gssd_proc.c | 130 ++++++++++++++++++++++++++++-------------------
1 files changed, 77 insertions(+), 53 deletions(-)
diff --git a/utils/gssd/gssd_proc.c b/utils/gssd/gssd_proc.c
index be17019..bebefe7 100644
--- a/utils/gssd/gssd_proc.c
+++ b/utils/gssd/gssd_proc.c
@@ -540,6 +540,74 @@ out_err:
}
/*
+ * Determine the port from the servicename and set the right field in the
+ * sockaddr. This is mostly a no-op with newer kernels that send the port
+ * in the upcall. Returns true on success and false on failure.
+ */
+static int
+populate_port(struct sockaddr *sa, char *servicename, int protocol)
+{
+ struct sockaddr_in *s4 = (struct sockaddr_in *) sa;
+ char service[64];
+ char *at_sign;
+ int errcode;
+ struct addrinfo *a = NULL;
+ struct addrinfo ai_hints = { .ai_family = sa->sa_family,
+ .ai_protocol = protocol,
+ .ai_flags = AI_NUMERICHOST };
+
+ /*
+ * Newer kernels send the port in the upcall. If we already have
+ * the port, there's no need to look it up.
+ */
+ switch (sa->sa_family) {
+ case AF_INET:
+ if (s4->sin_port != 0) {
+ printerr(2, "DEBUG: port already set to %d\n",
+ ntohs(s4->sin_port));
+ return 1;
+ }
+ break;
+ default:
+ printerr(0, "ERROR: unsupported address family %d\n",
+ sa->sa_family);
+ return 0;
+ }
+
+ /* extract the service name from clp->servicename */
+ if ((at_sign = strchr(servicename, '@')) == NULL) {
+ printerr(0, "WARNING: servicename (%s) not formatted as "
+ "expected with service@host\n", servicename);
+ return 0;
+ }
+ if ((at_sign - servicename) >= sizeof(service)) {
+ printerr(0, "WARNING: service portion of servicename (%s) "
+ "is too long!\n", servicename);
+ return 0;
+ }
+ strncpy(service, servicename, at_sign - servicename);
+ service[at_sign - servicename] = '\0';
+
+ errcode = getaddrinfo(NULL, service, &ai_hints, &a);
+ if (errcode) {
+ printerr(0, "WARNING: Error from getaddrinfo for service "
+ "'%s': %s\n", service,
+ errcode == EAI_SYSTEM ? strerror(errno) :
+ gai_strerror(errcode));
+ return 0;
+ }
+
+ if (a->ai_family == AF_INET)
+ s4->sin_port = ((struct sockaddr_in *) a->ai_addr)->sin_port;
+ else
+ printerr(0, "ERROR: unrecognized address family %d returned "
+ "by getaddrinfo.\n", a->ai_family);
+
+ freeaddrinfo(a);
+ return 1;
+}
+
+/*
* Create an RPC connection and establish an authenticated
* gss context with a server.
*/
@@ -554,14 +622,12 @@ int create_auth_rpc_client(struct clnt_info *clp,
AUTH *auth = NULL;
uid_t save_uid = -1;
int retval = -1;
- int errcode;
OM_uint32 min_stat;
char rpc_errmsg[1024];
int sockp = RPC_ANYSOCK;
int sendsz = 32768, recvsz = 32768;
- struct addrinfo ai_hints, *a = NULL;
- char service[64];
- char *at_sign;
+ int protocol;
+ struct sockaddr *addr = (struct sockaddr *) &clp->addr;
/* Create the context as the user (not as root) */
save_uid = geteuid();
@@ -615,15 +681,10 @@ int create_auth_rpc_client(struct clnt_info *clp,
printerr(2, "creating %s client for server %s\n", clp->protocol,
clp->servername);
- memset(&ai_hints, '\0', sizeof(ai_hints));
- ai_hints.ai_family = PF_INET;
- ai_hints.ai_flags |= AI_CANONNAME;
if ((strcmp(clp->protocol, "tcp")) == 0) {
- ai_hints.ai_socktype = SOCK_STREAM;
- ai_hints.ai_protocol = IPPROTO_TCP;
+ protocol = IPPROTO_TCP;
} else if ((strcmp(clp->protocol, "udp")) == 0) {
- ai_hints.ai_socktype = SOCK_DGRAM;
- ai_hints.ai_protocol = IPPROTO_UDP;
+ protocol = IPPROTO_UDP;
} else {
printerr(0, "WARNING: unrecognized protocol, '%s', requested "
"for connection to server %s for user with uid %d\n",
@@ -631,39 +692,12 @@ int create_auth_rpc_client(struct clnt_info *clp,
goto out_fail;
}
- /* extract the service name from clp->servicename */
- if ((at_sign = strchr(clp->servicename, '@')) == NULL) {
- printerr(0, "WARNING: servicename (%s) not formatted as "
- "expected with service@host\n", clp->servicename);
- goto out_fail;
- }
- if ((at_sign - clp->servicename) >= sizeof(service)) {
- printerr(0, "WARNING: service portion of servicename (%s) "
- "is too long!\n", clp->servicename);
- goto out_fail;
- }
- strncpy(service, clp->servicename, at_sign - clp->servicename);
- service[at_sign - clp->servicename] = '\0';
-
- errcode = getaddrinfo(clp->servername, service, &ai_hints, &a);
- if (errcode) {
- printerr(0, "WARNING: Error from getaddrinfo for server "
- "'%s': %s\n", clp->servername, gai_strerror(errcode));
+ if (!populate_port(addr, clp->servicename, protocol))
goto out_fail;
- }
- if (a == NULL) {
- printerr(0, "WARNING: No address information found for "
- "connection to server %s for user with uid %d\n",
- clp->servername, uid);
- goto out_fail;
- }
- if (((struct sockaddr_in) clp->addr).sin_port != 0)
- ((struct sockaddr_in *) a->ai_addr)->sin_port =
- ((struct sockaddr_in) clp->addr).sin_port;
- if (a->ai_protocol == IPPROTO_TCP) {
+ if (protocol == IPPROTO_TCP) {
if ((rpc_clnt = clnttcp_create(
- (struct sockaddr_in *) a->ai_addr,
+ (struct sockaddr_in *) &clp->addr,
clp->prog, clp->vers, &sockp,
sendsz, recvsz)) == NULL) {
snprintf(rpc_errmsg, sizeof(rpc_errmsg),
@@ -674,10 +708,10 @@ int create_auth_rpc_client(struct clnt_info *clp,
clnt_spcreateerror(rpc_errmsg));
goto out_fail;
}
- } else if (a->ai_protocol == IPPROTO_UDP) {
+ } else if (protocol == IPPROTO_UDP) {
const struct timeval timeout = {5, 0};
if ((rpc_clnt = clntudp_bufcreate(
- (struct sockaddr_in *) a->ai_addr,
+ (struct sockaddr_in *) &clp->addr,
clp->prog, clp->vers, timeout,
&sockp, sendsz, recvsz)) == NULL) {
snprintf(rpc_errmsg, sizeof(rpc_errmsg),
@@ -688,16 +722,7 @@ int create_auth_rpc_client(struct clnt_info *clp,
clnt_spcreateerror(rpc_errmsg));
goto out_fail;
}
- } else {
- /* Shouldn't happen! */
- printerr(0, "ERROR: requested protocol '%s', but "
- "got addrinfo with protocol %d\n",
- clp->protocol, a->ai_protocol);
- goto out_fail;
}
- /* We're done with this */
- freeaddrinfo(a);
- a = NULL;
printerr(2, "creating context with server %s\n", clp->servicename);
auth = authgss_create_default(rpc_clnt, clp->servicename, &sec);
@@ -719,7 +744,6 @@ int create_auth_rpc_client(struct clnt_info *clp,
out:
if (sec.cred != GSS_C_NO_CREDENTIAL)
gss_release_cred(&min_stat, &sec.cred);
- if (a != NULL) freeaddrinfo(a);
/* Restore euid to original value */
if ((save_uid != -1) && (setfsuid(save_uid) != uid)) {
printerr(0, "WARNING: Failed to restore fsuid"
--
1.6.0.6
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH 4/5] nfs-utils: switch gssd to use standard function for getting an RPC client
2009-04-05 13:42 [PATCH 0/5] nfs-utils: convert gssd to TI-RPC and add IPv6 support (try #3) Jeff Layton
` (2 preceding siblings ...)
2009-04-05 13:43 ` [PATCH 3/5] nfs-utils: skip getaddrinfo in create_auth_rpc_client unless we need port Jeff Layton
@ 2009-04-05 13:43 ` Jeff Layton
2009-04-06 15:35 ` Chuck Lever
2009-04-05 13:43 ` [PATCH 5/5] nfs-utils: add IPv6 code to gssd Jeff Layton
4 siblings, 1 reply; 15+ messages in thread
From: Jeff Layton @ 2009-04-05 13:43 UTC (permalink / raw)
To: linux-nfs, nfsv4; +Cc: chuck.lever, kwc
We already have a common function for setting up an RPC client. Switch
gssd to use it.
Signed-off-by: Jeff Layton <jlayton@redhat.com>
---
utils/gssd/gssd_proc.c | 53 +++++++++++++++++++++--------------------------
1 files changed, 24 insertions(+), 29 deletions(-)
diff --git a/utils/gssd/gssd_proc.c b/utils/gssd/gssd_proc.c
index bebefe7..1f7dadd 100644
--- a/utils/gssd/gssd_proc.c
+++ b/utils/gssd/gssd_proc.c
@@ -72,6 +72,7 @@
#include "gss_util.h"
#include "krb5_util.h"
#include "context.h"
+#include "nfsrpc.h"
/*
* pollarray:
@@ -624,10 +625,10 @@ int create_auth_rpc_client(struct clnt_info *clp,
int retval = -1;
OM_uint32 min_stat;
char rpc_errmsg[1024];
- int sockp = RPC_ANYSOCK;
- int sendsz = 32768, recvsz = 32768;
int protocol;
+ struct timeval timeout = {5, 0};
struct sockaddr *addr = (struct sockaddr *) &clp->addr;
+ socklen_t salen;
/* Create the context as the user (not as root) */
save_uid = geteuid();
@@ -695,33 +696,27 @@ int create_auth_rpc_client(struct clnt_info *clp,
if (!populate_port(addr, clp->servicename, protocol))
goto out_fail;
- if (protocol == IPPROTO_TCP) {
- if ((rpc_clnt = clnttcp_create(
- (struct sockaddr_in *) &clp->addr,
- clp->prog, clp->vers, &sockp,
- sendsz, recvsz)) == NULL) {
- snprintf(rpc_errmsg, sizeof(rpc_errmsg),
- "WARNING: can't create tcp rpc_clnt "
- "for server %s for user with uid %d",
- clp->servername, uid);
- printerr(0, "%s\n",
- clnt_spcreateerror(rpc_errmsg));
- goto out_fail;
- }
- } else if (protocol == IPPROTO_UDP) {
- const struct timeval timeout = {5, 0};
- if ((rpc_clnt = clntudp_bufcreate(
- (struct sockaddr_in *) &clp->addr,
- clp->prog, clp->vers, timeout,
- &sockp, sendsz, recvsz)) == NULL) {
- snprintf(rpc_errmsg, sizeof(rpc_errmsg),
- "WARNING: can't create udp rpc_clnt "
- "for server %s for user with uid %d",
- clp->servername, uid);
- printerr(0, "%s\n",
- clnt_spcreateerror(rpc_errmsg));
- goto out_fail;
- }
+ switch (addr->sa_family) {
+ case AF_INET:
+ salen = sizeof(struct sockaddr_in);
+ break;
+ default:
+ printerr(1, "ERROR: Unknown address family %d\n",
+ addr->sa_family);
+ goto out_fail;
+ }
+
+ rpc_clnt = nfs_get_rpcclient(addr, salen, protocol, clp->prog,
+ clp->vers, &timeout);
+ if (!rpc_clnt) {
+ snprintf(rpc_errmsg, sizeof(rpc_errmsg),
+ "WARNING: can't create %s rpc_clnt to server %s for "
+ "user with uid %d",
+ protocol == IPPROTO_TCP ? "tcp" : "udp",
+ clp->servername, uid);
+ printerr(0, "%s\n",
+ clnt_spcreateerror(rpc_errmsg));
+ goto out_fail;
}
printerr(2, "creating context with server %s\n", clp->servicename);
--
1.6.0.6
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH 4/5] nfs-utils: switch gssd to use standard function for getting an RPC client
2009-04-05 13:43 ` [PATCH 4/5] nfs-utils: switch gssd to use standard function for getting an RPC client Jeff Layton
@ 2009-04-06 15:35 ` Chuck Lever
0 siblings, 0 replies; 15+ messages in thread
From: Chuck Lever @ 2009-04-06 15:35 UTC (permalink / raw)
To: Jeff Layton; +Cc: linux-nfs, nfsv4
On Apr 5, 2009, at 9:43 AM, Jeff Layton wrote:
> We already have a common function for setting up an RPC client. Switch
> gssd to use it.
Maybe this is a nit, but I would like a stronger justification... like
"switch to a function that can support IPv6".
> Signed-off-by: Jeff Layton <jlayton@redhat.com>
> ---
> utils/gssd/gssd_proc.c | 53 ++++++++++++++++++++
> +--------------------------
> 1 files changed, 24 insertions(+), 29 deletions(-)
>
> diff --git a/utils/gssd/gssd_proc.c b/utils/gssd/gssd_proc.c
> index bebefe7..1f7dadd 100644
> --- a/utils/gssd/gssd_proc.c
> +++ b/utils/gssd/gssd_proc.c
> @@ -72,6 +72,7 @@
> #include "gss_util.h"
> #include "krb5_util.h"
> #include "context.h"
> +#include "nfsrpc.h"
>
> /*
> * pollarray:
> @@ -624,10 +625,10 @@ int create_auth_rpc_client(struct clnt_info
> *clp,
> int retval = -1;
> OM_uint32 min_stat;
> char rpc_errmsg[1024];
> - int sockp = RPC_ANYSOCK;
> - int sendsz = 32768, recvsz = 32768;
> int protocol;
> + struct timeval timeout = {5, 0};
> struct sockaddr *addr = (struct sockaddr *) &clp->addr;
> + socklen_t salen;
>
> /* Create the context as the user (not as root) */
> save_uid = geteuid();
> @@ -695,33 +696,27 @@ int create_auth_rpc_client(struct clnt_info
> *clp,
> if (!populate_port(addr, clp->servicename, protocol))
> goto out_fail;
>
> - if (protocol == IPPROTO_TCP) {
> - if ((rpc_clnt = clnttcp_create(
> - (struct sockaddr_in *) &clp->addr,
> - clp->prog, clp->vers, &sockp,
> - sendsz, recvsz)) == NULL) {
> - snprintf(rpc_errmsg, sizeof(rpc_errmsg),
> - "WARNING: can't create tcp rpc_clnt "
> - "for server %s for user with uid %d",
> - clp->servername, uid);
> - printerr(0, "%s\n",
> - clnt_spcreateerror(rpc_errmsg));
> - goto out_fail;
> - }
> - } else if (protocol == IPPROTO_UDP) {
> - const struct timeval timeout = {5, 0};
> - if ((rpc_clnt = clntudp_bufcreate(
> - (struct sockaddr_in *) &clp->addr,
> - clp->prog, clp->vers, timeout,
> - &sockp, sendsz, recvsz)) == NULL) {
> - snprintf(rpc_errmsg, sizeof(rpc_errmsg),
> - "WARNING: can't create udp rpc_clnt "
> - "for server %s for user with uid %d",
> - clp->servername, uid);
> - printerr(0, "%s\n",
> - clnt_spcreateerror(rpc_errmsg));
> - goto out_fail;
> - }
> + switch (addr->sa_family) {
> + case AF_INET:
> + salen = sizeof(struct sockaddr_in);
> + break;
> + default:
> + printerr(1, "ERROR: Unknown address family %d\n",
> + addr->sa_family);
> + goto out_fail;
> + }
> +
> + rpc_clnt = nfs_get_rpcclient(addr, salen, protocol, clp->prog,
> + clp->vers, &timeout);
> + if (!rpc_clnt) {
> + snprintf(rpc_errmsg, sizeof(rpc_errmsg),
> + "WARNING: can't create %s rpc_clnt to server %s for "
> + "user with uid %d",
> + protocol == IPPROTO_TCP ? "tcp" : "udp",
> + clp->servername, uid);
> + printerr(0, "%s\n",
> + clnt_spcreateerror(rpc_errmsg));
> + goto out_fail;
> }
>
> printerr(2, "creating context with server %s\n", clp->servicename);
--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 5/5] nfs-utils: add IPv6 code to gssd
2009-04-05 13:42 [PATCH 0/5] nfs-utils: convert gssd to TI-RPC and add IPv6 support (try #3) Jeff Layton
` (3 preceding siblings ...)
2009-04-05 13:43 ` [PATCH 4/5] nfs-utils: switch gssd to use standard function for getting an RPC client Jeff Layton
@ 2009-04-05 13:43 ` Jeff Layton
2009-04-06 15:35 ` Chuck Lever
4 siblings, 1 reply; 15+ messages in thread
From: Jeff Layton @ 2009-04-05 13:43 UTC (permalink / raw)
To: linux-nfs, nfsv4; +Cc: chuck.lever, kwc
All of the pieces to handle IPv6 are now in place. Add IPv6-specific
code wrapped in the proper #ifdef's so that IPv6 support works when
it's enabled at build-time.
Signed-off-by: Jeff Layton <jlayton@redhat.com>
---
utils/gssd/gssd_proc.c | 34 ++++++++++++++++++++++++++++++++++
1 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/utils/gssd/gssd_proc.c b/utils/gssd/gssd_proc.c
index 1f7dadd..8a595c2 100644
--- a/utils/gssd/gssd_proc.c
+++ b/utils/gssd/gssd_proc.c
@@ -111,10 +111,18 @@ static int
addrstr_to_sockaddr(struct sockaddr *sa, const char *addr, const int port)
{
struct sockaddr_in *s4 = (struct sockaddr_in *) sa;
+#ifdef IPV6_SUPPORTED
+ struct sockaddr_in6 *s6 = (struct sockaddr_in6 *) sa;
+#endif /* IPV6_SUPPORTED */
if (inet_pton(AF_INET, addr, &s4->sin_addr)) {
s4->sin_family = AF_INET;
s4->sin_port = htons(port);
+#ifdef IPV6_SUPPORTED
+ } else if (inet_pton(AF_INET6, addr, &s6->sin6_addr)) {
+ s6->sin6_family = AF_INET6;
+ s6->sin6_port = htons(port);
+#endif /* IPV6_SUPPORTED */
} else {
printerr(0, "ERROR: unable to convert %s to address\n", addr);
return 0;
@@ -138,6 +146,11 @@ sockaddr_to_hostname(const struct sockaddr *sa, const char *addr)
case AF_INET:
addrlen = sizeof(struct sockaddr_in);
break;
+#ifdef IPV6_SUPPORTED
+ case AF_INET6:
+ addrlen = sizeof(struct sockaddr_in6);
+ break;
+#endif /* IPV6_SUPPORTED */
default:
printerr(0, "ERROR: unrecognized addr family %d\n",
sa->sa_family);
@@ -549,6 +562,9 @@ static int
populate_port(struct sockaddr *sa, char *servicename, int protocol)
{
struct sockaddr_in *s4 = (struct sockaddr_in *) sa;
+#ifdef IPV6_SUPPORTED
+ struct sockaddr_in6 *s6 = (struct sockaddr_in6 *) sa;
+#endif /* IPV6_SUPPORTED */
char service[64];
char *at_sign;
int errcode;
@@ -569,6 +585,15 @@ populate_port(struct sockaddr *sa, char *servicename, int protocol)
return 1;
}
break;
+#ifdef IPV6_SUPPORTED
+ case AF_INET6:
+ if (s6->sin6_port != 0) {
+ printerr(2, "DEBUG: port already set to %d\n",
+ ntohs(s6->sin6_port));
+ return 1;
+ }
+ break;
+#endif /* IPV6_SUPPORTED */
default:
printerr(0, "ERROR: unsupported address family %d\n",
sa->sa_family);
@@ -600,6 +625,10 @@ populate_port(struct sockaddr *sa, char *servicename, int protocol)
if (a->ai_family == AF_INET)
s4->sin_port = ((struct sockaddr_in *) a->ai_addr)->sin_port;
+#ifdef IPV6_SUPPORTED
+ else if (a->ai_family == AF_INET6)
+ s6->sin6_port = ((struct sockaddr_in6 *) a->ai_addr)->sin6_port;
+#endif /* IPV6_SUPPORTED */
else
printerr(0, "ERROR: unrecognized address family %d returned "
"by getaddrinfo.\n", a->ai_family);
@@ -700,6 +729,11 @@ int create_auth_rpc_client(struct clnt_info *clp,
case AF_INET:
salen = sizeof(struct sockaddr_in);
break;
+#ifdef IPV6_SUPPORTED
+ case AF_INET6:
+ salen = sizeof(struct sockaddr_in6);
+ break;
+#endif /* IPV6_SUPPORTED */
default:
printerr(1, "ERROR: Unknown address family %d\n",
addr->sa_family);
--
1.6.0.6
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH 5/5] nfs-utils: add IPv6 code to gssd
2009-04-05 13:43 ` [PATCH 5/5] nfs-utils: add IPv6 code to gssd Jeff Layton
@ 2009-04-06 15:35 ` Chuck Lever
2009-04-06 16:24 ` Jeff Layton
0 siblings, 1 reply; 15+ messages in thread
From: Chuck Lever @ 2009-04-06 15:35 UTC (permalink / raw)
To: Jeff Layton; +Cc: linux-nfs, nfsv4
On Apr 5, 2009, at 9:43 AM, Jeff Layton wrote:
> All of the pieces to handle IPv6 are now in place. Add IPv6-specific
> code wrapped in the proper #ifdef's so that IPv6 support works when
> it's enabled at build-time.
>
> Signed-off-by: Jeff Layton <jlayton@redhat.com>
> ---
> utils/gssd/gssd_proc.c | 34 ++++++++++++++++++++++++++++++++++
> 1 files changed, 34 insertions(+), 0 deletions(-)
>
> diff --git a/utils/gssd/gssd_proc.c b/utils/gssd/gssd_proc.c
> index 1f7dadd..8a595c2 100644
> --- a/utils/gssd/gssd_proc.c
> +++ b/utils/gssd/gssd_proc.c
> @@ -111,10 +111,18 @@ static int
> addrstr_to_sockaddr(struct sockaddr *sa, const char *addr, const int
> port)
> {
> struct sockaddr_in *s4 = (struct sockaddr_in *) sa;
> +#ifdef IPV6_SUPPORTED
> + struct sockaddr_in6 *s6 = (struct sockaddr_in6 *) sa;
> +#endif /* IPV6_SUPPORTED */
>
> if (inet_pton(AF_INET, addr, &s4->sin_addr)) {
> s4->sin_family = AF_INET;
> s4->sin_port = htons(port);
> +#ifdef IPV6_SUPPORTED
> + } else if (inet_pton(AF_INET6, addr, &s6->sin6_addr)) {
> + s6->sin6_family = AF_INET6;
> + s6->sin6_port = htons(port);
> +#endif /* IPV6_SUPPORTED */
Does this support scope IDs? Do we expect to get a link-local IPv6
address here?
> } else {
> printerr(0, "ERROR: unable to convert %s to address\n", addr);
> return 0;
> @@ -138,6 +146,11 @@ sockaddr_to_hostname(const struct sockaddr *sa,
> const char *addr)
> case AF_INET:
> addrlen = sizeof(struct sockaddr_in);
> break;
> +#ifdef IPV6_SUPPORTED
> + case AF_INET6:
> + addrlen = sizeof(struct sockaddr_in6);
> + break;
> +#endif /* IPV6_SUPPORTED */
> default:
> printerr(0, "ERROR: unrecognized addr family %d\n",
> sa->sa_family);
> @@ -549,6 +562,9 @@ static int
> populate_port(struct sockaddr *sa, char *servicename, int protocol)
> {
> struct sockaddr_in *s4 = (struct sockaddr_in *) sa;
> +#ifdef IPV6_SUPPORTED
> + struct sockaddr_in6 *s6 = (struct sockaddr_in6 *) sa;
> +#endif /* IPV6_SUPPORTED */
> char service[64];
> char *at_sign;
> int errcode;
> @@ -569,6 +585,15 @@ populate_port(struct sockaddr *sa, char
> *servicename, int protocol)
> return 1;
> }
> break;
> +#ifdef IPV6_SUPPORTED
> + case AF_INET6:
> + if (s6->sin6_port != 0) {
> + printerr(2, "DEBUG: port already set to %d\n",
> + ntohs(s6->sin6_port));
> + return 1;
> + }
> + break;
> +#endif /* IPV6_SUPPORTED */
> default:
> printerr(0, "ERROR: unsupported address family %d\n",
> sa->sa_family);
> @@ -600,6 +625,10 @@ populate_port(struct sockaddr *sa, char
> *servicename, int protocol)
>
> if (a->ai_family == AF_INET)
> s4->sin_port = ((struct sockaddr_in *) a->ai_addr)->sin_port;
> +#ifdef IPV6_SUPPORTED
> + else if (a->ai_family == AF_INET6)
> + s6->sin6_port = ((struct sockaddr_in6 *) a->ai_addr)->sin6_port;
> +#endif /* IPV6_SUPPORTED */
> else
> printerr(0, "ERROR: unrecognized address family %d returned "
> "by getaddrinfo.\n", a->ai_family);
> @@ -700,6 +729,11 @@ int create_auth_rpc_client(struct clnt_info *clp,
> case AF_INET:
> salen = sizeof(struct sockaddr_in);
> break;
> +#ifdef IPV6_SUPPORTED
> + case AF_INET6:
> + salen = sizeof(struct sockaddr_in6);
> + break;
> +#endif /* IPV6_SUPPORTED */
> default:
> printerr(1, "ERROR: Unknown address family %d\n",
> addr->sa_family);
--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH 5/5] nfs-utils: add IPv6 code to gssd
2009-04-06 15:35 ` Chuck Lever
@ 2009-04-06 16:24 ` Jeff Layton
2009-04-06 16:35 ` Chuck Lever
0 siblings, 1 reply; 15+ messages in thread
From: Jeff Layton @ 2009-04-06 16:24 UTC (permalink / raw)
To: Chuck Lever; +Cc: linux-nfs, nfsv4
On Mon, 6 Apr 2009 11:35:21 -0400
Chuck Lever <chuck.lever@oracle.com> wrote:
> On Apr 5, 2009, at 9:43 AM, Jeff Layton wrote:
> > All of the pieces to handle IPv6 are now in place. Add IPv6-specific
> > code wrapped in the proper #ifdef's so that IPv6 support works when
> > it's enabled at build-time.
> >
> > Signed-off-by: Jeff Layton <jlayton@redhat.com>
> > ---
> > utils/gssd/gssd_proc.c | 34 ++++++++++++++++++++++++++++++++++
> > 1 files changed, 34 insertions(+), 0 deletions(-)
> >
> > diff --git a/utils/gssd/gssd_proc.c b/utils/gssd/gssd_proc.c
> > index 1f7dadd..8a595c2 100644
> > --- a/utils/gssd/gssd_proc.c
> > +++ b/utils/gssd/gssd_proc.c
> > @@ -111,10 +111,18 @@ static int
> > addrstr_to_sockaddr(struct sockaddr *sa, const char *addr, const int
> > port)
> > {
> > struct sockaddr_in *s4 = (struct sockaddr_in *) sa;
> > +#ifdef IPV6_SUPPORTED
> > + struct sockaddr_in6 *s6 = (struct sockaddr_in6 *) sa;
> > +#endif /* IPV6_SUPPORTED */
> >
> > if (inet_pton(AF_INET, addr, &s4->sin_addr)) {
> > s4->sin_family = AF_INET;
> > s4->sin_port = htons(port);
> > +#ifdef IPV6_SUPPORTED
> > + } else if (inet_pton(AF_INET6, addr, &s6->sin6_addr)) {
> > + s6->sin6_family = AF_INET6;
> > + s6->sin6_port = htons(port);
> > +#endif /* IPV6_SUPPORTED */
>
> Does this support scope IDs? Do we expect to get a link-local IPv6
> address here?
>
It doesn't support scope ID's. The upcall doesn't send the scopeid if
there's one defined.
Given that we rely on name resolution to some degree with krb5 auth,
I'm not sure that it makes much sense to deal with scopeid's here. AAAA
records in DNS don't have space for them.
PS: I'll fix the getnameinfo() autoconf patch to do what you suggest...
--
Jeff Layton <jlayton@redhat.com>
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: [PATCH 5/5] nfs-utils: add IPv6 code to gssd
2009-04-06 16:24 ` Jeff Layton
@ 2009-04-06 16:35 ` Chuck Lever
0 siblings, 0 replies; 15+ messages in thread
From: Chuck Lever @ 2009-04-06 16:35 UTC (permalink / raw)
To: Jeff Layton; +Cc: linux-nfs, nfsv4
On Apr 6, 2009, at 12:24 PM, Jeff Layton wrote:
> On Mon, 6 Apr 2009 11:35:21 -0400
> Chuck Lever <chuck.lever@oracle.com> wrote:
>
>> On Apr 5, 2009, at 9:43 AM, Jeff Layton wrote:
>>> All of the pieces to handle IPv6 are now in place. Add IPv6-specific
>>> code wrapped in the proper #ifdef's so that IPv6 support works when
>>> it's enabled at build-time.
>>>
>>> Signed-off-by: Jeff Layton <jlayton@redhat.com>
>>> ---
>>> utils/gssd/gssd_proc.c | 34 ++++++++++++++++++++++++++++++++++
>>> 1 files changed, 34 insertions(+), 0 deletions(-)
>>>
>>> diff --git a/utils/gssd/gssd_proc.c b/utils/gssd/gssd_proc.c
>>> index 1f7dadd..8a595c2 100644
>>> --- a/utils/gssd/gssd_proc.c
>>> +++ b/utils/gssd/gssd_proc.c
>>> @@ -111,10 +111,18 @@ static int
>>> addrstr_to_sockaddr(struct sockaddr *sa, const char *addr, const int
>>> port)
>>> {
>>> struct sockaddr_in *s4 = (struct sockaddr_in *) sa;
>>> +#ifdef IPV6_SUPPORTED
>>> + struct sockaddr_in6 *s6 = (struct sockaddr_in6 *) sa;
>>> +#endif /* IPV6_SUPPORTED */
>>>
>>> if (inet_pton(AF_INET, addr, &s4->sin_addr)) {
>>> s4->sin_family = AF_INET;
>>> s4->sin_port = htons(port);
>>> +#ifdef IPV6_SUPPORTED
>>> + } else if (inet_pton(AF_INET6, addr, &s6->sin6_addr)) {
>>> + s6->sin6_family = AF_INET6;
>>> + s6->sin6_port = htons(port);
>>> +#endif /* IPV6_SUPPORTED */
>>
>> Does this support scope IDs? Do we expect to get a link-local IPv6
>> address here?
>>
>
> It doesn't support scope ID's. The upcall doesn't send the scopeid if
> there's one defined.
>
> Given that we rely on name resolution to some degree with krb5 auth,
> I'm not sure that it makes much sense to deal with scopeid's here.
> AAAA
> records in DNS don't have space for them.
I think that's worth mentioning somewhere in the comments or in the
man page -- a hostname is required in here, it won't work with raw
addresses. So link-local support is right out.
--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
^ permalink raw reply [flat|nested] 15+ messages in thread