From: David Ahern <dsahern@kernel.org>
To: netdev@vger.kernel.org
Cc: stephen@networkplumber.org, David Ahern <dsahern@gmail.com>
Subject: [PATCH iproute2] ip rule: Require at least one argument for add
Date: Tue, 30 Oct 2018 13:59:05 -0700 [thread overview]
Message-ID: <20181030205905.14209-1-dsahern@kernel.org> (raw)
From: David Ahern <dsahern@gmail.com>
'ip rule add' with no additional arguments just adds another rule
for the main table - which exists by default. Require at least
1 argument similar to delete.
Signed-off-by: David Ahern <dsahern@gmail.com>
---
ip/iprule.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/ip/iprule.c b/ip/iprule.c
index d89d808d8909..b465a80785b1 100644
--- a/ip/iprule.c
+++ b/ip/iprule.c
@@ -691,6 +691,11 @@ static int iprule_modify(int cmd, int argc, char **argv)
};
if (cmd == RTM_NEWRULE) {
+ if (argc == 0) {
+ fprintf(stderr,
+ "\"ip rule add\" requires arguments.\n");
+ return -1;
+ }
req.n.nlmsg_flags |= NLM_F_CREATE|NLM_F_EXCL;
req.frh.action = FR_ACT_TO_TBL;
}
--
2.11.0
next reply other threads:[~2018-10-31 5:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-30 20:59 David Ahern [this message]
2018-11-01 19:54 ` [PATCH iproute2] ip rule: Require at least one argument for add 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=20181030205905.14209-1-dsahern@kernel.org \
--to=dsahern@kernel.org \
--cc=dsahern@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.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).