提交 daa11cc8 编写于 作者: X Xin Long 提交者: Greg Kroah-Hartman

ipv4: not do cache for local delivery if bc_forwarding is enabled

[ Upstream commit 0a90478b93a46bdcd56ba33c37566a993e455d54 ]

With the topo:

    h1 ---| rp1            |
          |     route  rp3 |--- h3 (192.168.200.1)
    h2 ---| rp2            |

If rp1 bc_forwarding is set while rp2 bc_forwarding is not, after
doing "ping 192.168.200.255" on h1, then ping 192.168.200.255 on
h2, and the packets can still be forwared.

This issue was caused by the input route cache. It should only do
the cache for either bc forwarding or local delivery. Otherwise,
local delivery can use the route cache for bc forwarding of other
interfaces.

This patch is to fix it by not doing cache for local delivery if
all.bc_forwarding is enabled.

Note that we don't fix it by checking route cache local flag after
rt_cache_valid() in "local_input:" and "ip_mkroute_input", as the
common route code shouldn't be touched for bc_forwarding.

Fixes: 5cbf777c ("route: add support for directed broadcast forwarding")
Reported-by: NJianlin Shi <jishi@redhat.com>
Signed-off-by: NXin Long <lucien.xin@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 05b933f2
...@@ -1960,7 +1960,7 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr, ...@@ -1960,7 +1960,7 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
u32 itag = 0; u32 itag = 0;
struct rtable *rth; struct rtable *rth;
struct flowi4 fl4; struct flowi4 fl4;
bool do_cache; bool do_cache = true;
/* IP on this device is disabled. */ /* IP on this device is disabled. */
...@@ -2037,6 +2037,9 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr, ...@@ -2037,6 +2037,9 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
if (res->type == RTN_BROADCAST) { if (res->type == RTN_BROADCAST) {
if (IN_DEV_BFORWARD(in_dev)) if (IN_DEV_BFORWARD(in_dev))
goto make_route; goto make_route;
/* not do cache if bc_forwarding is enabled */
if (IPV4_DEVCONF_ALL(net, BC_FORWARDING))
do_cache = false;
goto brd_input; goto brd_input;
} }
...@@ -2074,17 +2077,14 @@ out: return err; ...@@ -2074,17 +2077,14 @@ out: return err;
RT_CACHE_STAT_INC(in_brd); RT_CACHE_STAT_INC(in_brd);
local_input: local_input:
do_cache = false; do_cache &= res->fi && !itag;
if (res->fi) { if (do_cache) {
if (!itag) {
rth = rcu_dereference(FIB_RES_NH(*res).nh_rth_input); rth = rcu_dereference(FIB_RES_NH(*res).nh_rth_input);
if (rt_cache_valid(rth)) { if (rt_cache_valid(rth)) {
skb_dst_set_noref(skb, &rth->dst); skb_dst_set_noref(skb, &rth->dst);
err = 0; err = 0;
goto out; goto out;
} }
do_cache = true;
}
} }
rth = rt_dst_alloc(l3mdev_master_dev_rcu(dev) ? : net->loopback_dev, rth = rt_dst_alloc(l3mdev_master_dev_rcu(dev) ? : net->loopback_dev,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册