Skip to contentSkip to conversation

ksmb: add ipv6 support in parse_srvaddr() in smb client

PATCH New Aaditya Kansal 1 participant 1 message Nov 22, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 fs/smb/client/cifsroot.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
fs/smb/client/cifsroot.c +10 -3
index 56ec1b233f52..d957db8b2efe 100644
@@ -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';
Signature · 1 line
2.51.1