From patchwork Mon Sep 19 15:14:10 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Benc X-Patchwork-Id: 115366 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 0AD15B6FD7 for ; Tue, 20 Sep 2011 01:14:23 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754662Ab1ISPOS (ORCPT ); Mon, 19 Sep 2011 11:14:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42904 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753134Ab1ISPOR (ORCPT ); Mon, 19 Sep 2011 11:14:17 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p8JFEER9012190 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 19 Sep 2011 11:14:14 -0400 Received: from griffin (ovpn-116-49.ams2.redhat.com [10.36.116.49]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p8JFEBFV010557 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Mon, 19 Sep 2011 11:14:13 -0400 Date: Mon, 19 Sep 2011 17:14:10 +0200 From: Jiri Benc To: netdev@vger.kernel.org Cc: Stephen Hemminger Subject: [PATCH] iproute2: fix changing of ip6ip6 tunnel parameters Message-ID: <20110919171410.1b2bf005@griffin> Mime-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org When changing ip6ip6 parameters (ip -6 tun change), ip passes zeroed struct ip6_tnl_parm to the kernel. The kernel then tries to change all of the tunnel parameters to the passed values, including zeroing of local and remote address. This fails (-EEXIST in net/ipv6/ip6_tunnel.c:ip6_tnl_ioctl). For other tunnel types, ip fetches the current parameters first and applies the required changes on top of them. This patch applies the same code as in ip/iptunnel.c to ip/ip6tunnel.c. See http://bugzilla.redhat.com/730627 for the original bug report. Signed-off-by: Jiri Benc --- a/ip/ip6tunnel.c +++ b/ip/ip6tunnel.c @@ -106,8 +106,9 @@ static void print_tunnel(struct ip6_tnl_ printf(" dscp inherit"); } -static int parse_args(int argc, char **argv, struct ip6_tnl_parm *p) +static int parse_args(int argc, char **argv, int cmd, struct ip6_tnl_parm *p) { + int count = 0; char medium[IFNAMSIZ]; memset(medium, 0, sizeof(medium)); @@ -207,7 +208,15 @@ static int parse_args(int argc, char **a if (p->name[0]) duparg2("name", *argv); strncpy(p->name, *argv, IFNAMSIZ - 1); + if (cmd == SIOCCHGTUNNEL && count == 0) { + struct ip6_tnl_parm old_p; + memset(&old_p, 0, sizeof(old_p)); + if (tnl_get_ioctl(*argv, &old_p)) + return -1; + *p = old_p; + } } + count++; argc--; argv++; } if (medium[0]) { @@ -340,7 +349,7 @@ static int do_show(int argc, char **argv ip6_tnl_parm_init(&p, 0); p.proto = 0; /* default to any */ - if (parse_args(argc, argv, &p) < 0) + if (parse_args(argc, argv, SIOCGETTUNNEL, &p) < 0) return -1; if (!p.name[0] || show_stats) @@ -361,7 +370,7 @@ static int do_add(int cmd, int argc, cha ip6_tnl_parm_init(&p, 1); - if (parse_args(argc, argv, &p) < 0) + if (parse_args(argc, argv, cmd, &p) < 0) return -1; return tnl_add_ioctl(cmd, @@ -375,7 +384,7 @@ static int do_del(int argc, char **argv) ip6_tnl_parm_init(&p, 1); - if (parse_args(argc, argv, &p) < 0) + if (parse_args(argc, argv, SIOCDELTUNNEL, &p) < 0) return -1; return tnl_del_ioctl(p.name[0] ? p.name : "ip6tnl0", p.name, &p);