diff --git a/m_mirred.go b/m_mirred.go index a5663b6..5267b4b 100644 --- a/m_mirred.go +++ b/m_mirred.go @@ -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 @@ -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()) } @@ -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) } diff --git a/m_mirred_test.go b/m_mirred_test.go index ec5e7f5..c12665c 100644 --- a/m_mirred_test.go +++ b/m_mirred_test.go @@ -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 {