mirror of
https://github.com/kubenetworks/kubevpn.git
synced 2025-10-13 11:04:03 +08:00
feat: upgrade go version to 1.23
This commit is contained in:
2
vendor/github.com/tailscale/netlink/.travis.yml
generated
vendored
2
vendor/github.com/tailscale/netlink/.travis.yml
generated
vendored
@@ -17,4 +17,4 @@ before_script:
|
||||
- sudo modprobe sch_sfq
|
||||
install:
|
||||
- go get -v -t ./...
|
||||
go_import_path: github.com/vishvananda/netlink
|
||||
go_import_path: github.com/tailscale/netlink
|
||||
|
2
vendor/github.com/tailscale/netlink/Makefile
generated
vendored
2
vendor/github.com/tailscale/netlink/Makefile
generated
vendored
@@ -19,7 +19,7 @@ $(call goroot,$(DEPS)):
|
||||
|
||||
.PHONY: $(call testdirs,$(DIRS))
|
||||
$(call testdirs,$(DIRS)):
|
||||
go test -test.exec sudo -test.parallel 4 -timeout 60s -test.v github.com/vishvananda/netlink/$@
|
||||
go test -test.exec sudo -test.parallel 4 -timeout 60s -test.v github.com/tailscale/netlink/$@
|
||||
|
||||
$(call fmt,$(call testdirs,$(DIRS))):
|
||||
! gofmt -l $(subst fmt-,,$@)/*.go | grep -q .
|
||||
|
10
vendor/github.com/tailscale/netlink/README.md
generated
vendored
10
vendor/github.com/tailscale/netlink/README.md
generated
vendored
@@ -1,6 +1,6 @@
|
||||
# netlink - netlink library for go #
|
||||
|
||||
[](https://app.travis-ci.com/github/vishvananda/netlink) [](https://godoc.org/github.com/vishvananda/netlink)
|
||||
[](https://app.travis-ci.com/github/vishvananda/netlink) [](https://godoc.org/github.com/tailscale/netlink)
|
||||
|
||||
The netlink package provides a simple netlink library for go. Netlink
|
||||
is the interface a user-space program in linux uses to communicate with
|
||||
@@ -20,7 +20,7 @@ functionality like ipsec xfrm handling.
|
||||
|
||||
You can use go get command:
|
||||
|
||||
go get github.com/vishvananda/netlink
|
||||
go get github.com/tailscale/netlink
|
||||
|
||||
Testing dependencies:
|
||||
|
||||
@@ -28,7 +28,7 @@ Testing dependencies:
|
||||
|
||||
Testing (requires root):
|
||||
|
||||
sudo -E go test github.com/vishvananda/netlink
|
||||
sudo -E go test github.com/tailscale/netlink
|
||||
|
||||
## Examples ##
|
||||
|
||||
@@ -39,7 +39,7 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/vishvananda/netlink"
|
||||
"github.com/tailscale/netlink"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -66,7 +66,7 @@ Add a new ip address to loopback:
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/vishvananda/netlink"
|
||||
"github.com/tailscale/netlink"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
2
vendor/github.com/tailscale/netlink/addr_linux.go
generated
vendored
2
vendor/github.com/tailscale/netlink/addr_linux.go
generated
vendored
@@ -6,7 +6,7 @@ import (
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"github.com/vishvananda/netlink/nl"
|
||||
"github.com/tailscale/netlink/nl"
|
||||
"github.com/vishvananda/netns"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
2
vendor/github.com/tailscale/netlink/bridge_linux.go
generated
vendored
2
vendor/github.com/tailscale/netlink/bridge_linux.go
generated
vendored
@@ -3,7 +3,7 @@ package netlink
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/vishvananda/netlink/nl"
|
||||
"github.com/tailscale/netlink/nl"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
|
2
vendor/github.com/tailscale/netlink/class_linux.go
generated
vendored
2
vendor/github.com/tailscale/netlink/class_linux.go
generated
vendored
@@ -8,7 +8,7 @@ import (
|
||||
"fmt"
|
||||
"syscall"
|
||||
|
||||
"github.com/vishvananda/netlink/nl"
|
||||
"github.com/tailscale/netlink/nl"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
|
2
vendor/github.com/tailscale/netlink/conntrack_linux.go
generated
vendored
2
vendor/github.com/tailscale/netlink/conntrack_linux.go
generated
vendored
@@ -8,7 +8,7 @@ import (
|
||||
"net"
|
||||
"time"
|
||||
|
||||
"github.com/vishvananda/netlink/nl"
|
||||
"github.com/tailscale/netlink/nl"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
|
2
vendor/github.com/tailscale/netlink/devlink_linux.go
generated
vendored
2
vendor/github.com/tailscale/netlink/devlink_linux.go
generated
vendored
@@ -6,7 +6,7 @@ import (
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"github.com/vishvananda/netlink/nl"
|
||||
"github.com/tailscale/netlink/nl"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
|
5
vendor/github.com/tailscale/netlink/filter_linux.go
generated
vendored
5
vendor/github.com/tailscale/netlink/filter_linux.go
generated
vendored
@@ -9,7 +9,7 @@ import (
|
||||
"net"
|
||||
"syscall"
|
||||
|
||||
"github.com/vishvananda/netlink/nl"
|
||||
"github.com/tailscale/netlink/nl"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
@@ -53,7 +53,8 @@ func (filter *U32) Type() string {
|
||||
|
||||
// Fw filter filters on firewall marks
|
||||
// NOTE: this is in filter_linux because it refers to nl.TcPolice which
|
||||
// is defined in nl/tc_linux.go
|
||||
//
|
||||
// is defined in nl/tc_linux.go
|
||||
type Fw struct {
|
||||
FilterAttrs
|
||||
ClassId uint32
|
||||
|
3
vendor/github.com/tailscale/netlink/fou_linux.go
generated
vendored
3
vendor/github.com/tailscale/netlink/fou_linux.go
generated
vendored
@@ -1,3 +1,4 @@
|
||||
//go:build linux
|
||||
// +build linux
|
||||
|
||||
package netlink
|
||||
@@ -6,7 +7,7 @@ import (
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
|
||||
"github.com/vishvananda/netlink/nl"
|
||||
"github.com/tailscale/netlink/nl"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
|
2
vendor/github.com/tailscale/netlink/genetlink_linux.go
generated
vendored
2
vendor/github.com/tailscale/netlink/genetlink_linux.go
generated
vendored
@@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
"syscall"
|
||||
|
||||
"github.com/vishvananda/netlink/nl"
|
||||
"github.com/tailscale/netlink/nl"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
|
2
vendor/github.com/tailscale/netlink/gtp_linux.go
generated
vendored
2
vendor/github.com/tailscale/netlink/gtp_linux.go
generated
vendored
@@ -6,7 +6,7 @@ import (
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"github.com/vishvananda/netlink/nl"
|
||||
"github.com/tailscale/netlink/nl"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
|
2
vendor/github.com/tailscale/netlink/handle_linux.go
generated
vendored
2
vendor/github.com/tailscale/netlink/handle_linux.go
generated
vendored
@@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/vishvananda/netlink/nl"
|
||||
"github.com/tailscale/netlink/nl"
|
||||
"github.com/vishvananda/netns"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
2
vendor/github.com/tailscale/netlink/ipset_linux.go
generated
vendored
2
vendor/github.com/tailscale/netlink/ipset_linux.go
generated
vendored
@@ -6,7 +6,7 @@ import (
|
||||
"net"
|
||||
"syscall"
|
||||
|
||||
"github.com/vishvananda/netlink/nl"
|
||||
"github.com/tailscale/netlink/nl"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
|
2
vendor/github.com/tailscale/netlink/link_linux.go
generated
vendored
2
vendor/github.com/tailscale/netlink/link_linux.go
generated
vendored
@@ -12,7 +12,7 @@ import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"github.com/vishvananda/netlink/nl"
|
||||
"github.com/tailscale/netlink/nl"
|
||||
"github.com/vishvananda/netns"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
2
vendor/github.com/tailscale/netlink/neigh_linux.go
generated
vendored
2
vendor/github.com/tailscale/netlink/neigh_linux.go
generated
vendored
@@ -6,7 +6,7 @@ import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"github.com/vishvananda/netlink/nl"
|
||||
"github.com/tailscale/netlink/nl"
|
||||
"github.com/vishvananda/netns"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
2
vendor/github.com/tailscale/netlink/netlink_linux.go
generated
vendored
2
vendor/github.com/tailscale/netlink/netlink_linux.go
generated
vendored
@@ -1,6 +1,6 @@
|
||||
package netlink
|
||||
|
||||
import "github.com/vishvananda/netlink/nl"
|
||||
import "github.com/tailscale/netlink/nl"
|
||||
|
||||
// Family type definitions
|
||||
const (
|
||||
|
2
vendor/github.com/tailscale/netlink/netns_linux.go
generated
vendored
2
vendor/github.com/tailscale/netlink/netns_linux.go
generated
vendored
@@ -15,7 +15,7 @@ package netlink
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/vishvananda/netlink/nl"
|
||||
"github.com/tailscale/netlink/nl"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
|
71
vendor/github.com/tailscale/netlink/nl/addr_linux.go
generated
vendored
Normal file
71
vendor/github.com/tailscale/netlink/nl/addr_linux.go
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
package nl
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
type IfAddrmsg struct {
|
||||
unix.IfAddrmsg
|
||||
}
|
||||
|
||||
func NewIfAddrmsg(family int) *IfAddrmsg {
|
||||
return &IfAddrmsg{
|
||||
IfAddrmsg: unix.IfAddrmsg{
|
||||
Family: uint8(family),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// struct ifaddrmsg {
|
||||
// __u8 ifa_family;
|
||||
// __u8 ifa_prefixlen; /* The prefix length */
|
||||
// __u8 ifa_flags; /* Flags */
|
||||
// __u8 ifa_scope; /* Address scope */
|
||||
// __u32 ifa_index; /* Link index */
|
||||
// };
|
||||
|
||||
// type IfAddrmsg struct {
|
||||
// Family uint8
|
||||
// Prefixlen uint8
|
||||
// Flags uint8
|
||||
// Scope uint8
|
||||
// Index uint32
|
||||
// }
|
||||
// SizeofIfAddrmsg = 0x8
|
||||
|
||||
func DeserializeIfAddrmsg(b []byte) *IfAddrmsg {
|
||||
return (*IfAddrmsg)(unsafe.Pointer(&b[0:unix.SizeofIfAddrmsg][0]))
|
||||
}
|
||||
|
||||
func (msg *IfAddrmsg) Serialize() []byte {
|
||||
return (*(*[unix.SizeofIfAddrmsg]byte)(unsafe.Pointer(msg)))[:]
|
||||
}
|
||||
|
||||
func (msg *IfAddrmsg) Len() int {
|
||||
return unix.SizeofIfAddrmsg
|
||||
}
|
||||
|
||||
// struct ifa_cacheinfo {
|
||||
// __u32 ifa_prefered;
|
||||
// __u32 ifa_valid;
|
||||
// __u32 cstamp; /* created timestamp, hundredths of seconds */
|
||||
// __u32 tstamp; /* updated timestamp, hundredths of seconds */
|
||||
// };
|
||||
|
||||
type IfaCacheInfo struct {
|
||||
unix.IfaCacheinfo
|
||||
}
|
||||
|
||||
func (msg *IfaCacheInfo) Len() int {
|
||||
return unix.SizeofIfaCacheinfo
|
||||
}
|
||||
|
||||
func DeserializeIfaCacheInfo(b []byte) *IfaCacheInfo {
|
||||
return (*IfaCacheInfo)(unsafe.Pointer(&b[0:unix.SizeofIfaCacheinfo][0]))
|
||||
}
|
||||
|
||||
func (msg *IfaCacheInfo) Serialize() []byte {
|
||||
return (*(*[unix.SizeofIfaCacheinfo]byte)(unsafe.Pointer(msg)))[:]
|
||||
}
|
74
vendor/github.com/tailscale/netlink/nl/bridge_linux.go
generated
vendored
Normal file
74
vendor/github.com/tailscale/netlink/nl/bridge_linux.go
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
package nl
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
SizeofBridgeVlanInfo = 0x04
|
||||
)
|
||||
|
||||
/* Bridge Flags */
|
||||
const (
|
||||
BRIDGE_FLAGS_MASTER = iota + 1 /* Bridge command to/from master */
|
||||
BRIDGE_FLAGS_SELF /* Bridge command to/from lowerdev */
|
||||
)
|
||||
|
||||
/* Bridge management nested attributes
|
||||
* [IFLA_AF_SPEC] = {
|
||||
* [IFLA_BRIDGE_FLAGS]
|
||||
* [IFLA_BRIDGE_MODE]
|
||||
* [IFLA_BRIDGE_VLAN_INFO]
|
||||
* }
|
||||
*/
|
||||
const (
|
||||
IFLA_BRIDGE_FLAGS = iota
|
||||
IFLA_BRIDGE_MODE
|
||||
IFLA_BRIDGE_VLAN_INFO
|
||||
)
|
||||
|
||||
const (
|
||||
BRIDGE_VLAN_INFO_MASTER = 1 << iota
|
||||
BRIDGE_VLAN_INFO_PVID
|
||||
BRIDGE_VLAN_INFO_UNTAGGED
|
||||
BRIDGE_VLAN_INFO_RANGE_BEGIN
|
||||
BRIDGE_VLAN_INFO_RANGE_END
|
||||
)
|
||||
|
||||
// struct bridge_vlan_info {
|
||||
// __u16 flags;
|
||||
// __u16 vid;
|
||||
// };
|
||||
|
||||
type BridgeVlanInfo struct {
|
||||
Flags uint16
|
||||
Vid uint16
|
||||
}
|
||||
|
||||
func (b *BridgeVlanInfo) Serialize() []byte {
|
||||
return (*(*[SizeofBridgeVlanInfo]byte)(unsafe.Pointer(b)))[:]
|
||||
}
|
||||
|
||||
func DeserializeBridgeVlanInfo(b []byte) *BridgeVlanInfo {
|
||||
return (*BridgeVlanInfo)(unsafe.Pointer(&b[0:SizeofBridgeVlanInfo][0]))
|
||||
}
|
||||
|
||||
func (b *BridgeVlanInfo) PortVID() bool {
|
||||
return b.Flags&BRIDGE_VLAN_INFO_PVID > 0
|
||||
}
|
||||
|
||||
func (b *BridgeVlanInfo) EngressUntag() bool {
|
||||
return b.Flags&BRIDGE_VLAN_INFO_UNTAGGED > 0
|
||||
}
|
||||
|
||||
func (b *BridgeVlanInfo) String() string {
|
||||
return fmt.Sprintf("%+v", *b)
|
||||
}
|
||||
|
||||
/* New extended info filters for IFLA_EXT_MASK */
|
||||
const (
|
||||
RTEXT_FILTER_VF = 1 << iota
|
||||
RTEXT_FILTER_BRVLAN
|
||||
RTEXT_FILTER_BRVLAN_COMPRESSED
|
||||
)
|
219
vendor/github.com/tailscale/netlink/nl/conntrack_linux.go
generated
vendored
Normal file
219
vendor/github.com/tailscale/netlink/nl/conntrack_linux.go
generated
vendored
Normal file
@@ -0,0 +1,219 @@
|
||||
package nl
|
||||
|
||||
import "unsafe"
|
||||
|
||||
// Track the message sizes for the correct serialization/deserialization
|
||||
const (
|
||||
SizeofNfgenmsg = 4
|
||||
SizeofNfattr = 4
|
||||
SizeofNfConntrack = 376
|
||||
SizeofNfctTupleHead = 52
|
||||
)
|
||||
|
||||
var L4ProtoMap = map[uint8]string{
|
||||
6: "tcp",
|
||||
17: "udp",
|
||||
}
|
||||
|
||||
// All the following constants are coming from:
|
||||
// https://github.com/torvalds/linux/blob/master/include/uapi/linux/netfilter/nfnetlink_conntrack.h
|
||||
|
||||
// enum cntl_msg_types {
|
||||
// IPCTNL_MSG_CT_NEW,
|
||||
// IPCTNL_MSG_CT_GET,
|
||||
// IPCTNL_MSG_CT_DELETE,
|
||||
// IPCTNL_MSG_CT_GET_CTRZERO,
|
||||
// IPCTNL_MSG_CT_GET_STATS_CPU,
|
||||
// IPCTNL_MSG_CT_GET_STATS,
|
||||
// IPCTNL_MSG_CT_GET_DYING,
|
||||
// IPCTNL_MSG_CT_GET_UNCONFIRMED,
|
||||
//
|
||||
// IPCTNL_MSG_MAX
|
||||
// };
|
||||
const (
|
||||
IPCTNL_MSG_CT_GET = 1
|
||||
IPCTNL_MSG_CT_DELETE = 2
|
||||
)
|
||||
|
||||
// #define NFNETLINK_V0 0
|
||||
const (
|
||||
NFNETLINK_V0 = 0
|
||||
)
|
||||
|
||||
const (
|
||||
NLA_F_NESTED uint16 = (1 << 15) // #define NLA_F_NESTED (1 << 15)
|
||||
NLA_F_NET_BYTEORDER uint16 = (1 << 14) // #define NLA_F_NESTED (1 << 14)
|
||||
NLA_TYPE_MASK = ^(NLA_F_NESTED | NLA_F_NET_BYTEORDER)
|
||||
NLA_ALIGNTO uint16 = 4 // #define NLA_ALIGNTO 4
|
||||
)
|
||||
|
||||
// enum ctattr_type {
|
||||
// CTA_UNSPEC,
|
||||
// CTA_TUPLE_ORIG,
|
||||
// CTA_TUPLE_REPLY,
|
||||
// CTA_STATUS,
|
||||
// CTA_PROTOINFO,
|
||||
// CTA_HELP,
|
||||
// CTA_NAT_SRC,
|
||||
// #define CTA_NAT CTA_NAT_SRC /* backwards compatibility */
|
||||
// CTA_TIMEOUT,
|
||||
// CTA_MARK,
|
||||
// CTA_COUNTERS_ORIG,
|
||||
// CTA_COUNTERS_REPLY,
|
||||
// CTA_USE,
|
||||
// CTA_ID,
|
||||
// CTA_NAT_DST,
|
||||
// CTA_TUPLE_MASTER,
|
||||
// CTA_SEQ_ADJ_ORIG,
|
||||
// CTA_NAT_SEQ_ADJ_ORIG = CTA_SEQ_ADJ_ORIG,
|
||||
// CTA_SEQ_ADJ_REPLY,
|
||||
// CTA_NAT_SEQ_ADJ_REPLY = CTA_SEQ_ADJ_REPLY,
|
||||
// CTA_SECMARK, /* obsolete */
|
||||
// CTA_ZONE,
|
||||
// CTA_SECCTX,
|
||||
// CTA_TIMESTAMP,
|
||||
// CTA_MARK_MASK,
|
||||
// CTA_LABELS,
|
||||
// CTA_LABELS_MASK,
|
||||
// __CTA_MAX
|
||||
// };
|
||||
const (
|
||||
CTA_TUPLE_ORIG = 1
|
||||
CTA_TUPLE_REPLY = 2
|
||||
CTA_STATUS = 3
|
||||
CTA_PROTOINFO = 4
|
||||
CTA_TIMEOUT = 7
|
||||
CTA_MARK = 8
|
||||
CTA_COUNTERS_ORIG = 9
|
||||
CTA_COUNTERS_REPLY = 10
|
||||
CTA_USE = 11
|
||||
CTA_ID = 12
|
||||
CTA_TIMESTAMP = 20
|
||||
)
|
||||
|
||||
// enum ctattr_tuple {
|
||||
// CTA_TUPLE_UNSPEC,
|
||||
// CTA_TUPLE_IP,
|
||||
// CTA_TUPLE_PROTO,
|
||||
// CTA_TUPLE_ZONE,
|
||||
// __CTA_TUPLE_MAX
|
||||
// };
|
||||
// #define CTA_TUPLE_MAX (__CTA_TUPLE_MAX - 1)
|
||||
const (
|
||||
CTA_TUPLE_IP = 1
|
||||
CTA_TUPLE_PROTO = 2
|
||||
)
|
||||
|
||||
// enum ctattr_ip {
|
||||
// CTA_IP_UNSPEC,
|
||||
// CTA_IP_V4_SRC,
|
||||
// CTA_IP_V4_DST,
|
||||
// CTA_IP_V6_SRC,
|
||||
// CTA_IP_V6_DST,
|
||||
// __CTA_IP_MAX
|
||||
// };
|
||||
// #define CTA_IP_MAX (__CTA_IP_MAX - 1)
|
||||
const (
|
||||
CTA_IP_V4_SRC = 1
|
||||
CTA_IP_V4_DST = 2
|
||||
CTA_IP_V6_SRC = 3
|
||||
CTA_IP_V6_DST = 4
|
||||
)
|
||||
|
||||
// enum ctattr_l4proto {
|
||||
// CTA_PROTO_UNSPEC,
|
||||
// CTA_PROTO_NUM,
|
||||
// CTA_PROTO_SRC_PORT,
|
||||
// CTA_PROTO_DST_PORT,
|
||||
// CTA_PROTO_ICMP_ID,
|
||||
// CTA_PROTO_ICMP_TYPE,
|
||||
// CTA_PROTO_ICMP_CODE,
|
||||
// CTA_PROTO_ICMPV6_ID,
|
||||
// CTA_PROTO_ICMPV6_TYPE,
|
||||
// CTA_PROTO_ICMPV6_CODE,
|
||||
// __CTA_PROTO_MAX
|
||||
// };
|
||||
// #define CTA_PROTO_MAX (__CTA_PROTO_MAX - 1)
|
||||
const (
|
||||
CTA_PROTO_NUM = 1
|
||||
CTA_PROTO_SRC_PORT = 2
|
||||
CTA_PROTO_DST_PORT = 3
|
||||
)
|
||||
|
||||
// enum ctattr_protoinfo {
|
||||
// CTA_PROTOINFO_UNSPEC,
|
||||
// CTA_PROTOINFO_TCP,
|
||||
// CTA_PROTOINFO_DCCP,
|
||||
// CTA_PROTOINFO_SCTP,
|
||||
// __CTA_PROTOINFO_MAX
|
||||
// };
|
||||
// #define CTA_PROTOINFO_MAX (__CTA_PROTOINFO_MAX - 1)
|
||||
const (
|
||||
CTA_PROTOINFO_TCP = 1
|
||||
)
|
||||
|
||||
// enum ctattr_protoinfo_tcp {
|
||||
// CTA_PROTOINFO_TCP_UNSPEC,
|
||||
// CTA_PROTOINFO_TCP_STATE,
|
||||
// CTA_PROTOINFO_TCP_WSCALE_ORIGINAL,
|
||||
// CTA_PROTOINFO_TCP_WSCALE_REPLY,
|
||||
// CTA_PROTOINFO_TCP_FLAGS_ORIGINAL,
|
||||
// CTA_PROTOINFO_TCP_FLAGS_REPLY,
|
||||
// __CTA_PROTOINFO_TCP_MAX
|
||||
// };
|
||||
// #define CTA_PROTOINFO_TCP_MAX (__CTA_PROTOINFO_TCP_MAX - 1)
|
||||
const (
|
||||
CTA_PROTOINFO_TCP_STATE = 1
|
||||
CTA_PROTOINFO_TCP_WSCALE_ORIGINAL = 2
|
||||
CTA_PROTOINFO_TCP_WSCALE_REPLY = 3
|
||||
CTA_PROTOINFO_TCP_FLAGS_ORIGINAL = 4
|
||||
CTA_PROTOINFO_TCP_FLAGS_REPLY = 5
|
||||
)
|
||||
|
||||
// enum ctattr_counters {
|
||||
// CTA_COUNTERS_UNSPEC,
|
||||
// CTA_COUNTERS_PACKETS, /* 64bit counters */
|
||||
// CTA_COUNTERS_BYTES, /* 64bit counters */
|
||||
// CTA_COUNTERS32_PACKETS, /* old 32bit counters, unused */
|
||||
// CTA_COUNTERS32_BYTES, /* old 32bit counters, unused */
|
||||
// CTA_COUNTERS_PAD,
|
||||
// __CTA_COUNTERS_M
|
||||
// };
|
||||
// #define CTA_COUNTERS_MAX (__CTA_COUNTERS_MAX - 1)
|
||||
const (
|
||||
CTA_COUNTERS_PACKETS = 1
|
||||
CTA_COUNTERS_BYTES = 2
|
||||
)
|
||||
|
||||
// enum CTA TIMESTAMP TLVs
|
||||
// CTA_TIMESTAMP_START /* 64bit value */
|
||||
// CTA_TIMESTAMP_STOP /* 64bit value */
|
||||
const (
|
||||
CTA_TIMESTAMP_START = 1
|
||||
CTA_TIMESTAMP_STOP = 2
|
||||
)
|
||||
|
||||
// /* General form of address family dependent message.
|
||||
// */
|
||||
// struct nfgenmsg {
|
||||
// __u8 nfgen_family; /* AF_xxx */
|
||||
// __u8 version; /* nfnetlink version */
|
||||
// __be16 res_id; /* resource id */
|
||||
// };
|
||||
type Nfgenmsg struct {
|
||||
NfgenFamily uint8
|
||||
Version uint8
|
||||
ResId uint16 // big endian
|
||||
}
|
||||
|
||||
func (msg *Nfgenmsg) Len() int {
|
||||
return SizeofNfgenmsg
|
||||
}
|
||||
|
||||
func DeserializeNfgenmsg(b []byte) *Nfgenmsg {
|
||||
return (*Nfgenmsg)(unsafe.Pointer(&b[0:SizeofNfgenmsg][0]))
|
||||
}
|
||||
|
||||
func (msg *Nfgenmsg) Serialize() []byte {
|
||||
return (*(*[SizeofNfgenmsg]byte)(unsafe.Pointer(msg)))[:]
|
||||
}
|
96
vendor/github.com/tailscale/netlink/nl/devlink_linux.go
generated
vendored
Normal file
96
vendor/github.com/tailscale/netlink/nl/devlink_linux.go
generated
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
package nl
|
||||
|
||||
// All the following constants are coming from:
|
||||
// https://github.com/torvalds/linux/blob/master/include/uapi/linux/devlink.h
|
||||
|
||||
const (
|
||||
GENL_DEVLINK_VERSION = 1
|
||||
GENL_DEVLINK_NAME = "devlink"
|
||||
)
|
||||
|
||||
const (
|
||||
DEVLINK_CMD_GET = 1
|
||||
DEVLINK_CMD_PORT_GET = 5
|
||||
DEVLINK_CMD_PORT_SET = 6
|
||||
DEVLINK_CMD_PORT_NEW = 7
|
||||
DEVLINK_CMD_PORT_DEL = 8
|
||||
DEVLINK_CMD_ESWITCH_GET = 29
|
||||
DEVLINK_CMD_ESWITCH_SET = 30
|
||||
DEVLINK_CMD_INFO_GET = 51
|
||||
)
|
||||
|
||||
const (
|
||||
DEVLINK_ATTR_BUS_NAME = 1
|
||||
DEVLINK_ATTR_DEV_NAME = 2
|
||||
DEVLINK_ATTR_PORT_INDEX = 3
|
||||
DEVLINK_ATTR_PORT_TYPE = 4
|
||||
DEVLINK_ATTR_PORT_NETDEV_IFINDEX = 6
|
||||
DEVLINK_ATTR_PORT_NETDEV_NAME = 7
|
||||
DEVLINK_ATTR_PORT_IBDEV_NAME = 8
|
||||
DEVLINK_ATTR_ESWITCH_MODE = 25
|
||||
DEVLINK_ATTR_ESWITCH_INLINE_MODE = 26
|
||||
DEVLINK_ATTR_ESWITCH_ENCAP_MODE = 62
|
||||
DEVLINK_ATTR_PORT_FLAVOUR = 77
|
||||
DEVLINK_ATTR_INFO_DRIVER_NAME = 98
|
||||
DEVLINK_ATTR_INFO_SERIAL_NUMBER = 99
|
||||
DEVLINK_ATTR_INFO_VERSION_FIXED = 100
|
||||
DEVLINK_ATTR_INFO_VERSION_RUNNING = 101
|
||||
DEVLINK_ATTR_INFO_VERSION_STORED = 102
|
||||
DEVLINK_ATTR_INFO_VERSION_NAME = 103
|
||||
DEVLINK_ATTR_INFO_VERSION_VALUE = 104
|
||||
DEVLINK_ATTR_PORT_PCI_PF_NUMBER = 127
|
||||
DEVLINK_ATTR_PORT_FUNCTION = 145
|
||||
DEVLINK_ATTR_PORT_CONTROLLER_NUMBER = 150
|
||||
DEVLINK_ATTR_PORT_PCI_SF_NUMBER = 164
|
||||
)
|
||||
|
||||
const (
|
||||
DEVLINK_ESWITCH_MODE_LEGACY = 0
|
||||
DEVLINK_ESWITCH_MODE_SWITCHDEV = 1
|
||||
)
|
||||
|
||||
const (
|
||||
DEVLINK_ESWITCH_INLINE_MODE_NONE = 0
|
||||
DEVLINK_ESWITCH_INLINE_MODE_LINK = 1
|
||||
DEVLINK_ESWITCH_INLINE_MODE_NETWORK = 2
|
||||
DEVLINK_ESWITCH_INLINE_MODE_TRANSPORT = 3
|
||||
)
|
||||
|
||||
const (
|
||||
DEVLINK_ESWITCH_ENCAP_MODE_NONE = 0
|
||||
DEVLINK_ESWITCH_ENCAP_MODE_BASIC = 1
|
||||
)
|
||||
|
||||
const (
|
||||
DEVLINK_PORT_FLAVOUR_PHYSICAL = 0
|
||||
DEVLINK_PORT_FLAVOUR_CPU = 1
|
||||
DEVLINK_PORT_FLAVOUR_DSA = 2
|
||||
DEVLINK_PORT_FLAVOUR_PCI_PF = 3
|
||||
DEVLINK_PORT_FLAVOUR_PCI_VF = 4
|
||||
DEVLINK_PORT_FLAVOUR_VIRTUAL = 5
|
||||
DEVLINK_PORT_FLAVOUR_UNUSED = 6
|
||||
DEVLINK_PORT_FLAVOUR_PCI_SF = 7
|
||||
)
|
||||
|
||||
const (
|
||||
DEVLINK_PORT_TYPE_NOTSET = 0
|
||||
DEVLINK_PORT_TYPE_AUTO = 1
|
||||
DEVLINK_PORT_TYPE_ETH = 2
|
||||
DEVLINK_PORT_TYPE_IB = 3
|
||||
)
|
||||
|
||||
const (
|
||||
DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR = 1
|
||||
DEVLINK_PORT_FN_ATTR_STATE = 2
|
||||
DEVLINK_PORT_FN_ATTR_OPSTATE = 3
|
||||
)
|
||||
|
||||
const (
|
||||
DEVLINK_PORT_FN_STATE_INACTIVE = 0
|
||||
DEVLINK_PORT_FN_STATE_ACTIVE = 1
|
||||
)
|
||||
|
||||
const (
|
||||
DEVLINK_PORT_FN_OPSTATE_DETACHED = 0
|
||||
DEVLINK_PORT_FN_OPSTATE_ATTACHED = 1
|
||||
)
|
89
vendor/github.com/tailscale/netlink/nl/genetlink_linux.go
generated
vendored
Normal file
89
vendor/github.com/tailscale/netlink/nl/genetlink_linux.go
generated
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
package nl
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
const SizeofGenlmsg = 4
|
||||
|
||||
const (
|
||||
GENL_ID_CTRL = 0x10
|
||||
GENL_CTRL_VERSION = 2
|
||||
GENL_CTRL_NAME = "nlctrl"
|
||||
)
|
||||
|
||||
const (
|
||||
GENL_CTRL_CMD_GETFAMILY = 3
|
||||
)
|
||||
|
||||
const (
|
||||
GENL_CTRL_ATTR_UNSPEC = iota
|
||||
GENL_CTRL_ATTR_FAMILY_ID
|
||||
GENL_CTRL_ATTR_FAMILY_NAME
|
||||
GENL_CTRL_ATTR_VERSION
|
||||
GENL_CTRL_ATTR_HDRSIZE
|
||||
GENL_CTRL_ATTR_MAXATTR
|
||||
GENL_CTRL_ATTR_OPS
|
||||
GENL_CTRL_ATTR_MCAST_GROUPS
|
||||
)
|
||||
|
||||
const (
|
||||
GENL_CTRL_ATTR_OP_UNSPEC = iota
|
||||
GENL_CTRL_ATTR_OP_ID
|
||||
GENL_CTRL_ATTR_OP_FLAGS
|
||||
)
|
||||
|
||||
const (
|
||||
GENL_ADMIN_PERM = 1 << iota
|
||||
GENL_CMD_CAP_DO
|
||||
GENL_CMD_CAP_DUMP
|
||||
GENL_CMD_CAP_HASPOL
|
||||
)
|
||||
|
||||
const (
|
||||
GENL_CTRL_ATTR_MCAST_GRP_UNSPEC = iota
|
||||
GENL_CTRL_ATTR_MCAST_GRP_NAME
|
||||
GENL_CTRL_ATTR_MCAST_GRP_ID
|
||||
)
|
||||
|
||||
const (
|
||||
GENL_GTP_VERSION = 0
|
||||
GENL_GTP_NAME = "gtp"
|
||||
)
|
||||
|
||||
const (
|
||||
GENL_GTP_CMD_NEWPDP = iota
|
||||
GENL_GTP_CMD_DELPDP
|
||||
GENL_GTP_CMD_GETPDP
|
||||
)
|
||||
|
||||
const (
|
||||
GENL_GTP_ATTR_UNSPEC = iota
|
||||
GENL_GTP_ATTR_LINK
|
||||
GENL_GTP_ATTR_VERSION
|
||||
GENL_GTP_ATTR_TID
|
||||
GENL_GTP_ATTR_PEER_ADDRESS
|
||||
GENL_GTP_ATTR_MS_ADDRESS
|
||||
GENL_GTP_ATTR_FLOW
|
||||
GENL_GTP_ATTR_NET_NS_FD
|
||||
GENL_GTP_ATTR_I_TEI
|
||||
GENL_GTP_ATTR_O_TEI
|
||||
GENL_GTP_ATTR_PAD
|
||||
)
|
||||
|
||||
type Genlmsg struct {
|
||||
Command uint8
|
||||
Version uint8
|
||||
}
|
||||
|
||||
func (msg *Genlmsg) Len() int {
|
||||
return SizeofGenlmsg
|
||||
}
|
||||
|
||||
func DeserializeGenlmsg(b []byte) *Genlmsg {
|
||||
return (*Genlmsg)(unsafe.Pointer(&b[0:SizeofGenlmsg][0]))
|
||||
}
|
||||
|
||||
func (msg *Genlmsg) Serialize() []byte {
|
||||
return (*(*[SizeofGenlmsg]byte)(unsafe.Pointer(msg)))[:]
|
||||
}
|
222
vendor/github.com/tailscale/netlink/nl/ipset_linux.go
generated
vendored
Normal file
222
vendor/github.com/tailscale/netlink/nl/ipset_linux.go
generated
vendored
Normal file
@@ -0,0 +1,222 @@
|
||||
package nl
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
const (
|
||||
/* The protocol version */
|
||||
IPSET_PROTOCOL = 6
|
||||
|
||||
/* The max length of strings including NUL: set and type identifiers */
|
||||
IPSET_MAXNAMELEN = 32
|
||||
|
||||
/* The maximum permissible comment length we will accept over netlink */
|
||||
IPSET_MAX_COMMENT_SIZE = 255
|
||||
)
|
||||
|
||||
const (
|
||||
_ = iota
|
||||
IPSET_CMD_PROTOCOL /* 1: Return protocol version */
|
||||
IPSET_CMD_CREATE /* 2: Create a new (empty) set */
|
||||
IPSET_CMD_DESTROY /* 3: Destroy a (empty) set */
|
||||
IPSET_CMD_FLUSH /* 4: Remove all elements from a set */
|
||||
IPSET_CMD_RENAME /* 5: Rename a set */
|
||||
IPSET_CMD_SWAP /* 6: Swap two sets */
|
||||
IPSET_CMD_LIST /* 7: List sets */
|
||||
IPSET_CMD_SAVE /* 8: Save sets */
|
||||
IPSET_CMD_ADD /* 9: Add an element to a set */
|
||||
IPSET_CMD_DEL /* 10: Delete an element from a set */
|
||||
IPSET_CMD_TEST /* 11: Test an element in a set */
|
||||
IPSET_CMD_HEADER /* 12: Get set header data only */
|
||||
IPSET_CMD_TYPE /* 13: Get set type */
|
||||
)
|
||||
|
||||
/* Attributes at command level */
|
||||
const (
|
||||
_ = iota
|
||||
IPSET_ATTR_PROTOCOL /* 1: Protocol version */
|
||||
IPSET_ATTR_SETNAME /* 2: Name of the set */
|
||||
IPSET_ATTR_TYPENAME /* 3: Typename */
|
||||
IPSET_ATTR_REVISION /* 4: Settype revision */
|
||||
IPSET_ATTR_FAMILY /* 5: Settype family */
|
||||
IPSET_ATTR_FLAGS /* 6: Flags at command level */
|
||||
IPSET_ATTR_DATA /* 7: Nested attributes */
|
||||
IPSET_ATTR_ADT /* 8: Multiple data containers */
|
||||
IPSET_ATTR_LINENO /* 9: Restore lineno */
|
||||
IPSET_ATTR_PROTOCOL_MIN /* 10: Minimal supported version number */
|
||||
|
||||
IPSET_ATTR_SETNAME2 = IPSET_ATTR_TYPENAME /* Setname at rename/swap */
|
||||
IPSET_ATTR_REVISION_MIN = IPSET_ATTR_PROTOCOL_MIN /* type rev min */
|
||||
)
|
||||
|
||||
/* CADT specific attributes */
|
||||
const (
|
||||
IPSET_ATTR_IP = 1
|
||||
IPSET_ATTR_IP_FROM = 1
|
||||
IPSET_ATTR_IP_TO = 2
|
||||
IPSET_ATTR_CIDR = 3
|
||||
IPSET_ATTR_PORT = 4
|
||||
IPSET_ATTR_PORT_FROM = 4
|
||||
IPSET_ATTR_PORT_TO = 5
|
||||
IPSET_ATTR_TIMEOUT = 6
|
||||
IPSET_ATTR_PROTO = 7
|
||||
IPSET_ATTR_CADT_FLAGS = 8
|
||||
IPSET_ATTR_CADT_LINENO = IPSET_ATTR_LINENO /* 9 */
|
||||
IPSET_ATTR_MARK = 10
|
||||
IPSET_ATTR_MARKMASK = 11
|
||||
|
||||
/* Reserve empty slots */
|
||||
IPSET_ATTR_CADT_MAX = 16
|
||||
|
||||
/* Create-only specific attributes */
|
||||
IPSET_ATTR_GC = 3 + iota
|
||||
IPSET_ATTR_HASHSIZE
|
||||
IPSET_ATTR_MAXELEM
|
||||
IPSET_ATTR_NETMASK
|
||||
IPSET_ATTR_PROBES
|
||||
IPSET_ATTR_RESIZE
|
||||
IPSET_ATTR_SIZE
|
||||
|
||||
/* Kernel-only */
|
||||
IPSET_ATTR_ELEMENTS
|
||||
IPSET_ATTR_REFERENCES
|
||||
IPSET_ATTR_MEMSIZE
|
||||
|
||||
SET_ATTR_CREATE_MAX
|
||||
)
|
||||
|
||||
/* ADT specific attributes */
|
||||
const (
|
||||
IPSET_ATTR_ETHER = IPSET_ATTR_CADT_MAX + iota + 1
|
||||
IPSET_ATTR_NAME
|
||||
IPSET_ATTR_NAMEREF
|
||||
IPSET_ATTR_IP2
|
||||
IPSET_ATTR_CIDR2
|
||||
IPSET_ATTR_IP2_TO
|
||||
IPSET_ATTR_IFACE
|
||||
IPSET_ATTR_BYTES
|
||||
IPSET_ATTR_PACKETS
|
||||
IPSET_ATTR_COMMENT
|
||||
IPSET_ATTR_SKBMARK
|
||||
IPSET_ATTR_SKBPRIO
|
||||
IPSET_ATTR_SKBQUEUE
|
||||
)
|
||||
|
||||
/* Flags at CADT attribute level, upper half of cmdattrs */
|
||||
const (
|
||||
IPSET_FLAG_BIT_BEFORE = 0
|
||||
IPSET_FLAG_BEFORE = (1 << IPSET_FLAG_BIT_BEFORE)
|
||||
IPSET_FLAG_BIT_PHYSDEV = 1
|
||||
IPSET_FLAG_PHYSDEV = (1 << IPSET_FLAG_BIT_PHYSDEV)
|
||||
IPSET_FLAG_BIT_NOMATCH = 2
|
||||
IPSET_FLAG_NOMATCH = (1 << IPSET_FLAG_BIT_NOMATCH)
|
||||
IPSET_FLAG_BIT_WITH_COUNTERS = 3
|
||||
IPSET_FLAG_WITH_COUNTERS = (1 << IPSET_FLAG_BIT_WITH_COUNTERS)
|
||||
IPSET_FLAG_BIT_WITH_COMMENT = 4
|
||||
IPSET_FLAG_WITH_COMMENT = (1 << IPSET_FLAG_BIT_WITH_COMMENT)
|
||||
IPSET_FLAG_BIT_WITH_FORCEADD = 5
|
||||
IPSET_FLAG_WITH_FORCEADD = (1 << IPSET_FLAG_BIT_WITH_FORCEADD)
|
||||
IPSET_FLAG_BIT_WITH_SKBINFO = 6
|
||||
IPSET_FLAG_WITH_SKBINFO = (1 << IPSET_FLAG_BIT_WITH_SKBINFO)
|
||||
IPSET_FLAG_CADT_MAX = 15
|
||||
)
|
||||
|
||||
const (
|
||||
IPSET_ERR_PRIVATE = 4096 + iota
|
||||
IPSET_ERR_PROTOCOL
|
||||
IPSET_ERR_FIND_TYPE
|
||||
IPSET_ERR_MAX_SETS
|
||||
IPSET_ERR_BUSY
|
||||
IPSET_ERR_EXIST_SETNAME2
|
||||
IPSET_ERR_TYPE_MISMATCH
|
||||
IPSET_ERR_EXIST
|
||||
IPSET_ERR_INVALID_CIDR
|
||||
IPSET_ERR_INVALID_NETMASK
|
||||
IPSET_ERR_INVALID_FAMILY
|
||||
IPSET_ERR_TIMEOUT
|
||||
IPSET_ERR_REFERENCED
|
||||
IPSET_ERR_IPADDR_IPV4
|
||||
IPSET_ERR_IPADDR_IPV6
|
||||
IPSET_ERR_COUNTER
|
||||
IPSET_ERR_COMMENT
|
||||
IPSET_ERR_INVALID_MARKMASK
|
||||
IPSET_ERR_SKBINFO
|
||||
|
||||
/* Type specific error codes */
|
||||
IPSET_ERR_TYPE_SPECIFIC = 4352
|
||||
)
|
||||
|
||||
type IPSetError uintptr
|
||||
|
||||
func (e IPSetError) Error() string {
|
||||
switch int(e) {
|
||||
case IPSET_ERR_PRIVATE:
|
||||
return "private"
|
||||
case IPSET_ERR_PROTOCOL:
|
||||
return "invalid protocol"
|
||||
case IPSET_ERR_FIND_TYPE:
|
||||
return "invalid type"
|
||||
case IPSET_ERR_MAX_SETS:
|
||||
return "max sets reached"
|
||||
case IPSET_ERR_BUSY:
|
||||
return "busy"
|
||||
case IPSET_ERR_EXIST_SETNAME2:
|
||||
return "exist_setname2"
|
||||
case IPSET_ERR_TYPE_MISMATCH:
|
||||
return "type mismatch"
|
||||
case IPSET_ERR_EXIST:
|
||||
return "exist"
|
||||
case IPSET_ERR_INVALID_CIDR:
|
||||
return "invalid cidr"
|
||||
case IPSET_ERR_INVALID_NETMASK:
|
||||
return "invalid netmask"
|
||||
case IPSET_ERR_INVALID_FAMILY:
|
||||
return "invalid family"
|
||||
case IPSET_ERR_TIMEOUT:
|
||||
return "timeout"
|
||||
case IPSET_ERR_REFERENCED:
|
||||
return "referenced"
|
||||
case IPSET_ERR_IPADDR_IPV4:
|
||||
return "invalid ipv4 address"
|
||||
case IPSET_ERR_IPADDR_IPV6:
|
||||
return "invalid ipv6 address"
|
||||
case IPSET_ERR_COUNTER:
|
||||
return "invalid counter"
|
||||
case IPSET_ERR_COMMENT:
|
||||
return "invalid comment"
|
||||
case IPSET_ERR_INVALID_MARKMASK:
|
||||
return "invalid markmask"
|
||||
case IPSET_ERR_SKBINFO:
|
||||
return "skbinfo"
|
||||
default:
|
||||
return "errno " + strconv.Itoa(int(e))
|
||||
}
|
||||
}
|
||||
|
||||
func GetIpsetFlags(cmd int) int {
|
||||
switch cmd {
|
||||
case IPSET_CMD_CREATE:
|
||||
return unix.NLM_F_REQUEST | unix.NLM_F_ACK | unix.NLM_F_CREATE
|
||||
case IPSET_CMD_DESTROY,
|
||||
IPSET_CMD_FLUSH,
|
||||
IPSET_CMD_RENAME,
|
||||
IPSET_CMD_SWAP,
|
||||
IPSET_CMD_TEST:
|
||||
return unix.NLM_F_REQUEST | unix.NLM_F_ACK
|
||||
case IPSET_CMD_LIST,
|
||||
IPSET_CMD_SAVE:
|
||||
return unix.NLM_F_REQUEST | unix.NLM_F_ACK | unix.NLM_F_ROOT | unix.NLM_F_MATCH | unix.NLM_F_DUMP
|
||||
case IPSET_CMD_ADD,
|
||||
IPSET_CMD_DEL:
|
||||
return unix.NLM_F_REQUEST | unix.NLM_F_ACK
|
||||
case IPSET_CMD_HEADER,
|
||||
IPSET_CMD_TYPE,
|
||||
IPSET_CMD_PROTOCOL:
|
||||
return unix.NLM_F_REQUEST
|
||||
default:
|
||||
return 0
|
||||
}
|
||||
}
|
720
vendor/github.com/tailscale/netlink/nl/link_linux.go
generated
vendored
Normal file
720
vendor/github.com/tailscale/netlink/nl/link_linux.go
generated
vendored
Normal file
@@ -0,0 +1,720 @@
|
||||
package nl
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
DEFAULT_CHANGE = 0xFFFFFFFF
|
||||
)
|
||||
|
||||
const (
|
||||
IFLA_INFO_UNSPEC = iota
|
||||
IFLA_INFO_KIND
|
||||
IFLA_INFO_DATA
|
||||
IFLA_INFO_XSTATS
|
||||
IFLA_INFO_SLAVE_KIND
|
||||
IFLA_INFO_SLAVE_DATA
|
||||
IFLA_INFO_MAX = IFLA_INFO_SLAVE_DATA
|
||||
)
|
||||
|
||||
const (
|
||||
IFLA_VLAN_UNSPEC = iota
|
||||
IFLA_VLAN_ID
|
||||
IFLA_VLAN_FLAGS
|
||||
IFLA_VLAN_EGRESS_QOS
|
||||
IFLA_VLAN_INGRESS_QOS
|
||||
IFLA_VLAN_PROTOCOL
|
||||
IFLA_VLAN_MAX = IFLA_VLAN_PROTOCOL
|
||||
)
|
||||
|
||||
const (
|
||||
VETH_INFO_UNSPEC = iota
|
||||
VETH_INFO_PEER
|
||||
VETH_INFO_MAX = VETH_INFO_PEER
|
||||
)
|
||||
|
||||
const (
|
||||
IFLA_VXLAN_UNSPEC = iota
|
||||
IFLA_VXLAN_ID
|
||||
IFLA_VXLAN_GROUP
|
||||
IFLA_VXLAN_LINK
|
||||
IFLA_VXLAN_LOCAL
|
||||
IFLA_VXLAN_TTL
|
||||
IFLA_VXLAN_TOS
|
||||
IFLA_VXLAN_LEARNING
|
||||
IFLA_VXLAN_AGEING
|
||||
IFLA_VXLAN_LIMIT
|
||||
IFLA_VXLAN_PORT_RANGE
|
||||
IFLA_VXLAN_PROXY
|
||||
IFLA_VXLAN_RSC
|
||||
IFLA_VXLAN_L2MISS
|
||||
IFLA_VXLAN_L3MISS
|
||||
IFLA_VXLAN_PORT
|
||||
IFLA_VXLAN_GROUP6
|
||||
IFLA_VXLAN_LOCAL6
|
||||
IFLA_VXLAN_UDP_CSUM
|
||||
IFLA_VXLAN_UDP_ZERO_CSUM6_TX
|
||||
IFLA_VXLAN_UDP_ZERO_CSUM6_RX
|
||||
IFLA_VXLAN_REMCSUM_TX
|
||||
IFLA_VXLAN_REMCSUM_RX
|
||||
IFLA_VXLAN_GBP
|
||||
IFLA_VXLAN_REMCSUM_NOPARTIAL
|
||||
IFLA_VXLAN_FLOWBASED
|
||||
IFLA_VXLAN_MAX = IFLA_VXLAN_FLOWBASED
|
||||
)
|
||||
|
||||
const (
|
||||
BRIDGE_MODE_UNSPEC = iota
|
||||
BRIDGE_MODE_HAIRPIN
|
||||
)
|
||||
|
||||
const (
|
||||
IFLA_BRPORT_UNSPEC = iota
|
||||
IFLA_BRPORT_STATE
|
||||
IFLA_BRPORT_PRIORITY
|
||||
IFLA_BRPORT_COST
|
||||
IFLA_BRPORT_MODE
|
||||
IFLA_BRPORT_GUARD
|
||||
IFLA_BRPORT_PROTECT
|
||||
IFLA_BRPORT_FAST_LEAVE
|
||||
IFLA_BRPORT_LEARNING
|
||||
IFLA_BRPORT_UNICAST_FLOOD
|
||||
IFLA_BRPORT_PROXYARP
|
||||
IFLA_BRPORT_LEARNING_SYNC
|
||||
IFLA_BRPORT_PROXYARP_WIFI
|
||||
IFLA_BRPORT_MAX = IFLA_BRPORT_PROXYARP_WIFI
|
||||
)
|
||||
|
||||
const (
|
||||
IFLA_IPVLAN_UNSPEC = iota
|
||||
IFLA_IPVLAN_MODE
|
||||
IFLA_IPVLAN_FLAG
|
||||
IFLA_IPVLAN_MAX = IFLA_IPVLAN_FLAG
|
||||
)
|
||||
|
||||
const (
|
||||
IFLA_MACVLAN_UNSPEC = iota
|
||||
IFLA_MACVLAN_MODE
|
||||
IFLA_MACVLAN_FLAGS
|
||||
IFLA_MACVLAN_MACADDR_MODE
|
||||
IFLA_MACVLAN_MACADDR
|
||||
IFLA_MACVLAN_MACADDR_DATA
|
||||
IFLA_MACVLAN_MACADDR_COUNT
|
||||
IFLA_MACVLAN_MAX = IFLA_MACVLAN_FLAGS
|
||||
)
|
||||
|
||||
const (
|
||||
MACVLAN_MODE_PRIVATE = 1
|
||||
MACVLAN_MODE_VEPA = 2
|
||||
MACVLAN_MODE_BRIDGE = 4
|
||||
MACVLAN_MODE_PASSTHRU = 8
|
||||
MACVLAN_MODE_SOURCE = 16
|
||||
)
|
||||
|
||||
const (
|
||||
MACVLAN_MACADDR_ADD = iota
|
||||
MACVLAN_MACADDR_DEL
|
||||
MACVLAN_MACADDR_FLUSH
|
||||
MACVLAN_MACADDR_SET
|
||||
)
|
||||
|
||||
const (
|
||||
IFLA_BOND_UNSPEC = iota
|
||||
IFLA_BOND_MODE
|
||||
IFLA_BOND_ACTIVE_SLAVE
|
||||
IFLA_BOND_MIIMON
|
||||
IFLA_BOND_UPDELAY
|
||||
IFLA_BOND_DOWNDELAY
|
||||
IFLA_BOND_USE_CARRIER
|
||||
IFLA_BOND_ARP_INTERVAL
|
||||
IFLA_BOND_ARP_IP_TARGET
|
||||
IFLA_BOND_ARP_VALIDATE
|
||||
IFLA_BOND_ARP_ALL_TARGETS
|
||||
IFLA_BOND_PRIMARY
|
||||
IFLA_BOND_PRIMARY_RESELECT
|
||||
IFLA_BOND_FAIL_OVER_MAC
|
||||
IFLA_BOND_XMIT_HASH_POLICY
|
||||
IFLA_BOND_RESEND_IGMP
|
||||
IFLA_BOND_NUM_PEER_NOTIF
|
||||
IFLA_BOND_ALL_SLAVES_ACTIVE
|
||||
IFLA_BOND_MIN_LINKS
|
||||
IFLA_BOND_LP_INTERVAL
|
||||
IFLA_BOND_PACKETS_PER_SLAVE
|
||||
IFLA_BOND_AD_LACP_RATE
|
||||
IFLA_BOND_AD_SELECT
|
||||
IFLA_BOND_AD_INFO
|
||||
IFLA_BOND_AD_ACTOR_SYS_PRIO
|
||||
IFLA_BOND_AD_USER_PORT_KEY
|
||||
IFLA_BOND_AD_ACTOR_SYSTEM
|
||||
IFLA_BOND_TLB_DYNAMIC_LB
|
||||
)
|
||||
|
||||
const (
|
||||
IFLA_BOND_AD_INFO_UNSPEC = iota
|
||||
IFLA_BOND_AD_INFO_AGGREGATOR
|
||||
IFLA_BOND_AD_INFO_NUM_PORTS
|
||||
IFLA_BOND_AD_INFO_ACTOR_KEY
|
||||
IFLA_BOND_AD_INFO_PARTNER_KEY
|
||||
IFLA_BOND_AD_INFO_PARTNER_MAC
|
||||
)
|
||||
|
||||
const (
|
||||
IFLA_BOND_SLAVE_UNSPEC = iota
|
||||
IFLA_BOND_SLAVE_STATE
|
||||
IFLA_BOND_SLAVE_MII_STATUS
|
||||
IFLA_BOND_SLAVE_LINK_FAILURE_COUNT
|
||||
IFLA_BOND_SLAVE_PERM_HWADDR
|
||||
IFLA_BOND_SLAVE_QUEUE_ID
|
||||
IFLA_BOND_SLAVE_AD_AGGREGATOR_ID
|
||||
IFLA_BOND_SLAVE_AD_ACTOR_OPER_PORT_STATE
|
||||
IFLA_BOND_SLAVE_AD_PARTNER_OPER_PORT_STATE
|
||||
)
|
||||
|
||||
const (
|
||||
IFLA_GENEVE_UNSPEC = iota
|
||||
IFLA_GENEVE_ID // vni
|
||||
IFLA_GENEVE_REMOTE
|
||||
IFLA_GENEVE_TTL
|
||||
IFLA_GENEVE_TOS
|
||||
IFLA_GENEVE_PORT // destination port
|
||||
IFLA_GENEVE_COLLECT_METADATA
|
||||
IFLA_GENEVE_REMOTE6
|
||||
IFLA_GENEVE_UDP_CSUM
|
||||
IFLA_GENEVE_UDP_ZERO_CSUM6_TX
|
||||
IFLA_GENEVE_UDP_ZERO_CSUM6_RX
|
||||
IFLA_GENEVE_LABEL
|
||||
IFLA_GENEVE_MAX = IFLA_GENEVE_LABEL
|
||||
)
|
||||
|
||||
const (
|
||||
IFLA_GRE_UNSPEC = iota
|
||||
IFLA_GRE_LINK
|
||||
IFLA_GRE_IFLAGS
|
||||
IFLA_GRE_OFLAGS
|
||||
IFLA_GRE_IKEY
|
||||
IFLA_GRE_OKEY
|
||||
IFLA_GRE_LOCAL
|
||||
IFLA_GRE_REMOTE
|
||||
IFLA_GRE_TTL
|
||||
IFLA_GRE_TOS
|
||||
IFLA_GRE_PMTUDISC
|
||||
IFLA_GRE_ENCAP_LIMIT
|
||||
IFLA_GRE_FLOWINFO
|
||||
IFLA_GRE_FLAGS
|
||||
IFLA_GRE_ENCAP_TYPE
|
||||
IFLA_GRE_ENCAP_FLAGS
|
||||
IFLA_GRE_ENCAP_SPORT
|
||||
IFLA_GRE_ENCAP_DPORT
|
||||
IFLA_GRE_COLLECT_METADATA
|
||||
IFLA_GRE_MAX = IFLA_GRE_COLLECT_METADATA
|
||||
)
|
||||
|
||||
const (
|
||||
GRE_CSUM = 0x8000
|
||||
GRE_ROUTING = 0x4000
|
||||
GRE_KEY = 0x2000
|
||||
GRE_SEQ = 0x1000
|
||||
GRE_STRICT = 0x0800
|
||||
GRE_REC = 0x0700
|
||||
GRE_FLAGS = 0x00F8
|
||||
GRE_VERSION = 0x0007
|
||||
)
|
||||
|
||||
const (
|
||||
IFLA_VF_INFO_UNSPEC = iota
|
||||
IFLA_VF_INFO
|
||||
IFLA_VF_INFO_MAX = IFLA_VF_INFO
|
||||
)
|
||||
|
||||
const (
|
||||
IFLA_VF_UNSPEC = iota
|
||||
IFLA_VF_MAC /* Hardware queue specific attributes */
|
||||
IFLA_VF_VLAN
|
||||
IFLA_VF_TX_RATE /* Max TX Bandwidth Allocation */
|
||||
IFLA_VF_SPOOFCHK /* Spoof Checking on/off switch */
|
||||
IFLA_VF_LINK_STATE /* link state enable/disable/auto switch */
|
||||
IFLA_VF_RATE /* Min and Max TX Bandwidth Allocation */
|
||||
IFLA_VF_RSS_QUERY_EN /* RSS Redirection Table and Hash Key query
|
||||
* on/off switch
|
||||
*/
|
||||
IFLA_VF_STATS /* network device statistics */
|
||||
IFLA_VF_TRUST /* Trust state of VF */
|
||||
IFLA_VF_IB_NODE_GUID /* VF Infiniband node GUID */
|
||||
IFLA_VF_IB_PORT_GUID /* VF Infiniband port GUID */
|
||||
IFLA_VF_MAX = IFLA_VF_IB_PORT_GUID
|
||||
)
|
||||
|
||||
const (
|
||||
IFLA_VF_LINK_STATE_AUTO = iota /* link state of the uplink */
|
||||
IFLA_VF_LINK_STATE_ENABLE /* link always up */
|
||||
IFLA_VF_LINK_STATE_DISABLE /* link always down */
|
||||
IFLA_VF_LINK_STATE_MAX = IFLA_VF_LINK_STATE_DISABLE
|
||||
)
|
||||
|
||||
const (
|
||||
IFLA_VF_STATS_RX_PACKETS = iota
|
||||
IFLA_VF_STATS_TX_PACKETS
|
||||
IFLA_VF_STATS_RX_BYTES
|
||||
IFLA_VF_STATS_TX_BYTES
|
||||
IFLA_VF_STATS_BROADCAST
|
||||
IFLA_VF_STATS_MULTICAST
|
||||
IFLA_VF_STATS_RX_DROPPED
|
||||
IFLA_VF_STATS_TX_DROPPED
|
||||
IFLA_VF_STATS_MAX = IFLA_VF_STATS_TX_DROPPED
|
||||
)
|
||||
|
||||
const (
|
||||
SizeofVfMac = 0x24
|
||||
SizeofVfVlan = 0x0c
|
||||
SizeofVfTxRate = 0x08
|
||||
SizeofVfRate = 0x0c
|
||||
SizeofVfSpoofchk = 0x08
|
||||
SizeofVfLinkState = 0x08
|
||||
SizeofVfRssQueryEn = 0x08
|
||||
SizeofVfTrust = 0x08
|
||||
SizeofVfGUID = 0x10
|
||||
)
|
||||
|
||||
// struct ifla_vf_mac {
|
||||
// __u32 vf;
|
||||
// __u8 mac[32]; /* MAX_ADDR_LEN */
|
||||
// };
|
||||
|
||||
type VfMac struct {
|
||||
Vf uint32
|
||||
Mac [32]byte
|
||||
}
|
||||
|
||||
func (msg *VfMac) Len() int {
|
||||
return SizeofVfMac
|
||||
}
|
||||
|
||||
func DeserializeVfMac(b []byte) *VfMac {
|
||||
return (*VfMac)(unsafe.Pointer(&b[0:SizeofVfMac][0]))
|
||||
}
|
||||
|
||||
func (msg *VfMac) Serialize() []byte {
|
||||
return (*(*[SizeofVfMac]byte)(unsafe.Pointer(msg)))[:]
|
||||
}
|
||||
|
||||
// struct ifla_vf_vlan {
|
||||
// __u32 vf;
|
||||
// __u32 vlan; /* 0 - 4095, 0 disables VLAN filter */
|
||||
// __u32 qos;
|
||||
// };
|
||||
|
||||
type VfVlan struct {
|
||||
Vf uint32
|
||||
Vlan uint32
|
||||
Qos uint32
|
||||
}
|
||||
|
||||
func (msg *VfVlan) Len() int {
|
||||
return SizeofVfVlan
|
||||
}
|
||||
|
||||
func DeserializeVfVlan(b []byte) *VfVlan {
|
||||
return (*VfVlan)(unsafe.Pointer(&b[0:SizeofVfVlan][0]))
|
||||
}
|
||||
|
||||
func (msg *VfVlan) Serialize() []byte {
|
||||
return (*(*[SizeofVfVlan]byte)(unsafe.Pointer(msg)))[:]
|
||||
}
|
||||
|
||||
// struct ifla_vf_tx_rate {
|
||||
// __u32 vf;
|
||||
// __u32 rate; /* Max TX bandwidth in Mbps, 0 disables throttling */
|
||||
// };
|
||||
|
||||
type VfTxRate struct {
|
||||
Vf uint32
|
||||
Rate uint32
|
||||
}
|
||||
|
||||
func (msg *VfTxRate) Len() int {
|
||||
return SizeofVfTxRate
|
||||
}
|
||||
|
||||
func DeserializeVfTxRate(b []byte) *VfTxRate {
|
||||
return (*VfTxRate)(unsafe.Pointer(&b[0:SizeofVfTxRate][0]))
|
||||
}
|
||||
|
||||
func (msg *VfTxRate) Serialize() []byte {
|
||||
return (*(*[SizeofVfTxRate]byte)(unsafe.Pointer(msg)))[:]
|
||||
}
|
||||
|
||||
//struct ifla_vf_stats {
|
||||
// __u64 rx_packets;
|
||||
// __u64 tx_packets;
|
||||
// __u64 rx_bytes;
|
||||
// __u64 tx_bytes;
|
||||
// __u64 broadcast;
|
||||
// __u64 multicast;
|
||||
//};
|
||||
|
||||
type VfStats struct {
|
||||
RxPackets uint64
|
||||
TxPackets uint64
|
||||
RxBytes uint64
|
||||
TxBytes uint64
|
||||
Multicast uint64
|
||||
Broadcast uint64
|
||||
RxDropped uint64
|
||||
TxDropped uint64
|
||||
}
|
||||
|
||||
func DeserializeVfStats(b []byte) VfStats {
|
||||
var vfstat VfStats
|
||||
stats, err := ParseRouteAttr(b)
|
||||
if err != nil {
|
||||
return vfstat
|
||||
}
|
||||
var valueVar uint64
|
||||
for _, stat := range stats {
|
||||
if err := binary.Read(bytes.NewBuffer(stat.Value), NativeEndian(), &valueVar); err != nil {
|
||||
break
|
||||
}
|
||||
switch stat.Attr.Type {
|
||||
case IFLA_VF_STATS_RX_PACKETS:
|
||||
vfstat.RxPackets = valueVar
|
||||
case IFLA_VF_STATS_TX_PACKETS:
|
||||
vfstat.TxPackets = valueVar
|
||||
case IFLA_VF_STATS_RX_BYTES:
|
||||
vfstat.RxBytes = valueVar
|
||||
case IFLA_VF_STATS_TX_BYTES:
|
||||
vfstat.TxBytes = valueVar
|
||||
case IFLA_VF_STATS_MULTICAST:
|
||||
vfstat.Multicast = valueVar
|
||||
case IFLA_VF_STATS_BROADCAST:
|
||||
vfstat.Broadcast = valueVar
|
||||
case IFLA_VF_STATS_RX_DROPPED:
|
||||
vfstat.RxDropped = valueVar
|
||||
case IFLA_VF_STATS_TX_DROPPED:
|
||||
vfstat.TxDropped = valueVar
|
||||
}
|
||||
}
|
||||
return vfstat
|
||||
}
|
||||
|
||||
// struct ifla_vf_rate {
|
||||
// __u32 vf;
|
||||
// __u32 min_tx_rate; /* Min Bandwidth in Mbps */
|
||||
// __u32 max_tx_rate; /* Max Bandwidth in Mbps */
|
||||
// };
|
||||
|
||||
type VfRate struct {
|
||||
Vf uint32
|
||||
MinTxRate uint32
|
||||
MaxTxRate uint32
|
||||
}
|
||||
|
||||
func (msg *VfRate) Len() int {
|
||||
return SizeofVfRate
|
||||
}
|
||||
|
||||
func DeserializeVfRate(b []byte) *VfRate {
|
||||
return (*VfRate)(unsafe.Pointer(&b[0:SizeofVfRate][0]))
|
||||
}
|
||||
|
||||
func (msg *VfRate) Serialize() []byte {
|
||||
return (*(*[SizeofVfRate]byte)(unsafe.Pointer(msg)))[:]
|
||||
}
|
||||
|
||||
// struct ifla_vf_spoofchk {
|
||||
// __u32 vf;
|
||||
// __u32 setting;
|
||||
// };
|
||||
|
||||
type VfSpoofchk struct {
|
||||
Vf uint32
|
||||
Setting uint32
|
||||
}
|
||||
|
||||
func (msg *VfSpoofchk) Len() int {
|
||||
return SizeofVfSpoofchk
|
||||
}
|
||||
|
||||
func DeserializeVfSpoofchk(b []byte) *VfSpoofchk {
|
||||
return (*VfSpoofchk)(unsafe.Pointer(&b[0:SizeofVfSpoofchk][0]))
|
||||
}
|
||||
|
||||
func (msg *VfSpoofchk) Serialize() []byte {
|
||||
return (*(*[SizeofVfSpoofchk]byte)(unsafe.Pointer(msg)))[:]
|
||||
}
|
||||
|
||||
// struct ifla_vf_link_state {
|
||||
// __u32 vf;
|
||||
// __u32 link_state;
|
||||
// };
|
||||
|
||||
type VfLinkState struct {
|
||||
Vf uint32
|
||||
LinkState uint32
|
||||
}
|
||||
|
||||
func (msg *VfLinkState) Len() int {
|
||||
return SizeofVfLinkState
|
||||
}
|
||||
|
||||
func DeserializeVfLinkState(b []byte) *VfLinkState {
|
||||
return (*VfLinkState)(unsafe.Pointer(&b[0:SizeofVfLinkState][0]))
|
||||
}
|
||||
|
||||
func (msg *VfLinkState) Serialize() []byte {
|
||||
return (*(*[SizeofVfLinkState]byte)(unsafe.Pointer(msg)))[:]
|
||||
}
|
||||
|
||||
// struct ifla_vf_rss_query_en {
|
||||
// __u32 vf;
|
||||
// __u32 setting;
|
||||
// };
|
||||
|
||||
type VfRssQueryEn struct {
|
||||
Vf uint32
|
||||
Setting uint32
|
||||
}
|
||||
|
||||
func (msg *VfRssQueryEn) Len() int {
|
||||
return SizeofVfRssQueryEn
|
||||
}
|
||||
|
||||
func DeserializeVfRssQueryEn(b []byte) *VfRssQueryEn {
|
||||
return (*VfRssQueryEn)(unsafe.Pointer(&b[0:SizeofVfRssQueryEn][0]))
|
||||
}
|
||||
|
||||
func (msg *VfRssQueryEn) Serialize() []byte {
|
||||
return (*(*[SizeofVfRssQueryEn]byte)(unsafe.Pointer(msg)))[:]
|
||||
}
|
||||
|
||||
// struct ifla_vf_trust {
|
||||
// __u32 vf;
|
||||
// __u32 setting;
|
||||
// };
|
||||
|
||||
type VfTrust struct {
|
||||
Vf uint32
|
||||
Setting uint32
|
||||
}
|
||||
|
||||
func (msg *VfTrust) Len() int {
|
||||
return SizeofVfTrust
|
||||
}
|
||||
|
||||
func DeserializeVfTrust(b []byte) *VfTrust {
|
||||
return (*VfTrust)(unsafe.Pointer(&b[0:SizeofVfTrust][0]))
|
||||
}
|
||||
|
||||
func (msg *VfTrust) Serialize() []byte {
|
||||
return (*(*[SizeofVfTrust]byte)(unsafe.Pointer(msg)))[:]
|
||||
}
|
||||
|
||||
// struct ifla_vf_guid {
|
||||
// __u32 vf;
|
||||
// __u32 rsvd;
|
||||
// __u64 guid;
|
||||
// };
|
||||
|
||||
type VfGUID struct {
|
||||
Vf uint32
|
||||
Rsvd uint32
|
||||
GUID uint64
|
||||
}
|
||||
|
||||
func (msg *VfGUID) Len() int {
|
||||
return SizeofVfGUID
|
||||
}
|
||||
|
||||
func DeserializeVfGUID(b []byte) *VfGUID {
|
||||
return (*VfGUID)(unsafe.Pointer(&b[0:SizeofVfGUID][0]))
|
||||
}
|
||||
|
||||
func (msg *VfGUID) Serialize() []byte {
|
||||
return (*(*[SizeofVfGUID]byte)(unsafe.Pointer(msg)))[:]
|
||||
}
|
||||
|
||||
const (
|
||||
XDP_FLAGS_UPDATE_IF_NOEXIST = 1 << iota
|
||||
XDP_FLAGS_SKB_MODE
|
||||
XDP_FLAGS_DRV_MODE
|
||||
XDP_FLAGS_MASK = XDP_FLAGS_UPDATE_IF_NOEXIST | XDP_FLAGS_SKB_MODE | XDP_FLAGS_DRV_MODE
|
||||
)
|
||||
|
||||
const (
|
||||
IFLA_XDP_UNSPEC = iota
|
||||
IFLA_XDP_FD /* fd of xdp program to attach, or -1 to remove */
|
||||
IFLA_XDP_ATTACHED /* read-only bool indicating if prog is attached */
|
||||
IFLA_XDP_FLAGS /* xdp prog related flags */
|
||||
IFLA_XDP_PROG_ID /* xdp prog id */
|
||||
IFLA_XDP_MAX = IFLA_XDP_PROG_ID
|
||||
)
|
||||
|
||||
// XDP program attach mode (used as dump value for IFLA_XDP_ATTACHED)
|
||||
const (
|
||||
XDP_ATTACHED_NONE = iota
|
||||
XDP_ATTACHED_DRV
|
||||
XDP_ATTACHED_SKB
|
||||
XDP_ATTACHED_HW
|
||||
)
|
||||
|
||||
const (
|
||||
IFLA_IPTUN_UNSPEC = iota
|
||||
IFLA_IPTUN_LINK
|
||||
IFLA_IPTUN_LOCAL
|
||||
IFLA_IPTUN_REMOTE
|
||||
IFLA_IPTUN_TTL
|
||||
IFLA_IPTUN_TOS
|
||||
IFLA_IPTUN_ENCAP_LIMIT
|
||||
IFLA_IPTUN_FLOWINFO
|
||||
IFLA_IPTUN_FLAGS
|
||||
IFLA_IPTUN_PROTO
|
||||
IFLA_IPTUN_PMTUDISC
|
||||
IFLA_IPTUN_6RD_PREFIX
|
||||
IFLA_IPTUN_6RD_RELAY_PREFIX
|
||||
IFLA_IPTUN_6RD_PREFIXLEN
|
||||
IFLA_IPTUN_6RD_RELAY_PREFIXLEN
|
||||
IFLA_IPTUN_ENCAP_TYPE
|
||||
IFLA_IPTUN_ENCAP_FLAGS
|
||||
IFLA_IPTUN_ENCAP_SPORT
|
||||
IFLA_IPTUN_ENCAP_DPORT
|
||||
IFLA_IPTUN_COLLECT_METADATA
|
||||
IFLA_IPTUN_MAX = IFLA_IPTUN_COLLECT_METADATA
|
||||
)
|
||||
|
||||
const (
|
||||
IFLA_VTI_UNSPEC = iota
|
||||
IFLA_VTI_LINK
|
||||
IFLA_VTI_IKEY
|
||||
IFLA_VTI_OKEY
|
||||
IFLA_VTI_LOCAL
|
||||
IFLA_VTI_REMOTE
|
||||
IFLA_VTI_MAX = IFLA_VTI_REMOTE
|
||||
)
|
||||
|
||||
const (
|
||||
IFLA_VRF_UNSPEC = iota
|
||||
IFLA_VRF_TABLE
|
||||
)
|
||||
|
||||
const (
|
||||
IFLA_BR_UNSPEC = iota
|
||||
IFLA_BR_FORWARD_DELAY
|
||||
IFLA_BR_HELLO_TIME
|
||||
IFLA_BR_MAX_AGE
|
||||
IFLA_BR_AGEING_TIME
|
||||
IFLA_BR_STP_STATE
|
||||
IFLA_BR_PRIORITY
|
||||
IFLA_BR_VLAN_FILTERING
|
||||
IFLA_BR_VLAN_PROTOCOL
|
||||
IFLA_BR_GROUP_FWD_MASK
|
||||
IFLA_BR_ROOT_ID
|
||||
IFLA_BR_BRIDGE_ID
|
||||
IFLA_BR_ROOT_PORT
|
||||
IFLA_BR_ROOT_PATH_COST
|
||||
IFLA_BR_TOPOLOGY_CHANGE
|
||||
IFLA_BR_TOPOLOGY_CHANGE_DETECTED
|
||||
IFLA_BR_HELLO_TIMER
|
||||
IFLA_BR_TCN_TIMER
|
||||
IFLA_BR_TOPOLOGY_CHANGE_TIMER
|
||||
IFLA_BR_GC_TIMER
|
||||
IFLA_BR_GROUP_ADDR
|
||||
IFLA_BR_FDB_FLUSH
|
||||
IFLA_BR_MCAST_ROUTER
|
||||
IFLA_BR_MCAST_SNOOPING
|
||||
IFLA_BR_MCAST_QUERY_USE_IFADDR
|
||||
IFLA_BR_MCAST_QUERIER
|
||||
IFLA_BR_MCAST_HASH_ELASTICITY
|
||||
IFLA_BR_MCAST_HASH_MAX
|
||||
IFLA_BR_MCAST_LAST_MEMBER_CNT
|
||||
IFLA_BR_MCAST_STARTUP_QUERY_CNT
|
||||
IFLA_BR_MCAST_LAST_MEMBER_INTVL
|
||||
IFLA_BR_MCAST_MEMBERSHIP_INTVL
|
||||
IFLA_BR_MCAST_QUERIER_INTVL
|
||||
IFLA_BR_MCAST_QUERY_INTVL
|
||||
IFLA_BR_MCAST_QUERY_RESPONSE_INTVL
|
||||
IFLA_BR_MCAST_STARTUP_QUERY_INTVL
|
||||
IFLA_BR_NF_CALL_IPTABLES
|
||||
IFLA_BR_NF_CALL_IP6TABLES
|
||||
IFLA_BR_NF_CALL_ARPTABLES
|
||||
IFLA_BR_VLAN_DEFAULT_PVID
|
||||
IFLA_BR_PAD
|
||||
IFLA_BR_VLAN_STATS_ENABLED
|
||||
IFLA_BR_MCAST_STATS_ENABLED
|
||||
IFLA_BR_MCAST_IGMP_VERSION
|
||||
IFLA_BR_MCAST_MLD_VERSION
|
||||
IFLA_BR_MAX = IFLA_BR_MCAST_MLD_VERSION
|
||||
)
|
||||
|
||||
const (
|
||||
IFLA_GTP_UNSPEC = iota
|
||||
IFLA_GTP_FD0
|
||||
IFLA_GTP_FD1
|
||||
IFLA_GTP_PDP_HASHSIZE
|
||||
IFLA_GTP_ROLE
|
||||
)
|
||||
|
||||
const (
|
||||
GTP_ROLE_GGSN = iota
|
||||
GTP_ROLE_SGSN
|
||||
)
|
||||
|
||||
const (
|
||||
IFLA_XFRM_UNSPEC = iota
|
||||
IFLA_XFRM_LINK
|
||||
IFLA_XFRM_IF_ID
|
||||
|
||||
IFLA_XFRM_MAX = iota - 1
|
||||
)
|
||||
|
||||
const (
|
||||
IFLA_TUN_UNSPEC = iota
|
||||
IFLA_TUN_OWNER
|
||||
IFLA_TUN_GROUP
|
||||
IFLA_TUN_TYPE
|
||||
IFLA_TUN_PI
|
||||
IFLA_TUN_VNET_HDR
|
||||
IFLA_TUN_PERSIST
|
||||
IFLA_TUN_MULTI_QUEUE
|
||||
IFLA_TUN_NUM_QUEUES
|
||||
IFLA_TUN_NUM_DISABLED_QUEUES
|
||||
IFLA_TUN_MAX = IFLA_TUN_NUM_DISABLED_QUEUES
|
||||
)
|
||||
|
||||
const (
|
||||
IFLA_IPOIB_UNSPEC = iota
|
||||
IFLA_IPOIB_PKEY
|
||||
IFLA_IPOIB_MODE
|
||||
IFLA_IPOIB_UMCAST
|
||||
IFLA_IPOIB_MAX = IFLA_IPOIB_UMCAST
|
||||
)
|
||||
|
||||
const (
|
||||
IFLA_CAN_UNSPEC = iota
|
||||
IFLA_CAN_BITTIMING
|
||||
IFLA_CAN_BITTIMING_CONST
|
||||
IFLA_CAN_CLOCK
|
||||
IFLA_CAN_STATE
|
||||
IFLA_CAN_CTRLMODE
|
||||
IFLA_CAN_RESTART_MS
|
||||
IFLA_CAN_RESTART
|
||||
IFLA_CAN_BERR_COUNTER
|
||||
IFLA_CAN_DATA_BITTIMING
|
||||
IFLA_CAN_DATA_BITTIMING_CONST
|
||||
IFLA_CAN_TERMINATION
|
||||
IFLA_CAN_TERMINATION_CONST
|
||||
IFLA_CAN_BITRATE_CONST
|
||||
IFLA_CAN_DATA_BITRATE_CONST
|
||||
IFLA_CAN_BITRATE_MAX
|
||||
IFLA_CAN_MAX = IFLA_CAN_BITRATE_MAX
|
||||
)
|
||||
|
||||
const (
|
||||
IFLA_BAREUDP_UNSPEC = iota
|
||||
IFLA_BAREUDP_PORT
|
||||
IFLA_BAREUDP_ETHERTYPE
|
||||
IFLA_BAREUDP_SRCPORT_MIN
|
||||
IFLA_BAREUDP_MULTIPROTO_MODE
|
||||
IFLA_BAREUDP_MAX = IFLA_BAREUDP_MULTIPROTO_MODE
|
||||
)
|
29
vendor/github.com/tailscale/netlink/nl/lwt_linux.go
generated
vendored
Normal file
29
vendor/github.com/tailscale/netlink/nl/lwt_linux.go
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
package nl
|
||||
|
||||
const (
|
||||
LWT_BPF_PROG_UNSPEC = iota
|
||||
LWT_BPF_PROG_FD
|
||||
LWT_BPF_PROG_NAME
|
||||
__LWT_BPF_PROG_MAX
|
||||
)
|
||||
|
||||
const (
|
||||
LWT_BPF_PROG_MAX = __LWT_BPF_PROG_MAX - 1
|
||||
)
|
||||
|
||||
const (
|
||||
LWT_BPF_UNSPEC = iota
|
||||
LWT_BPF_IN
|
||||
LWT_BPF_OUT
|
||||
LWT_BPF_XMIT
|
||||
LWT_BPF_XMIT_HEADROOM
|
||||
__LWT_BPF_MAX
|
||||
)
|
||||
|
||||
const (
|
||||
LWT_BPF_MAX = __LWT_BPF_MAX - 1
|
||||
)
|
||||
|
||||
const (
|
||||
LWT_BPF_MAX_HEADROOM = 256
|
||||
)
|
36
vendor/github.com/tailscale/netlink/nl/mpls_linux.go
generated
vendored
Normal file
36
vendor/github.com/tailscale/netlink/nl/mpls_linux.go
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
package nl
|
||||
|
||||
import "encoding/binary"
|
||||
|
||||
const (
|
||||
MPLS_LS_LABEL_SHIFT = 12
|
||||
MPLS_LS_S_SHIFT = 8
|
||||
)
|
||||
|
||||
func EncodeMPLSStack(labels ...int) []byte {
|
||||
b := make([]byte, 4*len(labels))
|
||||
for idx, label := range labels {
|
||||
l := label << MPLS_LS_LABEL_SHIFT
|
||||
if idx == len(labels)-1 {
|
||||
l |= 1 << MPLS_LS_S_SHIFT
|
||||
}
|
||||
binary.BigEndian.PutUint32(b[idx*4:], uint32(l))
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func DecodeMPLSStack(buf []byte) []int {
|
||||
if len(buf)%4 != 0 {
|
||||
return nil
|
||||
}
|
||||
stack := make([]int, 0, len(buf)/4)
|
||||
for len(buf) > 0 {
|
||||
l := binary.BigEndian.Uint32(buf[:4])
|
||||
buf = buf[4:]
|
||||
stack = append(stack, int(l)>>MPLS_LS_LABEL_SHIFT)
|
||||
if (l>>MPLS_LS_S_SHIFT)&1 > 0 {
|
||||
break
|
||||
}
|
||||
}
|
||||
return stack
|
||||
}
|
791
vendor/github.com/tailscale/netlink/nl/nl_linux.go
generated
vendored
Normal file
791
vendor/github.com/tailscale/netlink/nl/nl_linux.go
generated
vendored
Normal file
@@ -0,0 +1,791 @@
|
||||
// Package nl has low level primitives for making Netlink calls.
|
||||
package nl
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"net"
|
||||
"runtime"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"github.com/vishvananda/netns"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
const (
|
||||
// Family type definitions
|
||||
FAMILY_ALL = unix.AF_UNSPEC
|
||||
FAMILY_V4 = unix.AF_INET
|
||||
FAMILY_V6 = unix.AF_INET6
|
||||
FAMILY_MPLS = unix.AF_MPLS
|
||||
// Arbitrary set value (greater than default 4k) to allow receiving
|
||||
// from kernel more verbose messages e.g. for statistics,
|
||||
// tc rules or filters, or other more memory requiring data.
|
||||
RECEIVE_BUFFER_SIZE = 65536
|
||||
// Kernel netlink pid
|
||||
PidKernel uint32 = 0
|
||||
)
|
||||
|
||||
// SupportedNlFamilies contains the list of netlink families this netlink package supports
|
||||
var SupportedNlFamilies = []int{unix.NETLINK_ROUTE, unix.NETLINK_XFRM, unix.NETLINK_NETFILTER}
|
||||
|
||||
var nextSeqNr uint32
|
||||
|
||||
// Default netlink socket timeout, 60s
|
||||
var SocketTimeoutTv = unix.Timeval{Sec: 60, Usec: 0}
|
||||
|
||||
// GetIPFamily returns the family type of a net.IP.
|
||||
func GetIPFamily(ip net.IP) int {
|
||||
if len(ip) <= net.IPv4len {
|
||||
return FAMILY_V4
|
||||
}
|
||||
if ip.To4() != nil {
|
||||
return FAMILY_V4
|
||||
}
|
||||
return FAMILY_V6
|
||||
}
|
||||
|
||||
var nativeEndian binary.ByteOrder
|
||||
|
||||
// NativeEndian gets native endianness for the system
|
||||
func NativeEndian() binary.ByteOrder {
|
||||
if nativeEndian == nil {
|
||||
var x uint32 = 0x01020304
|
||||
if *(*byte)(unsafe.Pointer(&x)) == 0x01 {
|
||||
nativeEndian = binary.BigEndian
|
||||
} else {
|
||||
nativeEndian = binary.LittleEndian
|
||||
}
|
||||
}
|
||||
return nativeEndian
|
||||
}
|
||||
|
||||
// Byte swap a 16 bit value if we aren't big endian
|
||||
func Swap16(i uint16) uint16 {
|
||||
if NativeEndian() == binary.BigEndian {
|
||||
return i
|
||||
}
|
||||
return (i&0xff00)>>8 | (i&0xff)<<8
|
||||
}
|
||||
|
||||
// Byte swap a 32 bit value if aren't big endian
|
||||
func Swap32(i uint32) uint32 {
|
||||
if NativeEndian() == binary.BigEndian {
|
||||
return i
|
||||
}
|
||||
return (i&0xff000000)>>24 | (i&0xff0000)>>8 | (i&0xff00)<<8 | (i&0xff)<<24
|
||||
}
|
||||
|
||||
type NetlinkRequestData interface {
|
||||
Len() int
|
||||
Serialize() []byte
|
||||
}
|
||||
|
||||
// IfInfomsg is related to links, but it is used for list requests as well
|
||||
type IfInfomsg struct {
|
||||
unix.IfInfomsg
|
||||
}
|
||||
|
||||
// Create an IfInfomsg with family specified
|
||||
func NewIfInfomsg(family int) *IfInfomsg {
|
||||
return &IfInfomsg{
|
||||
IfInfomsg: unix.IfInfomsg{
|
||||
Family: uint8(family),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func DeserializeIfInfomsg(b []byte) *IfInfomsg {
|
||||
return (*IfInfomsg)(unsafe.Pointer(&b[0:unix.SizeofIfInfomsg][0]))
|
||||
}
|
||||
|
||||
func (msg *IfInfomsg) Serialize() []byte {
|
||||
return (*(*[unix.SizeofIfInfomsg]byte)(unsafe.Pointer(msg)))[:]
|
||||
}
|
||||
|
||||
func (msg *IfInfomsg) Len() int {
|
||||
return unix.SizeofIfInfomsg
|
||||
}
|
||||
|
||||
func (msg *IfInfomsg) EncapType() string {
|
||||
switch msg.Type {
|
||||
case 0:
|
||||
return "generic"
|
||||
case unix.ARPHRD_ETHER:
|
||||
return "ether"
|
||||
case unix.ARPHRD_EETHER:
|
||||
return "eether"
|
||||
case unix.ARPHRD_AX25:
|
||||
return "ax25"
|
||||
case unix.ARPHRD_PRONET:
|
||||
return "pronet"
|
||||
case unix.ARPHRD_CHAOS:
|
||||
return "chaos"
|
||||
case unix.ARPHRD_IEEE802:
|
||||
return "ieee802"
|
||||
case unix.ARPHRD_ARCNET:
|
||||
return "arcnet"
|
||||
case unix.ARPHRD_APPLETLK:
|
||||
return "atalk"
|
||||
case unix.ARPHRD_DLCI:
|
||||
return "dlci"
|
||||
case unix.ARPHRD_ATM:
|
||||
return "atm"
|
||||
case unix.ARPHRD_METRICOM:
|
||||
return "metricom"
|
||||
case unix.ARPHRD_IEEE1394:
|
||||
return "ieee1394"
|
||||
case unix.ARPHRD_INFINIBAND:
|
||||
return "infiniband"
|
||||
case unix.ARPHRD_SLIP:
|
||||
return "slip"
|
||||
case unix.ARPHRD_CSLIP:
|
||||
return "cslip"
|
||||
case unix.ARPHRD_SLIP6:
|
||||
return "slip6"
|
||||
case unix.ARPHRD_CSLIP6:
|
||||
return "cslip6"
|
||||
case unix.ARPHRD_RSRVD:
|
||||
return "rsrvd"
|
||||
case unix.ARPHRD_ADAPT:
|
||||
return "adapt"
|
||||
case unix.ARPHRD_ROSE:
|
||||
return "rose"
|
||||
case unix.ARPHRD_X25:
|
||||
return "x25"
|
||||
case unix.ARPHRD_HWX25:
|
||||
return "hwx25"
|
||||
case unix.ARPHRD_PPP:
|
||||
return "ppp"
|
||||
case unix.ARPHRD_HDLC:
|
||||
return "hdlc"
|
||||
case unix.ARPHRD_LAPB:
|
||||
return "lapb"
|
||||
case unix.ARPHRD_DDCMP:
|
||||
return "ddcmp"
|
||||
case unix.ARPHRD_RAWHDLC:
|
||||
return "rawhdlc"
|
||||
case unix.ARPHRD_TUNNEL:
|
||||
return "ipip"
|
||||
case unix.ARPHRD_TUNNEL6:
|
||||
return "tunnel6"
|
||||
case unix.ARPHRD_FRAD:
|
||||
return "frad"
|
||||
case unix.ARPHRD_SKIP:
|
||||
return "skip"
|
||||
case unix.ARPHRD_LOOPBACK:
|
||||
return "loopback"
|
||||
case unix.ARPHRD_LOCALTLK:
|
||||
return "ltalk"
|
||||
case unix.ARPHRD_FDDI:
|
||||
return "fddi"
|
||||
case unix.ARPHRD_BIF:
|
||||
return "bif"
|
||||
case unix.ARPHRD_SIT:
|
||||
return "sit"
|
||||
case unix.ARPHRD_IPDDP:
|
||||
return "ip/ddp"
|
||||
case unix.ARPHRD_IPGRE:
|
||||
return "gre"
|
||||
case unix.ARPHRD_PIMREG:
|
||||
return "pimreg"
|
||||
case unix.ARPHRD_HIPPI:
|
||||
return "hippi"
|
||||
case unix.ARPHRD_ASH:
|
||||
return "ash"
|
||||
case unix.ARPHRD_ECONET:
|
||||
return "econet"
|
||||
case unix.ARPHRD_IRDA:
|
||||
return "irda"
|
||||
case unix.ARPHRD_FCPP:
|
||||
return "fcpp"
|
||||
case unix.ARPHRD_FCAL:
|
||||
return "fcal"
|
||||
case unix.ARPHRD_FCPL:
|
||||
return "fcpl"
|
||||
case unix.ARPHRD_FCFABRIC:
|
||||
return "fcfb0"
|
||||
case unix.ARPHRD_FCFABRIC + 1:
|
||||
return "fcfb1"
|
||||
case unix.ARPHRD_FCFABRIC + 2:
|
||||
return "fcfb2"
|
||||
case unix.ARPHRD_FCFABRIC + 3:
|
||||
return "fcfb3"
|
||||
case unix.ARPHRD_FCFABRIC + 4:
|
||||
return "fcfb4"
|
||||
case unix.ARPHRD_FCFABRIC + 5:
|
||||
return "fcfb5"
|
||||
case unix.ARPHRD_FCFABRIC + 6:
|
||||
return "fcfb6"
|
||||
case unix.ARPHRD_FCFABRIC + 7:
|
||||
return "fcfb7"
|
||||
case unix.ARPHRD_FCFABRIC + 8:
|
||||
return "fcfb8"
|
||||
case unix.ARPHRD_FCFABRIC + 9:
|
||||
return "fcfb9"
|
||||
case unix.ARPHRD_FCFABRIC + 10:
|
||||
return "fcfb10"
|
||||
case unix.ARPHRD_FCFABRIC + 11:
|
||||
return "fcfb11"
|
||||
case unix.ARPHRD_FCFABRIC + 12:
|
||||
return "fcfb12"
|
||||
case unix.ARPHRD_IEEE802_TR:
|
||||
return "tr"
|
||||
case unix.ARPHRD_IEEE80211:
|
||||
return "ieee802.11"
|
||||
case unix.ARPHRD_IEEE80211_PRISM:
|
||||
return "ieee802.11/prism"
|
||||
case unix.ARPHRD_IEEE80211_RADIOTAP:
|
||||
return "ieee802.11/radiotap"
|
||||
case unix.ARPHRD_IEEE802154:
|
||||
return "ieee802.15.4"
|
||||
|
||||
case 65534:
|
||||
return "none"
|
||||
case 65535:
|
||||
return "void"
|
||||
}
|
||||
return fmt.Sprintf("unknown%d", msg.Type)
|
||||
}
|
||||
|
||||
func rtaAlignOf(attrlen int) int {
|
||||
return (attrlen + unix.RTA_ALIGNTO - 1) & ^(unix.RTA_ALIGNTO - 1)
|
||||
}
|
||||
|
||||
func NewIfInfomsgChild(parent *RtAttr, family int) *IfInfomsg {
|
||||
msg := NewIfInfomsg(family)
|
||||
parent.children = append(parent.children, msg)
|
||||
return msg
|
||||
}
|
||||
|
||||
type Uint32Attribute struct {
|
||||
Type uint16
|
||||
Value uint32
|
||||
}
|
||||
|
||||
func (a *Uint32Attribute) Serialize() []byte {
|
||||
native := NativeEndian()
|
||||
buf := make([]byte, rtaAlignOf(8))
|
||||
native.PutUint16(buf[0:2], 8)
|
||||
native.PutUint16(buf[2:4], a.Type)
|
||||
|
||||
if a.Type&NLA_F_NET_BYTEORDER != 0 {
|
||||
binary.BigEndian.PutUint32(buf[4:], a.Value)
|
||||
} else {
|
||||
native.PutUint32(buf[4:], a.Value)
|
||||
}
|
||||
return buf
|
||||
}
|
||||
|
||||
func (a *Uint32Attribute) Len() int {
|
||||
return 8
|
||||
}
|
||||
|
||||
// Extend RtAttr to handle data and children
|
||||
type RtAttr struct {
|
||||
unix.RtAttr
|
||||
Data []byte
|
||||
children []NetlinkRequestData
|
||||
}
|
||||
|
||||
// Create a new Extended RtAttr object
|
||||
func NewRtAttr(attrType int, data []byte) *RtAttr {
|
||||
return &RtAttr{
|
||||
RtAttr: unix.RtAttr{
|
||||
Type: uint16(attrType),
|
||||
},
|
||||
children: []NetlinkRequestData{},
|
||||
Data: data,
|
||||
}
|
||||
}
|
||||
|
||||
// NewRtAttrChild adds an RtAttr as a child to the parent and returns the new attribute
|
||||
//
|
||||
// Deprecated: Use AddRtAttr() on the parent object
|
||||
func NewRtAttrChild(parent *RtAttr, attrType int, data []byte) *RtAttr {
|
||||
return parent.AddRtAttr(attrType, data)
|
||||
}
|
||||
|
||||
// AddRtAttr adds an RtAttr as a child and returns the new attribute
|
||||
func (a *RtAttr) AddRtAttr(attrType int, data []byte) *RtAttr {
|
||||
attr := NewRtAttr(attrType, data)
|
||||
a.children = append(a.children, attr)
|
||||
return attr
|
||||
}
|
||||
|
||||
// AddChild adds an existing NetlinkRequestData as a child.
|
||||
func (a *RtAttr) AddChild(attr NetlinkRequestData) {
|
||||
a.children = append(a.children, attr)
|
||||
}
|
||||
|
||||
func (a *RtAttr) Len() int {
|
||||
if len(a.children) == 0 {
|
||||
return (unix.SizeofRtAttr + len(a.Data))
|
||||
}
|
||||
|
||||
l := 0
|
||||
for _, child := range a.children {
|
||||
l += rtaAlignOf(child.Len())
|
||||
}
|
||||
l += unix.SizeofRtAttr
|
||||
return rtaAlignOf(l + len(a.Data))
|
||||
}
|
||||
|
||||
// Serialize the RtAttr into a byte array
|
||||
// This can't just unsafe.cast because it must iterate through children.
|
||||
func (a *RtAttr) Serialize() []byte {
|
||||
native := NativeEndian()
|
||||
|
||||
length := a.Len()
|
||||
buf := make([]byte, rtaAlignOf(length))
|
||||
|
||||
next := 4
|
||||
if a.Data != nil {
|
||||
copy(buf[next:], a.Data)
|
||||
next += rtaAlignOf(len(a.Data))
|
||||
}
|
||||
if len(a.children) > 0 {
|
||||
for _, child := range a.children {
|
||||
childBuf := child.Serialize()
|
||||
copy(buf[next:], childBuf)
|
||||
next += rtaAlignOf(len(childBuf))
|
||||
}
|
||||
}
|
||||
|
||||
if l := uint16(length); l != 0 {
|
||||
native.PutUint16(buf[0:2], l)
|
||||
}
|
||||
native.PutUint16(buf[2:4], a.Type)
|
||||
return buf
|
||||
}
|
||||
|
||||
type NetlinkRequest struct {
|
||||
unix.NlMsghdr
|
||||
Data []NetlinkRequestData
|
||||
RawData []byte
|
||||
Sockets map[int]*SocketHandle
|
||||
}
|
||||
|
||||
// Serialize the Netlink Request into a byte array
|
||||
func (req *NetlinkRequest) Serialize() []byte {
|
||||
length := unix.SizeofNlMsghdr
|
||||
dataBytes := make([][]byte, len(req.Data))
|
||||
for i, data := range req.Data {
|
||||
dataBytes[i] = data.Serialize()
|
||||
length = length + len(dataBytes[i])
|
||||
}
|
||||
length += len(req.RawData)
|
||||
|
||||
req.Len = uint32(length)
|
||||
b := make([]byte, length)
|
||||
hdr := (*(*[unix.SizeofNlMsghdr]byte)(unsafe.Pointer(req)))[:]
|
||||
next := unix.SizeofNlMsghdr
|
||||
copy(b[0:next], hdr)
|
||||
for _, data := range dataBytes {
|
||||
for _, dataByte := range data {
|
||||
b[next] = dataByte
|
||||
next = next + 1
|
||||
}
|
||||
}
|
||||
// Add the raw data if any
|
||||
if len(req.RawData) > 0 {
|
||||
copy(b[next:length], req.RawData)
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func (req *NetlinkRequest) AddData(data NetlinkRequestData) {
|
||||
req.Data = append(req.Data, data)
|
||||
}
|
||||
|
||||
// AddRawData adds raw bytes to the end of the NetlinkRequest object during serialization
|
||||
func (req *NetlinkRequest) AddRawData(data []byte) {
|
||||
req.RawData = append(req.RawData, data...)
|
||||
}
|
||||
|
||||
// Execute the request against a the given sockType.
|
||||
// Returns a list of netlink messages in serialized format, optionally filtered
|
||||
// by resType.
|
||||
func (req *NetlinkRequest) Execute(sockType int, resType uint16) ([][]byte, error) {
|
||||
var (
|
||||
s *NetlinkSocket
|
||||
err error
|
||||
)
|
||||
|
||||
if req.Sockets != nil {
|
||||
if sh, ok := req.Sockets[sockType]; ok {
|
||||
s = sh.Socket
|
||||
req.Seq = atomic.AddUint32(&sh.Seq, 1)
|
||||
}
|
||||
}
|
||||
sharedSocket := s != nil
|
||||
|
||||
if s == nil {
|
||||
s, err = getNetlinkSocket(sockType)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := s.SetSendTimeout(&SocketTimeoutTv); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := s.SetReceiveTimeout(&SocketTimeoutTv); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
defer s.Close()
|
||||
} else {
|
||||
s.Lock()
|
||||
defer s.Unlock()
|
||||
}
|
||||
|
||||
if err := s.Send(req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
pid, err := s.GetPid()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var res [][]byte
|
||||
|
||||
done:
|
||||
for {
|
||||
msgs, from, err := s.Receive()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if from.Pid != PidKernel {
|
||||
return nil, fmt.Errorf("Wrong sender portid %d, expected %d", from.Pid, PidKernel)
|
||||
}
|
||||
for _, m := range msgs {
|
||||
if m.Header.Seq != req.Seq {
|
||||
if sharedSocket {
|
||||
continue
|
||||
}
|
||||
return nil, fmt.Errorf("Wrong Seq nr %d, expected %d", m.Header.Seq, req.Seq)
|
||||
}
|
||||
if m.Header.Pid != pid {
|
||||
continue
|
||||
}
|
||||
if m.Header.Type == unix.NLMSG_DONE || m.Header.Type == unix.NLMSG_ERROR {
|
||||
native := NativeEndian()
|
||||
error := int32(native.Uint32(m.Data[0:4]))
|
||||
if error == 0 {
|
||||
break done
|
||||
}
|
||||
return nil, syscall.Errno(-error)
|
||||
}
|
||||
if resType != 0 && m.Header.Type != resType {
|
||||
continue
|
||||
}
|
||||
res = append(res, m.Data)
|
||||
if m.Header.Flags&unix.NLM_F_MULTI == 0 {
|
||||
break done
|
||||
}
|
||||
}
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// Create a new netlink request from proto and flags
|
||||
// Note the Len value will be inaccurate once data is added until
|
||||
// the message is serialized
|
||||
func NewNetlinkRequest(proto, flags int) *NetlinkRequest {
|
||||
return &NetlinkRequest{
|
||||
NlMsghdr: unix.NlMsghdr{
|
||||
Len: uint32(unix.SizeofNlMsghdr),
|
||||
Type: uint16(proto),
|
||||
Flags: unix.NLM_F_REQUEST | uint16(flags),
|
||||
Seq: atomic.AddUint32(&nextSeqNr, 1),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
type NetlinkSocket struct {
|
||||
fd int32
|
||||
lsa unix.SockaddrNetlink
|
||||
sync.Mutex
|
||||
}
|
||||
|
||||
func getNetlinkSocket(protocol int) (*NetlinkSocket, error) {
|
||||
fd, err := unix.Socket(unix.AF_NETLINK, unix.SOCK_RAW|unix.SOCK_CLOEXEC, protocol)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s := &NetlinkSocket{
|
||||
fd: int32(fd),
|
||||
}
|
||||
s.lsa.Family = unix.AF_NETLINK
|
||||
if err := unix.Bind(fd, &s.lsa); err != nil {
|
||||
unix.Close(fd)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return s, nil
|
||||
}
|
||||
|
||||
// GetNetlinkSocketAt opens a netlink socket in the network namespace newNs
|
||||
// and positions the thread back into the network namespace specified by curNs,
|
||||
// when done. If curNs is close, the function derives the current namespace and
|
||||
// moves back into it when done. If newNs is close, the socket will be opened
|
||||
// in the current network namespace.
|
||||
func GetNetlinkSocketAt(newNs, curNs netns.NsHandle, protocol int) (*NetlinkSocket, error) {
|
||||
c, err := executeInNetns(newNs, curNs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer c()
|
||||
return getNetlinkSocket(protocol)
|
||||
}
|
||||
|
||||
// executeInNetns sets execution of the code following this call to the
|
||||
// network namespace newNs, then moves the thread back to curNs if open,
|
||||
// otherwise to the current netns at the time the function was invoked
|
||||
// In case of success, the caller is expected to execute the returned function
|
||||
// at the end of the code that needs to be executed in the network namespace.
|
||||
// Example:
|
||||
// func jobAt(...) error {
|
||||
// d, err := executeInNetns(...)
|
||||
// if err != nil { return err}
|
||||
// defer d()
|
||||
// < code which needs to be executed in specific netns>
|
||||
// }
|
||||
// TODO: his function probably belongs to netns pkg.
|
||||
func executeInNetns(newNs, curNs netns.NsHandle) (func(), error) {
|
||||
var (
|
||||
err error
|
||||
moveBack func(netns.NsHandle) error
|
||||
closeNs func() error
|
||||
unlockThd func()
|
||||
)
|
||||
restore := func() {
|
||||
// order matters
|
||||
if moveBack != nil {
|
||||
moveBack(curNs)
|
||||
}
|
||||
if closeNs != nil {
|
||||
closeNs()
|
||||
}
|
||||
if unlockThd != nil {
|
||||
unlockThd()
|
||||
}
|
||||
}
|
||||
if newNs.IsOpen() {
|
||||
runtime.LockOSThread()
|
||||
unlockThd = runtime.UnlockOSThread
|
||||
if !curNs.IsOpen() {
|
||||
if curNs, err = netns.Get(); err != nil {
|
||||
restore()
|
||||
return nil, fmt.Errorf("could not get current namespace while creating netlink socket: %v", err)
|
||||
}
|
||||
closeNs = curNs.Close
|
||||
}
|
||||
if err := netns.Set(newNs); err != nil {
|
||||
restore()
|
||||
return nil, fmt.Errorf("failed to set into network namespace %d while creating netlink socket: %v", newNs, err)
|
||||
}
|
||||
moveBack = netns.Set
|
||||
}
|
||||
return restore, nil
|
||||
}
|
||||
|
||||
// Create a netlink socket with a given protocol (e.g. NETLINK_ROUTE)
|
||||
// and subscribe it to multicast groups passed in variable argument list.
|
||||
// Returns the netlink socket on which Receive() method can be called
|
||||
// to retrieve the messages from the kernel.
|
||||
func Subscribe(protocol int, groups ...uint) (*NetlinkSocket, error) {
|
||||
fd, err := unix.Socket(unix.AF_NETLINK, unix.SOCK_RAW, protocol)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
s := &NetlinkSocket{
|
||||
fd: int32(fd),
|
||||
}
|
||||
s.lsa.Family = unix.AF_NETLINK
|
||||
|
||||
for _, g := range groups {
|
||||
s.lsa.Groups |= (1 << (g - 1))
|
||||
}
|
||||
|
||||
if err := unix.Bind(fd, &s.lsa); err != nil {
|
||||
unix.Close(fd)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return s, nil
|
||||
}
|
||||
|
||||
// SubscribeAt works like Subscribe plus let's the caller choose the network
|
||||
// namespace in which the socket would be opened (newNs). Then control goes back
|
||||
// to curNs if open, otherwise to the netns at the time this function was called.
|
||||
func SubscribeAt(newNs, curNs netns.NsHandle, protocol int, groups ...uint) (*NetlinkSocket, error) {
|
||||
c, err := executeInNetns(newNs, curNs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer c()
|
||||
return Subscribe(protocol, groups...)
|
||||
}
|
||||
|
||||
func (s *NetlinkSocket) Close() {
|
||||
fd := int(atomic.SwapInt32(&s.fd, -1))
|
||||
unix.Close(fd)
|
||||
}
|
||||
|
||||
func (s *NetlinkSocket) GetFd() int {
|
||||
return int(atomic.LoadInt32(&s.fd))
|
||||
}
|
||||
|
||||
func (s *NetlinkSocket) Send(request *NetlinkRequest) error {
|
||||
fd := int(atomic.LoadInt32(&s.fd))
|
||||
if fd < 0 {
|
||||
return fmt.Errorf("Send called on a closed socket")
|
||||
}
|
||||
if err := unix.Sendto(fd, request.Serialize(), 0, &s.lsa); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *NetlinkSocket) Receive() ([]syscall.NetlinkMessage, *unix.SockaddrNetlink, error) {
|
||||
fd := int(atomic.LoadInt32(&s.fd))
|
||||
if fd < 0 {
|
||||
return nil, nil, fmt.Errorf("Receive called on a closed socket")
|
||||
}
|
||||
var fromAddr *unix.SockaddrNetlink
|
||||
var rb [RECEIVE_BUFFER_SIZE]byte
|
||||
nr, from, err := unix.Recvfrom(fd, rb[:], 0)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
fromAddr, ok := from.(*unix.SockaddrNetlink)
|
||||
if !ok {
|
||||
return nil, nil, fmt.Errorf("Error converting to netlink sockaddr")
|
||||
}
|
||||
if nr < unix.NLMSG_HDRLEN {
|
||||
return nil, nil, fmt.Errorf("Got short response from netlink")
|
||||
}
|
||||
rb2 := make([]byte, nr)
|
||||
copy(rb2, rb[:nr])
|
||||
nl, err := syscall.ParseNetlinkMessage(rb2)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
return nl, fromAddr, nil
|
||||
}
|
||||
|
||||
// SetSendTimeout allows to set a send timeout on the socket
|
||||
func (s *NetlinkSocket) SetSendTimeout(timeout *unix.Timeval) error {
|
||||
// Set a send timeout of SOCKET_SEND_TIMEOUT, this will allow the Send to periodically unblock and avoid that a routine
|
||||
// remains stuck on a send on a closed fd
|
||||
return unix.SetsockoptTimeval(int(s.fd), unix.SOL_SOCKET, unix.SO_SNDTIMEO, timeout)
|
||||
}
|
||||
|
||||
// SetReceiveTimeout allows to set a receive timeout on the socket
|
||||
func (s *NetlinkSocket) SetReceiveTimeout(timeout *unix.Timeval) error {
|
||||
// Set a read timeout of SOCKET_READ_TIMEOUT, this will allow the Read to periodically unblock and avoid that a routine
|
||||
// remains stuck on a recvmsg on a closed fd
|
||||
return unix.SetsockoptTimeval(int(s.fd), unix.SOL_SOCKET, unix.SO_RCVTIMEO, timeout)
|
||||
}
|
||||
|
||||
func (s *NetlinkSocket) GetPid() (uint32, error) {
|
||||
fd := int(atomic.LoadInt32(&s.fd))
|
||||
lsa, err := unix.Getsockname(fd)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
switch v := lsa.(type) {
|
||||
case *unix.SockaddrNetlink:
|
||||
return v.Pid, nil
|
||||
}
|
||||
return 0, fmt.Errorf("Wrong socket type")
|
||||
}
|
||||
|
||||
func ZeroTerminated(s string) []byte {
|
||||
bytes := make([]byte, len(s)+1)
|
||||
for i := 0; i < len(s); i++ {
|
||||
bytes[i] = s[i]
|
||||
}
|
||||
bytes[len(s)] = 0
|
||||
return bytes
|
||||
}
|
||||
|
||||
func NonZeroTerminated(s string) []byte {
|
||||
bytes := make([]byte, len(s))
|
||||
for i := 0; i < len(s); i++ {
|
||||
bytes[i] = s[i]
|
||||
}
|
||||
return bytes
|
||||
}
|
||||
|
||||
func BytesToString(b []byte) string {
|
||||
n := bytes.Index(b, []byte{0})
|
||||
return string(b[:n])
|
||||
}
|
||||
|
||||
func Uint8Attr(v uint8) []byte {
|
||||
return []byte{byte(v)}
|
||||
}
|
||||
|
||||
func Uint16Attr(v uint16) []byte {
|
||||
native := NativeEndian()
|
||||
bytes := make([]byte, 2)
|
||||
native.PutUint16(bytes, v)
|
||||
return bytes
|
||||
}
|
||||
|
||||
func Uint32Attr(v uint32) []byte {
|
||||
native := NativeEndian()
|
||||
bytes := make([]byte, 4)
|
||||
native.PutUint32(bytes, v)
|
||||
return bytes
|
||||
}
|
||||
|
||||
func Uint64Attr(v uint64) []byte {
|
||||
native := NativeEndian()
|
||||
bytes := make([]byte, 8)
|
||||
native.PutUint64(bytes, v)
|
||||
return bytes
|
||||
}
|
||||
|
||||
func ParseRouteAttr(b []byte) ([]syscall.NetlinkRouteAttr, error) {
|
||||
var attrs []syscall.NetlinkRouteAttr
|
||||
for len(b) >= unix.SizeofRtAttr {
|
||||
a, vbuf, alen, err := netlinkRouteAttrAndValue(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ra := syscall.NetlinkRouteAttr{Attr: syscall.RtAttr(*a), Value: vbuf[:int(a.Len)-unix.SizeofRtAttr]}
|
||||
attrs = append(attrs, ra)
|
||||
b = b[alen:]
|
||||
}
|
||||
return attrs, nil
|
||||
}
|
||||
|
||||
func netlinkRouteAttrAndValue(b []byte) (*unix.RtAttr, []byte, int, error) {
|
||||
a := (*unix.RtAttr)(unsafe.Pointer(&b[0]))
|
||||
if int(a.Len) < unix.SizeofRtAttr || int(a.Len) > len(b) {
|
||||
return nil, nil, 0, unix.EINVAL
|
||||
}
|
||||
return a, b[unix.SizeofRtAttr:], rtaAlignOf(int(a.Len)), nil
|
||||
}
|
||||
|
||||
// SocketHandle contains the netlink socket and the associated
|
||||
// sequence counter for a specific netlink family
|
||||
type SocketHandle struct {
|
||||
Seq uint32
|
||||
Socket *NetlinkSocket
|
||||
}
|
||||
|
||||
// Close closes the netlink socket
|
||||
func (sh *SocketHandle) Close() {
|
||||
if sh.Socket != nil {
|
||||
sh.Socket.Close()
|
||||
}
|
||||
}
|
11
vendor/github.com/tailscale/netlink/nl/nl_unspecified.go
generated
vendored
Normal file
11
vendor/github.com/tailscale/netlink/nl/nl_unspecified.go
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
// +build !linux
|
||||
|
||||
package nl
|
||||
|
||||
import "encoding/binary"
|
||||
|
||||
var SupportedNlFamilies = []int{}
|
||||
|
||||
func NativeEndian() binary.ByteOrder {
|
||||
return nil
|
||||
}
|
79
vendor/github.com/tailscale/netlink/nl/parse_attr_linux.go
generated
vendored
Normal file
79
vendor/github.com/tailscale/netlink/nl/parse_attr_linux.go
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
package nl
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"log"
|
||||
)
|
||||
|
||||
type Attribute struct {
|
||||
Type uint16
|
||||
Value []byte
|
||||
}
|
||||
|
||||
func ParseAttributes(data []byte) <-chan Attribute {
|
||||
native := NativeEndian()
|
||||
result := make(chan Attribute)
|
||||
|
||||
go func() {
|
||||
i := 0
|
||||
for i+4 < len(data) {
|
||||
length := int(native.Uint16(data[i : i+2]))
|
||||
attrType := native.Uint16(data[i+2 : i+4])
|
||||
|
||||
if length < 4 {
|
||||
log.Printf("attribute 0x%02x has invalid length of %d bytes", attrType, length)
|
||||
break
|
||||
}
|
||||
|
||||
if len(data) < i+length {
|
||||
log.Printf("attribute 0x%02x of length %d is truncated, only %d bytes remaining", attrType, length, len(data)-i)
|
||||
break
|
||||
}
|
||||
|
||||
result <- Attribute{
|
||||
Type: attrType,
|
||||
Value: data[i+4 : i+length],
|
||||
}
|
||||
i += rtaAlignOf(length)
|
||||
}
|
||||
close(result)
|
||||
}()
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
func PrintAttributes(data []byte) {
|
||||
printAttributes(data, 0)
|
||||
}
|
||||
|
||||
func printAttributes(data []byte, level int) {
|
||||
for attr := range ParseAttributes(data) {
|
||||
for i := 0; i < level; i++ {
|
||||
print("> ")
|
||||
}
|
||||
nested := attr.Type&NLA_F_NESTED != 0
|
||||
fmt.Printf("type=%d nested=%v len=%v %v\n", attr.Type&NLA_TYPE_MASK, nested, len(attr.Value), attr.Value)
|
||||
if nested {
|
||||
printAttributes(attr.Value, level+1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Uint32 returns the uint32 value respecting the NET_BYTEORDER flag
|
||||
func (attr *Attribute) Uint32() uint32 {
|
||||
if attr.Type&NLA_F_NET_BYTEORDER != 0 {
|
||||
return binary.BigEndian.Uint32(attr.Value)
|
||||
} else {
|
||||
return NativeEndian().Uint32(attr.Value)
|
||||
}
|
||||
}
|
||||
|
||||
// Uint64 returns the uint64 value respecting the NET_BYTEORDER flag
|
||||
func (attr *Attribute) Uint64() uint64 {
|
||||
if attr.Type&NLA_F_NET_BYTEORDER != 0 {
|
||||
return binary.BigEndian.Uint64(attr.Value)
|
||||
} else {
|
||||
return NativeEndian().Uint64(attr.Value)
|
||||
}
|
||||
}
|
39
vendor/github.com/tailscale/netlink/nl/rdma_link_linux.go
generated
vendored
Normal file
39
vendor/github.com/tailscale/netlink/nl/rdma_link_linux.go
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
package nl
|
||||
|
||||
const (
|
||||
RDMA_NL_GET_CLIENT_SHIFT = 10
|
||||
)
|
||||
|
||||
const (
|
||||
RDMA_NL_NLDEV = 5
|
||||
)
|
||||
|
||||
const (
|
||||
RDMA_NLDEV_CMD_GET = 1
|
||||
RDMA_NLDEV_CMD_SET = 2
|
||||
RDMA_NLDEV_CMD_NEWLINK = 3
|
||||
RDMA_NLDEV_CMD_DELLINK = 4
|
||||
RDMA_NLDEV_CMD_SYS_GET = 6
|
||||
RDMA_NLDEV_CMD_SYS_SET = 7
|
||||
)
|
||||
|
||||
const (
|
||||
RDMA_NLDEV_ATTR_DEV_INDEX = 1
|
||||
RDMA_NLDEV_ATTR_DEV_NAME = 2
|
||||
RDMA_NLDEV_ATTR_PORT_INDEX = 3
|
||||
RDMA_NLDEV_ATTR_CAP_FLAGS = 4
|
||||
RDMA_NLDEV_ATTR_FW_VERSION = 5
|
||||
RDMA_NLDEV_ATTR_NODE_GUID = 6
|
||||
RDMA_NLDEV_ATTR_SYS_IMAGE_GUID = 7
|
||||
RDMA_NLDEV_ATTR_SUBNET_PREFIX = 8
|
||||
RDMA_NLDEV_ATTR_LID = 9
|
||||
RDMA_NLDEV_ATTR_SM_LID = 10
|
||||
RDMA_NLDEV_ATTR_LMC = 11
|
||||
RDMA_NLDEV_ATTR_PORT_STATE = 12
|
||||
RDMA_NLDEV_ATTR_PORT_PHYS_STATE = 13
|
||||
RDMA_NLDEV_ATTR_DEV_NODE_TYPE = 14
|
||||
RDMA_NLDEV_ATTR_NDEV_NAME = 51
|
||||
RDMA_NLDEV_ATTR_LINK_TYPE = 65
|
||||
RDMA_NLDEV_SYS_ATTR_NETNS_MODE = 66
|
||||
RDMA_NLDEV_NET_NS_FD = 68
|
||||
)
|
107
vendor/github.com/tailscale/netlink/nl/route_linux.go
generated
vendored
Normal file
107
vendor/github.com/tailscale/netlink/nl/route_linux.go
generated
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
package nl
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
type RtMsg struct {
|
||||
unix.RtMsg
|
||||
}
|
||||
|
||||
func NewRtMsg() *RtMsg {
|
||||
return &RtMsg{
|
||||
RtMsg: unix.RtMsg{
|
||||
Table: unix.RT_TABLE_MAIN,
|
||||
Scope: unix.RT_SCOPE_UNIVERSE,
|
||||
Protocol: unix.RTPROT_BOOT,
|
||||
Type: unix.RTN_UNICAST,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func NewRtDelMsg() *RtMsg {
|
||||
return &RtMsg{
|
||||
RtMsg: unix.RtMsg{
|
||||
Table: unix.RT_TABLE_MAIN,
|
||||
Scope: unix.RT_SCOPE_NOWHERE,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (msg *RtMsg) Len() int {
|
||||
return unix.SizeofRtMsg
|
||||
}
|
||||
|
||||
func DeserializeRtMsg(b []byte) *RtMsg {
|
||||
return (*RtMsg)(unsafe.Pointer(&b[0:unix.SizeofRtMsg][0]))
|
||||
}
|
||||
|
||||
func (msg *RtMsg) Serialize() []byte {
|
||||
return (*(*[unix.SizeofRtMsg]byte)(unsafe.Pointer(msg)))[:]
|
||||
}
|
||||
|
||||
type RtNexthop struct {
|
||||
unix.RtNexthop
|
||||
Children []NetlinkRequestData
|
||||
}
|
||||
|
||||
func DeserializeRtNexthop(b []byte) *RtNexthop {
|
||||
return (*RtNexthop)(unsafe.Pointer(&b[0:unix.SizeofRtNexthop][0]))
|
||||
}
|
||||
|
||||
func (msg *RtNexthop) Len() int {
|
||||
if len(msg.Children) == 0 {
|
||||
return unix.SizeofRtNexthop
|
||||
}
|
||||
|
||||
l := 0
|
||||
for _, child := range msg.Children {
|
||||
l += rtaAlignOf(child.Len())
|
||||
}
|
||||
l += unix.SizeofRtNexthop
|
||||
return rtaAlignOf(l)
|
||||
}
|
||||
|
||||
func (msg *RtNexthop) Serialize() []byte {
|
||||
length := msg.Len()
|
||||
msg.RtNexthop.Len = uint16(length)
|
||||
buf := make([]byte, length)
|
||||
copy(buf, (*(*[unix.SizeofRtNexthop]byte)(unsafe.Pointer(msg)))[:])
|
||||
next := rtaAlignOf(unix.SizeofRtNexthop)
|
||||
if len(msg.Children) > 0 {
|
||||
for _, child := range msg.Children {
|
||||
childBuf := child.Serialize()
|
||||
copy(buf[next:], childBuf)
|
||||
next += rtaAlignOf(len(childBuf))
|
||||
}
|
||||
}
|
||||
return buf
|
||||
}
|
||||
|
||||
type RtGenMsg struct {
|
||||
unix.RtGenmsg
|
||||
}
|
||||
|
||||
func NewRtGenMsg() *RtGenMsg {
|
||||
return &RtGenMsg{
|
||||
RtGenmsg: unix.RtGenmsg{
|
||||
Family: unix.AF_UNSPEC,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (msg *RtGenMsg) Len() int {
|
||||
return rtaAlignOf(unix.SizeofRtGenmsg)
|
||||
}
|
||||
|
||||
func DeserializeRtGenMsg(b []byte) *RtGenMsg {
|
||||
return &RtGenMsg{RtGenmsg: unix.RtGenmsg{Family: b[0]}}
|
||||
}
|
||||
|
||||
func (msg *RtGenMsg) Serialize() []byte {
|
||||
out := make([]byte, msg.Len())
|
||||
out[0] = msg.Family
|
||||
return out
|
||||
}
|
154
vendor/github.com/tailscale/netlink/nl/seg6_linux.go
generated
vendored
Normal file
154
vendor/github.com/tailscale/netlink/nl/seg6_linux.go
generated
vendored
Normal file
@@ -0,0 +1,154 @@
|
||||
package nl
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
)
|
||||
|
||||
type IPv6SrHdr struct {
|
||||
nextHdr uint8
|
||||
hdrLen uint8
|
||||
routingType uint8
|
||||
segmentsLeft uint8
|
||||
firstSegment uint8
|
||||
flags uint8
|
||||
reserved uint16
|
||||
|
||||
Segments []net.IP
|
||||
}
|
||||
|
||||
func (s1 *IPv6SrHdr) Equal(s2 IPv6SrHdr) bool {
|
||||
if len(s1.Segments) != len(s2.Segments) {
|
||||
return false
|
||||
}
|
||||
for i := range s1.Segments {
|
||||
if !s1.Segments[i].Equal(s2.Segments[i]) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return s1.nextHdr == s2.nextHdr &&
|
||||
s1.hdrLen == s2.hdrLen &&
|
||||
s1.routingType == s2.routingType &&
|
||||
s1.segmentsLeft == s2.segmentsLeft &&
|
||||
s1.firstSegment == s2.firstSegment &&
|
||||
s1.flags == s2.flags
|
||||
// reserved doesn't need to be identical.
|
||||
}
|
||||
|
||||
// seg6 encap mode
|
||||
const (
|
||||
SEG6_IPTUN_MODE_INLINE = iota
|
||||
SEG6_IPTUN_MODE_ENCAP
|
||||
)
|
||||
|
||||
// number of nested RTATTR
|
||||
// from include/uapi/linux/seg6_iptunnel.h
|
||||
const (
|
||||
SEG6_IPTUNNEL_UNSPEC = iota
|
||||
SEG6_IPTUNNEL_SRH
|
||||
__SEG6_IPTUNNEL_MAX
|
||||
)
|
||||
const (
|
||||
SEG6_IPTUNNEL_MAX = __SEG6_IPTUNNEL_MAX - 1
|
||||
)
|
||||
|
||||
func EncodeSEG6Encap(mode int, segments []net.IP) ([]byte, error) {
|
||||
nsegs := len(segments) // nsegs: number of segments
|
||||
if nsegs == 0 {
|
||||
return nil, errors.New("EncodeSEG6Encap: No Segment in srh")
|
||||
}
|
||||
b := make([]byte, 12, 12+len(segments)*16)
|
||||
native := NativeEndian()
|
||||
native.PutUint32(b, uint32(mode))
|
||||
b[4] = 0 // srh.nextHdr (0 when calling netlink)
|
||||
b[5] = uint8(16 * nsegs >> 3) // srh.hdrLen (in 8-octets unit)
|
||||
b[6] = IPV6_SRCRT_TYPE_4 // srh.routingType (assigned by IANA)
|
||||
b[7] = uint8(nsegs - 1) // srh.segmentsLeft
|
||||
b[8] = uint8(nsegs - 1) // srh.firstSegment
|
||||
b[9] = 0 // srh.flags (SR6_FLAG1_HMAC for srh_hmac)
|
||||
// srh.reserved: Defined as "Tag" in draft-ietf-6man-segment-routing-header-07
|
||||
native.PutUint16(b[10:], 0) // srh.reserved
|
||||
for _, netIP := range segments {
|
||||
b = append(b, netIP...) // srh.Segments
|
||||
}
|
||||
return b, nil
|
||||
}
|
||||
|
||||
func DecodeSEG6Encap(buf []byte) (int, []net.IP, error) {
|
||||
native := NativeEndian()
|
||||
mode := int(native.Uint32(buf))
|
||||
srh := IPv6SrHdr{
|
||||
nextHdr: buf[4],
|
||||
hdrLen: buf[5],
|
||||
routingType: buf[6],
|
||||
segmentsLeft: buf[7],
|
||||
firstSegment: buf[8],
|
||||
flags: buf[9],
|
||||
reserved: native.Uint16(buf[10:12]),
|
||||
}
|
||||
buf = buf[12:]
|
||||
if len(buf)%16 != 0 {
|
||||
err := fmt.Errorf("DecodeSEG6Encap: error parsing Segment List (buf len: %d)", len(buf))
|
||||
return mode, nil, err
|
||||
}
|
||||
for len(buf) > 0 {
|
||||
srh.Segments = append(srh.Segments, net.IP(buf[:16]))
|
||||
buf = buf[16:]
|
||||
}
|
||||
return mode, srh.Segments, nil
|
||||
}
|
||||
|
||||
func DecodeSEG6Srh(buf []byte) ([]net.IP, error) {
|
||||
native := NativeEndian()
|
||||
srh := IPv6SrHdr{
|
||||
nextHdr: buf[0],
|
||||
hdrLen: buf[1],
|
||||
routingType: buf[2],
|
||||
segmentsLeft: buf[3],
|
||||
firstSegment: buf[4],
|
||||
flags: buf[5],
|
||||
reserved: native.Uint16(buf[6:8]),
|
||||
}
|
||||
buf = buf[8:]
|
||||
if len(buf)%16 != 0 {
|
||||
err := fmt.Errorf("DecodeSEG6Srh: error parsing Segment List (buf len: %d)", len(buf))
|
||||
return nil, err
|
||||
}
|
||||
for len(buf) > 0 {
|
||||
srh.Segments = append(srh.Segments, net.IP(buf[:16]))
|
||||
buf = buf[16:]
|
||||
}
|
||||
return srh.Segments, nil
|
||||
}
|
||||
func EncodeSEG6Srh(segments []net.IP) ([]byte, error) {
|
||||
nsegs := len(segments) // nsegs: number of segments
|
||||
if nsegs == 0 {
|
||||
return nil, errors.New("EncodeSEG6Srh: No Segments")
|
||||
}
|
||||
b := make([]byte, 8, 8+len(segments)*16)
|
||||
native := NativeEndian()
|
||||
b[0] = 0 // srh.nextHdr (0 when calling netlink)
|
||||
b[1] = uint8(16 * nsegs >> 3) // srh.hdrLen (in 8-octets unit)
|
||||
b[2] = IPV6_SRCRT_TYPE_4 // srh.routingType (assigned by IANA)
|
||||
b[3] = uint8(nsegs - 1) // srh.segmentsLeft
|
||||
b[4] = uint8(nsegs - 1) // srh.firstSegment
|
||||
b[5] = 0 // srh.flags (SR6_FLAG1_HMAC for srh_hmac)
|
||||
// srh.reserved: Defined as "Tag" in draft-ietf-6man-segment-routing-header-07
|
||||
native.PutUint16(b[6:], 0) // srh.reserved
|
||||
for _, netIP := range segments {
|
||||
b = append(b, netIP...) // srh.Segments
|
||||
}
|
||||
return b, nil
|
||||
}
|
||||
|
||||
// Helper functions
|
||||
func SEG6EncapModeString(mode int) string {
|
||||
switch mode {
|
||||
case SEG6_IPTUN_MODE_INLINE:
|
||||
return "inline"
|
||||
case SEG6_IPTUN_MODE_ENCAP:
|
||||
return "encap"
|
||||
}
|
||||
return "unknown"
|
||||
}
|
76
vendor/github.com/tailscale/netlink/nl/seg6local_linux.go
generated
vendored
Normal file
76
vendor/github.com/tailscale/netlink/nl/seg6local_linux.go
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
package nl
|
||||
|
||||
import ()
|
||||
|
||||
// seg6local parameters
|
||||
const (
|
||||
SEG6_LOCAL_UNSPEC = iota
|
||||
SEG6_LOCAL_ACTION
|
||||
SEG6_LOCAL_SRH
|
||||
SEG6_LOCAL_TABLE
|
||||
SEG6_LOCAL_NH4
|
||||
SEG6_LOCAL_NH6
|
||||
SEG6_LOCAL_IIF
|
||||
SEG6_LOCAL_OIF
|
||||
__SEG6_LOCAL_MAX
|
||||
)
|
||||
const (
|
||||
SEG6_LOCAL_MAX = __SEG6_LOCAL_MAX
|
||||
)
|
||||
|
||||
// seg6local actions
|
||||
const (
|
||||
SEG6_LOCAL_ACTION_END = iota + 1 // 1
|
||||
SEG6_LOCAL_ACTION_END_X // 2
|
||||
SEG6_LOCAL_ACTION_END_T // 3
|
||||
SEG6_LOCAL_ACTION_END_DX2 // 4
|
||||
SEG6_LOCAL_ACTION_END_DX6 // 5
|
||||
SEG6_LOCAL_ACTION_END_DX4 // 6
|
||||
SEG6_LOCAL_ACTION_END_DT6 // 7
|
||||
SEG6_LOCAL_ACTION_END_DT4 // 8
|
||||
SEG6_LOCAL_ACTION_END_B6 // 9
|
||||
SEG6_LOCAL_ACTION_END_B6_ENCAPS // 10
|
||||
SEG6_LOCAL_ACTION_END_BM // 11
|
||||
SEG6_LOCAL_ACTION_END_S // 12
|
||||
SEG6_LOCAL_ACTION_END_AS // 13
|
||||
SEG6_LOCAL_ACTION_END_AM // 14
|
||||
__SEG6_LOCAL_ACTION_MAX
|
||||
)
|
||||
const (
|
||||
SEG6_LOCAL_ACTION_MAX = __SEG6_LOCAL_ACTION_MAX - 1
|
||||
)
|
||||
|
||||
// Helper functions
|
||||
func SEG6LocalActionString(action int) string {
|
||||
switch action {
|
||||
case SEG6_LOCAL_ACTION_END:
|
||||
return "End"
|
||||
case SEG6_LOCAL_ACTION_END_X:
|
||||
return "End.X"
|
||||
case SEG6_LOCAL_ACTION_END_T:
|
||||
return "End.T"
|
||||
case SEG6_LOCAL_ACTION_END_DX2:
|
||||
return "End.DX2"
|
||||
case SEG6_LOCAL_ACTION_END_DX6:
|
||||
return "End.DX6"
|
||||
case SEG6_LOCAL_ACTION_END_DX4:
|
||||
return "End.DX4"
|
||||
case SEG6_LOCAL_ACTION_END_DT6:
|
||||
return "End.DT6"
|
||||
case SEG6_LOCAL_ACTION_END_DT4:
|
||||
return "End.DT4"
|
||||
case SEG6_LOCAL_ACTION_END_B6:
|
||||
return "End.B6"
|
||||
case SEG6_LOCAL_ACTION_END_B6_ENCAPS:
|
||||
return "End.B6.Encaps"
|
||||
case SEG6_LOCAL_ACTION_END_BM:
|
||||
return "End.BM"
|
||||
case SEG6_LOCAL_ACTION_END_S:
|
||||
return "End.S"
|
||||
case SEG6_LOCAL_ACTION_END_AS:
|
||||
return "End.AS"
|
||||
case SEG6_LOCAL_ACTION_END_AM:
|
||||
return "End.AM"
|
||||
}
|
||||
return "unknown"
|
||||
}
|
76
vendor/github.com/tailscale/netlink/nl/syscall.go
generated
vendored
Normal file
76
vendor/github.com/tailscale/netlink/nl/syscall.go
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
package nl
|
||||
|
||||
// syscall package lack of rule attributes type.
|
||||
// Thus there are defined below
|
||||
const (
|
||||
FRA_UNSPEC = iota
|
||||
FRA_DST /* destination address */
|
||||
FRA_SRC /* source address */
|
||||
FRA_IIFNAME /* interface name */
|
||||
FRA_GOTO /* target to jump to (FR_ACT_GOTO) */
|
||||
FRA_UNUSED2
|
||||
FRA_PRIORITY /* priority/preference */
|
||||
FRA_UNUSED3
|
||||
FRA_UNUSED4
|
||||
FRA_UNUSED5
|
||||
FRA_FWMARK /* mark */
|
||||
FRA_FLOW /* flow/class id */
|
||||
FRA_TUN_ID
|
||||
FRA_SUPPRESS_IFGROUP
|
||||
FRA_SUPPRESS_PREFIXLEN
|
||||
FRA_TABLE /* Extended table id */
|
||||
FRA_FWMASK /* mask for netfilter mark */
|
||||
FRA_OIFNAME
|
||||
FRA_PAD
|
||||
FRA_L3MDEV /* iif or oif is l3mdev goto its table */
|
||||
FRA_UID_RANGE /* UID range */
|
||||
FRA_PROTOCOL /* Originator of the rule */
|
||||
FRA_IP_PROTO /* ip proto */
|
||||
FRA_SPORT_RANGE /* sport */
|
||||
FRA_DPORT_RANGE /* dport */
|
||||
)
|
||||
|
||||
// ip rule netlink request types
|
||||
const (
|
||||
FR_ACT_UNSPEC = iota
|
||||
FR_ACT_TO_TBL /* Pass to fixed table */
|
||||
FR_ACT_GOTO /* Jump to another rule */
|
||||
FR_ACT_NOP /* No operation */
|
||||
FR_ACT_RES3
|
||||
FR_ACT_RES4
|
||||
FR_ACT_BLACKHOLE /* Drop without notification */
|
||||
FR_ACT_UNREACHABLE /* Drop with ENETUNREACH */
|
||||
FR_ACT_PROHIBIT /* Drop with EACCES */
|
||||
)
|
||||
|
||||
// socket diags related
|
||||
const (
|
||||
SOCK_DIAG_BY_FAMILY = 20 /* linux.sock_diag.h */
|
||||
TCPDIAG_NOCOOKIE = 0xFFFFFFFF /* TCPDIAG_NOCOOKIE in net/ipv4/tcp_diag.h*/
|
||||
)
|
||||
|
||||
// RTA_ENCAP subtype
|
||||
const (
|
||||
MPLS_IPTUNNEL_UNSPEC = iota
|
||||
MPLS_IPTUNNEL_DST
|
||||
)
|
||||
|
||||
// light weight tunnel encap types
|
||||
const (
|
||||
LWTUNNEL_ENCAP_NONE = iota
|
||||
LWTUNNEL_ENCAP_MPLS
|
||||
LWTUNNEL_ENCAP_IP
|
||||
LWTUNNEL_ENCAP_ILA
|
||||
LWTUNNEL_ENCAP_IP6
|
||||
LWTUNNEL_ENCAP_SEG6
|
||||
LWTUNNEL_ENCAP_BPF
|
||||
LWTUNNEL_ENCAP_SEG6_LOCAL
|
||||
)
|
||||
|
||||
// routing header types
|
||||
const (
|
||||
IPV6_SRCRT_STRICT = 0x01 // Deprecated; will be removed
|
||||
IPV6_SRCRT_TYPE_0 = 0 // Deprecated; will be removed
|
||||
IPV6_SRCRT_TYPE_2 = 2 // IPv6 type 2 Routing Header
|
||||
IPV6_SRCRT_TYPE_4 = 4 // Segment Routing with IPv6
|
||||
)
|
1088
vendor/github.com/tailscale/netlink/nl/tc_linux.go
generated
vendored
Normal file
1088
vendor/github.com/tailscale/netlink/nl/tc_linux.go
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
306
vendor/github.com/tailscale/netlink/nl/xfrm_linux.go
generated
vendored
Normal file
306
vendor/github.com/tailscale/netlink/nl/xfrm_linux.go
generated
vendored
Normal file
@@ -0,0 +1,306 @@
|
||||
package nl
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"net"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// Infinity for packet and byte counts
|
||||
const (
|
||||
XFRM_INF = ^uint64(0)
|
||||
)
|
||||
|
||||
type XfrmMsgType uint8
|
||||
|
||||
type XfrmMsg interface {
|
||||
Type() XfrmMsgType
|
||||
}
|
||||
|
||||
// Message Types
|
||||
const (
|
||||
XFRM_MSG_BASE XfrmMsgType = 0x10
|
||||
XFRM_MSG_NEWSA = 0x10
|
||||
XFRM_MSG_DELSA = 0x11
|
||||
XFRM_MSG_GETSA = 0x12
|
||||
XFRM_MSG_NEWPOLICY = 0x13
|
||||
XFRM_MSG_DELPOLICY = 0x14
|
||||
XFRM_MSG_GETPOLICY = 0x15
|
||||
XFRM_MSG_ALLOCSPI = 0x16
|
||||
XFRM_MSG_ACQUIRE = 0x17
|
||||
XFRM_MSG_EXPIRE = 0x18
|
||||
XFRM_MSG_UPDPOLICY = 0x19
|
||||
XFRM_MSG_UPDSA = 0x1a
|
||||
XFRM_MSG_POLEXPIRE = 0x1b
|
||||
XFRM_MSG_FLUSHSA = 0x1c
|
||||
XFRM_MSG_FLUSHPOLICY = 0x1d
|
||||
XFRM_MSG_NEWAE = 0x1e
|
||||
XFRM_MSG_GETAE = 0x1f
|
||||
XFRM_MSG_REPORT = 0x20
|
||||
XFRM_MSG_MIGRATE = 0x21
|
||||
XFRM_MSG_NEWSADINFO = 0x22
|
||||
XFRM_MSG_GETSADINFO = 0x23
|
||||
XFRM_MSG_NEWSPDINFO = 0x24
|
||||
XFRM_MSG_GETSPDINFO = 0x25
|
||||
XFRM_MSG_MAPPING = 0x26
|
||||
XFRM_MSG_MAX = 0x26
|
||||
XFRM_NR_MSGTYPES = 0x17
|
||||
)
|
||||
|
||||
// Attribute types
|
||||
const (
|
||||
/* Netlink message attributes. */
|
||||
XFRMA_UNSPEC = iota
|
||||
XFRMA_ALG_AUTH /* struct xfrm_algo */
|
||||
XFRMA_ALG_CRYPT /* struct xfrm_algo */
|
||||
XFRMA_ALG_COMP /* struct xfrm_algo */
|
||||
XFRMA_ENCAP /* struct xfrm_algo + struct xfrm_encap_tmpl */
|
||||
XFRMA_TMPL /* 1 or more struct xfrm_user_tmpl */
|
||||
XFRMA_SA /* struct xfrm_usersa_info */
|
||||
XFRMA_POLICY /* struct xfrm_userpolicy_info */
|
||||
XFRMA_SEC_CTX /* struct xfrm_sec_ctx */
|
||||
XFRMA_LTIME_VAL
|
||||
XFRMA_REPLAY_VAL
|
||||
XFRMA_REPLAY_THRESH
|
||||
XFRMA_ETIMER_THRESH
|
||||
XFRMA_SRCADDR /* xfrm_address_t */
|
||||
XFRMA_COADDR /* xfrm_address_t */
|
||||
XFRMA_LASTUSED /* unsigned long */
|
||||
XFRMA_POLICY_TYPE /* struct xfrm_userpolicy_type */
|
||||
XFRMA_MIGRATE
|
||||
XFRMA_ALG_AEAD /* struct xfrm_algo_aead */
|
||||
XFRMA_KMADDRESS /* struct xfrm_user_kmaddress */
|
||||
XFRMA_ALG_AUTH_TRUNC /* struct xfrm_algo_auth */
|
||||
XFRMA_MARK /* struct xfrm_mark */
|
||||
XFRMA_TFCPAD /* __u32 */
|
||||
XFRMA_REPLAY_ESN_VAL /* struct xfrm_replay_esn */
|
||||
XFRMA_SA_EXTRA_FLAGS /* __u32 */
|
||||
XFRMA_PROTO /* __u8 */
|
||||
XFRMA_ADDRESS_FILTER /* struct xfrm_address_filter */
|
||||
XFRMA_PAD
|
||||
XFRMA_OFFLOAD_DEV /* struct xfrm_state_offload */
|
||||
XFRMA_SET_MARK /* __u32 */
|
||||
XFRMA_SET_MARK_MASK /* __u32 */
|
||||
XFRMA_IF_ID /* __u32 */
|
||||
|
||||
XFRMA_MAX = iota - 1
|
||||
)
|
||||
|
||||
const XFRMA_OUTPUT_MARK = XFRMA_SET_MARK
|
||||
|
||||
const (
|
||||
SizeofXfrmAddress = 0x10
|
||||
SizeofXfrmSelector = 0x38
|
||||
SizeofXfrmLifetimeCfg = 0x40
|
||||
SizeofXfrmLifetimeCur = 0x20
|
||||
SizeofXfrmId = 0x18
|
||||
SizeofXfrmMark = 0x08
|
||||
)
|
||||
|
||||
// Netlink groups
|
||||
const (
|
||||
XFRMNLGRP_NONE = 0x0
|
||||
XFRMNLGRP_ACQUIRE = 0x1
|
||||
XFRMNLGRP_EXPIRE = 0x2
|
||||
XFRMNLGRP_SA = 0x3
|
||||
XFRMNLGRP_POLICY = 0x4
|
||||
XFRMNLGRP_AEVENTS = 0x5
|
||||
XFRMNLGRP_REPORT = 0x6
|
||||
XFRMNLGRP_MIGRATE = 0x7
|
||||
XFRMNLGRP_MAPPING = 0x8
|
||||
__XFRMNLGRP_MAX = 0x9
|
||||
)
|
||||
|
||||
// typedef union {
|
||||
// __be32 a4;
|
||||
// __be32 a6[4];
|
||||
// } xfrm_address_t;
|
||||
|
||||
type XfrmAddress [SizeofXfrmAddress]byte
|
||||
|
||||
func (x *XfrmAddress) ToIP() net.IP {
|
||||
var empty = [12]byte{}
|
||||
ip := make(net.IP, net.IPv6len)
|
||||
if bytes.Equal(x[4:16], empty[:]) {
|
||||
ip[10] = 0xff
|
||||
ip[11] = 0xff
|
||||
copy(ip[12:16], x[0:4])
|
||||
} else {
|
||||
copy(ip[:], x[:])
|
||||
}
|
||||
return ip
|
||||
}
|
||||
|
||||
func (x *XfrmAddress) ToIPNet(prefixlen uint8) *net.IPNet {
|
||||
ip := x.ToIP()
|
||||
if GetIPFamily(ip) == FAMILY_V4 {
|
||||
return &net.IPNet{IP: ip, Mask: net.CIDRMask(int(prefixlen), 32)}
|
||||
}
|
||||
return &net.IPNet{IP: ip, Mask: net.CIDRMask(int(prefixlen), 128)}
|
||||
}
|
||||
|
||||
func (x *XfrmAddress) FromIP(ip net.IP) {
|
||||
var empty = [16]byte{}
|
||||
if len(ip) < net.IPv4len {
|
||||
copy(x[4:16], empty[:])
|
||||
} else if GetIPFamily(ip) == FAMILY_V4 {
|
||||
copy(x[0:4], ip.To4()[0:4])
|
||||
copy(x[4:16], empty[:12])
|
||||
} else {
|
||||
copy(x[0:16], ip.To16()[0:16])
|
||||
}
|
||||
}
|
||||
|
||||
func DeserializeXfrmAddress(b []byte) *XfrmAddress {
|
||||
return (*XfrmAddress)(unsafe.Pointer(&b[0:SizeofXfrmAddress][0]))
|
||||
}
|
||||
|
||||
func (x *XfrmAddress) Serialize() []byte {
|
||||
return (*(*[SizeofXfrmAddress]byte)(unsafe.Pointer(x)))[:]
|
||||
}
|
||||
|
||||
// struct xfrm_selector {
|
||||
// xfrm_address_t daddr;
|
||||
// xfrm_address_t saddr;
|
||||
// __be16 dport;
|
||||
// __be16 dport_mask;
|
||||
// __be16 sport;
|
||||
// __be16 sport_mask;
|
||||
// __u16 family;
|
||||
// __u8 prefixlen_d;
|
||||
// __u8 prefixlen_s;
|
||||
// __u8 proto;
|
||||
// int ifindex;
|
||||
// __kernel_uid32_t user;
|
||||
// };
|
||||
|
||||
type XfrmSelector struct {
|
||||
Daddr XfrmAddress
|
||||
Saddr XfrmAddress
|
||||
Dport uint16 // big endian
|
||||
DportMask uint16 // big endian
|
||||
Sport uint16 // big endian
|
||||
SportMask uint16 // big endian
|
||||
Family uint16
|
||||
PrefixlenD uint8
|
||||
PrefixlenS uint8
|
||||
Proto uint8
|
||||
Pad [3]byte
|
||||
Ifindex int32
|
||||
User uint32
|
||||
}
|
||||
|
||||
func (msg *XfrmSelector) Len() int {
|
||||
return SizeofXfrmSelector
|
||||
}
|
||||
|
||||
func DeserializeXfrmSelector(b []byte) *XfrmSelector {
|
||||
return (*XfrmSelector)(unsafe.Pointer(&b[0:SizeofXfrmSelector][0]))
|
||||
}
|
||||
|
||||
func (msg *XfrmSelector) Serialize() []byte {
|
||||
return (*(*[SizeofXfrmSelector]byte)(unsafe.Pointer(msg)))[:]
|
||||
}
|
||||
|
||||
// struct xfrm_lifetime_cfg {
|
||||
// __u64 soft_byte_limit;
|
||||
// __u64 hard_byte_limit;
|
||||
// __u64 soft_packet_limit;
|
||||
// __u64 hard_packet_limit;
|
||||
// __u64 soft_add_expires_seconds;
|
||||
// __u64 hard_add_expires_seconds;
|
||||
// __u64 soft_use_expires_seconds;
|
||||
// __u64 hard_use_expires_seconds;
|
||||
// };
|
||||
//
|
||||
|
||||
type XfrmLifetimeCfg struct {
|
||||
SoftByteLimit uint64
|
||||
HardByteLimit uint64
|
||||
SoftPacketLimit uint64
|
||||
HardPacketLimit uint64
|
||||
SoftAddExpiresSeconds uint64
|
||||
HardAddExpiresSeconds uint64
|
||||
SoftUseExpiresSeconds uint64
|
||||
HardUseExpiresSeconds uint64
|
||||
}
|
||||
|
||||
func (msg *XfrmLifetimeCfg) Len() int {
|
||||
return SizeofXfrmLifetimeCfg
|
||||
}
|
||||
|
||||
func DeserializeXfrmLifetimeCfg(b []byte) *XfrmLifetimeCfg {
|
||||
return (*XfrmLifetimeCfg)(unsafe.Pointer(&b[0:SizeofXfrmLifetimeCfg][0]))
|
||||
}
|
||||
|
||||
func (msg *XfrmLifetimeCfg) Serialize() []byte {
|
||||
return (*(*[SizeofXfrmLifetimeCfg]byte)(unsafe.Pointer(msg)))[:]
|
||||
}
|
||||
|
||||
// struct xfrm_lifetime_cur {
|
||||
// __u64 bytes;
|
||||
// __u64 packets;
|
||||
// __u64 add_time;
|
||||
// __u64 use_time;
|
||||
// };
|
||||
|
||||
type XfrmLifetimeCur struct {
|
||||
Bytes uint64
|
||||
Packets uint64
|
||||
AddTime uint64
|
||||
UseTime uint64
|
||||
}
|
||||
|
||||
func (msg *XfrmLifetimeCur) Len() int {
|
||||
return SizeofXfrmLifetimeCur
|
||||
}
|
||||
|
||||
func DeserializeXfrmLifetimeCur(b []byte) *XfrmLifetimeCur {
|
||||
return (*XfrmLifetimeCur)(unsafe.Pointer(&b[0:SizeofXfrmLifetimeCur][0]))
|
||||
}
|
||||
|
||||
func (msg *XfrmLifetimeCur) Serialize() []byte {
|
||||
return (*(*[SizeofXfrmLifetimeCur]byte)(unsafe.Pointer(msg)))[:]
|
||||
}
|
||||
|
||||
// struct xfrm_id {
|
||||
// xfrm_address_t daddr;
|
||||
// __be32 spi;
|
||||
// __u8 proto;
|
||||
// };
|
||||
|
||||
type XfrmId struct {
|
||||
Daddr XfrmAddress
|
||||
Spi uint32 // big endian
|
||||
Proto uint8
|
||||
Pad [3]byte
|
||||
}
|
||||
|
||||
func (msg *XfrmId) Len() int {
|
||||
return SizeofXfrmId
|
||||
}
|
||||
|
||||
func DeserializeXfrmId(b []byte) *XfrmId {
|
||||
return (*XfrmId)(unsafe.Pointer(&b[0:SizeofXfrmId][0]))
|
||||
}
|
||||
|
||||
func (msg *XfrmId) Serialize() []byte {
|
||||
return (*(*[SizeofXfrmId]byte)(unsafe.Pointer(msg)))[:]
|
||||
}
|
||||
|
||||
type XfrmMark struct {
|
||||
Value uint32
|
||||
Mask uint32
|
||||
}
|
||||
|
||||
func (msg *XfrmMark) Len() int {
|
||||
return SizeofXfrmMark
|
||||
}
|
||||
|
||||
func DeserializeXfrmMark(b []byte) *XfrmMark {
|
||||
return (*XfrmMark)(unsafe.Pointer(&b[0:SizeofXfrmMark][0]))
|
||||
}
|
||||
|
||||
func (msg *XfrmMark) Serialize() []byte {
|
||||
return (*(*[SizeofXfrmMark]byte)(unsafe.Pointer(msg)))[:]
|
||||
}
|
32
vendor/github.com/tailscale/netlink/nl/xfrm_monitor_linux.go
generated
vendored
Normal file
32
vendor/github.com/tailscale/netlink/nl/xfrm_monitor_linux.go
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
package nl
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
SizeofXfrmUserExpire = 0xe8
|
||||
)
|
||||
|
||||
// struct xfrm_user_expire {
|
||||
// struct xfrm_usersa_info state;
|
||||
// __u8 hard;
|
||||
// };
|
||||
|
||||
type XfrmUserExpire struct {
|
||||
XfrmUsersaInfo XfrmUsersaInfo
|
||||
Hard uint8
|
||||
Pad [7]byte
|
||||
}
|
||||
|
||||
func (msg *XfrmUserExpire) Len() int {
|
||||
return SizeofXfrmUserExpire
|
||||
}
|
||||
|
||||
func DeserializeXfrmUserExpire(b []byte) *XfrmUserExpire {
|
||||
return (*XfrmUserExpire)(unsafe.Pointer(&b[0:SizeofXfrmUserExpire][0]))
|
||||
}
|
||||
|
||||
func (msg *XfrmUserExpire) Serialize() []byte {
|
||||
return (*(*[SizeofXfrmUserExpire]byte)(unsafe.Pointer(msg)))[:]
|
||||
}
|
119
vendor/github.com/tailscale/netlink/nl/xfrm_policy_linux.go
generated
vendored
Normal file
119
vendor/github.com/tailscale/netlink/nl/xfrm_policy_linux.go
generated
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
package nl
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
SizeofXfrmUserpolicyId = 0x40
|
||||
SizeofXfrmUserpolicyInfo = 0xa8
|
||||
SizeofXfrmUserTmpl = 0x40
|
||||
)
|
||||
|
||||
// struct xfrm_userpolicy_id {
|
||||
// struct xfrm_selector sel;
|
||||
// __u32 index;
|
||||
// __u8 dir;
|
||||
// };
|
||||
//
|
||||
|
||||
type XfrmUserpolicyId struct {
|
||||
Sel XfrmSelector
|
||||
Index uint32
|
||||
Dir uint8
|
||||
Pad [3]byte
|
||||
}
|
||||
|
||||
func (msg *XfrmUserpolicyId) Len() int {
|
||||
return SizeofXfrmUserpolicyId
|
||||
}
|
||||
|
||||
func DeserializeXfrmUserpolicyId(b []byte) *XfrmUserpolicyId {
|
||||
return (*XfrmUserpolicyId)(unsafe.Pointer(&b[0:SizeofXfrmUserpolicyId][0]))
|
||||
}
|
||||
|
||||
func (msg *XfrmUserpolicyId) Serialize() []byte {
|
||||
return (*(*[SizeofXfrmUserpolicyId]byte)(unsafe.Pointer(msg)))[:]
|
||||
}
|
||||
|
||||
// struct xfrm_userpolicy_info {
|
||||
// struct xfrm_selector sel;
|
||||
// struct xfrm_lifetime_cfg lft;
|
||||
// struct xfrm_lifetime_cur curlft;
|
||||
// __u32 priority;
|
||||
// __u32 index;
|
||||
// __u8 dir;
|
||||
// __u8 action;
|
||||
// #define XFRM_POLICY_ALLOW 0
|
||||
// #define XFRM_POLICY_BLOCK 1
|
||||
// __u8 flags;
|
||||
// #define XFRM_POLICY_LOCALOK 1 /* Allow user to override global policy */
|
||||
// /* Automatically expand selector to include matching ICMP payloads. */
|
||||
// #define XFRM_POLICY_ICMP 2
|
||||
// __u8 share;
|
||||
// };
|
||||
|
||||
type XfrmUserpolicyInfo struct {
|
||||
Sel XfrmSelector
|
||||
Lft XfrmLifetimeCfg
|
||||
Curlft XfrmLifetimeCur
|
||||
Priority uint32
|
||||
Index uint32
|
||||
Dir uint8
|
||||
Action uint8
|
||||
Flags uint8
|
||||
Share uint8
|
||||
Pad [4]byte
|
||||
}
|
||||
|
||||
func (msg *XfrmUserpolicyInfo) Len() int {
|
||||
return SizeofXfrmUserpolicyInfo
|
||||
}
|
||||
|
||||
func DeserializeXfrmUserpolicyInfo(b []byte) *XfrmUserpolicyInfo {
|
||||
return (*XfrmUserpolicyInfo)(unsafe.Pointer(&b[0:SizeofXfrmUserpolicyInfo][0]))
|
||||
}
|
||||
|
||||
func (msg *XfrmUserpolicyInfo) Serialize() []byte {
|
||||
return (*(*[SizeofXfrmUserpolicyInfo]byte)(unsafe.Pointer(msg)))[:]
|
||||
}
|
||||
|
||||
// struct xfrm_user_tmpl {
|
||||
// struct xfrm_id id;
|
||||
// __u16 family;
|
||||
// xfrm_address_t saddr;
|
||||
// __u32 reqid;
|
||||
// __u8 mode;
|
||||
// __u8 share;
|
||||
// __u8 optional;
|
||||
// __u32 aalgos;
|
||||
// __u32 ealgos;
|
||||
// __u32 calgos;
|
||||
// }
|
||||
|
||||
type XfrmUserTmpl struct {
|
||||
XfrmId XfrmId
|
||||
Family uint16
|
||||
Pad1 [2]byte
|
||||
Saddr XfrmAddress
|
||||
Reqid uint32
|
||||
Mode uint8
|
||||
Share uint8
|
||||
Optional uint8
|
||||
Pad2 byte
|
||||
Aalgos uint32
|
||||
Ealgos uint32
|
||||
Calgos uint32
|
||||
}
|
||||
|
||||
func (msg *XfrmUserTmpl) Len() int {
|
||||
return SizeofXfrmUserTmpl
|
||||
}
|
||||
|
||||
func DeserializeXfrmUserTmpl(b []byte) *XfrmUserTmpl {
|
||||
return (*XfrmUserTmpl)(unsafe.Pointer(&b[0:SizeofXfrmUserTmpl][0]))
|
||||
}
|
||||
|
||||
func (msg *XfrmUserTmpl) Serialize() []byte {
|
||||
return (*(*[SizeofXfrmUserTmpl]byte)(unsafe.Pointer(msg)))[:]
|
||||
}
|
334
vendor/github.com/tailscale/netlink/nl/xfrm_state_linux.go
generated
vendored
Normal file
334
vendor/github.com/tailscale/netlink/nl/xfrm_state_linux.go
generated
vendored
Normal file
@@ -0,0 +1,334 @@
|
||||
package nl
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
SizeofXfrmUsersaId = 0x18
|
||||
SizeofXfrmStats = 0x0c
|
||||
SizeofXfrmUsersaInfo = 0xe0
|
||||
SizeofXfrmUserSpiInfo = 0xe8
|
||||
SizeofXfrmAlgo = 0x44
|
||||
SizeofXfrmAlgoAuth = 0x48
|
||||
SizeofXfrmAlgoAEAD = 0x48
|
||||
SizeofXfrmEncapTmpl = 0x18
|
||||
SizeofXfrmUsersaFlush = 0x1
|
||||
SizeofXfrmReplayStateEsn = 0x18
|
||||
)
|
||||
|
||||
const (
|
||||
XFRM_STATE_NOECN = 1
|
||||
XFRM_STATE_DECAP_DSCP = 2
|
||||
XFRM_STATE_NOPMTUDISC = 4
|
||||
XFRM_STATE_WILDRECV = 8
|
||||
XFRM_STATE_ICMP = 16
|
||||
XFRM_STATE_AF_UNSPEC = 32
|
||||
XFRM_STATE_ALIGN4 = 64
|
||||
XFRM_STATE_ESN = 128
|
||||
)
|
||||
|
||||
// struct xfrm_usersa_id {
|
||||
// xfrm_address_t daddr;
|
||||
// __be32 spi;
|
||||
// __u16 family;
|
||||
// __u8 proto;
|
||||
// };
|
||||
|
||||
type XfrmUsersaId struct {
|
||||
Daddr XfrmAddress
|
||||
Spi uint32 // big endian
|
||||
Family uint16
|
||||
Proto uint8
|
||||
Pad byte
|
||||
}
|
||||
|
||||
func (msg *XfrmUsersaId) Len() int {
|
||||
return SizeofXfrmUsersaId
|
||||
}
|
||||
|
||||
func DeserializeXfrmUsersaId(b []byte) *XfrmUsersaId {
|
||||
return (*XfrmUsersaId)(unsafe.Pointer(&b[0:SizeofXfrmUsersaId][0]))
|
||||
}
|
||||
|
||||
func (msg *XfrmUsersaId) Serialize() []byte {
|
||||
return (*(*[SizeofXfrmUsersaId]byte)(unsafe.Pointer(msg)))[:]
|
||||
}
|
||||
|
||||
// struct xfrm_stats {
|
||||
// __u32 replay_window;
|
||||
// __u32 replay;
|
||||
// __u32 integrity_failed;
|
||||
// };
|
||||
|
||||
type XfrmStats struct {
|
||||
ReplayWindow uint32
|
||||
Replay uint32
|
||||
IntegrityFailed uint32
|
||||
}
|
||||
|
||||
func (msg *XfrmStats) Len() int {
|
||||
return SizeofXfrmStats
|
||||
}
|
||||
|
||||
func DeserializeXfrmStats(b []byte) *XfrmStats {
|
||||
return (*XfrmStats)(unsafe.Pointer(&b[0:SizeofXfrmStats][0]))
|
||||
}
|
||||
|
||||
func (msg *XfrmStats) Serialize() []byte {
|
||||
return (*(*[SizeofXfrmStats]byte)(unsafe.Pointer(msg)))[:]
|
||||
}
|
||||
|
||||
// struct xfrm_usersa_info {
|
||||
// struct xfrm_selector sel;
|
||||
// struct xfrm_id id;
|
||||
// xfrm_address_t saddr;
|
||||
// struct xfrm_lifetime_cfg lft;
|
||||
// struct xfrm_lifetime_cur curlft;
|
||||
// struct xfrm_stats stats;
|
||||
// __u32 seq;
|
||||
// __u32 reqid;
|
||||
// __u16 family;
|
||||
// __u8 mode; /* XFRM_MODE_xxx */
|
||||
// __u8 replay_window;
|
||||
// __u8 flags;
|
||||
// #define XFRM_STATE_NOECN 1
|
||||
// #define XFRM_STATE_DECAP_DSCP 2
|
||||
// #define XFRM_STATE_NOPMTUDISC 4
|
||||
// #define XFRM_STATE_WILDRECV 8
|
||||
// #define XFRM_STATE_ICMP 16
|
||||
// #define XFRM_STATE_AF_UNSPEC 32
|
||||
// #define XFRM_STATE_ALIGN4 64
|
||||
// #define XFRM_STATE_ESN 128
|
||||
// };
|
||||
//
|
||||
// #define XFRM_SA_XFLAG_DONT_ENCAP_DSCP 1
|
||||
//
|
||||
|
||||
type XfrmUsersaInfo struct {
|
||||
Sel XfrmSelector
|
||||
Id XfrmId
|
||||
Saddr XfrmAddress
|
||||
Lft XfrmLifetimeCfg
|
||||
Curlft XfrmLifetimeCur
|
||||
Stats XfrmStats
|
||||
Seq uint32
|
||||
Reqid uint32
|
||||
Family uint16
|
||||
Mode uint8
|
||||
ReplayWindow uint8
|
||||
Flags uint8
|
||||
Pad [7]byte
|
||||
}
|
||||
|
||||
func (msg *XfrmUsersaInfo) Len() int {
|
||||
return SizeofXfrmUsersaInfo
|
||||
}
|
||||
|
||||
func DeserializeXfrmUsersaInfo(b []byte) *XfrmUsersaInfo {
|
||||
return (*XfrmUsersaInfo)(unsafe.Pointer(&b[0:SizeofXfrmUsersaInfo][0]))
|
||||
}
|
||||
|
||||
func (msg *XfrmUsersaInfo) Serialize() []byte {
|
||||
return (*(*[SizeofXfrmUsersaInfo]byte)(unsafe.Pointer(msg)))[:]
|
||||
}
|
||||
|
||||
// struct xfrm_userspi_info {
|
||||
// struct xfrm_usersa_info info;
|
||||
// __u32 min;
|
||||
// __u32 max;
|
||||
// };
|
||||
|
||||
type XfrmUserSpiInfo struct {
|
||||
XfrmUsersaInfo XfrmUsersaInfo
|
||||
Min uint32
|
||||
Max uint32
|
||||
}
|
||||
|
||||
func (msg *XfrmUserSpiInfo) Len() int {
|
||||
return SizeofXfrmUserSpiInfo
|
||||
}
|
||||
|
||||
func DeserializeXfrmUserSpiInfo(b []byte) *XfrmUserSpiInfo {
|
||||
return (*XfrmUserSpiInfo)(unsafe.Pointer(&b[0:SizeofXfrmUserSpiInfo][0]))
|
||||
}
|
||||
|
||||
func (msg *XfrmUserSpiInfo) Serialize() []byte {
|
||||
return (*(*[SizeofXfrmUserSpiInfo]byte)(unsafe.Pointer(msg)))[:]
|
||||
}
|
||||
|
||||
// struct xfrm_algo {
|
||||
// char alg_name[64];
|
||||
// unsigned int alg_key_len; /* in bits */
|
||||
// char alg_key[0];
|
||||
// };
|
||||
|
||||
type XfrmAlgo struct {
|
||||
AlgName [64]byte
|
||||
AlgKeyLen uint32
|
||||
AlgKey []byte
|
||||
}
|
||||
|
||||
func (msg *XfrmAlgo) Len() int {
|
||||
return SizeofXfrmAlgo + int(msg.AlgKeyLen/8)
|
||||
}
|
||||
|
||||
func DeserializeXfrmAlgo(b []byte) *XfrmAlgo {
|
||||
ret := XfrmAlgo{}
|
||||
copy(ret.AlgName[:], b[0:64])
|
||||
ret.AlgKeyLen = *(*uint32)(unsafe.Pointer(&b[64]))
|
||||
ret.AlgKey = b[68:ret.Len()]
|
||||
return &ret
|
||||
}
|
||||
|
||||
func (msg *XfrmAlgo) Serialize() []byte {
|
||||
b := make([]byte, msg.Len())
|
||||
copy(b[0:64], msg.AlgName[:])
|
||||
copy(b[64:68], (*(*[4]byte)(unsafe.Pointer(&msg.AlgKeyLen)))[:])
|
||||
copy(b[68:msg.Len()], msg.AlgKey[:])
|
||||
return b
|
||||
}
|
||||
|
||||
// struct xfrm_algo_auth {
|
||||
// char alg_name[64];
|
||||
// unsigned int alg_key_len; /* in bits */
|
||||
// unsigned int alg_trunc_len; /* in bits */
|
||||
// char alg_key[0];
|
||||
// };
|
||||
|
||||
type XfrmAlgoAuth struct {
|
||||
AlgName [64]byte
|
||||
AlgKeyLen uint32
|
||||
AlgTruncLen uint32
|
||||
AlgKey []byte
|
||||
}
|
||||
|
||||
func (msg *XfrmAlgoAuth) Len() int {
|
||||
return SizeofXfrmAlgoAuth + int(msg.AlgKeyLen/8)
|
||||
}
|
||||
|
||||
func DeserializeXfrmAlgoAuth(b []byte) *XfrmAlgoAuth {
|
||||
ret := XfrmAlgoAuth{}
|
||||
copy(ret.AlgName[:], b[0:64])
|
||||
ret.AlgKeyLen = *(*uint32)(unsafe.Pointer(&b[64]))
|
||||
ret.AlgTruncLen = *(*uint32)(unsafe.Pointer(&b[68]))
|
||||
ret.AlgKey = b[72:ret.Len()]
|
||||
return &ret
|
||||
}
|
||||
|
||||
func (msg *XfrmAlgoAuth) Serialize() []byte {
|
||||
b := make([]byte, msg.Len())
|
||||
copy(b[0:64], msg.AlgName[:])
|
||||
copy(b[64:68], (*(*[4]byte)(unsafe.Pointer(&msg.AlgKeyLen)))[:])
|
||||
copy(b[68:72], (*(*[4]byte)(unsafe.Pointer(&msg.AlgTruncLen)))[:])
|
||||
copy(b[72:msg.Len()], msg.AlgKey[:])
|
||||
return b
|
||||
}
|
||||
|
||||
// struct xfrm_algo_aead {
|
||||
// char alg_name[64];
|
||||
// unsigned int alg_key_len; /* in bits */
|
||||
// unsigned int alg_icv_len; /* in bits */
|
||||
// char alg_key[0];
|
||||
// }
|
||||
|
||||
type XfrmAlgoAEAD struct {
|
||||
AlgName [64]byte
|
||||
AlgKeyLen uint32
|
||||
AlgICVLen uint32
|
||||
AlgKey []byte
|
||||
}
|
||||
|
||||
func (msg *XfrmAlgoAEAD) Len() int {
|
||||
return SizeofXfrmAlgoAEAD + int(msg.AlgKeyLen/8)
|
||||
}
|
||||
|
||||
func DeserializeXfrmAlgoAEAD(b []byte) *XfrmAlgoAEAD {
|
||||
ret := XfrmAlgoAEAD{}
|
||||
copy(ret.AlgName[:], b[0:64])
|
||||
ret.AlgKeyLen = *(*uint32)(unsafe.Pointer(&b[64]))
|
||||
ret.AlgICVLen = *(*uint32)(unsafe.Pointer(&b[68]))
|
||||
ret.AlgKey = b[72:ret.Len()]
|
||||
return &ret
|
||||
}
|
||||
|
||||
func (msg *XfrmAlgoAEAD) Serialize() []byte {
|
||||
b := make([]byte, msg.Len())
|
||||
copy(b[0:64], msg.AlgName[:])
|
||||
copy(b[64:68], (*(*[4]byte)(unsafe.Pointer(&msg.AlgKeyLen)))[:])
|
||||
copy(b[68:72], (*(*[4]byte)(unsafe.Pointer(&msg.AlgICVLen)))[:])
|
||||
copy(b[72:msg.Len()], msg.AlgKey[:])
|
||||
return b
|
||||
}
|
||||
|
||||
// struct xfrm_encap_tmpl {
|
||||
// __u16 encap_type;
|
||||
// __be16 encap_sport;
|
||||
// __be16 encap_dport;
|
||||
// xfrm_address_t encap_oa;
|
||||
// };
|
||||
|
||||
type XfrmEncapTmpl struct {
|
||||
EncapType uint16
|
||||
EncapSport uint16 // big endian
|
||||
EncapDport uint16 // big endian
|
||||
Pad [2]byte
|
||||
EncapOa XfrmAddress
|
||||
}
|
||||
|
||||
func (msg *XfrmEncapTmpl) Len() int {
|
||||
return SizeofXfrmEncapTmpl
|
||||
}
|
||||
|
||||
func DeserializeXfrmEncapTmpl(b []byte) *XfrmEncapTmpl {
|
||||
return (*XfrmEncapTmpl)(unsafe.Pointer(&b[0:SizeofXfrmEncapTmpl][0]))
|
||||
}
|
||||
|
||||
func (msg *XfrmEncapTmpl) Serialize() []byte {
|
||||
return (*(*[SizeofXfrmEncapTmpl]byte)(unsafe.Pointer(msg)))[:]
|
||||
}
|
||||
|
||||
// struct xfrm_usersa_flush {
|
||||
// __u8 proto;
|
||||
// };
|
||||
|
||||
type XfrmUsersaFlush struct {
|
||||
Proto uint8
|
||||
}
|
||||
|
||||
func (msg *XfrmUsersaFlush) Len() int {
|
||||
return SizeofXfrmUsersaFlush
|
||||
}
|
||||
|
||||
func DeserializeXfrmUsersaFlush(b []byte) *XfrmUsersaFlush {
|
||||
return (*XfrmUsersaFlush)(unsafe.Pointer(&b[0:SizeofXfrmUsersaFlush][0]))
|
||||
}
|
||||
|
||||
func (msg *XfrmUsersaFlush) Serialize() []byte {
|
||||
return (*(*[SizeofXfrmUsersaFlush]byte)(unsafe.Pointer(msg)))[:]
|
||||
}
|
||||
|
||||
// struct xfrm_replay_state_esn {
|
||||
// unsigned int bmp_len;
|
||||
// __u32 oseq;
|
||||
// __u32 seq;
|
||||
// __u32 oseq_hi;
|
||||
// __u32 seq_hi;
|
||||
// __u32 replay_window;
|
||||
// __u32 bmp[0];
|
||||
// };
|
||||
|
||||
type XfrmReplayStateEsn struct {
|
||||
BmpLen uint32
|
||||
OSeq uint32
|
||||
Seq uint32
|
||||
OSeqHi uint32
|
||||
SeqHi uint32
|
||||
ReplayWindow uint32
|
||||
Bmp []uint32
|
||||
}
|
||||
|
||||
func (msg *XfrmReplayStateEsn) Serialize() []byte {
|
||||
// We deliberately do not pass Bmp, as it gets set by the kernel.
|
||||
return (*(*[SizeofXfrmReplayStateEsn]byte)(unsafe.Pointer(msg)))[:]
|
||||
}
|
2
vendor/github.com/tailscale/netlink/order.go
generated
vendored
2
vendor/github.com/tailscale/netlink/order.go
generated
vendored
@@ -3,7 +3,7 @@ package netlink
|
||||
import (
|
||||
"encoding/binary"
|
||||
|
||||
"github.com/vishvananda/netlink/nl"
|
||||
"github.com/tailscale/netlink/nl"
|
||||
)
|
||||
|
||||
var (
|
||||
|
2
vendor/github.com/tailscale/netlink/protinfo_linux.go
generated
vendored
2
vendor/github.com/tailscale/netlink/protinfo_linux.go
generated
vendored
@@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
"syscall"
|
||||
|
||||
"github.com/vishvananda/netlink/nl"
|
||||
"github.com/tailscale/netlink/nl"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
|
2
vendor/github.com/tailscale/netlink/qdisc_linux.go
generated
vendored
2
vendor/github.com/tailscale/netlink/qdisc_linux.go
generated
vendored
@@ -7,7 +7,7 @@ import (
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"github.com/vishvananda/netlink/nl"
|
||||
"github.com/tailscale/netlink/nl"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
|
3
vendor/github.com/tailscale/netlink/rdma_link_linux.go
generated
vendored
3
vendor/github.com/tailscale/netlink/rdma_link_linux.go
generated
vendored
@@ -6,7 +6,7 @@ import (
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
"github.com/vishvananda/netlink/nl"
|
||||
"github.com/tailscale/netlink/nl"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
@@ -307,6 +307,7 @@ func (h *Handle) RdmaLinkDel(name string) error {
|
||||
|
||||
// RdmaLinkAdd adds an rdma link for the specified type to the network device.
|
||||
// Similar to: rdma link add NAME type TYPE netdev NETDEV
|
||||
//
|
||||
// NAME - specifies the new name of the rdma link to add
|
||||
// TYPE - specifies which rdma type to use. Link types:
|
||||
// rxe - Soft RoCE driver
|
||||
|
2
vendor/github.com/tailscale/netlink/route_linux.go
generated
vendored
2
vendor/github.com/tailscale/netlink/route_linux.go
generated
vendored
@@ -9,7 +9,7 @@ import (
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"github.com/vishvananda/netlink/nl"
|
||||
"github.com/tailscale/netlink/nl"
|
||||
"github.com/vishvananda/netns"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
2
vendor/github.com/tailscale/netlink/rule_linux.go
generated
vendored
2
vendor/github.com/tailscale/netlink/rule_linux.go
generated
vendored
@@ -5,7 +5,7 @@ import (
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
"github.com/vishvananda/netlink/nl"
|
||||
"github.com/tailscale/netlink/nl"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
|
2
vendor/github.com/tailscale/netlink/socket_linux.go
generated
vendored
2
vendor/github.com/tailscale/netlink/socket_linux.go
generated
vendored
@@ -6,7 +6,7 @@ import (
|
||||
"net"
|
||||
"syscall"
|
||||
|
||||
"github.com/vishvananda/netlink/nl"
|
||||
"github.com/tailscale/netlink/nl"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
|
2
vendor/github.com/tailscale/netlink/xfrm_monitor_linux.go
generated
vendored
2
vendor/github.com/tailscale/netlink/xfrm_monitor_linux.go
generated
vendored
@@ -3,7 +3,7 @@ package netlink
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/vishvananda/netlink/nl"
|
||||
"github.com/tailscale/netlink/nl"
|
||||
"github.com/vishvananda/netns"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
2
vendor/github.com/tailscale/netlink/xfrm_policy_linux.go
generated
vendored
2
vendor/github.com/tailscale/netlink/xfrm_policy_linux.go
generated
vendored
@@ -1,7 +1,7 @@
|
||||
package netlink
|
||||
|
||||
import (
|
||||
"github.com/vishvananda/netlink/nl"
|
||||
"github.com/tailscale/netlink/nl"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
|
2
vendor/github.com/tailscale/netlink/xfrm_state_linux.go
generated
vendored
2
vendor/github.com/tailscale/netlink/xfrm_state_linux.go
generated
vendored
@@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
"unsafe"
|
||||
|
||||
"github.com/vishvananda/netlink/nl"
|
||||
"github.com/tailscale/netlink/nl"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user