From ea46479db33deb6bcbc7098f0be3b893a8ef11ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=A5=96=E5=BB=BA?= Date: Mon, 3 Apr 2023 13:41:49 +0800 Subject: [PATCH] underlay: get address/route before setting nm managed to no (#2592) --- pkg/daemon/init_linux.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/daemon/init_linux.go b/pkg/daemon/init_linux.go index ba2d99f1e5c..622a45a43ba 100644 --- a/pkg/daemon/init_linux.go +++ b/pkg/daemon/init_linux.go @@ -105,13 +105,6 @@ func changeProvideNicName(current, target string) (bool, error) { return true, nil } - // set link unmanaged by NetworkManager - if err = nmSetManaged(current, false); err != nil { - klog.Errorf("failed set device %s unmanaged by NetworkManager: %v", current, err) - return false, err - } - - klog.Infof("renaming link %s as %s", current, target) addresses, err := netlink.AddrList(link, netlink.FAMILY_ALL) if err != nil { klog.Errorf("failed to list addresses of link %s: %v", current, err) @@ -123,6 +116,13 @@ func changeProvideNicName(current, target string) (bool, error) { return false, err } + // set link unmanaged by NetworkManager + if err = nmSetManaged(current, false); err != nil { + klog.Errorf("failed set device %s unmanaged by NetworkManager: %v", current, err) + return false, err + } + + klog.Infof("renaming link %s as %s", current, target) if err = netlink.LinkSetDown(link); err != nil { klog.Errorf("failed to set link %s down: %v", current, err) return false, err