update netlink dependencies
Signed-off-by: Antonio Ojea <aojea@redhat.com>
This commit is contained in:
parent
8aad9739d8
commit
c41c78b600
5
go.mod
5
go.mod
@ -23,11 +23,10 @@ require (
|
|||||||
github.com/safchain/ethtool v0.0.0-20190326074333-42ed695e3de8
|
github.com/safchain/ethtool v0.0.0-20190326074333-42ed695e3de8
|
||||||
github.com/sirupsen/logrus v1.0.6 // indirect
|
github.com/sirupsen/logrus v1.0.6 // indirect
|
||||||
github.com/stretchr/testify v1.3.0 // indirect
|
github.com/stretchr/testify v1.3.0 // indirect
|
||||||
github.com/vishvananda/netlink v1.1.0
|
github.com/vishvananda/netlink v1.1.1-0.20201029203352-d40f9887b852
|
||||||
github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae // indirect
|
|
||||||
golang.org/x/crypto v0.0.0-20181009213950-7c1a557ab941 // indirect
|
golang.org/x/crypto v0.0.0-20181009213950-7c1a557ab941 // indirect
|
||||||
golang.org/x/net v0.0.0-20181011144130-49bb7cea24b1 // indirect
|
golang.org/x/net v0.0.0-20181011144130-49bb7cea24b1 // indirect
|
||||||
golang.org/x/sys v0.0.0-20200831180312-196b9ba8737a
|
golang.org/x/sys v0.0.0-20201117170446-d9b008d0a637
|
||||||
gopkg.in/airbrake/gobrake.v2 v2.0.9 // indirect
|
gopkg.in/airbrake/gobrake.v2 v2.0.9 // indirect
|
||||||
gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 // indirect
|
gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 // indirect
|
||||||
)
|
)
|
||||||
|
18
go.sum
18
go.sum
@ -43,26 +43,18 @@ github.com/sirupsen/logrus v1.0.6/go.mod h1:pMByvHTf9Beacp5x1UXfOR9xyW/9antXMhjM
|
|||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
|
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
|
||||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
github.com/vishvananda/netlink v0.0.0-20181108222139-023a6dafdcdf h1:3J37+NPjNyGW/dbfXtj3yWuF9OEepIdGOXRaJGbORV8=
|
github.com/vishvananda/netlink v1.1.1-0.20201029203352-d40f9887b852 h1:cPXZWzzG0NllBLdjWoD1nDfaqu98YMv+OneaKc8sPOA=
|
||||||
github.com/vishvananda/netlink v0.0.0-20181108222139-023a6dafdcdf/go.mod h1:+SR5DhBJrl6ZM7CoCKvpw5BKroDKQ+PJqOg65H/2ktk=
|
github.com/vishvananda/netlink v1.1.1-0.20201029203352-d40f9887b852/go.mod h1:twkDnbuQxJYemMlGd4JFIcuhgX83tXhKS2B/PRMpOho=
|
||||||
github.com/vishvananda/netlink v1.1.0 h1:1iyaYNBLmP6L0220aDnYQpo1QEV4t4hJ+xEEhhJH8j0=
|
|
||||||
github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE=
|
|
||||||
github.com/vishvananda/netns v0.0.0-20180720170159-13995c7128cc h1:R83G5ikgLMxrBvLh22JhdfI8K6YXEPHx5P03Uu3DRs4=
|
|
||||||
github.com/vishvananda/netns v0.0.0-20180720170159-13995c7128cc/go.mod h1:ZjcWmFBXmLKZu9Nxj3WKYEafiSqer2rnvPr0en9UNpI=
|
|
||||||
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df h1:OviZH7qLw/7ZovXvuNyL3XQl8UFofeikI1NW1Gypu7k=
|
|
||||||
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU=
|
|
||||||
github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae h1:4hwBBUfQCFe3Cym0ZtKyq7L16eZUtYKs+BaHDN6mAns=
|
github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae h1:4hwBBUfQCFe3Cym0ZtKyq7L16eZUtYKs+BaHDN6mAns=
|
||||||
github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=
|
github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=
|
||||||
golang.org/x/crypto v0.0.0-20181009213950-7c1a557ab941 h1:qBTHLajHecfu+xzRI9PqVDcqx7SdHj9d4B+EzSn3tAc=
|
golang.org/x/crypto v0.0.0-20181009213950-7c1a557ab941 h1:qBTHLajHecfu+xzRI9PqVDcqx7SdHj9d4B+EzSn3tAc=
|
||||||
golang.org/x/crypto v0.0.0-20181009213950-7c1a557ab941/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
golang.org/x/crypto v0.0.0-20181009213950-7c1a557ab941/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||||
golang.org/x/net v0.0.0-20181011144130-49bb7cea24b1 h1:Y/KGZSOdz/2r0WJ9Mkmz6NJBusp0kiNx1Cn82lzJQ6w=
|
golang.org/x/net v0.0.0-20181011144130-49bb7cea24b1 h1:Y/KGZSOdz/2r0WJ9Mkmz6NJBusp0kiNx1Cn82lzJQ6w=
|
||||||
golang.org/x/net v0.0.0-20181011144130-49bb7cea24b1/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20181011144130-49bb7cea24b1/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f h1:25KHgbfyiSm6vwQLbM3zZIe1v9p/3ea4Rz+nnM5K/i4=
|
|
||||||
golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20200217220822-9197077df867/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200217220822-9197077df867/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200831180312-196b9ba8737a h1:i47hUS795cOydZI4AwJQCKXOr4BvxzvikwDoDtHhP2Y=
|
golang.org/x/sys v0.0.0-20200728102440-3e129f6d46b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200831180312-196b9ba8737a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201117170446-d9b008d0a637 h1:O5hKNaGxIT4A8OTMnuh6UpmBdI3SAPxlZ3g0olDrJVM=
|
||||||
|
golang.org/x/sys v0.0.0-20201117170446-d9b008d0a637/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
gopkg.in/airbrake/gobrake.v2 v2.0.9 h1:7z2uVWwn7oVeeugY1DtlPAy5H+KYgB1KeKTnqjNatLo=
|
gopkg.in/airbrake/gobrake.v2 v2.0.9 h1:7z2uVWwn7oVeeugY1DtlPAy5H+KYgB1KeKTnqjNatLo=
|
||||||
gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U=
|
gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U=
|
||||||
gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 h1:OAj3g0cR6Dx/R07QgQe8wkA9RNjB2u4i700xBkIT4e0=
|
gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 h1:OAj3g0cR6Dx/R07QgQe8wkA9RNjB2u4i700xBkIT4e0=
|
||||||
|
1
vendor/github.com/containernetworking/cni/pkg/skel/skel.go
generated
vendored
1
vendor/github.com/containernetworking/cni/pkg/skel/skel.go
generated
vendored
@ -200,6 +200,7 @@ func (t *dispatcher) pluginMain(cmdAdd, cmdCheck, cmdDel func(_ *CmdArgs) error,
|
|||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if cmd != "VERSION" {
|
if cmd != "VERSION" {
|
||||||
if err = validateConfig(cmdArgs.StdinData); err != nil {
|
if err = validateConfig(cmdArgs.StdinData); err != nil {
|
||||||
return err
|
return err
|
||||||
|
7
vendor/github.com/vishvananda/netlink/.travis.yml
generated
vendored
7
vendor/github.com/vishvananda/netlink/.travis.yml
generated
vendored
@ -1,8 +1,8 @@
|
|||||||
language: go
|
language: go
|
||||||
go:
|
go:
|
||||||
- "1.10.x"
|
|
||||||
- "1.11.x"
|
|
||||||
- "1.12.x"
|
- "1.12.x"
|
||||||
|
- "1.13.x"
|
||||||
|
- "1.14.x"
|
||||||
before_script:
|
before_script:
|
||||||
# make sure we keep path in tact when we sudo
|
# make sure we keep path in tact when we sudo
|
||||||
- sudo sed -i -e 's/^Defaults\tsecure_path.*$//' /etc/sudoers
|
- sudo sed -i -e 's/^Defaults\tsecure_path.*$//' /etc/sudoers
|
||||||
@ -14,6 +14,7 @@ before_script:
|
|||||||
- sudo modprobe nf_conntrack_ipv4
|
- sudo modprobe nf_conntrack_ipv4
|
||||||
- sudo modprobe nf_conntrack_ipv6
|
- sudo modprobe nf_conntrack_ipv6
|
||||||
- sudo modprobe sch_hfsc
|
- sudo modprobe sch_hfsc
|
||||||
|
- sudo modprobe sch_sfq
|
||||||
install:
|
install:
|
||||||
- go get github.com/vishvananda/netns
|
- go get -v -t ./...
|
||||||
go_import_path: github.com/vishvananda/netlink
|
go_import_path: github.com/vishvananda/netlink
|
||||||
|
1
vendor/github.com/vishvananda/netlink/addr.go
generated
vendored
1
vendor/github.com/vishvananda/netlink/addr.go
generated
vendored
@ -17,6 +17,7 @@ type Addr struct {
|
|||||||
Broadcast net.IP
|
Broadcast net.IP
|
||||||
PreferedLft int
|
PreferedLft int
|
||||||
ValidLft int
|
ValidLft int
|
||||||
|
LinkIndex int
|
||||||
}
|
}
|
||||||
|
|
||||||
// String returns $ip/$netmask $label
|
// String returns $ip/$netmask $label
|
||||||
|
35
vendor/github.com/vishvananda/netlink/addr_linux.go
generated
vendored
35
vendor/github.com/vishvananda/netlink/addr_linux.go
generated
vendored
@ -11,9 +11,6 @@ import (
|
|||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
|
|
||||||
// IFA_FLAGS is a u32 attribute.
|
|
||||||
const IFA_FLAGS = 0x8
|
|
||||||
|
|
||||||
// AddrAdd will add an IP address to a link device.
|
// AddrAdd will add an IP address to a link device.
|
||||||
//
|
//
|
||||||
// Equivalent to: `ip addr add $addr dev $link`
|
// Equivalent to: `ip addr add $addr dev $link`
|
||||||
@ -125,7 +122,7 @@ func (h *Handle) addrHandle(link Link, addr *Addr, req *nl.NetlinkRequest) error
|
|||||||
} else {
|
} else {
|
||||||
b := make([]byte, 4)
|
b := make([]byte, 4)
|
||||||
native.PutUint32(b, uint32(addr.Flags))
|
native.PutUint32(b, uint32(addr.Flags))
|
||||||
flagsData := nl.NewRtAttr(IFA_FLAGS, b)
|
flagsData := nl.NewRtAttr(unix.IFA_FLAGS, b)
|
||||||
req.AddData(flagsData)
|
req.AddData(flagsData)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -156,10 +153,10 @@ func (h *Handle) addrHandle(link Link, addr *Addr, req *nl.NetlinkRequest) error
|
|||||||
// value should be "forever". To compensate for that, only add the attributes if at least one of the values is
|
// value should be "forever". To compensate for that, only add the attributes if at least one of the values is
|
||||||
// non-zero, which means the caller has explicitly set them
|
// non-zero, which means the caller has explicitly set them
|
||||||
if addr.ValidLft > 0 || addr.PreferedLft > 0 {
|
if addr.ValidLft > 0 || addr.PreferedLft > 0 {
|
||||||
cachedata := nl.IfaCacheInfo{
|
cachedata := nl.IfaCacheInfo{unix.IfaCacheinfo{
|
||||||
IfaValid: uint32(addr.ValidLft),
|
Valid: uint32(addr.ValidLft),
|
||||||
IfaPrefered: uint32(addr.PreferedLft),
|
Prefered: uint32(addr.PreferedLft),
|
||||||
}
|
}}
|
||||||
req.AddData(nl.NewRtAttr(unix.IFA_CACHEINFO, cachedata.Serialize()))
|
req.AddData(nl.NewRtAttr(unix.IFA_CACHEINFO, cachedata.Serialize()))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,12 +193,12 @@ func (h *Handle) AddrList(link Link, family int) ([]Addr, error) {
|
|||||||
|
|
||||||
var res []Addr
|
var res []Addr
|
||||||
for _, m := range msgs {
|
for _, m := range msgs {
|
||||||
addr, msgFamily, ifindex, err := parseAddr(m)
|
addr, msgFamily, err := parseAddr(m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if link != nil && ifindex != indexFilter {
|
if link != nil && addr.LinkIndex != indexFilter {
|
||||||
// Ignore messages from other interfaces
|
// Ignore messages from other interfaces
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -216,11 +213,11 @@ func (h *Handle) AddrList(link Link, family int) ([]Addr, error) {
|
|||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseAddr(m []byte) (addr Addr, family, index int, err error) {
|
func parseAddr(m []byte) (addr Addr, family int, err error) {
|
||||||
msg := nl.DeserializeIfAddrmsg(m)
|
msg := nl.DeserializeIfAddrmsg(m)
|
||||||
|
|
||||||
family = -1
|
family = -1
|
||||||
index = -1
|
addr.LinkIndex = -1
|
||||||
|
|
||||||
attrs, err1 := nl.ParseRouteAttr(m[msg.Len():])
|
attrs, err1 := nl.ParseRouteAttr(m[msg.Len():])
|
||||||
if err1 != nil {
|
if err1 != nil {
|
||||||
@ -229,7 +226,7 @@ func parseAddr(m []byte) (addr Addr, family, index int, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
family = int(msg.Family)
|
family = int(msg.Family)
|
||||||
index = int(msg.Index)
|
addr.LinkIndex = int(msg.Index)
|
||||||
|
|
||||||
var local, dst *net.IPNet
|
var local, dst *net.IPNet
|
||||||
for _, attr := range attrs {
|
for _, attr := range attrs {
|
||||||
@ -254,12 +251,12 @@ func parseAddr(m []byte) (addr Addr, family, index int, err error) {
|
|||||||
addr.Broadcast = attr.Value
|
addr.Broadcast = attr.Value
|
||||||
case unix.IFA_LABEL:
|
case unix.IFA_LABEL:
|
||||||
addr.Label = string(attr.Value[:len(attr.Value)-1])
|
addr.Label = string(attr.Value[:len(attr.Value)-1])
|
||||||
case IFA_FLAGS:
|
case unix.IFA_FLAGS:
|
||||||
addr.Flags = int(native.Uint32(attr.Value[0:4]))
|
addr.Flags = int(native.Uint32(attr.Value[0:4]))
|
||||||
case nl.IFA_CACHEINFO:
|
case unix.IFA_CACHEINFO:
|
||||||
ci := nl.DeserializeIfaCacheInfo(attr.Value)
|
ci := nl.DeserializeIfaCacheInfo(attr.Value)
|
||||||
addr.PreferedLft = int(ci.IfaPrefered)
|
addr.PreferedLft = int(ci.Prefered)
|
||||||
addr.ValidLft = int(ci.IfaValid)
|
addr.ValidLft = int(ci.Valid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -394,7 +391,7 @@ func addrSubscribeAt(newNs, curNs netns.NsHandle, ch chan<- AddrUpdate, done <-c
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
addr, _, ifindex, err := parseAddr(m.Data)
|
addr, _, err := parseAddr(m.Data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if cberr != nil {
|
if cberr != nil {
|
||||||
cberr(fmt.Errorf("could not parse address: %v", err))
|
cberr(fmt.Errorf("could not parse address: %v", err))
|
||||||
@ -403,7 +400,7 @@ func addrSubscribeAt(newNs, curNs netns.NsHandle, ch chan<- AddrUpdate, done <-c
|
|||||||
}
|
}
|
||||||
|
|
||||||
ch <- AddrUpdate{LinkAddress: *addr.IPNet,
|
ch <- AddrUpdate{LinkAddress: *addr.IPNet,
|
||||||
LinkIndex: ifindex,
|
LinkIndex: addr.LinkIndex,
|
||||||
NewAddr: msgType == unix.RTM_NEWADDR,
|
NewAddr: msgType == unix.RTM_NEWADDR,
|
||||||
Flags: addr.Flags,
|
Flags: addr.Flags,
|
||||||
Scope: addr.Scope,
|
Scope: addr.Scope,
|
||||||
|
56
vendor/github.com/vishvananda/netlink/class.go
generated
vendored
56
vendor/github.com/vishvananda/netlink/class.go
generated
vendored
@ -132,7 +132,10 @@ func (class *GenericClass) Type() string {
|
|||||||
return class.ClassType
|
return class.ClassType
|
||||||
}
|
}
|
||||||
|
|
||||||
// ServiceCurve is the way the HFSC curve are represented
|
// ServiceCurve is a nondecreasing function of some time unit, returning the amount of service
|
||||||
|
// (an allowed or allocated amount of bandwidth) at some specific point in time. The purpose of it
|
||||||
|
// should be subconsciously obvious: if a class was allowed to transfer not less than the amount
|
||||||
|
// specified by its service curve, then the service curve is not violated.
|
||||||
type ServiceCurve struct {
|
type ServiceCurve struct {
|
||||||
m1 uint32
|
m1 uint32
|
||||||
d uint32
|
d uint32
|
||||||
@ -144,6 +147,21 @@ func (c *ServiceCurve) Attrs() (uint32, uint32, uint32) {
|
|||||||
return c.m1, c.d, c.m2
|
return c.m1, c.d, c.m2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Burst returns the burst rate (m1) of the curve
|
||||||
|
func (c *ServiceCurve) Burst() uint32 {
|
||||||
|
return c.m1
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delay return the delay (d) of the curve
|
||||||
|
func (c *ServiceCurve) Delay() uint32 {
|
||||||
|
return c.d
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rate returns the rate (m2) of the curve
|
||||||
|
func (c *ServiceCurve) Rate() uint32 {
|
||||||
|
return c.m2
|
||||||
|
}
|
||||||
|
|
||||||
// HfscClass is a representation of the HFSC class
|
// HfscClass is a representation of the HFSC class
|
||||||
type HfscClass struct {
|
type HfscClass struct {
|
||||||
ClassAttrs
|
ClassAttrs
|
||||||
@ -152,35 +170,44 @@ type HfscClass struct {
|
|||||||
Usc ServiceCurve
|
Usc ServiceCurve
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetUsc sets the Usc curve
|
// SetUsc sets the USC curve. The bandwidth (m1 and m2) is specified in bits and the delay in
|
||||||
|
// seconds.
|
||||||
func (hfsc *HfscClass) SetUsc(m1 uint32, d uint32, m2 uint32) {
|
func (hfsc *HfscClass) SetUsc(m1 uint32, d uint32, m2 uint32) {
|
||||||
hfsc.Usc = ServiceCurve{m1: m1 / 8, d: d, m2: m2 / 8}
|
hfsc.Usc = ServiceCurve{m1: m1, d: d, m2: m2}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetFsc sets the Fsc curve
|
// SetFsc sets the Fsc curve. The bandwidth (m1 and m2) is specified in bits and the delay in
|
||||||
|
// seconds.
|
||||||
func (hfsc *HfscClass) SetFsc(m1 uint32, d uint32, m2 uint32) {
|
func (hfsc *HfscClass) SetFsc(m1 uint32, d uint32, m2 uint32) {
|
||||||
hfsc.Fsc = ServiceCurve{m1: m1 / 8, d: d, m2: m2 / 8}
|
hfsc.Fsc = ServiceCurve{m1: m1, d: d, m2: m2}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetRsc sets the Rsc curve
|
// SetRsc sets the Rsc curve. The bandwidth (m1 and m2) is specified in bits and the delay in
|
||||||
|
// seconds.
|
||||||
func (hfsc *HfscClass) SetRsc(m1 uint32, d uint32, m2 uint32) {
|
func (hfsc *HfscClass) SetRsc(m1 uint32, d uint32, m2 uint32) {
|
||||||
hfsc.Rsc = ServiceCurve{m1: m1 / 8, d: d, m2: m2 / 8}
|
hfsc.Rsc = ServiceCurve{m1: m1, d: d, m2: m2}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetSC implements the SC from the tc CLI
|
// SetSC implements the SC from the `tc` CLI. This function behaves the same as if one would set the
|
||||||
|
// USC through the `tc` command-line tool. This means bandwidth (m1 and m2) is specified in bits and
|
||||||
|
// the delay in ms.
|
||||||
func (hfsc *HfscClass) SetSC(m1 uint32, d uint32, m2 uint32) {
|
func (hfsc *HfscClass) SetSC(m1 uint32, d uint32, m2 uint32) {
|
||||||
hfsc.Rsc = ServiceCurve{m1: m1 / 8, d: d, m2: m2 / 8}
|
hfsc.SetRsc(m1, d, m2)
|
||||||
hfsc.Fsc = ServiceCurve{m1: m1 / 8, d: d, m2: m2 / 8}
|
hfsc.SetFsc(m1, d, m2)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetUL implements the UL from the tc CLI
|
// SetUL implements the UL from the `tc` CLI. This function behaves the same as if one would set the
|
||||||
|
// USC through the `tc` command-line tool. This means bandwidth (m1 and m2) is specified in bits and
|
||||||
|
// the delay in ms.
|
||||||
func (hfsc *HfscClass) SetUL(m1 uint32, d uint32, m2 uint32) {
|
func (hfsc *HfscClass) SetUL(m1 uint32, d uint32, m2 uint32) {
|
||||||
hfsc.Usc = ServiceCurve{m1: m1 / 8, d: d, m2: m2 / 8}
|
hfsc.SetUsc(m1, d, m2)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetLS implements the LS from the tc CLI
|
// SetLS implements the LS from the `tc` CLI. This function behaves the same as if one would set the
|
||||||
|
// USC through the `tc` command-line tool. This means bandwidth (m1 and m2) is specified in bits and
|
||||||
|
// the delay in ms.
|
||||||
func (hfsc *HfscClass) SetLS(m1 uint32, d uint32, m2 uint32) {
|
func (hfsc *HfscClass) SetLS(m1 uint32, d uint32, m2 uint32) {
|
||||||
hfsc.Fsc = ServiceCurve{m1: m1 / 8, d: d, m2: m2 / 8}
|
hfsc.SetFsc(m1, d, m2)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewHfscClass returns a new HFSC struct with the set parameters
|
// NewHfscClass returns a new HFSC struct with the set parameters
|
||||||
@ -193,6 +220,7 @@ func NewHfscClass(attrs ClassAttrs) *HfscClass {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// String() returns a string that contains the information and attributes of the HFSC class
|
||||||
func (hfsc *HfscClass) String() string {
|
func (hfsc *HfscClass) String() string {
|
||||||
return fmt.Sprintf(
|
return fmt.Sprintf(
|
||||||
"{%s -- {RSC: {m1=%d d=%d m2=%d}} {FSC: {m1=%d d=%d m2=%d}} {USC: {m1=%d d=%d m2=%d}}}",
|
"{%s -- {RSC: {m1=%d d=%d m2=%d}} {FSC: {m1=%d d=%d m2=%d}} {USC: {m1=%d d=%d m2=%d}}}",
|
||||||
|
29
vendor/github.com/vishvananda/netlink/class_linux.go
generated
vendored
29
vendor/github.com/vishvananda/netlink/class_linux.go
generated
vendored
@ -43,12 +43,12 @@ func NewHtbClass(attrs ClassAttrs, cattrs HtbClassAttrs) *HtbClass {
|
|||||||
if buffer == 0 {
|
if buffer == 0 {
|
||||||
buffer = uint32(float64(rate)/Hz() + float64(mtu))
|
buffer = uint32(float64(rate)/Hz() + float64(mtu))
|
||||||
}
|
}
|
||||||
buffer = uint32(Xmittime(rate, buffer))
|
buffer = Xmittime(rate, buffer)
|
||||||
|
|
||||||
if cbuffer == 0 {
|
if cbuffer == 0 {
|
||||||
cbuffer = uint32(float64(ceil)/Hz() + float64(mtu))
|
cbuffer = uint32(float64(ceil)/Hz() + float64(mtu))
|
||||||
}
|
}
|
||||||
cbuffer = uint32(Xmittime(ceil, cbuffer))
|
cbuffer = Xmittime(ceil, cbuffer)
|
||||||
|
|
||||||
return &HtbClass{
|
return &HtbClass{
|
||||||
ClassAttrs: attrs,
|
ClassAttrs: attrs,
|
||||||
@ -56,9 +56,9 @@ func NewHtbClass(attrs ClassAttrs, cattrs HtbClassAttrs) *HtbClass {
|
|||||||
Ceil: ceil,
|
Ceil: ceil,
|
||||||
Buffer: buffer,
|
Buffer: buffer,
|
||||||
Cbuffer: cbuffer,
|
Cbuffer: cbuffer,
|
||||||
Quantum: 10,
|
|
||||||
Level: 0,
|
Level: 0,
|
||||||
Prio: 0,
|
Prio: cattrs.Prio,
|
||||||
|
Quantum: cattrs.Quantum,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,12 +179,15 @@ func classPayload(req *nl.NetlinkRequest, class Class) error {
|
|||||||
case "hfsc":
|
case "hfsc":
|
||||||
hfsc := class.(*HfscClass)
|
hfsc := class.(*HfscClass)
|
||||||
opt := nl.HfscCopt{}
|
opt := nl.HfscCopt{}
|
||||||
opt.Rsc.Set(hfsc.Rsc.Attrs())
|
rm1, rd, rm2 := hfsc.Rsc.Attrs()
|
||||||
opt.Fsc.Set(hfsc.Fsc.Attrs())
|
opt.Rsc.Set(rm1/8, rd, rm2/8)
|
||||||
opt.Usc.Set(hfsc.Usc.Attrs())
|
fm1, fd, fm2 := hfsc.Fsc.Attrs()
|
||||||
options.AddRtAttr(nl.TCA_HFSC_RSC, nl.SerializeHfscCurve(&opt.Rsc))
|
opt.Fsc.Set(fm1/8, fd, fm2/8)
|
||||||
options.AddRtAttr(nl.TCA_HFSC_FSC, nl.SerializeHfscCurve(&opt.Fsc))
|
um1, ud, um2 := hfsc.Usc.Attrs()
|
||||||
options.AddRtAttr(nl.TCA_HFSC_USC, nl.SerializeHfscCurve(&opt.Usc))
|
opt.Usc.Set(um1/8, ud, um2/8)
|
||||||
|
nl.NewRtAttrChild(options, nl.TCA_HFSC_RSC, nl.SerializeHfscCurve(&opt.Rsc))
|
||||||
|
nl.NewRtAttrChild(options, nl.TCA_HFSC_FSC, nl.SerializeHfscCurve(&opt.Fsc))
|
||||||
|
nl.NewRtAttrChild(options, nl.TCA_HFSC_USC, nl.SerializeHfscCurve(&opt.Usc))
|
||||||
}
|
}
|
||||||
req.AddData(options)
|
req.AddData(options)
|
||||||
return nil
|
return nil
|
||||||
@ -315,11 +318,11 @@ func parseHfscClassData(class Class, data []syscall.NetlinkRouteAttr) (bool, err
|
|||||||
m1, d, m2 := nl.DeserializeHfscCurve(datum.Value).Attrs()
|
m1, d, m2 := nl.DeserializeHfscCurve(datum.Value).Attrs()
|
||||||
switch datum.Attr.Type {
|
switch datum.Attr.Type {
|
||||||
case nl.TCA_HFSC_RSC:
|
case nl.TCA_HFSC_RSC:
|
||||||
hfsc.Rsc = ServiceCurve{m1: m1, d: d, m2: m2}
|
hfsc.Rsc = ServiceCurve{m1: m1 * 8, d: d, m2: m2 * 8}
|
||||||
case nl.TCA_HFSC_FSC:
|
case nl.TCA_HFSC_FSC:
|
||||||
hfsc.Fsc = ServiceCurve{m1: m1, d: d, m2: m2}
|
hfsc.Fsc = ServiceCurve{m1: m1 * 8, d: d, m2: m2 * 8}
|
||||||
case nl.TCA_HFSC_USC:
|
case nl.TCA_HFSC_USC:
|
||||||
hfsc.Usc = ServiceCurve{m1: m1, d: d, m2: m2}
|
hfsc.Usc = ServiceCurve{m1: m1 * 8, d: d, m2: m2 * 8}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return detailed, nil
|
return detailed, nil
|
||||||
|
64
vendor/github.com/vishvananda/netlink/conntrack_linux.go
generated
vendored
64
vendor/github.com/vishvananda/netlink/conntrack_linux.go
generated
vendored
@ -318,6 +318,11 @@ func parseRawData(data []byte) *ConntrackFlow {
|
|||||||
// --mask-src ip Source mask address
|
// --mask-src ip Source mask address
|
||||||
// --mask-dst ip Destination mask address
|
// --mask-dst ip Destination mask address
|
||||||
|
|
||||||
|
// Layer 4 Protocol common parameters and options:
|
||||||
|
// TCP, UDP, SCTP, UDPLite and DCCP
|
||||||
|
// --sport, --orig-port-src port Source port in original direction
|
||||||
|
// --dport, --orig-port-dst port Destination port in original direction
|
||||||
|
|
||||||
// Filter types
|
// Filter types
|
||||||
type ConntrackFilterType uint8
|
type ConntrackFilterType uint8
|
||||||
|
|
||||||
@ -327,9 +332,11 @@ const (
|
|||||||
ConntrackReplySrcIP // --reply-src ip Reply Source IP
|
ConntrackReplySrcIP // --reply-src ip Reply Source IP
|
||||||
ConntrackReplyDstIP // --reply-dst ip Reply Destination IP
|
ConntrackReplyDstIP // --reply-dst ip Reply Destination IP
|
||||||
ConntrackReplyAnyIP // Match source or destination reply IP
|
ConntrackReplyAnyIP // Match source or destination reply IP
|
||||||
|
ConntrackOrigSrcPort // --orig-port-src port Source port in original direction
|
||||||
|
ConntrackOrigDstPort // --orig-port-dst port Destination port in original direction
|
||||||
ConntrackNatSrcIP = ConntrackReplySrcIP // deprecated use instead ConntrackReplySrcIP
|
ConntrackNatSrcIP = ConntrackReplySrcIP // deprecated use instead ConntrackReplySrcIP
|
||||||
ConntrackNatDstIP = ConntrackReplyDstIP // deprecated use instead ConntrackReplyDstIP
|
ConntrackNatDstIP = ConntrackReplyDstIP // deprecated use instead ConntrackReplyDstIP
|
||||||
ConntrackNatAnyIP = ConntrackReplyAnyIP // deprecated use instaed ConntrackReplyAnyIP
|
ConntrackNatAnyIP = ConntrackReplyAnyIP // deprecated use instead ConntrackReplyAnyIP
|
||||||
)
|
)
|
||||||
|
|
||||||
type CustomConntrackFilter interface {
|
type CustomConntrackFilter interface {
|
||||||
@ -340,6 +347,8 @@ type CustomConntrackFilter interface {
|
|||||||
|
|
||||||
type ConntrackFilter struct {
|
type ConntrackFilter struct {
|
||||||
ipFilter map[ConntrackFilterType]net.IP
|
ipFilter map[ConntrackFilterType]net.IP
|
||||||
|
portFilter map[ConntrackFilterType]uint16
|
||||||
|
protoFilter uint8
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddIP adds an IP to the conntrack filter
|
// AddIP adds an IP to the conntrack filter
|
||||||
@ -354,15 +363,52 @@ func (f *ConntrackFilter) AddIP(tp ConntrackFilterType, ip net.IP) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AddPort adds a Port to the conntrack filter if the Layer 4 protocol allows it
|
||||||
|
func (f *ConntrackFilter) AddPort(tp ConntrackFilterType, port uint16) error {
|
||||||
|
switch f.protoFilter {
|
||||||
|
// TCP, UDP, DCCP, SCTP, UDPLite
|
||||||
|
case 6, 17, 33, 132, 136:
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("Filter attribute not available without a valid Layer 4 protocol: %d", f.protoFilter)
|
||||||
|
}
|
||||||
|
|
||||||
|
if f.portFilter == nil {
|
||||||
|
f.portFilter = make(map[ConntrackFilterType]uint16)
|
||||||
|
}
|
||||||
|
if _, ok := f.portFilter[tp]; ok {
|
||||||
|
return errors.New("Filter attribute already present")
|
||||||
|
}
|
||||||
|
f.portFilter[tp] = port
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddProtocol adds the Layer 4 protocol to the conntrack filter
|
||||||
|
func (f *ConntrackFilter) AddProtocol(proto uint8) error {
|
||||||
|
if f.protoFilter != 0 {
|
||||||
|
return errors.New("Filter attribute already present")
|
||||||
|
}
|
||||||
|
f.protoFilter = proto
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// MatchConntrackFlow applies the filter to the flow and returns true if the flow matches the filter
|
// MatchConntrackFlow applies the filter to the flow and returns true if the flow matches the filter
|
||||||
// false otherwise
|
// false otherwise
|
||||||
func (f *ConntrackFilter) MatchConntrackFlow(flow *ConntrackFlow) bool {
|
func (f *ConntrackFilter) MatchConntrackFlow(flow *ConntrackFlow) bool {
|
||||||
if len(f.ipFilter) == 0 {
|
if len(f.ipFilter) == 0 && len(f.portFilter) == 0 && f.protoFilter == 0 {
|
||||||
// empty filter always not match
|
// empty filter always not match
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -p, --protonum proto Layer 4 Protocol, eg. 'tcp'
|
||||||
|
if f.protoFilter != 0 && flow.Forward.Protocol != f.protoFilter {
|
||||||
|
// different Layer 4 protocol always not match
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
match := true
|
match := true
|
||||||
|
|
||||||
|
// IP conntrack filter
|
||||||
|
if len(f.ipFilter) > 0 {
|
||||||
// -orig-src ip Source address from original direction
|
// -orig-src ip Source address from original direction
|
||||||
if elem, found := f.ipFilter[ConntrackOrigSrcIP]; found {
|
if elem, found := f.ipFilter[ConntrackOrigSrcIP]; found {
|
||||||
match = match && elem.Equal(flow.Forward.SrcIP)
|
match = match && elem.Equal(flow.Forward.SrcIP)
|
||||||
@ -387,6 +433,20 @@ func (f *ConntrackFilter) MatchConntrackFlow(flow *ConntrackFlow) bool {
|
|||||||
if elem, found := f.ipFilter[ConntrackReplyAnyIP]; match && found {
|
if elem, found := f.ipFilter[ConntrackReplyAnyIP]; match && found {
|
||||||
match = match && (elem.Equal(flow.Reverse.SrcIP) || elem.Equal(flow.Reverse.DstIP))
|
match = match && (elem.Equal(flow.Reverse.SrcIP) || elem.Equal(flow.Reverse.DstIP))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Layer 4 Port filter
|
||||||
|
if len(f.portFilter) > 0 {
|
||||||
|
// -orig-port-src port Source port from original direction
|
||||||
|
if elem, found := f.portFilter[ConntrackOrigSrcPort]; match && found {
|
||||||
|
match = match && elem == flow.Forward.SrcPort
|
||||||
|
}
|
||||||
|
|
||||||
|
// -orig-port-dst port Destination port from original direction
|
||||||
|
if elem, found := f.portFilter[ConntrackOrigDstPort]; match && found {
|
||||||
|
match = match && elem == flow.Forward.DstPort
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return match
|
return match
|
||||||
}
|
}
|
||||||
|
1
vendor/github.com/vishvananda/netlink/filter.go
generated
vendored
1
vendor/github.com/vishvananda/netlink/filter.go
generated
vendored
@ -217,6 +217,7 @@ type TunnelKeyAction struct {
|
|||||||
SrcAddr net.IP
|
SrcAddr net.IP
|
||||||
DstAddr net.IP
|
DstAddr net.IP
|
||||||
KeyID uint32
|
KeyID uint32
|
||||||
|
DestPort uint16
|
||||||
}
|
}
|
||||||
|
|
||||||
func (action *TunnelKeyAction) Type() string {
|
func (action *TunnelKeyAction) Type() string {
|
||||||
|
20
vendor/github.com/vishvananda/netlink/filter_linux.go
generated
vendored
20
vendor/github.com/vishvananda/netlink/filter_linux.go
generated
vendored
@ -6,7 +6,6 @@ import (
|
|||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/vishvananda/netlink/nl"
|
"github.com/vishvananda/netlink/nl"
|
||||||
@ -89,7 +88,7 @@ func NewFw(attrs FilterAttrs, fattrs FilterFwAttrs) (*Fw, error) {
|
|||||||
if CalcRtable(&police.Rate, rtab[:], rcellLog, fattrs.Mtu, linklayer) < 0 {
|
if CalcRtable(&police.Rate, rtab[:], rcellLog, fattrs.Mtu, linklayer) < 0 {
|
||||||
return nil, errors.New("TBF: failed to calculate rate table")
|
return nil, errors.New("TBF: failed to calculate rate table")
|
||||||
}
|
}
|
||||||
police.Burst = uint32(Xmittime(uint64(police.Rate.Rate), uint32(buffer)))
|
police.Burst = Xmittime(uint64(police.Rate.Rate), uint32(buffer))
|
||||||
}
|
}
|
||||||
police.Mtu = fattrs.Mtu
|
police.Mtu = fattrs.Mtu
|
||||||
if police.PeakRate.Rate != 0 {
|
if police.PeakRate.Rate != 0 {
|
||||||
@ -456,6 +455,9 @@ func EncodeActions(attr *nl.RtAttr, actions []Action) error {
|
|||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("invalid dst addr %s for tunnel_key action", action.DstAddr)
|
return fmt.Errorf("invalid dst addr %s for tunnel_key action", action.DstAddr)
|
||||||
}
|
}
|
||||||
|
if action.DestPort != 0 {
|
||||||
|
aopts.AddRtAttr(nl.TCA_TUNNEL_KEY_ENC_DST_PORT, htons(action.DestPort))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case *SkbEditAction:
|
case *SkbEditAction:
|
||||||
table := attr.AddRtAttr(tabIndex, nil)
|
table := attr.AddRtAttr(tabIndex, nil)
|
||||||
@ -566,12 +568,12 @@ func parseActions(tables []syscall.NetlinkRouteAttr) ([]Action, error) {
|
|||||||
action.(*TunnelKeyAction).Action = TunnelKeyAct(tun.Action)
|
action.(*TunnelKeyAction).Action = TunnelKeyAct(tun.Action)
|
||||||
case nl.TCA_TUNNEL_KEY_ENC_KEY_ID:
|
case nl.TCA_TUNNEL_KEY_ENC_KEY_ID:
|
||||||
action.(*TunnelKeyAction).KeyID = networkOrder.Uint32(adatum.Value[0:4])
|
action.(*TunnelKeyAction).KeyID = networkOrder.Uint32(adatum.Value[0:4])
|
||||||
case nl.TCA_TUNNEL_KEY_ENC_IPV6_SRC:
|
case nl.TCA_TUNNEL_KEY_ENC_IPV6_SRC, nl.TCA_TUNNEL_KEY_ENC_IPV4_SRC:
|
||||||
case nl.TCA_TUNNEL_KEY_ENC_IPV4_SRC:
|
action.(*TunnelKeyAction).SrcAddr = adatum.Value[:]
|
||||||
action.(*TunnelKeyAction).SrcAddr = net.IP(adatum.Value[:])
|
case nl.TCA_TUNNEL_KEY_ENC_IPV6_DST, nl.TCA_TUNNEL_KEY_ENC_IPV4_DST:
|
||||||
case nl.TCA_TUNNEL_KEY_ENC_IPV6_DST:
|
action.(*TunnelKeyAction).DstAddr = adatum.Value[:]
|
||||||
case nl.TCA_TUNNEL_KEY_ENC_IPV4_DST:
|
case nl.TCA_TUNNEL_KEY_ENC_DST_PORT:
|
||||||
action.(*TunnelKeyAction).DstAddr = net.IP(adatum.Value[:])
|
action.(*TunnelKeyAction).DestPort = ntohs(adatum.Value)
|
||||||
}
|
}
|
||||||
case "skbedit":
|
case "skbedit":
|
||||||
switch adatum.Attr.Type {
|
switch adatum.Attr.Type {
|
||||||
@ -783,7 +785,7 @@ func CalcRtable(rate *nl.TcRateSpec, rtab []uint32, cellLog int, mtu uint32, lin
|
|||||||
}
|
}
|
||||||
for i := 0; i < 256; i++ {
|
for i := 0; i < 256; i++ {
|
||||||
sz = AdjustSize(uint((i+1)<<uint32(cellLog)), uint(mpu), linklayer)
|
sz = AdjustSize(uint((i+1)<<uint32(cellLog)), uint(mpu), linklayer)
|
||||||
rtab[i] = uint32(Xmittime(uint64(bps), uint32(sz)))
|
rtab[i] = Xmittime(uint64(bps), uint32(sz))
|
||||||
}
|
}
|
||||||
rate.CellAlign = -1
|
rate.CellAlign = -1
|
||||||
rate.CellLog = uint8(cellLog)
|
rate.CellLog = uint8(cellLog)
|
||||||
|
4
vendor/github.com/vishvananda/netlink/go.mod
generated
vendored
4
vendor/github.com/vishvananda/netlink/go.mod
generated
vendored
@ -3,6 +3,6 @@ module github.com/vishvananda/netlink
|
|||||||
go 1.12
|
go 1.12
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df
|
github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae
|
||||||
golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444
|
golang.org/x/sys v0.0.0-20200728102440-3e129f6d46b1
|
||||||
)
|
)
|
||||||
|
10
vendor/github.com/vishvananda/netlink/go.sum
generated
vendored
10
vendor/github.com/vishvananda/netlink/go.sum
generated
vendored
@ -1,4 +1,6 @@
|
|||||||
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df h1:OviZH7qLw/7ZovXvuNyL3XQl8UFofeikI1NW1Gypu7k=
|
github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae h1:4hwBBUfQCFe3Cym0ZtKyq7L16eZUtYKs+BaHDN6mAns=
|
||||||
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU=
|
github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0=
|
||||||
golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444 h1:/d2cWp6PSamH4jDPFLyO150psQdqvtoNX8Zjg3AQ31g=
|
golang.org/x/sys v0.0.0-20200217220822-9197077df867 h1:JoRuNIf+rpHl+VhScRQQvzbHed86tKkqwPMV34T8myw=
|
||||||
golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200217220822-9197077df867/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20200728102440-3e129f6d46b1 h1:sIky/MyNRSHTrdxfsiUSS4WIAMvInbeXljJz+jDjeYE=
|
||||||
|
golang.org/x/sys v0.0.0-20200728102440-3e129f6d46b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
2
vendor/github.com/vishvananda/netlink/handle_unspecified.go
generated
vendored
2
vendor/github.com/vishvananda/netlink/handle_unspecified.go
generated
vendored
@ -85,7 +85,7 @@ func (h *Handle) LinkSetVfRate(link Link, vf, minRate, maxRate int) error {
|
|||||||
return ErrNotImplemented
|
return ErrNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *Handle) LinkSetMaster(link Link, master *Bridge) error {
|
func (h *Handle) LinkSetMaster(link Link, master Link) error {
|
||||||
return ErrNotImplemented
|
return ErrNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
|
30
vendor/github.com/vishvananda/netlink/inet_diag.go
generated
vendored
Normal file
30
vendor/github.com/vishvananda/netlink/inet_diag.go
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package netlink
|
||||||
|
|
||||||
|
// INET_DIAG constatns
|
||||||
|
const (
|
||||||
|
INET_DIAG_NONE = iota
|
||||||
|
INET_DIAG_MEMINFO
|
||||||
|
INET_DIAG_INFO
|
||||||
|
INET_DIAG_VEGASINFO
|
||||||
|
INET_DIAG_CONG
|
||||||
|
INET_DIAG_TOS
|
||||||
|
INET_DIAG_TCLASS
|
||||||
|
INET_DIAG_SKMEMINFO
|
||||||
|
INET_DIAG_SHUTDOWN
|
||||||
|
INET_DIAG_DCTCPINFO
|
||||||
|
INET_DIAG_PROTOCOL
|
||||||
|
INET_DIAG_SKV6ONLY
|
||||||
|
INET_DIAG_LOCALS
|
||||||
|
INET_DIAG_PEERS
|
||||||
|
INET_DIAG_PAD
|
||||||
|
INET_DIAG_MARK
|
||||||
|
INET_DIAG_BBRINFO
|
||||||
|
INET_DIAG_CLASS_ID
|
||||||
|
INET_DIAG_MD5SIG
|
||||||
|
INET_DIAG_MAX
|
||||||
|
)
|
||||||
|
|
||||||
|
type InetDiagTCPInfoResp struct {
|
||||||
|
InetDiagMsg *Socket
|
||||||
|
TCPInfo *TCPInfo
|
||||||
|
}
|
335
vendor/github.com/vishvananda/netlink/ipset_linux.go
generated
vendored
Normal file
335
vendor/github.com/vishvananda/netlink/ipset_linux.go
generated
vendored
Normal file
@ -0,0 +1,335 @@
|
|||||||
|
package netlink
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
"net"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
|
"github.com/vishvananda/netlink/nl"
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
|
)
|
||||||
|
|
||||||
|
// IPSetEntry is used for adding, updating, retreiving and deleting entries
|
||||||
|
type IPSetEntry struct {
|
||||||
|
Comment string
|
||||||
|
MAC net.HardwareAddr
|
||||||
|
IP net.IP
|
||||||
|
Timeout *uint32
|
||||||
|
Packets *uint64
|
||||||
|
Bytes *uint64
|
||||||
|
|
||||||
|
Replace bool // replace existing entry
|
||||||
|
}
|
||||||
|
|
||||||
|
// IPSetResult is the result of a dump request for a set
|
||||||
|
type IPSetResult struct {
|
||||||
|
Nfgenmsg *nl.Nfgenmsg
|
||||||
|
Protocol uint8
|
||||||
|
Revision uint8
|
||||||
|
Family uint8
|
||||||
|
Flags uint8
|
||||||
|
SetName string
|
||||||
|
TypeName string
|
||||||
|
|
||||||
|
HashSize uint32
|
||||||
|
NumEntries uint32
|
||||||
|
MaxElements uint32
|
||||||
|
References uint32
|
||||||
|
SizeInMemory uint32
|
||||||
|
CadtFlags uint32
|
||||||
|
Timeout *uint32
|
||||||
|
|
||||||
|
Entries []IPSetEntry
|
||||||
|
}
|
||||||
|
|
||||||
|
// IpsetCreateOptions is the options struct for creating a new ipset
|
||||||
|
type IpsetCreateOptions struct {
|
||||||
|
Replace bool // replace existing ipset
|
||||||
|
Timeout *uint32
|
||||||
|
Counters bool
|
||||||
|
Comments bool
|
||||||
|
Skbinfo bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// IpsetProtocol returns the ipset protocol version from the kernel
|
||||||
|
func IpsetProtocol() (uint8, error) {
|
||||||
|
return pkgHandle.IpsetProtocol()
|
||||||
|
}
|
||||||
|
|
||||||
|
// IpsetCreate creates a new ipset
|
||||||
|
func IpsetCreate(setname, typename string, options IpsetCreateOptions) error {
|
||||||
|
return pkgHandle.IpsetCreate(setname, typename, options)
|
||||||
|
}
|
||||||
|
|
||||||
|
// IpsetDestroy destroys an existing ipset
|
||||||
|
func IpsetDestroy(setname string) error {
|
||||||
|
return pkgHandle.IpsetDestroy(setname)
|
||||||
|
}
|
||||||
|
|
||||||
|
// IpsetFlush flushes an existing ipset
|
||||||
|
func IpsetFlush(setname string) error {
|
||||||
|
return pkgHandle.IpsetFlush(setname)
|
||||||
|
}
|
||||||
|
|
||||||
|
// IpsetList dumps an specific ipset.
|
||||||
|
func IpsetList(setname string) (*IPSetResult, error) {
|
||||||
|
return pkgHandle.IpsetList(setname)
|
||||||
|
}
|
||||||
|
|
||||||
|
// IpsetListAll dumps all ipsets.
|
||||||
|
func IpsetListAll() ([]IPSetResult, error) {
|
||||||
|
return pkgHandle.IpsetListAll()
|
||||||
|
}
|
||||||
|
|
||||||
|
// IpsetAdd adds an entry to an existing ipset.
|
||||||
|
func IpsetAdd(setname string, entry *IPSetEntry) error {
|
||||||
|
return pkgHandle.ipsetAddDel(nl.IPSET_CMD_ADD, setname, entry)
|
||||||
|
}
|
||||||
|
|
||||||
|
// IpsetDele deletes an entry from an existing ipset.
|
||||||
|
func IpsetDel(setname string, entry *IPSetEntry) error {
|
||||||
|
return pkgHandle.ipsetAddDel(nl.IPSET_CMD_DEL, setname, entry)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *Handle) IpsetProtocol() (uint8, error) {
|
||||||
|
req := h.newIpsetRequest(nl.IPSET_CMD_PROTOCOL)
|
||||||
|
msgs, err := req.Execute(unix.NETLINK_NETFILTER, 0)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return ipsetUnserialize(msgs).Protocol, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *Handle) IpsetCreate(setname, typename string, options IpsetCreateOptions) error {
|
||||||
|
req := h.newIpsetRequest(nl.IPSET_CMD_CREATE)
|
||||||
|
|
||||||
|
if !options.Replace {
|
||||||
|
req.Flags |= unix.NLM_F_EXCL
|
||||||
|
}
|
||||||
|
|
||||||
|
req.AddData(nl.NewRtAttr(nl.IPSET_ATTR_SETNAME, nl.ZeroTerminated(setname)))
|
||||||
|
req.AddData(nl.NewRtAttr(nl.IPSET_ATTR_TYPENAME, nl.ZeroTerminated(typename)))
|
||||||
|
req.AddData(nl.NewRtAttr(nl.IPSET_ATTR_REVISION, nl.Uint8Attr(0)))
|
||||||
|
req.AddData(nl.NewRtAttr(nl.IPSET_ATTR_FAMILY, nl.Uint8Attr(0)))
|
||||||
|
|
||||||
|
data := nl.NewRtAttr(nl.IPSET_ATTR_DATA|int(nl.NLA_F_NESTED), nil)
|
||||||
|
|
||||||
|
if timeout := options.Timeout; timeout != nil {
|
||||||
|
data.AddChild(&nl.Uint32Attribute{Type: nl.IPSET_ATTR_TIMEOUT | nl.NLA_F_NET_BYTEORDER, Value: *timeout})
|
||||||
|
}
|
||||||
|
|
||||||
|
var cadtFlags uint32
|
||||||
|
|
||||||
|
if options.Comments {
|
||||||
|
cadtFlags |= nl.IPSET_FLAG_WITH_COMMENT
|
||||||
|
}
|
||||||
|
if options.Counters {
|
||||||
|
cadtFlags |= nl.IPSET_FLAG_WITH_COUNTERS
|
||||||
|
}
|
||||||
|
if options.Skbinfo {
|
||||||
|
cadtFlags |= nl.IPSET_FLAG_WITH_SKBINFO
|
||||||
|
}
|
||||||
|
|
||||||
|
if cadtFlags != 0 {
|
||||||
|
data.AddChild(&nl.Uint32Attribute{Type: nl.IPSET_ATTR_CADT_FLAGS | nl.NLA_F_NET_BYTEORDER, Value: cadtFlags})
|
||||||
|
}
|
||||||
|
|
||||||
|
req.AddData(data)
|
||||||
|
_, err := ipsetExecute(req)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *Handle) IpsetDestroy(setname string) error {
|
||||||
|
req := h.newIpsetRequest(nl.IPSET_CMD_DESTROY)
|
||||||
|
req.AddData(nl.NewRtAttr(nl.IPSET_ATTR_SETNAME, nl.ZeroTerminated(setname)))
|
||||||
|
_, err := ipsetExecute(req)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *Handle) IpsetFlush(setname string) error {
|
||||||
|
req := h.newIpsetRequest(nl.IPSET_CMD_FLUSH)
|
||||||
|
req.AddData(nl.NewRtAttr(nl.IPSET_ATTR_SETNAME, nl.ZeroTerminated(setname)))
|
||||||
|
_, err := ipsetExecute(req)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *Handle) IpsetList(name string) (*IPSetResult, error) {
|
||||||
|
req := h.newIpsetRequest(nl.IPSET_CMD_LIST)
|
||||||
|
req.AddData(nl.NewRtAttr(nl.IPSET_ATTR_SETNAME, nl.ZeroTerminated(name)))
|
||||||
|
|
||||||
|
msgs, err := ipsetExecute(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result := ipsetUnserialize(msgs)
|
||||||
|
return &result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *Handle) IpsetListAll() ([]IPSetResult, error) {
|
||||||
|
req := h.newIpsetRequest(nl.IPSET_CMD_LIST)
|
||||||
|
|
||||||
|
msgs, err := ipsetExecute(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
result := make([]IPSetResult, len(msgs))
|
||||||
|
for i, msg := range msgs {
|
||||||
|
result[i].unserialize(msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *Handle) ipsetAddDel(nlCmd int, setname string, entry *IPSetEntry) error {
|
||||||
|
req := h.newIpsetRequest(nlCmd)
|
||||||
|
req.AddData(nl.NewRtAttr(nl.IPSET_ATTR_SETNAME, nl.ZeroTerminated(setname)))
|
||||||
|
data := nl.NewRtAttr(nl.IPSET_ATTR_DATA|int(nl.NLA_F_NESTED), nil)
|
||||||
|
|
||||||
|
if !entry.Replace {
|
||||||
|
req.Flags |= unix.NLM_F_EXCL
|
||||||
|
}
|
||||||
|
|
||||||
|
if entry.Timeout != nil {
|
||||||
|
data.AddChild(&nl.Uint32Attribute{Type: nl.IPSET_ATTR_TIMEOUT | nl.NLA_F_NET_BYTEORDER, Value: *entry.Timeout})
|
||||||
|
}
|
||||||
|
if entry.MAC != nil {
|
||||||
|
data.AddChild(nl.NewRtAttr(nl.IPSET_ATTR_ETHER, entry.MAC))
|
||||||
|
}
|
||||||
|
|
||||||
|
data.AddChild(&nl.Uint32Attribute{Type: nl.IPSET_ATTR_LINENO | nl.NLA_F_NET_BYTEORDER, Value: 0})
|
||||||
|
req.AddData(data)
|
||||||
|
|
||||||
|
_, err := ipsetExecute(req)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *Handle) newIpsetRequest(cmd int) *nl.NetlinkRequest {
|
||||||
|
req := h.newNetlinkRequest(cmd|(unix.NFNL_SUBSYS_IPSET<<8), nl.GetIpsetFlags(cmd))
|
||||||
|
|
||||||
|
// Add the netfilter header
|
||||||
|
msg := &nl.Nfgenmsg{
|
||||||
|
NfgenFamily: uint8(unix.AF_NETLINK),
|
||||||
|
Version: nl.NFNETLINK_V0,
|
||||||
|
ResId: 0,
|
||||||
|
}
|
||||||
|
req.AddData(msg)
|
||||||
|
req.AddData(nl.NewRtAttr(nl.IPSET_ATTR_PROTOCOL, nl.Uint8Attr(nl.IPSET_PROTOCOL)))
|
||||||
|
|
||||||
|
return req
|
||||||
|
}
|
||||||
|
|
||||||
|
func ipsetExecute(req *nl.NetlinkRequest) (msgs [][]byte, err error) {
|
||||||
|
msgs, err = req.Execute(unix.NETLINK_NETFILTER, 0)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
if errno := int(err.(syscall.Errno)); errno >= nl.IPSET_ERR_PRIVATE {
|
||||||
|
err = nl.IPSetError(uintptr(errno))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func ipsetUnserialize(msgs [][]byte) (result IPSetResult) {
|
||||||
|
for _, msg := range msgs {
|
||||||
|
result.unserialize(msg)
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
func (result *IPSetResult) unserialize(msg []byte) {
|
||||||
|
result.Nfgenmsg = nl.DeserializeNfgenmsg(msg)
|
||||||
|
|
||||||
|
for attr := range nl.ParseAttributes(msg[4:]) {
|
||||||
|
switch attr.Type {
|
||||||
|
case nl.IPSET_ATTR_PROTOCOL:
|
||||||
|
result.Protocol = attr.Value[0]
|
||||||
|
case nl.IPSET_ATTR_SETNAME:
|
||||||
|
result.SetName = nl.BytesToString(attr.Value)
|
||||||
|
case nl.IPSET_ATTR_TYPENAME:
|
||||||
|
result.TypeName = nl.BytesToString(attr.Value)
|
||||||
|
case nl.IPSET_ATTR_REVISION:
|
||||||
|
result.Revision = attr.Value[0]
|
||||||
|
case nl.IPSET_ATTR_FAMILY:
|
||||||
|
result.Family = attr.Value[0]
|
||||||
|
case nl.IPSET_ATTR_FLAGS:
|
||||||
|
result.Flags = attr.Value[0]
|
||||||
|
case nl.IPSET_ATTR_DATA | nl.NLA_F_NESTED:
|
||||||
|
result.parseAttrData(attr.Value)
|
||||||
|
case nl.IPSET_ATTR_ADT | nl.NLA_F_NESTED:
|
||||||
|
result.parseAttrADT(attr.Value)
|
||||||
|
default:
|
||||||
|
log.Printf("unknown ipset attribute from kernel: %+v %v", attr, attr.Type&nl.NLA_TYPE_MASK)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (result *IPSetResult) parseAttrData(data []byte) {
|
||||||
|
for attr := range nl.ParseAttributes(data) {
|
||||||
|
switch attr.Type {
|
||||||
|
case nl.IPSET_ATTR_HASHSIZE | nl.NLA_F_NET_BYTEORDER:
|
||||||
|
result.HashSize = attr.Uint32()
|
||||||
|
case nl.IPSET_ATTR_MAXELEM | nl.NLA_F_NET_BYTEORDER:
|
||||||
|
result.MaxElements = attr.Uint32()
|
||||||
|
case nl.IPSET_ATTR_TIMEOUT | nl.NLA_F_NET_BYTEORDER:
|
||||||
|
val := attr.Uint32()
|
||||||
|
result.Timeout = &val
|
||||||
|
case nl.IPSET_ATTR_ELEMENTS | nl.NLA_F_NET_BYTEORDER:
|
||||||
|
result.NumEntries = attr.Uint32()
|
||||||
|
case nl.IPSET_ATTR_REFERENCES | nl.NLA_F_NET_BYTEORDER:
|
||||||
|
result.References = attr.Uint32()
|
||||||
|
case nl.IPSET_ATTR_MEMSIZE | nl.NLA_F_NET_BYTEORDER:
|
||||||
|
result.SizeInMemory = attr.Uint32()
|
||||||
|
case nl.IPSET_ATTR_CADT_FLAGS | nl.NLA_F_NET_BYTEORDER:
|
||||||
|
result.CadtFlags = attr.Uint32()
|
||||||
|
default:
|
||||||
|
log.Printf("unknown ipset data attribute from kernel: %+v %v", attr, attr.Type&nl.NLA_TYPE_MASK)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (result *IPSetResult) parseAttrADT(data []byte) {
|
||||||
|
for attr := range nl.ParseAttributes(data) {
|
||||||
|
switch attr.Type {
|
||||||
|
case nl.IPSET_ATTR_DATA | nl.NLA_F_NESTED:
|
||||||
|
result.Entries = append(result.Entries, parseIPSetEntry(attr.Value))
|
||||||
|
default:
|
||||||
|
log.Printf("unknown ADT attribute from kernel: %+v %v", attr, attr.Type&nl.NLA_TYPE_MASK)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseIPSetEntry(data []byte) (entry IPSetEntry) {
|
||||||
|
for attr := range nl.ParseAttributes(data) {
|
||||||
|
switch attr.Type {
|
||||||
|
case nl.IPSET_ATTR_TIMEOUT | nl.NLA_F_NET_BYTEORDER:
|
||||||
|
val := attr.Uint32()
|
||||||
|
entry.Timeout = &val
|
||||||
|
case nl.IPSET_ATTR_BYTES | nl.NLA_F_NET_BYTEORDER:
|
||||||
|
val := attr.Uint64()
|
||||||
|
entry.Bytes = &val
|
||||||
|
case nl.IPSET_ATTR_PACKETS | nl.NLA_F_NET_BYTEORDER:
|
||||||
|
val := attr.Uint64()
|
||||||
|
entry.Packets = &val
|
||||||
|
case nl.IPSET_ATTR_ETHER:
|
||||||
|
entry.MAC = net.HardwareAddr(attr.Value)
|
||||||
|
case nl.IPSET_ATTR_COMMENT:
|
||||||
|
entry.Comment = nl.BytesToString(attr.Value)
|
||||||
|
case nl.IPSET_ATTR_IP | nl.NLA_F_NESTED:
|
||||||
|
for attr := range nl.ParseAttributes(attr.Value) {
|
||||||
|
switch attr.Type {
|
||||||
|
case nl.IPSET_ATTR_IP:
|
||||||
|
entry.IP = net.IP(attr.Value)
|
||||||
|
default:
|
||||||
|
log.Printf("unknown nested ADT attribute from kernel: %+v", attr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
log.Printf("unknown ADT attribute from kernel: %+v", attr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
40
vendor/github.com/vishvananda/netlink/link.go
generated
vendored
40
vendor/github.com/vishvananda/netlink/link.go
generated
vendored
@ -65,6 +65,17 @@ type VfInfo struct {
|
|||||||
LinkState uint32
|
LinkState uint32
|
||||||
MaxTxRate uint32 // IFLA_VF_RATE Max TxRate
|
MaxTxRate uint32 // IFLA_VF_RATE Max TxRate
|
||||||
MinTxRate uint32 // IFLA_VF_RATE Min TxRate
|
MinTxRate uint32 // IFLA_VF_RATE Min TxRate
|
||||||
|
RxPackets uint64
|
||||||
|
TxPackets uint64
|
||||||
|
RxBytes uint64
|
||||||
|
TxBytes uint64
|
||||||
|
Multicast uint64
|
||||||
|
Broadcast uint64
|
||||||
|
RxDropped uint64
|
||||||
|
TxDropped uint64
|
||||||
|
|
||||||
|
RssQuery uint32
|
||||||
|
Trust uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
// LinkOperState represents the values of the IFLA_OPERSTATE link
|
// LinkOperState represents the values of the IFLA_OPERSTATE link
|
||||||
@ -103,6 +114,7 @@ func (s LinkOperState) String() string {
|
|||||||
// NewLinkAttrs returns LinkAttrs structure filled with default values
|
// NewLinkAttrs returns LinkAttrs structure filled with default values
|
||||||
func NewLinkAttrs() LinkAttrs {
|
func NewLinkAttrs() LinkAttrs {
|
||||||
return LinkAttrs{
|
return LinkAttrs{
|
||||||
|
NetNsID: -1,
|
||||||
TxQLen: -1,
|
TxQLen: -1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -198,6 +210,7 @@ type LinkStatistics64 struct {
|
|||||||
type LinkXdp struct {
|
type LinkXdp struct {
|
||||||
Fd int
|
Fd int
|
||||||
Attached bool
|
Attached bool
|
||||||
|
AttachMode uint32
|
||||||
Flags uint32
|
Flags uint32
|
||||||
ProgId uint32
|
ProgId uint32
|
||||||
}
|
}
|
||||||
@ -246,6 +259,7 @@ func (ifb *Ifb) Type() string {
|
|||||||
type Bridge struct {
|
type Bridge struct {
|
||||||
LinkAttrs
|
LinkAttrs
|
||||||
MulticastSnooping *bool
|
MulticastSnooping *bool
|
||||||
|
AgeingTime *uint32
|
||||||
HelloTime *uint32
|
HelloTime *uint32
|
||||||
VlanFiltering *bool
|
VlanFiltering *bool
|
||||||
}
|
}
|
||||||
@ -338,6 +352,7 @@ type Veth struct {
|
|||||||
LinkAttrs
|
LinkAttrs
|
||||||
PeerName string // veth on create only
|
PeerName string // veth on create only
|
||||||
PeerHardwareAddr net.HardwareAddr
|
PeerHardwareAddr net.HardwareAddr
|
||||||
|
PeerNamespace interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (veth *Veth) Attrs() *LinkAttrs {
|
func (veth *Veth) Attrs() *LinkAttrs {
|
||||||
@ -348,6 +363,19 @@ func (veth *Veth) Type() string {
|
|||||||
return "veth"
|
return "veth"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Wireguard represent links of type "wireguard", see https://www.wireguard.com/
|
||||||
|
type Wireguard struct {
|
||||||
|
LinkAttrs
|
||||||
|
}
|
||||||
|
|
||||||
|
func (wg *Wireguard) Attrs() *LinkAttrs {
|
||||||
|
return &wg.LinkAttrs
|
||||||
|
}
|
||||||
|
|
||||||
|
func (wg *Wireguard) Type() string {
|
||||||
|
return "wireguard"
|
||||||
|
}
|
||||||
|
|
||||||
// GenericLink links represent types that are not currently understood
|
// GenericLink links represent types that are not currently understood
|
||||||
// by this netlink library.
|
// by this netlink library.
|
||||||
type GenericLink struct {
|
type GenericLink struct {
|
||||||
@ -878,10 +906,14 @@ type Ip6tnl struct {
|
|||||||
Remote net.IP
|
Remote net.IP
|
||||||
Ttl uint8
|
Ttl uint8
|
||||||
Tos uint8
|
Tos uint8
|
||||||
EncapLimit uint8
|
|
||||||
Flags uint32
|
Flags uint32
|
||||||
Proto uint8
|
Proto uint8
|
||||||
FlowInfo uint32
|
FlowInfo uint32
|
||||||
|
EncapLimit uint8
|
||||||
|
EncapType uint16
|
||||||
|
EncapFlags uint16
|
||||||
|
EncapSport uint16
|
||||||
|
EncapDport uint16
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ip6tnl *Ip6tnl) Attrs() *LinkAttrs {
|
func (ip6tnl *Ip6tnl) Attrs() *LinkAttrs {
|
||||||
@ -895,11 +927,13 @@ func (ip6tnl *Ip6tnl) Type() string {
|
|||||||
type Sittun struct {
|
type Sittun struct {
|
||||||
LinkAttrs
|
LinkAttrs
|
||||||
Link uint32
|
Link uint32
|
||||||
Local net.IP
|
|
||||||
Remote net.IP
|
|
||||||
Ttl uint8
|
Ttl uint8
|
||||||
Tos uint8
|
Tos uint8
|
||||||
PMtuDisc uint8
|
PMtuDisc uint8
|
||||||
|
Proto uint8
|
||||||
|
Local net.IP
|
||||||
|
Remote net.IP
|
||||||
|
EncapLimit uint8
|
||||||
EncapType uint16
|
EncapType uint16
|
||||||
EncapFlags uint16
|
EncapFlags uint16
|
||||||
EncapSport uint16
|
EncapSport uint16
|
||||||
|
198
vendor/github.com/vishvananda/netlink/link_linux.go
generated
vendored
198
vendor/github.com/vishvananda/netlink/link_linux.go
generated
vendored
@ -237,6 +237,37 @@ func (h *Handle) macvlanMACAddrChange(link Link, addrs []net.HardwareAddr, mode
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LinkSetMacvlanMode sets the mode of a macvlan or macvtap link device.
|
||||||
|
// Note that passthrough mode cannot be set to and from and will fail.
|
||||||
|
// Equivalent to: `ip link set $link type (macvlan|macvtap) mode $mode
|
||||||
|
func LinkSetMacvlanMode(link Link, mode MacvlanMode) error {
|
||||||
|
return pkgHandle.LinkSetMacvlanMode(link, mode)
|
||||||
|
}
|
||||||
|
|
||||||
|
// LinkSetMacvlanMode sets the mode of the macvlan or macvtap link device.
|
||||||
|
// Note that passthrough mode cannot be set to and from and will fail.
|
||||||
|
// Equivalent to: `ip link set $link type (macvlan|macvtap) mode $mode
|
||||||
|
func (h *Handle) LinkSetMacvlanMode(link Link, mode MacvlanMode) error {
|
||||||
|
base := link.Attrs()
|
||||||
|
h.ensureIndex(base)
|
||||||
|
req := h.newNetlinkRequest(unix.RTM_NEWLINK, unix.NLM_F_ACK)
|
||||||
|
|
||||||
|
msg := nl.NewIfInfomsg(unix.AF_UNSPEC)
|
||||||
|
msg.Index = int32(base.Index)
|
||||||
|
req.AddData(msg)
|
||||||
|
|
||||||
|
linkInfo := nl.NewRtAttr(unix.IFLA_LINKINFO, nil)
|
||||||
|
linkInfo.AddRtAttr(nl.IFLA_INFO_KIND, nl.NonZeroTerminated(link.Type()))
|
||||||
|
|
||||||
|
data := linkInfo.AddRtAttr(nl.IFLA_INFO_DATA, nil)
|
||||||
|
data.AddRtAttr(nl.IFLA_MACVLAN_MODE, nl.Uint32Attr(macvlanModes[mode]))
|
||||||
|
|
||||||
|
req.AddData(linkInfo)
|
||||||
|
|
||||||
|
_, err := req.Execute(unix.NETLINK_ROUTE, 0)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
func BridgeSetMcastSnoop(link Link, on bool) error {
|
func BridgeSetMcastSnoop(link Link, on bool) error {
|
||||||
return pkgHandle.BridgeSetMcastSnoop(link, on)
|
return pkgHandle.BridgeSetMcastSnoop(link, on)
|
||||||
}
|
}
|
||||||
@ -247,6 +278,16 @@ func (h *Handle) BridgeSetMcastSnoop(link Link, on bool) error {
|
|||||||
return h.linkModify(bridge, unix.NLM_F_ACK)
|
return h.linkModify(bridge, unix.NLM_F_ACK)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func BridgeSetVlanFiltering(link Link, on bool) error {
|
||||||
|
return pkgHandle.BridgeSetVlanFiltering(link, on)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *Handle) BridgeSetVlanFiltering(link Link, on bool) error {
|
||||||
|
bridge := link.(*Bridge)
|
||||||
|
bridge.VlanFiltering = &on
|
||||||
|
return h.linkModify(bridge, unix.NLM_F_ACK)
|
||||||
|
}
|
||||||
|
|
||||||
func SetPromiscOn(link Link) error {
|
func SetPromiscOn(link Link) error {
|
||||||
return pkgHandle.SetPromiscOn(link)
|
return pkgHandle.SetPromiscOn(link)
|
||||||
}
|
}
|
||||||
@ -1048,6 +1089,10 @@ func (h *Handle) LinkAdd(link Link) error {
|
|||||||
return h.linkModify(link, unix.NLM_F_CREATE|unix.NLM_F_EXCL|unix.NLM_F_ACK)
|
return h.linkModify(link, unix.NLM_F_CREATE|unix.NLM_F_EXCL|unix.NLM_F_ACK)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h *Handle) LinkModify(link Link) error {
|
||||||
|
return h.linkModify(link, unix.NLM_F_REQUEST|unix.NLM_F_ACK)
|
||||||
|
}
|
||||||
|
|
||||||
func (h *Handle) linkModify(link Link, flags int) error {
|
func (h *Handle) linkModify(link Link, flags int) error {
|
||||||
// TODO: support extra data for macvlan
|
// TODO: support extra data for macvlan
|
||||||
base := link.Attrs()
|
base := link.Attrs()
|
||||||
@ -1060,8 +1105,6 @@ func (h *Handle) linkModify(link Link, flags int) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if isTuntap {
|
if isTuntap {
|
||||||
// TODO: support user
|
|
||||||
// TODO: support group
|
|
||||||
if tuntap.Mode < unix.IFF_TUN || tuntap.Mode > unix.IFF_TAP {
|
if tuntap.Mode < unix.IFF_TUN || tuntap.Mode > unix.IFF_TAP {
|
||||||
return fmt.Errorf("Tuntap.Mode %v unknown", tuntap.Mode)
|
return fmt.Errorf("Tuntap.Mode %v unknown", tuntap.Mode)
|
||||||
}
|
}
|
||||||
@ -1089,21 +1132,64 @@ func (h *Handle) linkModify(link Link, flags int) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
req.Flags |= uint16(tuntap.Mode)
|
req.Flags |= uint16(tuntap.Mode)
|
||||||
|
const TUN = "/dev/net/tun"
|
||||||
for i := 0; i < queues; i++ {
|
for i := 0; i < queues; i++ {
|
||||||
localReq := req
|
localReq := req
|
||||||
file, err := os.OpenFile("/dev/net/tun", os.O_RDWR, 0)
|
fd, err := unix.Open(TUN, os.O_RDWR|syscall.O_CLOEXEC, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cleanupFds(fds)
|
cleanupFds(fds)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
fds = append(fds, file)
|
_, _, errno := unix.Syscall(unix.SYS_IOCTL, uintptr(fd), uintptr(unix.TUNSETIFF), uintptr(unsafe.Pointer(&localReq)))
|
||||||
_, _, errno := unix.Syscall(unix.SYS_IOCTL, file.Fd(), uintptr(unix.TUNSETIFF), uintptr(unsafe.Pointer(&localReq)))
|
|
||||||
if errno != 0 {
|
if errno != 0 {
|
||||||
|
// close the new fd
|
||||||
|
unix.Close(fd)
|
||||||
|
// and the already opened ones
|
||||||
cleanupFds(fds)
|
cleanupFds(fds)
|
||||||
return fmt.Errorf("Tuntap IOCTL TUNSETIFF failed [%d], errno %v", i, errno)
|
return fmt.Errorf("Tuntap IOCTL TUNSETIFF failed [%d], errno %v", i, errno)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_, _, errno = syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), syscall.TUNSETOWNER, uintptr(tuntap.Owner))
|
||||||
|
if errno != 0 {
|
||||||
|
cleanupFds(fds)
|
||||||
|
return fmt.Errorf("Tuntap IOCTL TUNSETOWNER failed [%d], errno %v", i, errno)
|
||||||
|
}
|
||||||
|
|
||||||
|
_, _, errno = syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), syscall.TUNSETGROUP, uintptr(tuntap.Group))
|
||||||
|
if errno != 0 {
|
||||||
|
cleanupFds(fds)
|
||||||
|
return fmt.Errorf("Tuntap IOCTL TUNSETGROUP failed [%d], errno %v", i, errno)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the tun device to non-blocking before use. The below comment
|
||||||
|
// taken from:
|
||||||
|
//
|
||||||
|
// https://github.com/mistsys/tuntap/commit/161418c25003bbee77d085a34af64d189df62bea
|
||||||
|
//
|
||||||
|
// Note there is a complication because in go, if a device node is
|
||||||
|
// opened, go sets it to use nonblocking I/O. However a /dev/net/tun
|
||||||
|
// doesn't work with epoll until after the TUNSETIFF ioctl has been
|
||||||
|
// done. So we open the unix fd directly, do the ioctl, then put the
|
||||||
|
// fd in nonblocking mode, an then finally wrap it in a os.File,
|
||||||
|
// which will see the nonblocking mode and add the fd to the
|
||||||
|
// pollable set, so later on when we Read() from it blocked the
|
||||||
|
// calling thread in the kernel.
|
||||||
|
//
|
||||||
|
// See
|
||||||
|
// https://github.com/golang/go/issues/30426
|
||||||
|
// which got exposed in go 1.13 by the fix to
|
||||||
|
// https://github.com/golang/go/issues/30624
|
||||||
|
err = unix.SetNonblock(fd, true)
|
||||||
|
if err != nil {
|
||||||
|
cleanupFds(fds)
|
||||||
|
return fmt.Errorf("Tuntap set to non-blocking failed [%d], err %v", i, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// create the file from the file descriptor and store it
|
||||||
|
file := os.NewFile(uintptr(fd), TUN)
|
||||||
|
fds = append(fds, file)
|
||||||
|
|
||||||
// 1) we only care for the name of the first tap in the multi queue set
|
// 1) we only care for the name of the first tap in the multi queue set
|
||||||
// 2) if the original name was empty, the localReq has now the actual name
|
// 2) if the original name was empty, the localReq has now the actual name
|
||||||
//
|
//
|
||||||
@ -1114,6 +1200,7 @@ func (h *Handle) linkModify(link Link, flags int) error {
|
|||||||
if i == 0 {
|
if i == 0 {
|
||||||
link.Attrs().Name = strings.Trim(string(localReq.Name[:]), "\x00")
|
link.Attrs().Name = strings.Trim(string(localReq.Name[:]), "\x00")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// only persist interface if NonPersist is NOT set
|
// only persist interface if NonPersist is NOT set
|
||||||
@ -1193,6 +1280,11 @@ func (h *Handle) linkModify(link Link, flags int) error {
|
|||||||
nameData := nl.NewRtAttr(unix.IFLA_IFNAME, nl.ZeroTerminated(base.Name))
|
nameData := nl.NewRtAttr(unix.IFLA_IFNAME, nl.ZeroTerminated(base.Name))
|
||||||
req.AddData(nameData)
|
req.AddData(nameData)
|
||||||
|
|
||||||
|
if base.Alias != "" {
|
||||||
|
alias := nl.NewRtAttr(unix.IFLA_IFALIAS, []byte(base.Alias))
|
||||||
|
req.AddData(alias)
|
||||||
|
}
|
||||||
|
|
||||||
if base.MTU > 0 {
|
if base.MTU > 0 {
|
||||||
mtu := nl.NewRtAttr(unix.IFLA_MTU, nl.Uint32Attr(uint32(base.MTU)))
|
mtu := nl.NewRtAttr(unix.IFLA_MTU, nl.Uint32Attr(uint32(base.MTU)))
|
||||||
req.AddData(mtu)
|
req.AddData(mtu)
|
||||||
@ -1272,12 +1364,28 @@ func (h *Handle) linkModify(link Link, flags int) error {
|
|||||||
if base.TxQLen >= 0 {
|
if base.TxQLen >= 0 {
|
||||||
peer.AddRtAttr(unix.IFLA_TXQLEN, nl.Uint32Attr(uint32(base.TxQLen)))
|
peer.AddRtAttr(unix.IFLA_TXQLEN, nl.Uint32Attr(uint32(base.TxQLen)))
|
||||||
}
|
}
|
||||||
|
if base.NumTxQueues > 0 {
|
||||||
|
peer.AddRtAttr(unix.IFLA_NUM_TX_QUEUES, nl.Uint32Attr(uint32(base.NumTxQueues)))
|
||||||
|
}
|
||||||
|
if base.NumRxQueues > 0 {
|
||||||
|
peer.AddRtAttr(unix.IFLA_NUM_RX_QUEUES, nl.Uint32Attr(uint32(base.NumRxQueues)))
|
||||||
|
}
|
||||||
if base.MTU > 0 {
|
if base.MTU > 0 {
|
||||||
peer.AddRtAttr(unix.IFLA_MTU, nl.Uint32Attr(uint32(base.MTU)))
|
peer.AddRtAttr(unix.IFLA_MTU, nl.Uint32Attr(uint32(base.MTU)))
|
||||||
}
|
}
|
||||||
if link.PeerHardwareAddr != nil {
|
if link.PeerHardwareAddr != nil {
|
||||||
peer.AddRtAttr(unix.IFLA_ADDRESS, []byte(link.PeerHardwareAddr))
|
peer.AddRtAttr(unix.IFLA_ADDRESS, []byte(link.PeerHardwareAddr))
|
||||||
}
|
}
|
||||||
|
if link.PeerNamespace != nil {
|
||||||
|
switch ns := link.PeerNamespace.(type) {
|
||||||
|
case NsPid:
|
||||||
|
val := nl.Uint32Attr(uint32(ns))
|
||||||
|
peer.AddRtAttr(unix.IFLA_NET_NS_PID, val)
|
||||||
|
case NsFd:
|
||||||
|
val := nl.Uint32Attr(uint32(ns))
|
||||||
|
peer.AddRtAttr(unix.IFLA_NET_NS_FD, val)
|
||||||
|
}
|
||||||
|
}
|
||||||
case *Vxlan:
|
case *Vxlan:
|
||||||
addVxlanAttrs(link, linkInfo)
|
addVxlanAttrs(link, linkInfo)
|
||||||
case *Bond:
|
case *Bond:
|
||||||
@ -1509,7 +1617,11 @@ func LinkDeserialize(hdr *unix.NlMsghdr, m []byte) (Link, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
base := LinkAttrs{Index: int(msg.Index), RawFlags: msg.Flags, Flags: linkFlags(msg.Flags), EncapType: msg.EncapType()}
|
base := NewLinkAttrs()
|
||||||
|
base.Index = int(msg.Index)
|
||||||
|
base.RawFlags = msg.Flags
|
||||||
|
base.Flags = linkFlags(msg.Flags)
|
||||||
|
base.EncapType = msg.EncapType()
|
||||||
if msg.Flags&unix.IFF_PROMISC != 0 {
|
if msg.Flags&unix.IFF_PROMISC != 0 {
|
||||||
base.Promisc = 1
|
base.Promisc = 1
|
||||||
}
|
}
|
||||||
@ -1543,6 +1655,8 @@ func LinkDeserialize(hdr *unix.NlMsghdr, m []byte) (Link, error) {
|
|||||||
link = &Vlan{}
|
link = &Vlan{}
|
||||||
case "veth":
|
case "veth":
|
||||||
link = &Veth{}
|
link = &Veth{}
|
||||||
|
case "wireguard":
|
||||||
|
link = &Wireguard{}
|
||||||
case "vxlan":
|
case "vxlan":
|
||||||
link = &Vxlan{}
|
link = &Vxlan{}
|
||||||
case "bond":
|
case "bond":
|
||||||
@ -2080,6 +2194,13 @@ func parseVlanData(link Link, data []syscall.NetlinkRouteAttr) {
|
|||||||
func parseVxlanData(link Link, data []syscall.NetlinkRouteAttr) {
|
func parseVxlanData(link Link, data []syscall.NetlinkRouteAttr) {
|
||||||
vxlan := link.(*Vxlan)
|
vxlan := link.(*Vxlan)
|
||||||
for _, datum := range data {
|
for _, datum := range data {
|
||||||
|
// NOTE(vish): Apparently some messages can be sent with no value.
|
||||||
|
// We special case GBP here to not change existing
|
||||||
|
// functionality. It appears that GBP sends a datum.Value
|
||||||
|
// of null.
|
||||||
|
if len(datum.Value) == 0 && datum.Attr.Type != nl.IFLA_VXLAN_GBP {
|
||||||
|
continue
|
||||||
|
}
|
||||||
switch datum.Attr.Type {
|
switch datum.Attr.Type {
|
||||||
case nl.IFLA_VXLAN_ID:
|
case nl.IFLA_VXLAN_ID:
|
||||||
vxlan.VxlanId = int(native.Uint32(datum.Value[0:4]))
|
vxlan.VxlanId = int(native.Uint32(datum.Value[0:4]))
|
||||||
@ -2513,7 +2634,8 @@ func parseLinkXdp(data []byte) (*LinkXdp, error) {
|
|||||||
case nl.IFLA_XDP_FD:
|
case nl.IFLA_XDP_FD:
|
||||||
xdp.Fd = int(native.Uint32(attr.Value[0:4]))
|
xdp.Fd = int(native.Uint32(attr.Value[0:4]))
|
||||||
case nl.IFLA_XDP_ATTACHED:
|
case nl.IFLA_XDP_ATTACHED:
|
||||||
xdp.Attached = attr.Value[0] != 0
|
xdp.AttachMode = uint32(attr.Value[0])
|
||||||
|
xdp.Attached = xdp.AttachMode != 0
|
||||||
case nl.IFLA_XDP_FLAGS:
|
case nl.IFLA_XDP_FLAGS:
|
||||||
xdp.Flags = native.Uint32(attr.Value[0:4])
|
xdp.Flags = native.Uint32(attr.Value[0:4])
|
||||||
case nl.IFLA_XDP_PROG_ID:
|
case nl.IFLA_XDP_PROG_ID:
|
||||||
@ -2577,7 +2699,7 @@ func parseIptunData(link Link, data []syscall.NetlinkRouteAttr) {
|
|||||||
case nl.IFLA_IPTUN_ENCAP_FLAGS:
|
case nl.IFLA_IPTUN_ENCAP_FLAGS:
|
||||||
iptun.EncapFlags = native.Uint16(datum.Value[0:2])
|
iptun.EncapFlags = native.Uint16(datum.Value[0:2])
|
||||||
case nl.IFLA_IPTUN_COLLECT_METADATA:
|
case nl.IFLA_IPTUN_COLLECT_METADATA:
|
||||||
iptun.FlowBased = int8(datum.Value[0]) != 0
|
iptun.FlowBased = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2601,10 +2723,14 @@ func addIp6tnlAttrs(ip6tnl *Ip6tnl, linkInfo *nl.RtAttr) {
|
|||||||
|
|
||||||
data.AddRtAttr(nl.IFLA_IPTUN_TTL, nl.Uint8Attr(ip6tnl.Ttl))
|
data.AddRtAttr(nl.IFLA_IPTUN_TTL, nl.Uint8Attr(ip6tnl.Ttl))
|
||||||
data.AddRtAttr(nl.IFLA_IPTUN_TOS, nl.Uint8Attr(ip6tnl.Tos))
|
data.AddRtAttr(nl.IFLA_IPTUN_TOS, nl.Uint8Attr(ip6tnl.Tos))
|
||||||
data.AddRtAttr(nl.IFLA_IPTUN_ENCAP_LIMIT, nl.Uint8Attr(ip6tnl.EncapLimit))
|
|
||||||
data.AddRtAttr(nl.IFLA_IPTUN_FLAGS, nl.Uint32Attr(ip6tnl.Flags))
|
data.AddRtAttr(nl.IFLA_IPTUN_FLAGS, nl.Uint32Attr(ip6tnl.Flags))
|
||||||
data.AddRtAttr(nl.IFLA_IPTUN_PROTO, nl.Uint8Attr(ip6tnl.Proto))
|
data.AddRtAttr(nl.IFLA_IPTUN_PROTO, nl.Uint8Attr(ip6tnl.Proto))
|
||||||
data.AddRtAttr(nl.IFLA_IPTUN_FLOWINFO, nl.Uint32Attr(ip6tnl.FlowInfo))
|
data.AddRtAttr(nl.IFLA_IPTUN_FLOWINFO, nl.Uint32Attr(ip6tnl.FlowInfo))
|
||||||
|
data.AddRtAttr(nl.IFLA_IPTUN_ENCAP_LIMIT, nl.Uint8Attr(ip6tnl.EncapLimit))
|
||||||
|
data.AddRtAttr(nl.IFLA_IPTUN_ENCAP_TYPE, nl.Uint16Attr(ip6tnl.EncapType))
|
||||||
|
data.AddRtAttr(nl.IFLA_IPTUN_ENCAP_FLAGS, nl.Uint16Attr(ip6tnl.EncapFlags))
|
||||||
|
data.AddRtAttr(nl.IFLA_IPTUN_ENCAP_SPORT, htons(ip6tnl.EncapSport))
|
||||||
|
data.AddRtAttr(nl.IFLA_IPTUN_ENCAP_DPORT, htons(ip6tnl.EncapDport))
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseIp6tnlData(link Link, data []syscall.NetlinkRouteAttr) {
|
func parseIp6tnlData(link Link, data []syscall.NetlinkRouteAttr) {
|
||||||
@ -2616,17 +2742,25 @@ func parseIp6tnlData(link Link, data []syscall.NetlinkRouteAttr) {
|
|||||||
case nl.IFLA_IPTUN_REMOTE:
|
case nl.IFLA_IPTUN_REMOTE:
|
||||||
ip6tnl.Remote = net.IP(datum.Value[:16])
|
ip6tnl.Remote = net.IP(datum.Value[:16])
|
||||||
case nl.IFLA_IPTUN_TTL:
|
case nl.IFLA_IPTUN_TTL:
|
||||||
ip6tnl.Ttl = uint8(datum.Value[0])
|
ip6tnl.Ttl = datum.Value[0]
|
||||||
case nl.IFLA_IPTUN_TOS:
|
case nl.IFLA_IPTUN_TOS:
|
||||||
ip6tnl.Tos = uint8(datum.Value[0])
|
ip6tnl.Tos = datum.Value[0]
|
||||||
case nl.IFLA_IPTUN_ENCAP_LIMIT:
|
|
||||||
ip6tnl.EncapLimit = uint8(datum.Value[0])
|
|
||||||
case nl.IFLA_IPTUN_FLAGS:
|
case nl.IFLA_IPTUN_FLAGS:
|
||||||
ip6tnl.Flags = native.Uint32(datum.Value[:4])
|
ip6tnl.Flags = native.Uint32(datum.Value[:4])
|
||||||
case nl.IFLA_IPTUN_PROTO:
|
case nl.IFLA_IPTUN_PROTO:
|
||||||
ip6tnl.Proto = uint8(datum.Value[0])
|
ip6tnl.Proto = datum.Value[0]
|
||||||
case nl.IFLA_IPTUN_FLOWINFO:
|
case nl.IFLA_IPTUN_FLOWINFO:
|
||||||
ip6tnl.FlowInfo = native.Uint32(datum.Value[:4])
|
ip6tnl.FlowInfo = native.Uint32(datum.Value[:4])
|
||||||
|
case nl.IFLA_IPTUN_ENCAP_LIMIT:
|
||||||
|
ip6tnl.EncapLimit = datum.Value[0]
|
||||||
|
case nl.IFLA_IPTUN_ENCAP_TYPE:
|
||||||
|
ip6tnl.EncapType = native.Uint16(datum.Value[0:2])
|
||||||
|
case nl.IFLA_IPTUN_ENCAP_FLAGS:
|
||||||
|
ip6tnl.EncapFlags = native.Uint16(datum.Value[0:2])
|
||||||
|
case nl.IFLA_IPTUN_ENCAP_SPORT:
|
||||||
|
ip6tnl.EncapSport = ntohs(datum.Value[0:2])
|
||||||
|
case nl.IFLA_IPTUN_ENCAP_DPORT:
|
||||||
|
ip6tnl.EncapDport = ntohs(datum.Value[0:2])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2653,8 +2787,10 @@ func addSittunAttrs(sittun *Sittun, linkInfo *nl.RtAttr) {
|
|||||||
data.AddRtAttr(nl.IFLA_IPTUN_TTL, nl.Uint8Attr(sittun.Ttl))
|
data.AddRtAttr(nl.IFLA_IPTUN_TTL, nl.Uint8Attr(sittun.Ttl))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data.AddRtAttr(nl.IFLA_IPTUN_PROTO, nl.Uint8Attr(sittun.Proto))
|
||||||
data.AddRtAttr(nl.IFLA_IPTUN_TOS, nl.Uint8Attr(sittun.Tos))
|
data.AddRtAttr(nl.IFLA_IPTUN_TOS, nl.Uint8Attr(sittun.Tos))
|
||||||
data.AddRtAttr(nl.IFLA_IPTUN_PMTUDISC, nl.Uint8Attr(sittun.PMtuDisc))
|
data.AddRtAttr(nl.IFLA_IPTUN_PMTUDISC, nl.Uint8Attr(sittun.PMtuDisc))
|
||||||
|
data.AddRtAttr(nl.IFLA_IPTUN_ENCAP_LIMIT, nl.Uint8Attr(sittun.EncapLimit))
|
||||||
data.AddRtAttr(nl.IFLA_IPTUN_ENCAP_TYPE, nl.Uint16Attr(sittun.EncapType))
|
data.AddRtAttr(nl.IFLA_IPTUN_ENCAP_TYPE, nl.Uint16Attr(sittun.EncapType))
|
||||||
data.AddRtAttr(nl.IFLA_IPTUN_ENCAP_FLAGS, nl.Uint16Attr(sittun.EncapFlags))
|
data.AddRtAttr(nl.IFLA_IPTUN_ENCAP_FLAGS, nl.Uint16Attr(sittun.EncapFlags))
|
||||||
data.AddRtAttr(nl.IFLA_IPTUN_ENCAP_SPORT, htons(sittun.EncapSport))
|
data.AddRtAttr(nl.IFLA_IPTUN_ENCAP_SPORT, htons(sittun.EncapSport))
|
||||||
@ -2670,11 +2806,13 @@ func parseSittunData(link Link, data []syscall.NetlinkRouteAttr) {
|
|||||||
case nl.IFLA_IPTUN_REMOTE:
|
case nl.IFLA_IPTUN_REMOTE:
|
||||||
sittun.Remote = net.IP(datum.Value[0:4])
|
sittun.Remote = net.IP(datum.Value[0:4])
|
||||||
case nl.IFLA_IPTUN_TTL:
|
case nl.IFLA_IPTUN_TTL:
|
||||||
sittun.Ttl = uint8(datum.Value[0])
|
sittun.Ttl = datum.Value[0]
|
||||||
case nl.IFLA_IPTUN_TOS:
|
case nl.IFLA_IPTUN_TOS:
|
||||||
sittun.Tos = uint8(datum.Value[0])
|
sittun.Tos = datum.Value[0]
|
||||||
case nl.IFLA_IPTUN_PMTUDISC:
|
case nl.IFLA_IPTUN_PMTUDISC:
|
||||||
sittun.PMtuDisc = uint8(datum.Value[0])
|
sittun.PMtuDisc = datum.Value[0]
|
||||||
|
case nl.IFLA_IPTUN_PROTO:
|
||||||
|
sittun.Proto = datum.Value[0]
|
||||||
case nl.IFLA_IPTUN_ENCAP_TYPE:
|
case nl.IFLA_IPTUN_ENCAP_TYPE:
|
||||||
sittun.EncapType = native.Uint16(datum.Value[0:2])
|
sittun.EncapType = native.Uint16(datum.Value[0:2])
|
||||||
case nl.IFLA_IPTUN_ENCAP_FLAGS:
|
case nl.IFLA_IPTUN_ENCAP_FLAGS:
|
||||||
@ -2761,6 +2899,9 @@ func addBridgeAttrs(bridge *Bridge, linkInfo *nl.RtAttr) {
|
|||||||
if bridge.MulticastSnooping != nil {
|
if bridge.MulticastSnooping != nil {
|
||||||
data.AddRtAttr(nl.IFLA_BR_MCAST_SNOOPING, boolToByte(*bridge.MulticastSnooping))
|
data.AddRtAttr(nl.IFLA_BR_MCAST_SNOOPING, boolToByte(*bridge.MulticastSnooping))
|
||||||
}
|
}
|
||||||
|
if bridge.AgeingTime != nil {
|
||||||
|
data.AddRtAttr(nl.IFLA_BR_AGEING_TIME, nl.Uint32Attr(*bridge.AgeingTime))
|
||||||
|
}
|
||||||
if bridge.HelloTime != nil {
|
if bridge.HelloTime != nil {
|
||||||
data.AddRtAttr(nl.IFLA_BR_HELLO_TIME, nl.Uint32Attr(*bridge.HelloTime))
|
data.AddRtAttr(nl.IFLA_BR_HELLO_TIME, nl.Uint32Attr(*bridge.HelloTime))
|
||||||
}
|
}
|
||||||
@ -2773,6 +2914,9 @@ func parseBridgeData(bridge Link, data []syscall.NetlinkRouteAttr) {
|
|||||||
br := bridge.(*Bridge)
|
br := bridge.(*Bridge)
|
||||||
for _, datum := range data {
|
for _, datum := range data {
|
||||||
switch datum.Attr.Type {
|
switch datum.Attr.Type {
|
||||||
|
case nl.IFLA_BR_AGEING_TIME:
|
||||||
|
ageingTime := native.Uint32(datum.Value[0:4])
|
||||||
|
br.AgeingTime = &ageingTime
|
||||||
case nl.IFLA_BR_HELLO_TIME:
|
case nl.IFLA_BR_HELLO_TIME:
|
||||||
helloTime := native.Uint32(datum.Value[0:4])
|
helloTime := native.Uint32(datum.Value[0:4])
|
||||||
br.HelloTime = &helloTime
|
br.HelloTime = &helloTime
|
||||||
@ -2852,6 +2996,24 @@ func parseVfInfo(data []syscall.NetlinkRouteAttr, id int) VfInfo {
|
|||||||
vfr := nl.DeserializeVfRate(element.Value[:])
|
vfr := nl.DeserializeVfRate(element.Value[:])
|
||||||
vf.MaxTxRate = vfr.MaxTxRate
|
vf.MaxTxRate = vfr.MaxTxRate
|
||||||
vf.MinTxRate = vfr.MinTxRate
|
vf.MinTxRate = vfr.MinTxRate
|
||||||
|
case nl.IFLA_VF_STATS:
|
||||||
|
vfstats := nl.DeserializeVfStats(element.Value[:])
|
||||||
|
vf.RxPackets = vfstats.RxPackets
|
||||||
|
vf.TxPackets = vfstats.TxPackets
|
||||||
|
vf.RxBytes = vfstats.RxBytes
|
||||||
|
vf.TxBytes = vfstats.TxBytes
|
||||||
|
vf.Multicast = vfstats.Multicast
|
||||||
|
vf.Broadcast = vfstats.Broadcast
|
||||||
|
vf.RxDropped = vfstats.RxDropped
|
||||||
|
vf.TxDropped = vfstats.TxDropped
|
||||||
|
|
||||||
|
case nl.IFLA_VF_RSS_QUERY_EN:
|
||||||
|
result := nl.DeserializeVfRssQueryEn(element.Value)
|
||||||
|
vf.RssQuery = result.Setting
|
||||||
|
|
||||||
|
case nl.IFLA_VF_TRUST:
|
||||||
|
result := nl.DeserializeVfTrust(element.Value)
|
||||||
|
vf.Trust = result.Setting
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return vf
|
return vf
|
||||||
|
12
vendor/github.com/vishvananda/netlink/neigh_linux.go
generated
vendored
12
vendor/github.com/vishvananda/netlink/neigh_linux.go
generated
vendored
@ -243,6 +243,18 @@ func (h *Handle) NeighListExecute(msg Ndmsg) ([]Neigh, error) {
|
|||||||
// Ignore messages from other interfaces
|
// Ignore messages from other interfaces
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if msg.Family != 0 && ndm.Family != msg.Family {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if msg.State != 0 && ndm.State != msg.State {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if msg.Type != 0 && ndm.Type != msg.Type {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if msg.Flags != 0 && ndm.Flags != msg.Flags {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
neigh, err := NeighDeserialize(m)
|
neigh, err := NeighDeserialize(m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
6
vendor/github.com/vishvananda/netlink/netlink_unspecified.go
generated
vendored
6
vendor/github.com/vishvananda/netlink/netlink_unspecified.go
generated
vendored
@ -16,7 +16,7 @@ func LinkSetMTU(link Link, mtu int) error {
|
|||||||
return ErrNotImplemented
|
return ErrNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
func LinkSetMaster(link Link, master *Bridge) error {
|
func LinkSetMaster(link Link, master Link) error {
|
||||||
return ErrNotImplemented
|
return ErrNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,6 +72,10 @@ func LinkSetXdpFd(link Link, fd int) error {
|
|||||||
return ErrNotImplemented
|
return ErrNotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func LinkSetXdpFdWithFlags(link Link, fd, flags int) error {
|
||||||
|
return ErrNotImplemented
|
||||||
|
}
|
||||||
|
|
||||||
func LinkSetARPOff(link Link) error {
|
func LinkSetARPOff(link Link) error {
|
||||||
return ErrNotImplemented
|
return ErrNotImplemented
|
||||||
}
|
}
|
||||||
|
14
vendor/github.com/vishvananda/netlink/nl/addr_linux.go
generated
vendored
14
vendor/github.com/vishvananda/netlink/nl/addr_linux.go
generated
vendored
@ -54,24 +54,18 @@ func (msg *IfAddrmsg) Len() int {
|
|||||||
// __u32 tstamp; /* updated timestamp, hundredths of seconds */
|
// __u32 tstamp; /* updated timestamp, hundredths of seconds */
|
||||||
// };
|
// };
|
||||||
|
|
||||||
const IFA_CACHEINFO = 6
|
|
||||||
const SizeofIfaCacheInfo = 0x10
|
|
||||||
|
|
||||||
type IfaCacheInfo struct {
|
type IfaCacheInfo struct {
|
||||||
IfaPrefered uint32
|
unix.IfaCacheinfo
|
||||||
IfaValid uint32
|
|
||||||
Cstamp uint32
|
|
||||||
Tstamp uint32
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (msg *IfaCacheInfo) Len() int {
|
func (msg *IfaCacheInfo) Len() int {
|
||||||
return SizeofIfaCacheInfo
|
return unix.SizeofIfaCacheinfo
|
||||||
}
|
}
|
||||||
|
|
||||||
func DeserializeIfaCacheInfo(b []byte) *IfaCacheInfo {
|
func DeserializeIfaCacheInfo(b []byte) *IfaCacheInfo {
|
||||||
return (*IfaCacheInfo)(unsafe.Pointer(&b[0:SizeofIfaCacheInfo][0]))
|
return (*IfaCacheInfo)(unsafe.Pointer(&b[0:unix.SizeofIfaCacheinfo][0]))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (msg *IfaCacheInfo) Serialize() []byte {
|
func (msg *IfaCacheInfo) Serialize() []byte {
|
||||||
return (*(*[SizeofIfaCacheInfo]byte)(unsafe.Pointer(msg)))[:]
|
return (*(*[unix.SizeofIfaCacheinfo]byte)(unsafe.Pointer(msg)))[:]
|
||||||
}
|
}
|
||||||
|
5
vendor/github.com/vishvananda/netlink/nl/conntrack_linux.go
generated
vendored
5
vendor/github.com/vishvananda/netlink/nl/conntrack_linux.go
generated
vendored
@ -40,9 +40,10 @@ const (
|
|||||||
NFNETLINK_V0 = 0
|
NFNETLINK_V0 = 0
|
||||||
)
|
)
|
||||||
|
|
||||||
// #define NLA_F_NESTED (1 << 15)
|
|
||||||
const (
|
const (
|
||||||
NLA_F_NESTED = (1 << 15)
|
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)
|
||||||
)
|
)
|
||||||
|
|
||||||
// enum ctattr_type {
|
// enum ctattr_type {
|
||||||
|
222
vendor/github.com/vishvananda/netlink/nl/ipset_linux.go
generated
vendored
Normal file
222
vendor/github.com/vishvananda/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
|
||||||
|
}
|
||||||
|
}
|
67
vendor/github.com/vishvananda/netlink/nl/link_linux.go
generated
vendored
67
vendor/github.com/vishvananda/netlink/nl/link_linux.go
generated
vendored
@ -1,6 +1,8 @@
|
|||||||
package nl
|
package nl
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/binary"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -243,7 +245,9 @@ const (
|
|||||||
IFLA_VF_STATS_TX_BYTES
|
IFLA_VF_STATS_TX_BYTES
|
||||||
IFLA_VF_STATS_BROADCAST
|
IFLA_VF_STATS_BROADCAST
|
||||||
IFLA_VF_STATS_MULTICAST
|
IFLA_VF_STATS_MULTICAST
|
||||||
IFLA_VF_STATS_MAX = IFLA_VF_STATS_MULTICAST
|
IFLA_VF_STATS_RX_DROPPED
|
||||||
|
IFLA_VF_STATS_TX_DROPPED
|
||||||
|
IFLA_VF_STATS_MAX = IFLA_VF_STATS_TX_DROPPED
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -326,6 +330,59 @@ func (msg *VfTxRate) Serialize() []byte {
|
|||||||
return (*(*[SizeofVfTxRate]byte)(unsafe.Pointer(msg)))[:]
|
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 {
|
// struct ifla_vf_rate {
|
||||||
// __u32 vf;
|
// __u32 vf;
|
||||||
// __u32 min_tx_rate; /* Min Bandwidth in Mbps */
|
// __u32 min_tx_rate; /* Min Bandwidth in Mbps */
|
||||||
@ -478,6 +535,14 @@ const (
|
|||||||
IFLA_XDP_MAX = IFLA_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 (
|
const (
|
||||||
IFLA_IPTUN_UNSPEC = iota
|
IFLA_IPTUN_UNSPEC = iota
|
||||||
IFLA_IPTUN_LINK
|
IFLA_IPTUN_LINK
|
||||||
|
28
vendor/github.com/vishvananda/netlink/nl/nl_linux.go
generated
vendored
28
vendor/github.com/vishvananda/netlink/nl/nl_linux.go
generated
vendored
@ -259,6 +259,29 @@ func NewIfInfomsgChild(parent *RtAttr, family int) *IfInfomsg {
|
|||||||
return 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
|
// Extend RtAttr to handle data and children
|
||||||
type RtAttr struct {
|
type RtAttr struct {
|
||||||
unix.RtAttr
|
unix.RtAttr
|
||||||
@ -439,10 +462,7 @@ done:
|
|||||||
if m.Header.Pid != pid {
|
if m.Header.Pid != pid {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if m.Header.Type == unix.NLMSG_DONE {
|
if m.Header.Type == unix.NLMSG_DONE || m.Header.Type == unix.NLMSG_ERROR {
|
||||||
break done
|
|
||||||
}
|
|
||||||
if m.Header.Type == unix.NLMSG_ERROR {
|
|
||||||
native := NativeEndian()
|
native := NativeEndian()
|
||||||
error := int32(native.Uint32(m.Data[0:4]))
|
error := int32(native.Uint32(m.Data[0:4]))
|
||||||
if error == 0 {
|
if error == 0 {
|
||||||
|
67
vendor/github.com/vishvananda/netlink/nl/parse_attr.go
generated
vendored
Normal file
67
vendor/github.com/vishvananda/netlink/nl/parse_attr.go
generated
vendored
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
package nl
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/binary"
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
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]))
|
||||||
|
|
||||||
|
result <- Attribute{
|
||||||
|
Type: native.Uint16(data[i+2 : i+4]),
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
7
vendor/github.com/vishvananda/netlink/nl/syscall.go
generated
vendored
7
vendor/github.com/vishvananda/netlink/nl/syscall.go
generated
vendored
@ -21,6 +21,13 @@ const (
|
|||||||
FRA_TABLE /* Extended table id */
|
FRA_TABLE /* Extended table id */
|
||||||
FRA_FWMASK /* mask for netfilter mark */
|
FRA_FWMASK /* mask for netfilter mark */
|
||||||
FRA_OIFNAME
|
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
|
// ip rule netlink request types
|
||||||
|
111
vendor/github.com/vishvananda/netlink/nl/tc_linux.go
generated
vendored
111
vendor/github.com/vishvananda/netlink/nl/tc_linux.go
generated
vendored
@ -94,6 +94,9 @@ const (
|
|||||||
SizeofTcTunnelKey = SizeofTcGen + 0x04
|
SizeofTcTunnelKey = SizeofTcGen + 0x04
|
||||||
SizeofTcSkbEdit = SizeofTcGen
|
SizeofTcSkbEdit = SizeofTcGen
|
||||||
SizeofTcPolice = 2*SizeofTcRateSpec + 0x20
|
SizeofTcPolice = 2*SizeofTcRateSpec + 0x20
|
||||||
|
SizeofTcSfqQopt = 0x0b
|
||||||
|
SizeofTcSfqRedStats = 0x18
|
||||||
|
SizeofTcSfqQoptV1 = SizeofTcSfqQopt + SizeofTcSfqRedStats + 0x1c
|
||||||
)
|
)
|
||||||
|
|
||||||
// struct tcmsg {
|
// struct tcmsg {
|
||||||
@ -735,7 +738,13 @@ const (
|
|||||||
TCA_TUNNEL_KEY_ENC_IPV6_SRC
|
TCA_TUNNEL_KEY_ENC_IPV6_SRC
|
||||||
TCA_TUNNEL_KEY_ENC_IPV6_DST
|
TCA_TUNNEL_KEY_ENC_IPV6_DST
|
||||||
TCA_TUNNEL_KEY_ENC_KEY_ID
|
TCA_TUNNEL_KEY_ENC_KEY_ID
|
||||||
TCA_TUNNEL_KEY_MAX = TCA_TUNNEL_KEY_ENC_KEY_ID
|
TCA_TUNNEL_KEY_PAD
|
||||||
|
TCA_TUNNEL_KEY_ENC_DST_PORT
|
||||||
|
TCA_TUNNEL_KEY_NO_CSUM
|
||||||
|
TCA_TUNNEL_KEY_ENC_OPTS
|
||||||
|
TCA_TUNNEL_KEY_ENC_TOS
|
||||||
|
TCA_TUNNEL_KEY_ENC_TTL
|
||||||
|
TCA_TUNNEL_KEY_MAX
|
||||||
)
|
)
|
||||||
|
|
||||||
type TcTunnelKey struct {
|
type TcTunnelKey struct {
|
||||||
@ -872,3 +881,103 @@ const (
|
|||||||
TCA_HFSC_FSC
|
TCA_HFSC_FSC
|
||||||
TCA_HFSC_USC
|
TCA_HFSC_USC
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// struct tc_sfq_qopt {
|
||||||
|
// unsigned quantum; /* Bytes per round allocated to flow */
|
||||||
|
// int perturb_period; /* Period of hash perturbation */
|
||||||
|
// __u32 limit; /* Maximal packets in queue */
|
||||||
|
// unsigned divisor; /* Hash divisor */
|
||||||
|
// unsigned flows; /* Maximal number of flows */
|
||||||
|
// };
|
||||||
|
|
||||||
|
type TcSfqQopt struct {
|
||||||
|
Quantum uint8
|
||||||
|
Perturb int32
|
||||||
|
Limit uint32
|
||||||
|
Divisor uint8
|
||||||
|
Flows uint8
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *TcSfqQopt) Len() int {
|
||||||
|
return SizeofTcSfqQopt
|
||||||
|
}
|
||||||
|
|
||||||
|
func DeserializeTcSfqQopt(b []byte) *TcSfqQopt {
|
||||||
|
return (*TcSfqQopt)(unsafe.Pointer(&b[0:SizeofTcSfqQopt][0]))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *TcSfqQopt) Serialize() []byte {
|
||||||
|
return (*(*[SizeofTcSfqQopt]byte)(unsafe.Pointer(x)))[:]
|
||||||
|
}
|
||||||
|
|
||||||
|
// struct tc_sfqred_stats {
|
||||||
|
// __u32 prob_drop; /* Early drops, below max threshold */
|
||||||
|
// __u32 forced_drop; /* Early drops, after max threshold */
|
||||||
|
// __u32 prob_mark; /* Marked packets, below max threshold */
|
||||||
|
// __u32 forced_mark; /* Marked packets, after max threshold */
|
||||||
|
// __u32 prob_mark_head; /* Marked packets, below max threshold */
|
||||||
|
// __u32 forced_mark_head;/* Marked packets, after max threshold */
|
||||||
|
// };
|
||||||
|
type TcSfqRedStats struct {
|
||||||
|
ProbDrop uint32
|
||||||
|
ForcedDrop uint32
|
||||||
|
ProbMark uint32
|
||||||
|
ForcedMark uint32
|
||||||
|
ProbMarkHead uint32
|
||||||
|
ForcedMarkHead uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *TcSfqRedStats) Len() int {
|
||||||
|
return SizeofTcSfqRedStats
|
||||||
|
}
|
||||||
|
|
||||||
|
func DeserializeTcSfqRedStats(b []byte) *TcSfqRedStats {
|
||||||
|
return (*TcSfqRedStats)(unsafe.Pointer(&b[0:SizeofTcSfqRedStats][0]))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *TcSfqRedStats) Serialize() []byte {
|
||||||
|
return (*(*[SizeofTcSfqRedStats]byte)(unsafe.Pointer(x)))[:]
|
||||||
|
}
|
||||||
|
|
||||||
|
// struct tc_sfq_qopt_v1 {
|
||||||
|
// struct tc_sfq_qopt v0;
|
||||||
|
// unsigned int depth; /* max number of packets per flow */
|
||||||
|
// unsigned int headdrop;
|
||||||
|
// /* SFQRED parameters */
|
||||||
|
// __u32 limit; /* HARD maximal flow queue length (bytes) */
|
||||||
|
// __u32 qth_min; /* Min average length threshold (bytes) */
|
||||||
|
// __u32 qth_max; /* Max average length threshold (bytes) */
|
||||||
|
// unsigned char Wlog; /* log(W) */
|
||||||
|
// unsigned char Plog; /* log(P_max/(qth_max-qth_min)) */
|
||||||
|
// unsigned char Scell_log; /* cell size for idle damping */
|
||||||
|
// unsigned char flags;
|
||||||
|
// __u32 max_P; /* probability, high resolution */
|
||||||
|
// /* SFQRED stats */
|
||||||
|
// struct tc_sfqred_stats stats;
|
||||||
|
// };
|
||||||
|
type TcSfqQoptV1 struct {
|
||||||
|
TcSfqQopt
|
||||||
|
Depth uint32
|
||||||
|
HeadDrop uint32
|
||||||
|
Limit uint32
|
||||||
|
QthMin uint32
|
||||||
|
QthMax uint32
|
||||||
|
Wlog byte
|
||||||
|
Plog byte
|
||||||
|
ScellLog byte
|
||||||
|
Flags byte
|
||||||
|
MaxP uint32
|
||||||
|
TcSfqRedStats
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *TcSfqQoptV1) Len() int {
|
||||||
|
return SizeofTcSfqQoptV1
|
||||||
|
}
|
||||||
|
|
||||||
|
func DeserializeTcSfqQoptV1(b []byte) *TcSfqQoptV1 {
|
||||||
|
return (*TcSfqQoptV1)(unsafe.Pointer(&b[0:SizeofTcSfqQoptV1][0]))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *TcSfqQoptV1) Serialize() []byte {
|
||||||
|
return (*(*[SizeofTcSfqQoptV1]byte)(unsafe.Pointer(x)))[:]
|
||||||
|
}
|
||||||
|
2
vendor/github.com/vishvananda/netlink/nl/xfrm_state_linux.go
generated
vendored
2
vendor/github.com/vishvananda/netlink/nl/xfrm_state_linux.go
generated
vendored
@ -13,7 +13,7 @@ const (
|
|||||||
SizeofXfrmAlgoAuth = 0x48
|
SizeofXfrmAlgoAuth = 0x48
|
||||||
SizeofXfrmAlgoAEAD = 0x48
|
SizeofXfrmAlgoAEAD = 0x48
|
||||||
SizeofXfrmEncapTmpl = 0x18
|
SizeofXfrmEncapTmpl = 0x18
|
||||||
SizeofXfrmUsersaFlush = 0x8
|
SizeofXfrmUsersaFlush = 0x1
|
||||||
SizeofXfrmReplayStateEsn = 0x18
|
SizeofXfrmReplayStateEsn = 0x18
|
||||||
)
|
)
|
||||||
|
|
||||||
|
24
vendor/github.com/vishvananda/netlink/qdisc.go
generated
vendored
24
vendor/github.com/vishvananda/netlink/qdisc.go
generated
vendored
@ -338,3 +338,27 @@ func (qdisc *FqCodel) Attrs() *QdiscAttrs {
|
|||||||
func (qdisc *FqCodel) Type() string {
|
func (qdisc *FqCodel) Type() string {
|
||||||
return "fq_codel"
|
return "fq_codel"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Sfq struct {
|
||||||
|
QdiscAttrs
|
||||||
|
// TODO: Only the simplified options for SFQ are handled here. Support for the extended one can be added later.
|
||||||
|
Quantum uint8
|
||||||
|
Perturb uint8
|
||||||
|
Limit uint32
|
||||||
|
Divisor uint8
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sfq *Sfq) String() string {
|
||||||
|
return fmt.Sprintf(
|
||||||
|
"{%v -- Quantum: %v, Perturb: %v, Limit: %v, Divisor: %v}",
|
||||||
|
sfq.Attrs(), sfq.Quantum, sfq.Perturb, sfq.Limit, sfq.Divisor,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (qdisc *Sfq) Attrs() *QdiscAttrs {
|
||||||
|
return &qdisc.QdiscAttrs
|
||||||
|
}
|
||||||
|
|
||||||
|
func (qdisc *Sfq) Type() string {
|
||||||
|
return "sfq"
|
||||||
|
}
|
||||||
|
41
vendor/github.com/vishvananda/netlink/qdisc_linux.go
generated
vendored
41
vendor/github.com/vishvananda/netlink/qdisc_linux.go
generated
vendored
@ -278,6 +278,14 @@ func qdiscPayload(req *nl.NetlinkRequest, qdisc Qdisc) error {
|
|||||||
if qdisc.FlowDefaultRate > 0 {
|
if qdisc.FlowDefaultRate > 0 {
|
||||||
options.AddRtAttr(nl.TCA_FQ_FLOW_DEFAULT_RATE, nl.Uint32Attr((uint32(qdisc.FlowDefaultRate))))
|
options.AddRtAttr(nl.TCA_FQ_FLOW_DEFAULT_RATE, nl.Uint32Attr((uint32(qdisc.FlowDefaultRate))))
|
||||||
}
|
}
|
||||||
|
case *Sfq:
|
||||||
|
opt := nl.TcSfqQoptV1{}
|
||||||
|
opt.TcSfqQopt.Quantum = qdisc.Quantum
|
||||||
|
opt.TcSfqQopt.Perturb = int32(qdisc.Perturb)
|
||||||
|
opt.TcSfqQopt.Limit = qdisc.Limit
|
||||||
|
opt.TcSfqQopt.Divisor = qdisc.Divisor
|
||||||
|
|
||||||
|
options = nl.NewRtAttr(nl.TCA_OPTIONS, opt.Serialize())
|
||||||
default:
|
default:
|
||||||
options = nil
|
options = nil
|
||||||
}
|
}
|
||||||
@ -362,6 +370,8 @@ func (h *Handle) QdiscList(link Link) ([]Qdisc, error) {
|
|||||||
qdisc = &FqCodel{}
|
qdisc = &FqCodel{}
|
||||||
case "netem":
|
case "netem":
|
||||||
qdisc = &Netem{}
|
qdisc = &Netem{}
|
||||||
|
case "sfq":
|
||||||
|
qdisc = &Sfq{}
|
||||||
default:
|
default:
|
||||||
qdisc = &GenericQdisc{QdiscType: qdiscType}
|
qdisc = &GenericQdisc{QdiscType: qdiscType}
|
||||||
}
|
}
|
||||||
@ -417,6 +427,10 @@ func (h *Handle) QdiscList(link Link) ([]Qdisc, error) {
|
|||||||
if err := parseNetemData(qdisc, attr.Value); err != nil {
|
if err := parseNetemData(qdisc, attr.Value); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
case "sfq":
|
||||||
|
if err := parseSfqData(qdisc, attr.Value); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
// no options for ingress
|
// no options for ingress
|
||||||
}
|
}
|
||||||
@ -582,6 +596,17 @@ func parseTbfData(qdisc Qdisc, data []syscall.NetlinkRouteAttr) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func parseSfqData(qdisc Qdisc, value []byte) error {
|
||||||
|
sfq := qdisc.(*Sfq)
|
||||||
|
opt := nl.DeserializeTcSfqQoptV1(value)
|
||||||
|
sfq.Quantum = opt.TcSfqQopt.Quantum
|
||||||
|
sfq.Perturb = uint8(opt.TcSfqQopt.Perturb)
|
||||||
|
sfq.Limit = opt.TcSfqQopt.Limit
|
||||||
|
sfq.Divisor = opt.TcSfqQopt.Divisor
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
TIME_UNITS_PER_SEC = 1000000
|
TIME_UNITS_PER_SEC = 1000000
|
||||||
)
|
)
|
||||||
@ -598,10 +623,10 @@ func initClock() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
parts := strings.Split(strings.TrimSpace(string(data)), " ")
|
parts := strings.Split(strings.TrimSpace(string(data)), " ")
|
||||||
if len(parts) < 3 {
|
if len(parts) < 4 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var vals [3]uint64
|
var vals [4]uint64
|
||||||
for i := range vals {
|
for i := range vals {
|
||||||
val, err := strconv.ParseUint(parts[i], 16, 32)
|
val, err := strconv.ParseUint(parts[i], 16, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -615,7 +640,12 @@ func initClock() {
|
|||||||
}
|
}
|
||||||
clockFactor = float64(vals[2]) / TIME_UNITS_PER_SEC
|
clockFactor = float64(vals[2]) / TIME_UNITS_PER_SEC
|
||||||
tickInUsec = float64(vals[0]) / float64(vals[1]) * clockFactor
|
tickInUsec = float64(vals[0]) / float64(vals[1]) * clockFactor
|
||||||
hz = float64(vals[0])
|
if vals[2] == 1000000 {
|
||||||
|
// ref https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/tree/lib/utils.c#n963
|
||||||
|
hz = float64(vals[3])
|
||||||
|
} else {
|
||||||
|
hz = 100
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TickInUsec() float64 {
|
func TickInUsec() float64 {
|
||||||
@ -663,6 +693,7 @@ func latency(rate uint64, limit, buffer uint32) float64 {
|
|||||||
return TIME_UNITS_PER_SEC*(float64(limit)/float64(rate)) - float64(tick2Time(buffer))
|
return TIME_UNITS_PER_SEC*(float64(limit)/float64(rate)) - float64(tick2Time(buffer))
|
||||||
}
|
}
|
||||||
|
|
||||||
func Xmittime(rate uint64, size uint32) float64 {
|
func Xmittime(rate uint64, size uint32) uint32 {
|
||||||
return TickInUsec() * TIME_UNITS_PER_SEC * (float64(size) / float64(rate))
|
// https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/tree/tc/tc_core.c#n62
|
||||||
|
return time2Tick(uint32(TIME_UNITS_PER_SEC * (float64(size) / float64(rate))))
|
||||||
}
|
}
|
||||||
|
46
vendor/github.com/vishvananda/netlink/rdma_link_linux.go
generated
vendored
46
vendor/github.com/vishvananda/netlink/rdma_link_linux.go
generated
vendored
@ -77,28 +77,39 @@ func executeOneGetRdmaLink(data []byte) (*RdmaLink, error) {
|
|||||||
return &link, nil
|
return &link, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func execRdmaGetLink(req *nl.NetlinkRequest, name string) (*RdmaLink, error) {
|
func execRdmaSetLink(req *nl.NetlinkRequest) error {
|
||||||
|
|
||||||
|
_, err := req.Execute(unix.NETLINK_RDMA, 0)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// RdmaLinkList gets a list of RDMA link devices.
|
||||||
|
// Equivalent to: `rdma dev show`
|
||||||
|
func RdmaLinkList() ([]*RdmaLink, error) {
|
||||||
|
return pkgHandle.RdmaLinkList()
|
||||||
|
}
|
||||||
|
|
||||||
|
// RdmaLinkList gets a list of RDMA link devices.
|
||||||
|
// Equivalent to: `rdma dev show`
|
||||||
|
func (h *Handle) RdmaLinkList() ([]*RdmaLink, error) {
|
||||||
|
proto := getProtoField(nl.RDMA_NL_NLDEV, nl.RDMA_NLDEV_CMD_GET)
|
||||||
|
req := h.newNetlinkRequest(proto, unix.NLM_F_ACK|unix.NLM_F_DUMP)
|
||||||
|
|
||||||
msgs, err := req.Execute(unix.NETLINK_RDMA, 0)
|
msgs, err := req.Execute(unix.NETLINK_RDMA, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var res []*RdmaLink
|
||||||
for _, m := range msgs {
|
for _, m := range msgs {
|
||||||
link, err := executeOneGetRdmaLink(m)
|
link, err := executeOneGetRdmaLink(m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if link.Attrs.Name == name {
|
res = append(res, link)
|
||||||
return link, nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil, fmt.Errorf("Rdma device %v not found", name)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func execRdmaSetLink(req *nl.NetlinkRequest) error {
|
return res, nil
|
||||||
|
|
||||||
_, err := req.Execute(unix.NETLINK_RDMA, 0)
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// RdmaLinkByName finds a link by name and returns a pointer to the object if
|
// RdmaLinkByName finds a link by name and returns a pointer to the object if
|
||||||
@ -110,11 +121,16 @@ func RdmaLinkByName(name string) (*RdmaLink, error) {
|
|||||||
// RdmaLinkByName finds a link by name and returns a pointer to the object if
|
// RdmaLinkByName finds a link by name and returns a pointer to the object if
|
||||||
// found and nil error, otherwise returns error code.
|
// found and nil error, otherwise returns error code.
|
||||||
func (h *Handle) RdmaLinkByName(name string) (*RdmaLink, error) {
|
func (h *Handle) RdmaLinkByName(name string) (*RdmaLink, error) {
|
||||||
|
links, err := h.RdmaLinkList()
|
||||||
proto := getProtoField(nl.RDMA_NL_NLDEV, nl.RDMA_NLDEV_CMD_GET)
|
if err != nil {
|
||||||
req := h.newNetlinkRequest(proto, unix.NLM_F_ACK|unix.NLM_F_DUMP)
|
return nil, err
|
||||||
|
}
|
||||||
return execRdmaGetLink(req, name)
|
for _, link := range links {
|
||||||
|
if link.Attrs.Name == name {
|
||||||
|
return link, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("Rdma device %v not found", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RdmaLinkSetName sets the name of the rdma link device. Return nil on success
|
// RdmaLinkSetName sets the name of the rdma link device. Return nil on success
|
||||||
|
13
vendor/github.com/vishvananda/netlink/route.go
generated
vendored
13
vendor/github.com/vishvananda/netlink/route.go
generated
vendored
@ -46,8 +46,21 @@ type Route struct {
|
|||||||
NewDst Destination
|
NewDst Destination
|
||||||
Encap Encap
|
Encap Encap
|
||||||
MTU int
|
MTU int
|
||||||
|
Window int
|
||||||
|
Rtt int
|
||||||
|
RttVar int
|
||||||
|
Ssthresh int
|
||||||
|
Cwnd int
|
||||||
AdvMSS int
|
AdvMSS int
|
||||||
|
Reordering int
|
||||||
Hoplimit int
|
Hoplimit int
|
||||||
|
InitCwnd int
|
||||||
|
Features int
|
||||||
|
RtoMin int
|
||||||
|
InitRwnd int
|
||||||
|
QuickACK int
|
||||||
|
Congctl string
|
||||||
|
FastOpenNoCookie int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r Route) String() string {
|
func (r Route) String() string {
|
||||||
|
119
vendor/github.com/vishvananda/netlink/route_linux.go
generated
vendored
119
vendor/github.com/vishvananda/netlink/route_linux.go
generated
vendored
@ -33,6 +33,9 @@ const (
|
|||||||
RT_FILTER_GW
|
RT_FILTER_GW
|
||||||
RT_FILTER_TABLE
|
RT_FILTER_TABLE
|
||||||
RT_FILTER_HOPLIMIT
|
RT_FILTER_HOPLIMIT
|
||||||
|
RT_FILTER_PRIORITY
|
||||||
|
RT_FILTER_MARK
|
||||||
|
RT_FILTER_MASK
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -639,19 +642,70 @@ func (h *Handle) routeHandle(route *Route, req *nl.NetlinkRequest, msg *nl.RtMsg
|
|||||||
}
|
}
|
||||||
|
|
||||||
var metrics []*nl.RtAttr
|
var metrics []*nl.RtAttr
|
||||||
// TODO: support other rta_metric values
|
|
||||||
if route.MTU > 0 {
|
if route.MTU > 0 {
|
||||||
b := nl.Uint32Attr(uint32(route.MTU))
|
b := nl.Uint32Attr(uint32(route.MTU))
|
||||||
metrics = append(metrics, nl.NewRtAttr(unix.RTAX_MTU, b))
|
metrics = append(metrics, nl.NewRtAttr(unix.RTAX_MTU, b))
|
||||||
}
|
}
|
||||||
|
if route.Window > 0 {
|
||||||
|
b := nl.Uint32Attr(uint32(route.Window))
|
||||||
|
metrics = append(metrics, nl.NewRtAttr(unix.RTAX_WINDOW, b))
|
||||||
|
}
|
||||||
|
if route.Rtt > 0 {
|
||||||
|
b := nl.Uint32Attr(uint32(route.Rtt))
|
||||||
|
metrics = append(metrics, nl.NewRtAttr(unix.RTAX_RTT, b))
|
||||||
|
}
|
||||||
|
if route.RttVar > 0 {
|
||||||
|
b := nl.Uint32Attr(uint32(route.RttVar))
|
||||||
|
metrics = append(metrics, nl.NewRtAttr(unix.RTAX_RTTVAR, b))
|
||||||
|
}
|
||||||
|
if route.Ssthresh > 0 {
|
||||||
|
b := nl.Uint32Attr(uint32(route.Ssthresh))
|
||||||
|
metrics = append(metrics, nl.NewRtAttr(unix.RTAX_SSTHRESH, b))
|
||||||
|
}
|
||||||
|
if route.Cwnd > 0 {
|
||||||
|
b := nl.Uint32Attr(uint32(route.Cwnd))
|
||||||
|
metrics = append(metrics, nl.NewRtAttr(unix.RTAX_CWND, b))
|
||||||
|
}
|
||||||
if route.AdvMSS > 0 {
|
if route.AdvMSS > 0 {
|
||||||
b := nl.Uint32Attr(uint32(route.AdvMSS))
|
b := nl.Uint32Attr(uint32(route.AdvMSS))
|
||||||
metrics = append(metrics, nl.NewRtAttr(unix.RTAX_ADVMSS, b))
|
metrics = append(metrics, nl.NewRtAttr(unix.RTAX_ADVMSS, b))
|
||||||
}
|
}
|
||||||
|
if route.Reordering > 0 {
|
||||||
|
b := nl.Uint32Attr(uint32(route.Reordering))
|
||||||
|
metrics = append(metrics, nl.NewRtAttr(unix.RTAX_REORDERING, b))
|
||||||
|
}
|
||||||
if route.Hoplimit > 0 {
|
if route.Hoplimit > 0 {
|
||||||
b := nl.Uint32Attr(uint32(route.Hoplimit))
|
b := nl.Uint32Attr(uint32(route.Hoplimit))
|
||||||
metrics = append(metrics, nl.NewRtAttr(unix.RTAX_HOPLIMIT, b))
|
metrics = append(metrics, nl.NewRtAttr(unix.RTAX_HOPLIMIT, b))
|
||||||
}
|
}
|
||||||
|
if route.InitCwnd > 0 {
|
||||||
|
b := nl.Uint32Attr(uint32(route.InitCwnd))
|
||||||
|
metrics = append(metrics, nl.NewRtAttr(unix.RTAX_INITCWND, b))
|
||||||
|
}
|
||||||
|
if route.Features > 0 {
|
||||||
|
b := nl.Uint32Attr(uint32(route.Features))
|
||||||
|
metrics = append(metrics, nl.NewRtAttr(unix.RTAX_FEATURES, b))
|
||||||
|
}
|
||||||
|
if route.RtoMin > 0 {
|
||||||
|
b := nl.Uint32Attr(uint32(route.RtoMin))
|
||||||
|
metrics = append(metrics, nl.NewRtAttr(unix.RTAX_RTO_MIN, b))
|
||||||
|
}
|
||||||
|
if route.InitRwnd > 0 {
|
||||||
|
b := nl.Uint32Attr(uint32(route.InitRwnd))
|
||||||
|
metrics = append(metrics, nl.NewRtAttr(unix.RTAX_INITRWND, b))
|
||||||
|
}
|
||||||
|
if route.QuickACK > 0 {
|
||||||
|
b := nl.Uint32Attr(uint32(route.QuickACK))
|
||||||
|
metrics = append(metrics, nl.NewRtAttr(unix.RTAX_QUICKACK, b))
|
||||||
|
}
|
||||||
|
if route.Congctl != "" {
|
||||||
|
b := nl.ZeroTerminated(route.Congctl)
|
||||||
|
metrics = append(metrics, nl.NewRtAttr(unix.RTAX_CC_ALGO, b))
|
||||||
|
}
|
||||||
|
if route.FastOpenNoCookie > 0 {
|
||||||
|
b := nl.Uint32Attr(uint32(route.FastOpenNoCookie))
|
||||||
|
metrics = append(metrics, nl.NewRtAttr(unix.RTAX_FASTOPEN_NO_COOKIE, b))
|
||||||
|
}
|
||||||
|
|
||||||
if metrics != nil {
|
if metrics != nil {
|
||||||
attr := nl.NewRtAttr(unix.RTA_METRICS, nil)
|
attr := nl.NewRtAttr(unix.RTA_METRICS, nil)
|
||||||
@ -903,10 +957,36 @@ func deserializeRoute(m []byte) (Route, error) {
|
|||||||
switch metric.Attr.Type {
|
switch metric.Attr.Type {
|
||||||
case unix.RTAX_MTU:
|
case unix.RTAX_MTU:
|
||||||
route.MTU = int(native.Uint32(metric.Value[0:4]))
|
route.MTU = int(native.Uint32(metric.Value[0:4]))
|
||||||
|
case unix.RTAX_WINDOW:
|
||||||
|
route.Window = int(native.Uint32(metric.Value[0:4]))
|
||||||
|
case unix.RTAX_RTT:
|
||||||
|
route.Rtt = int(native.Uint32(metric.Value[0:4]))
|
||||||
|
case unix.RTAX_RTTVAR:
|
||||||
|
route.RttVar = int(native.Uint32(metric.Value[0:4]))
|
||||||
|
case unix.RTAX_SSTHRESH:
|
||||||
|
route.Ssthresh = int(native.Uint32(metric.Value[0:4]))
|
||||||
|
case unix.RTAX_CWND:
|
||||||
|
route.Cwnd = int(native.Uint32(metric.Value[0:4]))
|
||||||
case unix.RTAX_ADVMSS:
|
case unix.RTAX_ADVMSS:
|
||||||
route.AdvMSS = int(native.Uint32(metric.Value[0:4]))
|
route.AdvMSS = int(native.Uint32(metric.Value[0:4]))
|
||||||
|
case unix.RTAX_REORDERING:
|
||||||
|
route.Reordering = int(native.Uint32(metric.Value[0:4]))
|
||||||
case unix.RTAX_HOPLIMIT:
|
case unix.RTAX_HOPLIMIT:
|
||||||
route.Hoplimit = int(native.Uint32(metric.Value[0:4]))
|
route.Hoplimit = int(native.Uint32(metric.Value[0:4]))
|
||||||
|
case unix.RTAX_INITCWND:
|
||||||
|
route.InitCwnd = int(native.Uint32(metric.Value[0:4]))
|
||||||
|
case unix.RTAX_FEATURES:
|
||||||
|
route.Features = int(native.Uint32(metric.Value[0:4]))
|
||||||
|
case unix.RTAX_RTO_MIN:
|
||||||
|
route.RtoMin = int(native.Uint32(metric.Value[0:4]))
|
||||||
|
case unix.RTAX_INITRWND:
|
||||||
|
route.InitRwnd = int(native.Uint32(metric.Value[0:4]))
|
||||||
|
case unix.RTAX_QUICKACK:
|
||||||
|
route.QuickACK = int(native.Uint32(metric.Value[0:4]))
|
||||||
|
case unix.RTAX_CC_ALGO:
|
||||||
|
route.Congctl = nl.BytesToString(metric.Value)
|
||||||
|
case unix.RTAX_FASTOPEN_NO_COOKIE:
|
||||||
|
route.FastOpenNoCookie = int(native.Uint32(metric.Value[0:4]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -938,15 +1018,27 @@ func deserializeRoute(m []byte) (Route, error) {
|
|||||||
return route, nil
|
return route, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RouteGetOptions contains a set of options to use with
|
||||||
|
// RouteGetWithOptions
|
||||||
|
type RouteGetOptions struct {
|
||||||
|
VrfName string
|
||||||
|
}
|
||||||
|
|
||||||
|
// RouteGetWithOptions gets a route to a specific destination from the host system.
|
||||||
|
// Equivalent to: 'ip route get <> vrf <VrfName>'.
|
||||||
|
func RouteGetWithOptions(destination net.IP, options *RouteGetOptions) ([]Route, error) {
|
||||||
|
return pkgHandle.RouteGetWithOptions(destination, options)
|
||||||
|
}
|
||||||
|
|
||||||
// RouteGet gets a route to a specific destination from the host system.
|
// RouteGet gets a route to a specific destination from the host system.
|
||||||
// Equivalent to: 'ip route get'.
|
// Equivalent to: 'ip route get'.
|
||||||
func RouteGet(destination net.IP) ([]Route, error) {
|
func RouteGet(destination net.IP) ([]Route, error) {
|
||||||
return pkgHandle.RouteGet(destination)
|
return pkgHandle.RouteGet(destination)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RouteGet gets a route to a specific destination from the host system.
|
// RouteGetWithOptions gets a route to a specific destination from the host system.
|
||||||
// Equivalent to: 'ip route get'.
|
// Equivalent to: 'ip route get <> vrf <VrfName>'.
|
||||||
func (h *Handle) RouteGet(destination net.IP) ([]Route, error) {
|
func (h *Handle) RouteGetWithOptions(destination net.IP, options *RouteGetOptions) ([]Route, error) {
|
||||||
req := h.newNetlinkRequest(unix.RTM_GETROUTE, unix.NLM_F_REQUEST)
|
req := h.newNetlinkRequest(unix.RTM_GETROUTE, unix.NLM_F_REQUEST)
|
||||||
family := nl.GetIPFamily(destination)
|
family := nl.GetIPFamily(destination)
|
||||||
var destinationData []byte
|
var destinationData []byte
|
||||||
@ -966,6 +1058,20 @@ func (h *Handle) RouteGet(destination net.IP) ([]Route, error) {
|
|||||||
rtaDst := nl.NewRtAttr(unix.RTA_DST, destinationData)
|
rtaDst := nl.NewRtAttr(unix.RTA_DST, destinationData)
|
||||||
req.AddData(rtaDst)
|
req.AddData(rtaDst)
|
||||||
|
|
||||||
|
if options != nil {
|
||||||
|
link, err := LinkByName(options.VrfName)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var (
|
||||||
|
b = make([]byte, 4)
|
||||||
|
native = nl.NativeEndian()
|
||||||
|
)
|
||||||
|
native.PutUint32(b, uint32(link.Attrs().Index))
|
||||||
|
|
||||||
|
req.AddData(nl.NewRtAttr(unix.RTA_OIF, b))
|
||||||
|
}
|
||||||
|
|
||||||
msgs, err := req.Execute(unix.NETLINK_ROUTE, unix.RTM_NEWROUTE)
|
msgs, err := req.Execute(unix.NETLINK_ROUTE, unix.RTM_NEWROUTE)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -980,7 +1086,12 @@ func (h *Handle) RouteGet(destination net.IP) ([]Route, error) {
|
|||||||
res = append(res, route)
|
res = append(res, route)
|
||||||
}
|
}
|
||||||
return res, nil
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RouteGet gets a route to a specific destination from the host system.
|
||||||
|
// Equivalent to: 'ip route get'.
|
||||||
|
func (h *Handle) RouteGet(destination net.IP) ([]Route, error) {
|
||||||
|
return h.RouteGetWithOptions(destination, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RouteSubscribe takes a chan down which notifications will be sent
|
// RouteSubscribe takes a chan down which notifications will be sent
|
||||||
|
14
vendor/github.com/vishvananda/netlink/rule.go
generated
vendored
14
vendor/github.com/vishvananda/netlink/rule.go
generated
vendored
@ -12,6 +12,7 @@ type Rule struct {
|
|||||||
Table int
|
Table int
|
||||||
Mark int
|
Mark int
|
||||||
Mask int
|
Mask int
|
||||||
|
Tos uint
|
||||||
TunID uint
|
TunID uint
|
||||||
Goto int
|
Goto int
|
||||||
Src *net.IPNet
|
Src *net.IPNet
|
||||||
@ -22,6 +23,8 @@ type Rule struct {
|
|||||||
SuppressIfgroup int
|
SuppressIfgroup int
|
||||||
SuppressPrefixlen int
|
SuppressPrefixlen int
|
||||||
Invert bool
|
Invert bool
|
||||||
|
Dport *RulePortRange
|
||||||
|
Sport *RulePortRange
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r Rule) String() string {
|
func (r Rule) String() string {
|
||||||
@ -40,3 +43,14 @@ func NewRule() *Rule {
|
|||||||
Flow: -1,
|
Flow: -1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewRulePortRange creates rule sport/dport range.
|
||||||
|
func NewRulePortRange(start, end uint16) *RulePortRange {
|
||||||
|
return &RulePortRange{Start: start, End: end}
|
||||||
|
}
|
||||||
|
|
||||||
|
// RulePortRange represents rule sport/dport range.
|
||||||
|
type RulePortRange struct {
|
||||||
|
Start uint16
|
||||||
|
End uint16
|
||||||
|
}
|
||||||
|
66
vendor/github.com/vishvananda/netlink/rule_linux.go
generated
vendored
66
vendor/github.com/vishvananda/netlink/rule_linux.go
generated
vendored
@ -1,6 +1,7 @@
|
|||||||
package netlink
|
package netlink
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
@ -55,6 +56,9 @@ func ruleHandle(rule *Rule, req *nl.NetlinkRequest) error {
|
|||||||
if rule.Table >= 0 && rule.Table < 256 {
|
if rule.Table >= 0 && rule.Table < 256 {
|
||||||
msg.Table = uint8(rule.Table)
|
msg.Table = uint8(rule.Table)
|
||||||
}
|
}
|
||||||
|
if rule.Tos != 0 {
|
||||||
|
msg.Tos = uint8(rule.Tos)
|
||||||
|
}
|
||||||
|
|
||||||
var dstFamily uint8
|
var dstFamily uint8
|
||||||
var rtAttrs []*nl.RtAttr
|
var rtAttrs []*nl.RtAttr
|
||||||
@ -138,10 +142,10 @@ func ruleHandle(rule *Rule, req *nl.NetlinkRequest) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if rule.IifName != "" {
|
if rule.IifName != "" {
|
||||||
req.AddData(nl.NewRtAttr(nl.FRA_IIFNAME, []byte(rule.IifName)))
|
req.AddData(nl.NewRtAttr(nl.FRA_IIFNAME, []byte(rule.IifName+"\x00")))
|
||||||
}
|
}
|
||||||
if rule.OifName != "" {
|
if rule.OifName != "" {
|
||||||
req.AddData(nl.NewRtAttr(nl.FRA_OIFNAME, []byte(rule.OifName)))
|
req.AddData(nl.NewRtAttr(nl.FRA_OIFNAME, []byte(rule.OifName+"\x00")))
|
||||||
}
|
}
|
||||||
if rule.Goto >= 0 {
|
if rule.Goto >= 0 {
|
||||||
msg.Type = nl.FR_ACT_GOTO
|
msg.Type = nl.FR_ACT_GOTO
|
||||||
@ -150,6 +154,16 @@ func ruleHandle(rule *Rule, req *nl.NetlinkRequest) error {
|
|||||||
req.AddData(nl.NewRtAttr(nl.FRA_GOTO, b))
|
req.AddData(nl.NewRtAttr(nl.FRA_GOTO, b))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if rule.Dport != nil {
|
||||||
|
b := rule.Dport.toRtAttrData()
|
||||||
|
req.AddData(nl.NewRtAttr(nl.FRA_DPORT_RANGE, b))
|
||||||
|
}
|
||||||
|
|
||||||
|
if rule.Sport != nil {
|
||||||
|
b := rule.Sport.toRtAttrData()
|
||||||
|
req.AddData(nl.NewRtAttr(nl.FRA_SPORT_RANGE, b))
|
||||||
|
}
|
||||||
|
|
||||||
_, err := req.Execute(unix.NETLINK_ROUTE, 0)
|
_, err := req.Execute(unix.NETLINK_ROUTE, 0)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -163,6 +177,19 @@ func RuleList(family int) ([]Rule, error) {
|
|||||||
// RuleList lists rules in the system.
|
// RuleList lists rules in the system.
|
||||||
// Equivalent to: ip rule list
|
// Equivalent to: ip rule list
|
||||||
func (h *Handle) RuleList(family int) ([]Rule, error) {
|
func (h *Handle) RuleList(family int) ([]Rule, error) {
|
||||||
|
return h.RuleListFiltered(family, nil, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RuleListFiltered gets a list of rules in the system filtered by the
|
||||||
|
// specified rule template `filter`.
|
||||||
|
// Equivalent to: ip rule list
|
||||||
|
func RuleListFiltered(family int, filter *Rule, filterMask uint64) ([]Rule, error) {
|
||||||
|
return pkgHandle.RuleListFiltered(family, filter, filterMask)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RuleListFiltered lists rules in the system.
|
||||||
|
// Equivalent to: ip rule list
|
||||||
|
func (h *Handle) RuleListFiltered(family int, filter *Rule, filterMask uint64) ([]Rule, error) {
|
||||||
req := h.newNetlinkRequest(unix.RTM_GETRULE, unix.NLM_F_DUMP|unix.NLM_F_REQUEST)
|
req := h.newNetlinkRequest(unix.RTM_GETRULE, unix.NLM_F_DUMP|unix.NLM_F_REQUEST)
|
||||||
msg := nl.NewIfInfomsg(family)
|
msg := nl.NewIfInfomsg(family)
|
||||||
req.AddData(msg)
|
req.AddData(msg)
|
||||||
@ -184,6 +211,7 @@ func (h *Handle) RuleList(family int) ([]Rule, error) {
|
|||||||
rule := NewRule()
|
rule := NewRule()
|
||||||
|
|
||||||
rule.Invert = msg.Flags&FibRuleInvert > 0
|
rule.Invert = msg.Flags&FibRuleInvert > 0
|
||||||
|
rule.Tos = uint(msg.Tos)
|
||||||
|
|
||||||
for j := range attrs {
|
for j := range attrs {
|
||||||
switch attrs[j].Attr.Type {
|
switch attrs[j].Attr.Type {
|
||||||
@ -225,10 +253,44 @@ func (h *Handle) RuleList(family int) ([]Rule, error) {
|
|||||||
rule.Goto = int(native.Uint32(attrs[j].Value[0:4]))
|
rule.Goto = int(native.Uint32(attrs[j].Value[0:4]))
|
||||||
case nl.FRA_PRIORITY:
|
case nl.FRA_PRIORITY:
|
||||||
rule.Priority = int(native.Uint32(attrs[j].Value[0:4]))
|
rule.Priority = int(native.Uint32(attrs[j].Value[0:4]))
|
||||||
|
case nl.FRA_DPORT_RANGE:
|
||||||
|
rule.Dport = NewRulePortRange(native.Uint16(attrs[j].Value[0:2]), native.Uint16(attrs[j].Value[2:4]))
|
||||||
|
case nl.FRA_SPORT_RANGE:
|
||||||
|
rule.Sport = NewRulePortRange(native.Uint16(attrs[j].Value[0:2]), native.Uint16(attrs[j].Value[2:4]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if filter != nil {
|
||||||
|
switch {
|
||||||
|
case filterMask&RT_FILTER_SRC != 0 &&
|
||||||
|
(rule.Src == nil || rule.Src.String() != filter.Src.String()):
|
||||||
|
continue
|
||||||
|
case filterMask&RT_FILTER_DST != 0 &&
|
||||||
|
(rule.Dst == nil || rule.Dst.String() != filter.Dst.String()):
|
||||||
|
continue
|
||||||
|
case filterMask&RT_FILTER_TABLE != 0 &&
|
||||||
|
filter.Table != unix.RT_TABLE_UNSPEC && rule.Table != filter.Table:
|
||||||
|
continue
|
||||||
|
case filterMask&RT_FILTER_TOS != 0 && rule.Tos != filter.Tos:
|
||||||
|
continue
|
||||||
|
case filterMask&RT_FILTER_PRIORITY != 0 && rule.Priority != filter.Priority:
|
||||||
|
continue
|
||||||
|
case filterMask&RT_FILTER_MARK != 0 && rule.Mark != filter.Mark:
|
||||||
|
continue
|
||||||
|
case filterMask&RT_FILTER_MASK != 0 && rule.Mask != filter.Mask:
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
res = append(res, *rule)
|
res = append(res, *rule)
|
||||||
}
|
}
|
||||||
|
|
||||||
return res, nil
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (pr *RulePortRange) toRtAttrData() []byte {
|
||||||
|
b := [][]byte{make([]byte, 2), make([]byte, 2)}
|
||||||
|
native.PutUint16(b[0], pr.Start)
|
||||||
|
native.PutUint16(b[1], pr.End)
|
||||||
|
return bytes.Join(b, []byte{})
|
||||||
|
}
|
||||||
|
76
vendor/github.com/vishvananda/netlink/socket_linux.go
generated
vendored
76
vendor/github.com/vishvananda/netlink/socket_linux.go
generated
vendored
@ -4,6 +4,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
"github.com/vishvananda/netlink/nl"
|
"github.com/vishvananda/netlink/nl"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
@ -49,10 +50,15 @@ func (r *socketRequest) Serialize() []byte {
|
|||||||
native.PutUint32(b.Next(4), r.States)
|
native.PutUint32(b.Next(4), r.States)
|
||||||
networkOrder.PutUint16(b.Next(2), r.ID.SourcePort)
|
networkOrder.PutUint16(b.Next(2), r.ID.SourcePort)
|
||||||
networkOrder.PutUint16(b.Next(2), r.ID.DestinationPort)
|
networkOrder.PutUint16(b.Next(2), r.ID.DestinationPort)
|
||||||
|
if r.Family == unix.AF_INET6 {
|
||||||
|
copy(b.Next(16), r.ID.Source)
|
||||||
|
copy(b.Next(16), r.ID.Destination)
|
||||||
|
} else {
|
||||||
copy(b.Next(4), r.ID.Source.To4())
|
copy(b.Next(4), r.ID.Source.To4())
|
||||||
b.Next(12)
|
b.Next(12)
|
||||||
copy(b.Next(4), r.ID.Destination.To4())
|
copy(b.Next(4), r.ID.Destination.To4())
|
||||||
b.Next(12)
|
b.Next(12)
|
||||||
|
}
|
||||||
native.PutUint32(b.Next(4), r.ID.Interface)
|
native.PutUint32(b.Next(4), r.ID.Interface)
|
||||||
native.PutUint32(b.Next(4), r.ID.Cookie[0])
|
native.PutUint32(b.Next(4), r.ID.Cookie[0])
|
||||||
native.PutUint32(b.Next(4), r.ID.Cookie[1])
|
native.PutUint32(b.Next(4), r.ID.Cookie[1])
|
||||||
@ -89,10 +95,15 @@ func (s *Socket) deserialize(b []byte) error {
|
|||||||
s.Retrans = rb.Read()
|
s.Retrans = rb.Read()
|
||||||
s.ID.SourcePort = networkOrder.Uint16(rb.Next(2))
|
s.ID.SourcePort = networkOrder.Uint16(rb.Next(2))
|
||||||
s.ID.DestinationPort = networkOrder.Uint16(rb.Next(2))
|
s.ID.DestinationPort = networkOrder.Uint16(rb.Next(2))
|
||||||
|
if s.Family == unix.AF_INET6 {
|
||||||
|
s.ID.Source = net.IP(rb.Next(16))
|
||||||
|
s.ID.Destination = net.IP(rb.Next(16))
|
||||||
|
} else {
|
||||||
s.ID.Source = net.IPv4(rb.Read(), rb.Read(), rb.Read(), rb.Read())
|
s.ID.Source = net.IPv4(rb.Read(), rb.Read(), rb.Read(), rb.Read())
|
||||||
rb.Next(12)
|
rb.Next(12)
|
||||||
s.ID.Destination = net.IPv4(rb.Read(), rb.Read(), rb.Read(), rb.Read())
|
s.ID.Destination = net.IPv4(rb.Read(), rb.Read(), rb.Read(), rb.Read())
|
||||||
rb.Next(12)
|
rb.Next(12)
|
||||||
|
}
|
||||||
s.ID.Interface = native.Uint32(rb.Next(4))
|
s.ID.Interface = native.Uint32(rb.Next(4))
|
||||||
s.ID.Cookie[0] = native.Uint32(rb.Next(4))
|
s.ID.Cookie[0] = native.Uint32(rb.Next(4))
|
||||||
s.ID.Cookie[1] = native.Uint32(rb.Next(4))
|
s.ID.Cookie[1] = native.Uint32(rb.Next(4))
|
||||||
@ -160,3 +171,68 @@ func SocketGet(local, remote net.Addr) (*Socket, error) {
|
|||||||
}
|
}
|
||||||
return sock, nil
|
return sock, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SocketDiagTCPInfo requests INET_DIAG_INFO for TCP protocol for specified family type.
|
||||||
|
func SocketDiagTCPInfo(family uint8) ([]*InetDiagTCPInfoResp, error) {
|
||||||
|
s, err := nl.Subscribe(unix.NETLINK_INET_DIAG)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer s.Close()
|
||||||
|
|
||||||
|
req := nl.NewNetlinkRequest(nl.SOCK_DIAG_BY_FAMILY, unix.NLM_F_DUMP)
|
||||||
|
req.AddData(&socketRequest{
|
||||||
|
Family: family,
|
||||||
|
Protocol: unix.IPPROTO_TCP,
|
||||||
|
Ext: INET_DIAG_INFO,
|
||||||
|
States: uint32(0xfff), // All TCP states
|
||||||
|
})
|
||||||
|
s.Send(req)
|
||||||
|
|
||||||
|
var result []*InetDiagTCPInfoResp
|
||||||
|
loop:
|
||||||
|
for {
|
||||||
|
msgs, from, err := s.Receive()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if from.Pid != nl.PidKernel {
|
||||||
|
return nil, fmt.Errorf("Wrong sender portid %d, expected %d", from.Pid, nl.PidKernel)
|
||||||
|
}
|
||||||
|
if len(msgs) == 0 {
|
||||||
|
return nil, errors.New("no message nor error from netlink")
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, m := range msgs {
|
||||||
|
switch m.Header.Type {
|
||||||
|
case unix.NLMSG_DONE:
|
||||||
|
break loop
|
||||||
|
case unix.NLMSG_ERROR:
|
||||||
|
native := nl.NativeEndian()
|
||||||
|
error := int32(native.Uint32(m.Data[0:4]))
|
||||||
|
return nil, syscall.Errno(-error)
|
||||||
|
}
|
||||||
|
sockInfo := &Socket{}
|
||||||
|
if err := sockInfo.deserialize(m.Data); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
attrs, err := nl.ParseRouteAttr(m.Data[sizeofSocket:])
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var tcpInfo *TCPInfo
|
||||||
|
for _, a := range attrs {
|
||||||
|
if a.Attr.Type == INET_DIAG_INFO {
|
||||||
|
tcpInfo = &TCPInfo{}
|
||||||
|
if err := tcpInfo.deserialize(a.Value); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
r := &InetDiagTCPInfoResp{InetDiagMsg: sockInfo, TCPInfo: tcpInfo}
|
||||||
|
result = append(result, r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
18
vendor/github.com/vishvananda/netlink/tcp.go
generated
vendored
Normal file
18
vendor/github.com/vishvananda/netlink/tcp.go
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
package netlink
|
||||||
|
|
||||||
|
// TCP States
|
||||||
|
const (
|
||||||
|
TCP_ESTABLISHED = iota + 0x01
|
||||||
|
TCP_SYN_SENT
|
||||||
|
TCP_SYN_RECV
|
||||||
|
TCP_FIN_WAIT1
|
||||||
|
TCP_FIN_WAIT2
|
||||||
|
TCP_TIME_WAIT
|
||||||
|
TCP_CLOSE
|
||||||
|
TCP_CLOSE_WAIT
|
||||||
|
TCP_LAST_ACK
|
||||||
|
TCP_LISTEN
|
||||||
|
TCP_CLOSING
|
||||||
|
TCP_NEW_SYN_REC
|
||||||
|
TCP_MAX_STATES
|
||||||
|
)
|
393
vendor/github.com/vishvananda/netlink/tcp_linux.go
generated
vendored
Normal file
393
vendor/github.com/vishvananda/netlink/tcp_linux.go
generated
vendored
Normal file
@ -0,0 +1,393 @@
|
|||||||
|
package netlink
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"io"
|
||||||
|
)
|
||||||
|
|
||||||
|
type TCPInfo struct {
|
||||||
|
State uint8
|
||||||
|
Ca_state uint8
|
||||||
|
Retransmits uint8
|
||||||
|
Probes uint8
|
||||||
|
Backoff uint8
|
||||||
|
Options uint8
|
||||||
|
Snd_wscale uint8 // no uint4
|
||||||
|
Rcv_wscale uint8
|
||||||
|
Delivery_rate_app_limited uint8
|
||||||
|
Fastopen_client_fail uint8
|
||||||
|
Rto uint32
|
||||||
|
Ato uint32
|
||||||
|
Snd_mss uint32
|
||||||
|
Rcv_mss uint32
|
||||||
|
Unacked uint32
|
||||||
|
Sacked uint32
|
||||||
|
Lost uint32
|
||||||
|
Retrans uint32
|
||||||
|
Fackets uint32
|
||||||
|
Last_data_sent uint32
|
||||||
|
Last_ack_sent uint32
|
||||||
|
Last_data_recv uint32
|
||||||
|
Last_ack_recv uint32
|
||||||
|
Pmtu uint32
|
||||||
|
Rcv_ssthresh uint32
|
||||||
|
Rtt uint32
|
||||||
|
Rttvar uint32
|
||||||
|
Snd_ssthresh uint32
|
||||||
|
Snd_cwnd uint32
|
||||||
|
Advmss uint32
|
||||||
|
Reordering uint32
|
||||||
|
Rcv_rtt uint32
|
||||||
|
Rcv_space uint32
|
||||||
|
Total_retrans uint32
|
||||||
|
Pacing_rate uint64
|
||||||
|
Max_pacing_rate uint64
|
||||||
|
Bytes_acked uint64 /* RFC4898 tcpEStatsAppHCThruOctetsAcked */
|
||||||
|
Bytes_received uint64 /* RFC4898 tcpEStatsAppHCThruOctetsReceived */
|
||||||
|
Segs_out uint32 /* RFC4898 tcpEStatsPerfSegsOut */
|
||||||
|
Segs_in uint32 /* RFC4898 tcpEStatsPerfSegsIn */
|
||||||
|
Notsent_bytes uint32
|
||||||
|
Min_rtt uint32
|
||||||
|
Data_segs_in uint32 /* RFC4898 tcpEStatsDataSegsIn */
|
||||||
|
Data_segs_out uint32 /* RFC4898 tcpEStatsDataSegsOut */
|
||||||
|
Delivery_rate uint64
|
||||||
|
Busy_time uint64 /* Time (usec) busy sending data */
|
||||||
|
Rwnd_limited uint64 /* Time (usec) limited by receive window */
|
||||||
|
Sndbuf_limited uint64 /* Time (usec) limited by send buffer */
|
||||||
|
Delivered uint32
|
||||||
|
Delivered_ce uint32
|
||||||
|
Bytes_sent uint64 /* RFC4898 tcpEStatsPerfHCDataOctetsOut */
|
||||||
|
Bytes_retrans uint64 /* RFC4898 tcpEStatsPerfOctetsRetrans */
|
||||||
|
Dsack_dups uint32 /* RFC4898 tcpEStatsStackDSACKDups */
|
||||||
|
Reord_seen uint32 /* reordering events seen */
|
||||||
|
Rcv_ooopack uint32 /* Out-of-order packets received */
|
||||||
|
Snd_wnd uint32 /* peer's advertised receive window after * scaling (bytes) */
|
||||||
|
}
|
||||||
|
|
||||||
|
func checkDeserErr(err error) error {
|
||||||
|
if err == io.EOF {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TCPInfo) deserialize(b []byte) error {
|
||||||
|
var err error
|
||||||
|
rb := bytes.NewBuffer(b)
|
||||||
|
|
||||||
|
t.State, err = rb.ReadByte()
|
||||||
|
if err != nil {
|
||||||
|
return checkDeserErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Ca_state, err = rb.ReadByte()
|
||||||
|
if err != nil {
|
||||||
|
return checkDeserErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Retransmits, err = rb.ReadByte()
|
||||||
|
if err != nil {
|
||||||
|
return checkDeserErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Probes, err = rb.ReadByte()
|
||||||
|
if err != nil {
|
||||||
|
return checkDeserErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Backoff, err = rb.ReadByte()
|
||||||
|
if err != nil {
|
||||||
|
return checkDeserErr(err)
|
||||||
|
}
|
||||||
|
t.Options, err = rb.ReadByte()
|
||||||
|
if err != nil {
|
||||||
|
return checkDeserErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
scales, err := rb.ReadByte()
|
||||||
|
if err != nil {
|
||||||
|
return checkDeserErr(err)
|
||||||
|
}
|
||||||
|
t.Snd_wscale = scales >> 4 // first 4 bits
|
||||||
|
t.Rcv_wscale = scales & 0xf // last 4 bits
|
||||||
|
|
||||||
|
rateLimAndFastOpen, err := rb.ReadByte()
|
||||||
|
if err != nil {
|
||||||
|
return checkDeserErr(err)
|
||||||
|
}
|
||||||
|
t.Delivery_rate_app_limited = rateLimAndFastOpen >> 7 // get first bit
|
||||||
|
t.Fastopen_client_fail = rateLimAndFastOpen >> 5 & 3 // get next two bits
|
||||||
|
|
||||||
|
next := rb.Next(4)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Rto = native.Uint32(next)
|
||||||
|
|
||||||
|
next = rb.Next(4)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Ato = native.Uint32(next)
|
||||||
|
|
||||||
|
next = rb.Next(4)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Snd_mss = native.Uint32(next)
|
||||||
|
|
||||||
|
next = rb.Next(4)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Rcv_mss = native.Uint32(next)
|
||||||
|
|
||||||
|
next = rb.Next(4)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Unacked = native.Uint32(next)
|
||||||
|
|
||||||
|
next = rb.Next(4)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Sacked = native.Uint32(next)
|
||||||
|
|
||||||
|
next = rb.Next(4)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Lost = native.Uint32(next)
|
||||||
|
|
||||||
|
next = rb.Next(4)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Retrans = native.Uint32(next)
|
||||||
|
|
||||||
|
next = rb.Next(4)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Fackets = native.Uint32(next)
|
||||||
|
|
||||||
|
next = rb.Next(4)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Last_data_sent = native.Uint32(next)
|
||||||
|
|
||||||
|
next = rb.Next(4)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Last_ack_sent = native.Uint32(next)
|
||||||
|
|
||||||
|
next = rb.Next(4)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Last_data_recv = native.Uint32(next)
|
||||||
|
|
||||||
|
next = rb.Next(4)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Last_ack_recv = native.Uint32(next)
|
||||||
|
|
||||||
|
next = rb.Next(4)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Pmtu = native.Uint32(next)
|
||||||
|
|
||||||
|
next = rb.Next(4)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Rcv_ssthresh = native.Uint32(next)
|
||||||
|
|
||||||
|
next = rb.Next(4)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Rtt = native.Uint32(next)
|
||||||
|
|
||||||
|
next = rb.Next(4)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Rttvar = native.Uint32(next)
|
||||||
|
|
||||||
|
next = rb.Next(4)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Snd_ssthresh = native.Uint32(next)
|
||||||
|
|
||||||
|
next = rb.Next(4)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Snd_cwnd = native.Uint32(next)
|
||||||
|
|
||||||
|
next = rb.Next(4)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Advmss = native.Uint32(next)
|
||||||
|
|
||||||
|
next = rb.Next(4)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Reordering = native.Uint32(next)
|
||||||
|
|
||||||
|
next = rb.Next(4)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Rcv_rtt = native.Uint32(next)
|
||||||
|
|
||||||
|
next = rb.Next(4)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Rcv_space = native.Uint32(next)
|
||||||
|
|
||||||
|
next = rb.Next(4)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Total_retrans = native.Uint32(next)
|
||||||
|
|
||||||
|
next = rb.Next(8)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Pacing_rate = native.Uint64(next)
|
||||||
|
|
||||||
|
next = rb.Next(8)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Max_pacing_rate = native.Uint64(next)
|
||||||
|
|
||||||
|
next = rb.Next(8)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Bytes_acked = native.Uint64(next)
|
||||||
|
|
||||||
|
next = rb.Next(8)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Bytes_received = native.Uint64(next)
|
||||||
|
|
||||||
|
next = rb.Next(4)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Segs_out = native.Uint32(next)
|
||||||
|
|
||||||
|
next = rb.Next(4)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Segs_in = native.Uint32(next)
|
||||||
|
next = rb.Next(4)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Notsent_bytes = native.Uint32(next)
|
||||||
|
next = rb.Next(4)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Min_rtt = native.Uint32(next)
|
||||||
|
next = rb.Next(4)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Data_segs_in = native.Uint32(next)
|
||||||
|
next = rb.Next(4)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Data_segs_out = native.Uint32(next)
|
||||||
|
|
||||||
|
next = rb.Next(8)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Delivery_rate = native.Uint64(next)
|
||||||
|
|
||||||
|
next = rb.Next(8)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Busy_time = native.Uint64(next)
|
||||||
|
|
||||||
|
next = rb.Next(8)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Rwnd_limited = native.Uint64(next)
|
||||||
|
|
||||||
|
next = rb.Next(8)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Sndbuf_limited = native.Uint64(next)
|
||||||
|
|
||||||
|
next = rb.Next(4)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Delivered = native.Uint32(next)
|
||||||
|
|
||||||
|
next = rb.Next(4)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Delivered_ce = native.Uint32(next)
|
||||||
|
|
||||||
|
next = rb.Next(8)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Bytes_sent = native.Uint64(next)
|
||||||
|
|
||||||
|
next = rb.Next(8)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Bytes_retrans = native.Uint64(next)
|
||||||
|
|
||||||
|
next = rb.Next(4)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Dsack_dups = native.Uint32(next)
|
||||||
|
|
||||||
|
next = rb.Next(4)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Reord_seen = native.Uint32(next)
|
||||||
|
|
||||||
|
next = rb.Next(4)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Rcv_ooopack = native.Uint32(next)
|
||||||
|
|
||||||
|
next = rb.Next(4)
|
||||||
|
if len(next) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
t.Snd_wnd = native.Uint32(next)
|
||||||
|
return nil
|
||||||
|
}
|
2
vendor/golang.org/x/sys/unix/asm_aix_ppc64.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_aix_ppc64.s
generated
vendored
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build !gccgo
|
// +build gc
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_darwin_386.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_darwin_386.s
generated
vendored
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build !gccgo
|
// +build gc
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_darwin_amd64.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_darwin_amd64.s
generated
vendored
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build !gccgo
|
// +build gc
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_darwin_arm.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_darwin_arm.s
generated
vendored
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build !gccgo
|
// +build gc
|
||||||
// +build arm,darwin
|
// +build arm,darwin
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_darwin_arm64.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_darwin_arm64.s
generated
vendored
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build !gccgo
|
// +build gc
|
||||||
// +build arm64,darwin
|
// +build arm64,darwin
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s
generated
vendored
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build !gccgo
|
// +build gc
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_freebsd_386.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_freebsd_386.s
generated
vendored
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build !gccgo
|
// +build gc
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s
generated
vendored
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build !gccgo
|
// +build gc
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_freebsd_arm.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_freebsd_arm.s
generated
vendored
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build !gccgo
|
// +build gc
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_freebsd_arm64.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_freebsd_arm64.s
generated
vendored
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build !gccgo
|
// +build gc
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_linux_386.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_linux_386.s
generated
vendored
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build !gccgo
|
// +build gc
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_linux_amd64.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_linux_amd64.s
generated
vendored
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build !gccgo
|
// +build gc
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_linux_arm.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_linux_arm.s
generated
vendored
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build !gccgo
|
// +build gc
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_linux_arm64.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_linux_arm64.s
generated
vendored
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
// +build linux
|
// +build linux
|
||||||
// +build arm64
|
// +build arm64
|
||||||
// +build !gccgo
|
// +build gc
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_linux_mips64x.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_linux_mips64x.s
generated
vendored
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
// +build linux
|
// +build linux
|
||||||
// +build mips64 mips64le
|
// +build mips64 mips64le
|
||||||
// +build !gccgo
|
// +build gc
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_linux_mipsx.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_linux_mipsx.s
generated
vendored
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
// +build linux
|
// +build linux
|
||||||
// +build mips mipsle
|
// +build mips mipsle
|
||||||
// +build !gccgo
|
// +build gc
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s
generated
vendored
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
// +build linux
|
// +build linux
|
||||||
// +build ppc64 ppc64le
|
// +build ppc64 ppc64le
|
||||||
// +build !gccgo
|
// +build gc
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_linux_riscv64.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_linux_riscv64.s
generated
vendored
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build riscv64,!gccgo
|
// +build riscv64,gc
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_linux_s390x.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_linux_s390x.s
generated
vendored
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
// +build s390x
|
// +build s390x
|
||||||
// +build linux
|
// +build linux
|
||||||
// +build !gccgo
|
// +build gc
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_netbsd_386.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_netbsd_386.s
generated
vendored
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build !gccgo
|
// +build gc
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s
generated
vendored
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build !gccgo
|
// +build gc
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_netbsd_arm.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_netbsd_arm.s
generated
vendored
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build !gccgo
|
// +build gc
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_netbsd_arm64.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_netbsd_arm64.s
generated
vendored
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build !gccgo
|
// +build gc
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_openbsd_386.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_openbsd_386.s
generated
vendored
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build !gccgo
|
// +build gc
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s
generated
vendored
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build !gccgo
|
// +build gc
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_openbsd_arm.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_openbsd_arm.s
generated
vendored
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build !gccgo
|
// +build gc
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_openbsd_arm64.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_openbsd_arm64.s
generated
vendored
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build !gccgo
|
// +build gc
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_openbsd_mips64.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_openbsd_mips64.s
generated
vendored
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build !gccgo
|
// +build gc
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/asm_solaris_amd64.s
generated
vendored
2
vendor/golang.org/x/sys/unix/asm_solaris_amd64.s
generated
vendored
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build !gccgo
|
// +build gc
|
||||||
|
|
||||||
#include "textflag.h"
|
#include "textflag.h"
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/endian_big.go
generated
vendored
2
vendor/golang.org/x/sys/unix/endian_big.go
generated
vendored
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
//
|
//
|
||||||
// +build ppc64 s390x mips mips64
|
// +build armbe arm64be m68k mips mips64 mips64p32 ppc ppc64 s390 s390x shbe sparc sparc64
|
||||||
|
|
||||||
package unix
|
package unix
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/endian_little.go
generated
vendored
2
vendor/golang.org/x/sys/unix/endian_little.go
generated
vendored
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
//
|
//
|
||||||
// +build 386 amd64 amd64p32 arm arm64 ppc64le mipsle mips64le riscv64
|
// +build 386 amd64 amd64p32 alpha arm arm64 mipsle mips64le mips64p32le nios2 ppc64le riscv riscv64 sh
|
||||||
|
|
||||||
package unix
|
package unix
|
||||||
|
|
||||||
|
6
vendor/golang.org/x/sys/unix/fcntl_darwin.go
generated
vendored
6
vendor/golang.org/x/sys/unix/fcntl_darwin.go
generated
vendored
@ -16,3 +16,9 @@ func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
|
|||||||
_, err := fcntl(int(fd), cmd, int(uintptr(unsafe.Pointer(lk))))
|
_, err := fcntl(int(fd), cmd, int(uintptr(unsafe.Pointer(lk))))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FcntlFstore performs a fcntl syscall for the F_PREALLOCATE command.
|
||||||
|
func FcntlFstore(fd uintptr, cmd int, fstore *Fstore_t) error {
|
||||||
|
_, err := fcntl(int(fd), cmd, int(uintptr(unsafe.Pointer(fstore))))
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
4
vendor/golang.org/x/sys/unix/fcntl_linux_32bit.go
generated
vendored
4
vendor/golang.org/x/sys/unix/fcntl_linux_32bit.go
generated
vendored
@ -1,9 +1,9 @@
|
|||||||
// +build linux,386 linux,arm linux,mips linux,mipsle
|
|
||||||
|
|
||||||
// Copyright 2014 The Go Authors. All rights reserved.
|
// Copyright 2014 The Go Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build linux,386 linux,arm linux,mips linux,mipsle
|
||||||
|
|
||||||
package unix
|
package unix
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
2
vendor/golang.org/x/sys/unix/gccgo.go
generated
vendored
2
vendor/golang.org/x/sys/unix/gccgo.go
generated
vendored
@ -12,10 +12,8 @@ import "syscall"
|
|||||||
// We can't use the gc-syntax .s files for gccgo. On the plus side
|
// We can't use the gc-syntax .s files for gccgo. On the plus side
|
||||||
// much of the functionality can be written directly in Go.
|
// much of the functionality can be written directly in Go.
|
||||||
|
|
||||||
//extern gccgoRealSyscallNoError
|
|
||||||
func realSyscallNoError(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r uintptr)
|
func realSyscallNoError(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r uintptr)
|
||||||
|
|
||||||
//extern gccgoRealSyscall
|
|
||||||
func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr)
|
func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr)
|
||||||
|
|
||||||
func SyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) {
|
func SyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) {
|
||||||
|
6
vendor/golang.org/x/sys/unix/gccgo_c.c
generated
vendored
6
vendor/golang.org/x/sys/unix/gccgo_c.c
generated
vendored
@ -21,6 +21,9 @@ struct ret {
|
|||||||
uintptr_t err;
|
uintptr_t err;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ret gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9)
|
||||||
|
__asm__(GOSYM_PREFIX GOPKGPATH ".realSyscall");
|
||||||
|
|
||||||
struct ret
|
struct ret
|
||||||
gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9)
|
gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9)
|
||||||
{
|
{
|
||||||
@ -32,6 +35,9 @@ gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintp
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uintptr_t gccgoRealSyscallNoError(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9)
|
||||||
|
__asm__(GOSYM_PREFIX GOPKGPATH ".realSyscallNoError");
|
||||||
|
|
||||||
uintptr_t
|
uintptr_t
|
||||||
gccgoRealSyscallNoError(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9)
|
gccgoRealSyscallNoError(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9)
|
||||||
{
|
{
|
||||||
|
13
vendor/golang.org/x/sys/unix/mkerrors.sh
generated
vendored
13
vendor/golang.org/x/sys/unix/mkerrors.sh
generated
vendored
@ -58,12 +58,15 @@ includes_Darwin='
|
|||||||
#define _DARWIN_USE_64_BIT_INODE
|
#define _DARWIN_USE_64_BIT_INODE
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <sys/attr.h>
|
#include <sys/attr.h>
|
||||||
|
#include <sys/clonefile.h>
|
||||||
|
#include <sys/kern_control.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/event.h>
|
#include <sys/event.h>
|
||||||
#include <sys/ptrace.h>
|
#include <sys/ptrace.h>
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/sockio.h>
|
#include <sys/sockio.h>
|
||||||
|
#include <sys/sys_domain.h>
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
@ -93,6 +96,7 @@ includes_DragonFly='
|
|||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <net/bpf.h>
|
#include <net/bpf.h>
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
|
#include <net/if_clone.h>
|
||||||
#include <net/if_types.h>
|
#include <net/if_types.h>
|
||||||
#include <net/route.h>
|
#include <net/route.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
@ -229,6 +233,7 @@ struct ltchars {
|
|||||||
#include <linux/net_namespace.h>
|
#include <linux/net_namespace.h>
|
||||||
#include <linux/nsfs.h>
|
#include <linux/nsfs.h>
|
||||||
#include <linux/perf_event.h>
|
#include <linux/perf_event.h>
|
||||||
|
#include <linux/pps.h>
|
||||||
#include <linux/ptrace.h>
|
#include <linux/ptrace.h>
|
||||||
#include <linux/random.h>
|
#include <linux/random.h>
|
||||||
#include <linux/reboot.h>
|
#include <linux/reboot.h>
|
||||||
@ -371,6 +376,7 @@ includes_SunOS='
|
|||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/sockio.h>
|
#include <sys/sockio.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <sys/stream.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
@ -495,6 +501,7 @@ ccflags="$@"
|
|||||||
$2 !~ "NLA_TYPE_MASK" &&
|
$2 !~ "NLA_TYPE_MASK" &&
|
||||||
$2 !~ /^RTC_VL_(ACCURACY|BACKUP|DATA)/ &&
|
$2 !~ /^RTC_VL_(ACCURACY|BACKUP|DATA)/ &&
|
||||||
$2 ~ /^(NETLINK|NLM|NLMSG|NLA|IFA|IFAN|RT|RTC|RTCF|RTN|RTPROT|RTNH|ARPHRD|ETH_P|NETNSA)_/ ||
|
$2 ~ /^(NETLINK|NLM|NLMSG|NLA|IFA|IFAN|RT|RTC|RTCF|RTN|RTPROT|RTNH|ARPHRD|ETH_P|NETNSA)_/ ||
|
||||||
|
$2 ~ /^FIORDCHK$/ ||
|
||||||
$2 ~ /^SIOC/ ||
|
$2 ~ /^SIOC/ ||
|
||||||
$2 ~ /^TIOC/ ||
|
$2 ~ /^TIOC/ ||
|
||||||
$2 ~ /^TCGET/ ||
|
$2 ~ /^TCGET/ ||
|
||||||
@ -515,7 +522,9 @@ ccflags="$@"
|
|||||||
$2 ~ /^CAP_/ ||
|
$2 ~ /^CAP_/ ||
|
||||||
$2 ~ /^CP_/ ||
|
$2 ~ /^CP_/ ||
|
||||||
$2 ~ /^CPUSTATES$/ ||
|
$2 ~ /^CPUSTATES$/ ||
|
||||||
|
$2 ~ /^CTLIOCGINFO$/ ||
|
||||||
$2 ~ /^ALG_/ ||
|
$2 ~ /^ALG_/ ||
|
||||||
|
$2 ~ /^FI(CLONE|DEDUPERANGE)/ ||
|
||||||
$2 ~ /^FS_(POLICY_FLAGS|KEY_DESC|ENCRYPTION_MODE|[A-Z0-9_]+_KEY_SIZE)/ ||
|
$2 ~ /^FS_(POLICY_FLAGS|KEY_DESC|ENCRYPTION_MODE|[A-Z0-9_]+_KEY_SIZE)/ ||
|
||||||
$2 ~ /^FS_IOC_.*(ENCRYPTION|VERITY|[GS]ETFLAGS)/ ||
|
$2 ~ /^FS_IOC_.*(ENCRYPTION|VERITY|[GS]ETFLAGS)/ ||
|
||||||
$2 ~ /^FS_VERITY_/ ||
|
$2 ~ /^FS_VERITY_/ ||
|
||||||
@ -525,7 +534,7 @@ ccflags="$@"
|
|||||||
$2 ~ /^RND/ ||
|
$2 ~ /^RND/ ||
|
||||||
$2 ~ /^KEY_(SPEC|REQKEY_DEFL)_/ ||
|
$2 ~ /^KEY_(SPEC|REQKEY_DEFL)_/ ||
|
||||||
$2 ~ /^KEYCTL_/ ||
|
$2 ~ /^KEYCTL_/ ||
|
||||||
$2 ~ /^PERF_EVENT_IOC_/ ||
|
$2 ~ /^PERF_/ ||
|
||||||
$2 ~ /^SECCOMP_MODE_/ ||
|
$2 ~ /^SECCOMP_MODE_/ ||
|
||||||
$2 ~ /^SPLICE_/ ||
|
$2 ~ /^SPLICE_/ ||
|
||||||
$2 ~ /^SYNC_FILE_RANGE_/ ||
|
$2 ~ /^SYNC_FILE_RANGE_/ ||
|
||||||
@ -544,7 +553,7 @@ ccflags="$@"
|
|||||||
$2 ~ /^XATTR_(CREATE|REPLACE|NO(DEFAULT|FOLLOW|SECURITY)|SHOWCOMPRESSION)/ ||
|
$2 ~ /^XATTR_(CREATE|REPLACE|NO(DEFAULT|FOLLOW|SECURITY)|SHOWCOMPRESSION)/ ||
|
||||||
$2 ~ /^ATTR_(BIT_MAP_COUNT|(CMN|VOL|FILE)_)/ ||
|
$2 ~ /^ATTR_(BIT_MAP_COUNT|(CMN|VOL|FILE)_)/ ||
|
||||||
$2 ~ /^FSOPT_/ ||
|
$2 ~ /^FSOPT_/ ||
|
||||||
$2 ~ /^WDIOC_/ ||
|
$2 ~ /^WDIO[CFS]_/ ||
|
||||||
$2 ~ /^NFN/ ||
|
$2 ~ /^NFN/ ||
|
||||||
$2 ~ /^XDP_/ ||
|
$2 ~ /^XDP_/ ||
|
||||||
$2 ~ /^RWF_/ ||
|
$2 ~ /^RWF_/ ||
|
||||||
|
6
vendor/golang.org/x/sys/unix/sockcmsg_unix_other.go
generated
vendored
6
vendor/golang.org/x/sys/unix/sockcmsg_unix_other.go
generated
vendored
@ -20,7 +20,7 @@ func cmsgAlignOf(salen int) int {
|
|||||||
case "aix":
|
case "aix":
|
||||||
// There is no alignment on AIX.
|
// There is no alignment on AIX.
|
||||||
salign = 1
|
salign = 1
|
||||||
case "darwin", "illumos", "solaris":
|
case "darwin", "ios", "illumos", "solaris":
|
||||||
// NOTE: It seems like 64-bit Darwin, Illumos and Solaris
|
// NOTE: It seems like 64-bit Darwin, Illumos and Solaris
|
||||||
// kernels still require 32-bit aligned access to network
|
// kernels still require 32-bit aligned access to network
|
||||||
// subsystem.
|
// subsystem.
|
||||||
@ -32,6 +32,10 @@ func cmsgAlignOf(salen int) int {
|
|||||||
if runtime.GOARCH == "arm" {
|
if runtime.GOARCH == "arm" {
|
||||||
salign = 8
|
salign = 8
|
||||||
}
|
}
|
||||||
|
// NetBSD aarch64 requires 128-bit alignment.
|
||||||
|
if runtime.GOOS == "netbsd" && runtime.GOARCH == "arm64" {
|
||||||
|
salign = 16
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (salen + salign - 1) & ^(salign - 1)
|
return (salen + salign - 1) & ^(salign - 1)
|
||||||
|
43
vendor/golang.org/x/sys/unix/syscall.go
generated
vendored
43
vendor/golang.org/x/sys/unix/syscall.go
generated
vendored
@ -24,7 +24,13 @@
|
|||||||
// holds a value of type syscall.Errno.
|
// holds a value of type syscall.Errno.
|
||||||
package unix // import "golang.org/x/sys/unix"
|
package unix // import "golang.org/x/sys/unix"
|
||||||
|
|
||||||
import "strings"
|
import (
|
||||||
|
"bytes"
|
||||||
|
"strings"
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
|
"golang.org/x/sys/internal/unsafeheader"
|
||||||
|
)
|
||||||
|
|
||||||
// ByteSliceFromString returns a NUL-terminated slice of bytes
|
// ByteSliceFromString returns a NUL-terminated slice of bytes
|
||||||
// containing the text of s. If s contains a NUL byte at any
|
// containing the text of s. If s contains a NUL byte at any
|
||||||
@ -49,5 +55,40 @@ func BytePtrFromString(s string) (*byte, error) {
|
|||||||
return &a[0], nil
|
return &a[0], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ByteSliceToString returns a string form of the text represented by the slice s, with a terminating NUL and any
|
||||||
|
// bytes after the NUL removed.
|
||||||
|
func ByteSliceToString(s []byte) string {
|
||||||
|
if i := bytes.IndexByte(s, 0); i != -1 {
|
||||||
|
s = s[:i]
|
||||||
|
}
|
||||||
|
return string(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// BytePtrToString takes a pointer to a sequence of text and returns the corresponding string.
|
||||||
|
// If the pointer is nil, it returns the empty string. It assumes that the text sequence is terminated
|
||||||
|
// at a zero byte; if the zero byte is not present, the program may crash.
|
||||||
|
func BytePtrToString(p *byte) string {
|
||||||
|
if p == nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
if *p == 0 {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find NUL terminator.
|
||||||
|
n := 0
|
||||||
|
for ptr := unsafe.Pointer(p); *(*byte)(ptr) != 0; n++ {
|
||||||
|
ptr = unsafe.Pointer(uintptr(ptr) + 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
var s []byte
|
||||||
|
h := (*unsafeheader.Slice)(unsafe.Pointer(&s))
|
||||||
|
h.Data = unsafe.Pointer(p)
|
||||||
|
h.Len = n
|
||||||
|
h.Cap = n
|
||||||
|
|
||||||
|
return string(s)
|
||||||
|
}
|
||||||
|
|
||||||
// Single-word zero for use when we need a valid pointer to 0 bytes.
|
// Single-word zero for use when we need a valid pointer to 0 bytes.
|
||||||
var _zero uintptr
|
var _zero uintptr
|
||||||
|
16
vendor/golang.org/x/sys/unix/syscall_aix.go
generated
vendored
16
vendor/golang.org/x/sys/unix/syscall_aix.go
generated
vendored
@ -19,6 +19,22 @@ import "unsafe"
|
|||||||
* Wrapped
|
* Wrapped
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
func Access(path string, mode uint32) (err error) {
|
||||||
|
return Faccessat(AT_FDCWD, path, mode, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Chmod(path string, mode uint32) (err error) {
|
||||||
|
return Fchmodat(AT_FDCWD, path, mode, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Chown(path string, uid int, gid int) (err error) {
|
||||||
|
return Fchownat(AT_FDCWD, path, uid, gid, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Creat(path string, mode uint32) (fd int, err error) {
|
||||||
|
return Open(path, O_CREAT|O_WRONLY|O_TRUNC, mode)
|
||||||
|
}
|
||||||
|
|
||||||
//sys utimes(path string, times *[2]Timeval) (err error)
|
//sys utimes(path string, times *[2]Timeval) (err error)
|
||||||
func Utimes(path string, tv []Timeval) error {
|
func Utimes(path string, tv []Timeval) error {
|
||||||
if len(tv) != 2 {
|
if len(tv) != 2 {
|
||||||
|
19
vendor/golang.org/x/sys/unix/syscall_bsd.go
generated
vendored
19
vendor/golang.org/x/sys/unix/syscall_bsd.go
generated
vendored
@ -18,6 +18,21 @@ import (
|
|||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const ImplementsGetwd = true
|
||||||
|
|
||||||
|
func Getwd() (string, error) {
|
||||||
|
var buf [PathMax]byte
|
||||||
|
_, err := Getcwd(buf[0:])
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
n := clen(buf[:])
|
||||||
|
if n < 1 {
|
||||||
|
return "", EINVAL
|
||||||
|
}
|
||||||
|
return string(buf[:n]), nil
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Wrapped
|
* Wrapped
|
||||||
*/
|
*/
|
||||||
@ -262,7 +277,7 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) {
|
|||||||
}
|
}
|
||||||
return sa, nil
|
return sa, nil
|
||||||
}
|
}
|
||||||
return nil, EAFNOSUPPORT
|
return anyToSockaddrGOOS(fd, rsa)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Accept(fd int) (nfd int, sa Sockaddr, err error) {
|
func Accept(fd int) (nfd int, sa Sockaddr, err error) {
|
||||||
@ -272,7 +287,7 @@ func Accept(fd int) (nfd int, sa Sockaddr, err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if runtime.GOOS == "darwin" && len == 0 {
|
if (runtime.GOOS == "darwin" || runtime.GOOS == "ios") && len == 0 {
|
||||||
// Accepted socket has no address.
|
// Accepted socket has no address.
|
||||||
// This is likely due to a bug in xnu kernels,
|
// This is likely due to a bug in xnu kernels,
|
||||||
// where instead of ECONNABORTED error socket
|
// where instead of ECONNABORTED error socket
|
||||||
|
138
vendor/golang.org/x/sys/unix/syscall_darwin.go
generated
vendored
138
vendor/golang.org/x/sys/unix/syscall_darwin.go
generated
vendored
@ -13,29 +13,11 @@
|
|||||||
package unix
|
package unix
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"runtime"
|
||||||
"syscall"
|
"syscall"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
const ImplementsGetwd = true
|
|
||||||
|
|
||||||
func Getwd() (string, error) {
|
|
||||||
buf := make([]byte, 2048)
|
|
||||||
attrs, err := getAttrList(".", attrList{CommonAttr: attrCmnFullpath}, buf, 0)
|
|
||||||
if err == nil && len(attrs) == 1 && len(attrs[0]) >= 2 {
|
|
||||||
wd := string(attrs[0])
|
|
||||||
// Sanity check that it's an absolute path and ends
|
|
||||||
// in a null byte, which we then strip.
|
|
||||||
if wd[0] == '/' && wd[len(wd)-1] == 0 {
|
|
||||||
return wd[:len(wd)-1], nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// If pkg/os/getwd.go gets ENOTSUP, it will fall back to the
|
|
||||||
// slow algorithm.
|
|
||||||
return "", ENOTSUP
|
|
||||||
}
|
|
||||||
|
|
||||||
// SockaddrDatalink implements the Sockaddr interface for AF_LINK type sockets.
|
// SockaddrDatalink implements the Sockaddr interface for AF_LINK type sockets.
|
||||||
type SockaddrDatalink struct {
|
type SockaddrDatalink struct {
|
||||||
Len uint8
|
Len uint8
|
||||||
@ -49,10 +31,40 @@ type SockaddrDatalink struct {
|
|||||||
raw RawSockaddrDatalink
|
raw RawSockaddrDatalink
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SockaddrCtl implements the Sockaddr interface for AF_SYSTEM type sockets.
|
||||||
|
type SockaddrCtl struct {
|
||||||
|
ID uint32
|
||||||
|
Unit uint32
|
||||||
|
raw RawSockaddrCtl
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sa *SockaddrCtl) sockaddr() (unsafe.Pointer, _Socklen, error) {
|
||||||
|
sa.raw.Sc_len = SizeofSockaddrCtl
|
||||||
|
sa.raw.Sc_family = AF_SYSTEM
|
||||||
|
sa.raw.Ss_sysaddr = AF_SYS_CONTROL
|
||||||
|
sa.raw.Sc_id = sa.ID
|
||||||
|
sa.raw.Sc_unit = sa.Unit
|
||||||
|
return unsafe.Pointer(&sa.raw), SizeofSockaddrCtl, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func anyToSockaddrGOOS(fd int, rsa *RawSockaddrAny) (Sockaddr, error) {
|
||||||
|
switch rsa.Addr.Family {
|
||||||
|
case AF_SYSTEM:
|
||||||
|
pp := (*RawSockaddrCtl)(unsafe.Pointer(rsa))
|
||||||
|
if pp.Ss_sysaddr == AF_SYS_CONTROL {
|
||||||
|
sa := new(SockaddrCtl)
|
||||||
|
sa.ID = pp.Sc_id
|
||||||
|
sa.Unit = pp.Sc_unit
|
||||||
|
return sa, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil, EAFNOSUPPORT
|
||||||
|
}
|
||||||
|
|
||||||
// Some external packages rely on SYS___SYSCTL being defined to implement their
|
// Some external packages rely on SYS___SYSCTL being defined to implement their
|
||||||
// own sysctl wrappers. Provide it here, even though direct syscalls are no
|
// own sysctl wrappers. Provide it here, even though direct syscalls are no
|
||||||
// longer supported on darwin.
|
// longer supported on darwin.
|
||||||
const SYS___SYSCTL = 202
|
const SYS___SYSCTL = SYS_SYSCTL
|
||||||
|
|
||||||
// Translate "kern.hostname" to []_C_int{0,1,2,3}.
|
// Translate "kern.hostname" to []_C_int{0,1,2,3}.
|
||||||
func nametomib(name string) (mib []_C_int, err error) {
|
func nametomib(name string) (mib []_C_int, err error) {
|
||||||
@ -97,11 +109,6 @@ func direntNamlen(buf []byte) (uint64, bool) {
|
|||||||
func PtraceAttach(pid int) (err error) { return ptrace(PT_ATTACH, pid, 0, 0) }
|
func PtraceAttach(pid int) (err error) { return ptrace(PT_ATTACH, pid, 0, 0) }
|
||||||
func PtraceDetach(pid int) (err error) { return ptrace(PT_DETACH, pid, 0, 0) }
|
func PtraceDetach(pid int) (err error) { return ptrace(PT_DETACH, pid, 0, 0) }
|
||||||
|
|
||||||
const (
|
|
||||||
attrBitMapCount = 5
|
|
||||||
attrCmnFullpath = 0x08000000
|
|
||||||
)
|
|
||||||
|
|
||||||
type attrList struct {
|
type attrList struct {
|
||||||
bitmapCount uint16
|
bitmapCount uint16
|
||||||
_ uint16
|
_ uint16
|
||||||
@ -112,54 +119,6 @@ type attrList struct {
|
|||||||
Forkattr uint32
|
Forkattr uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
func getAttrList(path string, attrList attrList, attrBuf []byte, options uint) (attrs [][]byte, err error) {
|
|
||||||
if len(attrBuf) < 4 {
|
|
||||||
return nil, errors.New("attrBuf too small")
|
|
||||||
}
|
|
||||||
attrList.bitmapCount = attrBitMapCount
|
|
||||||
|
|
||||||
var _p0 *byte
|
|
||||||
_p0, err = BytePtrFromString(path)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := getattrlist(_p0, unsafe.Pointer(&attrList), unsafe.Pointer(&attrBuf[0]), uintptr(len(attrBuf)), int(options)); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
size := *(*uint32)(unsafe.Pointer(&attrBuf[0]))
|
|
||||||
|
|
||||||
// dat is the section of attrBuf that contains valid data,
|
|
||||||
// without the 4 byte length header. All attribute offsets
|
|
||||||
// are relative to dat.
|
|
||||||
dat := attrBuf
|
|
||||||
if int(size) < len(attrBuf) {
|
|
||||||
dat = dat[:size]
|
|
||||||
}
|
|
||||||
dat = dat[4:] // remove length prefix
|
|
||||||
|
|
||||||
for i := uint32(0); int(i) < len(dat); {
|
|
||||||
header := dat[i:]
|
|
||||||
if len(header) < 8 {
|
|
||||||
return attrs, errors.New("truncated attribute header")
|
|
||||||
}
|
|
||||||
datOff := *(*int32)(unsafe.Pointer(&header[0]))
|
|
||||||
attrLen := *(*uint32)(unsafe.Pointer(&header[4]))
|
|
||||||
if datOff < 0 || uint32(datOff)+attrLen > uint32(len(dat)) {
|
|
||||||
return attrs, errors.New("truncated results; attrBuf too small")
|
|
||||||
}
|
|
||||||
end := uint32(datOff) + attrLen
|
|
||||||
attrs = append(attrs, dat[datOff:end])
|
|
||||||
i = end
|
|
||||||
if r := i % 4; r != 0 {
|
|
||||||
i += (4 - r)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
//sys getattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error)
|
|
||||||
|
|
||||||
//sysnb pipe() (r int, w int, err error)
|
//sysnb pipe() (r int, w int, err error)
|
||||||
|
|
||||||
func Pipe(p []int) (err error) {
|
func Pipe(p []int) (err error) {
|
||||||
@ -329,6 +288,35 @@ func Kill(pid int, signum syscall.Signal) (err error) { return kill(pid, int(sig
|
|||||||
|
|
||||||
//sys ioctl(fd int, req uint, arg uintptr) (err error)
|
//sys ioctl(fd int, req uint, arg uintptr) (err error)
|
||||||
|
|
||||||
|
func IoctlCtlInfo(fd int, ctlInfo *CtlInfo) error {
|
||||||
|
err := ioctl(fd, CTLIOCGINFO, uintptr(unsafe.Pointer(ctlInfo)))
|
||||||
|
runtime.KeepAlive(ctlInfo)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// IfreqMTU is struct ifreq used to get or set a network device's MTU.
|
||||||
|
type IfreqMTU struct {
|
||||||
|
Name [IFNAMSIZ]byte
|
||||||
|
MTU int32
|
||||||
|
}
|
||||||
|
|
||||||
|
// IoctlGetIfreqMTU performs the SIOCGIFMTU ioctl operation on fd to get the MTU
|
||||||
|
// of the network device specified by ifname.
|
||||||
|
func IoctlGetIfreqMTU(fd int, ifname string) (*IfreqMTU, error) {
|
||||||
|
var ifreq IfreqMTU
|
||||||
|
copy(ifreq.Name[:], ifname)
|
||||||
|
err := ioctl(fd, SIOCGIFMTU, uintptr(unsafe.Pointer(&ifreq)))
|
||||||
|
return &ifreq, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// IoctlSetIfreqMTU performs the SIOCSIFMTU ioctl operation on fd to set the MTU
|
||||||
|
// of the network device specified by ifreq.Name.
|
||||||
|
func IoctlSetIfreqMTU(fd int, ifreq *IfreqMTU) error {
|
||||||
|
err := ioctl(fd, SIOCSIFMTU, uintptr(unsafe.Pointer(ifreq)))
|
||||||
|
runtime.KeepAlive(ifreq)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
//sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS_SYSCTL
|
//sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS_SYSCTL
|
||||||
|
|
||||||
func Uname(uname *Utsname) error {
|
func Uname(uname *Utsname) error {
|
||||||
@ -401,6 +389,8 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
|
|||||||
//sys Chroot(path string) (err error)
|
//sys Chroot(path string) (err error)
|
||||||
//sys ClockGettime(clockid int32, time *Timespec) (err error)
|
//sys ClockGettime(clockid int32, time *Timespec) (err error)
|
||||||
//sys Close(fd int) (err error)
|
//sys Close(fd int) (err error)
|
||||||
|
//sys Clonefile(src string, dst string, flags int) (err error)
|
||||||
|
//sys Clonefileat(srcDirfd int, src string, dstDirfd int, dst string, flags int) (err error)
|
||||||
//sys Dup(fd int) (nfd int, err error)
|
//sys Dup(fd int) (nfd int, err error)
|
||||||
//sys Dup2(from int, to int) (err error)
|
//sys Dup2(from int, to int) (err error)
|
||||||
//sys Exchangedata(path1 string, path2 string, options int) (err error)
|
//sys Exchangedata(path1 string, path2 string, options int) (err error)
|
||||||
@ -412,10 +402,12 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e
|
|||||||
//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error)
|
//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error)
|
||||||
//sys Fchown(fd int, uid int, gid int) (err error)
|
//sys Fchown(fd int, uid int, gid int) (err error)
|
||||||
//sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error)
|
//sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error)
|
||||||
|
//sys Fclonefileat(srcDirfd int, dstDirfd int, dst string, flags int) (err error)
|
||||||
//sys Flock(fd int, how int) (err error)
|
//sys Flock(fd int, how int) (err error)
|
||||||
//sys Fpathconf(fd int, name int) (val int, err error)
|
//sys Fpathconf(fd int, name int) (val int, err error)
|
||||||
//sys Fsync(fd int) (err error)
|
//sys Fsync(fd int) (err error)
|
||||||
//sys Ftruncate(fd int, length int64) (err error)
|
//sys Ftruncate(fd int, length int64) (err error)
|
||||||
|
//sys Getcwd(buf []byte) (n int, err error)
|
||||||
//sys Getdtablesize() (size int)
|
//sys Getdtablesize() (size int)
|
||||||
//sysnb Getegid() (egid int)
|
//sysnb Getegid() (egid int)
|
||||||
//sysnb Geteuid() (uid int)
|
//sysnb Geteuid() (uid int)
|
||||||
|
7
vendor/golang.org/x/sys/unix/syscall_darwin_386.go
generated
vendored
7
vendor/golang.org/x/sys/unix/syscall_darwin_386.go
generated
vendored
@ -6,11 +6,7 @@
|
|||||||
|
|
||||||
package unix
|
package unix
|
||||||
|
|
||||||
import (
|
import "syscall"
|
||||||
"syscall"
|
|
||||||
)
|
|
||||||
|
|
||||||
//sys ptrace(request int, pid int, addr uintptr, data uintptr) (err error)
|
|
||||||
|
|
||||||
func setTimespec(sec, nsec int64) Timespec {
|
func setTimespec(sec, nsec int64) Timespec {
|
||||||
return Timespec{Sec: int32(sec), Nsec: int32(nsec)}
|
return Timespec{Sec: int32(sec), Nsec: int32(nsec)}
|
||||||
@ -49,5 +45,6 @@ func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr,
|
|||||||
//sys Fstatfs(fd int, stat *Statfs_t) (err error) = SYS_FSTATFS64
|
//sys Fstatfs(fd int, stat *Statfs_t) (err error) = SYS_FSTATFS64
|
||||||
//sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT64
|
//sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT64
|
||||||
//sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64
|
//sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64
|
||||||
|
//sys ptrace(request int, pid int, addr uintptr, data uintptr) (err error)
|
||||||
//sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64
|
//sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64
|
||||||
//sys Statfs(path string, stat *Statfs_t) (err error) = SYS_STATFS64
|
//sys Statfs(path string, stat *Statfs_t) (err error) = SYS_STATFS64
|
||||||
|
7
vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go
generated
vendored
7
vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go
generated
vendored
@ -6,11 +6,7 @@
|
|||||||
|
|
||||||
package unix
|
package unix
|
||||||
|
|
||||||
import (
|
import "syscall"
|
||||||
"syscall"
|
|
||||||
)
|
|
||||||
|
|
||||||
//sys ptrace(request int, pid int, addr uintptr, data uintptr) (err error)
|
|
||||||
|
|
||||||
func setTimespec(sec, nsec int64) Timespec {
|
func setTimespec(sec, nsec int64) Timespec {
|
||||||
return Timespec{Sec: sec, Nsec: nsec}
|
return Timespec{Sec: sec, Nsec: nsec}
|
||||||
@ -49,5 +45,6 @@ func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr,
|
|||||||
//sys Fstatfs(fd int, stat *Statfs_t) (err error) = SYS_FSTATFS64
|
//sys Fstatfs(fd int, stat *Statfs_t) (err error) = SYS_FSTATFS64
|
||||||
//sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT64
|
//sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT64
|
||||||
//sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64
|
//sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64
|
||||||
|
//sys ptrace(request int, pid int, addr uintptr, data uintptr) (err error)
|
||||||
//sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64
|
//sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64
|
||||||
//sys Statfs(path string, stat *Statfs_t) (err error) = SYS_STATFS64
|
//sys Statfs(path string, stat *Statfs_t) (err error) = SYS_STATFS64
|
||||||
|
4
vendor/golang.org/x/sys/unix/syscall_darwin_arm.go
generated
vendored
4
vendor/golang.org/x/sys/unix/syscall_darwin_arm.go
generated
vendored
@ -4,9 +4,7 @@
|
|||||||
|
|
||||||
package unix
|
package unix
|
||||||
|
|
||||||
import (
|
import "syscall"
|
||||||
"syscall"
|
|
||||||
)
|
|
||||||
|
|
||||||
func ptrace(request int, pid int, addr uintptr, data uintptr) error {
|
func ptrace(request int, pid int, addr uintptr, data uintptr) error {
|
||||||
return ENOTSUP
|
return ENOTSUP
|
||||||
|
9
vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go
generated
vendored
9
vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go
generated
vendored
@ -6,13 +6,7 @@
|
|||||||
|
|
||||||
package unix
|
package unix
|
||||||
|
|
||||||
import (
|
import "syscall"
|
||||||
"syscall"
|
|
||||||
)
|
|
||||||
|
|
||||||
func ptrace(request int, pid int, addr uintptr, data uintptr) error {
|
|
||||||
return ENOTSUP
|
|
||||||
}
|
|
||||||
|
|
||||||
func setTimespec(sec, nsec int64) Timespec {
|
func setTimespec(sec, nsec int64) Timespec {
|
||||||
return Timespec{Sec: sec, Nsec: nsec}
|
return Timespec{Sec: sec, Nsec: nsec}
|
||||||
@ -51,5 +45,6 @@ func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr,
|
|||||||
//sys Fstatfs(fd int, stat *Statfs_t) (err error)
|
//sys Fstatfs(fd int, stat *Statfs_t) (err error)
|
||||||
//sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT
|
//sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT
|
||||||
//sys Lstat(path string, stat *Stat_t) (err error)
|
//sys Lstat(path string, stat *Stat_t) (err error)
|
||||||
|
//sys ptrace(request int, pid int, addr uintptr, data uintptr) (err error)
|
||||||
//sys Stat(path string, stat *Stat_t) (err error)
|
//sys Stat(path string, stat *Stat_t) (err error)
|
||||||
//sys Statfs(path string, stat *Statfs_t) (err error)
|
//sys Statfs(path string, stat *Statfs_t) (err error)
|
||||||
|
19
vendor/golang.org/x/sys/unix/syscall_dragonfly.go
generated
vendored
19
vendor/golang.org/x/sys/unix/syscall_dragonfly.go
generated
vendored
@ -47,6 +47,10 @@ type SockaddrDatalink struct {
|
|||||||
raw RawSockaddrDatalink
|
raw RawSockaddrDatalink
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func anyToSockaddrGOOS(fd int, rsa *RawSockaddrAny) (Sockaddr, error) {
|
||||||
|
return nil, EAFNOSUPPORT
|
||||||
|
}
|
||||||
|
|
||||||
// Translate "kern.hostname" to []_C_int{0,1,2,3}.
|
// Translate "kern.hostname" to []_C_int{0,1,2,3}.
|
||||||
func nametomib(name string) (mib []_C_int, err error) {
|
func nametomib(name string) (mib []_C_int, err error) {
|
||||||
const siz = unsafe.Sizeof(mib[0])
|
const siz = unsafe.Sizeof(mib[0])
|
||||||
@ -129,23 +133,8 @@ func Accept4(fd, flags int) (nfd int, sa Sockaddr, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const ImplementsGetwd = true
|
|
||||||
|
|
||||||
//sys Getcwd(buf []byte) (n int, err error) = SYS___GETCWD
|
//sys Getcwd(buf []byte) (n int, err error) = SYS___GETCWD
|
||||||
|
|
||||||
func Getwd() (string, error) {
|
|
||||||
var buf [PathMax]byte
|
|
||||||
_, err := Getcwd(buf[0:])
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
n := clen(buf[:])
|
|
||||||
if n < 1 {
|
|
||||||
return "", EINVAL
|
|
||||||
}
|
|
||||||
return string(buf[:n]), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
|
func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
|
||||||
var _p0 unsafe.Pointer
|
var _p0 unsafe.Pointer
|
||||||
var bufsize uintptr
|
var bufsize uintptr
|
||||||
|
19
vendor/golang.org/x/sys/unix/syscall_freebsd.go
generated
vendored
19
vendor/golang.org/x/sys/unix/syscall_freebsd.go
generated
vendored
@ -54,6 +54,10 @@ type SockaddrDatalink struct {
|
|||||||
raw RawSockaddrDatalink
|
raw RawSockaddrDatalink
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func anyToSockaddrGOOS(fd int, rsa *RawSockaddrAny) (Sockaddr, error) {
|
||||||
|
return nil, EAFNOSUPPORT
|
||||||
|
}
|
||||||
|
|
||||||
// Translate "kern.hostname" to []_C_int{0,1,2,3}.
|
// Translate "kern.hostname" to []_C_int{0,1,2,3}.
|
||||||
func nametomib(name string) (mib []_C_int, err error) {
|
func nametomib(name string) (mib []_C_int, err error) {
|
||||||
const siz = unsafe.Sizeof(mib[0])
|
const siz = unsafe.Sizeof(mib[0])
|
||||||
@ -140,23 +144,8 @@ func Accept4(fd, flags int) (nfd int, sa Sockaddr, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const ImplementsGetwd = true
|
|
||||||
|
|
||||||
//sys Getcwd(buf []byte) (n int, err error) = SYS___GETCWD
|
//sys Getcwd(buf []byte) (n int, err error) = SYS___GETCWD
|
||||||
|
|
||||||
func Getwd() (string, error) {
|
|
||||||
var buf [PathMax]byte
|
|
||||||
_, err := Getcwd(buf[0:])
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
n := clen(buf[:])
|
|
||||||
if n < 1 {
|
|
||||||
return "", EINVAL
|
|
||||||
}
|
|
||||||
return string(buf[:n]), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
|
func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
|
||||||
var (
|
var (
|
||||||
_p0 unsafe.Pointer
|
_p0 unsafe.Pointer
|
||||||
|
33
vendor/golang.org/x/sys/unix/syscall_illumos.go
generated
vendored
33
vendor/golang.org/x/sys/unix/syscall_illumos.go
generated
vendored
@ -55,3 +55,36 @@ func Pwritev(fd int, iovs [][]byte, off int64) (n int, err error) {
|
|||||||
n, err = pwritev(fd, iovecs, off)
|
n, err = pwritev(fd, iovecs, off)
|
||||||
return n, err
|
return n, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) = libsocket.accept4
|
||||||
|
|
||||||
|
func Accept4(fd int, flags int) (nfd int, sa Sockaddr, err error) {
|
||||||
|
var rsa RawSockaddrAny
|
||||||
|
var len _Socklen = SizeofSockaddrAny
|
||||||
|
nfd, err = accept4(fd, &rsa, &len, flags)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if len > SizeofSockaddrAny {
|
||||||
|
panic("RawSockaddrAny too small")
|
||||||
|
}
|
||||||
|
sa, err = anyToSockaddr(fd, &rsa)
|
||||||
|
if err != nil {
|
||||||
|
Close(nfd)
|
||||||
|
nfd = 0
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//sysnb pipe2(p *[2]_C_int, flags int) (err error)
|
||||||
|
|
||||||
|
func Pipe2(p []int, flags int) error {
|
||||||
|
if len(p) != 2 {
|
||||||
|
return EINVAL
|
||||||
|
}
|
||||||
|
var pp [2]_C_int
|
||||||
|
err := pipe2(&pp, flags)
|
||||||
|
p[0] = int(pp[0])
|
||||||
|
p[1] = int(pp[1])
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
47
vendor/golang.org/x/sys/unix/syscall_linux.go
generated
vendored
47
vendor/golang.org/x/sys/unix/syscall_linux.go
generated
vendored
@ -106,12 +106,53 @@ func IoctlGetRTCTime(fd int) (*RTCTime, error) {
|
|||||||
return &value, err
|
return &value, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IoctlGetWatchdogInfo fetches information about a watchdog device from the
|
||||||
|
// Linux watchdog API. For more information, see:
|
||||||
|
// https://www.kernel.org/doc/html/latest/watchdog/watchdog-api.html.
|
||||||
|
func IoctlGetWatchdogInfo(fd int) (*WatchdogInfo, error) {
|
||||||
|
var value WatchdogInfo
|
||||||
|
err := ioctl(fd, WDIOC_GETSUPPORT, uintptr(unsafe.Pointer(&value)))
|
||||||
|
return &value, err
|
||||||
|
}
|
||||||
|
|
||||||
func IoctlGetRTCWkAlrm(fd int) (*RTCWkAlrm, error) {
|
func IoctlGetRTCWkAlrm(fd int) (*RTCWkAlrm, error) {
|
||||||
var value RTCWkAlrm
|
var value RTCWkAlrm
|
||||||
err := ioctl(fd, RTC_WKALM_RD, uintptr(unsafe.Pointer(&value)))
|
err := ioctl(fd, RTC_WKALM_RD, uintptr(unsafe.Pointer(&value)))
|
||||||
return &value, err
|
return &value, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IoctlFileCloneRange performs an FICLONERANGE ioctl operation to clone the
|
||||||
|
// range of data conveyed in value to the file associated with the file
|
||||||
|
// descriptor destFd. See the ioctl_ficlonerange(2) man page for details.
|
||||||
|
func IoctlFileCloneRange(destFd int, value *FileCloneRange) error {
|
||||||
|
err := ioctl(destFd, FICLONERANGE, uintptr(unsafe.Pointer(value)))
|
||||||
|
runtime.KeepAlive(value)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// IoctlFileClone performs an FICLONE ioctl operation to clone the entire file
|
||||||
|
// associated with the file description srcFd to the file associated with the
|
||||||
|
// file descriptor destFd. See the ioctl_ficlone(2) man page for details.
|
||||||
|
func IoctlFileClone(destFd, srcFd int) error {
|
||||||
|
return ioctl(destFd, FICLONE, uintptr(srcFd))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IoctlFileDedupeRange performs an FIDEDUPERANGE ioctl operation to share the
|
||||||
|
// range of data conveyed in value with the file associated with the file
|
||||||
|
// descriptor destFd. See the ioctl_fideduperange(2) man page for details.
|
||||||
|
func IoctlFileDedupeRange(destFd int, value *FileDedupeRange) error {
|
||||||
|
err := ioctl(destFd, FIDEDUPERANGE, uintptr(unsafe.Pointer(value)))
|
||||||
|
runtime.KeepAlive(value)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// IoctlWatchdogKeepalive issues a keepalive ioctl to a watchdog device. For
|
||||||
|
// more information, see:
|
||||||
|
// https://www.kernel.org/doc/html/latest/watchdog/watchdog-api.html.
|
||||||
|
func IoctlWatchdogKeepalive(fd int) error {
|
||||||
|
return ioctl(fd, WDIOC_KEEPALIVE, 0)
|
||||||
|
}
|
||||||
|
|
||||||
//sys Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error)
|
//sys Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error)
|
||||||
|
|
||||||
func Link(oldpath string, newpath string) (err error) {
|
func Link(oldpath string, newpath string) (err error) {
|
||||||
@ -136,6 +177,12 @@ func Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error)
|
|||||||
return openat(dirfd, path, flags|O_LARGEFILE, mode)
|
return openat(dirfd, path, flags|O_LARGEFILE, mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//sys openat2(dirfd int, path string, open_how *OpenHow, size int) (fd int, err error)
|
||||||
|
|
||||||
|
func Openat2(dirfd int, path string, how *OpenHow) (fd int, err error) {
|
||||||
|
return openat2(dirfd, path, how, SizeofOpenHow)
|
||||||
|
}
|
||||||
|
|
||||||
//sys ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error)
|
//sys ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error)
|
||||||
|
|
||||||
func Ppoll(fds []PollFd, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {
|
func Ppoll(fds []PollFd, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {
|
||||||
|
3
vendor/golang.org/x/sys/unix/syscall_linux_386.go
generated
vendored
3
vendor/golang.org/x/sys/unix/syscall_linux_386.go
generated
vendored
@ -2,9 +2,6 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// TODO(rsc): Rewrite all nn(SP) references into name+(nn-8)(FP)
|
|
||||||
// so that go vet can check that they are correct.
|
|
||||||
|
|
||||||
// +build 386,linux
|
// +build 386,linux
|
||||||
|
|
||||||
package unix
|
package unix
|
||||||
|
2
vendor/golang.org/x/sys/unix/syscall_linux_amd64_gc.go
generated
vendored
2
vendor/golang.org/x/sys/unix/syscall_linux_amd64_gc.go
generated
vendored
@ -3,7 +3,7 @@
|
|||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build amd64,linux
|
// +build amd64,linux
|
||||||
// +build !gccgo
|
// +build gc
|
||||||
|
|
||||||
package unix
|
package unix
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/syscall_linux_gc.go
generated
vendored
2
vendor/golang.org/x/sys/unix/syscall_linux_gc.go
generated
vendored
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build linux,!gccgo
|
// +build linux,gc
|
||||||
|
|
||||||
package unix
|
package unix
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/syscall_linux_gc_386.go
generated
vendored
2
vendor/golang.org/x/sys/unix/syscall_linux_gc_386.go
generated
vendored
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build linux,!gccgo,386
|
// +build linux,gc,386
|
||||||
|
|
||||||
package unix
|
package unix
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/syscall_linux_gc_arm.go
generated
vendored
2
vendor/golang.org/x/sys/unix/syscall_linux_gc_arm.go
generated
vendored
@ -2,7 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build arm,!gccgo,linux
|
// +build arm,gc,linux
|
||||||
|
|
||||||
package unix
|
package unix
|
||||||
|
|
||||||
|
19
vendor/golang.org/x/sys/unix/syscall_netbsd.go
generated
vendored
19
vendor/golang.org/x/sys/unix/syscall_netbsd.go
generated
vendored
@ -31,6 +31,10 @@ type SockaddrDatalink struct {
|
|||||||
raw RawSockaddrDatalink
|
raw RawSockaddrDatalink
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func anyToSockaddrGOOS(fd int, rsa *RawSockaddrAny) (Sockaddr, error) {
|
||||||
|
return nil, EAFNOSUPPORT
|
||||||
|
}
|
||||||
|
|
||||||
func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
|
func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
|
||||||
|
|
||||||
func sysctlNodes(mib []_C_int) (nodes []Sysctlnode, err error) {
|
func sysctlNodes(mib []_C_int) (nodes []Sysctlnode, err error) {
|
||||||
@ -141,23 +145,8 @@ func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const ImplementsGetwd = true
|
|
||||||
|
|
||||||
//sys Getcwd(buf []byte) (n int, err error) = SYS___GETCWD
|
//sys Getcwd(buf []byte) (n int, err error) = SYS___GETCWD
|
||||||
|
|
||||||
func Getwd() (string, error) {
|
|
||||||
var buf [PathMax]byte
|
|
||||||
_, err := Getcwd(buf[0:])
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
n := clen(buf[:])
|
|
||||||
if n < 1 {
|
|
||||||
return "", EINVAL
|
|
||||||
}
|
|
||||||
return string(buf[:n]), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
|
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
|
||||||
return -1, ENOSYS
|
return -1, ENOSYS
|
||||||
|
19
vendor/golang.org/x/sys/unix/syscall_openbsd.go
generated
vendored
19
vendor/golang.org/x/sys/unix/syscall_openbsd.go
generated
vendored
@ -31,6 +31,10 @@ type SockaddrDatalink struct {
|
|||||||
raw RawSockaddrDatalink
|
raw RawSockaddrDatalink
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func anyToSockaddrGOOS(fd int, rsa *RawSockaddrAny) (Sockaddr, error) {
|
||||||
|
return nil, EAFNOSUPPORT
|
||||||
|
}
|
||||||
|
|
||||||
func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
|
func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
|
||||||
|
|
||||||
func nametomib(name string) (mib []_C_int, err error) {
|
func nametomib(name string) (mib []_C_int, err error) {
|
||||||
@ -114,23 +118,8 @@ func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const ImplementsGetwd = true
|
|
||||||
|
|
||||||
//sys Getcwd(buf []byte) (n int, err error) = SYS___GETCWD
|
//sys Getcwd(buf []byte) (n int, err error) = SYS___GETCWD
|
||||||
|
|
||||||
func Getwd() (string, error) {
|
|
||||||
var buf [PathMax]byte
|
|
||||||
_, err := Getcwd(buf[0:])
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
n := clen(buf[:])
|
|
||||||
if n < 1 {
|
|
||||||
return "", EINVAL
|
|
||||||
}
|
|
||||||
return string(buf[:n]), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
|
func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
|
||||||
if raceenabled {
|
if raceenabled {
|
||||||
raceReleaseMerge(unsafe.Pointer(&ioSync))
|
raceReleaseMerge(unsafe.Pointer(&ioSync))
|
||||||
|
7
vendor/golang.org/x/sys/unix/syscall_solaris.go
generated
vendored
7
vendor/golang.org/x/sys/unix/syscall_solaris.go
generated
vendored
@ -13,6 +13,7 @@
|
|||||||
package unix
|
package unix
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"runtime"
|
||||||
"syscall"
|
"syscall"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
@ -553,8 +554,10 @@ func Minor(dev uint64) uint32 {
|
|||||||
|
|
||||||
//sys ioctl(fd int, req uint, arg uintptr) (err error)
|
//sys ioctl(fd int, req uint, arg uintptr) (err error)
|
||||||
|
|
||||||
func IoctlSetTermio(fd int, req uint, value *Termio) (err error) {
|
func IoctlSetTermio(fd int, req uint, value *Termio) error {
|
||||||
return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
err := ioctl(fd, req, uintptr(unsafe.Pointer(value)))
|
||||||
|
runtime.KeepAlive(value)
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func IoctlGetTermio(fd int, req uint) (*Termio, error) {
|
func IoctlGetTermio(fd int, req uint) (*Termio, error) {
|
||||||
|
2
vendor/golang.org/x/sys/unix/syscall_unix_gc.go
generated
vendored
2
vendor/golang.org/x/sys/unix/syscall_unix_gc.go
generated
vendored
@ -3,7 +3,7 @@
|
|||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
|
||||||
// +build !gccgo,!ppc64le,!ppc64
|
// +build gc,!ppc64le,!ppc64
|
||||||
|
|
||||||
package unix
|
package unix
|
||||||
|
|
||||||
|
2
vendor/golang.org/x/sys/unix/syscall_unix_gc_ppc64x.go
generated
vendored
2
vendor/golang.org/x/sys/unix/syscall_unix_gc_ppc64x.go
generated
vendored
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
// +build linux
|
// +build linux
|
||||||
// +build ppc64le ppc64
|
// +build ppc64le ppc64
|
||||||
// +build !gccgo
|
// +build gc
|
||||||
|
|
||||||
package unix
|
package unix
|
||||||
|
|
||||||
|
4
vendor/golang.org/x/sys/unix/zerrors_darwin_386.go
generated
vendored
4
vendor/golang.org/x/sys/unix/zerrors_darwin_386.go
generated
vendored
@ -45,6 +45,7 @@ const (
|
|||||||
AF_SIP = 0x18
|
AF_SIP = 0x18
|
||||||
AF_SNA = 0xb
|
AF_SNA = 0xb
|
||||||
AF_SYSTEM = 0x20
|
AF_SYSTEM = 0x20
|
||||||
|
AF_SYS_CONTROL = 0x2
|
||||||
AF_UNIX = 0x1
|
AF_UNIX = 0x1
|
||||||
AF_UNSPEC = 0x0
|
AF_UNSPEC = 0x0
|
||||||
AF_UTUN = 0x26
|
AF_UTUN = 0x26
|
||||||
@ -232,6 +233,8 @@ const (
|
|||||||
CLOCK_THREAD_CPUTIME_ID = 0x10
|
CLOCK_THREAD_CPUTIME_ID = 0x10
|
||||||
CLOCK_UPTIME_RAW = 0x8
|
CLOCK_UPTIME_RAW = 0x8
|
||||||
CLOCK_UPTIME_RAW_APPROX = 0x9
|
CLOCK_UPTIME_RAW_APPROX = 0x9
|
||||||
|
CLONE_NOFOLLOW = 0x1
|
||||||
|
CLONE_NOOWNERCOPY = 0x2
|
||||||
CR0 = 0x0
|
CR0 = 0x0
|
||||||
CR1 = 0x1000
|
CR1 = 0x1000
|
||||||
CR2 = 0x2000
|
CR2 = 0x2000
|
||||||
@ -249,6 +252,7 @@ const (
|
|||||||
CSTOP = 0x13
|
CSTOP = 0x13
|
||||||
CSTOPB = 0x400
|
CSTOPB = 0x400
|
||||||
CSUSP = 0x1a
|
CSUSP = 0x1a
|
||||||
|
CTLIOCGINFO = 0xc0644e03
|
||||||
CTL_HW = 0x6
|
CTL_HW = 0x6
|
||||||
CTL_KERN = 0x1
|
CTL_KERN = 0x1
|
||||||
CTL_MAXNAME = 0xc
|
CTL_MAXNAME = 0xc
|
||||||
|
4
vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go
generated
vendored
4
vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go
generated
vendored
@ -45,6 +45,7 @@ const (
|
|||||||
AF_SIP = 0x18
|
AF_SIP = 0x18
|
||||||
AF_SNA = 0xb
|
AF_SNA = 0xb
|
||||||
AF_SYSTEM = 0x20
|
AF_SYSTEM = 0x20
|
||||||
|
AF_SYS_CONTROL = 0x2
|
||||||
AF_UNIX = 0x1
|
AF_UNIX = 0x1
|
||||||
AF_UNSPEC = 0x0
|
AF_UNSPEC = 0x0
|
||||||
AF_UTUN = 0x26
|
AF_UTUN = 0x26
|
||||||
@ -232,6 +233,8 @@ const (
|
|||||||
CLOCK_THREAD_CPUTIME_ID = 0x10
|
CLOCK_THREAD_CPUTIME_ID = 0x10
|
||||||
CLOCK_UPTIME_RAW = 0x8
|
CLOCK_UPTIME_RAW = 0x8
|
||||||
CLOCK_UPTIME_RAW_APPROX = 0x9
|
CLOCK_UPTIME_RAW_APPROX = 0x9
|
||||||
|
CLONE_NOFOLLOW = 0x1
|
||||||
|
CLONE_NOOWNERCOPY = 0x2
|
||||||
CR0 = 0x0
|
CR0 = 0x0
|
||||||
CR1 = 0x1000
|
CR1 = 0x1000
|
||||||
CR2 = 0x2000
|
CR2 = 0x2000
|
||||||
@ -249,6 +252,7 @@ const (
|
|||||||
CSTOP = 0x13
|
CSTOP = 0x13
|
||||||
CSTOPB = 0x400
|
CSTOPB = 0x400
|
||||||
CSUSP = 0x1a
|
CSUSP = 0x1a
|
||||||
|
CTLIOCGINFO = 0xc0644e03
|
||||||
CTL_HW = 0x6
|
CTL_HW = 0x6
|
||||||
CTL_KERN = 0x1
|
CTL_KERN = 0x1
|
||||||
CTL_MAXNAME = 0xc
|
CTL_MAXNAME = 0xc
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user