vps_net_ctl(), vps_{add,del}_ip(): refactor and fix

Here is the current (before this patch) code flow of setting up venet0 IPs:

1. vps_setup_res() calls
	vps_net_ctl(DEL, del_res.net)
   and then
	vps_net_ctl(ADD, res.net)

2. vps_net_ctl(DEL) calls vps_del_ip() to remove explicitly specified
   IPs from the host, then calls *del_ip.sh distscript with
   IPDELALL=yes set to remove all IPs from inside the container.

3. vps_net_ctl(ADD) checks if net->delall is set to YES, and calls either
   vps_add_ip() or vps_set_ip(). The difference is vps_set_ip() first
   gets the list of currently assigned IP and removes all of those, and
   then adds new IPs, while vps_add_ip() just adds new IPs.

Now, commit bc2afdd0 checks that there are no IPs to add on an ADD stage,
and skips running vps_set_ip(), therefore leaving old IPs on the host.

This commit tries to untangle this twisted logic and fix the bug introduced
by the above mentioned commit. What it does is:

1. vps_del_ip() takes care of removing IP addresses, not only the one
   specified explicitly, but also (if --ipdel all is specified) all the
   the exising ones (they are just added to the list of IPs to delete).

2. vps_set_ip() is no longer needed since IP deletion is already taken
   care of.

I hope it's less of a mess this way. The only side effect is there was
a rollback in vps_set_ip() to re-add old IPs if new ones were failed to
add -- now there's no rollback.

While at it, enhance the "Deleting IP" log message to say "all" if we're
about to delete all IPs.

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
1 file changed