From patchwork Wed Mar 14 17:30:34 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: stephen hemminger X-Patchwork-Id: 146692 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 E57CCB6EEA for ; Thu, 15 Mar 2012 04:30:40 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760259Ab2CNRaj (ORCPT ); Wed, 14 Mar 2012 13:30:39 -0400 Received: from mail.vyatta.com ([76.74.103.46]:42721 "EHLO mail.vyatta.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760076Ab2CNRah (ORCPT ); Wed, 14 Mar 2012 13:30:37 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.vyatta.com (Postfix) with ESMTP id 66E15142001F; Wed, 14 Mar 2012 10:30:36 -0700 (PDT) X-Virus-Scanned: amavisd-new at tahiti.vyatta.com Received: from mail.vyatta.com ([127.0.0.1]) by localhost (mail.vyatta.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GOoAQMtW4fsl; Wed, 14 Mar 2012 10:30:35 -0700 (PDT) Received: from nehalam.linuxnetplumber.net (static-50-53-80-93.bvtn.or.frontiernet.net [50.53.80.93]) by mail.vyatta.com (Postfix) with ESMTPSA id 6FB4C1410002; Wed, 14 Mar 2012 10:30:35 -0700 (PDT) Date: Wed, 14 Mar 2012 10:30:34 -0700 From: Stephen Hemminger To: Herbert Xu Cc: netdev@vger.kernel.org Subject: [PATCH] iproute: allow changing gretap parameters Message-ID: <20120314103034.451cf3a9@nehalam.linuxnetplumber.net> Organization: Vyatta X-Mailer: Claws Mail 3.8.0 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Change the order of evaluation of ip link type arguements to allow changing parameters of gre tunnels. The following wouldn't work: # ip li add mytunnel type gretap remote 1.1.1.1 key 3 # ip li set mytunnel type gretap key 9 --- ip/iplink.c | 60 +++++++++++++++++++++++++++++----------------------------- 1 files changed, 30 insertions(+), 30 deletions(-) diff --git a/ip/iplink.c b/ip/iplink.c index 6b051b6..8481514 100644 --- a/ip/iplink.c +++ b/ip/iplink.c @@ -490,36 +490,6 @@ static int iplink_modify(int cmd, unsigned int flags, int argc, char **argv) ll_init_map(&rth); - if (type) { - struct rtattr *linkinfo = NLMSG_TAIL(&req.n); - addattr_l(&req.n, sizeof(req), IFLA_LINKINFO, NULL, 0); - addattr_l(&req.n, sizeof(req), IFLA_INFO_KIND, type, - strlen(type)); - - lu = get_link_kind(type); - if (lu && argc) { - struct rtattr * data = NLMSG_TAIL(&req.n); - addattr_l(&req.n, sizeof(req), IFLA_INFO_DATA, NULL, 0); - - if (lu->parse_opt && - lu->parse_opt(lu, argc, argv, &req.n)) - return -1; - - data->rta_len = (void *)NLMSG_TAIL(&req.n) - (void *)data; - } else if (argc) { - if (matches(*argv, "help") == 0) - usage(); - fprintf(stderr, "Garbage instead of arguments \"%s ...\". " - "Try \"ip link help\".\n", *argv); - return -1; - } - linkinfo->rta_len = (void *)NLMSG_TAIL(&req.n) - (void *)linkinfo; - } else if (flags & NLM_F_CREATE) { - fprintf(stderr, "Not enough information: \"type\" argument " - "is required\n"); - return -1; - } - if (!(flags & NLM_F_CREATE)) { if (!dev) { fprintf(stderr, "Not enough information: \"dev\" " @@ -559,6 +529,36 @@ static int iplink_modify(int cmd, unsigned int flags, int argc, char **argv) addattr_l(&req.n, sizeof(req), IFLA_IFNAME, name, len); } + if (type) { + struct rtattr *linkinfo = NLMSG_TAIL(&req.n); + addattr_l(&req.n, sizeof(req), IFLA_LINKINFO, NULL, 0); + addattr_l(&req.n, sizeof(req), IFLA_INFO_KIND, type, + strlen(type)); + + lu = get_link_kind(type); + if (lu && argc) { + struct rtattr * data = NLMSG_TAIL(&req.n); + addattr_l(&req.n, sizeof(req), IFLA_INFO_DATA, NULL, 0); + + if (lu->parse_opt && + lu->parse_opt(lu, argc, argv, &req.n)) + return -1; + + data->rta_len = (void *)NLMSG_TAIL(&req.n) - (void *)data; + } else if (argc) { + if (matches(*argv, "help") == 0) + usage(); + fprintf(stderr, "Garbage instead of arguments \"%s ...\". " + "Try \"ip link help\".\n", *argv); + return -1; + } + linkinfo->rta_len = (void *)NLMSG_TAIL(&req.n) - (void *)linkinfo; + } else if (flags & NLM_F_CREATE) { + fprintf(stderr, "Not enough information: \"type\" argument " + "is required\n"); + return -1; + } + if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0) exit(2);