summaryrefslogtreecommitdiffstats
path: root/fs/lockd
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2008-08-27 16:57:38 -0400
committerJ. Bruce Fields <bfields@citi.umich.edu>2008-09-29 18:13:38 -0400
commit396cb3d003c2ce72b50c8c06fddfbb7516f30eb1 (patch)
treec23d66bde884c07eb45234d2ed76681914be3584 /fs/lockd
parent2860a0227b700feb8d6e5c4f07a62a1b40d96022 (diff)
downloadtalos-op-linux-396cb3d003c2ce72b50c8c06fddfbb7516f30eb1.tar.gz
talos-op-linux-396cb3d003c2ce72b50c8c06fddfbb7516f30eb1.zip
lockd: Add address family-agnostic helper for zeroing the port number
Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Diffstat (limited to 'fs/lockd')
-rw-r--r--fs/lockd/host.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/fs/lockd/host.c b/fs/lockd/host.c
index 22423abea281..008e4026f540 100644
--- a/fs/lockd/host.c
+++ b/fs/lockd/host.c
@@ -40,6 +40,18 @@ static struct nsm_handle * nsm_find(const struct sockaddr_in *sin,
const char *hostname,
unsigned int hostname_len);
+static void nlm_clear_port(struct sockaddr *sap)
+{
+ switch (sap->sa_family) {
+ case AF_INET:
+ ((struct sockaddr_in *)sap)->sin_port = 0;
+ break;
+ case AF_INET6:
+ ((struct sockaddr_in6 *)sap)->sin6_port = 0;
+ break;
+ }
+}
+
static void nlm_display_address(const struct sockaddr *sap,
char *buf, const size_t len)
{
@@ -154,7 +166,7 @@ static struct nlm_host *nlm_lookup_host(int server,
}
host->h_name = nsm->sm_name;
host->h_addr = *sin;
- host->h_addr.sin_port = 0; /* ouch! */
+ nlm_clear_port((struct sockaddr *)&host->h_addr);
host->h_saddr = *ssin;
host->h_version = version;
host->h_proto = proto;
OpenPOWER on IntegriCloud