Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
network: Remove grpc AddInterface and RemoveInterface api
Browse files Browse the repository at this point in the history
These grpc APIs are not really used/called by the runtime.
Remove this to clean the code.

Fixes #456

Signed-off-by: Archana Shinde <[email protected]>
  • Loading branch information
amshinde committed Feb 19, 2019
1 parent 17192be commit ae9ce6e
Show file tree
Hide file tree
Showing 5 changed files with 192 additions and 622 deletions.
8 changes: 0 additions & 8 deletions grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -1357,18 +1357,10 @@ func (a *agentGRPC) DestroySandbox(ctx context.Context, req *pb.DestroySandboxRe
return emptyResp, nil
}

func (a *agentGRPC) AddInterface(ctx context.Context, req *pb.AddInterfaceRequest) (*types.Interface, error) {
return a.sandbox.addInterface(nil, req.Interface)
}

func (a *agentGRPC) UpdateInterface(ctx context.Context, req *pb.UpdateInterfaceRequest) (*types.Interface, error) {
return a.sandbox.updateInterface(nil, req.Interface)
}

func (a *agentGRPC) RemoveInterface(ctx context.Context, req *pb.RemoveInterfaceRequest) (*types.Interface, error) {
return a.sandbox.removeInterface(nil, req.Interface)
}

func (a *agentGRPC) UpdateRoutes(ctx context.Context, req *pb.UpdateRoutesRequest) (*pb.Routes, error) {
return a.sandbox.updateRoutes(nil, req.Routes)
}
Expand Down
45 changes: 0 additions & 45 deletions network.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,51 +147,6 @@ func updateLink(netHandle *netlink.Handle, link netlink.Link, iface *types.Inter
return nil
}

func (s *sandbox) addInterface(netHandle *netlink.Handle, iface *types.Interface) (resultingIfc *types.Interface, err error) {
if iface == nil {
return nil, errNoIF
}

s.network.ifacesLock.Lock()
defer s.network.ifacesLock.Unlock()

if netHandle == nil {
netHandle, err = netlink.NewHandle(unix.NETLINK_ROUTE)
if err != nil {
return nil, err
}
defer netHandle.Delete()
}

hwAddr, err := net.ParseMAC(iface.HwAddr)
if err != nil {
return nil, err
}

link := &netlink.Device{
LinkAttrs: netlink.LinkAttrs{
MTU: int(iface.Mtu),
TxQLen: -1,
Name: iface.Name,
HardwareAddr: hwAddr,
},
}

// Create the link.
if err := netHandle.LinkAdd(link); err != nil {
return nil, err
}

// Set the link up.
if err := netHandle.LinkSetUp(link); err != nil {
return iface, err
}

// Update sandbox interface list.
s.network.ifaces[iface.Name] = iface

return iface, nil
}
func (s *sandbox) removeInterface(netHandle *netlink.Handle, iface *types.Interface) (resultingIfc *types.Interface, err error) {
if iface == nil {
return nil, errNoIF
Expand Down
Loading

0 comments on commit ae9ce6e

Please sign in to comment.