cilium/cilium · error

failed to get link after rename: %w

Error message

failed to get link after rename: %w

What it means

After a successful LinkSetName rename, configureIfName re-fetches the link under its new name to return a fresh reference. This error means the rename appeared to succeed but the link could not be found afterwards — an unexpected state indicating the link disappeared or a netlink cache/lookup issue.

Source

Thrown at pkg/networkdriver/nri.go:379

	return ""
}

// configureIfName renames an interface to newIfName if the current link name differs from the
// newIfName and newIfName is not empty.
func configureIfName(l netlink.Link, newIfName string) (netlink.Link, error) {
	if newIfName == "" || l.Attrs().Name == newIfName {
		// no changes needed
		return l, nil
	}

	if err := netlink.LinkSetName(l, newIfName); err != nil {
		return nil, fmt.Errorf("failed to rename interface from %s to %s: %w", l.Attrs().Name, newIfName, err)
	}

	// Refresh link reference after rename
	l, err := safenetlink.LinkByName(newIfName)
	if err != nil {
		return nil, fmt.Errorf("failed to get link after rename: %w", err)
	}

	return l, nil
}

// validateInterfaceNames checks if a pod's set of allocated devices
// contain valid interface names, that dont collide with interfaces in the pod namespace.
func validateInterfaceNames(alloc []allocation) error {
	existingLinks, err := safenetlink.LinkList()
	if err != nil {
		return fmt.Errorf("failed to list existing interfaces in pod netns: %w", err)
	}

	existingNames := make(map[string]bool)
	for _, link := range existingLinks {
		existingNames[link.Attrs().Name] = true
	}

View on GitHub (pinned to ac7b90affa)

Solutions

  1. Retry the sandbox operation: the error is rare and usually transient; restart the pod.
  2. Check node logs/dmesg for link removal events at the same timestamp (VF removed, link down).
  3. Verify no other component (CNI, device plugin) deletes or renames interfaces concurrently in the pod netns.
  4. If persistent, restart the agent and re-create the pod to get a fresh device.
Defensive patterns

Strategy: retry

Try / catch

err := driver.RunPodSandbox(ctx, sandbox)
if err != nil && strings.Contains(err.Error(), "failed to get link after rename") {
    // transient race: backoff and retry sandbox start once
}

Prevention

When it happens

Trigger: netlink.LinkSetName succeeded but the subsequent safenetlink.LinkByName(newIfName) fails — the interface was removed concurrently (e.g. link monitor/other actor deleted it), or the rename raced with netns movement so the handle is in another namespace.

Common situations: Racing device teardown while the sandbox is stopping; SR-IOV VF unplugged by the PF driver during rename; netlink socket errors under memory pressure.

Related errors


AI-assisted analysis of cilium/cilium@ac7b90affa (2026-08-31). Data as JSON: /api/errors/e3b2d5471132ec23. Report an issue: GitHub.