Skip to contentSkip to conversation

Fix changing tunnel remote and local address to any

PATCH RESEND Applied Thadeu Lima de Souza Cascardo 3 participants 3 messages Jun 4, 2015 – Jun 25, 2015

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

PATCH RESEND 1/1 Fix changing tunnel remote and local address to any

If a tunnel is created with a local address, you can't change it to any.

 # ip tunnel add tunl1 mode ipip remote 10.16.42.37 local 10.16.42.214 ttl 64
 # ip tunnel show tunl1
 tunl1: ip/ip  remote 10.16.42.37  local 10.16.42.214  ttl 64
 # ip tunnel change tunl1 local any
 # echo $?
 0
 # ip tunnel show tunl1
 tunl1: ip/ip  remote 10.16.42.37  local 10.16.42.214  ttl 64

It happens that parse_args zeroes ip_tunnel_parm, and when creating the tunnel, it is OK to leave it as is if the address is any. However, when changing the tunnel, the current parameters will be read from ip_tunnel_parm, and local and remote address won't be zeroes anymore, so it needs to be explicitly set to any.

---

Resending because it was probably lost in patchwork.

---
 ip/iptunnel.c | 4 ++++
 1 file changed, 4 insertions(+)
ip/iptunnel.c +4 -0
index be84b83..78fa988 100644
@@ -167,10 +167,14 @@ static int parse_args(int argc, char **argv, int cmd, struct ip_tunnel_parm *p)
 			NEXT_ARG();
 			if (strcmp(*argv, "any"))
 				p->iph.daddr = get_addr32(*argv);
+			else
+				p->iph.daddr = htonl(INADDR_ANY);
 		} else if (strcmp(*argv, "local") == 0) {
 			NEXT_ARG();
 			if (strcmp(*argv, "any"))
 				p->iph.saddr = get_addr32(*argv);
+			else
+				p->iph.saddr = htonl(INADDR_ANY);
 		} else if (strcmp(*argv, "dev") == 0) {
 			NEXT_ARG();
 			strncpy(medium, *argv, IFNAMSIZ-1);
Signature · 1 line
2.4.1
Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Thadeu Lima de Souza Cascardo

If a tunnel is created with a local address, you can't change it to any.

  # ip tunnel add tunl1 mode ipip remote 10.16.42.37 local 10.16.42.214 ttl 64
  # ip tunnel show tunl1
  tunl1: ip/ip  remote 10.16.42.37  local 10.16.42.214  ttl 64
  # ip tunnel change tunl1 local any
  # echo $?
  0
  # ip tunnel show tunl1
  tunl1: ip/ip  remote 10.16.42.37  local 10.16.42.214  ttl 64
Quoted 7 lines

It happens that parse_args zeroes ip_tunnel_parm, and when creating the tunnel, it is OK to leave it as is if the address is any. However, when changing the tunnel, the current parameters will be read from ip_tunnel_parm, and local and remote address won't be zeroes anymore, so it needs to be explicitly set to any.

#2 lore raw
Quoted 12 lines · On Mon, 08 Jun 2015 10:51:51 +0200 Nicolas Dichtel <[email protected]>…
Quoted 11 lines · Thadeu Lima de Souza Cascardo

If a tunnel is created with a local address, you can't change it to any.

  # ip tunnel add tunl1 mode ipip remote 10.16.42.37 local 10.16.42.214 ttl 64
  # ip tunnel show tunl1
  tunl1: ip/ip  remote 10.16.42.37  local 10.16.42.214  ttl 64
  # ip tunnel change tunl1 local any
  # echo $?
  0
  # ip tunnel show tunl1
  tunl1: ip/ip  remote 10.16.42.37  local 10.16.42.214  ttl 64
Quoted 8 lines
Quoted 7 lines

It happens that parse_args zeroes ip_tunnel_parm, and when creating the tunnel, it is OK to leave it as is if the address is any. However, when changing the tunnel, the current parameters will be read from ip_tunnel_parm, and local and remote address won't be zeroes anymore, so it needs to be explicitly set to any.

Applied.