@@ -134,16 +134,27 @@ func generateCNIResult(cniVersion string, cniResponse *request.PodResponse, ifNa
134
134
result .Routes = append (result .Routes , & route )
135
135
}
136
136
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 )
140
151
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 )
142
153
}
143
154
144
155
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 (),
147
158
Sandbox : netNs .Path (),
148
159
})
149
160
@@ -152,9 +163,9 @@ func generateCNIResult(cniVersion string, cniResponse *request.PodResponse, ifNa
152
163
return nil , err
153
164
}
154
165
155
- // bind ips with created interface
166
+ // bind ips with created container interface
156
167
for _ , ip := range result .IPs {
157
- ip .Interface = current .Int (0 )
168
+ ip .Interface = current .Int (1 )
158
169
}
159
170
160
171
return result , nil
0 commit comments