From e0a4ef0a401349ac7b1d830a75999032aebab7b0 Mon Sep 17 00:00:00 2001 From: bobz965 Date: Fri, 14 Jul 2023 11:07:30 +0800 Subject: [PATCH] fix ifname start with pod (#3038) --- pkg/daemon/ovs_linux.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/daemon/ovs_linux.go b/pkg/daemon/ovs_linux.go index 58b336392eb3..7ffaeb78541c 100644 --- a/pkg/daemon/ovs_linux.go +++ b/pkg/daemon/ovs_linux.go @@ -185,6 +185,11 @@ func generateNicName(containerID, ifname string) (string, string) { if ifname == "eth0" { return fmt.Sprintf("%s_h", containerID[0:12]), fmt.Sprintf("%s_c", containerID[0:12]) } + // The nic name is 14 length and have prefix pod in the Kubevirt v1.0.0 + if strings.HasPrefix(ifname, "pod") && len(ifname) == 14 { + ifname = ifname[3 : len(ifname)-4] + return fmt.Sprintf("%s_%s_h", containerID[0:12-len(ifname)], ifname), fmt.Sprintf("%s_%s_c", containerID[0:12-len(ifname)], ifname) + } return fmt.Sprintf("%s_%s_h", containerID[0:12-len(ifname)], ifname), fmt.Sprintf("%s_%s_c", containerID[0:12-len(ifname)], ifname) }