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

Merge main to oci-support #472

Merged
merged 3 commits into from
Dec 27, 2023
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
1 change: 1 addition & 0 deletions loxinet/dpbroker.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const (
DpStatsGet
DpStatsClr
DpMapGet
DpStatsGetImm
)

// DpStatusT - status of a dp work
Expand Down
7 changes: 5 additions & 2 deletions loxinet/dpebpf_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -1032,14 +1031,18 @@ 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

packets = 0
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),
Expand Down
29 changes: 8 additions & 21 deletions loxinet/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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:
Expand All @@ -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 {
Expand Down
Loading