diff --git a/src/network/generator/network-generator.c b/src/network/generator/network-generator.c index cf9305ea10..ce424d83e1 100644 --- a/src/network/generator/network-generator.c +++ b/src/network/generator/network-generator.c @@ -159,7 +159,7 @@ static Network *network_free(Network *network) { free(network->ifname); free(network->hostname); strv_free(network->dns); - free(network->vlan); + strv_free(network->vlan); free(network->bridge); free(network->bond); @@ -509,7 +509,7 @@ static int network_set_vlan(Context *context, const char *ifname, const char *va return r; } - return free_and_strdup(&network->vlan, value); + return strv_extend(&network->vlan, value); } static int network_set_bridge(Context *context, const char *ifname, const char *value) { @@ -1283,8 +1283,8 @@ void network_dump(Network *network, FILE *f) { STRV_FOREACH(dns, network->dns) fprintf(f, "DNS=%s\n", *dns); - if (network->vlan) - fprintf(f, "VLAN=%s\n", network->vlan); + STRV_FOREACH(v, network->vlan) + fprintf(f, "VLAN=%s\n", *v); if (network->bridge) fprintf(f, "Bridge=%s\n", network->bridge); diff --git a/src/network/generator/network-generator.h b/src/network/generator/network-generator.h index 0e0da2a57a..08e6ac9c1a 100644 --- a/src/network/generator/network-generator.h +++ b/src/network/generator/network-generator.h @@ -61,7 +61,7 @@ struct Network { /* [Network] */ DHCPType dhcp_type; char **dns; - char *vlan; + char **vlan; char *bridge; char *bond; diff --git a/src/network/generator/test-network-generator.c b/src/network/generator/test-network-generator.c index 318b9e98c3..26a37fd4f6 100644 --- a/src/network/generator/test-network-generator.c +++ b/src/network/generator/test-network-generator.c @@ -280,12 +280,13 @@ int main(int argc, char *argv[]) { "UseDNS=yes\n" ); - test_network_one("eth0", "vlan", "vlan99:eth0", + test_network_two("eth0", "vlan", "vlan99:eth0", "vlan", "vlan98:eth0", "[Match]\n" "Name=eth0\n" "\n[Link]\n" "\n[Network]\n" "VLAN=vlan99\n" + "VLAN=vlan98\n" "\n[DHCP]\n" );