Skip to content

Commit

Permalink
NLM: Rewrite IPv4 privileged requester's check
Browse files Browse the repository at this point in the history
Clean up.

For consistency, rewrite the IPv4 check to match the same style as the
new IPv6 check.  Note that ipv4_is_loopback() is somewhat broader in
its interpretation of what is a loopback address than simply
"127.0.0.1".

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
  • Loading branch information
Chuck Lever authored and J. Bruce Fields committed Jan 6, 2009
1 parent d1208f7 commit 57ef692
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions include/linux/lockd/lockd.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,11 @@ static inline struct inode *nlmsvc_file_inode(struct nlm_file *file)
static inline int __nlm_privileged_request4(const struct sockaddr *sap)
{
const struct sockaddr_in *sin = (struct sockaddr_in *)sap;
return (sin->sin_addr.s_addr == htonl(INADDR_LOOPBACK)) &&
(ntohs(sin->sin_port) < 1024);

if (ntohs(sin->sin_port) > 1023)
return 0;

return ipv4_is_loopback(sin->sin_addr.s_addr);
}

#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
Expand Down

0 comments on commit 57ef692

Please sign in to comment.