Documentation ¶
Index ¶
- Constants
- type Actuator
- type ActuatorFileWriterImpl
- type ActuatorTCImpl
- type FilterSet
- type FilterSetImpl
- func (f *FilterSetImpl) Add(filter types.Filter)
- func (f *FilterSetImpl) Difference(other FilterSet) FilterSet
- func (f *FilterSetImpl) Equals(other FilterSet) bool
- func (f *FilterSetImpl) Has(filter types.Filter) bool
- func (f *FilterSetImpl) In(other FilterSet) bool
- func (f *FilterSetImpl) Intersect(other FilterSet) FilterSet
- func (f *FilterSetImpl) Len() int
- func (f *FilterSetImpl) List() []types.Filter
- func (f *FilterSetImpl) Remove(filter types.Filter)
- type Generator
- type Objects
- type SimpleTCGenerator
- type TC
Constants ¶
const ( PrioDefault = 300 PrioPass = 200 PrioDrop = 100 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Actuator ¶
type Actuator interface { // Actuate applies TC object in Objects on NetDev provided in Objects Actuate(objects *Objects) error }
Actuator is an interface that applies specified TC Objects on netdev
type ActuatorFileWriterImpl ¶
type ActuatorFileWriterImpl struct {
// contains filtered or unexported fields
}
ActuatorFileWriterImpl implements Actuator interface and is used to save TC objects to file
func NewActuatorFileWriterImpl ¶
func NewActuatorFileWriterImpl(path string, log klog.Logger) *ActuatorFileWriterImpl
NewActuatorFileWriterImpl returns a new ActuatorFileWriterImpl instance
func (ActuatorFileWriterImpl) Actuate ¶
func (a ActuatorFileWriterImpl) Actuate(objects *Objects) error
Actuate implements Actuator interface Note(adrianc): As we are saving tc objects (mainly filters) to file in a human-readable format (as this is really intended for debug purposes). We need represent these objects as string. For now, we leverage CmdLineGenerator interface which is implemented by all objects. Later on, it may be desired to extend the interface with String() method and implement throughout then use it here.
type ActuatorTCImpl ¶
type ActuatorTCImpl struct {
// contains filtered or unexported fields
}
ActuatorTCImpl is an implementation of Actuator interface using provided TC interface to apply TC objects
func NewActuatorTCImpl ¶
func NewActuatorTCImpl(tcIfc TC, log klog.Logger) *ActuatorTCImpl
NewActuatorTCImpl creates a new ActuatorTCImpl
func (*ActuatorTCImpl) Actuate ¶
func (a *ActuatorTCImpl) Actuate(objects *Objects) error
Actuate is an implementation of Actuator interface. it applies Objects on the representor Note: it assumes all filters are in Chain 0
type FilterSet ¶
type FilterSet interface { // Add adds filter element to set Add(filter types.Filter) // Remove removes filter element from set. if filter element does not exist, the call is a no-op Remove(filter types.Filter) // Has returns true if filter element is in the set, else returns false Has(filter types.Filter) bool // Len returns the number of elements in the set Len() int // In returns true if every element in other is an alement of this set. else it returns false In(other FilterSet) bool // Intersect returns a new FilterSet with elements from both this FilterSet and other FilterSet Intersect(other FilterSet) FilterSet // Difference returns the difference between this and other FilterSet, that is, elements in this FilterSet // and not the other FilterSet Difference(other FilterSet) FilterSet // Equals returns true if this and other FilterSet are equal (have the same elements) Equals(other FilterSet) bool // List returns the Filter elements in FilterSet List() []types.Filter }
FilterSet interface defines an API for Filter set, which allows to perform set operations on a collection of Filters
type FilterSetImpl ¶
type FilterSetImpl struct {
// contains filtered or unexported fields
}
FilterSetImpl implements FilterSet
func NewFilterSetImpl ¶
func NewFilterSetImpl() *FilterSetImpl
NewFilterSetImpl returns a new *FilterSetImpl
func (*FilterSetImpl) Add ¶
func (f *FilterSetImpl) Add(filter types.Filter)
Add implements FilterSet
func (*FilterSetImpl) Difference ¶
func (f *FilterSetImpl) Difference(other FilterSet) FilterSet
Difference implements FilterSet
func (*FilterSetImpl) Equals ¶
func (f *FilterSetImpl) Equals(other FilterSet) bool
Equals implements FilterSet
func (*FilterSetImpl) Has ¶
func (f *FilterSetImpl) Has(filter types.Filter) bool
Has implements FilterSet
func (*FilterSetImpl) Intersect ¶
func (f *FilterSetImpl) Intersect(other FilterSet) FilterSet
Intersect implements FilterSet
func (*FilterSetImpl) List ¶
func (f *FilterSetImpl) List() []types.Filter
List implements FilterSet
func (*FilterSetImpl) Remove ¶
func (f *FilterSetImpl) Remove(filter types.Filter)
Remove implements FilterSet
type Generator ¶
type Generator interface { // GenerateFromPolicyRuleSet creates Objects that correspond to the provided ruleSet GenerateFromPolicyRuleSet(ruleSet policyrules.PolicyRuleSet) (*Objects, error) }
Generator is an interface to generate Objects from PolicyRuleSet
type Objects ¶
type Objects struct { // QDisc is the TC QDisc where rules should be applied QDisc tctypes.QDisc // Filters are the TC filters that should be applied Filters []tctypes.Filter }
Objects is a struct containing TC objects
type SimpleTCGenerator ¶
type SimpleTCGenerator struct{}
SimpleTCGenerator is a simple implementation for Generator interface
func NewSimpleTCGenerator ¶
func NewSimpleTCGenerator() *SimpleTCGenerator
NewSimpleTCGenerator creates a new SimpleTCGenerator instance
func (*SimpleTCGenerator) GenerateFromPolicyRuleSet ¶
func (s *SimpleTCGenerator) GenerateFromPolicyRuleSet(ruleSet policyrules.PolicyRuleSet) (*Objects, error)
GenerateFromPolicyRuleSet implements Generator interface It renders TC objects needed to satisfy the rules in the provided PolicyRuleSet QDisc is Ingress QDisc Filters is a list of filters which satisfy the PolicyRuleSet. They are generated as follows
- Drop rule at chain 0, priority 300 for all traffic
- Accept rules per CIDR X Port for every Pass Rule in PolicyRuleSet at chain 0, priority 200
- Drop rules per CIDR X Port for every Drop Rule in PolicyRuleSet at chain 0, prioirty 100 Note: only Egress Policy type is supported
type TC ¶
type TC interface { // QDiscAdd adds the specified Qdisc QDiscAdd(qdisc tctypes.QDisc) error // QDiscDel deletes the specified Qdisc QDiscDel(qdisc tctypes.QDisc) error // QDiscList lists QDiscs QDiscList() ([]tctypes.QDisc, error) // FilterAdd adds filter to qdisc FilterAdd(qdisc tctypes.QDisc, filter tctypes.Filter) error // FilterDel deletes filter identified by filterAttr from qdisc FilterDel(qdisc tctypes.QDisc, filterAttr *tctypes.FilterAttrs) error // FilterList lists Filters on qdisc FilterList(qdisc tctypes.QDisc) ([]tctypes.Filter, error) // ChainAdd adds chain to qdiscss ChainAdd(qdisc tctypes.QDisc, chain tctypes.Chain) error // ChainDel deletes chain from qdisc ChainDel(qdisc tctypes.QDisc, chain tctypes.Chain) error // ChainList lists chains on qdisc ChainList(qdisc tctypes.QDisc) ([]tctypes.Chain, error) }
TC defines an interface to interact with Linux Traffic Control subsystem an implementation should be associated with a specific network interface (netdev).