]> git.ipfire.org Git - thirdparty/iproute2.git/commit
Really fix get_addr() and get_prefix() error messages
authorPhil Sutter <phil@nwl.cc>
Tue, 1 Aug 2017 16:36:11 +0000 (18:36 +0200)
committerStephen Hemminger <stephen@networkplumber.org>
Thu, 3 Aug 2017 23:01:03 +0000 (16:01 -0700)
commit34705c807a38909247d1bb29ccdffe42e5c1dab3
treeba64e998044b92bd57bf6b54098f54c71e46e6c0
parentcc21ebe8431477a40bc6fdfbd61cefd826aa7e8b
Really fix get_addr() and get_prefix() error messages

Both functions take the desired address family as a parameter. So using
that to notify the user what address family was expected is correct,
unlike using dst->family which will tell the user only what address
family was specified.

The situation which commit 334af76143368 tried to fix was when 'ip'
would accept addresses from multiple families. In that case, the family
parameter is set to AF_UNSPEC so that get_addr_1() may accept any valid
address.

This patch introduces a wrapper around family_name() which returns the
string "any valid" for AF_UNSPEC instead of the three question marks
unsuitable for use in error messages.

Tests for AF_UNSPEC:

| # ip a a 256.10.166.1/24 dev d0
| Error: any valid prefix is expected rather than "256.10.166.1/24".

| # ip neighbor add proxy 2001:db8::g dev d0
| Error: any valid address is expected rather than "2001:db8::g".

Tests for explicit address family:

| # ip -6 addrlabel add prefix 1.1.1.1/24 label 123
| Error: inet6 prefix is expected rather than "1.1.1.1/24".

| # ip -4 addrlabel add prefix dead:beef::1/24 label 123
| Error: inet prefix is expected rather than "dead:beef::1/24".

Reported-by: Jaroslav Aster <jaster@redhat.com>
Fixes: 334af76143368 ("fix get_addr() and get_prefix() error messages")
Signed-off-by: Phil Sutter <phil@nwl.cc>
lib/utils.c