1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-06 13:17:44 +03:00

network-generator: vlan= can be specified multiple times

(cherry picked from commit 9eee6b1b3f00d46459eebefb70be50ea6af30ddb)
(cherry picked from commit f3baba94425e6ccaf7a672903148dbb2b9e022f7)
(cherry picked from commit be571ff648)
This commit is contained in:
Yu Watanabe 2024-08-07 15:03:59 +09:00 committed by Luca Boccassi
parent 9681d9ce1d
commit ca169c9e8b
3 changed files with 7 additions and 6 deletions

View File

@ -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);

View File

@ -61,7 +61,7 @@ struct Network {
/* [Network] */
DHCPType dhcp_type;
char **dns;
char *vlan;
char **vlan;
char *bridge;
char *bond;

View File

@ -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"
);