From: Serhey Popovych <serhe.popovych@gmail.com>
To: netdev@vger.kernel.org
Subject: [PATCH iproute2 1/6] utils: Always specify family for address in get_addr_1()
Date: Thu, 18 Jan 2018 20:13:42 +0200 [thread overview]
Message-ID: <1516299227-26724-2-git-send-email-serhe.popovych@gmail.com> (raw)
In-Reply-To: <1516299227-26724-1-git-send-email-serhe.popovych@gmail.com>
Set ->family correctly when string representing address
is "default", "all" or "any": get_addr_1() might be called
with AF_UNSPEC (e.g. get_addr() -> get_addr_1()).
Extend support for zero address to all address families,
not only AF_INET and AF_INET6 when one explicitly given
as @family: use af_byte_len() to correctly set address length.
Still assume AF_INET when @family is AF_UNSPEC.
Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
---
lib/utils.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/utils.c b/lib/utils.c
index 9fa5220..a023e74 100644
--- a/lib/utils.c
+++ b/lib/utils.c
@@ -543,8 +543,8 @@ int get_addr_1(inet_prefix *addr, const char *name, int family)
strcmp(name, "any") == 0) {
if ((family == AF_DECnet) || (family == AF_MPLS))
return -1;
- addr->family = family;
- addr->bytelen = (family == AF_INET6 ? 16 : 4);
+ addr->family = (family != AF_UNSPEC) ? family : AF_INET;
+ addr->bytelen = af_byte_len(addr->family);
addr->bitlen = -1;
return 0;
}
--
1.7.10.4
next prev parent reply other threads:[~2018-01-18 18:14 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-18 18:13 [PATCH iproute2 0/6] utils: Get rid of inet_get_addr() Serhey Popovych
2018-01-18 18:13 ` Serhey Popovych [this message]
2018-01-18 18:13 ` [PATCH iproute2 2/6] utils: Always specify family and ->bytelen in get_prefix_1() Serhey Popovych
2018-01-18 18:13 ` [PATCH iproute2 3/6] utils: Fast inet address classification after get_addr() Serhey Popovych
2018-01-18 18:13 ` [PATCH iproute2 4/6] iplink_geneve: Get rid of inet_get_addr() Serhey Popovych
2018-01-18 18:13 ` [PATCH iproute2 5/6] iplink_vxlan: " Serhey Popovych
2018-01-18 18:13 ` [PATCH iproute2 6/6] ip: " Serhey Popovych
2018-01-18 18:35 ` [PATCH iproute2 0/6] utils: " Stephen Hemminger
2018-01-21 18:13 ` David Ahern
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=1516299227-26724-2-git-send-email-serhe.popovych@gmail.com \
--to=serhe.popovych@gmail.com \
--cc=netdev@vger.kernel.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