mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
lxc: Initializing IPv6 and IPv4 gateway to overwrite old settings.
This commit fixes a bug when you have multiple network settings defined. Basically, if you set an IPv6 or IPv4 gateway, it carries on next network settings. It is happening because the data is not being initialized when a new network type is defined. So, the old data still persists into the pointer. Another way to initialized the data was introduced using memset() to avoid missing attributes from the struct. Signed-off-by: Julio Faracco <jcfaracco@gmail.com> Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
34eca98522
commit
53762677a8
@ -561,27 +561,26 @@ lxcNetworkWalkCallback(const char *name, virConfValuePtr value, void *data)
|
||||
int status;
|
||||
|
||||
if (STREQ(name, "lxc.network.type")) {
|
||||
virDomainDefPtr def = parseData->def;
|
||||
size_t networks = parseData->networks;
|
||||
bool privnet = parseData->privnet;
|
||||
|
||||
/* Store the previous NIC */
|
||||
status = lxcAddNetworkDefinition(parseData);
|
||||
|
||||
if (status < 0)
|
||||
return -1;
|
||||
else if (status > 0)
|
||||
parseData->networks++;
|
||||
networks++;
|
||||
else if (parseData->type != NULL && STREQ(parseData->type, "none"))
|
||||
parseData->privnet = false;
|
||||
privnet = false;
|
||||
|
||||
/* Start a new network interface config */
|
||||
parseData->type = NULL;
|
||||
parseData->link = NULL;
|
||||
parseData->mac = NULL;
|
||||
parseData->flag = NULL;
|
||||
parseData->macvlanmode = NULL;
|
||||
parseData->vlanid = NULL;
|
||||
parseData->name = NULL;
|
||||
/* clean NIC to store a new one */
|
||||
memset(parseData, 0, sizeof(*parseData));
|
||||
|
||||
parseData->ips = NULL;
|
||||
parseData->nips = 0;
|
||||
parseData->def = def;
|
||||
parseData->networks = networks;
|
||||
parseData->privnet = privnet;
|
||||
|
||||
/* Keep the new value */
|
||||
parseData->type = value->str;
|
||||
|
Loading…
Reference in New Issue
Block a user