Skip to content

Stale config is never cleaned up on ENI detach, shadowing the new config when the interface is renamed on re-attach #166

Description

@joeysk2012

When an ENI is detached, the udev rule in udev/99-vpc-policy-routes.rules runs
systemctl disable --now refresh-policy-routes@$name.timer policy-routes@$name.service,
but nothing ever deletes the generated configuration. policy-routes@.service defines
only ExecStart, so stopping the unit executes nothing, and the remove) branch in
bin/setup-policy-routes.sh — the only code that removes 70-<iface>.network and
70-<iface>.network.d/ — has no caller anywhere in the tree (its sibling
stop|cleanup) is an explicit no-op), making it effectively dead code.

The orphaned config therefore survives the detach with ec2net_alias.conf still listing the
pre-detach secondary IPs, and because create_if_overrides writes
[Match] MACAddress=${ether} rather than matching on interface name, it continues to
match the same ENI. If that ENI is later re-attached and the kernel assigns a different
name (e.g. enp40s0enp41s0), two .network files in /run/systemd/network match
the same MAC and systemd-networkd applies the lexicographically first — the stale one.
From that point refresh-policy-routes still recomputes the alias list correctly, but
writes it to 70-<newname>.network.d/ec2net_alias.conf, a drop-in belonging to an
inactive .network file, so removed secondary IPs are never withdrawn from the OS and
neither networkctl reload nor a full systemctl restart systemd-networkd recovers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions