From: Serhey Popovych <serhe.popovych@gmail.com>
To: netdev@vger.kernel.org
Cc: dsahern@gmail.com
Subject: [PATCH iproute2-next v3 4/8] iplink: Follow documented behaviour when "index" is given
Date: Thu, 22 Feb 2018 15:02:02 +0200 [thread overview]
Message-ID: <1519304526-18848-5-git-send-email-serhe.popovych@gmail.com> (raw)
In-Reply-To: <1519304526-18848-1-git-send-email-serhe.popovych@gmail.com>
Both ip-link(8) and error message when "index" parameter is given for
set/delete case says that index can only be given during network
device creation.
Follow this documented behaviour and get rid of ambiguous behaviour in
case of both "dev" and "index" specified for ip link delete scenario
(actually "index" being ignored in favor to "dev").
Prohibit "index" when configuring/deleting group of network devices.
Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
---
ip/iplink.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/ip/iplink.c b/ip/iplink.c
index 1359c0f..4e9f571 100644
--- a/ip/iplink.c
+++ b/ip/iplink.c
@@ -974,6 +974,12 @@ static int iplink_modify(int cmd, unsigned int flags, int argc, char **argv)
argc -= ret;
argv += ret;
+ if (!(flags & NLM_F_CREATE) && index) {
+ fprintf(stderr,
+ "index can be used only when creating devices.\n");
+ exit(-1);
+ }
+
if (group != -1) {
if (dev)
addattr_l(&req.n, sizeof(req), IFLA_GROUP,
@@ -1004,11 +1010,6 @@ static int iplink_modify(int cmd, unsigned int flags, int argc, char **argv)
"Not enough information: \"dev\" argument is required.\n");
exit(-1);
}
- if (cmd == RTM_NEWLINK && index) {
- fprintf(stderr,
- "index can be used only when creating devices.\n");
- exit(-1);
- }
req.i.ifi_index = ll_name_to_index(dev);
if (!req.i.ifi_index)
--
1.7.10.4
next prev parent reply other threads:[~2018-02-22 13:02 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-22 13:01 [PATCH iproute2-next v3 0/8] iplink: Improve iplink_parse() Serhey Popovych
2018-02-22 13:01 ` [PATCH iproute2-next v3 1/8] utils: Introduce and use nodev() helper routine Serhey Popovych
2018-02-22 13:02 ` [PATCH iproute2-next v3 2/8] iplink: Correctly report error when network device isn't found Serhey Popovych
2018-02-23 23:41 ` David Ahern
2018-02-25 12:07 ` Serhey Popovych
2018-02-22 13:02 ` [PATCH iproute2-next v3 3/8] iplink: Use "dev" and "name" parameters interchangeable when possible Serhey Popovych
2018-02-22 13:02 ` Serhey Popovych [this message]
2018-02-22 13:02 ` [PATCH iproute2-next v3 5/8] veth,vxcan: Save/reinitialize/restore whole @struct ifinfomsg Serhey Popovych
2018-02-26 3:28 ` David Ahern
2018-02-26 15:48 ` Serhey Popovych
2018-02-26 15:57 ` Serhey Popovych
2018-02-22 13:02 ` [PATCH iproute2-next v3 6/8] iplink: Perform most of request buffer setups and checks in iplink_parse() Serhey Popovych
2018-02-26 3:31 ` David Ahern
2018-02-26 15:51 ` Serhey Popovych
2018-02-22 13:02 ` [PATCH iproute2-next v3 7/8] iplink: Move data structures to block of their users Serhey Popovych
2018-02-22 13:02 ` [PATCH iproute2-next v3 8/8] iplink: Reduce number of arguments to iplink_parse() Serhey Popovych
2018-02-26 3:35 ` David Ahern
2018-02-26 15:44 ` Serhey Popovych
2018-02-26 16:07 ` Serhey Popovych
2018-02-26 18:06 ` Stephen Hemminger
2018-02-26 18:20 ` Serhey Popovych
2018-02-26 18:27 ` David Ahern
2018-02-26 18:38 ` Serhey Popovych
2018-02-26 20:09 ` Serhey Popovych
2018-02-26 21:35 ` Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1519304526-18848-5-git-send-email-serhe.popovych@gmail.com \
--to=serhe.popovych@gmail.com \
--cc=dsahern@gmail.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).