Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

vzctl set --ipadd: treat IPs with different masks as the same one

Introduce merge_ip_list() which is the same as merge_str_list(),
only using find_ip() instead of find_str() for checking IP addresses.
Since find_ip tries not to look at netmask (commit 0f8c652), we
will not have same IPs with different masks in the resulting list.

Also, due to commit e3d0346 new values have precedence over the
old ones, so --ipadd can be used to change the mask of the already
existing IP. Of course this is up to etc/dists/scripts/*_ip.sh
to process this in a correct fashion.

http://bugzilla.openvz.org/1088

Signed-off-by: Kir Kolyshkin <kir@openvz.org>
  • Loading branch information...
commit 30d0cf8d7618e1e2fc7b228f38da979d1b6446e9 1 parent e3d0346
@kolyshkin kolyshkin authored
Showing with 12 additions and 3 deletions.
  1. +3 −1 include/net.h
  2. +3 −2 src/lib/config.c
  3. +6 −0 src/lib/net.c
View
4 include/net.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2000-2009, Parallels, Inc. All rights reserved.
+ * Copyright (C) 2000-2011, Parallels, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -68,6 +68,8 @@ int vps_set_netdev(vps_handler *h, envid_t veid, ub_param *ub,
net_param *net_add, net_param *net_del);
char *find_ip(list_head_t *ip_h, const char *ipaddr);
+int merge_ip_list(int delall, list_head_t *old, list_head_t *add,
+ list_head_t *del, list_head_t *merged);
/** Obtain list of IP addresses belonging to the CT.
*
View
5 src/lib/config.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2000-2010, Parallels, Inc. All rights reserved.
+ * Copyright (C) 2000-2011, Parallels, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -48,6 +48,7 @@
#include "meminfo.h"
#include "vzfeatures.h"
#include "io.h"
+#include "net.h"
static int _page_size;
static int check_name(char *name);
@@ -802,7 +803,7 @@ static int store_ip(vps_param *old_p, vps_param *vps_p, vps_config *conf,
return 0;
}
list_head_init(&ip);
- merge_str_list(vps_p->res.net.delall, &old_p->res.net.ip,
+ merge_ip_list(vps_p->res.net.delall, &old_p->res.net.ip,
&vps_p->res.net.ip, &vps_p->del_res.net.ip, &ip);
ret = conf_store_strlist(conf_h, conf->name, &ip, 1);
free_str_param(&ip);
View
6 src/lib/net.c
@@ -77,6 +77,12 @@ char *find_ip(list_head_t *ip_h, const char *ipaddr)
return NULL;
}
+int merge_ip_list(int delall, list_head_t *old, list_head_t *add,
+ list_head_t *del, list_head_t *merged)
+{
+ return __merge_str_list(delall, old, add, del, merged, find_ip);
+}
+
static inline int _ip_ctl(vps_handler *h, envid_t veid, int op,
unsigned int *ip, int family)
{
Please sign in to comment.
Something went wrong with that request. Please try again.