aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/route.c
diff options
context:
space:
mode:
authorJulian Anastasov <ja@ssi.bg>2012-11-22 16:04:14 -0500
committerDavid S. Miller <davem@davemloft.net>2012-11-22 16:06:49 -0500
commit636174219b52b5a8bc51bc23bbcba97cd30a65e3 (patch)
treec2409e04422664285fe2a6774885d3d049d5d540 /net/ipv4/route.c
parent84ec95b047d2d02552f07c06d9d6da8b61532090 (diff)
ipv4: do not cache looped multicasts
Starting from 3.6 we cache output routes for multicasts only when using route to 224/4. For local receivers we can set RTCF_LOCAL flag depending on the membership but in such case we use maddr and saddr which are not caching keys as before. Additionally, we can not use same place to cache routes that differ in RTCF_LOCAL flag value. Fix it by caching only RTCF_MULTICAST entries without RTCF_LOCAL (send-only, no loopback). As a side effect, we avoid unneeded lookup for fnhe when not caching because multicasts are not redirected and they do not learn PMTU. Thanks to Maxime Bizon for showing the caching problems in __mkroute_output for 3.6 kernels: different RTCF_LOCAL flag in cache can lead to wrong ip_mc_output or ip_output call and the visible problem is that traffic can not reach local receivers via loopback. Reported-by: Maxime Bizon <mbizon@freebox.fr> Tested-by: Maxime Bizon <mbizon@freebox.fr> Signed-off-by: Julian Anastasov <ja@ssi.bg> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/route.c')
-rw-r--r--net/ipv4/route.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 200d287e49f5..df251424d816 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1785,6 +1785,7 @@ static struct rtable *__mkroute_output(const struct fib_result *res,
1785 if (dev_out->flags & IFF_LOOPBACK) 1785 if (dev_out->flags & IFF_LOOPBACK)
1786 flags |= RTCF_LOCAL; 1786 flags |= RTCF_LOCAL;
1787 1787
1788 do_cache = true;
1788 if (type == RTN_BROADCAST) { 1789 if (type == RTN_BROADCAST) {
1789 flags |= RTCF_BROADCAST | RTCF_LOCAL; 1790 flags |= RTCF_BROADCAST | RTCF_LOCAL;
1790 fi = NULL; 1791 fi = NULL;
@@ -1793,6 +1794,8 @@ static struct rtable *__mkroute_output(const struct fib_result *res,
1793 if (!ip_check_mc_rcu(in_dev, fl4->daddr, fl4->saddr, 1794 if (!ip_check_mc_rcu(in_dev, fl4->daddr, fl4->saddr,
1794 fl4->flowi4_proto)) 1795 fl4->flowi4_proto))
1795 flags &= ~RTCF_LOCAL; 1796 flags &= ~RTCF_LOCAL;
1797 else
1798 do_cache = false;
1796 /* If multicast route do not exist use 1799 /* If multicast route do not exist use
1797 * default one, but do not gateway in this case. 1800 * default one, but do not gateway in this case.
1798 * Yes, it is hack. 1801 * Yes, it is hack.
@@ -1802,8 +1805,8 @@ static struct rtable *__mkroute_output(const struct fib_result *res,
1802 } 1805 }
1803 1806
1804 fnhe = NULL; 1807 fnhe = NULL;
1805 do_cache = fi != NULL; 1808 do_cache &= fi != NULL;
1806 if (fi) { 1809 if (do_cache) {
1807 struct rtable __rcu **prth; 1810 struct rtable __rcu **prth;
1808 struct fib_nh *nh = &FIB_RES_NH(*res); 1811 struct fib_nh *nh = &FIB_RES_NH(*res);
1809 1812