Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extend m_mirred #191

Merged
merged 1 commit into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions m_mirred.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ const (
tcaMirredTm
tcaMirredParms
tcaMirredPad
tcaMirredBlockID
)

// Mirred represents policing attributes of various filters and classes
type Mirred struct {
Parms *MirredParam
Tm *Tcft
Parms *MirredParam
Tm *Tcft
BlockID *uint32
}

// MirredParam from include/uapi/linux/tc_act/tc_mirred.h
Expand Down Expand Up @@ -50,6 +52,8 @@ func unmarshalMirred(data []byte, info *Mirred) error {
info.Tm = tm
case tcaMirredPad:
// padding does not contain data, we just skip it
case tcaMirredBlockID:
info.BlockID = uint32Ptr(ad.Uint32())
default:
return fmt.Errorf("unmarshalMirred()\t%d\n\t%v", ad.Type(), ad.Bytes())
}
Expand All @@ -75,5 +79,8 @@ func marshalMirred(info *Mirred) ([]byte, error) {
}
options = append(options, tcOption{Interpretation: vtBytes, Type: tcaMirredParms, Data: data})
}
if info.BlockID != nil {
options = append(options, tcOption{Interpretation: vtUint32, Type: tcaMirredBlockID, Data: uint32Value(info.BlockID)})
}
return marshalAttributes(options)
}
2 changes: 1 addition & 1 deletion m_mirred_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func TestMirred(t *testing.T) {
err1 error
err2 error
}{
"simple": {val: Mirred{Parms: &MirredParam{Index: 42, Action: 1}}},
"all": {val: Mirred{Parms: &MirredParam{Index: 42, Action: 1}, BlockID: uint32Ptr(73)}},
"invalidArgument": {val: Mirred{Tm: &Tcft{Install: 1}}, err1: ErrNoArgAlter},
}
for name, testcase := range tests {
Expand Down
Loading