From: Hangbin Liu <liuhangbin@gmail.com>
To: netdev@vger.kernel.org
Cc: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>,
Stephen Hemminger <stephen@networkplumber.org>,
Phil Sutter <phil@nwl.cc>, Hangbin Liu <liuhangbin@gmail.com>
Subject: [PATCHv2 iproute2] utils: return default family when rtm_family is not RTNL_FAMILY_IPMR/IP6MR
Date: Thu, 27 Jul 2017 17:44:15 +0800 [thread overview]
Message-ID: <1501148655-32629-1-git-send-email-liuhangbin@gmail.com> (raw)
In-Reply-To: <1501146109-30032-1-git-send-email-liuhangbin@gmail.com>
When we get a multicast route, the rtm_type is RTN_MULTICAST, but the
rtm_family may be AF_INET. If we only check the type with RTNL_FAMILY_IPMR,
we will get malformed address. e.g.
+ ip -4 route add multicast 172.111.1.1 dev em1 table main
Before fix:
+ ip route list type multicast table main
multicast ac6f:101:800:400:400:0:3c00:0 dev em1 scope link
After fix:
+ ip route list type multicast table main
multicast 172.111.1.1 dev em1 scope link
Fixes: 56e3eb4c3400 ("ip: route: fix multicast route dumps")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
lib/utils.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/lib/utils.c b/lib/utils.c
index e77bd30..9aa3219 100644
--- a/lib/utils.c
+++ b/lib/utils.c
@@ -1215,5 +1215,11 @@ int get_real_family(int rtm_type, int rtm_family)
if (rtm_type != RTN_MULTICAST)
return rtm_family;
- return rtm_family == RTNL_FAMILY_IPMR ? AF_INET : AF_INET6;
+ if (rtm_family == RTNL_FAMILY_IPMR)
+ return AF_INET;
+
+ if (rtm_family == RTNL_FAMILY_IP6MR)
+ return AF_INET6;
+
+ return rtm_family;
}
--
2.5.5
next prev parent reply other threads:[~2017-07-27 9:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-27 9:01 [PATCH iproute2] utils: also check AF_INET family when rtm_type is RTN_MULTICAST Hangbin Liu
2017-07-27 9:11 ` Phil Sutter
2017-07-27 9:44 ` Hangbin Liu [this message]
2017-07-27 10:03 ` [PATCHv2 iproute2] utils: return default family when rtm_family is not RTNL_FAMILY_IPMR/IP6MR Phil Sutter
2017-07-27 18:28 ` Stephen Hemminger
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=1501148655-32629-1-git-send-email-liuhangbin@gmail.com \
--to=liuhangbin@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=nikolay@cumulusnetworks.com \
--cc=phil@nwl.cc \
--cc=stephen@networkplumber.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;
as well as URLs for NNTP newsgroup(s).