mirror of
https://github.com/systemd/systemd.git
synced 2026-08-09 01:20:53 +00:00
network-generator: allow to create bridge or friends without slave interfaces
This commit is contained in:
@@ -532,7 +532,9 @@ static int network_set_vlan(Context *context, const char *ifname, const char *va
|
||||
int r;
|
||||
|
||||
assert(context);
|
||||
assert(ifname);
|
||||
|
||||
if (isempty(ifname))
|
||||
return 0;
|
||||
|
||||
network = network_get(context, ifname);
|
||||
if (!network) {
|
||||
@@ -549,7 +551,9 @@ static int network_set_bridge(Context *context, const char *ifname, const char *
|
||||
int r;
|
||||
|
||||
assert(context);
|
||||
assert(ifname);
|
||||
|
||||
if (isempty(ifname))
|
||||
return 0;
|
||||
|
||||
network = network_get(context, ifname);
|
||||
if (!network) {
|
||||
@@ -566,7 +570,9 @@ static int network_set_bond(Context *context, const char *ifname, const char *va
|
||||
int r;
|
||||
|
||||
assert(context);
|
||||
assert(ifname);
|
||||
|
||||
if (isempty(ifname))
|
||||
return 0;
|
||||
|
||||
network = network_get(context, ifname);
|
||||
if (!network) {
|
||||
@@ -1011,8 +1017,6 @@ static int parse_cmdline_bridge(Context *context, const char *key, const char *v
|
||||
}
|
||||
|
||||
p++;
|
||||
if (isempty(p))
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), "Missing slave interfaces for bridge '%s'", name);
|
||||
|
||||
for (;;) {
|
||||
_cleanup_free_ char *word = NULL;
|
||||
@@ -1060,9 +1064,6 @@ static int parse_cmdline_bond(Context *context, const char *key, const char *val
|
||||
else
|
||||
slaves = strndupa_safe(value, p - value);
|
||||
|
||||
if (isempty(slaves))
|
||||
return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), "Missing slave interfaces for bond '%s'", name);
|
||||
|
||||
for (const char *q = slaves; ; ) {
|
||||
_cleanup_free_ char *word = NULL;
|
||||
|
||||
|
||||
@@ -343,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"
|
||||
|
||||
Reference in New Issue
Block a user