mirror of
https://github.com/systemd/systemd.git
synced 2025-01-24 06:04:05 +03:00
Merge pull request #33957 from yuwata/network-generator-vlan
network-generator: fixlets for vlan interfaces
This commit is contained in:
commit
33a2307ac7
File diff suppressed because it is too large
Load Diff
@ -62,7 +62,7 @@ struct Network {
|
||||
/* [Network] */
|
||||
DHCPType dhcp_type;
|
||||
char **dns;
|
||||
char *vlan;
|
||||
char **vlan;
|
||||
char *bridge;
|
||||
char *bond;
|
||||
|
||||
@ -79,6 +79,9 @@ struct NetDev {
|
||||
char *ifname;
|
||||
char *kind;
|
||||
uint32_t mtu;
|
||||
|
||||
/* [VLAN] */
|
||||
uint16_t vlan_id;
|
||||
};
|
||||
|
||||
struct Link {
|
||||
|
@ -10,12 +10,12 @@ static void test_network_one(const char *ifname, const char *key, const char *va
|
||||
_cleanup_free_ char *output = NULL;
|
||||
Network *network;
|
||||
|
||||
printf("# %s=%s\n", key, value);
|
||||
assert_se(parse_cmdline_item(key, value, &context) >= 0);
|
||||
assert_se(network = network_get(&context, ifname));
|
||||
assert_se(network_format(network, &output) >= 0);
|
||||
puts(output);
|
||||
assert_se(streq(output, expected));
|
||||
log_debug("/* %s(%s=%s) */", __func__, key, value);
|
||||
|
||||
ASSERT_OK(parse_cmdline_item(key, value, &context));
|
||||
ASSERT_NOT_NULL(network = network_get(&context, ifname));
|
||||
ASSERT_OK(network_format(network, &output));
|
||||
ASSERT_STREQ(output, expected);
|
||||
}
|
||||
|
||||
static void test_network_two(const char *ifname,
|
||||
@ -26,15 +26,14 @@ static void test_network_two(const char *ifname,
|
||||
_cleanup_free_ char *output = NULL;
|
||||
Network *network;
|
||||
|
||||
printf("# %s=%s\n", key1, value1);
|
||||
printf("# %s=%s\n", key2, value2);
|
||||
assert_se(parse_cmdline_item(key1, value1, &context) >= 0);
|
||||
assert_se(parse_cmdline_item(key2, value2, &context) >= 0);
|
||||
assert_se(context_merge_networks(&context) >= 0);
|
||||
assert_se(network = network_get(&context, ifname));
|
||||
assert_se(network_format(network, &output) >= 0);
|
||||
puts(output);
|
||||
assert_se(streq(output, expected));
|
||||
log_debug("/* %s(%s=%s, %s=%s) */", __func__, key1, value1, key2, value2);
|
||||
|
||||
ASSERT_OK(parse_cmdline_item(key1, value1, &context));
|
||||
ASSERT_OK(parse_cmdline_item(key2, value2, &context));
|
||||
ASSERT_OK(context_merge_networks(&context));
|
||||
ASSERT_NOT_NULL(network = network_get(&context, ifname));
|
||||
ASSERT_OK(network_format(network, &output));
|
||||
ASSERT_STREQ(output, expected);
|
||||
}
|
||||
|
||||
static void test_netdev_one(const char *ifname, const char *key, const char *value, const char *expected) {
|
||||
@ -42,12 +41,12 @@ static void test_netdev_one(const char *ifname, const char *key, const char *val
|
||||
_cleanup_free_ char *output = NULL;
|
||||
NetDev *netdev;
|
||||
|
||||
printf("# %s=%s\n", key, value);
|
||||
assert_se(parse_cmdline_item(key, value, &context) >= 0);
|
||||
assert_se(netdev = netdev_get(&context, ifname));
|
||||
assert_se(netdev_format(netdev, &output) >= 0);
|
||||
puts(output);
|
||||
assert_se(streq(output, expected));
|
||||
log_debug("/* %s(%s=%s) */", __func__, key, value);
|
||||
|
||||
ASSERT_OK(parse_cmdline_item(key, value, &context));
|
||||
ASSERT_NOT_NULL(netdev = netdev_get(&context, ifname));
|
||||
ASSERT_OK(netdev_format(netdev, &output));
|
||||
ASSERT_STREQ(output, expected);
|
||||
}
|
||||
|
||||
static void test_link_one(const char *filename, const char *key, const char *value, const char *expected) {
|
||||
@ -55,12 +54,12 @@ static void test_link_one(const char *filename, const char *key, const char *val
|
||||
_cleanup_free_ char *output = NULL;
|
||||
Link *link;
|
||||
|
||||
printf("# %s=%s\n", key, value);
|
||||
assert_se(parse_cmdline_item(key, value, &context) >= 0);
|
||||
assert_se(link = link_get(&context, filename));
|
||||
assert_se(link_format(link, &output) >= 0);
|
||||
puts(output);
|
||||
assert_se(streq(output, expected));
|
||||
log_debug("/* %s(%s=%s) */", __func__, key, value);
|
||||
|
||||
ASSERT_OK(parse_cmdline_item(key, value, &context));
|
||||
ASSERT_NOT_NULL(link = link_get(&context, filename));
|
||||
ASSERT_OK(link_format(link, &output));
|
||||
ASSERT_STREQ(output, expected);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
@ -106,6 +105,21 @@ int main(int argc, char *argv[]) {
|
||||
"\n[DHCP]\n"
|
||||
);
|
||||
|
||||
test_network_one("eth0", "ip", "10.99.37.44::10.99.10.1:255.255.0.0::eth0:off",
|
||||
"[Match]\n"
|
||||
"Name=eth0\n"
|
||||
"\n[Link]\n"
|
||||
"\n[Network]\n"
|
||||
"DHCP=no\n"
|
||||
"LinkLocalAddressing=no\n"
|
||||
"IPv6AcceptRA=no\n"
|
||||
"\n[DHCP]\n"
|
||||
"\n[Address]\n"
|
||||
"Address=10.99.37.44/16\n"
|
||||
"\n[Route]\n"
|
||||
"Gateway=10.99.10.1\n"
|
||||
);
|
||||
|
||||
test_network_one("eth0", "ip", "192.168.0.10::192.168.0.1:255.255.255.0:hogehoge:eth0:on",
|
||||
"[Match]\n"
|
||||
"Name=eth0\n"
|
||||
@ -283,12 +297,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"
|
||||
);
|
||||
|
||||
@ -328,6 +343,31 @@ int main(int argc, char *argv[]) {
|
||||
"\n[DHCP]\n"
|
||||
);
|
||||
|
||||
test_netdev_one("bridge99", "bridge", "bridge99:",
|
||||
"[NetDev]\n"
|
||||
"Kind=bridge\n"
|
||||
"Name=bridge99\n"
|
||||
);
|
||||
|
||||
test_netdev_one("bridge99", "bridge", "bridge99:,,,",
|
||||
"[NetDev]\n"
|
||||
"Kind=bridge\n"
|
||||
"Name=bridge99\n"
|
||||
);
|
||||
|
||||
test_netdev_one("bond99", "bond", "bond99:",
|
||||
"[NetDev]\n"
|
||||
"Kind=bond\n"
|
||||
"Name=bond99\n"
|
||||
);
|
||||
|
||||
test_netdev_one("bond99", "bond", "bond99::hogehoge:1530",
|
||||
"[NetDev]\n"
|
||||
"Kind=bond\n"
|
||||
"Name=bond99\n"
|
||||
"MTUBytes=1530\n"
|
||||
);
|
||||
|
||||
test_netdev_one("bond99", "bond", "bond99:eth0,eth1::1530",
|
||||
"[NetDev]\n"
|
||||
"Kind=bond\n"
|
||||
@ -335,6 +375,38 @@ int main(int argc, char *argv[]) {
|
||||
"MTUBytes=1530\n"
|
||||
);
|
||||
|
||||
test_netdev_one("vlan123", "vlan", "vlan123:eth0",
|
||||
"[NetDev]\n"
|
||||
"Kind=vlan\n"
|
||||
"Name=vlan123\n"
|
||||
"\n[VLAN]\n"
|
||||
"Id=123\n"
|
||||
);
|
||||
|
||||
test_netdev_one("vlan0013", "vlan", "vlan0013:eth0",
|
||||
"[NetDev]\n"
|
||||
"Kind=vlan\n"
|
||||
"Name=vlan0013\n"
|
||||
"\n[VLAN]\n"
|
||||
"Id=11\n" /* 0013 (octal) -> 11 */
|
||||
);
|
||||
|
||||
test_netdev_one("eth0.123", "vlan", "eth0.123:eth0",
|
||||
"[NetDev]\n"
|
||||
"Kind=vlan\n"
|
||||
"Name=eth0.123\n"
|
||||
"\n[VLAN]\n"
|
||||
"Id=123\n"
|
||||
);
|
||||
|
||||
test_netdev_one("eth0.0013", "vlan", "eth0.0013:eth0",
|
||||
"[NetDev]\n"
|
||||
"Kind=vlan\n"
|
||||
"Name=eth0.0013\n"
|
||||
"\n[VLAN]\n"
|
||||
"Id=11\n" /* 0013 (octal) -> 11 */
|
||||
);
|
||||
|
||||
test_link_one("hogehoge", "ifname", "hogehoge:00:11:22:33:44:55",
|
||||
"[Match]\n"
|
||||
"MACAddress=00:11:22:33:44:55\n"
|
||||
|
@ -261,7 +261,6 @@ COMMAND_LINES=(
|
||||
"ip=1.2.3.4:2.3.4.5:1.2.3.1:255.255.255.0:hello-world.local:dummy99:off:123"
|
||||
"ip=1.2.3.4:2.3.4.5:1.2.3.1:255.255.255.0:hello-world.local:dummy99:off:123:52:54:00:a7:8f:ac"
|
||||
"ip=1.2.3.4:2.3.4.5:1.2.3.1:255.255.255.0:hello-world.local:dummy99:off::52:54:00:a7:8f:ac"
|
||||
"ip=1.2.3.4:2.3.4.5:1.2.3.1:255.255.255.0:hello-world.local:dummy99:off::"
|
||||
"ip=1.2.3.4:2.3.4.5:1.2.3.1:255.255.255.0:hello-world.local:dummy99:off:1.2.3.2"
|
||||
"ip=1.2.3.4:2.3.4.5:1.2.3.1:255.255.255.0:hello-world.local:dummy99:off:1.2.3.2:1.2.3.3"
|
||||
"ip=192.168.0.2::192.168.0.1:255.255.128.0::foo1:off"
|
||||
@ -272,7 +271,6 @@ COMMAND_LINES=(
|
||||
"ip=[fdef:c400:bd01:1096::2]::[fdef:c400:bd01:1096::1]:64::ipv6:off:666"
|
||||
"ip=[fdef:c400:bd01:1096::2]::[fdef:c400:bd01:1096::1]:64::ipv6:off:666:52:54:00:a7:8f:ac"
|
||||
"ip=[fdef:c400:bd01:1096::2]::[fdef:c400:bd01:1096::1]:64::ipv6:off::52:54:00:a7:8f:ac"
|
||||
"ip=[fdef:c400:bd01:1096::2]::[fdef:c400:bd01:1096::1]:64::ipv6:off::"
|
||||
"ip=[fdef:c400:bd01:1096::2]::[fdef:c400:bd01:1096::1]:64::ipv6:off:[fdef:c400:bd01:1096::aaaa]"
|
||||
"ip=[fdef:c400:bd01:1096::2]::[fdef:c400:bd01:1096::1]:64::ipv6:off:[fdef:c400:bd01:1096::aaaa]:[fdef:c400:bd01:1096::bbbb]"
|
||||
"ip=:::::dhcp99:any"
|
||||
@ -299,7 +297,9 @@ INVALID_COMMAND_LINES=(
|
||||
"ip=:::::dhcp99:dhcp6:4294967296"
|
||||
"ip=:::::dhcp99:dhcp6:-1"
|
||||
"ip=:::::dhcp99:dhcp6:666:52:54:00"
|
||||
"ip=1.2.3.4:2.3.4.5:1.2.3.1:255.255.255.0:hello-world.local:dummy99:off::"
|
||||
"ip=fdef:c400:bd01:1096::2::[fdef:c400:bd01:1096::1]:64::ipv6:off:[fdef:c400:bd01:1096::aaaa]"
|
||||
"ip=[fdef:c400:bd01:1096::2]::[fdef:c400:bd01:1096::1]:64::ipv6:off::"
|
||||
"ip=[fdef:c400:bd01:1096::2]::[fdef:c400:bd01:1096::1]:64::ipv6:off:foo"
|
||||
"ip=[fdef:c400:bd01:1096::2]::[fdef:c400:bd01:1096::1]:64::ipv6:off:[fdef:c400:bd01:1096::aaaa]:foo"
|
||||
"ip=[fdef:c400:bd01:1096::2]::[fdef:c400:bd01:1096::1]:64::ipv6:off:[fdef:c400:bd01:1096::aaaa]:[fdef:c400:bd01:1096::bbbb]:"
|
||||
|
Loading…
x
Reference in New Issue
Block a user