* [PATCH] cifs: add ipv6 parsing
@ 2022-12-05 23:45 Elijah Conners
2022-12-06 1:13 ` [PATCH] cifs: fix tabbing Elijah Conners
0 siblings, 1 reply; 4+ messages in thread
From: Elijah Conners @ 2022-12-05 23:45 UTC (permalink / raw)
To: samba-technical, linux-cifs; +Cc: lsahlber, sfrench, pc, sprasad, tom
CIFS currently lacks IPv6 parsing, presenting complications for CIFS
over IPv6.
To parse both IPv4 and IPv6 addresses, the parse_srvaddr() function
was altered; parse_srvaddr() now returns void. To retrieve the IP
address from parse_srvaddr(), the parameters *out6 and *out32, an
in6_addr and a __be32 respectively, are provided. The value of
root_server_addr is determined by if those parameters are set or not.
The parsing in parse_srvaddr() was updated slightly. The character addr
can hold up to 46 characters, the longest a possible IPv6 address can
be. In the while loop, isdigit() has been replaced with isxdigit() to
account for letters present in IPv6 addresses, and *start is also
checked for being a colon. Finally, the function uses inet_pton() to
determine if the address is an IPv6 address; if so, *out6 is equal to
in6, set by inet_pton, otherwise, *out32 is set to in_aton(addr).
Signed-off-by: Elijah Conners <business@elijahpepe.com>
---
fs/cifs/cifsroot.c | 29 ++++++++++++++++++++---------
1 file changed, 20 insertions(+), 9 deletions(-)
diff --git a/fs/cifs/cifsroot.c b/fs/cifs/cifsroot.c
index 9e91a5a40aae..f0aba7c824dc 100644
--- a/fs/cifs/cifsroot.c
+++ b/fs/cifs/cifsroot.c
@@ -14,6 +14,7 @@
#include <linux/in.h>
#include <linux/inet.h>
#include <net/ipconfig.h>
+#include <arpa/inet.h>
#define DEFAULT_MNT_OPTS \
"vers=1.0,cifsacl,mfsymlinks,rsize=1048576,wsize=65536,uid=0,gid=0," \
@@ -22,19 +23,24 @@
static char root_dev[2048] __initdata = "";
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")];
+static void __init parse_srvaddr(char *start, char *end, struct in6_addr *out6, __be32 *out32)
+{
+ char addr[INET6_ADDRSTRLEN];
+ struct in6_addr in6;
int i = 0;
while (start < end && i < sizeof(addr) - 1) {
- if (isdigit(*start) || *start == '.')
+ if (isxdigit(*start) || *start == '.' || *start == ':')
addr[i++] = *start;
start++;
}
addr[i] = '\0';
- return in_aton(addr);
+
+ if (inet_pton(AF_INET6, addr, &in6) > 0) {
+ *out6 = in6;
+ } else {
+ *out32 = in_aton(addr);
+ }
}
/* cifsroot=//<server-ip>/<share>[,options] */
@@ -42,7 +48,8 @@ static int __init cifs_root_setup(char *line)
{
char *s;
int len;
- __be32 srvaddr = htonl(INADDR_NONE);
+ struct in6_addr addr6;
+ __be32 addr32;
ROOT_DEV = Root_CIFS;
@@ -60,7 +67,7 @@ static int __init cifs_root_setup(char *line)
return 1;
}
strlcpy(root_dev, line, len);
- srvaddr = parse_srvaddr(&line[2], s);
+ parse_srvaddr(&line[2], s, &addr6, &addr32);
if (*s) {
int n = snprintf(root_opts,
sizeof(root_opts), "%s,%s",
@@ -73,7 +80,11 @@ static int __init cifs_root_setup(char *line)
}
}
- root_server_addr = srvaddr;
+ if (addr6.is_set) {
+ root_server_addr = addr6;
+ } else if (addr32.is_set) {
+ root_server_addr = addr32;
+ }
return 1;
}
--
2.29.2.windows.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] cifs: fix tabbing
2022-12-05 23:45 [PATCH] cifs: add ipv6 parsing Elijah Conners
@ 2022-12-06 1:13 ` Elijah Conners
2022-12-06 4:42 ` Steve French
0 siblings, 1 reply; 4+ messages in thread
From: Elijah Conners @ 2022-12-06 1:13 UTC (permalink / raw)
To: samba-technical, linux-cifs; +Cc: tom, pc, sfrench, sprasad, lsahlber
Signed-off-by: Elijah Conners <business@elijahpepe.com>
---
fs/cifs/cifsroot.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/cifs/cifsroot.c b/fs/cifs/cifsroot.c
index f0aba7c824dc..46aaa731723d 100644
--- a/fs/cifs/cifsroot.c
+++ b/fs/cifs/cifsroot.c
@@ -37,9 +37,9 @@ static void __init parse_srvaddr(char *start, char *end, struct in6_addr *out6,
addr[i] = '\0';
if (inet_pton(AF_INET6, addr, &in6) > 0) {
- *out6 = in6;
- } else {
- *out32 = in_aton(addr);
+ *out6 = in6;
+ } else {
+ *out32 = in_aton(addr);
}
}
--
2.29.2.windows.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] cifs: fix tabbing
2022-12-06 1:13 ` [PATCH] cifs: fix tabbing Elijah Conners
@ 2022-12-06 4:42 ` Steve French
2022-12-06 5:11 ` Elijah Conners
0 siblings, 1 reply; 4+ messages in thread
From: Steve French @ 2022-12-06 4:42 UTC (permalink / raw)
To: Elijah Conners
Cc: samba-technical, linux-cifs, tom, pc, sfrench, sprasad, lsahlber
wasn't this problem introduced in your previous patch? Why not merge
them together since this is a cleanup for the tab problem in the
previous patch
On Mon, Dec 5, 2022 at 7:15 PM Elijah Conners <business@elijahpepe.com> wrote:
>
> Signed-off-by: Elijah Conners <business@elijahpepe.com>
> ---
> fs/cifs/cifsroot.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/fs/cifs/cifsroot.c b/fs/cifs/cifsroot.c
> index f0aba7c824dc..46aaa731723d 100644
> --- a/fs/cifs/cifsroot.c
> +++ b/fs/cifs/cifsroot.c
> @@ -37,9 +37,9 @@ static void __init parse_srvaddr(char *start, char *end, struct in6_addr *out6,
> addr[i] = '\0';
>
> if (inet_pton(AF_INET6, addr, &in6) > 0) {
> - *out6 = in6;
> - } else {
> - *out32 = in_aton(addr);
> + *out6 = in6;
> + } else {
> + *out32 = in_aton(addr);
> }
> }
>
> --
> 2.29.2.windows.2
>
>
>
--
Thanks,
Steve
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] cifs: fix tabbing
2022-12-06 4:42 ` Steve French
@ 2022-12-06 5:11 ` Elijah Conners
0 siblings, 0 replies; 4+ messages in thread
From: Elijah Conners @ 2022-12-06 5:11 UTC (permalink / raw)
To: Steve French; +Cc: linux-cifs
Steve French <smfrench@gmail.com> writes:
> wasn't this problem introduced in your previous patch? Why not merge
> them together since this is a cleanup for the tab problem in the
> previous patch
Thank you. I've merged the patches together.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-12-06 5:11 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-05 23:45 [PATCH] cifs: add ipv6 parsing Elijah Conners
2022-12-06 1:13 ` [PATCH] cifs: fix tabbing Elijah Conners
2022-12-06 4:42 ` Steve French
2022-12-06 5:11 ` Elijah Conners
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.