From: "Bastien Curutchet (eBPF Foundation)" bastien.curutchet@bootlin.com Date: Wed, 12 Feb 2025 09:23:47 +0100
rtnl_net_cmp_locks() always returns -1 if CONFIG_DEBUG_NET_SMALL_RTNL is disabled. However, if CONFIG_DEBUG_NET_SMALL_RTNL is enabled, it returns 0 when both inputs are equal. It is then used by rtnl_nets_add() to call put_net() if the net to be added is already present in the struct rtnl_nets. As a result, when rtnl_nets_add() is called on an already present net, put_net() is called only if DEBUG is on.
If CONFIG_DEBUG_NET_SMALL_RTNL is disabled, every duplicate net is added to rtnl_nets, so put_net() is expected to be called for each in rtnl_nets_destroy().