From patchwork Thu Jun 4 12:01:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thadeu Lima de Souza Cascardo X-Patchwork-Id: 480671 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 7036B140271 for ; Thu, 4 Jun 2015 22:01:30 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753001AbbFDMB0 (ORCPT ); Thu, 4 Jun 2015 08:01:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46321 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752268AbbFDMBZ (ORCPT ); Thu, 4 Jun 2015 08:01:25 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 0F4B3362AEA; Thu, 4 Jun 2015 12:01:25 +0000 (UTC) Received: from indiana.gru.redhat.com (ovpn-113-214.phx2.redhat.com [10.3.113.214]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t54C1JDM016402 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 4 Jun 2015 08:01:23 -0400 Date: Thu, 4 Jun 2015 09:01:18 -0300 From: Thadeu Lima de Souza Cascardo To: netdev@vger.kernel.org Cc: stephen@networkplumber.org Subject: [PATCH iproute2 resend] Fix changing tunnel remote and local address to any Message-ID: <20150604120117.GB7119@indiana.gru.redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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. Signed-off-by: Thadeu Lima de Souza Cascardo Acked-by: Nicolas Dichtel --- Resending because it was probably lost in patchwork. --- ip/iptunnel.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ip/iptunnel.c b/ip/iptunnel.c index be84b83..78fa988 100644 --- a/ip/iptunnel.c +++ b/ip/iptunnel.c @@ -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);