summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/network/generator/network-generator.c13
-rw-r--r--src/network/generator/test-network-generator.c15
-rw-r--r--test/test-network-generator-conversion/test-01-dhcp.expected/91-default.network3
3 files changed, 21 insertions, 10 deletions
diff --git a/src/network/generator/network-generator.c b/src/network/generator/network-generator.c
index 823cd41f7e..f1bcc32591 100644
--- a/src/network/generator/network-generator.c
+++ b/src/network/generator/network-generator.c
@@ -1108,10 +1108,15 @@ void network_dump(Network *network, FILE *f) {
assert(network);
assert(f);
- fprintf(f,
- "[Match]\n"
- "Name=%s\n",
- isempty(network->ifname) ? "*" : network->ifname);
+ fputs("[Match]\n", f);
+
+ if (isempty(network->ifname))
+ /* If the interface name is not specified, then let's make the .network file match the all
+ * physical interfaces. */
+ fputs("Kind=!*\n"
+ "Type=!loopback\n", f);
+ else
+ fprintf(f, "Name=%s\n", network->ifname);
fputs("\n[Link]\n", f);
diff --git a/src/network/generator/test-network-generator.c b/src/network/generator/test-network-generator.c
index bcd4b1d9e4..318b9e98c3 100644
--- a/src/network/generator/test-network-generator.c
+++ b/src/network/generator/test-network-generator.c
@@ -65,7 +65,8 @@ static void test_link_one(const char *filename, const char *key, const char *val
int main(int argc, char *argv[]) {
test_network_one("", "ip", "dhcp6",
"[Match]\n"
- "Name=*\n"
+ "Kind=!*\n"
+ "Type=!loopback\n"
"\n[Link]\n"
"\n[Network]\n"
"DHCP=ipv6\n"
@@ -228,7 +229,8 @@ int main(int argc, char *argv[]) {
test_network_one("", "rd.route", "10.1.2.3/16:10.0.2.3",
"[Match]\n"
- "Name=*\n"
+ "Kind=!*\n"
+ "Type=!loopback\n"
"\n[Link]\n"
"\n[Network]\n"
"\n[DHCP]\n"
@@ -250,7 +252,8 @@ int main(int argc, char *argv[]) {
test_network_one("", "nameserver", "10.1.2.3",
"[Match]\n"
- "Name=*\n"
+ "Kind=!*\n"
+ "Type=!loopback\n"
"\n[Link]\n"
"\n[Network]\n"
"DNS=10.1.2.3\n"
@@ -259,7 +262,8 @@ int main(int argc, char *argv[]) {
test_network_one("", "rd.peerdns", "0",
"[Match]\n"
- "Name=*\n"
+ "Kind=!*\n"
+ "Type=!loopback\n"
"\n[Link]\n"
"\n[Network]\n"
"\n[DHCP]\n"
@@ -268,7 +272,8 @@ int main(int argc, char *argv[]) {
test_network_one("", "rd.peerdns", "1",
"[Match]\n"
- "Name=*\n"
+ "Kind=!*\n"
+ "Type=!loopback\n"
"\n[Link]\n"
"\n[Network]\n"
"\n[DHCP]\n"
diff --git a/test/test-network-generator-conversion/test-01-dhcp.expected/91-default.network b/test/test-network-generator-conversion/test-01-dhcp.expected/91-default.network
index e42ce1e311..657cde79ae 100644
--- a/test/test-network-generator-conversion/test-01-dhcp.expected/91-default.network
+++ b/test/test-network-generator-conversion/test-01-dhcp.expected/91-default.network
@@ -1,7 +1,8 @@
# Automatically generated by systemd-network-generator
[Match]
-Name=*
+Kind=!*
+Type=!loopback
[Link]