@@ -15,6 +15,7 @@ import (
1515
1616 "golang.org/x/sys/unix"
1717
18+ "github.com/kata-containers/agent/pkg/types"
1819 pb "github.com/kata-containers/agent/protocols/grpc"
1920 "github.com/sirupsen/logrus"
2021 "github.com/vishvananda/netlink"
@@ -34,10 +35,10 @@ var (
3435// related information.
3536type network struct {
3637 ifacesLock sync.Mutex
37- ifaces map [string ]* pb .Interface
38+ ifaces map [string ]* types .Interface
3839
3940 routesLock sync.Mutex
40- routes []pb .Route
41+ routes []types .Route
4142
4243 dns []string
4344}
@@ -82,7 +83,7 @@ func linkByHwAddr(netHandle *netlink.Handle, hwAddr string) (netlink.Link, error
8283 return nil , grpcStatus .Errorf (codes .NotFound , "Could not find the link corresponding to HwAddr %q" , hwAddr )
8384}
8485
85- func updateLink (netHandle * netlink.Handle , link netlink.Link , iface * pb .Interface ) error {
86+ func updateLink (netHandle * netlink.Handle , link netlink.Link , iface * types .Interface ) error {
8687 if netHandle == nil {
8788 return errNoHandle
8889 }
@@ -134,7 +135,7 @@ func updateLink(netHandle *netlink.Handle, link netlink.Link, iface *pb.Interfac
134135 return nil
135136}
136137
137- func (s * sandbox ) addInterface (netHandle * netlink.Handle , iface * pb .Interface ) (resultingIfc * pb .Interface , err error ) {
138+ func (s * sandbox ) addInterface (netHandle * netlink.Handle , iface * types .Interface ) (resultingIfc * types .Interface , err error ) {
138139 if iface == nil {
139140 return nil , errNoIF
140141 }
@@ -179,7 +180,7 @@ func (s *sandbox) addInterface(netHandle *netlink.Handle, iface *pb.Interface) (
179180
180181 return iface , nil
181182}
182- func (s * sandbox ) removeInterface (netHandle * netlink.Handle , iface * pb .Interface ) (resultingIfc * pb .Interface , err error ) {
183+ func (s * sandbox ) removeInterface (netHandle * netlink.Handle , iface * types .Interface ) (resultingIfc * types .Interface , err error ) {
183184 if iface == nil {
184185 return nil , errNoIF
185186 }
@@ -217,10 +218,10 @@ func (s *sandbox) removeInterface(netHandle *netlink.Handle, iface *pb.Interface
217218 return nil , nil
218219}
219220
220- // updateInterface will update an existing interface with the values provided in the pb .Interface. It will identify the
221+ // updateInterface will update an existing interface with the values provided in the types .Interface. It will identify the
221222// existing interface via MAC address and will return the state of the interface once the function completes as well an any
222223// errors observed.
223- func (s * sandbox ) updateInterface (netHandle * netlink.Handle , iface * pb .Interface ) (resultingIfc * pb .Interface , err error ) {
224+ func (s * sandbox ) updateInterface (netHandle * netlink.Handle , iface * types .Interface ) (resultingIfc * types .Interface , err error ) {
224225 if iface == nil {
225226 return nil , errNoIF
226227 }
@@ -301,7 +302,7 @@ func (s *sandbox) updateInterface(netHandle *netlink.Handle, iface *pb.Interface
301302}
302303
303304// getInterface will retrieve interface details from the provided link
304- func getInterface (netHandle * netlink.Handle , link netlink.Link ) (* pb .Interface , error ) {
305+ func getInterface (netHandle * netlink.Handle , link netlink.Link ) (* types .Interface , error ) {
305306 if netHandle == nil {
306307 return nil , errNoHandle
307308 }
@@ -310,7 +311,7 @@ func getInterface(netHandle *netlink.Handle, link netlink.Link) (*pb.Interface,
310311 return nil , errNoLink
311312 }
312313
313- var ifc pb .Interface
314+ var ifc types .Interface
314315 linkAttrs := link .Attrs ()
315316 ifc .Name = linkAttrs .Name
316317 ifc .Mtu = uint64 (linkAttrs .MTU )
@@ -323,7 +324,7 @@ func getInterface(netHandle *netlink.Handle, link netlink.Link) (*pb.Interface,
323324 }
324325 for _ , addr := range addrs {
325326 netMask , _ := addr .Mask .Size ()
326- m := pb .IPAddress {
327+ m := types .IPAddress {
327328 Address : addr .IP .String (),
328329 Mask : fmt .Sprintf ("%d" , netMask ),
329330 }
@@ -481,7 +482,7 @@ func getCurrentRoutes(netHandle *netlink.Handle) (*pb.Routes, error) {
481482 }
482483
483484 for _ , route := range finalRouteList {
484- var r pb .Route
485+ var r types .Route
485486 if route .Dst != nil {
486487 r .Dest = route .Dst .String ()
487488 }
@@ -508,7 +509,7 @@ func getCurrentRoutes(netHandle *netlink.Handle) (*pb.Routes, error) {
508509 return & routes , nil
509510}
510511
511- func (s * sandbox ) updateRoute (netHandle * netlink.Handle , route * pb .Route , add bool ) (err error ) {
512+ func (s * sandbox ) updateRoute (netHandle * netlink.Handle , route * types .Route , add bool ) (err error ) {
512513 s .network .routesLock .Lock ()
513514 defer s .network .routesLock .Unlock ()
514515
0 commit comments