Bug 2182769

Summary: [RFE] Implement support for "NIC name pinning"
Product: Red Hat Enterprise Linux 9 Reporter: Colin Walters <walters>
Component: nmstateAssignee: Gris Ge <fge>
Status: VERIFIED --- QA Contact: Mingyu Shi <mshi>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 9.2CC: ferferna, jiji, jishi, network-qe, pamoedom, sfaye, till
Target Milestone: rcKeywords: FutureFeature, Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: nmstate-2.2.10-2.el9 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Feature Request
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Colin Walters 2023-03-29 15:02:19 UTC
Current discussion around https://issues.redhat.com/browse/OCPBUGS-10787 is leaning to shipping at least PoC code in nmstate.

Something of the form:

nmstatectl pin-nic-names 

Possibly with options like --active-only (or --ignore-inactive) or `--include-only-glob=enp*` etc.

Filing this to track work on this from the nmstate side.

Comment 3 Gris Ge 2023-04-11 12:58:11 UTC
Patch send to upstream: https://github.com/nmstate/nmstate/pull/2306

The whole workflow:

 * Use `nmstatectl persist-nic-names` to pin __every__ ethernet interface to its
   MAC via systemd .link file.
 * After boot into new environment, `nmstatectl persist-nic-names --cleanup`
   will remove un-required systemd .link file.

Key tech point:

    Use `udevadm test-builtin net_id /sys/class/net/<iface_name>` to check
    systemd preferred interface name and compare to current interface
    name.

Tested:
 * CentOS stream 9 VM by renaming a existing interface to new name.

 * RHEL 8.8 and CentOS stream 9 on Mellanox MT27710:
    * Not from upgrade, just reinstall CentOS stream 9 and restored the
      nmstate created .link files.