Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1186098pxb; Sun, 11 Apr 2021 10:17:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+rahN/79OcxJWWZyrB6FK/Q6sg7yp60XSwoFMd+GuwnXDzFw14hr/d0VlVcEtVxKR+ZCI X-Received: by 2002:a63:e318:: with SMTP id f24mr6973365pgh.212.1618161435510; Sun, 11 Apr 2021 10:17:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618161435; cv=none; d=google.com; s=arc-20160816; b=PnEFkRWh09MqgcfzzhkHNtmg6YsAn1tHKcC2/cEwLj1+0zjTuxxQUrqClywI8Y102f UD1JBKJm1lr60w3H28IZHc5RWHznzCa9AOwW+xrFB581nAca8ks47kdkhaf4SsmlkCN1 yK5b7Epexh/Q5k8yYDJAROqi0dyVSdXZZRYxCA9RNx07dvcV6ta7qjODG5rukxRfJ708 HSgIknFg6EgDGN7uPwEOnazy5LNhdDU9mhNnfl+Dnk95GZgFRp+Q7EflnKACqx9FHmXj bnZ7+Px1It123QjvSmWuJc6L45thjdo68+BHS+ZE55qEg+UJtwxVRiCh1sGJkv12aE8B rY3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=oU9M0yEQA82+X1/ZR45YbPir+XlGNryVAzw61jdT/10=; b=sRDeleg/l83H/45lzm/onwEJv5v8N7a5a/MugqbrFlcZ1WCi5K6h1PotxsIX9gGfye Rj32TI2z3xFDOEY94KtcTUwAto+K1FyFkwl7eVNXvta5jVQIU+qphL8Q7IURUgq4GYet OyjD/FvOwSI2q5QGf8wKeOXriYhFL/6C86jTCcgOvFijps6DoSrP8X/cjn/wp11caen+ WmuA0UkhdwDD7iR/T8PlPYoD+0jJono75x7CC/1Kk+cqUX6RCqmPnDzWMhJ8KvuZLsJa HVm/AHUpAEBeSqHnwWCVmOnPN08mH0JGtsVuoSslRG3AyBQZ9jvi1448i6VtHdAJeuWl Tgxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HrvwYiEi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b11si10644327plg.355.2021.04.11.10.17.02; Sun, 11 Apr 2021 10:17:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HrvwYiEi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236306AbhDKPEf (ORCPT + 99 others); Sun, 11 Apr 2021 11:04:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236182AbhDKPEe (ORCPT ); Sun, 11 Apr 2021 11:04:34 -0400 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45EEFC061574; Sun, 11 Apr 2021 08:04:18 -0700 (PDT) Received: by mail-ej1-x630.google.com with SMTP id u17so16092165ejk.2; Sun, 11 Apr 2021 08:04:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oU9M0yEQA82+X1/ZR45YbPir+XlGNryVAzw61jdT/10=; b=HrvwYiEiwSwJ74cCd24Sb7zSz2skg4nAG8HJbySNYh7Tp9nm9PVsyKj5LWQ8UrXTRk L6CT+v4JCBynL/1kqpOeEsDkMLMLpZed1RDkkDup4l7gayYrh4Raphs9PV4wCzEhm0t/ vZh8q7FT/QTZqbeAexiZYmh0bxk7jHW61a7aHK7b7mU+AaAZJiXrKBca0M8o6b8D49s+ +qINJdIkfwcW6CFRZaL7tGwoog/USaG6QrIXQVkfyEOBYEp7UcM4fz6gSciAzCzWVUAO KdrPFk99tlS6mA43nIiOGu2P6a8XXepaiVn5aiVJ7DpLOrpx6fCnH2W0DsGF94b2on7O KhbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oU9M0yEQA82+X1/ZR45YbPir+XlGNryVAzw61jdT/10=; b=J6X5LLMC12dPCY26WWB5yHHTfRa9WztuGiXVAg8NVuL73WQCbyBj5FztguD5VQNWIZ Esjvt9XL92rY/MUesL0VhomKT3R6b/G6yNzj1Z/NVuJ9qu8aS6KWv3NkZffUgLjP/wbA zkkj43yJjCwX23F0FH71H7NodGeaP+HRLRzIA+ZII6YrFBcFoD2jWTxiD1rRGfUqIK95 h/RmlGKU2UHyJe5l4yXT7zMEA8GUMfGUTW4I/2TBxHll4fefLVIZfVlHh4p+PkcOUOGE N8lrbhe32uZrkEDWGLkFx+gMM6iqe5x7YQut65GrCKsTVQ5bqlJ8sWTmdCp8EOQ/Tyaz gUKg== X-Gm-Message-State: AOAM533MXd7Ywx/28b4hUKAWexC6nzfIh4F/99noFUEwjPORK7eJVNV0 HHAWecxsKDB1z2qHIjXjwo+Vlv0ncZJ5SQ== X-Received: by 2002:a17:906:9501:: with SMTP id u1mr23674613ejx.324.1618153455791; Sun, 11 Apr 2021 08:04:15 -0700 (PDT) Received: from Ansuel-xps.localdomain (host-95-239-254-7.retail.telecomitalia.it. [95.239.254.7]) by smtp.googlemail.com with ESMTPSA id l15sm4736146edb.48.2021.04.11.08.04.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Apr 2021 08:04:15 -0700 (PDT) From: Ansuel Smith To: netdev@vger.kernel.org Cc: =?UTF-8?q?Marek=20Beh=C3=BAn?= , David Ahern , Stephen Hemminger , "David S. Miller" , Jakub Kicinski , Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Eric Dumazet , Wei Wang , Cong Wang , Taehee Yoo , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Di Zhu , Weilong Chen , Nikolay Aleksandrov , Colin Ian King , Roopa Prabhu , Francis Laniel , linux-kernel@vger.kernel.org Subject: [PATCH RFC iproute2-next] iplink: allow to change iplink value Date: Sat, 10 Apr 2021 15:34:50 +0200 Message-Id: <20210410133454.4768-5-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210410133454.4768-1-ansuelsmth@gmail.com> References: <20210410133454.4768-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Allow to change the interface to which a given interface is linked to. This is useful in the case of multi-CPU port DSA, for changing the CPU port of a given user port. Signed-off-by: Marek BehĂșn Cc: David Ahern Cc: Stephen Hemminger --- ip/iplink.c | 16 +++++----------- man/man8/ip-link.8.in | 7 +++++++ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/ip/iplink.c b/ip/iplink.c index 212a0885..d52c0aaf 100644 --- a/ip/iplink.c +++ b/ip/iplink.c @@ -579,7 +579,6 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req, char **type) { char *name = NULL; char *dev = NULL; - char *link = NULL; int ret, len; char abuf[32]; int qlen = -1; @@ -590,6 +589,7 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req, char **type) int numrxqueues = -1; int link_netnsid = -1; int index = 0; + int link = -1; int group = -1; int addr_len = 0; @@ -620,7 +620,10 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req, char **type) invarg("Invalid \"index\" value", *argv); } else if (matches(*argv, "link") == 0) { NEXT_ARG(); - link = *argv; + link = ll_name_to_index(*argv); + if (!link) + return nodev(*argv); + addattr32(&req->n, sizeof(*req), IFLA_LINK, link); } else if (matches(*argv, "address") == 0) { NEXT_ARG(); addr_len = ll_addr_a2n(abuf, sizeof(abuf), *argv); @@ -1004,15 +1007,6 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req, char **type) exit(-1); } - if (link) { - int ifindex; - - ifindex = ll_name_to_index(link); - if (!ifindex) - return nodev(link); - addattr32(&req->n, sizeof(*req), IFLA_LINK, ifindex); - } - req->i.ifi_index = index; } diff --git a/man/man8/ip-link.8.in b/man/man8/ip-link.8.in index a8ae72d2..800aed05 100644 --- a/man/man8/ip-link.8.in +++ b/man/man8/ip-link.8.in @@ -149,6 +149,9 @@ ip-link \- network device configuration .br .RB "[ " nomaster " ]" .br +.RB "[ " link +.IR DEVICE " ]" +.br .RB "[ " vrf .IR NAME " ]" .br @@ -2131,6 +2134,10 @@ set master device of the device (enslave device). .BI nomaster unset master device of the device (release device). +.TP +.BI link " DEVICE" +set device to which this device is linked to. + .TP .BI addrgenmode " eui64|none|stable_secret|random" set the IPv6 address generation mode -- 2.21.0