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

Commit

Permalink
Merge pull request #210 from bergwolf/netlink
Browse files Browse the repository at this point in the history
network: specify netlink protocol
  • Loading branch information
bergwolf authored Apr 10, 2018
2 parents a80ad16 + 131554d commit a6166b7
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions network.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
"reflect"
"sync"

"golang.org/x/sys/unix"

pb "github.com/kata-containers/agent/protocols/grpc"
"github.com/sirupsen/logrus"
"github.com/vishvananda/netlink"
Expand Down Expand Up @@ -101,7 +103,7 @@ func (s *sandbox) addInterface(netHandle *netlink.Handle, iface *pb.Interface) (
defer s.network.ifacesLock.Unlock()

if netHandle == nil {
netHandle, err = netlink.NewHandle()
netHandle, err = netlink.NewHandle(unix.NETLINK_ROUTE)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -146,7 +148,7 @@ func (s *sandbox) removeInterface(netHandle *netlink.Handle, iface *pb.Interface
defer s.network.ifacesLock.Unlock()

if netHandle == nil {
netHandle, err = netlink.NewHandle()
netHandle, err = netlink.NewHandle(unix.NETLINK_ROUTE)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -192,7 +194,7 @@ func (s *sandbox) updateInterface(netHandle *netlink.Handle, iface *pb.Interface
}

if netHandle == nil {
netHandle, err = netlink.NewHandle()
netHandle, err = netlink.NewHandle(unix.NETLINK_ROUTE)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -288,7 +290,7 @@ func getInterface(netHandle *netlink.Handle, link netlink.Link) (*pb.Interface,
func (s *sandbox) updateRoutes(netHandle *netlink.Handle, requestedRoutes *pb.Routes) (resultingRoutes *pb.Routes, err error) {

if netHandle == nil {
netHandle, err = netlink.NewHandle()
netHandle, err = netlink.NewHandle(unix.NETLINK_ROUTE)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -365,7 +367,7 @@ func (s *sandbox) updateRoutes(netHandle *netlink.Handle, requestedRoutes *pb.Ro
func getCurrentRoutes(netHandle *netlink.Handle) (*pb.Routes, error) {

if netHandle == nil {
netHandle, err := netlink.NewHandle()
netHandle, err := netlink.NewHandle(unix.NETLINK_ROUTE)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -416,7 +418,7 @@ func (s *sandbox) updateRoute(netHandle *netlink.Handle, route *pb.Route, add bo
defer s.network.routesLock.Unlock()

if netHandle == nil {
netHandle, err = netlink.NewHandle()
netHandle, err = netlink.NewHandle(unix.NETLINK_ROUTE)
if err != nil {
return err
}
Expand Down Expand Up @@ -500,7 +502,7 @@ func removeDNS(dns []string) error {

// Remove everything related to network.
func (s *sandbox) removeNetwork() error {
netHandle, err := netlink.NewHandle()
netHandle, err := netlink.NewHandle(unix.NETLINK_ROUTE)
if err != nil {
return err
}
Expand Down

0 comments on commit a6166b7

Please sign in to comment.