|
@@ -207,6 +207,8 @@ func (h *Handle) FilterList(link Link, parent uint32) ([]Filter, error) {
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
+ default:
|
|
|
+ detailed = true
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -220,6 +222,22 @@ func (h *Handle) FilterList(link Link, parent uint32) ([]Filter, error) {
|
|
|
return res, nil
|
|
|
}
|
|
|
|
|
|
+func toTcGen(attrs *ActionAttrs, tcgen *nl.TcGen) {
|
|
|
+ tcgen.Index = uint32(attrs.Index)
|
|
|
+ tcgen.Capab = uint32(attrs.Capab)
|
|
|
+ tcgen.Action = int32(attrs.Action)
|
|
|
+ tcgen.Refcnt = int32(attrs.Refcnt)
|
|
|
+ tcgen.Bindcnt = int32(attrs.Bindcnt)
|
|
|
+}
|
|
|
+
|
|
|
+func toAttrs(tcgen *nl.TcGen, attrs *ActionAttrs) {
|
|
|
+ attrs.Index = int(tcgen.Index)
|
|
|
+ attrs.Capab = int(tcgen.Capab)
|
|
|
+ attrs.Action = TcAct(tcgen.Action)
|
|
|
+ attrs.Refcnt = int(tcgen.Refcnt)
|
|
|
+ attrs.Bindcnt = int(tcgen.Bindcnt)
|
|
|
+}
|
|
|
+
|
|
|
func encodeActions(attr *nl.RtAttr, actions []Action) error {
|
|
|
tabIndex := int(nl.TCA_ACT_TAB)
|
|
|
|
|
@@ -232,15 +250,30 @@ func encodeActions(attr *nl.RtAttr, actions []Action) error {
|
|
|
tabIndex++
|
|
|
nl.NewRtAttrChild(table, nl.TCA_ACT_KIND, nl.ZeroTerminated("mirred"))
|
|
|
aopts := nl.NewRtAttrChild(table, nl.TCA_ACT_OPTIONS, nil)
|
|
|
- nl.NewRtAttrChild(aopts, nl.TCA_MIRRED_PARMS, action.Serialize())
|
|
|
+ mirred := nl.TcMirred{
|
|
|
+ Eaction: int32(action.MirredAction),
|
|
|
+ Ifindex: uint32(action.Ifindex),
|
|
|
+ }
|
|
|
+ toTcGen(action.Attrs(), &mirred.TcGen)
|
|
|
+ nl.NewRtAttrChild(aopts, nl.TCA_MIRRED_PARMS, mirred.Serialize())
|
|
|
case *BpfAction:
|
|
|
table := nl.NewRtAttrChild(attr, tabIndex, nil)
|
|
|
tabIndex++
|
|
|
nl.NewRtAttrChild(table, nl.TCA_ACT_KIND, nl.ZeroTerminated("bpf"))
|
|
|
aopts := nl.NewRtAttrChild(table, nl.TCA_ACT_OPTIONS, nil)
|
|
|
- nl.NewRtAttrChild(aopts, nl.TCA_ACT_BPF_PARMS, action.Serialize())
|
|
|
+ gen := nl.TcGen{}
|
|
|
+ toTcGen(action.Attrs(), &gen)
|
|
|
+ nl.NewRtAttrChild(aopts, nl.TCA_ACT_BPF_PARMS, gen.Serialize())
|
|
|
nl.NewRtAttrChild(aopts, nl.TCA_ACT_BPF_FD, nl.Uint32Attr(uint32(action.Fd)))
|
|
|
nl.NewRtAttrChild(aopts, nl.TCA_ACT_BPF_NAME, nl.ZeroTerminated(action.Name))
|
|
|
+ case *GenericAction:
|
|
|
+ table := nl.NewRtAttrChild(attr, tabIndex, nil)
|
|
|
+ tabIndex++
|
|
|
+ nl.NewRtAttrChild(table, nl.TCA_ACT_KIND, nl.ZeroTerminated("gact"))
|
|
|
+ aopts := nl.NewRtAttrChild(table, nl.TCA_ACT_OPTIONS, nil)
|
|
|
+ gen := nl.TcGen{}
|
|
|
+ toTcGen(action.Attrs(), &gen)
|
|
|
+ nl.NewRtAttrChild(aopts, nl.TCA_GACT_PARMS, gen.Serialize())
|
|
|
}
|
|
|
}
|
|
|
return nil
|
|
@@ -266,6 +299,8 @@ func parseActions(tables []syscall.NetlinkRouteAttr) ([]Action, error) {
|
|
|
action = &MirredAction{}
|
|
|
case "bpf":
|
|
|
action = &BpfAction{}
|
|
|
+ case "gact":
|
|
|
+ action = &GenericAction{}
|
|
|
default:
|
|
|
break nextattr
|
|
|
}
|
|
@@ -279,17 +314,28 @@ func parseActions(tables []syscall.NetlinkRouteAttr) ([]Action, error) {
|
|
|
case "mirred":
|
|
|
switch adatum.Attr.Type {
|
|
|
case nl.TCA_MIRRED_PARMS:
|
|
|
- action.(*MirredAction).TcMirred = *nl.DeserializeTcMirred(adatum.Value)
|
|
|
+ mirred := *nl.DeserializeTcMirred(adatum.Value)
|
|
|
+ toAttrs(&mirred.TcGen, action.Attrs())
|
|
|
+ action.(*MirredAction).ActionAttrs = ActionAttrs{}
|
|
|
+ action.(*MirredAction).Ifindex = int(mirred.Ifindex)
|
|
|
+ action.(*MirredAction).MirredAction = MirredAct(mirred.Eaction)
|
|
|
}
|
|
|
case "bpf":
|
|
|
switch adatum.Attr.Type {
|
|
|
case nl.TCA_ACT_BPF_PARMS:
|
|
|
- action.(*BpfAction).TcActBpf = *nl.DeserializeTcActBpf(adatum.Value)
|
|
|
+ gen := *nl.DeserializeTcGen(adatum.Value)
|
|
|
+ toAttrs(&gen, action.Attrs())
|
|
|
case nl.TCA_ACT_BPF_FD:
|
|
|
action.(*BpfAction).Fd = int(native.Uint32(adatum.Value[0:4]))
|
|
|
case nl.TCA_ACT_BPF_NAME:
|
|
|
action.(*BpfAction).Name = string(adatum.Value[:len(adatum.Value)-1])
|
|
|
}
|
|
|
+ case "gact":
|
|
|
+ switch adatum.Attr.Type {
|
|
|
+ case nl.TCA_GACT_PARMS:
|
|
|
+ gen := *nl.DeserializeTcGen(adatum.Value)
|
|
|
+ toAttrs(&gen, action.Attrs())
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|