Files
openwrt/target/linux/mediatek
Mieczyslaw Nalewaj e262b0263d mediatek: filogic: handle name collisions in set_netdev_labels
The filogic 04_set_netdev_label preinit script renames interfaces
through netdev_name_set() with a plain "ip link set <netdev> name
<label>". The kernel refuses to rename an interface to a name that is
already in use (-EEXIST), and the result is not checked, so the rename
silently does not happen.

This breaks whenever the requested name is currently held by another
interface, most notably when two interfaces have to swap names, e.g.
because their probe order is not deterministic. Swapping them needs
an intermediate name, as each rename asks for the name the other
interface still holds.

Rename in two phases instead, like the other targets already do:

 1. park: move every interface that needs a new name to a temporary
    name ("tmp%d"), which the kernel expands to the lowest free
    "tmpN"
 2. rename: give each parked interface its final name

After the first phase none of the affected interfaces holds its old
name any more, so the target names are free in the second phase and
the result no longer depends on the order in which /sys/class/net is
walked. The label is read again in the second phase, which works
because the of_node of an interface follows it across renames. Letting
the kernel pick the temporary name means it cannot collide with an
existing interface and always fits in IFNAMSIZ, regardless of the
label length.

Unlike the other targets, filogic does the renaming in
netdev_name_set() from /lib/functions/netdev-name.sh, which is shared
with the preinit_netdev event handler that renames a single interface.
Add an optional "phase" argument to it: when it is "park" the
interface is moved to "tmp%d" instead of its label. The event handler
does not pass it and keeps renaming straight to the final name, as a
hotplugged interface cannot be parked together with the others.

Interfaces that already have the requested name are left alone in both
phases, so nothing changes (and nothing shows up in the boot log) when
the names are already correct. An interface that has to be renamed now
takes two renames at boot instead of one.

This does not help if the requested name is held by an interface that
has no label of its own, as there is nobody to move it out of the way.

Link: https://github.com/openwrt/openwrt/pull/25460
Signed-off-by: Mieczyslaw Nalewaj <namiltd@yahoo.com>
Link: https://github.com/openwrt/openwrt/pull/26278
Signed-off-by: Robert Marko <robimarko@gmail.com>
2026-10-29 10:20:41 +01:00
..