diff options
author | Cong Wang <amwang@redhat.com> | 2013-01-07 21:52:41 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-01-09 02:56:10 +0100 |
commit | b3d936f3ea1c97c32680e0cd235474cf9dadb762 (patch) | |
tree | 55231f53fa50114417709a1cc2623f124bcba1f0 /drivers/net/netconsole.c | |
parent | ipv6: move csum_ipv6_magic() and udp6_csum_init() into static library (diff) | |
download | linux-b3d936f3ea1c97c32680e0cd235474cf9dadb762.tar.xz linux-b3d936f3ea1c97c32680e0cd235474cf9dadb762.zip |
netpoll: add IPv6 support
Currently, netpoll only supports IPv4. This patch adds IPv6
support to netpoll so that we can run netconsole over IPv6 network.
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Cong Wang <amwang@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/netconsole.c')
-rw-r--r-- | drivers/net/netconsole.c | 44 |
1 files changed, 38 insertions, 6 deletions
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 998fa0257a92..37add21a3d7d 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -269,13 +269,17 @@ static ssize_t show_remote_port(struct netconsole_target *nt, char *buf) static ssize_t show_local_ip(struct netconsole_target *nt, char *buf) { - if (!nt->np.ipv6) + if (nt->np.ipv6) + return snprintf(buf, PAGE_SIZE, "%pI6c\n", &nt->np.local_ip.in6); + else return snprintf(buf, PAGE_SIZE, "%pI4\n", &nt->np.local_ip); } static ssize_t show_remote_ip(struct netconsole_target *nt, char *buf) { - if (!nt->np.ipv6) + if (nt->np.ipv6) + return snprintf(buf, PAGE_SIZE, "%pI6c\n", &nt->np.remote_ip.in6); + else return snprintf(buf, PAGE_SIZE, "%pI4\n", &nt->np.remote_ip); } @@ -412,8 +416,22 @@ static ssize_t store_local_ip(struct netconsole_target *nt, return -EINVAL; } - if (!strnchr(buf, count, ':')) - nt->np.local_ip.ip = in_aton(buf); + if (strnchr(buf, count, ':')) { + const char *end; + if (in6_pton(buf, count, nt->np.local_ip.in6.s6_addr, -1, &end) > 0) { + if (*end && *end != '\n') { + printk(KERN_ERR "netconsole: invalid IPv6 address at: <%c>\n", *end); + return -EINVAL; + } + nt->np.ipv6 = true; + } else + return -EINVAL; + } else { + if (!nt->np.ipv6) { + nt->np.local_ip.ip = in_aton(buf); + } else + return -EINVAL; + } return strnlen(buf, count); } @@ -429,8 +447,22 @@ static ssize_t store_remote_ip(struct netconsole_target *nt, return -EINVAL; } - if (!strnchr(buf, count, ':')) - nt->np.remote_ip.ip = in_aton(buf); + if (strnchr(buf, count, ':')) { + const char *end; + if (in6_pton(buf, count, nt->np.remote_ip.in6.s6_addr, -1, &end) > 0) { + if (*end && *end != '\n') { + printk(KERN_ERR "netconsole: invalid IPv6 address at: <%c>\n", *end); + return -EINVAL; + } + nt->np.ipv6 = true; + } else + return -EINVAL; + } else { + if (!nt->np.ipv6) { + nt->np.remote_ip.ip = in_aton(buf); + } else + return -EINVAL; + } return strnlen(buf, count); } |