mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-11 15:49:56 +00:00
cifs: reuse cifs_match_ipaddr for comparison of dstaddr too
We have two pieces of code that does pretty much the same comparison. This change reuses cifs_match_ipaddr within match_address. Signed-off-by: Shyam Prasad N <sprasad@microsoft.com> Signed-off-by: Steve French <stfrench@microsoft.com>
This commit is contained in:
parent
a21be1f5df
commit
410612b072
@ -1344,32 +1344,8 @@ match_port(struct TCP_Server_Info *server, struct sockaddr *addr)
|
|||||||
|
|
||||||
static bool match_server_address(struct TCP_Server_Info *server, struct sockaddr *addr)
|
static bool match_server_address(struct TCP_Server_Info *server, struct sockaddr *addr)
|
||||||
{
|
{
|
||||||
switch (addr->sa_family) {
|
if (!cifs_match_ipaddr(addr, (struct sockaddr *)&server->dstaddr))
|
||||||
case AF_INET: {
|
return false;
|
||||||
struct sockaddr_in *addr4 = (struct sockaddr_in *)addr;
|
|
||||||
struct sockaddr_in *srv_addr4 =
|
|
||||||
(struct sockaddr_in *)&server->dstaddr;
|
|
||||||
|
|
||||||
if (addr4->sin_addr.s_addr != srv_addr4->sin_addr.s_addr)
|
|
||||||
return false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case AF_INET6: {
|
|
||||||
struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)addr;
|
|
||||||
struct sockaddr_in6 *srv_addr6 =
|
|
||||||
(struct sockaddr_in6 *)&server->dstaddr;
|
|
||||||
|
|
||||||
if (!ipv6_addr_equal(&addr6->sin6_addr,
|
|
||||||
&srv_addr6->sin6_addr))
|
|
||||||
return false;
|
|
||||||
if (addr6->sin6_scope_id != srv_addr6->sin6_scope_id)
|
|
||||||
return false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
WARN_ON(1);
|
|
||||||
return false; /* don't expect to be here */
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user