Skip to content

Commit

Permalink
fix ifname start with pod (#3038)
Browse files Browse the repository at this point in the history
  • Loading branch information
bobz965 authored and hongzhen-ma committed Jul 14, 2023
1 parent a29d00c commit 8ce77f8
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/daemon/ovs_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit 8ce77f8

Please sign in to comment.