From 7220ecc26a9a8e6766eb9ec7cd90fbba048ce7b3 Mon Sep 17 00:00:00 2001
From: Andrea Pesaresi <andreapesaresi82@gmail.com>
Date: Tue, 30 Sep 2025 19:35:36 +0200
Subject: Revert "ksmbd: extend the connection limiting mechanism to support
 IPv6"

This reverts commit d9e157fcfebc126cd19b2333a6417a840c24e529.
---
 fs/smb/server/connection.h    |  7 +------
 fs/smb/server/transport_tcp.c | 26 +++-----------------------
 2 files changed, 4 insertions(+), 29 deletions(-)

--- a/fs/smb/server/connection.h
+++ b/fs/smb/server/connection.h
@@ -46,12 +46,7 @@ struct ksmbd_conn {
 	struct mutex			srv_mutex;
 	int				status;
 	unsigned int			cli_cap;
-	union {
-		__be32			inet_addr;
-#if IS_ENABLED(CONFIG_IPV6)
-		u8			inet6_addr[16];
-#endif
-	};
+	__be32				inet_addr;
 	char				*request_buf;
 	struct ksmbd_transport		*transport;
 	struct nls_table		*local_nls;
--- a/fs/smb/server/transport_tcp.c
+++ b/fs/smb/server/transport_tcp.c
@@ -87,14 +87,7 @@ static struct tcp_transport *alloc_trans
 		return NULL;
 	}
 
-#if IS_ENABLED(CONFIG_IPV6)
-	if (client_sk->sk->sk_family == AF_INET6)
-		memcpy(&conn->inet6_addr, &client_sk->sk->sk_v6_daddr, 16);
-	else
-		conn->inet_addr = inet_sk(client_sk->sk)->inet_daddr;
-#else
 	conn->inet_addr = inet_sk(client_sk->sk)->inet_daddr;
-#endif
 	conn->transport = KSMBD_TRANS(t);
 	KSMBD_TRANS(t)->conn = conn;
 	KSMBD_TRANS(t)->ops = &ksmbd_tcp_transport_ops;
@@ -238,6 +231,7 @@ static int ksmbd_kthread_fn(void *p)
 {
 	struct socket *client_sk = NULL;
 	struct interface *iface = (struct interface *)p;
+	struct inet_sock *csk_inet;
 	struct ksmbd_conn *conn;
 	int ret;
 
@@ -260,27 +254,13 @@ static int ksmbd_kthread_fn(void *p)
 		/*
 		 * Limits repeated connections from clients with the same IP.
 		 */
+		csk_inet = inet_sk(client_sk->sk);
 		down_read(&conn_list_lock);
 		list_for_each_entry(conn, &conn_list, conns_list)
-#if IS_ENABLED(CONFIG_IPV6)
-			if (client_sk->sk->sk_family == AF_INET6) {
-				if (memcmp(&client_sk->sk->sk_v6_daddr,
-					   &conn->inet6_addr, 16) == 0) {
-					ret = -EAGAIN;
-					break;
-				}
-			} else if (inet_sk(client_sk->sk)->inet_daddr ==
-				 conn->inet_addr) {
+			if (csk_inet->inet_daddr == conn->inet_addr) {
 				ret = -EAGAIN;
 				break;
 			}
-#else
-			if (inet_sk(client_sk->sk)->inet_daddr ==
-			    conn->inet_addr) {
-				ret = -EAGAIN;
-				break;
-			}
-#endif
 		up_read(&conn_list_lock);
 		if (ret == -EAGAIN)
 			continue;
