mirror of
https://github.com/siderolabs/talos.git
synced 2025-10-19 19:41:16 +02:00
chore: make nethelpers build on all OSes
Related to #4420 This removes `linux` build tags to make sure all `nethelpers` build on any OS, as it's part of Talos API (via resources). Constants were replaced with literal values. Code generated by `stringer` serves as proof of the change: constant values haven't changed. Remove build tags from `pkgs/resources/network` now, marking only a part of single file `_linux` (which converts link spec to low-level netlink messages). Theere should be no functional changes. Signed-off-by: Andrey Smirnov <andrey.smirnov@talos-systems.com>
This commit is contained in:
parent
5b5dd49f64
commit
205a8d6dc4
@ -23,7 +23,6 @@ require (
|
|||||||
github.com/talos-systems/go-blockdevice v0.2.4
|
github.com/talos-systems/go-blockdevice v0.2.4
|
||||||
github.com/talos-systems/go-debug v0.2.1
|
github.com/talos-systems/go-debug v0.2.1
|
||||||
github.com/talos-systems/net v0.3.0
|
github.com/talos-systems/net v0.3.0
|
||||||
golang.org/x/sys v0.0.0-20211023085530-d6a326fbbf70
|
|
||||||
google.golang.org/genproto v0.0.0-20211021150943-2b146023228c
|
google.golang.org/genproto v0.0.0-20211021150943-2b146023228c
|
||||||
google.golang.org/grpc v1.41.0
|
google.golang.org/grpc v1.41.0
|
||||||
google.golang.org/protobuf v1.27.1
|
google.golang.org/protobuf v1.27.1
|
||||||
@ -44,6 +43,7 @@ require (
|
|||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
github.com/ryanuber/go-glob v1.0.0 // indirect
|
github.com/ryanuber/go-glob v1.0.0 // indirect
|
||||||
golang.org/x/net v0.0.0-20210525063256-abc453219eb5 // indirect
|
golang.org/x/net v0.0.0-20210525063256-abc453219eb5 // indirect
|
||||||
|
golang.org/x/sys v0.0.0-20211023085530-d6a326fbbf70 // indirect
|
||||||
golang.org/x/text v0.3.6 // indirect
|
golang.org/x/text v0.3.6 // indirect
|
||||||
gopkg.in/yaml.v2 v2.3.0 // indirect
|
gopkg.in/yaml.v2 v2.3.0 // indirect
|
||||||
)
|
)
|
||||||
|
50
pkg/machinery/nethelpers/address_flags.go
Normal file
50
pkg/machinery/nethelpers/address_flags.go
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
package nethelpers
|
||||||
|
|
||||||
|
//go:generate stringer -type=AddressFlag -linecomment
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AddressFlags is a bitmask of AddressFlag.
|
||||||
|
type AddressFlags uint32
|
||||||
|
|
||||||
|
func (flags AddressFlags) String() string {
|
||||||
|
var values []string
|
||||||
|
|
||||||
|
for flag := AddressTemporary; flag <= AddressStablePrivacy; flag <<= 1 {
|
||||||
|
if (AddressFlag(flags) & flag) == flag {
|
||||||
|
values = append(values, flag.String())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return strings.Join(values, ",")
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalYAML implements yaml.Marshaler.
|
||||||
|
func (flags AddressFlags) MarshalYAML() (interface{}, error) {
|
||||||
|
return flags.String(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddressFlag wraps IFF_* constants.
|
||||||
|
type AddressFlag uint32
|
||||||
|
|
||||||
|
// AddressFlag constants.
|
||||||
|
const (
|
||||||
|
AddressTemporary AddressFlag = 1 << iota // temporary
|
||||||
|
AddressNoDAD // nodad
|
||||||
|
AddressOptimistic // optimistic
|
||||||
|
AddressDADFailed // dadfailed
|
||||||
|
AddressHome // homeaddress
|
||||||
|
AddressDeprecated // deprecated
|
||||||
|
AddressTentative // tentative
|
||||||
|
AddressPermanent // permanent
|
||||||
|
AddressManagementTemp // mngmtmpaddr
|
||||||
|
AddressNoPrefixRoute // noprefixroute
|
||||||
|
AddressMCAutoJoin // mcautojoin
|
||||||
|
AddressStablePrivacy // stableprivacy
|
||||||
|
)
|
@ -1,52 +0,0 @@
|
|||||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
package nethelpers
|
|
||||||
|
|
||||||
//go:generate stringer -type=AddressFlag -linecomment -output addressflag_string_linux.go
|
|
||||||
|
|
||||||
import (
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"golang.org/x/sys/unix"
|
|
||||||
)
|
|
||||||
|
|
||||||
// AddressFlags is a bitmask of AddressFlag.
|
|
||||||
type AddressFlags uint32
|
|
||||||
|
|
||||||
func (flags AddressFlags) String() string {
|
|
||||||
var values []string
|
|
||||||
|
|
||||||
for flag := AddressTemporary; flag <= AddressStablePrivacy; flag <<= 1 {
|
|
||||||
if (AddressFlag(flags) & flag) == flag {
|
|
||||||
values = append(values, flag.String())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return strings.Join(values, ",")
|
|
||||||
}
|
|
||||||
|
|
||||||
// MarshalYAML implements yaml.Marshaler.
|
|
||||||
func (flags AddressFlags) MarshalYAML() (interface{}, error) {
|
|
||||||
return flags.String(), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// AddressFlag wraps IFF_* constants.
|
|
||||||
type AddressFlag uint32
|
|
||||||
|
|
||||||
// AddressFlag constants.
|
|
||||||
const (
|
|
||||||
AddressTemporary AddressFlag = unix.IFA_F_TEMPORARY // temporary
|
|
||||||
AddressNoDAD AddressFlag = unix.IFA_F_NODAD // nodad
|
|
||||||
AddressOptimistic AddressFlag = unix.IFA_F_OPTIMISTIC // optimistic
|
|
||||||
AddressDADFailed AddressFlag = unix.IFA_F_DADFAILED // dadfailed
|
|
||||||
AddressHome AddressFlag = unix.IFA_F_HOMEADDRESS // homeaddress
|
|
||||||
AddressDeprecated AddressFlag = unix.IFA_F_DEPRECATED // deprecated
|
|
||||||
AddressTentative AddressFlag = unix.IFA_F_TENTATIVE // tentative
|
|
||||||
AddressPermanent AddressFlag = unix.IFA_F_PERMANENT // permanent
|
|
||||||
AddressManagementTemp AddressFlag = unix.IFA_F_MANAGETEMPADDR // mngmtmpaddr
|
|
||||||
AddressNoPrefixRoute AddressFlag = unix.IFA_F_NOPREFIXROUTE // noprefixroute
|
|
||||||
AddressMCAutoJoin AddressFlag = unix.IFA_F_MCAUTOJOIN // mcautojoin
|
|
||||||
AddressStablePrivacy AddressFlag = unix.IFA_F_STABLE_PRIVACY // stableprivacy
|
|
||||||
)
|
|
@ -1,4 +1,4 @@
|
|||||||
// Code generated by "stringer -type=AddressFlag -linecomment -output addressflag_string_linux.go"; DO NOT EDIT.
|
// Code generated by "stringer -type=AddressFlag -linecomment"; DO NOT EDIT.
|
||||||
|
|
||||||
package nethelpers
|
package nethelpers
|
||||||
|
|
@ -4,9 +4,7 @@
|
|||||||
|
|
||||||
package nethelpers
|
package nethelpers
|
||||||
|
|
||||||
import "golang.org/x/sys/unix"
|
//go:generate stringer -type=Family -linecomment
|
||||||
|
|
||||||
//go:generate stringer -type=Family -linecomment -output family_string_linux.go
|
|
||||||
|
|
||||||
// Family is a network family.
|
// Family is a network family.
|
||||||
type Family uint8
|
type Family uint8
|
||||||
@ -18,6 +16,6 @@ func (family Family) MarshalYAML() (interface{}, error) {
|
|||||||
|
|
||||||
// Family constants.
|
// Family constants.
|
||||||
const (
|
const (
|
||||||
FamilyInet4 Family = unix.AF_INET // inet4
|
FamilyInet4 Family = 2 // inet4
|
||||||
FamilyInet6 Family = unix.AF_INET6 // inet6
|
FamilyInet6 Family = 10 // inet6
|
||||||
)
|
)
|
@ -1,4 +1,4 @@
|
|||||||
// Code generated by "stringer -type=Family -linecomment -output family_string_linux.go"; DO NOT EDIT.
|
// Code generated by "stringer -type=Family -linecomment"; DO NOT EDIT.
|
||||||
|
|
||||||
package nethelpers
|
package nethelpers
|
||||||
|
|
57
pkg/machinery/nethelpers/linkflag.go
Normal file
57
pkg/machinery/nethelpers/linkflag.go
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
package nethelpers
|
||||||
|
|
||||||
|
//go:generate stringer -type=LinkFlag -linecomment
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// LinkFlags is a bitmask of LinkFlags.
|
||||||
|
type LinkFlags uint32
|
||||||
|
|
||||||
|
func (flags LinkFlags) String() string {
|
||||||
|
var values []string
|
||||||
|
|
||||||
|
for flag := LinkUp; flag <= LinkEcho; flag <<= 1 {
|
||||||
|
if (LinkFlag(flags) & flag) == flag {
|
||||||
|
values = append(values, flag.String())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return strings.Join(values, ",")
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalYAML implements yaml.Marshaler.
|
||||||
|
func (flags LinkFlags) MarshalYAML() (interface{}, error) {
|
||||||
|
return flags.String(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// LinkFlag wraps IFF_* constants.
|
||||||
|
type LinkFlag uint32
|
||||||
|
|
||||||
|
// LinkFlag constants.
|
||||||
|
const (
|
||||||
|
LinkUp LinkFlag = 1 << iota // UP
|
||||||
|
LinkBroadcast // BROADCAST
|
||||||
|
LinkDebug // DEBUG
|
||||||
|
LinkLoopback // LOOPBACK
|
||||||
|
LinkPointToPoint // POINTTOPOINT
|
||||||
|
LinkNoTrailers // NOTRAILERS
|
||||||
|
LinkRunning // RUNNING
|
||||||
|
LinkNoArp // NOARP
|
||||||
|
LinkPromisc // PROMISC
|
||||||
|
LinkAllMulti // ALLMULTI
|
||||||
|
LinkMaster // MASTER
|
||||||
|
LinkSlave // SLAVE
|
||||||
|
LinkMulticase // MULTICAST
|
||||||
|
LinkPortsel // PORTSEL
|
||||||
|
LinKAutoMedia // AUTOMEDIA
|
||||||
|
LinkDynamic // DYNAMIC
|
||||||
|
LinkLowerUp // LOWER_UP
|
||||||
|
LinkDormant // DORMANT
|
||||||
|
LinkEcho // ECHO
|
||||||
|
)
|
@ -1,59 +0,0 @@
|
|||||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
package nethelpers
|
|
||||||
|
|
||||||
//go:generate stringer -type=LinkFlag -linecomment -output linkflag_string_linux.go
|
|
||||||
|
|
||||||
import (
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"golang.org/x/sys/unix"
|
|
||||||
)
|
|
||||||
|
|
||||||
// LinkFlags is a bitmask of LinkFlags.
|
|
||||||
type LinkFlags uint32
|
|
||||||
|
|
||||||
func (flags LinkFlags) String() string {
|
|
||||||
var values []string
|
|
||||||
|
|
||||||
for flag := LinkUp; flag <= LinkEcho; flag <<= 1 {
|
|
||||||
if (LinkFlag(flags) & flag) == flag {
|
|
||||||
values = append(values, flag.String())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return strings.Join(values, ",")
|
|
||||||
}
|
|
||||||
|
|
||||||
// MarshalYAML implements yaml.Marshaler.
|
|
||||||
func (flags LinkFlags) MarshalYAML() (interface{}, error) {
|
|
||||||
return flags.String(), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// LinkFlag wraps IFF_* constants.
|
|
||||||
type LinkFlag uint32
|
|
||||||
|
|
||||||
// LinkFlag constants.
|
|
||||||
const (
|
|
||||||
LinkUp LinkFlag = unix.IFF_UP // UP
|
|
||||||
LinkBroadcast LinkFlag = unix.IFF_BROADCAST // BROADCAST
|
|
||||||
LinkDebug LinkFlag = unix.IFF_DEBUG // DEBUG
|
|
||||||
LinkLoopback LinkFlag = unix.IFF_LOOPBACK // LOOPBACK
|
|
||||||
LinkPointToPoint LinkFlag = unix.IFF_POINTOPOINT // POINTTOPOINT
|
|
||||||
LinkRunning LinkFlag = unix.IFF_RUNNING // RUNNING
|
|
||||||
LinkNoArp LinkFlag = unix.IFF_NOARP // NOARP
|
|
||||||
LinkPromisc LinkFlag = unix.IFF_PROMISC // PROMISC
|
|
||||||
LinkNoTrailers LinkFlag = unix.IFF_NOTRAILERS // NOTRAILERS
|
|
||||||
LinkAllMulti LinkFlag = unix.IFF_ALLMULTI // ALLMULTI
|
|
||||||
LinkMaster LinkFlag = unix.IFF_MASTER // MASTER
|
|
||||||
LinkSlave LinkFlag = unix.IFF_SLAVE // SLAVE
|
|
||||||
LinkMulticase LinkFlag = unix.IFF_MULTICAST // MULTICAST
|
|
||||||
LinkPortsel LinkFlag = unix.IFF_PORTSEL // PORTSEL
|
|
||||||
LinKAutoMedia LinkFlag = unix.IFF_AUTOMEDIA // AUTOMEDIA
|
|
||||||
LinkDynamic LinkFlag = unix.IFF_DYNAMIC // DYNAMIC
|
|
||||||
LinkLowerUp LinkFlag = unix.IFF_LOWER_UP // LOWER_UP
|
|
||||||
LinkDormant LinkFlag = unix.IFF_DORMANT // DORMANT
|
|
||||||
LinkEcho LinkFlag = unix.IFF_ECHO // ECHO
|
|
||||||
)
|
|
@ -1,4 +1,4 @@
|
|||||||
// Code generated by "stringer -type=LinkFlag -linecomment -output linkflag_string_linux.go"; DO NOT EDIT.
|
// Code generated by "stringer -type=LinkFlag -linecomment"; DO NOT EDIT.
|
||||||
|
|
||||||
package nethelpers
|
package nethelpers
|
||||||
|
|
||||||
@ -13,10 +13,10 @@ func _() {
|
|||||||
_ = x[LinkDebug-4]
|
_ = x[LinkDebug-4]
|
||||||
_ = x[LinkLoopback-8]
|
_ = x[LinkLoopback-8]
|
||||||
_ = x[LinkPointToPoint-16]
|
_ = x[LinkPointToPoint-16]
|
||||||
|
_ = x[LinkNoTrailers-32]
|
||||||
_ = x[LinkRunning-64]
|
_ = x[LinkRunning-64]
|
||||||
_ = x[LinkNoArp-128]
|
_ = x[LinkNoArp-128]
|
||||||
_ = x[LinkPromisc-256]
|
_ = x[LinkPromisc-256]
|
||||||
_ = x[LinkNoTrailers-32]
|
|
||||||
_ = x[LinkAllMulti-512]
|
_ = x[LinkAllMulti-512]
|
||||||
_ = x[LinkMaster-1024]
|
_ = x[LinkMaster-1024]
|
||||||
_ = x[LinkSlave-2048]
|
_ = x[LinkSlave-2048]
|
96
pkg/machinery/nethelpers/linktype.go
Normal file
96
pkg/machinery/nethelpers/linktype.go
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
package nethelpers
|
||||||
|
|
||||||
|
//go:generate stringer -type=LinkType -linecomment
|
||||||
|
|
||||||
|
// LinkType is a link type.
|
||||||
|
type LinkType uint16
|
||||||
|
|
||||||
|
// MarshalYAML implements yaml.Marshaler.
|
||||||
|
func (typ LinkType) MarshalYAML() (interface{}, error) {
|
||||||
|
return typ.String(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// LinkType constants.
|
||||||
|
const (
|
||||||
|
LinkNetrom LinkType = 0 // netrom
|
||||||
|
LinkEther LinkType = 1 // ether
|
||||||
|
LinkEether LinkType = 2 // eether
|
||||||
|
LinkAx25 LinkType = 3 // ax25
|
||||||
|
LinkPronet LinkType = 4 // pronet
|
||||||
|
LinkChaos LinkType = 5 // chaos
|
||||||
|
LinkIee802 LinkType = 6 // ieee802
|
||||||
|
LinkArcnet LinkType = 7 // arcnet
|
||||||
|
LinkAtalk LinkType = 8 // atalk
|
||||||
|
LinkDlci LinkType = 15 // dlci
|
||||||
|
LinkAtm LinkType = 19 // atm
|
||||||
|
LinkMetricom LinkType = 23 // metricom
|
||||||
|
LinkIeee1394 LinkType = 24 // ieee1394
|
||||||
|
LinkEui64 LinkType = 27 // eui64
|
||||||
|
LinkInfiniband LinkType = 32 // infiniband
|
||||||
|
LinkSlip LinkType = 256 // slip
|
||||||
|
LinkCslip LinkType = 257 // cslip
|
||||||
|
LinkSlip6 LinkType = 258 // slip6
|
||||||
|
LinkCslip6 LinkType = 259 // cslip6
|
||||||
|
LinkRsrvd LinkType = 260 // rsrvd
|
||||||
|
LinkAdapt LinkType = 264 // adapt
|
||||||
|
LinkRose LinkType = 270 // rose
|
||||||
|
LinkX25 LinkType = 271 // x25
|
||||||
|
LinkHwx25 LinkType = 272 // hwx25
|
||||||
|
LinkCan LinkType = 280 // can
|
||||||
|
LinkPpp LinkType = 512 // ppp
|
||||||
|
LinkCisco LinkType = 513 // cisco
|
||||||
|
LinkHdlc LinkType = 513 // hdlc
|
||||||
|
LinkLapb LinkType = 516 // lapb
|
||||||
|
LinkDdcmp LinkType = 517 // ddcmp
|
||||||
|
LinkRawhdlc LinkType = 518 // rawhdlc
|
||||||
|
LinkTunnel LinkType = 768 // ipip
|
||||||
|
LinkTunnel6 LinkType = 769 // tunnel6
|
||||||
|
LinkFrad LinkType = 770 // frad
|
||||||
|
LinkSkip LinkType = 771 // skip
|
||||||
|
LinkLoopbck LinkType = 772 // loopback
|
||||||
|
LinkLocaltlk LinkType = 773 // localtlk
|
||||||
|
LinkFddi LinkType = 774 // fddi
|
||||||
|
LinkBif LinkType = 775 // bif
|
||||||
|
LinkSit LinkType = 776 // sit
|
||||||
|
LinkIpddp LinkType = 777 // ip/ddp
|
||||||
|
LinkIpgre LinkType = 778 // gre
|
||||||
|
LinkPimreg LinkType = 779 // pimreg
|
||||||
|
LinkHippi LinkType = 780 // hippi
|
||||||
|
LinkAsh LinkType = 781 // ash
|
||||||
|
LinkEconet LinkType = 782 // econet
|
||||||
|
LinkIrda LinkType = 783 // irda
|
||||||
|
LinkFcpp LinkType = 784 // fcpp
|
||||||
|
LinkFcal LinkType = 785 // fcal
|
||||||
|
LinkFcpl LinkType = 786 // fcpl
|
||||||
|
LinkFcfabric LinkType = 787 // fcfb_0
|
||||||
|
LinkFcfabric1 LinkType = LinkFcfabric + 1 // fcfb_1
|
||||||
|
LinkFcfabric2 LinkType = LinkFcfabric + 2 // fcfb_2
|
||||||
|
LinkFcfabric3 LinkType = LinkFcfabric + 3 // fcfb_3
|
||||||
|
LinkFcfabric4 LinkType = LinkFcfabric + 4 // fcfb_4
|
||||||
|
LinkFcfabric5 LinkType = LinkFcfabric + 5 // fcfb_5
|
||||||
|
LinkFcfabric6 LinkType = LinkFcfabric + 6 // fcfb_6
|
||||||
|
LinkFcfabric7 LinkType = LinkFcfabric + 7 // fcfb_7
|
||||||
|
LinkFcfabric8 LinkType = LinkFcfabric + 8 // fcfb_8
|
||||||
|
LinkFcfabric9 LinkType = LinkFcfabric + 9 // fcfb_9
|
||||||
|
LinkFcfabric10 LinkType = LinkFcfabric + 10 // fcfb_10
|
||||||
|
LinkFcfabric11 LinkType = LinkFcfabric + 11 // fcfb_11
|
||||||
|
LinkFcfabric12 LinkType = LinkFcfabric + 12 // fcfb_12
|
||||||
|
LinkIee802tr LinkType = 800 // tr
|
||||||
|
LinkIee80211 LinkType = 801 // ieee802.11
|
||||||
|
LinkIee80211prism LinkType = 802 // ieee802.11_prism
|
||||||
|
LinkIee80211Radiotap LinkType = 803 // ieee802.11_radiotap
|
||||||
|
LinkIee8021154 LinkType = 804 // ieee802.15.4
|
||||||
|
LinkIee8021154monitor LinkType = 805 // ieee802.15.4_monitor
|
||||||
|
LinkPhonet LinkType = 820 // phonet
|
||||||
|
LinkPhonetpipe LinkType = 821 // phonet_pipe
|
||||||
|
LinkCaif LinkType = 822 // caif
|
||||||
|
LinkIP6gre LinkType = 823 // ip6gre
|
||||||
|
LinkNetlink LinkType = 824 // netlink
|
||||||
|
Link6Lowpan LinkType = 825 // 6lowpan
|
||||||
|
LinkVoid LinkType = 65535 // void
|
||||||
|
LinkNone LinkType = 65534 // nohdr
|
||||||
|
)
|
@ -1,98 +0,0 @@
|
|||||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
package nethelpers
|
|
||||||
|
|
||||||
import "golang.org/x/sys/unix"
|
|
||||||
|
|
||||||
//go:generate stringer -type=LinkType -linecomment -output linktype_string_linux.go
|
|
||||||
|
|
||||||
// LinkType is a link type.
|
|
||||||
type LinkType uint16
|
|
||||||
|
|
||||||
// MarshalYAML implements yaml.Marshaler.
|
|
||||||
func (typ LinkType) MarshalYAML() (interface{}, error) {
|
|
||||||
return typ.String(), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// LinkType constants.
|
|
||||||
const (
|
|
||||||
LinkNetrom LinkType = unix.ARPHRD_NETROM // netrom
|
|
||||||
LinkEther LinkType = unix.ARPHRD_ETHER // ether
|
|
||||||
LinkEether LinkType = unix.ARPHRD_EETHER // eether
|
|
||||||
LinkAx25 LinkType = unix.ARPHRD_AX25 // ax25
|
|
||||||
LinkPronet LinkType = unix.ARPHRD_PRONET // pronet
|
|
||||||
LinkChaos LinkType = unix.ARPHRD_CHAOS // chaos
|
|
||||||
LinkIee802 LinkType = unix.ARPHRD_IEEE802 // ieee802
|
|
||||||
LinkArcnet LinkType = unix.ARPHRD_ARCNET // arcnet
|
|
||||||
LinkAtalk LinkType = unix.ARPHRD_APPLETLK // atalk
|
|
||||||
LinkDlci LinkType = unix.ARPHRD_DLCI // dlci
|
|
||||||
LinkAtm LinkType = unix.ARPHRD_ATM // atm
|
|
||||||
LinkMetricom LinkType = unix.ARPHRD_METRICOM // metricom
|
|
||||||
LinkIeee1394 LinkType = unix.ARPHRD_IEEE1394 // ieee1394
|
|
||||||
LinkEui64 LinkType = unix.ARPHRD_EUI64 // eui64
|
|
||||||
LinkInfiniband LinkType = unix.ARPHRD_INFINIBAND // infiniband
|
|
||||||
LinkSlip LinkType = unix.ARPHRD_SLIP // slip
|
|
||||||
LinkCslip LinkType = unix.ARPHRD_CSLIP // cslip
|
|
||||||
LinkSlip6 LinkType = unix.ARPHRD_SLIP6 // slip6
|
|
||||||
LinkCslip6 LinkType = unix.ARPHRD_CSLIP6 // cslip6
|
|
||||||
LinkRsrvd LinkType = unix.ARPHRD_RSRVD // rsrvd
|
|
||||||
LinkAdapt LinkType = unix.ARPHRD_ADAPT // adapt
|
|
||||||
LinkRose LinkType = unix.ARPHRD_ROSE // rose
|
|
||||||
LinkX25 LinkType = unix.ARPHRD_X25 // x25
|
|
||||||
LinkHwx25 LinkType = unix.ARPHRD_HWX25 // hwx25
|
|
||||||
LinkCan LinkType = unix.ARPHRD_CAN // can
|
|
||||||
LinkPpp LinkType = unix.ARPHRD_PPP // ppp
|
|
||||||
LinkCisco LinkType = unix.ARPHRD_CISCO // cisco
|
|
||||||
LinkHdlc LinkType = unix.ARPHRD_HDLC // hdlc
|
|
||||||
LinkLapb LinkType = unix.ARPHRD_LAPB // lapb
|
|
||||||
LinkDdcmp LinkType = unix.ARPHRD_DDCMP // ddcmp
|
|
||||||
LinkRawhdlc LinkType = unix.ARPHRD_RAWHDLC // rawhdlc
|
|
||||||
LinkTunnel LinkType = unix.ARPHRD_TUNNEL // ipip
|
|
||||||
LinkTunnel6 LinkType = unix.ARPHRD_TUNNEL6 // tunnel6
|
|
||||||
LinkFrad LinkType = unix.ARPHRD_FRAD // frad
|
|
||||||
LinkSkip LinkType = unix.ARPHRD_SKIP // skip
|
|
||||||
LinkLoopbck LinkType = unix.ARPHRD_LOOPBACK // loopback
|
|
||||||
LinkLocaltlk LinkType = unix.ARPHRD_LOCALTLK // localtlk
|
|
||||||
LinkFddi LinkType = unix.ARPHRD_FDDI // fddi
|
|
||||||
LinkBif LinkType = unix.ARPHRD_BIF // bif
|
|
||||||
LinkSit LinkType = unix.ARPHRD_SIT // sit
|
|
||||||
LinkIpddp LinkType = unix.ARPHRD_IPDDP // ip/ddp
|
|
||||||
LinkIpgre LinkType = unix.ARPHRD_IPGRE // gre
|
|
||||||
LinkPimreg LinkType = unix.ARPHRD_PIMREG // pimreg
|
|
||||||
LinkHippi LinkType = unix.ARPHRD_HIPPI // hippi
|
|
||||||
LinkAsh LinkType = unix.ARPHRD_ASH // ash
|
|
||||||
LinkEconet LinkType = unix.ARPHRD_ECONET // econet
|
|
||||||
LinkIrda LinkType = unix.ARPHRD_IRDA // irda
|
|
||||||
LinkFcpp LinkType = unix.ARPHRD_FCPP // fcpp
|
|
||||||
LinkFcal LinkType = unix.ARPHRD_FCAL // fcal
|
|
||||||
LinkFcpl LinkType = unix.ARPHRD_FCPL // fcpl
|
|
||||||
LinkFcfabric LinkType = unix.ARPHRD_FCFABRIC // fcfb_0
|
|
||||||
LinkFcfabric1 LinkType = unix.ARPHRD_FCFABRIC + 1 // fcfb_1
|
|
||||||
LinkFcfabric2 LinkType = unix.ARPHRD_FCFABRIC + 2 // fcfb_2
|
|
||||||
LinkFcfabric3 LinkType = unix.ARPHRD_FCFABRIC + 3 // fcfb_3
|
|
||||||
LinkFcfabric4 LinkType = unix.ARPHRD_FCFABRIC + 4 // fcfb_4
|
|
||||||
LinkFcfabric5 LinkType = unix.ARPHRD_FCFABRIC + 5 // fcfb_5
|
|
||||||
LinkFcfabric6 LinkType = unix.ARPHRD_FCFABRIC + 6 // fcfb_6
|
|
||||||
LinkFcfabric7 LinkType = unix.ARPHRD_FCFABRIC + 7 // fcfb_7
|
|
||||||
LinkFcfabric8 LinkType = unix.ARPHRD_FCFABRIC + 8 // fcfb_8
|
|
||||||
LinkFcfabric9 LinkType = unix.ARPHRD_FCFABRIC + 9 // fcfb_9
|
|
||||||
LinkFcfabric10 LinkType = unix.ARPHRD_FCFABRIC + 10 // fcfb_10
|
|
||||||
LinkFcfabric11 LinkType = unix.ARPHRD_FCFABRIC + 11 // fcfb_11
|
|
||||||
LinkFcfabric12 LinkType = unix.ARPHRD_FCFABRIC + 12 // fcfb_12
|
|
||||||
LinkIee802tr LinkType = unix.ARPHRD_IEEE802_TR // tr
|
|
||||||
LinkIee80211 LinkType = unix.ARPHRD_IEEE80211 // ieee802.11
|
|
||||||
LinkIee80211prism LinkType = unix.ARPHRD_IEEE80211_PRISM // ieee802.11_prism
|
|
||||||
LinkIee80211Radiotap LinkType = unix.ARPHRD_IEEE80211_RADIOTAP // ieee802.11_radiotap
|
|
||||||
LinkIee8021154 LinkType = unix.ARPHRD_IEEE802154 // ieee802.15.4
|
|
||||||
LinkIee8021154monitor LinkType = unix.ARPHRD_IEEE802154_MONITOR // ieee802.15.4_monitor
|
|
||||||
LinkPhonet LinkType = unix.ARPHRD_PHONET // phonet
|
|
||||||
LinkPhonetpipe LinkType = unix.ARPHRD_PHONET_PIPE // phonet_pipe
|
|
||||||
LinkCaif LinkType = unix.ARPHRD_CAIF // caif
|
|
||||||
LinkIP6gre LinkType = unix.ARPHRD_IP6GRE // ip6gre
|
|
||||||
LinkNetlink LinkType = unix.ARPHRD_NETLINK // netlink
|
|
||||||
Link6Lowpan LinkType = unix.ARPHRD_6LOWPAN // 6lowpan
|
|
||||||
LinkVoid LinkType = unix.ARPHRD_VOID // void
|
|
||||||
LinkNone LinkType = unix.ARPHRD_NONE // nohdr
|
|
||||||
)
|
|
@ -1,4 +1,4 @@
|
|||||||
// Code generated by "stringer -type=LinkType -linecomment -output linktype_string_linux.go"; DO NOT EDIT.
|
// Code generated by "stringer -type=LinkType -linecomment"; DO NOT EDIT.
|
||||||
|
|
||||||
package nethelpers
|
package nethelpers
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
// Code generated by "stringer -type=RouteFlag -linecomment -output routeflag_string_linux.go"; DO NOT EDIT.
|
// Code generated by "stringer -type=RouteFlag -linecomment"; DO NOT EDIT.
|
||||||
|
|
||||||
package nethelpers
|
package nethelpers
|
||||||
|
|
@ -4,12 +4,10 @@
|
|||||||
|
|
||||||
package nethelpers
|
package nethelpers
|
||||||
|
|
||||||
//go:generate stringer -type=RouteFlag -linecomment -output routeflag_string_linux.go
|
//go:generate stringer -type=RouteFlag -linecomment
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"golang.org/x/sys/unix"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// RouteFlags is a bitmask of RouteFlag.
|
// RouteFlags is a bitmask of RouteFlag.
|
||||||
@ -42,14 +40,14 @@ type RouteFlag uint32
|
|||||||
|
|
||||||
// RouteFlag constants.
|
// RouteFlag constants.
|
||||||
const (
|
const (
|
||||||
RouteNotify RouteFlag = unix.RTM_F_NOTIFY // notify
|
RouteNotify RouteFlag = 256 << iota // notify
|
||||||
RouteCloned RouteFlag = unix.RTM_F_CLONED // cloned
|
RouteCloned // cloned
|
||||||
RouteEqualize RouteFlag = unix.RTM_F_EQUALIZE // equalize
|
RouteEqualize // equalize
|
||||||
RoutePrefix RouteFlag = unix.RTM_F_PREFIX // prefix
|
RoutePrefix // prefix
|
||||||
RouteLookupTable RouteFlag = unix.RTM_F_LOOKUP_TABLE // lookup_table
|
RouteLookupTable // lookup_table
|
||||||
RouteFIBMatch RouteFlag = unix.RTM_F_FIB_MATCH // fib_match
|
RouteFIBMatch // fib_match
|
||||||
RouteOffload RouteFlag = unix.RTM_F_OFFLOAD // offload
|
RouteOffload // offload
|
||||||
RouteTrap RouteFlag = unix.RTM_F_TRAP // trap
|
RouteTrap // trap
|
||||||
)
|
)
|
||||||
|
|
||||||
// RouteFlagsMask is a supported set of flags to manage.
|
// RouteFlagsMask is a supported set of flags to manage.
|
@ -4,9 +4,7 @@
|
|||||||
|
|
||||||
package nethelpers
|
package nethelpers
|
||||||
|
|
||||||
import "golang.org/x/sys/unix"
|
//go:generate stringer -type=RouteProtocol -linecomment
|
||||||
|
|
||||||
//go:generate stringer -type=RouteProtocol -linecomment -output routeprotocol_string_linux.go
|
|
||||||
|
|
||||||
// RouteProtocol is a routing protocol.
|
// RouteProtocol is a routing protocol.
|
||||||
type RouteProtocol uint8
|
type RouteProtocol uint8
|
||||||
@ -18,9 +16,9 @@ func (rp RouteProtocol) MarshalYAML() (interface{}, error) {
|
|||||||
|
|
||||||
// RouteType constants.
|
// RouteType constants.
|
||||||
const (
|
const (
|
||||||
ProtocolUnspec RouteProtocol = unix.RTPROT_UNSPEC // unspec
|
ProtocolUnspec RouteProtocol = iota // unspec
|
||||||
ProtocolRedirect RouteProtocol = unix.RTPROT_REDIRECT // redirect
|
ProtocolRedirect // redirect
|
||||||
ProtocolKernel RouteProtocol = unix.RTPROT_KERNEL // kernel
|
ProtocolKernel // kernel
|
||||||
ProtocolBoot RouteProtocol = unix.RTPROT_BOOT // boot
|
ProtocolBoot // boot
|
||||||
ProtocolStatic RouteProtocol = unix.RTPROT_STATIC // static
|
ProtocolStatic // static
|
||||||
)
|
)
|
@ -1,4 +1,4 @@
|
|||||||
// Code generated by "stringer -type=RouteProtocol -linecomment -output routeprotocol_string_linux.go"; DO NOT EDIT.
|
// Code generated by "stringer -type=RouteProtocol -linecomment"; DO NOT EDIT.
|
||||||
|
|
||||||
package nethelpers
|
package nethelpers
|
||||||
|
|
31
pkg/machinery/nethelpers/routetype.go
Normal file
31
pkg/machinery/nethelpers/routetype.go
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
package nethelpers
|
||||||
|
|
||||||
|
//go:generate stringer -type=RouteType -linecomment
|
||||||
|
|
||||||
|
// RouteType is a route type.
|
||||||
|
type RouteType uint8
|
||||||
|
|
||||||
|
// MarshalYAML implements yaml.Marshaler.
|
||||||
|
func (rt RouteType) MarshalYAML() (interface{}, error) {
|
||||||
|
return rt.String(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RouteType constants.
|
||||||
|
const (
|
||||||
|
TypeUnspec RouteType = iota // unspec
|
||||||
|
TypeUnicast // unicast
|
||||||
|
TypeLocal // local
|
||||||
|
TypeBroadcast // broadcast
|
||||||
|
TypeAnycast // anycast
|
||||||
|
TypeMulticast // multicast
|
||||||
|
TypeBlackhole // blackhole
|
||||||
|
TypeUnreachable // unreachable
|
||||||
|
TypeProhibit // prohibit
|
||||||
|
TypeThrow // throw
|
||||||
|
TypeNAT // nat
|
||||||
|
TypeXResolve // xresolve
|
||||||
|
)
|
@ -1,33 +0,0 @@
|
|||||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
package nethelpers
|
|
||||||
|
|
||||||
import "golang.org/x/sys/unix"
|
|
||||||
|
|
||||||
//go:generate stringer -type=RouteType -linecomment -output routetype_string_linux.go
|
|
||||||
|
|
||||||
// RouteType is a route type.
|
|
||||||
type RouteType uint8
|
|
||||||
|
|
||||||
// MarshalYAML implements yaml.Marshaler.
|
|
||||||
func (rt RouteType) MarshalYAML() (interface{}, error) {
|
|
||||||
return rt.String(), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// RouteType constants.
|
|
||||||
const (
|
|
||||||
TypeUnspec RouteType = unix.RTN_UNSPEC // unspec
|
|
||||||
TypeUnicast RouteType = unix.RTN_UNICAST // unicast
|
|
||||||
TypeLocal RouteType = unix.RTN_LOCAL // local
|
|
||||||
TypeBroadcast RouteType = unix.RTN_BROADCAST // broadcast
|
|
||||||
TypeAnycast RouteType = unix.RTN_ANYCAST // anycast
|
|
||||||
TypeMulticast RouteType = unix.RTN_MULTICAST // multicast
|
|
||||||
TypeBlackhole RouteType = unix.RTN_BLACKHOLE // blackhole
|
|
||||||
TypeUnreachable RouteType = unix.RTN_UNREACHABLE // unreachable
|
|
||||||
TypeProhibit RouteType = unix.RTN_PROHIBIT // prohibit
|
|
||||||
TypeThrow RouteType = unix.RTN_THROW // throw
|
|
||||||
TypeNAT RouteType = unix.RTN_NAT // nat
|
|
||||||
TypeXResolve RouteType = unix.RTN_XRESOLVE // xresolve
|
|
||||||
)
|
|
@ -1,4 +1,4 @@
|
|||||||
// Code generated by "stringer -type=RouteType -linecomment -output routetype_string_linux.go"; DO NOT EDIT.
|
// Code generated by "stringer -type=RouteType -linecomment"; DO NOT EDIT.
|
||||||
|
|
||||||
package nethelpers
|
package nethelpers
|
||||||
|
|
@ -4,9 +4,7 @@
|
|||||||
|
|
||||||
package nethelpers
|
package nethelpers
|
||||||
|
|
||||||
import "golang.org/x/sys/unix"
|
//go:generate stringer -type=RoutingTable -linecomment
|
||||||
|
|
||||||
//go:generate stringer -type=RoutingTable -linecomment -output routingtable_string_linux.go
|
|
||||||
|
|
||||||
// RoutingTable is a routing table ID.
|
// RoutingTable is a routing table ID.
|
||||||
type RoutingTable uint32
|
type RoutingTable uint32
|
||||||
@ -18,8 +16,8 @@ func (table RoutingTable) MarshalYAML() (interface{}, error) {
|
|||||||
|
|
||||||
// RoutingTable constants.
|
// RoutingTable constants.
|
||||||
const (
|
const (
|
||||||
TableUnspec RoutingTable = unix.RT_TABLE_UNSPEC // unspec
|
TableUnspec RoutingTable = 0 // unspec
|
||||||
TableDefault RoutingTable = unix.RT_TABLE_DEFAULT // default
|
TableDefault RoutingTable = 253 // default
|
||||||
TableMain RoutingTable = unix.RT_TABLE_MAIN // main
|
TableMain RoutingTable = 254 // main
|
||||||
TableLocal RoutingTable = unix.RT_TABLE_LOCAL // local
|
TableLocal RoutingTable = 255 // local
|
||||||
)
|
)
|
@ -1,4 +1,4 @@
|
|||||||
// Code generated by "stringer -type=RoutingTable -linecomment -output routingtable_string_linux.go"; DO NOT EDIT.
|
// Code generated by "stringer -type=RoutingTable -linecomment"; DO NOT EDIT.
|
||||||
|
|
||||||
package nethelpers
|
package nethelpers
|
||||||
|
|
@ -4,9 +4,7 @@
|
|||||||
|
|
||||||
package nethelpers
|
package nethelpers
|
||||||
|
|
||||||
import "golang.org/x/sys/unix"
|
//go:generate stringer -type=Scope -linecomment
|
||||||
|
|
||||||
//go:generate stringer -type=Scope -linecomment -output scope_string_linux.go
|
|
||||||
|
|
||||||
// Scope is an address scope.
|
// Scope is an address scope.
|
||||||
type Scope uint8
|
type Scope uint8
|
||||||
@ -18,9 +16,9 @@ func (scope Scope) MarshalYAML() (interface{}, error) {
|
|||||||
|
|
||||||
// Scope constants.
|
// Scope constants.
|
||||||
const (
|
const (
|
||||||
ScopeGlobal Scope = unix.RT_SCOPE_UNIVERSE // global
|
ScopeGlobal Scope = 0 // global
|
||||||
ScopeSite Scope = unix.RT_SCOPE_SITE // site
|
ScopeSite Scope = 200 // site
|
||||||
ScopeLink Scope = unix.RT_SCOPE_LINK // link
|
ScopeLink Scope = 253 // link
|
||||||
ScopeHost Scope = unix.RT_SCOPE_HOST // host
|
ScopeHost Scope = 254 // host
|
||||||
ScopeNowhere Scope = unix.RT_SCOPE_NOWHERE // nowhere
|
ScopeNowhere Scope = 255 // nowhere
|
||||||
)
|
)
|
@ -1,4 +1,4 @@
|
|||||||
// Code generated by "stringer -type=Scope -linecomment -output scope_string_linux.go"; DO NOT EDIT.
|
// Code generated by "stringer -type=Scope -linecomment"; DO NOT EDIT.
|
||||||
|
|
||||||
package nethelpers
|
package nethelpers
|
||||||
|
|
@ -4,9 +4,7 @@
|
|||||||
|
|
||||||
package nethelpers
|
package nethelpers
|
||||||
|
|
||||||
import "golang.org/x/sys/unix"
|
//go:generate stringer -type=VLANProtocol -linecomment
|
||||||
|
|
||||||
//go:generate stringer -type=VLANProtocol -linecomment -output vlanprotocol_string_linux.go
|
|
||||||
|
|
||||||
// VLANProtocol is a VLAN protocol.
|
// VLANProtocol is a VLAN protocol.
|
||||||
type VLANProtocol uint16
|
type VLANProtocol uint16
|
||||||
@ -18,6 +16,6 @@ func (proto VLANProtocol) MarshalYAML() (interface{}, error) {
|
|||||||
|
|
||||||
// VLANProtocol constants.
|
// VLANProtocol constants.
|
||||||
const (
|
const (
|
||||||
VLANProtocol8021Q VLANProtocol = unix.ETH_P_8021Q // 802.1q
|
VLANProtocol8021Q VLANProtocol = 33024 // 802.1q
|
||||||
VLANProtocol8021AD VLANProtocol = unix.ETH_P_8021AD // 802.1ad
|
VLANProtocol8021AD VLANProtocol = 34984 // 802.1ad
|
||||||
)
|
)
|
@ -1,4 +1,4 @@
|
|||||||
// Code generated by "stringer -type=VLANProtocol -linecomment -output vlanprotocol_string_linux.go"; DO NOT EDIT.
|
// Code generated by "stringer -type=VLANProtocol -linecomment"; DO NOT EDIT.
|
||||||
|
|
||||||
package nethelpers
|
package nethelpers
|
||||||
|
|
@ -2,9 +2,6 @@
|
|||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
//go:build linux
|
|
||||||
// +build linux
|
|
||||||
|
|
||||||
package k8s
|
package k8s
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
//go:build linux
|
|
||||||
|
|
||||||
package network
|
package network
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
//go:build linux
|
|
||||||
|
|
||||||
package network
|
package network
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
|
|
||||||
package network
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/cosi-project/runtime/pkg/resource"
|
|
||||||
)
|
|
||||||
|
|
||||||
// NamespaceName contains resources related to networking.
|
|
||||||
const NamespaceName resource.Namespace = "network"
|
|
||||||
|
|
||||||
// ConfigNamespaceName contains umerged resources related to networking generate from the configuration.
|
|
||||||
//
|
|
||||||
// Resources in the ConfigNamespaceName namespace are merged to produce final versions in the NamespaceName namespace.
|
|
||||||
const ConfigNamespaceName resource.Namespace = "network-config"
|
|
||||||
|
|
||||||
// LinkStatusType is type of LinkStatus resource.
|
|
||||||
const LinkStatusType = resource.Type("LinkStatuses.net.talos.dev")
|
|
@ -2,18 +2,13 @@
|
|||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
//go:build linux
|
|
||||||
|
|
||||||
package network
|
package network
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
|
||||||
"net"
|
"net"
|
||||||
"sort"
|
"sort"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/mdlayher/netlink"
|
|
||||||
"golang.org/x/sys/unix"
|
|
||||||
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
|
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
|
||||||
"inet.af/netaddr"
|
"inet.af/netaddr"
|
||||||
|
|
||||||
@ -29,38 +24,6 @@ type VLANSpec struct {
|
|||||||
Protocol nethelpers.VLANProtocol `yaml:"vlanProtocol"`
|
Protocol nethelpers.VLANProtocol `yaml:"vlanProtocol"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Encode the VLANSpec into netlink attributes.
|
|
||||||
func (vlan *VLANSpec) Encode() ([]byte, error) {
|
|
||||||
encoder := netlink.NewAttributeEncoder()
|
|
||||||
|
|
||||||
encoder.Uint16(unix.IFLA_VLAN_ID, vlan.VID)
|
|
||||||
|
|
||||||
buf := make([]byte, 2)
|
|
||||||
binary.BigEndian.PutUint16(buf, uint16(vlan.Protocol))
|
|
||||||
encoder.Bytes(unix.IFLA_VLAN_PROTOCOL, buf)
|
|
||||||
|
|
||||||
return encoder.Encode()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode the VLANSpec from netlink attributes.
|
|
||||||
func (vlan *VLANSpec) Decode(data []byte) error {
|
|
||||||
decoder, err := netlink.NewAttributeDecoder(data)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
for decoder.Next() {
|
|
||||||
switch decoder.Type() {
|
|
||||||
case unix.IFLA_VLAN_ID:
|
|
||||||
vlan.VID = decoder.Uint16()
|
|
||||||
case unix.IFLA_VLAN_PROTOCOL:
|
|
||||||
vlan.Protocol = nethelpers.VLANProtocol(binary.BigEndian.Uint16(decoder.Bytes()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return decoder.Err()
|
|
||||||
}
|
|
||||||
|
|
||||||
// BondMasterSpec describes bond settings if Kind == "bond".
|
// BondMasterSpec describes bond settings if Kind == "bond".
|
||||||
type BondMasterSpec struct {
|
type BondMasterSpec struct {
|
||||||
Mode nethelpers.BondMode `yaml:"mode"`
|
Mode nethelpers.BondMode `yaml:"mode"`
|
||||||
@ -116,144 +79,6 @@ func (bond *BondMasterSpec) FillDefaults() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Encode the BondMasterSpec into netlink attributes.
|
|
||||||
//
|
|
||||||
//nolint:gocyclo
|
|
||||||
func (bond *BondMasterSpec) Encode() ([]byte, error) {
|
|
||||||
encoder := netlink.NewAttributeEncoder()
|
|
||||||
|
|
||||||
encoder.Uint8(unix.IFLA_BOND_MODE, uint8(bond.Mode))
|
|
||||||
encoder.Uint8(unix.IFLA_BOND_XMIT_HASH_POLICY, uint8(bond.HashPolicy))
|
|
||||||
|
|
||||||
if bond.Mode == nethelpers.BondMode8023AD {
|
|
||||||
encoder.Uint8(unix.IFLA_BOND_AD_LACP_RATE, uint8(bond.LACPRate))
|
|
||||||
}
|
|
||||||
|
|
||||||
if bond.Mode != nethelpers.BondMode8023AD && bond.Mode != nethelpers.BondModeALB && bond.Mode != nethelpers.BondModeTLB {
|
|
||||||
encoder.Uint32(unix.IFLA_BOND_ARP_VALIDATE, uint32(bond.ARPValidate))
|
|
||||||
}
|
|
||||||
|
|
||||||
encoder.Uint32(unix.IFLA_BOND_ARP_ALL_TARGETS, uint32(bond.ARPAllTargets))
|
|
||||||
|
|
||||||
if bond.Mode == nethelpers.BondModeActiveBackup || bond.Mode == nethelpers.BondModeALB || bond.Mode == nethelpers.BondModeTLB {
|
|
||||||
encoder.Uint32(unix.IFLA_BOND_PRIMARY, bond.PrimaryIndex)
|
|
||||||
}
|
|
||||||
|
|
||||||
encoder.Uint8(unix.IFLA_BOND_PRIMARY_RESELECT, uint8(bond.PrimaryReselect))
|
|
||||||
encoder.Uint8(unix.IFLA_BOND_FAIL_OVER_MAC, uint8(bond.FailOverMac))
|
|
||||||
encoder.Uint8(unix.IFLA_BOND_AD_SELECT, uint8(bond.ADSelect))
|
|
||||||
encoder.Uint32(unix.IFLA_BOND_MIIMON, bond.MIIMon)
|
|
||||||
|
|
||||||
if bond.MIIMon != 0 {
|
|
||||||
encoder.Uint32(unix.IFLA_BOND_UPDELAY, bond.UpDelay)
|
|
||||||
encoder.Uint32(unix.IFLA_BOND_DOWNDELAY, bond.DownDelay)
|
|
||||||
}
|
|
||||||
|
|
||||||
if bond.Mode != nethelpers.BondMode8023AD && bond.Mode != nethelpers.BondModeALB && bond.Mode != nethelpers.BondModeTLB {
|
|
||||||
encoder.Uint32(unix.IFLA_BOND_ARP_INTERVAL, bond.ARPInterval)
|
|
||||||
}
|
|
||||||
|
|
||||||
encoder.Uint32(unix.IFLA_BOND_RESEND_IGMP, bond.ResendIGMP)
|
|
||||||
encoder.Uint32(unix.IFLA_BOND_MIN_LINKS, bond.MinLinks)
|
|
||||||
encoder.Uint32(unix.IFLA_BOND_LP_INTERVAL, bond.LPInterval)
|
|
||||||
|
|
||||||
if bond.Mode == nethelpers.BondModeRoundrobin {
|
|
||||||
encoder.Uint32(unix.IFLA_BOND_PACKETS_PER_SLAVE, bond.PacketsPerSlave)
|
|
||||||
}
|
|
||||||
|
|
||||||
encoder.Uint8(unix.IFLA_BOND_NUM_PEER_NOTIF, bond.NumPeerNotif)
|
|
||||||
|
|
||||||
if bond.Mode == nethelpers.BondModeALB || bond.Mode == nethelpers.BondModeTLB {
|
|
||||||
encoder.Uint8(unix.IFLA_BOND_TLB_DYNAMIC_LB, bond.TLBDynamicLB)
|
|
||||||
}
|
|
||||||
|
|
||||||
encoder.Uint8(unix.IFLA_BOND_ALL_SLAVES_ACTIVE, bond.AllSlavesActive)
|
|
||||||
|
|
||||||
var useCarrier uint8
|
|
||||||
|
|
||||||
if bond.UseCarrier {
|
|
||||||
useCarrier = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
encoder.Uint8(unix.IFLA_BOND_USE_CARRIER, useCarrier)
|
|
||||||
|
|
||||||
if bond.Mode == nethelpers.BondMode8023AD {
|
|
||||||
encoder.Uint16(unix.IFLA_BOND_AD_ACTOR_SYS_PRIO, bond.ADActorSysPrio)
|
|
||||||
encoder.Uint16(unix.IFLA_BOND_AD_USER_PORT_KEY, bond.ADUserPortKey)
|
|
||||||
}
|
|
||||||
|
|
||||||
if bond.MIIMon != 0 {
|
|
||||||
encoder.Uint32(unix.IFLA_BOND_PEER_NOTIF_DELAY, bond.PeerNotifyDelay)
|
|
||||||
}
|
|
||||||
|
|
||||||
return encoder.Encode()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Decode the BondMasterSpec from netlink attributes.
|
|
||||||
//
|
|
||||||
//nolint:gocyclo,cyclop
|
|
||||||
func (bond *BondMasterSpec) Decode(data []byte) error {
|
|
||||||
decoder, err := netlink.NewAttributeDecoder(data)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
for decoder.Next() {
|
|
||||||
switch decoder.Type() {
|
|
||||||
case unix.IFLA_BOND_MODE:
|
|
||||||
bond.Mode = nethelpers.BondMode(decoder.Uint8())
|
|
||||||
case unix.IFLA_BOND_XMIT_HASH_POLICY:
|
|
||||||
bond.HashPolicy = nethelpers.BondXmitHashPolicy(decoder.Uint8())
|
|
||||||
case unix.IFLA_BOND_AD_LACP_RATE:
|
|
||||||
bond.LACPRate = nethelpers.LACPRate(decoder.Uint8())
|
|
||||||
case unix.IFLA_BOND_ARP_VALIDATE:
|
|
||||||
bond.ARPValidate = nethelpers.ARPValidate(decoder.Uint32())
|
|
||||||
case unix.IFLA_BOND_ARP_ALL_TARGETS:
|
|
||||||
bond.ARPAllTargets = nethelpers.ARPAllTargets(decoder.Uint32())
|
|
||||||
case unix.IFLA_BOND_PRIMARY:
|
|
||||||
bond.PrimaryIndex = decoder.Uint32()
|
|
||||||
case unix.IFLA_BOND_PRIMARY_RESELECT:
|
|
||||||
bond.PrimaryReselect = nethelpers.PrimaryReselect(decoder.Uint8())
|
|
||||||
case unix.IFLA_BOND_FAIL_OVER_MAC:
|
|
||||||
bond.FailOverMac = nethelpers.FailOverMAC(decoder.Uint8())
|
|
||||||
case unix.IFLA_BOND_AD_SELECT:
|
|
||||||
bond.ADSelect = nethelpers.ADSelect(decoder.Uint8())
|
|
||||||
case unix.IFLA_BOND_MIIMON:
|
|
||||||
bond.MIIMon = decoder.Uint32()
|
|
||||||
case unix.IFLA_BOND_UPDELAY:
|
|
||||||
bond.UpDelay = decoder.Uint32()
|
|
||||||
case unix.IFLA_BOND_DOWNDELAY:
|
|
||||||
bond.DownDelay = decoder.Uint32()
|
|
||||||
case unix.IFLA_BOND_ARP_INTERVAL:
|
|
||||||
bond.ARPInterval = decoder.Uint32()
|
|
||||||
case unix.IFLA_BOND_RESEND_IGMP:
|
|
||||||
bond.ResendIGMP = decoder.Uint32()
|
|
||||||
case unix.IFLA_BOND_MIN_LINKS:
|
|
||||||
bond.MinLinks = decoder.Uint32()
|
|
||||||
case unix.IFLA_BOND_LP_INTERVAL:
|
|
||||||
bond.LPInterval = decoder.Uint32()
|
|
||||||
case unix.IFLA_BOND_PACKETS_PER_SLAVE:
|
|
||||||
bond.PacketsPerSlave = decoder.Uint32()
|
|
||||||
case unix.IFLA_BOND_NUM_PEER_NOTIF:
|
|
||||||
bond.NumPeerNotif = decoder.Uint8()
|
|
||||||
case unix.IFLA_BOND_TLB_DYNAMIC_LB:
|
|
||||||
bond.TLBDynamicLB = decoder.Uint8()
|
|
||||||
case unix.IFLA_BOND_ALL_SLAVES_ACTIVE:
|
|
||||||
bond.AllSlavesActive = decoder.Uint8()
|
|
||||||
case unix.IFLA_BOND_USE_CARRIER:
|
|
||||||
bond.UseCarrier = decoder.Uint8() == 1
|
|
||||||
case unix.IFLA_BOND_AD_ACTOR_SYS_PRIO:
|
|
||||||
bond.ADActorSysPrio = decoder.Uint16()
|
|
||||||
case unix.IFLA_BOND_AD_USER_PORT_KEY:
|
|
||||||
bond.ADUserPortKey = decoder.Uint16()
|
|
||||||
case unix.IFLA_BOND_PEER_NOTIF_DELAY:
|
|
||||||
bond.PeerNotifyDelay = decoder.Uint32()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return decoder.Err()
|
|
||||||
}
|
|
||||||
|
|
||||||
// WireguardSpec describes Wireguard settings if Kind == "wireguard".
|
// WireguardSpec describes Wireguard settings if Kind == "wireguard".
|
||||||
type WireguardSpec struct {
|
type WireguardSpec struct {
|
||||||
// PrivateKey is used to configure the link, present only in the LinkSpec.
|
// PrivateKey is used to configure the link, present only in the LinkSpec.
|
||||||
|
184
pkg/resources/network/link_linux.go
Normal file
184
pkg/resources/network/link_linux.go
Normal file
@ -0,0 +1,184 @@
|
|||||||
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
|
package network
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/binary"
|
||||||
|
|
||||||
|
"github.com/mdlayher/netlink"
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
|
|
||||||
|
"github.com/talos-systems/talos/pkg/machinery/nethelpers"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Encode the VLANSpec into netlink attributes.
|
||||||
|
func (vlan *VLANSpec) Encode() ([]byte, error) {
|
||||||
|
encoder := netlink.NewAttributeEncoder()
|
||||||
|
|
||||||
|
encoder.Uint16(unix.IFLA_VLAN_ID, vlan.VID)
|
||||||
|
|
||||||
|
buf := make([]byte, 2)
|
||||||
|
binary.BigEndian.PutUint16(buf, uint16(vlan.Protocol))
|
||||||
|
encoder.Bytes(unix.IFLA_VLAN_PROTOCOL, buf)
|
||||||
|
|
||||||
|
return encoder.Encode()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decode the VLANSpec from netlink attributes.
|
||||||
|
func (vlan *VLANSpec) Decode(data []byte) error {
|
||||||
|
decoder, err := netlink.NewAttributeDecoder(data)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for decoder.Next() {
|
||||||
|
switch decoder.Type() {
|
||||||
|
case unix.IFLA_VLAN_ID:
|
||||||
|
vlan.VID = decoder.Uint16()
|
||||||
|
case unix.IFLA_VLAN_PROTOCOL:
|
||||||
|
vlan.Protocol = nethelpers.VLANProtocol(binary.BigEndian.Uint16(decoder.Bytes()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return decoder.Err()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Encode the BondMasterSpec into netlink attributes.
|
||||||
|
//
|
||||||
|
//nolint:gocyclo
|
||||||
|
func (bond *BondMasterSpec) Encode() ([]byte, error) {
|
||||||
|
encoder := netlink.NewAttributeEncoder()
|
||||||
|
|
||||||
|
encoder.Uint8(unix.IFLA_BOND_MODE, uint8(bond.Mode))
|
||||||
|
encoder.Uint8(unix.IFLA_BOND_XMIT_HASH_POLICY, uint8(bond.HashPolicy))
|
||||||
|
|
||||||
|
if bond.Mode == nethelpers.BondMode8023AD {
|
||||||
|
encoder.Uint8(unix.IFLA_BOND_AD_LACP_RATE, uint8(bond.LACPRate))
|
||||||
|
}
|
||||||
|
|
||||||
|
if bond.Mode != nethelpers.BondMode8023AD && bond.Mode != nethelpers.BondModeALB && bond.Mode != nethelpers.BondModeTLB {
|
||||||
|
encoder.Uint32(unix.IFLA_BOND_ARP_VALIDATE, uint32(bond.ARPValidate))
|
||||||
|
}
|
||||||
|
|
||||||
|
encoder.Uint32(unix.IFLA_BOND_ARP_ALL_TARGETS, uint32(bond.ARPAllTargets))
|
||||||
|
|
||||||
|
if bond.Mode == nethelpers.BondModeActiveBackup || bond.Mode == nethelpers.BondModeALB || bond.Mode == nethelpers.BondModeTLB {
|
||||||
|
encoder.Uint32(unix.IFLA_BOND_PRIMARY, bond.PrimaryIndex)
|
||||||
|
}
|
||||||
|
|
||||||
|
encoder.Uint8(unix.IFLA_BOND_PRIMARY_RESELECT, uint8(bond.PrimaryReselect))
|
||||||
|
encoder.Uint8(unix.IFLA_BOND_FAIL_OVER_MAC, uint8(bond.FailOverMac))
|
||||||
|
encoder.Uint8(unix.IFLA_BOND_AD_SELECT, uint8(bond.ADSelect))
|
||||||
|
encoder.Uint32(unix.IFLA_BOND_MIIMON, bond.MIIMon)
|
||||||
|
|
||||||
|
if bond.MIIMon != 0 {
|
||||||
|
encoder.Uint32(unix.IFLA_BOND_UPDELAY, bond.UpDelay)
|
||||||
|
encoder.Uint32(unix.IFLA_BOND_DOWNDELAY, bond.DownDelay)
|
||||||
|
}
|
||||||
|
|
||||||
|
if bond.Mode != nethelpers.BondMode8023AD && bond.Mode != nethelpers.BondModeALB && bond.Mode != nethelpers.BondModeTLB {
|
||||||
|
encoder.Uint32(unix.IFLA_BOND_ARP_INTERVAL, bond.ARPInterval)
|
||||||
|
}
|
||||||
|
|
||||||
|
encoder.Uint32(unix.IFLA_BOND_RESEND_IGMP, bond.ResendIGMP)
|
||||||
|
encoder.Uint32(unix.IFLA_BOND_MIN_LINKS, bond.MinLinks)
|
||||||
|
encoder.Uint32(unix.IFLA_BOND_LP_INTERVAL, bond.LPInterval)
|
||||||
|
|
||||||
|
if bond.Mode == nethelpers.BondModeRoundrobin {
|
||||||
|
encoder.Uint32(unix.IFLA_BOND_PACKETS_PER_SLAVE, bond.PacketsPerSlave)
|
||||||
|
}
|
||||||
|
|
||||||
|
encoder.Uint8(unix.IFLA_BOND_NUM_PEER_NOTIF, bond.NumPeerNotif)
|
||||||
|
|
||||||
|
if bond.Mode == nethelpers.BondModeALB || bond.Mode == nethelpers.BondModeTLB {
|
||||||
|
encoder.Uint8(unix.IFLA_BOND_TLB_DYNAMIC_LB, bond.TLBDynamicLB)
|
||||||
|
}
|
||||||
|
|
||||||
|
encoder.Uint8(unix.IFLA_BOND_ALL_SLAVES_ACTIVE, bond.AllSlavesActive)
|
||||||
|
|
||||||
|
var useCarrier uint8
|
||||||
|
|
||||||
|
if bond.UseCarrier {
|
||||||
|
useCarrier = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
encoder.Uint8(unix.IFLA_BOND_USE_CARRIER, useCarrier)
|
||||||
|
|
||||||
|
if bond.Mode == nethelpers.BondMode8023AD {
|
||||||
|
encoder.Uint16(unix.IFLA_BOND_AD_ACTOR_SYS_PRIO, bond.ADActorSysPrio)
|
||||||
|
encoder.Uint16(unix.IFLA_BOND_AD_USER_PORT_KEY, bond.ADUserPortKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
if bond.MIIMon != 0 {
|
||||||
|
encoder.Uint32(unix.IFLA_BOND_PEER_NOTIF_DELAY, bond.PeerNotifyDelay)
|
||||||
|
}
|
||||||
|
|
||||||
|
return encoder.Encode()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decode the BondMasterSpec from netlink attributes.
|
||||||
|
//
|
||||||
|
//nolint:gocyclo,cyclop
|
||||||
|
func (bond *BondMasterSpec) Decode(data []byte) error {
|
||||||
|
decoder, err := netlink.NewAttributeDecoder(data)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for decoder.Next() {
|
||||||
|
switch decoder.Type() {
|
||||||
|
case unix.IFLA_BOND_MODE:
|
||||||
|
bond.Mode = nethelpers.BondMode(decoder.Uint8())
|
||||||
|
case unix.IFLA_BOND_XMIT_HASH_POLICY:
|
||||||
|
bond.HashPolicy = nethelpers.BondXmitHashPolicy(decoder.Uint8())
|
||||||
|
case unix.IFLA_BOND_AD_LACP_RATE:
|
||||||
|
bond.LACPRate = nethelpers.LACPRate(decoder.Uint8())
|
||||||
|
case unix.IFLA_BOND_ARP_VALIDATE:
|
||||||
|
bond.ARPValidate = nethelpers.ARPValidate(decoder.Uint32())
|
||||||
|
case unix.IFLA_BOND_ARP_ALL_TARGETS:
|
||||||
|
bond.ARPAllTargets = nethelpers.ARPAllTargets(decoder.Uint32())
|
||||||
|
case unix.IFLA_BOND_PRIMARY:
|
||||||
|
bond.PrimaryIndex = decoder.Uint32()
|
||||||
|
case unix.IFLA_BOND_PRIMARY_RESELECT:
|
||||||
|
bond.PrimaryReselect = nethelpers.PrimaryReselect(decoder.Uint8())
|
||||||
|
case unix.IFLA_BOND_FAIL_OVER_MAC:
|
||||||
|
bond.FailOverMac = nethelpers.FailOverMAC(decoder.Uint8())
|
||||||
|
case unix.IFLA_BOND_AD_SELECT:
|
||||||
|
bond.ADSelect = nethelpers.ADSelect(decoder.Uint8())
|
||||||
|
case unix.IFLA_BOND_MIIMON:
|
||||||
|
bond.MIIMon = decoder.Uint32()
|
||||||
|
case unix.IFLA_BOND_UPDELAY:
|
||||||
|
bond.UpDelay = decoder.Uint32()
|
||||||
|
case unix.IFLA_BOND_DOWNDELAY:
|
||||||
|
bond.DownDelay = decoder.Uint32()
|
||||||
|
case unix.IFLA_BOND_ARP_INTERVAL:
|
||||||
|
bond.ARPInterval = decoder.Uint32()
|
||||||
|
case unix.IFLA_BOND_RESEND_IGMP:
|
||||||
|
bond.ResendIGMP = decoder.Uint32()
|
||||||
|
case unix.IFLA_BOND_MIN_LINKS:
|
||||||
|
bond.MinLinks = decoder.Uint32()
|
||||||
|
case unix.IFLA_BOND_LP_INTERVAL:
|
||||||
|
bond.LPInterval = decoder.Uint32()
|
||||||
|
case unix.IFLA_BOND_PACKETS_PER_SLAVE:
|
||||||
|
bond.PacketsPerSlave = decoder.Uint32()
|
||||||
|
case unix.IFLA_BOND_NUM_PEER_NOTIF:
|
||||||
|
bond.NumPeerNotif = decoder.Uint8()
|
||||||
|
case unix.IFLA_BOND_TLB_DYNAMIC_LB:
|
||||||
|
bond.TLBDynamicLB = decoder.Uint8()
|
||||||
|
case unix.IFLA_BOND_ALL_SLAVES_ACTIVE:
|
||||||
|
bond.AllSlavesActive = decoder.Uint8()
|
||||||
|
case unix.IFLA_BOND_USE_CARRIER:
|
||||||
|
bond.UseCarrier = decoder.Uint8() == 1
|
||||||
|
case unix.IFLA_BOND_AD_ACTOR_SYS_PRIO:
|
||||||
|
bond.ADActorSysPrio = decoder.Uint16()
|
||||||
|
case unix.IFLA_BOND_AD_USER_PORT_KEY:
|
||||||
|
bond.ADUserPortKey = decoder.Uint16()
|
||||||
|
case unix.IFLA_BOND_PEER_NOTIF_DELAY:
|
||||||
|
bond.PeerNotifyDelay = decoder.Uint32()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return decoder.Err()
|
||||||
|
}
|
@ -2,8 +2,6 @@
|
|||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
//go:build linux
|
|
||||||
|
|
||||||
package network
|
package network
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
//go:build linux
|
|
||||||
|
|
||||||
package network
|
package network
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -15,6 +13,9 @@ import (
|
|||||||
"github.com/talos-systems/talos/pkg/machinery/nethelpers"
|
"github.com/talos-systems/talos/pkg/machinery/nethelpers"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// LinkStatusType is type of LinkStatus resource.
|
||||||
|
const LinkStatusType = resource.Type("LinkStatuses.net.talos.dev")
|
||||||
|
|
||||||
// LinkStatus resource holds physical network link status.
|
// LinkStatus resource holds physical network link status.
|
||||||
type LinkStatus struct {
|
type LinkStatus struct {
|
||||||
md resource.Metadata
|
md resource.Metadata
|
||||||
|
@ -2,19 +2,26 @@
|
|||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
//go:build linux
|
|
||||||
|
|
||||||
// Package network provides resources which describe networking subsystem state.
|
// Package network provides resources which describe networking subsystem state.
|
||||||
package network
|
package network
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/cosi-project/runtime/pkg/resource"
|
||||||
"inet.af/netaddr"
|
"inet.af/netaddr"
|
||||||
|
|
||||||
"github.com/talos-systems/talos/pkg/machinery/nethelpers"
|
"github.com/talos-systems/talos/pkg/machinery/nethelpers"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// NamespaceName contains resources related to networking.
|
||||||
|
const NamespaceName resource.Namespace = "network"
|
||||||
|
|
||||||
|
// ConfigNamespaceName contains umerged resources related to networking generate from the configuration.
|
||||||
|
//
|
||||||
|
// Resources in the ConfigNamespaceName namespace are merged to produce final versions in the NamespaceName namespace.
|
||||||
|
const ConfigNamespaceName resource.Namespace = "network-config"
|
||||||
|
|
||||||
// AddressID builds ID (primary key) for the address.
|
// AddressID builds ID (primary key) for the address.
|
||||||
func AddressID(linkName string, addr netaddr.IPPrefix) string {
|
func AddressID(linkName string, addr netaddr.IPPrefix) string {
|
||||||
return fmt.Sprintf("%s/%s", linkName, addr)
|
return fmt.Sprintf("%s/%s", linkName, addr)
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
//go:build linux
|
|
||||||
|
|
||||||
package network
|
package network
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
//go:build linux
|
|
||||||
|
|
||||||
package network
|
package network
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user