Skip to content

Commit e4b1ba1

Browse files
committed
host-device: Return interface name in result
Signed-off-by: Sriram Yagnaraman <sriram.yagnaraman@ericsson.com>
1 parent 6e7fb60 commit e4b1ba1

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

plugins/main/host-device/host-device.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ func cmdAdd(args *skel.CmdArgs) error {
131131
defer containerNs.Close()
132132

133133
result := &current.Result{}
134+
result.Interfaces = []*current.Interface{{
135+
Name: args.IfName,
136+
Sandbox: containerNs.Path(),
137+
}}
138+
134139
var contDev netlink.Link
135140
if !cfg.DPDKMode {
136141
hostDev, err := getLink(cfg.Device, cfg.HWAddr, cfg.KernelPath, cfg.PCIAddr, cfg.auxDevice)
@@ -143,11 +148,10 @@ func cmdAdd(args *skel.CmdArgs) error {
143148
return fmt.Errorf("failed to move link %v", err)
144149
}
145150

146-
result.Interfaces = []*current.Interface{{
147-
Name: contDev.Attrs().Name,
148-
Mac: contDev.Attrs().HardwareAddr.String(),
149-
Sandbox: containerNs.Path(),
150-
}}
151+
// Override the device name with the name in the container namespace
152+
result.Interfaces[0].Name = contDev.Attrs().Name
153+
// Set the MAC address of the interface
154+
result.Interfaces[0].Mac = contDev.Attrs().HardwareAddr.String()
151155
}
152156

153157
if cfg.IPAM.Type == "" {

0 commit comments

Comments
 (0)