-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
networkd: surprising behaviour of .network files with only commented content #717
Comments
Well. That's really expected behaviour. An empty .network file means a file with an empty match section and default settings for everything. An empty match section means it applies to every interface. hence you get the behaviour you are seeing. It probably would make sense to document this as a caveat though, since it is indeed surprising at first. |
Yes, I understand this. But an empty (zero sized) .network file actually gets skipped by network_load_one(). TBH, this behaviour is not consistent. :) |
@puleglot empty network files are a special case of a general rule in systemd: empty files and symlinks to /dev/null are used to "mask" a file. This is (partially) documented in network.network(5). OTOH, I understand how the case of fully commented-out files can be confusing. It would be nice to at least emit a warning in this case. (If I have a file with [Match] Name=a* Name=b_, I'll match two interfaces. If I have a file with [Match] Name=a_, I'll match one interface. But then if I have a file with [Match], all interfaces will be matched.) |
This should clear up some confusion in systemd#717. This basically copies the description from systemd.unit to this man page. Masking can happen also in /run, so strike the part about /etc, and also add the magic work "mask".
Refusing .network files with an empty [Match] section is a good idea IMHO. It really should be a required section. |
I would warn, but not refuse I must say. |
Warn user of completely commented .network file behavior systemd#717
This should clear up some confusion in systemd/systemd#717. This basically copies the description from systemd.unit to this man page. Masking can happen also in /run, so strike the part about /etc, and also add the magic work "mask".
the fact that someone as experienced as @kesyzbz could "get bit" by this problem (see #9895) suggests that the problem is in fact in the codebase and not in the user. a non-empty .network file with no Fixing this would provide sensible guard-rails to any reasonable system administrator, and removes no functionality, because an administrator who wants this particular (very odd) behavior of configuring nothing but matching on all interfaces can always explicitly create universally-matching config file with something like this:
Please consider making systemd less user-hostile in this case. |
We now emit a warning if no matches are found, see 84ea567. This opens the possibility to turn it into an error a few releases down the road. |
Two releases ago we started warning about this, and I think it is now to turn this into a hard error. People get bitten by this every once in a while, and there doesn't see to be any legitimate use case where the same .link or .network files should be applied to _all_ interfaces, since in particular that configuration would apply both to lo and any other interfaces. And if for whatever reason that is actually desired, OriginalName=* or Name=* can be easily added to silence the warning and achieve the effect. (The case described in systemd#12098 is particularly nasty: 'echo -n >foo.network' creates a mask file, 'echo >foo.network' creates a "match all" file.) Fixes systemd#717, systemd#12098 for realz now.
This broke compatibility with netplan! Now you cannot configure networkd to configure all interfaces through DHCP4 via netplan anymore because netplan refuses a simple * as a name glob. |
If network config contains only empty and/or commented out lines, then networkd begins to manage all interfaces:
Real world example of problematic network config:
The text was updated successfully, but these errors were encountered: