diff --git a/loxinet/dpbroker.go b/loxinet/dpbroker.go index 012aea84a..f7e228ad6 100644 --- a/loxinet/dpbroker.go +++ b/loxinet/dpbroker.go @@ -59,6 +59,7 @@ const ( DpStatsGet DpStatsClr DpMapGet + DpStatsGetImm ) // DpStatusT - status of a dp work diff --git a/loxinet/dpebpf_linux.go b/loxinet/dpebpf_linux.go index f6e4c2abb..6e437705f 100644 --- a/loxinet/dpebpf_linux.go +++ b/loxinet/dpebpf_linux.go @@ -1013,7 +1013,6 @@ func (e *DpEbpfH) DpStat(w *StatDpWorkQ) int { switch { case w.Name == MapNameNat4: tbl = append(tbl, int(C.LL_DP_NAT_STATS_MAP)) - sync = 1 case w.Name == MapNameBD: tbl = append(tbl, int(C.LL_DP_BD_STATS_MAP), int(C.LL_DP_TX_BD_STATS_MAP)) case w.Name == MapNameRxBD: @@ -1032,7 +1031,7 @@ func (e *DpEbpfH) DpStat(w *StatDpWorkQ) int { return EbpfErrWqUnk } - if w.Work == DpStatsGet { + if w.Work == DpStatsGet || w.Work == DpStatsGetImm { var b C.longlong var p C.longlong @@ -1040,6 +1039,10 @@ func (e *DpEbpfH) DpStat(w *StatDpWorkQ) int { bytes = 0 dropPackets = 0 + if w.Work == DpStatsGetImm { + sync = 1 + } + for _, t := range tbl { ret := C.llb_fetch_map_stats_cached(C.int(t), C.uint(w.Mark), C.int(sync), diff --git a/loxinet/rules.go b/loxinet/rules.go index 455dcede3..5b83b0cd8 100644 --- a/loxinet/rules.go +++ b/loxinet/rules.go @@ -750,6 +750,8 @@ func (R *RuleH) GetNatLbRule() ([]cmn.LbRuleMod, error) { ret.SecIPs = append(ret.SecIPs, cmn.LbSecIPArg{SecIP: sip.sIP.String()}) } + data.DP(DpStatsGetImm) + // Make Endpoints tmpEp := data.act.action.(*ruleNatActs).endPoints for _, ep := range tmpEp { @@ -1999,25 +2001,6 @@ func (R *RuleH) RulesSync() { rule.DP(DpCreate) } - bytes := uint64(0) - packets := uint64(0) - switch at := rule.act.action.(type) { - case *ruleNatActs: - for _, natActs := range at.endPoints { - bytes += natActs.stat.bytes - packets += natActs.stat.packets - } - } - - rule.stat.bytes = bytes - rule.stat.packets = packets - - tk.LogIt(-1, "%d:%s,%s pc %v bc %v \n", - rule.ruleNum, ruleKeys, ruleActs, - rule.stat.packets, rule.stat.bytes) - - rule.DP(DpStatsGet) - if !rule.hChk.actChk { continue } @@ -2328,7 +2311,7 @@ func (r *ruleEnt) DP(work DpWorkT) int { return 0 } - if work == DpStatsGet { + if work == DpStatsGet || work == DpStatsGetImm { if isNat { switch at := r.act.action.(type) { case *ruleNatActs: @@ -2340,7 +2323,11 @@ func (r *ruleEnt) DP(work DpWorkT) int { nStat.Name = MapNameNat4 nStat.Bytes = &nEP.stat.bytes nStat.Packets = &nEP.stat.packets - mh.dp.ToDpCh <- nStat + if work == DpStatsGetImm { + DpWorkSingle(mh.dp, nStat) + } else { + mh.dp.ToDpCh <- nStat + } } } } else {