mirror of
https://github.com/systemd/systemd
synced 2024-07-08 20:15:55 +00:00
network-generator: make network file generated from ip=dhcp matches only physical interfaces
Otherwise, it also matches later created virtual devices, and that breaks networks generated and managed by container management services, like docker. Closes #28626.
This commit is contained in:
parent
8d580dde76
commit
c25aa6c8ac
|
@ -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);
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
# Automatically generated by systemd-network-generator
|
||||
|
||||
[Match]
|
||||
Name=*
|
||||
Kind=!*
|
||||
Type=!loopback
|
||||
|
||||
[Link]
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user