Skip to content

Commit

Permalink
netpoll: add IPv6 support
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Cong Wang <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Cong Wang authored and davem330 committed Jan 9, 2013
1 parent acb3e04 commit b3d936f
Show file tree
Hide file tree
Showing 2 changed files with 274 additions and 16 deletions.
44 changes: 38 additions & 6 deletions drivers/net/netconsole.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down
Loading

0 comments on commit b3d936f

Please sign in to comment.