]> git.baikalelectronics.ru Git - kernel.git/commit
ipv6: Always allocate pcpu memory in a fib6_nh
authorDavid Ahern <dsahern@gmail.com>
Tue, 4 Jun 2019 01:37:03 +0000 (18:37 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 4 Jun 2019 21:54:59 +0000 (14:54 -0700)
commited8e301b9e9f961ad1f88c25ae576d1882665850
tree5bff6411e8583d321fe845eeebd122b4f7dd794e
parentdada1394006fdf32f1c02e7fd2cbbb84c6a6a296
ipv6: Always allocate pcpu memory in a fib6_nh

A recent commit had an unintended side effect with reject routes:
rt6i_pcpu is expected to always be initialized for all fib6_info except
the null entry. The commit mentioned below skips it for reject routes
and ends up leaking references to the loopback device. For example,

    ip netns add foo
    ip -netns foo li set lo up
    ip -netns foo -6 ro add blackhole 2001:db8:1::1
    ip netns exec foo ping6 2001:db8:1::1
    ip netns del foo

ends up spewing:
    unregister_netdevice: waiting for lo to become free. Usage count = 3

The fib_nh_common_init is not needed for reject routes (no ipv4 caching
or encaps), so move the alloc_percpu_gfp after it and adjust the goto label.

Fixes: 5734354a2c6e ("ipv6: Move pcpu cached routes to fib6_nh")
Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv6/route.c