Skip to content

Commit 4b0ef6a

Browse files
authoredJun 21, 2023
Merge pull request #389 from hhyasdf/release/v0.8.3
[CHERRY PICK] release for v0.8.3
2 parents bc62c0c + 6ccfd57 commit 4b0ef6a

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed
 

‎cmd/cni/cni.go

+19-8
Original file line numberDiff line numberDiff line change
@@ -134,16 +134,27 @@ func generateCNIResult(cniVersion string, cniResponse *request.PodResponse, ifNa
134134
result.Routes = append(result.Routes, &route)
135135
}
136136

137-
// fetch interface info by name in container namespace
138-
if err := netNs.Do(func(_ ns.NetNS) error {
139-
createdInterface, err := netlink.LinkByName(ifName)
137+
// fetch created host interface by name
138+
hostInterface, err := netlink.LinkByName(cniResponse.HostInterface)
139+
if err != nil {
140+
return nil, fmt.Errorf("unable to get created host interface %q: %v", cniResponse.HostInterface, err)
141+
}
142+
143+
result.Interfaces = append(result.Interfaces, &current.Interface{
144+
Name: hostInterface.Attrs().Name,
145+
Mac: hostInterface.Attrs().HardwareAddr.String(),
146+
})
147+
148+
// fetch created container interface by name in container namespace
149+
if err = netNs.Do(func(_ ns.NetNS) error {
150+
containerInterface, err := netlink.LinkByName(ifName)
140151
if err != nil {
141-
return fmt.Errorf("unable to get created interface %q: %v", ifName, err)
152+
return fmt.Errorf("unable to get created container interface %q: %v", ifName, err)
142153
}
143154

144155
result.Interfaces = append(result.Interfaces, &current.Interface{
145-
Name: ifName,
146-
Mac: createdInterface.Attrs().HardwareAddr.String(),
156+
Name: containerInterface.Attrs().Name,
157+
Mac: containerInterface.Attrs().HardwareAddr.String(),
147158
Sandbox: netNs.Path(),
148159
})
149160

@@ -152,9 +163,9 @@ func generateCNIResult(cniVersion string, cniResponse *request.PodResponse, ifNa
152163
return nil, err
153164
}
154165

155-
// bind ips with created interface
166+
// bind ips with created container interface
156167
for _, ip := range result.IPs {
157-
ip.Interface = current.Int(0)
168+
ip.Interface = current.Int(1)
158169
}
159170

160171
return result, nil

0 commit comments

Comments
 (0)
Please sign in to comment.