[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20080602135556.0f4bc82a.varunc@linux.vnet.ibm.com>
Date: Mon, 2 Jun 2008 13:55:56 +0530
From: Varun Chandramohan <varunc@...ux.vnet.ibm.com>
To: shemminger@...ux-foundation.org
Cc: netdev@...r.kernel.org
Subject: [PATCH] Display Correct Error For Addrlabel Info
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@...ux.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
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists