Re: [PATCH net] ipvlan: Fix a reference count leak warning in ipvlan_ns_exit()

From: Florian Westphal
Date: Thu Aug 17 2023 - 11:15:22 EST


Lu Wei <luwei32@xxxxxxxxxx> wrote:
> There are two network devices(veth1 and veth3) in ns1, and ipvlan1 with
> L3S mode and ipvlan2 with L2 mode are created based on them as
> figure (1). In this case, ipvlan_register_nf_hook() will be called to
> register nf hook which is needed by ipvlans in L3S mode in ns1 and value
> of ipvl_nf_hook_refcnt is set to 1.

[..]

> register nf_hook in ns2 and unregister nf_hook in ns1. As a result,
> ipvl_nf_hook_refcnt in ns1 is decreased incorrectly and this in ns2
> is increased incorrectly. When the second net namespace is removed, a
> reference count leak warning in ipvlan_ns_exit() will be triggered.
>
> This patch add a check before ipvlan_migrate_l3s_hook() is called.

Reviewed-by: Florian Westphal <fw@xxxxxxxxx>