[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20251122220732.3203444-1-aadityakansal390@gmail.com>
Date: Sun, 23 Nov 2025 03:37:32 +0530
From: Aaditya Kansal <aadityakansal390@...il.com>
To: sfrench@...ba.org,
pc@...guebit.org
Cc: ronniesahlberg@...il.com,
sprasad@...rosoft.com,
tom@...pey.com,
linux-cifs@...r.kernel.org,
linux-kernel@...r.kernel.org,
skhan@...uxfoundation.org,
david.hunter.linux@...il.com,
Aaditya Kansal <aadityakansal390@...il.com>
Subject: [PATCH] ksmb: add ipv6 support in parse_srvaddr() in smb client
Add ipv6 support in parse_srvaddr() in fs/smb/client/cifsroot.c. The
existing parser filters out ipv4 out of the given string. The updated
implementation identifies the ip version by checking the characters used
and filters out the ip.
Signed-off-by: Aaditya Kansal <aadityakansal390@...il.com>
---
fs/smb/client/cifsroot.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/fs/smb/client/cifsroot.c b/fs/smb/client/cifsroot.c
index 56ec1b233f52..d957db8b2efe 100644
--- a/fs/smb/client/cifsroot.c
+++ b/fs/smb/client/cifsroot.c
@@ -24,13 +24,20 @@ static char root_opts[1024] __initdata = DEFAULT_MNT_OPTS;
static __be32 __init parse_srvaddr(char *start, char *end)
{
- /* TODO: ipv6 support */
- char addr[sizeof("aaa.bbb.ccc.ddd")];
+ char addr[sizeof("aaaa.bbbb.cccc.dddd.eeee.ffff.gggg.hhhh")];
int i = 0;
+ int ipv6 = -1;
while (start < end && i < sizeof(addr) - 1) {
- if (isdigit(*start) || *start == '.')
+ if (isdigit(*start))
addr[i++] = *start;
+ else if (*start == '.' && ipv6 != 1) {
+ addr[i++] = *start;
+ ipv6 = 0;
+ } else if ((isalpha(*start) || *start == ':') && ipv6 != 0) {
+ addr[i++] = *start;
+ ipv6 = 1;
+ }
start++;
}
addr[i] = '\0';
--
2.51.1
Powered by blists - more mailing lists