Skip to contentSkip to conversation

netpoll: fix netconsole IPv6 setup

PATCH In review Sabrina Dubroca 3 participants 5 messages Feb 6, 2014 – Feb 7, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netpoll: fix netconsole IPv6 setup

Currently, to make netconsole start over IPv6, the source address needs to be specified. Without a source address, netpoll_parse_options assumes we're setting up over IPv4 and the destination IPv6 address is rejected.

Check if the IP version has been forced by a source address before checking for a version mismatch when parsing the destination address.

---
 net/core/netpoll.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/core/netpoll.c +3 -1
index c03f3de..a664f78 100644
@@ -948,6 +948,7 @@ int netpoll_parse_options(struct netpoll *np, char *opt)
 {
 	char *cur=opt, *delim;
 	int ipv6;
+	bool ipversion_set = false;
 
 	if (*cur != '@') {
 		if ((delim = strchr(cur, '@')) == NULL)
@@ -960,6 +961,7 @@ int netpoll_parse_options(struct netpoll *np, char *opt)
 	cur++;
 
 	if (*cur != '/') {
+		ipversion_set = true;
 		if ((delim = strchr(cur, '/')) == NULL)
 			goto parse_failed;
 		*delim = 0;
@@ -1002,7 +1004,7 @@ int netpoll_parse_options(struct netpoll *np, char *opt)
 	ipv6 = netpoll_parse_ip_addr(cur, &np->remote_ip);
 	if (ipv6 < 0)
 		goto parse_failed;
-	else if (np->ipv6 != (bool)ipv6)
+	else if (ipversion_set && np->ipv6 != (bool)ipv6)
 		goto parse_failed;
 	else
 		np->ipv6 = (bool)ipv6;
Signature · 1 line
1.8.5.3
#1 lore raw

net/core/netpoll.c int netpoll_parse_options(struct netpoll *np, char *opt) · line 952

Quoted 13 lines · Sabrina Dubroca
 net/core/netpoll.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/core/netpoll.c +1 -0
index c03f3de..a664f78 100644
@@ -948,6 +948,7 @@ int netpoll_parse_options(struct netpoll *np, char *opt)
 {
        char *cur=opt, *delim;
        int ipv6;
+       bool ipversion_set = false;
 

Or initialize 'ipv6' to -1 and then check if it is -1?

#2 lore raw
Quoted 4 lines · Cong Wang
Quoted 3 lines · Sabrina Dubroca
 net/core/netpoll.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Quoted 12 lines

net/core/netpoll.c int netpoll_parse_options(struct netpoll *np, char *opt) · line 952

Quoted 10 lines
net/core/netpoll.c +1 -0
index c03f3de..a664f78 100644
@@ -948,6 +948,7 @@ int netpoll_parse_options(struct netpoll *np, char *opt)
 {
        char *cur=opt, *delim;
        int ipv6;
+       bool ipversion_set = false;
 

Or initialize 'ipv6' to -1 and then check if it is -1?

It's overwritten when we parse the remote address. And np->ipv6 is a bool, so we can't store it there either.

Signature · 1 line
Sabrina
Acked-by
#3 lore raw
Quoted 18 lines · Sabrina Dubroca
Quoted 4 lines · Cong Wang
Quoted 3 lines · Sabrina Dubroca
 net/core/netpoll.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Quoted 12 lines

net/core/netpoll.c int netpoll_parse_options(struct netpoll *np, char *opt) · line 952

Quoted 10 lines
net/core/netpoll.c +1 -0
index c03f3de..a664f78 100644
@@ -948,6 +948,7 @@ int netpoll_parse_options(struct netpoll *np, char *opt)
 {
        char *cur=opt, *delim;
        int ipv6;
+       bool ipversion_set = false;
 

Or initialize 'ipv6' to -1 and then check if it is -1?

Quoted 3 lines

It's overwritten when we parse the remote address. And np->ipv6 is a bool, so we can't store it there either.

Yeah, I misunderstood the problem. Your fix looks good.

For net-next, I think we should change bool np->ipv6 to int np->ip_version, so that we can tell if it is set or not.

Thanks!

maintainer
#4 lore raw
In reply to Sabrina Dubroca

From: Sabrina Dubroca <[email protected]>
Date: Thu, 6 Feb 2014 18:34:12 +0100

Quoted 9 lines

Currently, to make netconsole start over IPv6, the source address needs to be specified. Without a source address, netpoll_parse_options assumes we're setting up over IPv4 and the destination IPv6 address is rejected.

Check if the IP version has been forced by a source address before checking for a version mismatch when parsing the destination address.

Applied and queued up for -stable.