From bc71e9fd7647a32c94175e6109f9879a3779e29b Mon Sep 17 00:00:00 2001 From: Trekkie Coder Date: Tue, 31 Dec 2024 00:41:12 +0900 Subject: [PATCH] chore: fix persist timeout args --- pkg/loxinet/rules.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/loxinet/rules.go b/pkg/loxinet/rules.go index 17d8cacb..db298bb6 100644 --- a/pkg/loxinet/rules.go +++ b/pkg/loxinet/rules.go @@ -1571,6 +1571,13 @@ func (R *RuleH) AddLbRule(serv cmn.LbServiceArg, servSecIPs []cmn.LbSecIPArg, al return RuleEpCountErr, errors.New("endpoints-range error") } + // Validate persist timeout + if serv.Sel == cmn.LbSelRrPersist { + if serv.PersistTimeout == 0 || serv.PersistTimeout > 24*60*60 { + serv.PersistTimeout = DefaultPersistTimeOut + } + } + // For ICMP service, non-zero port can't be specified if serv.Proto == "icmp" && serv.ServPort != 0 { return RuleUnknownServiceErr, errors.New("malformed-service error") @@ -1847,14 +1854,7 @@ func (R *RuleH) AddLbRule(serv cmn.LbServiceArg, servSecIPs []cmn.LbSecIPArg, al r.bgp = serv.Bgp r.ci = cmn.CIDefault r.privIP = privIP - r.pTO = 0 - if serv.Sel == cmn.LbSelRrPersist { - if serv.PersistTimeout == 0 || serv.PersistTimeout > 24*60*60 { - r.pTO = DefaultPersistTimeOut - } else { - r.pTO = serv.PersistTimeout - } - } + r.pTO = serv.PersistTimeout r.locIPs = make(map[string]struct{}) if !serv.Snat {