summaryrefslogtreecommitdiffstats
path: root/drivers/net/netconsole.c
diff options
context:
space:
mode:
authorCong Wang <amwang@redhat.com>2013-01-07 15:52:41 -0500
committerDavid S. Miller <davem@davemloft.net>2013-01-08 20:56:10 -0500
commitb3d936f3ea1c97c32680e0cd235474cf9dadb762 (patch)
tree55231f53fa50114417709a1cc2623f124bcba1f0 /drivers/net/netconsole.c
parentacb3e04119fbf9145eb6d6bb707f6fb662ab4d3b (diff)
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.c44
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)
269 269
270static ssize_t show_local_ip(struct netconsole_target *nt, char *buf) 270static ssize_t show_local_ip(struct netconsole_target *nt, char *buf)
271{ 271{
272 if (!nt->np.ipv6) 272 if (nt->np.ipv6)
273 return snprintf(buf, PAGE_SIZE, "%pI6c\n", &nt->np.local_ip.in6);
274 else
273 return snprintf(buf, PAGE_SIZE, "%pI4\n", &nt->np.local_ip); 275 return snprintf(buf, PAGE_SIZE, "%pI4\n", &nt->np.local_ip);
274} 276}
275 277
276static ssize_t show_remote_ip(struct netconsole_target *nt, char *buf) 278static ssize_t show_remote_ip(struct netconsole_target *nt, char *buf)
277{ 279{
278 if (!nt->np.ipv6) 280 if (nt->np.ipv6)
281 return snprintf(buf, PAGE_SIZE, "%pI6c\n", &nt->np.remote_ip.in6);
282 else
279 return snprintf(buf, PAGE_SIZE, "%pI4\n", &nt->np.remote_ip); 283 return snprintf(buf, PAGE_SIZE, "%pI4\n", &nt->np.remote_ip);
280} 284}
281 285
@@ -412,8 +416,22 @@ static ssize_t store_local_ip(struct netconsole_target *nt,
412 return -EINVAL; 416 return -EINVAL;
413 } 417 }
414 418
415 if (!strnchr(buf, count, ':')) 419 if (strnchr(buf, count, ':')) {
416 nt->np.local_ip.ip = in_aton(buf); 420 const char *end;
421 if (in6_pton(buf, count, nt->np.local_ip.in6.s6_addr, -1, &end) > 0) {
422 if (*end && *end != '\n') {
423 printk(KERN_ERR "netconsole: invalid IPv6 address at: <%c>\n", *end);
424 return -EINVAL;
425 }
426 nt->np.ipv6 = true;
427 } else
428 return -EINVAL;
429 } else {
430 if (!nt->np.ipv6) {
431 nt->np.local_ip.ip = in_aton(buf);
432 } else
433 return -EINVAL;
434 }
417 435
418 return strnlen(buf, count); 436 return strnlen(buf, count);
419} 437}
@@ -429,8 +447,22 @@ static ssize_t store_remote_ip(struct netconsole_target *nt,
429 return -EINVAL; 447 return -EINVAL;
430 } 448 }
431 449
432 if (!strnchr(buf, count, ':')) 450 if (strnchr(buf, count, ':')) {
433 nt->np.remote_ip.ip = in_aton(buf); 451 const char *end;
452 if (in6_pton(buf, count, nt->np.remote_ip.in6.s6_addr, -1, &end) > 0) {
453 if (*end && *end != '\n') {
454 printk(KERN_ERR "netconsole: invalid IPv6 address at: <%c>\n", *end);
455 return -EINVAL;
456 }
457 nt->np.ipv6 = true;
458 } else
459 return -EINVAL;
460 } else {
461 if (!nt->np.ipv6) {
462 nt->np.remote_ip.ip = in_aton(buf);
463 } else
464 return -EINVAL;
465 }
434 466
435 return strnlen(buf, count); 467 return strnlen(buf, count);
436} 468}