From: Varun Chandramohan <varunc@linux.vnet.ibm.com>
To: shemminger@linux-foundation.org
Cc: netdev@vger.kernel.org
Subject: [PATCH] Display Correct Error For Addrlabel Info
Date: Mon, 2 Jun 2008 13:55:56 +0530 [thread overview]
Message-ID: <20080602135556.0f4bc82a.varunc@linux.vnet.ibm.com> (raw)
Hi Stephen,
The command "ip addrlabel add/del" displays incorrect error message when provided with insufficient inputs. This patch fixes it in par with "ip addr add/del".
Currently:
# ./ip addrlabel add
RTNETLINK answers: Numerical result out of range
# ./ip addr add
Not enough information: "dev" argument is required.
After patch:
# ./ip addrlabel add
Not enough information: "prefix" argument is required.
Signed-off-by: Varun Chandramohan <varunc@linux.vnet.ibm.com>
---
ip/ipaddrlabel.c | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/ip/ipaddrlabel.c b/ip/ipaddrlabel.c
index a4cdece..cf438d6 100644
--- a/ip/ipaddrlabel.c
+++ b/ip/ipaddrlabel.c
@@ -139,6 +139,8 @@ static int ipaddrlabel_modify(int cmd, int argc, char **argv)
inet_prefix prefix;
uint32_t label = 0xffffffffUL;
+ char *p = NULL;
+ char *l = NULL;
memset(&req, 0, sizeof(req));
memset(&prefix, 0, sizeof(prefix));
@@ -157,6 +159,7 @@ static int ipaddrlabel_modify(int cmd, int argc, char **argv)
while (argc > 0) {
if (strcmp(*argv, "prefix") == 0) {
NEXT_ARG();
+ p = *argv;
get_prefix(&prefix, *argv, preferred_family);
} else if (strcmp(*argv, "dev") == 0) {
NEXT_ARG();
@@ -164,13 +167,21 @@ static int ipaddrlabel_modify(int cmd, int argc, char **argv)
invarg("dev is invalid\n", *argv);
} else if (strcmp(*argv, "label") == 0) {
NEXT_ARG();
+ l = *argv;
if (get_u32(&label, *argv, 0) || label == 0xffffffffUL)
invarg("label is invalid\n", *argv);
}
argc--;
argv++;
}
-
+ if (p == NULL) {
+ fprintf(stderr, "Not enough information: \"prefix\" argument is required.\n");
+ return -1;
+ }
+ if (l == NULL) {
+ fprintf(stderr, "Not enough information: \"label\" argument is required.\n");
+ return -1;
+ }
addattr32(&req.n, sizeof(req), IFAL_LABEL, label);
addattr_l(&req.n, sizeof(req), IFAL_ADDRESS, &prefix.data, prefix.bytelen);
req.ifal.ifal_prefixlen = prefix.bitlen;
--
1.5.0.6
reply other threads:[~2008-06-02 8:26 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20080602135556.0f4bc82a.varunc@linux.vnet.ibm.com \
--to=varunc@linux.vnet.ibm.com \
--cc=netdev@vger.kernel.org \
--cc=shemminger@linux-foundation.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).