Skip to content

Commit

Permalink
chore: bump go.mod dependencies, fix netaddr API changes
Browse files Browse the repository at this point in the history
Bump dependencies, clean up go.mod files, update for netaddr changes
(all around `netaddr.IPPrefix` being a private struct now).

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
  • Loading branch information
smira authored and talos-bot committed Jun 24, 2021
1 parent c7e6225 commit b5244bf
Show file tree
Hide file tree
Showing 18 changed files with 155 additions and 108 deletions.
21 changes: 7 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ replace (
require (
github.com/AlekSi/pointer v1.1.0
github.com/BurntSushi/toml v0.3.1
github.com/aws/aws-sdk-go v1.27.0 // indirect
github.com/aws/aws-sdk-go v1.38.66 // indirect
github.com/beevik/ntp v0.3.0
github.com/containerd/cgroups v1.0.1
github.com/containerd/containerd v1.5.2
Expand Down Expand Up @@ -53,30 +53,25 @@ require (
github.com/hashicorp/go-getter v1.5.4
github.com/hashicorp/go-multierror v1.1.1
github.com/imdario/mergo v0.3.12 // indirect
github.com/insomniacslk/dhcp v0.0.0-20210608085346-465dd6c35f6c
github.com/insomniacslk/dhcp v0.0.0-20210621130208-1cac67f12b1e
github.com/jsimonetti/rtnetlink v0.0.0-20210614053835-9c52e516c709
github.com/magiconair/properties v1.8.5 // indirect
github.com/mattn/go-isatty v0.0.13
github.com/mdlayher/arp v0.0.0-20191213142603-f72070a231fc
github.com/mdlayher/ethtool v0.0.0-20210210192532-2b88debcdd43
github.com/mdlayher/genetlink v1.0.0
github.com/mdlayher/netlink v1.4.1
github.com/mdlayher/raw v0.0.0-20210412142147-51b895745faf // indirect
github.com/mitchellh/mapstructure v1.4.1 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/opencontainers/runtime-spec v1.0.3-0.20200929063507-e6143ca7d51d
github.com/pelletier/go-toml v1.9.0 // indirect
github.com/pin/tftp v2.1.0+incompatible
github.com/prometheus/procfs v0.6.0
github.com/rivo/tview v0.0.0-20210608105643-d4fb0348227b
github.com/rs/xid v1.3.0
github.com/ryanuber/columnize v2.1.2+incompatible
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/smira/go-xz v0.0.0-20201019130106-9921ed7a9935
github.com/spf13/afero v1.6.0 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/spf13/cobra v1.1.3
github.com/spf13/viper v1.7.1 // indirect
github.com/spf13/viper v1.8.0 // indirect
github.com/stretchr/testify v1.7.0
github.com/talos-systems/crypto v0.3.1
github.com/talos-systems/go-blockdevice v0.2.1
Expand All @@ -92,7 +87,7 @@ require (
github.com/talos-systems/talos/pkg/machinery v0.0.0-00010101000000-000000000000
github.com/u-root/u-root v7.0.0+incompatible
github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f // indirect
github.com/vmware-tanzu/sonobuoy v0.51.0
github.com/vmware-tanzu/sonobuoy v0.52.0
github.com/vmware/govmomi v0.26.0
github.com/vmware/vmw-guestinfo v0.0.0-20200218095840-687661b8bd8e
go.etcd.io/etcd/api/v3 v3.5.0
Expand All @@ -101,26 +96,24 @@ require (
go.etcd.io/etcd/etcdutl/v3 v3.5.0
go.uber.org/zap v1.17.0
golang.org/x/net v0.0.0-20210614182718-04defd469f4e
golang.org/x/oauth2 v0.0.0-20210427180440-81ed05c6b58c // indirect
golang.org/x/oauth2 v0.0.0-20210622215436-a8dc77f794b6 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b
golang.org/x/time v0.0.0-20210611083556-38a9dc6acbc6
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20210506160403-92e472f520a5
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/grpc v1.38.0
google.golang.org/protobuf v1.26.0
gopkg.in/freddierice/go-losetup.v1 v1.0.0-20170407175016-fc9adea44124
gopkg.in/ini.v1 v1.62.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
inet.af/netaddr v0.0.0-20210430201628-1d252cf8125e
inet.af/netaddr v0.0.0-20210603230628-bf05d8b52dda
k8s.io/api v0.21.2
k8s.io/apimachinery v0.21.2
k8s.io/apiserver v0.21.2 // indirect; use the same version as other k8s deps
k8s.io/client-go v0.21.2
k8s.io/cri-api v0.21.2
k8s.io/kubectl v0.21.2
k8s.io/kubelet v0.21.2
k8s.io/utils v0.0.0-20210305010621-2afb4311ab10 // indirect
k8s.io/utils v0.0.0-20210527160623-6fdb442a123b // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.1.1 // indirect
)
118 changes: 92 additions & 26 deletions go.sum

Large diffs are not rendered by default.

16 changes: 5 additions & 11 deletions internal/app/machined/pkg/controllers/network/address_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,21 +188,15 @@ func (ctrl *AddressConfigController) loopbackDefaults() []network.AddressSpecSpe

return []network.AddressSpecSpec{
{
Address: netaddr.IPPrefix{
IP: netaddr.IPv4(127, 0, 0, 1),
Bits: 8,
},
Address: netaddr.IPPrefixFrom(netaddr.IPv4(127, 0, 0, 1), 8),
Family: nethelpers.FamilyInet4,
Scope: nethelpers.ScopeHost,
Flags: nethelpers.AddressFlags(nethelpers.AddressPermanent),
LinkName: "lo",
ConfigLayer: network.ConfigDefault,
},
{
Address: netaddr.IPPrefix{
IP: netaddr.IPFrom16([16]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}),
Bits: 128,
},
Address: netaddr.IPPrefixFrom(netaddr.IPFrom16([16]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}), 128),
Family: nethelpers.FamilyInet6,
Scope: nethelpers.ScopeHost,
Flags: nethelpers.AddressFlags(nethelpers.AddressPermanent),
Expand All @@ -229,7 +223,7 @@ func (ctrl *AddressConfigController) parseCmdline(logger *zap.Logger) (address n
}

address.Address = settings.Address
if address.Address.IP.Is6() {
if address.Address.IP().Is6() {
address.Family = nethelpers.FamilyInet6
} else {
address.Family = nethelpers.FamilyInet4
Expand Down Expand Up @@ -265,7 +259,7 @@ func (ctrl *AddressConfigController) parseMachineConfiguration(logger *zap.Logge
Flags: nethelpers.AddressFlags(nethelpers.AddressPermanent),
}

if address.Address.IP.Is6() {
if address.Address.IP().Is6() {
address.Family = nethelpers.FamilyInet6
} else {
address.Family = nethelpers.FamilyInet4
Expand All @@ -291,7 +285,7 @@ func (ctrl *AddressConfigController) parseMachineConfiguration(logger *zap.Logge
Flags: nethelpers.AddressFlags(nethelpers.AddressPermanent),
}

if address.Address.IP.Is6() {
if address.Address.IP().Is6() {
address.Family = nethelpers.FamilyInet6
} else {
address.Family = nethelpers.FamilyInet4
Expand Down
14 changes: 7 additions & 7 deletions internal/app/machined/pkg/controllers/network/address_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ func findAddress(addrs []rtnetlink.AddressMessage, linkIndex uint32, ipPrefix ne
continue
}

if addr.PrefixLength != ipPrefix.Bits {
if addr.PrefixLength != ipPrefix.Bits() {
continue
}

if !addr.Attributes.Address.Equal(ipPrefix.IP.IPAddr().IP) {
if !addr.Attributes.Address.Equal(ipPrefix.IP().IPAddr().IP) {
continue
}

Expand Down Expand Up @@ -210,13 +210,13 @@ func (ctrl *AddressSpecController) syncAddress(ctx context.Context, r controller
// add address
if err := conn.Address.New(&rtnetlink.AddressMessage{
Family: uint8(address.TypedSpec().Family),
PrefixLength: address.TypedSpec().Address.Bits,
PrefixLength: address.TypedSpec().Address.Bits(),
Flags: uint8(address.TypedSpec().Flags),
Scope: uint8(address.TypedSpec().Scope),
Index: linkIndex,
Attributes: rtnetlink.AddressAttributes{
Address: address.TypedSpec().Address.IP.IPAddr().IP,
Local: address.TypedSpec().Address.IP.IPAddr().IP,
Address: address.TypedSpec().Address.IP().IPAddr().IP,
Local: address.TypedSpec().Address.IP().IPAddr().IP,
Broadcast: broadcastAddr(address.TypedSpec().Address),
Flags: uint32(address.TypedSpec().Flags),
},
Expand All @@ -230,7 +230,7 @@ func (ctrl *AddressSpecController) syncAddress(ctx context.Context, r controller
logger.Info("assigned address", zap.Stringer("address", address.TypedSpec().Address), zap.String("link", address.TypedSpec().LinkName))

if address.TypedSpec().AnnounceWithARP {
if err := ctrl.gratuitousARP(logger, linkIndex, address.TypedSpec().Address.IP); err != nil {
if err := ctrl.gratuitousARP(logger, linkIndex, address.TypedSpec().Address.IP()); err != nil {
logger.Warn("failure sending gratuitous ARP", zap.Stringer("address", address.TypedSpec().Address), zap.String("link", address.TypedSpec().LinkName), zap.Error(err))
}
}
Expand Down Expand Up @@ -278,7 +278,7 @@ func (ctrl *AddressSpecController) gratuitousARP(logger *zap.Logger, linkIndex u
}

func broadcastAddr(addr netaddr.IPPrefix) net.IP {
if !addr.IP.Is4() {
if !addr.IP().Is4() {
return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ func (suite *AddressSpecSuite) assertLinkAddress(linkName, address string) error
continue
}

if linkAddress.PrefixLength != addr.Bits {
if linkAddress.PrefixLength != addr.Bits() {
continue
}

if !linkAddress.Attributes.Address.Equal(addr.IP.IPAddr().IP) {
if !linkAddress.Attributes.Address.Equal(addr.IP().IPAddr().IP) {
continue
}

Expand All @@ -121,7 +121,7 @@ func (suite *AddressSpecSuite) assertNoLinkAddress(linkName, address string) err
suite.Require().NoError(err)

for _, linkAddress := range linkAddresses {
if linkAddress.Index == uint32(iface.Index) && linkAddress.PrefixLength == addr.Bits && linkAddress.Attributes.Address.Equal(addr.IP.IPAddr().IP) {
if linkAddress.Index == uint32(iface.Index) && linkAddress.PrefixLength == addr.Bits() && linkAddress.Attributes.Address.Equal(addr.IP().IPAddr().IP) {
return retry.ExpectedError(fmt.Errorf("address %s is assigned to %q", addr, linkName))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,7 @@ func (ctrl *AddressStatusController) Run(ctx context.Context, r controller.Runti
// * local address is supplied in IFA_LOCAL attribute.

ipAddr, _ := netaddr.FromStdIPRaw(addr.Attributes.Address)
ipPrefix := netaddr.IPPrefix{
IP: ipAddr,
Bits: addr.PrefixLength,
}
ipPrefix := netaddr.IPPrefixFrom(ipAddr, addr.PrefixLength)
id := network.AddressID(linkLookup[addr.Index], ipPrefix)

if err = r.Modify(ctx, network.NewAddressStatus(network.NamespaceName, id), func(r resource.Resource) error {
Expand Down
8 changes: 5 additions & 3 deletions internal/app/machined/pkg/controllers/network/cmdline.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,15 @@ func ParseCmdlineNetwork(cmdline *procfs.Cmdline) (CmdlineNetworking, error) {

switch i {
case 0:
settings.Address.IP, err = netaddr.ParseIP(fields[0])
var ip netaddr.IP

ip, err = netaddr.ParseIP(fields[0])
if err != nil {
return settings, fmt.Errorf("cmdline address parse failure: %s", err)
}

// default is to have complete address masked
settings.Address.Bits = settings.Address.IP.BitLen()
settings.Address = netaddr.IPPrefixFrom(ip, ip.BitLen())
case 2:
settings.Gateway, err = netaddr.ParseIP(fields[2])
if err != nil {
Expand All @@ -94,7 +96,7 @@ func ParseCmdlineNetwork(cmdline *procfs.Cmdline) (CmdlineNetworking, error) {

ones, _ := net.IPMask(netmask.IPAddr().IP).Size()

settings.Address.Bits = uint8(ones)
settings.Address = netaddr.IPPrefixFrom(settings.Address.IP(), uint8(ones))
case 4:
if settings.Hostname == "" {
settings.Hostname = fields[4]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (ctrl *NodeAddressController) Run(ctx context.Context, r controller.Runtime
continue
}

ip := addr.TypedSpec().Address.IP
ip := addr.TypedSpec().Address.IP()

if ip.IsLoopback() || ip.IsMulticast() || ip.IsLinkLocalUnicast() {
continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,7 @@ func (vip *VIP) AddressSpecs() []network.AddressSpecSpec {

return []network.AddressSpecSpec{
{
Address: netaddr.IPPrefix{
IP: vip.sharedIP,
Bits: vip.sharedIP.BitLen(),
},
Address: netaddr.IPPrefixFrom(vip.sharedIP, vip.sharedIP.BitLen()),
LinkName: vip.linkName,
Family: family,
Scope: nethelpers.ScopeGlobal,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ func (ctrl *RouteConfigController) parseMachineConfiguration(logger *zap.Logger,

route.Type = nethelpers.TypeUnicast

if route.Destination.IP.IsMulticast() {
if route.Destination.IP().IsMulticast() {
route.Type = nethelpers.TypeMulticast
}

Expand Down
14 changes: 7 additions & 7 deletions internal/app/machined/pkg/controllers/network/route_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ func findRoutes(routes []rtnetlink.RouteMessage, destination netaddr.IPPrefix, g
var result []*rtnetlink.RouteMessage //nolint:prealloc

for i, route := range routes {
if route.DstLength != destination.Bits {
if route.DstLength != destination.Bits() {
continue
}

if !route.Attributes.Dst.Equal(destination.IP.IPAddr().IP) {
if !route.Attributes.Dst.Equal(destination.IP().IPAddr().IP) {
continue
}

Expand Down Expand Up @@ -197,7 +197,7 @@ func (ctrl *RouteSpecController) syncRoute(ctx context.Context, r controller.Run
existing.Protocol == uint8(route.TypedSpec().Protocol) &&
existing.Attributes.OutIface == linkIndex && existing.Attributes.Priority == route.TypedSpec().Priority &&
(route.TypedSpec().Source.IsZero() ||
existing.Attributes.Src.Equal(route.TypedSpec().Source.IP.IPAddr().IP)) {
existing.Attributes.Src.Equal(route.TypedSpec().Source.IP().IPAddr().IP)) {
matchFound = true

continue
Expand Down Expand Up @@ -235,15 +235,15 @@ func (ctrl *RouteSpecController) syncRoute(ctx context.Context, r controller.Run
// add route
msg := &rtnetlink.RouteMessage{
Family: uint8(route.TypedSpec().Family),
DstLength: route.TypedSpec().Destination.Bits,
SrcLength: route.TypedSpec().Source.Bits,
DstLength: route.TypedSpec().Destination.Bits(),
SrcLength: route.TypedSpec().Source.Bits(),
Protocol: uint8(route.TypedSpec().Protocol),
Scope: uint8(route.TypedSpec().Scope),
Type: uint8(route.TypedSpec().Type),
Flags: uint32(route.TypedSpec().Flags),
Attributes: rtnetlink.RouteAttributes{
Dst: route.TypedSpec().Destination.IP.IPAddr().IP,
Src: route.TypedSpec().Source.IP.IPAddr().IP,
Dst: route.TypedSpec().Destination.IP().IPAddr().IP,
Src: route.TypedSpec().Source.IP().IPAddr().IP,
Gateway: route.TypedSpec().Gateway.IPAddr().IP,
OutIface: linkIndex,
Priority: route.TypedSpec().Priority,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ func (suite *RouteSpecSuite) assertRoute(destination netaddr.IPPrefix, gateway n
continue
}

if route.DstLength != destination.Bits {
if route.DstLength != destination.Bits() {
continue
}

if !destination.IP.IPAddr().IP.Equal(route.Attributes.Dst) {
if !destination.IP().IPAddr().IP.Equal(route.Attributes.Dst) {
continue
}

Expand Down Expand Up @@ -124,7 +124,7 @@ func (suite *RouteSpecSuite) assertNoRoute(destination netaddr.IPPrefix, gateway
suite.Require().NoError(err)

for _, route := range routes {
if gateway.IPAddr().IP.Equal(route.Attributes.Gateway) && destination.Bits == route.DstLength && destination.IP.IPAddr().IP.Equal(route.Attributes.Dst) {
if gateway.IPAddr().IP.Equal(route.Attributes.Gateway) && destination.Bits() == route.DstLength && destination.IP().IPAddr().IP.Equal(route.Attributes.Dst) {
return retry.ExpectedError(fmt.Errorf("route to %s via %s is present", destination, gateway))
}
}
Expand Down
10 changes: 4 additions & 6 deletions internal/app/machined/pkg/controllers/network/route_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,9 @@ func (ctrl *RouteStatusController) Run(ctx context.Context, r controller.Runtime
route := route

dstAddr, _ := netaddr.FromStdIPRaw(route.Attributes.Dst)
dstPrefix := netaddr.IPPrefix{
IP: dstAddr,
Bits: route.DstLength,
}
dstPrefix := netaddr.IPPrefixFrom(dstAddr, route.DstLength)
srcAddr, _ := netaddr.FromStdIPRaw(route.Attributes.Src)
srcPrefix := netaddr.IPPrefixFrom(srcAddr, route.SrcLength)
gatewayAddr, _ := netaddr.FromStdIPRaw(route.Attributes.Gateway)
id := network.RouteID(dstPrefix, gatewayAddr)

Expand All @@ -113,8 +112,7 @@ func (ctrl *RouteStatusController) Run(ctx context.Context, r controller.Runtime

status.Family = nethelpers.Family(route.Family)
status.Destination = dstPrefix
status.Source.IP, _ = netaddr.FromStdIPRaw(route.Attributes.Src)
status.Source.Bits = route.SrcLength
status.Source = srcPrefix
status.Gateway = gatewayAddr
status.OutLinkIndex = route.Attributes.OutIface
status.OutLinkName = linkLookup[route.Attributes.OutIface]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (suite *RouteStatusSuite) TestRoutes() {
suite.Assert().NoError(retry.Constant(3*time.Second, retry.WithUnits(100*time.Millisecond)).Retry(
func() error {
return suite.assertRoutes([]string{"/127.0.0.0/8"}, func(r *network.RouteStatus) error {
suite.Assert().True(r.TypedSpec().Source.IP.IsLoopback())
suite.Assert().True(r.TypedSpec().Source.IP().IsLoopback())
suite.Assert().Equal("lo", r.TypedSpec().OutLinkName)
suite.Assert().Equal(nethelpers.TableLocal, r.TypedSpec().Table)
suite.Assert().Equal(nethelpers.ScopeHost, r.TypedSpec().Scope)
Expand Down
4 changes: 1 addition & 3 deletions pkg/machinery/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ require (
github.com/hashicorp/go-multierror v1.1.1
github.com/jsimonetti/rtnetlink v0.0.0-20210614053835-9c52e516c709
github.com/mdlayher/ethtool v0.0.0-20210210192532-2b88debcdd43
github.com/onsi/ginkgo v1.15.0 // indirect
github.com/onsi/gomega v1.10.3 // indirect
github.com/onsi/gomega v1.13.0 // indirect
github.com/opencontainers/runtime-spec v1.0.3-0.20200929063507-e6143ca7d51d
github.com/stretchr/objx v0.3.0 // indirect
github.com/stretchr/testify v1.7.0
Expand All @@ -32,6 +31,5 @@ require (
google.golang.org/grpc v1.38.0
google.golang.org/protobuf v1.26.0
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
)
Loading

0 comments on commit b5244bf

Please sign in to comment.