summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorShyam Prasad N <sprasad@microsoft.com>2022-12-27 14:09:32 +0000
committerSteve French <stfrench@microsoft.com>2023-03-01 18:18:24 -0600
commit410612b0726b2ee68808da7bd27103d96b4cf898 (patch)
tree302f1f20f048abd1b14dc89f9a2de37ed4c3d8ac /fs
parenta21be1f5df85831147d5a1cbb5f2a13ec8c6852b (diff)
downloadlinux-410612b0726b2ee68808da7bd27103d96b4cf898.tar.gz
linux-410612b0726b2ee68808da7bd27103d96b4cf898.tar.bz2
linux-410612b0726b2ee68808da7bd27103d96b4cf898.zip
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>
Diffstat (limited to 'fs')
-rw-r--r--fs/cifs/connect.c28
1 files changed, 2 insertions, 26 deletions
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 5dabd8dc3e8e..5233f14f0636 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -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)
{
- switch (addr->sa_family) {
- case AF_INET: {
- 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 */
- }
+ if (!cifs_match_ipaddr(addr, (struct sockaddr *)&server->dstaddr))
+ return false;
return true;
}