unregister_netdevice: waiting for lo to become free. Usage count = 8
Subsystems (3)
Hello Julian
I'm trying to fix the cleanup process when a namespace get "killed", which is a new feature for ipvs. However an old problem appears again
When there has been traffic trough ipvs where the destination is unreachable the usage count on loopback dev increases one for every packet.... I guess thats because of this rule :
# ip route list table all ... unreachable default dev lo table 0 proto kernel metric 4294967295 error -101 hoplimit 25 ...
I made a test just forwarding packets through the same container (ipvs loaded)
to an unreachable destination and that test had a balanced count i.e. it was possible to reboot the container.
Do you have an idea why this happens in the ipvs case ?
Regards
Hans Schillstrom <[email protected]>
Quoted 14 lines · Hans Schillstrom
Hello Julian
I'm trying to fix the cleanup process when a namespace get "killed", which is a new feature for ipvs. However an old problem appears again
When there has been traffic trough ipvs where the destination is unreachable the usage count on loopback dev increases one for every packet.... I guess thats because of this rule :
# ip route list table all ... unreachable default dev lo table 0 proto kernel metric 4294967295 error -101 hoplimit 25 ...
Quoted 4 lines
I made a test just forwarding packets through the same container (ipvs loaded)
to an unreachable destination and that test had a balanced count i.e. it was possible to reboot the container.Do you have an idea why this happens in the ipvs case ?
Hans. I do know that most outstanding references when you clean up a container get moved to the loopback device. So it may not originally be the loopback device itself where the reference counting is wrong.
Eric
Julian Anastasov
maintainerHello,
Quoted 7 lines · Hans Schillstrom
Hello Julian
I'm trying to fix the cleanup process when a namespace get "killed", which is a new feature for ipvs. However an old problem appears again
When there has been traffic trough ipvs where the destination is unreachable the usage count on loopback dev increases one for every packet....
What is the kernel version?
Quoted 9 lines
I guess thats because of this rule :
# ip route list table all ... unreachable default dev lo table 0 proto kernel metric 4294967295 error -101 hoplimit 25 ...I made a test just forwarding packets through the same container (ipvs loaded)
to an unreachable destination and that test had a balanced count i.e. it was possible to reboot the container.
Can you explain, what do you mean with unreachable
destination? Are you adding some rejecting route?
Quoted 1 line
Do you have an idea why this happens in the ipvs case ?
Do you see with debug level 3 the "Removing destination"
messages. Only real servers can hold dest->dst_cache reference for dev which can be a problem because the real servers are not deleted immediately - on traffic they are moved to trash list. But ip_vs_trash_cleanup() should remove any left structures. You should check in debug that all servers are deleted. If all real server structures are freed but problem remains we should look more deeply in the dest->dst_cache usage. DR or NAT is used?
I assume cleanup really happens in this order:
ip_vs_cleanup():
nf_unregister_hooks() ... ip_vs_conn_cleanup() ... ip_vs_control_cleanup()
Regards
--
Julian Anastasov <[email protected]>
Quoted 7 lines · On Friday, April 15, 2011 22:11:32 Julian Anastasov wrote:
Hello,
Quoted 2 lines · Hans Schillstrom
Hello Julian
Quoted 7 lines
Quoted 5 lines
I'm trying to fix the cleanup process when a namespace get "killed", which is a new feature for ipvs. However an old problem appears again
When there has been traffic trough ipvs where the destination is unreachable the usage count on loopback dev increases one for every packet....
What is the kernel version?
net-next-2.6 i.e. 2.6.39-rc2
Quoted 8 lines
Quoted 8 lines
I guess thats because of this rule :
# ip route list table all ... unreachable default dev lo table 0 proto kernel metric 4294967295 error -101 hoplimit 25 ...
Quoted 5 lines
Quoted 2 lines
I made a test just forwarding packets through the same container (ipvs loaded)
to an unreachable destination and that test had a balanced count i.e. it was possible to reboot the container.Can you explain, what do you mean with unreachable
destination? Are you adding some rejecting route?
This comment from Eric, do explain what happens:
"Hans.
I do know that most outstanding references when you clean up a container get moved to the loopback device. So it may not originally be the loopback device itself where the reference counting is wrong.
Eric"
Quoted 12 lines
Quoted 2 lines
Do you have an idea why this happens in the ipvs case ?
Do you see with debug level 3 the "Removing destination"
messages. Only real servers can holddest->dst_cachereference for dev which can be a problem because the real servers are not deleted immediately - on traffic they are moved to trash list. Butip_vs_trash_cleanup()should remove any left structures. You should check in debug that all servers are deleted. If all real server structures are freed but problem remains we should look more deeply in thedest->dst_cacheusage. DR or NAT is used?
I have got some wise words from Eric,
i.e. moved all ipvs register/unregister from subsys to device that solved plenty of my issues
(Thanks Eric)
I'll will post a Patch later on regarding this.
Quoted 5 lines
I assume cleanup really happens in this order:
ip_vs_cleanup():
nf_unregister_hooks()
This will not happens in a namespace since nf_unregister_hooks() is not per netns. We might need a flag but I don't think so, further test will show....
Quoted 5 lines
... ip_vs_conn_cleanup() ... ip_vs_control_cleanup()
Regards
Hans
Hello
Quoted 13 lines · On Monday, April 18, 2011 08:10:26 Hans Schillstrom wrote:
Quoted 12 lines · On Friday, April 15, 2011 22:11:32 Julian Anastasov wrote:
Hello,
Quoted 7 lines · Hans Schillstrom
Hello Julian
I'm trying to fix the cleanup process when a namespace get "killed", which is a new feature for ipvs. However an old problem appears again
When there has been traffic trough ipvs where the destination is unreachable the usage count on loopback dev increases one for every packet....
[snip]
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
Do you have an idea why this happens in the ipvs case ?
Do you see with debug level 3 the "Removing destination"
messages. Only real servers can holddest->dst_cachereference for dev which can be a problem because the real servers are not deleted immediately - on traffic they are moved to trash list.
Actually I forgot to tell there is a need for aip_vs_service_cleanup() due to above.
Do you see any drawbacks with it ?
/*
* Delete service by {netns} in the service table.
*/
static void ip_vs_service_cleanup(struct net *net)
{
unsigned hash;
struct ip_vs_service *svc, *tmp;
EnterFunction(2);
/* Check for "full" addressed entries */
for (hash = 0; hash<IP_VS_SVC_TAB_SIZE; hash++) {
write_lock_bh(&__ip_vs_svc_lock);
list_for_each_entry_safe(svc, tmp, &ip_vs_svc_table[hash],
s_list) {
if (net_eq(svc->net, net)) {
ip_vs_svc_unhash(svc);
__ip_vs_del_service(svc);
}
}
list_for_each_entry_safe(svc, tmp, &ip_vs_svc_fwm_table[hash],
f_list) {
if (net_eq(svc->net, net)) {
ip_vs_svc_unhash(svc);
__ip_vs_del_service(svc);
}
}
write_unlock_bh(&__ip_vs_svc_lock);
}
LeaveFunction(2);
}Called just after the __ip_vs_control_cleanup_sysctl()
static void __net_exit __ip_vs_control_cleanup(struct net *net)
{
struct netns_ipvs *ipvs = net_ipvs(net);
ip_vs_trash_cleanup(net);
ip_vs_stop_estimator(net, &ipvs->tot_stats);
__ip_vs_control_cleanup_sysctl(net);
ip_vs_service_cleanup(net);
proc_net_remove(net, "ip_vs_stats_percpu");
proc_net_remove(net, "ip_vs_stats");
proc_net_remove(net, "ip_vs");
free_percpu(ipvs->tot_stats.cpustats);
}Quoted 14 lines
Quoted 5 lines
But
ip_vs_trash_cleanup()should remove any left structures. You should check in debug that all servers are deleted. If all real server structures are freed but problem remains we should look more deeply in thedest->dst_cacheusage. DR or NAT is used?I have got some wise words from Eric,
i.e. moved all ipvs register/unregister from subsys to device that solved plenty of my issues
(Thanks Eric)I'll will post a Patch later on regarding this.
Quoted 1 line
Quoted 14 lines
Quoted 4 lines
I assume cleanup really happens in this order:
ip_vs_cleanup():
nf_unregister_hooks()This will not happens in a namespace since
nf_unregister_hooks()is not per netns. We might need a flag but I don't think so, further test will show....Quoted 5 lines
... ip_vs_conn_cleanup() ... ip_vs_control_cleanup()
Regards
Hans
Julian Anastasov
maintainerHello,
Quoted 3 lines · Hans Schillstrom
Actually I forgot to tell there is a need for a
ip_vs_service_cleanup()due to above.
Do you see any drawbacks with it ?
May be ip_vs_service_cleanup() should call onlyip_vs_flush(), under __ip_vs_mutex.
Quoted 31 lines
/*
* Delete service by {netns} in the service table.
*/
static voidip_vs_service_cleanup(struct net *net){ unsigned hash; struct ip_vs_service *svc, *tmp; EnterFunction(2); /* Check for "full" addressed entries */ for (hash = 0; hash<IP_VS_SVC_TAB_SIZE; hash++) { write_lock_bh(&__ip_vs_svc_lock); list_for_each_entry_safe(svc, tmp, &ip_vs_svc_table[hash], s_list) { if (net_eq(svc->net, net)) { ip_vs_svc_unhash(svc); __ip_vs_del_service(svc); } } list_for_each_entry_safe(svc, tmp, &ip_vs_svc_fwm_table[hash], f_list) { if (net_eq(svc->net, net)) { ip_vs_svc_unhash(svc); __ip_vs_del_service(svc); } } write_unlock_bh(&__ip_vs_svc_lock); } LeaveFunction(2); }
Quoted 1 line
Called just after the
__ip_vs_control_cleanup_sysctl()
Hm, no. ip_vs_service_cleanup() should be called
by ip_vs_cleanup() before or after nf_unregister_hooks(). The rule is that ip_vs_flush() should be called before ip_vs_conn_flush() because after ip_vs_flush() no more connections can be created and even if hooks are still registered the packets can not create conns in the netns. Then ip_vs_conn_flush() will remove all existing connections and ip_vs_control_cleanup() can remove all real servers with ip_vs_trash_cleanup(). I mean, per-netns calls.
Also, may be all code that was called in old
kernels by ip_vs_cleanup() should be now called by __ip_vs_cleanup(net), i.e. we can preserve the needed order of all functions but now also per-netns. For example, for ip_vs_ctl.c ip_vs_control_init() can remain as global but it should not register ipvs_control_ops. Then we
can rename __ip_vs_control_init to ip_vs_control_init_net() and to call it from __ip_vs_init(). I.e. all such files will have global function and also _init_net and _cleanup_net. Now there are many register_pernet_subsys() calls and I'm not sure we preserve the needed order for cleanup. Are the ->exit methods called in reverse order? I don't see it in ops_exit_list() and we can not rely on such registration order. I think, ip_vs_init() should call global functions as now but __ip_vs_init() and __ip_vs_cleanup() should call the _net methods in right order.
Regards
--
Julian Anastasov <[email protected]>
Quoted 11 lines · On Monday, April 18, 2011 23:12:27 Julian Anastasov wrote:
Hello,
Quoted 3 lines · Hans Schillstrom
Actually I forgot to tell there is a need for a
ip_vs_service_cleanup()due to above.
Do you see any drawbacks with it ?May be
ip_vs_service_cleanup()should call onlyip_vs_flush(), under__ip_vs_mutex.
Hmm,
I'm not sure if the IP_VS_WAIT_WHILE() in ip_vs_flush is a good idea in this case... That was why I wrote ip_vs_service_cleanup()
Quoted 34 lines
Quoted 32 lines
/*
* Delete service by {netns} in the service table.
*/
static voidip_vs_service_cleanup(struct net *net){ unsigned hash; struct ip_vs_service *svc, *tmp; EnterFunction(2); /* Check for "full" addressed entries */ for (hash = 0; hash<IP_VS_SVC_TAB_SIZE; hash++) { write_lock_bh(&__ip_vs_svc_lock); list_for_each_entry_safe(svc, tmp, &ip_vs_svc_table[hash], s_list) { if (net_eq(svc->net, net)) { ip_vs_svc_unhash(svc); __ip_vs_del_service(svc); } } list_for_each_entry_safe(svc, tmp, &ip_vs_svc_fwm_table[hash], f_list) { if (net_eq(svc->net, net)) { ip_vs_svc_unhash(svc); __ip_vs_del_service(svc); } } write_unlock_bh(&__ip_vs_svc_lock); } LeaveFunction(2); }Quoted 1 line
Called just after the
__ip_vs_control_cleanup_sysctl()
Quoted 10 lines
Hm, no.
ip_vs_service_cleanup()should be called
byip_vs_cleanup()before or afternf_unregister_hooks(). The rule is thatip_vs_flush()should be called beforeip_vs_conn_flush()because afterip_vs_flush()no more connections can be created and even if hooks are still registered the packets can not create conns in the netns. Thenip_vs_conn_flush()will remove all existing connections andip_vs_control_cleanup()can remove all real servers withip_vs_trash_cleanup(). I mean, per-netns calls.
OK I will try to do that, both with and without throttle in ip_vs_in()
Quoted 4 lines
Also, may be all code that was called in old
kernels byip_vs_cleanup()should be now called by__ip_vs_cleanup(net), i.e. we can preserve the needed order of all functions but now also per-netns. For example, for
Quoted 8 lines
ip_vs_ctl.cip_vs_control_init()can remain as global but it should not registeripvs_control_ops. Then we
can rename__ip_vs_control_inittoip_vs_control_init_net()and to call it from__ip_vs_init(). I.e. all such files will have global function and also_init_netand_cleanup_net. Now there are manyregister_pernet_subsys()calls and I'm not sure we preserve the needed order for cleanup. Are the ->exit methods called in reverse order?
Yes
Quoted 5 lines
I don't see it in
ops_exit_list()and we can not rely on such registration order. I think,ip_vs_init()should call global functions as now but__ip_vs_init()and__ip_vs_cleanup()should call the_netmethods in right order.
Exactly,
I have already done that in my next patch, and some other small changes :-)
For the ip_vs.ko there is only one register/unregister now, the schedulers still have their own. Hopefully the patch is ready to morrow
Regards
Hans
Julian Anastasov
maintainerHello,
Quoted 10 lines · Hans Schillstrom
Quoted 9 lines · On Monday, April 18, 2011 23:12:27 Julian Anastasov wrote:
Hello,
Quoted 3 lines · Hans Schillstrom
Actually I forgot to tell there is a need for a
ip_vs_service_cleanup()due to above.
Do you see any drawbacks with it ?
Quoted 6 lines
Quoted 2 lines
May be
ip_vs_service_cleanup()should call onlyip_vs_flush(), under__ip_vs_mutex.Hmm,
I'm not sure if theIP_VS_WAIT_WHILE()inip_vs_flushis a good idea in this case... That was why I wroteip_vs_service_cleanup()
IP_VS_WAIT_WHILE should be called because some
schedulers do not use locks for ->schedule, eg. WLC. They rely on svc->usecnt reference to hold the virtual service. Nothing changes now with netns. It is currently the only way to modify or delete virtual service or scheduler. Of course, __ip_vs_svc_lock is now global but we do not have a choice.
Quoted 5 lines
Quoted 3 lines
_cleanup_net. Now there are manyregister_pernet_subsys()calls and I'm not sure we preserve the needed order for cleanup. Are the ->exit methods called in reverse order?Yes
You mean, only in the planned patch, yes?
Quoted 10 lines
Quoted 5 lines
I don't see it in
ops_exit_list()and we can not rely on such registration order. I think,ip_vs_init()should call global functions as now but__ip_vs_init()and__ip_vs_cleanup()should call the_netmethods in right order.Exactly,
I have already done that in my next patch, and some other small changes :-)
For the ip_vs.ko there is only one register/unregister now, the schedulers still have their own. Hopefully the patch is ready to morrow
OK, very good.
Regards
--
Julian Anastasov <[email protected]>