]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
fix get_addr() and get_prefix() error messages
authorMarco Varlese <marco.varlese@intel.com>
Sun, 27 Mar 2016 17:45:51 +0000 (10:45 -0700)
committerStephen Hemminger <stephen@networkplumber.org>
Sun, 27 Mar 2016 17:47:02 +0000 (10:47 -0700)
An attempt to add invalid address to interface would print "???" string
instead of the address family name.

For example:
$ ip address add 256.10.166.1/24 dev ens8
Error: ??? prefix is expected rather than "256.10.166.1/24".

$ ip neighbor add proxy 2001:db8::g dev ens8
Error: ??? address is expected rather than "2001:db8::g".

With this patch the output will look like:
$ ip address add 256.10.166.1/24 dev ens8
Error: inet prefix is expected rather than "256.10.166.1/24".

$ ip neighbor add proxy 2001:db8::g dev ens8
Error: inet6 address is expected rather than "2001:db8::g".

Signed-off-by: Przemyslaw Szczerbik <przemyslawx.szczerbik@intel.com>
Signed-off-by: Marco Varlese <marco.varlese@intel.com>
lib/utils.c

index 9b303a6b096bcbe96af6545f615a72cf6d657857..bd5842730147faa2638b7efa6b7f23a40571cf7b 100644 (file)
@@ -567,7 +567,7 @@ int get_addr(inet_prefix *dst, const char *arg, int family)
 {
        if (get_addr_1(dst, arg, family)) {
                fprintf(stderr, "Error: %s address is expected rather than \"%s\".\n",
-                               family_name(family) ,arg);
+                               family_name(dst->family) ,arg);
                exit(1);
        }
        return 0;
@@ -579,9 +579,10 @@ int get_prefix(inet_prefix *dst, char *arg, int family)
                fprintf(stderr, "Error: \"%s\" may be inet prefix, but it is not allowed in this context.\n", arg);
                exit(1);
        }
+
        if (get_prefix_1(dst, arg, family)) {
                fprintf(stderr, "Error: %s prefix is expected rather than \"%s\".\n",
-                               family_name(family) ,arg);
+                               family_name(dst->family) ,arg);
                exit(1);
        }
        return 0;