tc

package
v0.4.29 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2019 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Continue ConformExceed = iota
	Drop
	Shot
	Ok
	Pass
	Pipe

	// These values are stolen from linux kernel.
	EgressRedir   MirredActionType = 1
	EgressMirror                   = 2
	IngressRedir                   = 3
	IngressMirror                  = 4
)
View Source
const (
	HandleNone    Handle = netlink.HANDLE_NONE
	HandleRoot           = netlink.HANDLE_ROOT
	HandleIngress        = netlink.HANDLE_INGRESS
)
View Source
const (
	TCActionAdd = "add"
	TCActionDel = "del"
)

Variables

This section is empty.

Functions

func IFBClose

func IFBClose() error

IFBClose unloads the Intermediate Functional Block device kernel module.

func IFBFlush

func IFBFlush() error

IFBFlush completely reloads the Intermediate Functional Block device kernel module.

func IFBInit

func IFBInit() error

IFBInit loads the Intermediate Functional Block device kernel module.

It is used in conjunction with HTB queueing discipline to allow for queueing incoming traffic for shaping instead of dropping.

Types

type Action

type Action interface {
	// Kind returns this action's type.
	Kind() string
	// Cmd creates and returns "tc" sub-command using this filter action.
	Cmd() []string
}

type CMD

type CMD interface {
	// Cmd creates and returns "tc" sub-command using this qdisc.
	Cmd() []string
}

CMD represents "tc" commands and sub-commands that can be described using "tc"

type Class

type Class interface {
	// Kind returns this class's type.
	Kind() string
	// Attrs returns basic attributes of this filter.
	Attrs() ClassAttrs
	// Cmd creates and returns "tc" sub-command using this qdisc.
	Cmd() []string
}

type ClassAttrs

type ClassAttrs struct {
	Link   netlink.Link
	Handle Handle
	Parent Handle
}

type CmdTC

type CmdTC struct {
	// contains filtered or unexported fields
}

func (*CmdTC) ClassAdd

func (m *CmdTC) ClassAdd(class Class) error

func (*CmdTC) ClassDel

func (m *CmdTC) ClassDel(class Class) error

func (*CmdTC) Close

func (m *CmdTC) Close() error

func (*CmdTC) FilterAdd

func (m *CmdTC) FilterAdd(filter Filter) error

func (*CmdTC) FilterDel

func (m *CmdTC) FilterDel(filter Filter) error

func (*CmdTC) QDiscAdd

func (m *CmdTC) QDiscAdd(qdiscDesc QDisc) error

func (*CmdTC) QDiscDel

func (m *CmdTC) QDiscDel(qdiscDesc QDisc) error

type ConformExceed

type ConformExceed int32

func (ConformExceed) String

func (m ConformExceed) String() string

type Filter

type Filter interface {
	// Kind returns this filter's type.
	Kind() string
	// Attrs returns basic attributes of this filter.
	Attrs() FilterAttrs
	// Cmd creates and returns "tc" sub-command using this filter.
	Cmd() []string
}

type FilterAttrs

type FilterAttrs struct {
	Link     netlink.Link
	Parent   Handle
	Priority uint16
	Protocol Protocol
}

Note that lower Priority means a higher priority.

type HTBClass

type HTBClass struct {
	ClassAttrs
	Rate uint64
	Ceil uint64
}

func (*HTBClass) Attrs

func (m *HTBClass) Attrs() ClassAttrs

func (*HTBClass) Cmd

func (m *HTBClass) Cmd() []string

func (*HTBClass) Kind

func (m *HTBClass) Kind() string

type HTBQDisc

type HTBQDisc struct {
	QDiscAttrs
}

func (*HTBQDisc) Attrs

func (m *HTBQDisc) Attrs() QDiscAttrs

func (*HTBQDisc) Cmd

func (m *HTBQDisc) Cmd() []string

func (*HTBQDisc) Type

func (m *HTBQDisc) Type() string

type Handle

type Handle uint32

Handle specifies both qdisc, class and filter ID.

func NewHandle

func NewHandle(major uint16, minor uint16) Handle

NewHandle computes tc handle based on major and minor parts.

func (Handle) String

func (m Handle) String() string

func (Handle) UInt32

func (m Handle) UInt32() uint32

UInt32 returns internal handle representation as an uint32.

func (Handle) WithMinor

func (m Handle) WithMinor(minor uint16) Handle

type Ingress

type Ingress struct {
	QDiscAttrs
}

func (*Ingress) Attrs

func (m *Ingress) Attrs() QDiscAttrs

func (*Ingress) Cmd

func (m *Ingress) Cmd() []string

func (*Ingress) Type

func (m *Ingress) Type() string

type MirredAction

type MirredAction struct {
	Dev    netlink.Link
	Action MirredActionType
}

MirredAction is the action that allows packet mirroring or redirecting the packet it receives.

func (*MirredAction) Cmd

func (m *MirredAction) Cmd() []string

func (*MirredAction) Kind

func (m *MirredAction) Kind() string

type MirredActionType

type MirredActionType int

func (MirredActionType) String

func (m MirredActionType) String() string

type PfifoQDisc

type PfifoQDisc struct {
	QDiscAttrs
	// Limit constrains the queue size as measured in packets.
	Limit uint32
}

PfifoQDisc represents packet limited First In, First Out queue.

func (*PfifoQDisc) Attrs

func (m *PfifoQDisc) Attrs() QDiscAttrs

func (*PfifoQDisc) Cmd

func (m *PfifoQDisc) Cmd() []string

func (*PfifoQDisc) Type

func (m *PfifoQDisc) Type() string

type PoliceAction

type PoliceAction struct {
	// The maximum traffic rate of packets passing this action.
	Rate uint64
	// Set the maximum allowed burst in bytes.
	Burst uint64
	// This is the maximum packet size handled by the policer.
	MTU uint32
	// PeakRate sets the maximum bucket depletion rate, exceeding rate.
	PeakRate uint64
	// Overhead accounts for protocol overhead of encapsulating output devices
	// when computing rate and peakrate.
	Overhead uint64
	// Define how to handle packets which exceed or conform the configured
	// bandwidth limit.
	ConformExceed ConformExceed
}

func (*PoliceAction) Cmd

func (m *PoliceAction) Cmd() []string

func (*PoliceAction) Kind

func (m *PoliceAction) Kind() string

type Protocol

type Protocol int
const (
	ProtoAll Protocol = unix.ETH_P_ALL
	ProtoIP           = unix.ETH_P_IP
)

func (Protocol) String

func (m Protocol) String() string

type QDisc

type QDisc interface {
	// Type returns this qdisc name, for example "tbf", "htb", etc.
	Type() string
	// Attrs returns basic attributes of this qdisc.
	Attrs() QDiscAttrs
	// Cmd creates and returns "tc" sub-command using this qdisc.
	Cmd() []string
}

QDisc describes traffic control queueing discipline.

type QDiscAttrs

type QDiscAttrs struct {
	Link   netlink.Link
	Handle Handle
	Parent Handle
}

type TC

type TC interface {
	QDiscAdd(qdisc QDisc) error
	QDiscDel(qdisc QDisc) error
	ClassAdd(class Class) error
	ClassDel(class Class) error
	FilterAdd(filter Filter) error
	FilterDel(filter Filter) error
	Close() error
}

func NewCmdTC

func NewCmdTC() (TC, error)

func NewDefaultTC

func NewDefaultTC() (TC, error)

type TFBQDisc

type TFBQDisc struct {
	QDiscAttrs
	// Rate in bits per second.
	Rate uint64
	// Size of bucket in bytes.
	Burst uint64
	// Latency in microseconds.
	Latency uint32
}

func (*TFBQDisc) Attrs

func (m *TFBQDisc) Attrs() QDiscAttrs

func (*TFBQDisc) Cmd

func (m *TFBQDisc) Cmd() []string

func (*TFBQDisc) Type

func (m *TFBQDisc) Type() string

type U32

type U32 struct {
	FilterAttrs

	FlowID   Handle
	Selector U32Key
	Actions  []Action
}

U32 represents the Universal/Ugly 32bit filter classifier.

func (*U32) Attrs

func (m *U32) Attrs() FilterAttrs

func (*U32) Cmd

func (m *U32) Cmd() []string

func (*U32) Kind

func (m *U32) Kind() string

type U32Key

type U32Key struct {
	Val     uint32
	Mask    uint32
	Off     int
	OffMask int
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL