From 440edfdb3d5677b81662d0606a9679f1ecd785e4 Mon Sep 17 00:00:00 2001 From: "CTFang@WireLab" Date: Thu, 5 Sep 2024 07:36:18 +0000 Subject: [PATCH 1/2] feat: add UPF RemoveURR() --- internal/context/upf.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/internal/context/upf.go b/internal/context/upf.go index d14a0d3f..9063dec1 100644 --- a/internal/context/upf.go +++ b/internal/context/upf.go @@ -610,6 +610,17 @@ func (upf *UPF) RemoveQER(qer *QER) (err error) { return nil } +func (upf *UPF) RemoveURR(urr *URR) (err error) { + if upf.UPFStatus != AssociatedSetUpSuccess { + err = fmt.Errorf("UPF[%s] not Associate with SMF", upf.NodeID.ResolveNodeIdToIp().String()) + return err + } + + upf.urrIDGenerator.FreeID(int64(urr.URRID)) + upf.urrPool.Delete(urr.URRID) + return nil +} + func (upf *UPF) isSupportSnssai(snssai *SNssai) bool { for _, snssaiInfo := range upf.SNssaiInfos { if snssaiInfo.SNssai.Equal(snssai) { From 53befc34a3f0664e4312c54b5d695a1ab2d63fb0 Mon Sep 17 00:00:00 2001 From: "CTFang@WireLab" Date: Wed, 11 Sep 2024 05:43:41 +0000 Subject: [PATCH 2/2] fix: remove urr when deactivate tunnel --- internal/context/datapath.go | 28 ++++++++++++++++++++++++---- internal/context/upf.go | 1 + 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/internal/context/datapath.go b/internal/context/datapath.go index 3b540813..6e9e4db2 100644 --- a/internal/context/datapath.go +++ b/internal/context/datapath.go @@ -185,14 +185,14 @@ func (node *DataPathNode) DeactivateUpLinkTunnel(smContext *SMContext) { if far := pdr.FAR; far != nil { err = node.UPF.RemoveFAR(far) if err != nil { - logger.CtxLog.Warnln("Deactivated UpLinkTunnel", err) + logger.CtxLog.Warnln("Deactivated UpLinkTunnel RemoveFAR", err) } bar := far.BAR if bar != nil { err = node.UPF.RemoveBAR(bar) if err != nil { - logger.CtxLog.Warnln("Deactivated UpLinkTunnel", err) + logger.CtxLog.Warnln("Deactivated UpLinkTunnel RemoveBAR", err) } } } @@ -201,7 +201,17 @@ func (node *DataPathNode) DeactivateUpLinkTunnel(smContext *SMContext) { if qer != nil { err = node.UPF.RemoveQER(qer) if err != nil { - logger.CtxLog.Warnln("Deactivated UpLinkTunnel", err) + logger.CtxLog.Warnln("Deactivated UpLinkTunnel RemoveQER", err) + } + } + } + } + + if urrList := pdr.URR; urrList != nil { + for _, urr := range urrList { + if urr != nil { + if err = node.UPF.RemoveURR(urr); err != nil { + logger.CtxLog.Warnln("Deactivated UpLinkTunnel RemoveURR:", err) } } } @@ -236,7 +246,17 @@ func (node *DataPathNode) DeactivateDownLinkTunnel(smContext *SMContext) { if qer != nil { err = node.UPF.RemoveQER(qer) if err != nil { - logger.CtxLog.Warnln("Deactivated UpLinkTunnel", err) + logger.CtxLog.Warnln("Deactivated DownLinkTunnel", err) + } + } + } + } + + if urrList := pdr.URR; urrList != nil { + for _, urr := range urrList { + if urr != nil { + if err = node.UPF.RemoveURR(urr); err != nil { + logger.CtxLog.Warnln("Deactivated DownLinkTunnel RemoveURR:", err) } } } diff --git a/internal/context/upf.go b/internal/context/upf.go index 9063dec1..c534418c 100644 --- a/internal/context/upf.go +++ b/internal/context/upf.go @@ -610,6 +610,7 @@ func (upf *UPF) RemoveQER(qer *QER) (err error) { return nil } +// TODO: add unit test func (upf *UPF) RemoveURR(urr *URR) (err error) { if upf.UPFStatus != AssociatedSetUpSuccess { err = fmt.Errorf("UPF[%s] not Associate with SMF", upf.NodeID.ResolveNodeIdToIp().String())