naccyde / rpms / iproute

Forked from rpms/iproute 7 months ago
Clone

Blame SOURCES/0015-utils-return-default-family-when-rtm_family-is-not-R.patch

36cfb7
From 420957e4c56f65703c6f2f24da0ea35c6b7bbcda Mon Sep 17 00:00:00 2001
36cfb7
From: Stefano Brivio <sbrivio@redhat.com>
36cfb7
Date: Thu, 27 Jul 2017 21:52:30 +0200
36cfb7
Subject: [PATCH] utils: return default family when rtm_family is not
36cfb7
 RTNL_FAMILY_IPMR/IP6MR
36cfb7
36cfb7
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1475762
36cfb7
Upstream Status: iproute2.git commit 5ce897a03bfd
36cfb7
36cfb7
commit 5ce897a03bfda76dc66dc1acfa014fc0e3d3022a
36cfb7
Author: Hangbin Liu <liuhangbin@gmail.com>
36cfb7
Date:   Thu Jul 27 17:44:15 2017 +0800
36cfb7
36cfb7
    utils: return default family when rtm_family is not RTNL_FAMILY_IPMR/IP6MR
36cfb7
36cfb7
    When we get a multicast route, the rtm_type is RTN_MULTICAST, but the
36cfb7
    rtm_family may be AF_INET. If we only check the type with RTNL_FAMILY_IPMR,
36cfb7
    we will get malformed address. e.g.
36cfb7
36cfb7
    + ip -4 route add multicast 172.111.1.1 dev em1 table main
36cfb7
36cfb7
    Before fix:
36cfb7
    + ip route list type multicast table main
36cfb7
    multicast ac6f:101:800:400:400:0:3c00:0 dev em1 scope link
36cfb7
36cfb7
    After fix:
36cfb7
    + ip route list type multicast table main
36cfb7
    multicast 172.111.1.1 dev em1 scope link
36cfb7
36cfb7
    Fixes: 56e3eb4c3400 ("ip: route: fix multicast route dumps")
36cfb7
    Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
36cfb7
    Acked-by: Phil Sutter <phil@nwl.cc>
36cfb7
36cfb7
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
36cfb7
---
36cfb7
 lib/utils.c | 8 +++++++-
36cfb7
 1 file changed, 7 insertions(+), 1 deletion(-)
36cfb7
36cfb7
diff --git a/lib/utils.c b/lib/utils.c
e138d9
index 7d6ee53ad938d..9f55391d3c1ea 100644
36cfb7
--- a/lib/utils.c
36cfb7
+++ b/lib/utils.c
36cfb7
@@ -1219,5 +1219,11 @@ int get_real_family(int rtm_type, int rtm_family)
36cfb7
 	if (rtm_type != RTN_MULTICAST)
36cfb7
 		return rtm_family;
36cfb7
 
36cfb7
-	return rtm_family == RTNL_FAMILY_IPMR ? AF_INET : AF_INET6;
36cfb7
+	if (rtm_family == RTNL_FAMILY_IPMR)
36cfb7
+		return AF_INET;
36cfb7
+
36cfb7
+	if (rtm_family == RTNL_FAMILY_IP6MR)
36cfb7
+		return AF_INET6;
36cfb7
+
36cfb7
+	return rtm_family;
36cfb7
 }
36cfb7
-- 
e138d9
2.21.0
36cfb7