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@gmail.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