Skip to content

Commit

Permalink
Add comments for linux-specific constants
Browse files Browse the repository at this point in the history
Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>
  • Loading branch information
Vladimir Popov committed Sep 24, 2020
1 parent 04ac533 commit fb6ece2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
4 changes: 1 addition & 3 deletions pkg/kernel/link.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import (
"path/filepath"

"github.com/pkg/errors"
"golang.org/x/sys/unix"

"github.com/vishvananda/netlink"
"github.com/vishvananda/netns"
)
Expand Down Expand Up @@ -86,7 +84,7 @@ func (l *link) AddAddress(ip string) error {
}

// check if address is already assigned
current, err := netlink.AddrList(l.link, unix.AF_UNSPEC) // netlink.FAMILY_ALL
current, err := netlink.AddrList(l.link, 0x0) // netlink.FAMILY_ALL (linux-specific constant)
if err != nil {
return errors.Errorf("failed to get current IP address list %q: %s", ip, err)
}
Expand Down
10 changes: 4 additions & 6 deletions pkg/kernel/networkservice/connectioncontext/ipcontext/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@ import (
"os"

"github.com/golang/protobuf/ptypes/empty"
"github.com/pkg/errors"
"github.com/vishvananda/netlink"
"golang.org/x/sys/unix"

"github.com/networkservicemesh/api/pkg/api/networkservice"
"github.com/networkservicemesh/api/pkg/api/networkservice/mechanisms/kernel"
"github.com/networkservicemesh/sdk/pkg/networkservice/core/next"
"github.com/pkg/errors"
"github.com/vishvananda/netlink"
)

type ipContextServer struct{}
Expand Down Expand Up @@ -73,7 +71,7 @@ func (s *ipContextServer) Request(ctx context.Context, request *networkservice.N
}

func setIPAddr(ipAddr *netlink.Addr, link netlink.Link) error {
ipAddrs, err := netlink.AddrList(link, unix.AF_UNSPEC) // netlink.FAMILY_ALL
ipAddrs, err := netlink.AddrList(link, 0x0) // netlink.FAMILY_ALL (linux-specific constant)
if err != nil {
return errors.Wrapf(err, "failed to get the net interface IP addresses: %v", link.Attrs().Name)
}
Expand Down Expand Up @@ -119,7 +117,7 @@ func setIPNeighbors(ipNeighbours []*networkservice.IpNeighbor, link netlink.Link
}
if err := netlink.NeighAdd(&netlink.Neigh{
LinkIndex: link.Attrs().Index,
State: 0x02, // netlink.NUD_REACHABLE
State: 0x02, // netlink.NUD_REACHABLE (linux-specific constant)
IP: net.ParseIP(ipNeighbor.Ip),
HardwareAddr: macAddr,
}); err != nil && !os.IsExist(err) {
Expand Down

0 comments on commit fb6ece2

Please sign in to comment.