Commit 6bd02b3
committed
fix(lib): write drop-in configs to active network file directory
When another network config generator (e.g. netplan, cloud-init) creates
a .network file with a lower numerical prefix than the 70- prefix used
by amazon-ec2-net-utils, systemd-networkd selects that file as the
active config for the interface. Drop-in files written under
70-<iface>.network.d/ are then silently ignored because they belong to
an inactive network file.
This causes secondary IPv4 addresses (ec2net_alias.conf) and policy
routing rules (ec2net_policy_*.conf) to never be applied, even though
they are correctly fetched from IMDS and written to disk.
Add _get_active_dropin_dir() which queries the systemd-networkd runtime
state to discover the actual active NETWORK_FILE for an interface, then
returns that file's drop-in directory. Falls back to the original
70-<iface>.network.d path when detection is unavailable (e.g. during
early boot before networkd has initialised the interface).
Use _get_active_dropin_dir() in create_ipv4_aliases() and
create_rules() instead of the hardcoded 70- path.1 parent d9f01f3 commit 6bd02b3
1 file changed
Lines changed: 17 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
233 | 246 | | |
234 | 247 | | |
235 | 248 | | |
236 | 249 | | |
237 | 250 | | |
238 | 251 | | |
239 | | - | |
| 252 | + | |
| 253 | + | |
240 | 254 | | |
241 | 255 | | |
242 | 256 | | |
| |||
295 | 309 | | |
296 | 310 | | |
297 | 311 | | |
298 | | - | |
| 312 | + | |
| 313 | + | |
299 | 314 | | |
300 | 315 | | |
301 | 316 | | |
| |||
0 commit comments