diff --git a/go.mod b/go.mod index be8c8029e3..bf1f3c44a1 100644 --- a/go.mod +++ b/go.mod @@ -92,7 +92,7 @@ require ( github.com/hetznercloud/hcloud-go/v2 v2.9.0 github.com/insomniacslk/dhcp v0.0.0-20240529192340-51bc6136a0a6 github.com/jeromer/syslogparser v1.1.0 - github.com/jsimonetti/rtnetlink v1.4.2 + github.com/jsimonetti/rtnetlink/v2 v2.0.2 github.com/jxskiss/base62 v1.1.0 github.com/klauspost/compress v1.17.9 github.com/klauspost/cpuid/v2 v2.2.8 @@ -147,7 +147,7 @@ require ( github.com/siderolabs/grpc-proxy v0.4.0 github.com/siderolabs/kms-client v0.1.0 github.com/siderolabs/net v0.4.0 - github.com/siderolabs/siderolink v0.3.8 + github.com/siderolabs/siderolink v0.3.9 github.com/siderolabs/talos/pkg/machinery v1.8.0-alpha.0.0.20240521134552-e1711cd3c985 github.com/spf13/cobra v1.8.0 github.com/spf13/pflag v1.0.5 diff --git a/go.sum b/go.sum index 664dc8c73e..a6e588c457 100644 --- a/go.sum +++ b/go.sum @@ -436,8 +436,8 @@ github.com/josharian/native v1.1.0 h1:uuaP0hAbW7Y4l0ZRQ6C9zfb7Mg1mbFKry/xzDAfmtL github.com/josharian/native v1.1.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w= github.com/jsimonetti/rtnetlink v0.0.0-20190606172950-9527aa82566a/go.mod h1:Oz+70psSo5OFh8DBl0Zv2ACw7Esh6pPUphlvZG9x7uw= github.com/jsimonetti/rtnetlink v0.0.0-20200117123717-f846d4f6c1f4/go.mod h1:WGuG/smIU4J/54PblvSbh+xvCZmpJnFgr3ds6Z55XMQ= -github.com/jsimonetti/rtnetlink v1.4.2 h1:Df9w9TZ3npHTyDn0Ev9e1uzmN2odmXd0QX+J5GTEn90= -github.com/jsimonetti/rtnetlink v1.4.2/go.mod h1:92s6LJdE+1iOrw+F2/RO7LYI2Qd8pPpFNNUYW06gcoM= +github.com/jsimonetti/rtnetlink/v2 v2.0.2 h1:ZKlbCujrIpp4/u3V2Ka0oxlf4BCkt6ojkvpy3nZoCBY= +github.com/jsimonetti/rtnetlink/v2 v2.0.2/go.mod h1:7MoNYNbb3UaDHtF8udiJo/RH6VsTKP1pqKLUTVCvToE= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= @@ -680,8 +680,8 @@ github.com/siderolabs/net v0.4.0 h1:1bOgVay/ijPkJz4qct98nHsiB/ysLQU0KLoBC4qLm7I= github.com/siderolabs/net v0.4.0/go.mod h1:/ibG+Hm9HU27agp5r9Q3eZicEfjquzNzQNux5uEk0kM= github.com/siderolabs/protoenc v0.2.1 h1:BqxEmeWQeMpNP3R6WrPqDatX8sM/r4t97OP8mFmg6GA= github.com/siderolabs/protoenc v0.2.1/go.mod h1:StTHxjet1g11GpNAWiATgc8K0HMKiFSEVVFOa/H0otc= -github.com/siderolabs/siderolink v0.3.8 h1:UPG7SKgWXCrCRiHfQkHZQYy0xSVSF+KitnhXYC+ofAE= -github.com/siderolabs/siderolink v0.3.8/go.mod h1:mgfFQbAB28mX88jJp/7LlWmoyMEB4CcObcdJUcdNskQ= +github.com/siderolabs/siderolink v0.3.9 h1:lvHFCu+CdfUyMk90g1Zt5r7n1Dw3jhXMxyzXmQ0776o= +github.com/siderolabs/siderolink v0.3.9/go.mod h1:QbGnXpHI5MDq6qMZkCFnxYOOw5eE+lkLx53L5ZgjLMQ= github.com/siderolabs/tcpproxy v0.1.0 h1:IbkS9vRhjMOscc1US3M5P1RnsGKFgB6U5IzUk+4WkKA= github.com/siderolabs/tcpproxy v0.1.0/go.mod h1:onn6CPPj/w1UNqQ0U97oRPF0CqbrgEApYCw4P9IiCW8= github.com/siderolabs/wgctrl-go v0.0.0-20240401105613-579af3342774 h1:wLhs5zMQVjA6LN9WpF2owOdtcoRp40zL8AaQSle+9EE= diff --git a/internal/app/machined/pkg/controllers/network/address_spec.go b/internal/app/machined/pkg/controllers/network/address_spec.go index 7bfcde82e4..3e61c0a7b2 100644 --- a/internal/app/machined/pkg/controllers/network/address_spec.go +++ b/internal/app/machined/pkg/controllers/network/address_spec.go @@ -14,7 +14,7 @@ import ( "github.com/cosi-project/runtime/pkg/controller" "github.com/cosi-project/runtime/pkg/resource" - "github.com/jsimonetti/rtnetlink" + "github.com/jsimonetti/rtnetlink/v2" "github.com/mdlayher/arp" "go.uber.org/zap" "go4.org/netipx" diff --git a/internal/app/machined/pkg/controllers/network/address_spec_test.go b/internal/app/machined/pkg/controllers/network/address_spec_test.go index ac243ce243..bc17519e3e 100644 --- a/internal/app/machined/pkg/controllers/network/address_spec_test.go +++ b/internal/app/machined/pkg/controllers/network/address_spec_test.go @@ -21,7 +21,7 @@ import ( "github.com/cosi-project/runtime/pkg/state" "github.com/cosi-project/runtime/pkg/state/impl/inmem" "github.com/cosi-project/runtime/pkg/state/impl/namespaced" - "github.com/jsimonetti/rtnetlink" + "github.com/jsimonetti/rtnetlink/v2" "github.com/siderolabs/go-retry/retry" "github.com/stretchr/testify/suite" "go.uber.org/zap/zaptest" diff --git a/internal/app/machined/pkg/controllers/network/address_status.go b/internal/app/machined/pkg/controllers/network/address_status.go index 478076fb78..303b707415 100644 --- a/internal/app/machined/pkg/controllers/network/address_status.go +++ b/internal/app/machined/pkg/controllers/network/address_status.go @@ -11,7 +11,7 @@ import ( "github.com/cosi-project/runtime/pkg/controller" "github.com/cosi-project/runtime/pkg/resource" - "github.com/jsimonetti/rtnetlink" + "github.com/jsimonetti/rtnetlink/v2" "go.uber.org/zap" "golang.org/x/sys/unix" diff --git a/internal/app/machined/pkg/controllers/network/link_spec.go b/internal/app/machined/pkg/controllers/network/link_spec.go index d79906354a..12b8d2f3fc 100644 --- a/internal/app/machined/pkg/controllers/network/link_spec.go +++ b/internal/app/machined/pkg/controllers/network/link_spec.go @@ -14,7 +14,7 @@ import ( "github.com/cosi-project/runtime/pkg/resource" "github.com/cosi-project/runtime/pkg/safe" "github.com/hashicorp/go-multierror" - "github.com/jsimonetti/rtnetlink" + "github.com/jsimonetti/rtnetlink/v2" "github.com/siderolabs/gen/pair/ordered" "github.com/siderolabs/go-pointer" "go.uber.org/zap" @@ -231,6 +231,14 @@ func (ctrl *LinkSpecController) syncLink(ctx context.Context, r controller.Runti case resource.PhaseRunning: existing := findLink(*links, link.TypedSpec().Name) + var existingRawLinkData []byte + + if existing != nil && existing.Attributes != nil && existing.Attributes.Info != nil && existing.Attributes.Info.Data != nil { + if existingLinkData, ok := existing.Attributes.Info.Data.(*rtnetlink.LinkData); ok { + existingRawLinkData = existingLinkData.Data + } + } + // check if type/kind matches for the existing logical link if existing != nil && link.TypedSpec().Logical { replace := false @@ -261,7 +269,11 @@ func (ctrl *LinkSpecController) syncLink(ctx context.Context, r controller.Runti if !replace && link.TypedSpec().Kind == network.LinkKindVLAN { var existingVLAN network.VLANSpec - if err := networkadapter.VLANSpec(&existingVLAN).Decode(existing.Attributes.Info.Data); err != nil { + if existingRawLinkData == nil { + return fmt.Errorf("existing link %q has no data, can't decode VLAN settings", link.TypedSpec().Name) + } + + if err := networkadapter.VLANSpec(&existingVLAN).Decode(existingRawLinkData); err != nil { return fmt.Errorf("error decoding VLAN properties on %q: %w", link.TypedSpec().Name, err) } @@ -326,7 +338,10 @@ func (ctrl *LinkSpecController) syncLink(ctx context.Context, r controller.Runti Type: parentIndex, Info: &rtnetlink.LinkInfo{ Kind: link.TypedSpec().Kind, - Data: data, + Data: &rtnetlink.LinkData{ + Name: link.TypedSpec().Kind, + Data: data, + }, }, }, }); err != nil { @@ -351,7 +366,11 @@ func (ctrl *LinkSpecController) syncLink(ctx context.Context, r controller.Runti if link.TypedSpec().Kind == network.LinkKindBond { var existingBond network.BondMasterSpec - if err := networkadapter.BondMasterSpec(&existingBond).Decode(existing.Attributes.Info.Data); err != nil { + if existingRawLinkData == nil { + return fmt.Errorf("existing link %q has no data, can't decode bond settings", link.TypedSpec().Name) + } + + if err := networkadapter.BondMasterSpec(&existingBond).Decode(existingRawLinkData); err != nil { return fmt.Errorf("error parsing bond attributes for %q: %w", link.TypedSpec().Name, err) } @@ -403,7 +422,10 @@ func (ctrl *LinkSpecController) syncLink(ctx context.Context, r controller.Runti Attributes: &rtnetlink.LinkAttributes{ Info: &rtnetlink.LinkInfo{ Kind: existing.Attributes.Info.Kind, - Data: data, + Data: &rtnetlink.LinkData{ + Name: existing.Attributes.Info.Kind, + Data: data, + }, }, }, }); err != nil { @@ -418,7 +440,11 @@ func (ctrl *LinkSpecController) syncLink(ctx context.Context, r controller.Runti if link.TypedSpec().Kind == network.LinkKindBridge { var existingBridge network.BridgeMasterSpec - if err := networkadapter.BridgeMasterSpec(&existingBridge).Decode(existing.Attributes.Info.Data); err != nil { + if existingRawLinkData == nil { + return fmt.Errorf("existing link %q has no data, can't decode bridge settings", link.TypedSpec().Name) + } + + if err := networkadapter.BridgeMasterSpec(&existingBridge).Decode(existingRawLinkData); err != nil { return fmt.Errorf("error parsing bridge attributes for %q: %w", link.TypedSpec().Name, err) } @@ -470,7 +496,10 @@ func (ctrl *LinkSpecController) syncLink(ctx context.Context, r controller.Runti Attributes: &rtnetlink.LinkAttributes{ Info: &rtnetlink.LinkInfo{ Kind: existing.Attributes.Info.Kind, - Data: data, + Data: &rtnetlink.LinkData{ + Name: existing.Attributes.Info.Kind, + Data: data, + }, }, }, }); err != nil { diff --git a/internal/app/machined/pkg/controllers/network/link_status.go b/internal/app/machined/pkg/controllers/network/link_status.go index 40d9cc3bb3..b34d4543e9 100644 --- a/internal/app/machined/pkg/controllers/network/link_status.go +++ b/internal/app/machined/pkg/controllers/network/link_status.go @@ -13,7 +13,7 @@ import ( "github.com/cosi-project/runtime/pkg/controller" "github.com/cosi-project/runtime/pkg/resource" - "github.com/jsimonetti/rtnetlink" + "github.com/jsimonetti/rtnetlink/v2" "github.com/mdlayher/ethtool" ethtoolioctl "github.com/safchain/ethtool" "go.uber.org/zap" @@ -297,17 +297,31 @@ func (ctrl *LinkStatusController) reconcile( status.FirmwareVersion = driverInfo.FwVersion // link.Attributes.Info will be non-nil, because we set status.Kind above using link.Attributes.Info.Kind + var rawLinkData []byte + + if link.Attributes.Info != nil && link.Attributes.Info.Data != nil { + if linkData, ok := link.Attributes.Info.Data.(*rtnetlink.LinkData); ok { + rawLinkData = linkData.Data + } + } + switch status.Kind { case network.LinkKindVLAN: - if err = networkadapter.VLANSpec(&status.VLAN).Decode(link.Attributes.Info.Data); err != nil { + if rawLinkData == nil { + logger.Warn("VLAN link data is nil", zap.String("link", link.Attributes.Name)) + } else if err = networkadapter.VLANSpec(&status.VLAN).Decode(rawLinkData); err != nil { logger.Warn("failure decoding VLAN attributes", zap.Error(err), zap.String("link", link.Attributes.Name)) } case network.LinkKindBond: - if err = networkadapter.BondMasterSpec(&status.BondMaster).Decode(link.Attributes.Info.Data); err != nil { + if rawLinkData == nil { + logger.Warn("bond link data is nil", zap.String("link", link.Attributes.Name)) + } else if err = networkadapter.BondMasterSpec(&status.BondMaster).Decode(rawLinkData); err != nil { logger.Warn("failure decoding bond attributes", zap.Error(err), zap.String("link", link.Attributes.Name)) } case network.LinkKindBridge: - if err = networkadapter.BridgeMasterSpec(&status.BridgeMaster).Decode(link.Attributes.Info.Data); err != nil { + if rawLinkData == nil { + logger.Warn("bridge link data is nil", zap.String("link", link.Attributes.Name)) + } else if err = networkadapter.BridgeMasterSpec(&status.BridgeMaster).Decode(rawLinkData); err != nil { logger.Warn("failure decoding bridge attributes", zap.Error(err), zap.String("link", link.Attributes.Name)) } case network.LinkKindWireguard: diff --git a/internal/app/machined/pkg/controllers/network/link_status_test.go b/internal/app/machined/pkg/controllers/network/link_status_test.go index c6517a543a..5cb7b1b756 100644 --- a/internal/app/machined/pkg/controllers/network/link_status_test.go +++ b/internal/app/machined/pkg/controllers/network/link_status_test.go @@ -22,7 +22,7 @@ import ( "github.com/cosi-project/runtime/pkg/state" "github.com/cosi-project/runtime/pkg/state/impl/inmem" "github.com/cosi-project/runtime/pkg/state/impl/namespaced" - "github.com/jsimonetti/rtnetlink" + "github.com/jsimonetti/rtnetlink/v2" "github.com/mdlayher/netlink" "github.com/siderolabs/go-retry/retry" "github.com/stretchr/testify/suite" @@ -317,7 +317,10 @@ func (suite *LinkStatusSuite) TestBridgeInterface() { Name: bridgeInterface, Info: &rtnetlink.LinkInfo{ Kind: "bridge", - Data: bridgeData, + Data: &rtnetlink.LinkData{ + Name: "bridge", + Data: bridgeData, + }, }, }, }, diff --git a/internal/app/machined/pkg/controllers/network/nftables_chain_test.go b/internal/app/machined/pkg/controllers/network/nftables_chain_test.go index 9ac7d96dd2..8d87c9b8ab 100644 --- a/internal/app/machined/pkg/controllers/network/nftables_chain_test.go +++ b/internal/app/machined/pkg/controllers/network/nftables_chain_test.go @@ -155,7 +155,7 @@ func (s *NfTablesChainSuite) TestICMPLimit() { s.checkNftOutput(`table inet talos-test { chain test1 { type filter hook input priority security; policy accept; - meta l4proto icmp limit rate 5/second accept + meta l4proto icmp limit rate 5/second burst 5 packets accept } }`) } diff --git a/internal/app/machined/pkg/controllers/network/operator/dhcp6.go b/internal/app/machined/pkg/controllers/network/operator/dhcp6.go index 9be946a6c0..e1d8d68a12 100644 --- a/internal/app/machined/pkg/controllers/network/operator/dhcp6.go +++ b/internal/app/machined/pkg/controllers/network/operator/dhcp6.go @@ -17,7 +17,7 @@ import ( "github.com/insomniacslk/dhcp/dhcpv6" "github.com/insomniacslk/dhcp/dhcpv6/nclient6" - "github.com/jsimonetti/rtnetlink" + "github.com/jsimonetti/rtnetlink/v2" "github.com/siderolabs/gen/xslices" "github.com/siderolabs/go-retry/retry" "go.uber.org/zap" diff --git a/internal/app/machined/pkg/controllers/network/route_spec.go b/internal/app/machined/pkg/controllers/network/route_spec.go index 5aecb1eca3..a39caf3f57 100644 --- a/internal/app/machined/pkg/controllers/network/route_spec.go +++ b/internal/app/machined/pkg/controllers/network/route_spec.go @@ -12,7 +12,7 @@ import ( "github.com/cosi-project/runtime/pkg/controller" "github.com/cosi-project/runtime/pkg/resource" "github.com/hashicorp/go-multierror" - "github.com/jsimonetti/rtnetlink" + "github.com/jsimonetti/rtnetlink/v2" "github.com/siderolabs/gen/value" "go.uber.org/zap" "golang.org/x/sys/unix" diff --git a/internal/app/machined/pkg/controllers/network/route_spec_test.go b/internal/app/machined/pkg/controllers/network/route_spec_test.go index 2757a19e9c..1a9a5d8883 100644 --- a/internal/app/machined/pkg/controllers/network/route_spec_test.go +++ b/internal/app/machined/pkg/controllers/network/route_spec_test.go @@ -20,7 +20,7 @@ import ( "github.com/cosi-project/runtime/pkg/state" "github.com/cosi-project/runtime/pkg/state/impl/inmem" "github.com/cosi-project/runtime/pkg/state/impl/namespaced" - "github.com/jsimonetti/rtnetlink" + "github.com/jsimonetti/rtnetlink/v2" "github.com/siderolabs/go-retry/retry" "github.com/stretchr/testify/suite" "go.uber.org/zap/zaptest" diff --git a/internal/app/machined/pkg/controllers/network/route_status.go b/internal/app/machined/pkg/controllers/network/route_status.go index 9167bca294..908c5077b8 100644 --- a/internal/app/machined/pkg/controllers/network/route_status.go +++ b/internal/app/machined/pkg/controllers/network/route_status.go @@ -11,7 +11,7 @@ import ( "github.com/cosi-project/runtime/pkg/controller" "github.com/cosi-project/runtime/pkg/resource" - "github.com/jsimonetti/rtnetlink" + "github.com/jsimonetti/rtnetlink/v2" "go.uber.org/zap" "golang.org/x/sys/unix" diff --git a/internal/app/machined/pkg/controllers/network/watch/rtnetlink.go b/internal/app/machined/pkg/controllers/network/watch/rtnetlink.go index 3d2149005a..af72def70e 100644 --- a/internal/app/machined/pkg/controllers/network/watch/rtnetlink.go +++ b/internal/app/machined/pkg/controllers/network/watch/rtnetlink.go @@ -8,7 +8,7 @@ import ( "fmt" "sync" - "github.com/jsimonetti/rtnetlink" + "github.com/jsimonetti/rtnetlink/v2" "github.com/mdlayher/netlink" ) diff --git a/pkg/machinery/go.mod b/pkg/machinery/go.mod index 0a76393266..bcabfbcb0b 100644 --- a/pkg/machinery/go.mod +++ b/pkg/machinery/go.mod @@ -15,7 +15,7 @@ require ( github.com/evanphx/json-patch v5.9.0+incompatible github.com/ghodss/yaml v1.0.0 github.com/hashicorp/go-multierror v1.1.1 - github.com/jsimonetti/rtnetlink v1.4.2 + github.com/jsimonetti/rtnetlink/v2 v2.0.2 github.com/mdlayher/ethtool v0.1.0 github.com/opencontainers/runtime-spec v1.2.0 github.com/planetscale/vtprotobuf v0.6.0 diff --git a/pkg/machinery/go.sum b/pkg/machinery/go.sum index 1e16593aa7..2ecb576741 100644 --- a/pkg/machinery/go.sum +++ b/pkg/machinery/go.sum @@ -56,8 +56,8 @@ github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+l github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/josharian/native v1.1.0 h1:uuaP0hAbW7Y4l0ZRQ6C9zfb7Mg1mbFKry/xzDAfmtLA= github.com/josharian/native v1.1.0/go.mod h1:7X/raswPFr05uY3HiLlYeyQntB6OO7E/d2Cu7qoaN2w= -github.com/jsimonetti/rtnetlink v1.4.2 h1:Df9w9TZ3npHTyDn0Ev9e1uzmN2odmXd0QX+J5GTEn90= -github.com/jsimonetti/rtnetlink v1.4.2/go.mod h1:92s6LJdE+1iOrw+F2/RO7LYI2Qd8pPpFNNUYW06gcoM= +github.com/jsimonetti/rtnetlink/v2 v2.0.2 h1:ZKlbCujrIpp4/u3V2Ka0oxlf4BCkt6ojkvpy3nZoCBY= +github.com/jsimonetti/rtnetlink/v2 v2.0.2/go.mod h1:7MoNYNbb3UaDHtF8udiJo/RH6VsTKP1pqKLUTVCvToE= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= diff --git a/pkg/machinery/nethelpers/operstate.go b/pkg/machinery/nethelpers/operstate.go index 3ef00414ec..127e2338bc 100644 --- a/pkg/machinery/nethelpers/operstate.go +++ b/pkg/machinery/nethelpers/operstate.go @@ -5,7 +5,7 @@ package nethelpers import ( - "github.com/jsimonetti/rtnetlink" + "github.com/jsimonetti/rtnetlink/v2" ) // OperationalState wraps rtnetlink.OperationalState for YAML marshaling. diff --git a/pkg/provision/providers/vm/network.go b/pkg/provision/providers/vm/network.go index b9d13cf799..56765eb87e 100644 --- a/pkg/provision/providers/vm/network.go +++ b/pkg/provision/providers/vm/network.go @@ -21,7 +21,7 @@ import ( "github.com/containernetworking/plugins/pkg/testutils" "github.com/coreos/go-iptables/iptables" "github.com/google/uuid" - "github.com/jsimonetti/rtnetlink" + "github.com/jsimonetti/rtnetlink/v2" "github.com/siderolabs/gen/xslices" sideronet "github.com/siderolabs/net" "github.com/vishvananda/netlink"