netfilter: ipvs: fix dst leak in __ip_vs_addr_is_local_v6
After call to ip6_route_output() we must release dst or we leak it. Also should test dst->error, as ip6_route_output() never returns NULL. Use boolean while we are at it. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
This commit is contained in:
parent
ef5b6e1277
commit
c24584c028
@ -76,19 +76,19 @@ static void __ip_vs_del_service(struct ip_vs_service *svc);
|
|||||||
|
|
||||||
#ifdef CONFIG_IP_VS_IPV6
|
#ifdef CONFIG_IP_VS_IPV6
|
||||||
/* Taken from rt6_fill_node() in net/ipv6/route.c, is there a better way? */
|
/* Taken from rt6_fill_node() in net/ipv6/route.c, is there a better way? */
|
||||||
static int __ip_vs_addr_is_local_v6(struct net *net,
|
static bool __ip_vs_addr_is_local_v6(struct net *net,
|
||||||
const struct in6_addr *addr)
|
const struct in6_addr *addr)
|
||||||
{
|
{
|
||||||
struct rt6_info *rt;
|
|
||||||
struct flowi6 fl6 = {
|
struct flowi6 fl6 = {
|
||||||
.daddr = *addr,
|
.daddr = *addr,
|
||||||
};
|
};
|
||||||
|
struct dst_entry *dst = ip6_route_output(net, NULL, &fl6);
|
||||||
|
bool is_local;
|
||||||
|
|
||||||
rt = (struct rt6_info *)ip6_route_output(net, NULL, &fl6);
|
is_local = !dst->error && dst->dev && (dst->dev->flags & IFF_LOOPBACK);
|
||||||
if (rt && rt->dst.dev && (rt->dst.dev->flags & IFF_LOOPBACK))
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
return 0;
|
dst_release(dst);
|
||||||
|
return is_local;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user