# README
tc

This is a work in progress version of tc
. It provides a C-binding free API to the netlink based traffic control system of rtnetlink.
Example
func main() {
// open a rtnetlink socket
rtnl, err := tc.Open(&tc.Config{})
if err != nil {
fmt.Fprintf(os.Stderr, "could not open rtnetlink socket: %v\n", err)
return
}
defer func() {
if err := rtnl.Close(); err != nil {
fmt.Fprintf(os.Stderr, "could not close rtnetlink socket: %v\n", err)
}
}()
// get all the qdiscs from all interfaces
qdiscs, err := rtnl.Qdisc().Get()
if err != nil {
fmt.Fprintf(os.Stderr, "could not get qdiscs: %v\n", err)
return
}
for _, qdisc := range qdiscs {
iface, err := net.InterfaceByIndex(int(qdisc.Ifindex))
if err != nil {
fmt.Fprintf(os.Stderr, "could not get interface from id %d: %v", qdisc.Ifindex, err)
return
}
fmt.Printf("%20s\t%s\n", iface.Name, qdisc.Kind)
}
}
Requirements
- A version of Go that is supported by upstream
Privileges
This package processes information directly from the kernel and therefore it requires special privileges. You can provide this privileges by adjusting the CAP_NET_ADMIN
capabilities.
setcap 'cap_net_admin=+ep' /your/executable
# Packages
Package core contains some generic helper functions for the package github.com/florianl/go-tc.
# Functions
Open establishes a RTNETLINK socket for traffic control.
# Constants
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Flags defined by the kernel for the BPF filter.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Various Ematch kinds.
Various Ematch kinds.
Various Ematch kinds.
Various Ematch kinds.
Various Ematch kinds.
No description provided by the author
No description provided by the author
No description provided by the author
Various Ematch kinds.
Various Ematch kinds.
No description provided by the author
No description provided by the author
No description provided by the author
Various Ematch kinds.
Various Ematch kinds.
Various Ematch kinds.
Constants to define the direction.
Constants to define the direction.
Constants to define the direction.
Constants to define the direction.
Constants to define the direction.
filter is offloaded to HW.
No description provided by the author
No description provided by the author
To alter filter in shared blocks, set Msg.Ifindex to MagicBlock.
filter isn't offloaded to HW.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Default Policy actions.
Default Policy actions.
Default Policy actions.
Default Policy actions.
don't offload filter to HW.
don't use filter in SW.
verbose logging.
# Variables
ErrInvalidArg is returned on invalid given arguments.
Various errors.
ErrNoArg is returned for missing arguments.
Various errors.
ErrNotImplemented is returned for not yet implemented parts.
ErrUnknownKind is returned for unknown qdisc, filter or class types.
# Structs
ActBpf represents policing attributes of various filters and classes.
ActBpfParms from include/uapi/linux/tc_act/tc_bpf.h.
Action represents action attributes of various filters and classes.
Atm contains attributes of the atm discipline.
AtmPvc from include/uapi/linux/atm.h.
Attribute contains various elements for traffic control.
Basic contains attributes of the basic discipline.
Bpf contains attributes of the bpf discipline.
Cake contains attributes of the cake discipline.
Cbq contains attributes of the cbq discipline.
CbqFOpt from include/uapi/linux/pkt_sched.h.
CbqLssOpt from include/uapi/linux/pkt_sched.h.
CbqOvl from include/uapi/linux/pkt_sched.h.
CbqPolice from include/uapi/linux/pkt_sched.h.
CbqWrrOpt from include/uapi/linux/pkt_sched.h.
CbqXStats from include/uapi/linux/pkt_sched.h.
Cgroup contains attributes of the cgroup discipline.
Chain represents a collection of filter.
Choke contains attributes of the choke discipline.
ChokeXStats from include/uapi/linux/pkt_sched.h.
Class represents the class part of rtnetlink.
No description provided by the author
Codel contains attributes of the codel discipline.
CodelXStats from include/uapi/linux/pkt_sched.h.
Config contains options for RTNETLINK.
Connmark represents policing attributes of various filters and classes.
ConnmarkParam from include/uapi/linux/tc_act/tc_connmark.h.
Csum contains attributes of the csum discipline.
CsumParms from include/uapi/linux/tc_act/tc_csum.h.
Defact contains attributes of the defact discipline.
DefactParms from include/uapi/linux/tc_act/tc_defact.h.
Drr contains attributes of the drr discipline.
Dsmark contains attributes of the dsmark discipline.
Ematch contains attributes of the ematch discipline https://man7.org/linux/man-pages/man8/tc-ematch.8.html.
tcf_ematch_hdr from include/uapi/linux/pkt_cls.h.
No description provided by the author
tcf_ematch_tree_hdr from include/uapi/linux/pkt_cls.h.
Ets represents a struct for Enhanced Transmission Selection, a 802.1Qaz-based Qdisc.
FifoOpt from include/uapi/linux/pkt_sched.h.
Filter represents the filtering part of rtnetlink.
Flow contains attributes of the flow discipline.
Flower contains attrobutes of the flower discipline.
Fq contains attributes of the fq discipline.
FqCodel contains attributes of the fq_codel discipline.
FqCodelClStats from include/uapi/linux/pkt_sched.h.
FqCodelQdStats from include/uapi/linux/pkt_sched.h.
FqCodelXStats from include/uapi/linux/pkt_sched.h.
Fw contains attributes of the fw discipline.
type Gact contains attributes of the gact discipline.
GactParm from include/uapi/linux/tc_act/tc_gact.h.
GactProb from include/uapi/linux/tc_act/tc_gact.h.
Gate contains attributes of the gate discipline https://man7.org/linux/man-pages/man8/tc-gate.8.html.
GateParms from include/uapi/linux/tc_act/tc_gate.h.
GenBasic from include/uapi/linux/gen_stats.h.
GenQueue from include/uapi/linux/gen_stats.h.
GenRateEst from include/uapi/linux/gen_stats.h.
GenRateEst64 from include/uapi/linux/gen_stats.h.
GenStats from include/uapi/linux/gen_stats.h.
Hfsc contains attributes of the hfsc class.
HfscQOpt contains attributes of the hfsc qdisc.
HfscXStats from include/uapi/linux/pkt_sched.h.
Hhf contains attributes of the hhf discipline.
HhfXStats from include/uapi/linux/pkt_sched.h.
Htb contains attributes of the HTB discipline.
HtbGlob from include/uapi/linux/pkt_sched.h.
HtbOpt from include/uapi/linux/pkt_sched.h.
HtbXStats from include/uapi/linux/pkt_sched.h.
Ife contains attribute of the ife discipline.
IfeParms from from include/uapi/linux/tc_act/tc_ife.h.
No description provided by the author
Ipt contains attribute of the ipt discipline.
IptCnt as tc_cnt from include/uapi/linux/pkt_cls.h.
Matchall contains attributes of the matchall discipline.
Mirred represents policing attributes of various filters and classes.
MirredParam from include/uapi/linux/tc_act/tc_mirred.h.
MqPrio contains attributes of the mqprio discipline.
MqPrioQopt according to tc_mqprio_qopt in /include/uapi/linux/pkt_sched.h.
Msg represents a Traffic Control Message.
Nat contains attribute of the nat discipline.
NatParms from from include/uapi/linux/tc_act/tc_nat.h.
Netem contains attributes of the netem discipline.
NetemCorr from include/uapi/linux/pkt_sched.h.
NetemCorrupt from include/uapi/linux/pkt_sched.h.
NetemQopt from include/uapi/linux/pkt_sched.h.
NetemRate from include/uapi/linux/pkt_sched.h.
NetemReorder from include/uapi/linux/pkt_sched.h.
NetemSlot from include/uapi/linux/pkt_sched.h.
Object represents a generic traffic control object.
Pie contains attributes of the pie discipline.
PieXStats from include/uapi/linux/pkt_sched.h.
No description provided by the author
Police represents policing attributes of various filters and classes.
Policy from include/uapi/linux/pkt_sched.h.
Prio contains attributes of the prio discipline.
Qdisc represents the queueing discipline part of traffic control.
Qfq contains attributes of the qfq discipline.
RateSpec from include/uapi/linux/pkt_sched.h.
Red contains attributes of the red discipline.
RedQOpt from include/uapi/linux/pkt_sched.h.
RedXStats from include/uapi/linux/pkt_sched.h.
Route4 contains attributes of the route discipline.
Rsvp contains attributes of the rsvp discipline.
RsvpGpi from include/uapi/linux/pkt_sched.h.
RsvpPInfo from include/uapi/linux/pkt_sched.h.
Sample contains attribute of the Sample discipline.
SampleParms from from include/uapi/linux/tc_act/tc_sample.h.
ServiceCurve from include/uapi/linux/pkt_sched.h.
Sfb contains attributes of the SBF discipline.
SfbQopt from include/uapi/linux/pkt_sched.h.
SfbXStats from include/uapi/linux/pkt_sched.h.
No description provided by the author
No description provided by the author
SfqXStats from include/uapi/linux/pkt_sched.h.
SizeSpec implements tc_sizespec.
Stab contains attributes of a stab http://man7.org/linux/man-pages/man8/tc-stab.8.html.
Stats from include/uapi/linux/pkt_sched.h.
Stats2 from include/uapi/linux/pkt_sched.h.
Tbf contains attributes of the TBF discipline.
TbfQopt from include/uapi/linux/pkt_sched.h.
Tc represents a RTNETLINK wrapper.
Tcft from include/uapi/linux/pkt_sched.h.
TcIndex contains attributes of the tcIndex discipline.
TunnelKey contains attribute of the TunnelKey discipline.
TunnelParms from from include/uapi/linux/tc_act/tc_tunnel_key.h.
U32 contains attributes of the u32 discipline.
U32Key from include/uapi/linux/pkt_sched.h.
U32Mark from include/uapi/linux/pkt_sched.h.
No description provided by the author
U32Sel from include/uapi/linux/pkt_sched.h.
VLan contains attribute of the VLan discipline.
VLanParms from from include/uapi/linux/tc_act/tc_vlan.h.
XStats contains further statistics to the TCA_KIND.
# Type aliases
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
ErrorFunc is a function that receives all errors that happen while reading from a Netlinkgroup.
HookFunc is a function, which is called for each altered RTNETLINK Object.
No description provided by the author
No description provided by the author
PolicyAction defines the action that is applied by Policy.