From: Hangbin Liu <hidden> Date: 2017-07-27 09:02:20
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 <redacted>
---
lib/utils.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
@@ -1215,5 +1215,6 @@ int get_real_family(int rtm_type, int rtm_family)if(rtm_type!=RTN_MULTICAST)returnrtm_family;-returnrtm_family==RTNL_FAMILY_IPMR?AF_INET:AF_INET6;+return(rtm_family==RTNL_FAMILY_IPMR||+rtm_family==AF_INET)?AF_INET:AF_INET6;}
@@ -1215,5 +1215,6 @@ int get_real_family(int rtm_type, int rtm_family)if(rtm_type!=RTN_MULTICAST)returnrtm_family;-returnrtm_family==RTNL_FAMILY_IPMR?AF_INET:AF_INET6;+return(rtm_family==RTNL_FAMILY_IPMR||+rtm_family==AF_INET)?AF_INET:AF_INET6;}
I think this is not very readable. How about this instead:
- return rtm_family == RTNL_FAMILY_IPMR ? AF_INET : AF_INET6;
+ if (rtm_family == RTNL_FAMILY_IPMR)
+ return AF_INET;
+
+ return rtm_family;
Thanks, Phil
From: Hangbin Liu <hidden> Date: 2017-07-27 09:44:53
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 <redacted>
---
lib/utils.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
@@ -1215,5 +1215,11 @@ int get_real_family(int rtm_type, int rtm_family)if(rtm_type!=RTN_MULTICAST)returnrtm_family;-returnrtm_family==RTNL_FAMILY_IPMR?AF_INET:AF_INET6;+if(rtm_family==RTNL_FAMILY_IPMR)+returnAF_INET;++if(rtm_family==RTNL_FAMILY_IP6MR)+returnAF_INET6;++returnrtm_family;}
From: Phil Sutter <phil@nwl.cc> Date: 2017-07-27 10:03:03
On Thu, Jul 27, 2017 at 05:44:15PM +0800, Hangbin Liu wrote:
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 <redacted>
From: Stephen Hemminger <stephen@networkplumber.org> Date: 2017-07-27 18:28:47
On Thu, 27 Jul 2017 12:03:02 +0200
Phil Sutter [off-list ref] wrote:
On Thu, Jul 27, 2017 at 05:44:15PM +0800, Hangbin Liu wrote:
quoted
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 <redacted>