diff options
Diffstat (limited to 'drivers/net/netconsole.c')
| -rw-r--r-- | drivers/net/netconsole.c | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 6989ebe2bc79..37add21a3d7d 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c | |||
| @@ -269,12 +269,18 @@ static ssize_t show_remote_port(struct netconsole_target *nt, char *buf) | |||
| 269 | 269 | ||
| 270 | static ssize_t show_local_ip(struct netconsole_target *nt, char *buf) | 270 | static ssize_t show_local_ip(struct netconsole_target *nt, char *buf) |
| 271 | { | 271 | { |
| 272 | return snprintf(buf, PAGE_SIZE, "%pI4\n", &nt->np.local_ip); | 272 | if (nt->np.ipv6) |
| 273 | return snprintf(buf, PAGE_SIZE, "%pI6c\n", &nt->np.local_ip.in6); | ||
| 274 | else | ||
| 275 | return snprintf(buf, PAGE_SIZE, "%pI4\n", &nt->np.local_ip); | ||
| 273 | } | 276 | } |
| 274 | 277 | ||
| 275 | static ssize_t show_remote_ip(struct netconsole_target *nt, char *buf) | 278 | static ssize_t show_remote_ip(struct netconsole_target *nt, char *buf) |
| 276 | { | 279 | { |
| 277 | return snprintf(buf, PAGE_SIZE, "%pI4\n", &nt->np.remote_ip); | 280 | if (nt->np.ipv6) |
| 281 | return snprintf(buf, PAGE_SIZE, "%pI6c\n", &nt->np.remote_ip.in6); | ||
| 282 | else | ||
| 283 | return snprintf(buf, PAGE_SIZE, "%pI4\n", &nt->np.remote_ip); | ||
| 278 | } | 284 | } |
| 279 | 285 | ||
| 280 | static ssize_t show_local_mac(struct netconsole_target *nt, char *buf) | 286 | static ssize_t show_local_mac(struct netconsole_target *nt, char *buf) |
| @@ -410,7 +416,22 @@ static ssize_t store_local_ip(struct netconsole_target *nt, | |||
| 410 | return -EINVAL; | 416 | return -EINVAL; |
| 411 | } | 417 | } |
| 412 | 418 | ||
| 413 | nt->np.local_ip = in_aton(buf); | 419 | if (strnchr(buf, count, ':')) { |
| 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 | } | ||
| 414 | 435 | ||
| 415 | return strnlen(buf, count); | 436 | return strnlen(buf, count); |
| 416 | } | 437 | } |
| @@ -426,7 +447,22 @@ static ssize_t store_remote_ip(struct netconsole_target *nt, | |||
| 426 | return -EINVAL; | 447 | return -EINVAL; |
| 427 | } | 448 | } |
| 428 | 449 | ||
| 429 | nt->np.remote_ip = in_aton(buf); | 450 | if (strnchr(buf, count, ':')) { |
| 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 | } | ||
| 430 | 466 | ||
| 431 | return strnlen(buf, count); | 467 | return strnlen(buf, count); |
| 432 | } | 468 | } |
