mirror of
https://github.com/vishvananda/netlink.git
synced 2025-09-26 20:01:13 +08:00
Add Clsact qdisc
Straight copy from jrfastab's fork, but applied to newer main. Signed-off-by: Kevin Sheldrake <kevin.sheldrake@isovalent.com>
This commit is contained in:

committed by
Alessandro Boch

parent
0ced838538
commit
4287122432
@@ -1055,14 +1055,12 @@ func setupLinkForTestWithQdisc(t *testing.T, linkName string) (Qdisc, Link) {
|
||||
if err := LinkSetUp(link); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
attrs := QdiscAttrs{
|
||||
LinkIndex: link.Attrs().Index,
|
||||
Handle: MakeHandle(0xffff, 0),
|
||||
Parent: HANDLE_CLSACT,
|
||||
}
|
||||
qdisc := &GenericQdisc{
|
||||
QdiscAttrs: attrs,
|
||||
QdiscType: "clsact",
|
||||
qdisc := &Clsact{
|
||||
QdiscAttrs: QdiscAttrs{
|
||||
LinkIndex: link.Attrs().Index,
|
||||
Handle: MakeHandle(0xffff, 0),
|
||||
Parent: HANDLE_CLSACT,
|
||||
},
|
||||
}
|
||||
|
||||
if err := QdiscAdd(qdisc); err != nil {
|
||||
@@ -1075,7 +1073,7 @@ func setupLinkForTestWithQdisc(t *testing.T, linkName string) (Qdisc, Link) {
|
||||
if len(qdiscs) != 1 {
|
||||
t.Fatal("Failed to add qdisc", len(qdiscs))
|
||||
}
|
||||
if q, ok := qdiscs[0].(*GenericQdisc); !ok || q.Type() != "clsact" {
|
||||
if q, ok := qdiscs[0].(*Clsact); !ok || q.Type() != "clsact" {
|
||||
t.Fatal("qdisc is the wrong type")
|
||||
}
|
||||
return qdiscs[0], link
|
||||
|
13
qdisc.go
13
qdisc.go
@@ -217,6 +217,19 @@ func (qdisc *Tbf) Type() string {
|
||||
return "tbf"
|
||||
}
|
||||
|
||||
// Clsact is a qdisc for adding filters
|
||||
type Clsact struct {
|
||||
QdiscAttrs
|
||||
}
|
||||
|
||||
func (qdisc *Clsact) Attrs() *QdiscAttrs {
|
||||
return &qdisc.QdiscAttrs
|
||||
}
|
||||
|
||||
func (qdisc *Clsact) Type() string {
|
||||
return "clsact"
|
||||
}
|
||||
|
||||
// Ingress is a qdisc for adding ingress filters
|
||||
type Ingress struct {
|
||||
QdiscAttrs
|
||||
|
@@ -234,6 +234,8 @@ func qdiscPayload(req *nl.NetlinkRequest, qdisc Qdisc) error {
|
||||
if reorder.Probability > 0 {
|
||||
options.AddRtAttr(nl.TCA_NETEM_REORDER, reorder.Serialize())
|
||||
}
|
||||
case *Clsact:
|
||||
options = nil
|
||||
case *Ingress:
|
||||
// ingress filters must use the proper handle
|
||||
if qdisc.Attrs().Parent != HANDLE_INGRESS {
|
||||
@@ -392,6 +394,8 @@ func (h *Handle) QdiscList(link Link) ([]Qdisc, error) {
|
||||
qdisc = &Netem{}
|
||||
case "sfq":
|
||||
qdisc = &Sfq{}
|
||||
case "clsact":
|
||||
qdisc = &Clsact{}
|
||||
default:
|
||||
qdisc = &GenericQdisc{QdiscType: qdiscType}
|
||||
}
|
||||
|
Reference in New Issue
Block a user