mirror of
https://github.com/vishvananda/netlink.git
synced 2025-09-27 04:05:59 +08:00
enable rule statistic and time statistic for flower actions
This commit is contained in:

committed by
Alessandro Boch

parent
004274e828
commit
0ced838538
@@ -528,6 +528,14 @@ func toAttrs(tcgen *nl.TcGen, attrs *ActionAttrs) {
|
||||
attrs.Bindcnt = int(tcgen.Bindcnt)
|
||||
}
|
||||
|
||||
func toTimeStamp(tcf *nl.Tcf) *ActionTimestamp {
|
||||
return &ActionTimestamp{
|
||||
Installed: tcf.Install,
|
||||
LastUsed: tcf.LastUse,
|
||||
Expires: tcf.Expires,
|
||||
FirstUsed: tcf.FirstUse}
|
||||
}
|
||||
|
||||
func encodePolice(attr *nl.RtAttr, action *PoliceAction) error {
|
||||
var rtab [256]uint32
|
||||
var ptab [256]uint32
|
||||
@@ -748,6 +756,8 @@ func parseActions(tables []syscall.NetlinkRouteAttr) ([]Action, error) {
|
||||
for _, table := range tables {
|
||||
var action Action
|
||||
var actionType string
|
||||
var actionnStatistic *ActionStatistic
|
||||
var actionTimestamp *ActionTimestamp
|
||||
aattrs, err := nl.ParseRouteAttr(table.Value)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -795,7 +805,11 @@ func parseActions(tables []syscall.NetlinkRouteAttr) ([]Action, error) {
|
||||
toAttrs(&mirred.TcGen, action.Attrs())
|
||||
action.(*MirredAction).Ifindex = int(mirred.Ifindex)
|
||||
action.(*MirredAction).MirredAction = MirredAct(mirred.Eaction)
|
||||
case nl.TCA_MIRRED_TM:
|
||||
tcTs := nl.DeserializeTcf(adatum.Value)
|
||||
actionTimestamp = toTimeStamp(tcTs)
|
||||
}
|
||||
|
||||
case "tunnel_key":
|
||||
switch adatum.Attr.Type {
|
||||
case nl.TCA_TUNNEL_KEY_PARMS:
|
||||
@@ -811,6 +825,9 @@ func parseActions(tables []syscall.NetlinkRouteAttr) ([]Action, error) {
|
||||
action.(*TunnelKeyAction).DstAddr = adatum.Value[:]
|
||||
case nl.TCA_TUNNEL_KEY_ENC_DST_PORT:
|
||||
action.(*TunnelKeyAction).DestPort = ntohs(adatum.Value)
|
||||
case nl.TCA_TUNNEL_KEY_TM:
|
||||
tcTs := nl.DeserializeTcf(adatum.Value)
|
||||
actionTimestamp = toTimeStamp(tcTs)
|
||||
}
|
||||
case "skbedit":
|
||||
switch adatum.Attr.Type {
|
||||
@@ -833,6 +850,9 @@ func parseActions(tables []syscall.NetlinkRouteAttr) ([]Action, error) {
|
||||
case nl.TCA_SKBEDIT_QUEUE_MAPPING:
|
||||
mapping := native.Uint16(adatum.Value[0:2])
|
||||
action.(*SkbEditAction).QueueMapping = &mapping
|
||||
case nl.TCA_SKBEDIT_TM:
|
||||
tcTs := nl.DeserializeTcf(adatum.Value)
|
||||
actionTimestamp = toTimeStamp(tcTs)
|
||||
}
|
||||
case "bpf":
|
||||
switch adatum.Attr.Type {
|
||||
@@ -843,6 +863,9 @@ func parseActions(tables []syscall.NetlinkRouteAttr) ([]Action, error) {
|
||||
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 nl.TCA_ACT_BPF_TM:
|
||||
tcTs := nl.DeserializeTcf(adatum.Value)
|
||||
actionTimestamp = toTimeStamp(tcTs)
|
||||
}
|
||||
case "connmark":
|
||||
switch adatum.Attr.Type {
|
||||
@@ -851,6 +874,9 @@ func parseActions(tables []syscall.NetlinkRouteAttr) ([]Action, error) {
|
||||
action.(*ConnmarkAction).ActionAttrs = ActionAttrs{}
|
||||
toAttrs(&connmark.TcGen, action.Attrs())
|
||||
action.(*ConnmarkAction).Zone = connmark.Zone
|
||||
case nl.TCA_CONNMARK_TM:
|
||||
tcTs := nl.DeserializeTcf(adatum.Value)
|
||||
actionTimestamp = toTimeStamp(tcTs)
|
||||
}
|
||||
case "csum":
|
||||
switch adatum.Attr.Type {
|
||||
@@ -859,6 +885,9 @@ func parseActions(tables []syscall.NetlinkRouteAttr) ([]Action, error) {
|
||||
action.(*CsumAction).ActionAttrs = ActionAttrs{}
|
||||
toAttrs(&csum.TcGen, action.Attrs())
|
||||
action.(*CsumAction).UpdateFlags = CsumUpdateFlags(csum.UpdateFlags)
|
||||
case nl.TCA_CSUM_TM:
|
||||
tcTs := nl.DeserializeTcf(adatum.Value)
|
||||
actionTimestamp = toTimeStamp(tcTs)
|
||||
}
|
||||
case "gact":
|
||||
switch adatum.Attr.Type {
|
||||
@@ -868,13 +897,24 @@ func parseActions(tables []syscall.NetlinkRouteAttr) ([]Action, error) {
|
||||
if action.Attrs().Action.String() == "goto" {
|
||||
action.(*GenericAction).Chain = TC_ACT_EXT_VAL_MASK & gen.Action
|
||||
}
|
||||
case nl.TCA_GACT_TM:
|
||||
tcTs := nl.DeserializeTcf(adatum.Value)
|
||||
actionTimestamp = toTimeStamp(tcTs)
|
||||
}
|
||||
case "police":
|
||||
parsePolice(adatum, action.(*PoliceAction))
|
||||
}
|
||||
}
|
||||
case nl.TCA_ACT_STATS:
|
||||
s, err := parseTcStats2(aattr.Value)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
actionnStatistic = (*ActionStatistic)(s)
|
||||
}
|
||||
}
|
||||
action.Attrs().Statistics = actionnStatistic
|
||||
action.Attrs().Timestamp = actionTimestamp
|
||||
actions = append(actions, action)
|
||||
}
|
||||
return actions, nil
|
||||
|
Reference in New Issue
Block a user