Skip to content

Commit 4287122

Browse files
kevsecurityaboch
authored andcommitted
Add Clsact qdisc
Straight copy from jrfastab's fork, but applied to newer main. Signed-off-by: Kevin Sheldrake <[email protected]>
1 parent 0ced838 commit 4287122

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

filter_test.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,14 +1055,12 @@ func setupLinkForTestWithQdisc(t *testing.T, linkName string) (Qdisc, Link) {
10551055
if err := LinkSetUp(link); err != nil {
10561056
t.Fatal(err)
10571057
}
1058-
attrs := QdiscAttrs{
1059-
LinkIndex: link.Attrs().Index,
1060-
Handle: MakeHandle(0xffff, 0),
1061-
Parent: HANDLE_CLSACT,
1062-
}
1063-
qdisc := &GenericQdisc{
1064-
QdiscAttrs: attrs,
1065-
QdiscType: "clsact",
1058+
qdisc := &Clsact{
1059+
QdiscAttrs: QdiscAttrs{
1060+
LinkIndex: link.Attrs().Index,
1061+
Handle: MakeHandle(0xffff, 0),
1062+
Parent: HANDLE_CLSACT,
1063+
},
10661064
}
10671065

10681066
if err := QdiscAdd(qdisc); err != nil {
@@ -1075,7 +1073,7 @@ func setupLinkForTestWithQdisc(t *testing.T, linkName string) (Qdisc, Link) {
10751073
if len(qdiscs) != 1 {
10761074
t.Fatal("Failed to add qdisc", len(qdiscs))
10771075
}
1078-
if q, ok := qdiscs[0].(*GenericQdisc); !ok || q.Type() != "clsact" {
1076+
if q, ok := qdiscs[0].(*Clsact); !ok || q.Type() != "clsact" {
10791077
t.Fatal("qdisc is the wrong type")
10801078
}
10811079
return qdiscs[0], link

qdisc.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,19 @@ func (qdisc *Tbf) Type() string {
217217
return "tbf"
218218
}
219219

220+
// Clsact is a qdisc for adding filters
221+
type Clsact struct {
222+
QdiscAttrs
223+
}
224+
225+
func (qdisc *Clsact) Attrs() *QdiscAttrs {
226+
return &qdisc.QdiscAttrs
227+
}
228+
229+
func (qdisc *Clsact) Type() string {
230+
return "clsact"
231+
}
232+
220233
// Ingress is a qdisc for adding ingress filters
221234
type Ingress struct {
222235
QdiscAttrs

qdisc_linux.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ func qdiscPayload(req *nl.NetlinkRequest, qdisc Qdisc) error {
234234
if reorder.Probability > 0 {
235235
options.AddRtAttr(nl.TCA_NETEM_REORDER, reorder.Serialize())
236236
}
237+
case *Clsact:
238+
options = nil
237239
case *Ingress:
238240
// ingress filters must use the proper handle
239241
if qdisc.Attrs().Parent != HANDLE_INGRESS {
@@ -392,6 +394,8 @@ func (h *Handle) QdiscList(link Link) ([]Qdisc, error) {
392394
qdisc = &Netem{}
393395
case "sfq":
394396
qdisc = &Sfq{}
397+
case "clsact":
398+
qdisc = &Clsact{}
395399
default:
396400
qdisc = &GenericQdisc{QdiscType: qdiscType}
397401
}

0 commit comments

Comments
 (0)