Commit 396cb3d0 authored by Chuck Lever's avatar Chuck Lever Committed by J. Bruce Fields

lockd: Add address family-agnostic helper for zeroing the port number

Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
Signed-off-by: default avatarJ. Bruce Fields <bfields@citi.umich.edu>
parent 2860a022
...@@ -40,6 +40,18 @@ static struct nsm_handle * nsm_find(const struct sockaddr_in *sin, ...@@ -40,6 +40,18 @@ static struct nsm_handle * nsm_find(const struct sockaddr_in *sin,
const char *hostname, const char *hostname,
unsigned int hostname_len); 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, static void nlm_display_address(const struct sockaddr *sap,
char *buf, const size_t len) char *buf, const size_t len)
{ {
...@@ -154,7 +166,7 @@ static struct nlm_host *nlm_lookup_host(int server, ...@@ -154,7 +166,7 @@ static struct nlm_host *nlm_lookup_host(int server,
} }
host->h_name = nsm->sm_name; host->h_name = nsm->sm_name;
host->h_addr = *sin; 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_saddr = *ssin;
host->h_version = version; host->h_version = version;
host->h_proto = proto; host->h_proto = proto;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment