From: Shyam Prasad N Date: Tue, 27 Dec 2022 14:09:32 +0000 (+0000) Subject: cifs: reuse cifs_match_ipaddr for comparison of dstaddr too X-Git-Tag: v6.6.17~5361^2~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=410612b0726b2ee68808da7bd27103d96b4cf898;p=platform%2Fkernel%2Flinux-rpi.git 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 Signed-off-by: Steve French --- diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 5dabd8d..5233f14 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; }