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.szczer...@intel.com>
Signed-off-by: Marco Varlese <marco.varl...@intel.com>
---
lib/utils.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/utils.c b/lib/utils.c
index fa35f4d..4820de1 100644
--- a/lib/utils.c
+++ b/lib/utils.c
@@ -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;
@@ -581,7 +581,7 @@ int get_prefix(inet_prefix *dst, char *arg, int family)
        }
        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;
--
2.5.0

Reply via email to