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

SMF hearbeat and DLPDR crashes fix #13

Merged
merged 3 commits into from
May 1, 2021
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
2 changes: 1 addition & 1 deletion context/user_plane_information.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func NewUserPlaneInformation(upTopology *factory.UserPlaneInformation) *UserPlan
}
upNode.NodeID.NodeIdType = pfcpType.NodeIdTypeIpv4Address
if ns, err := net.LookupHost(string(upNode.NodeID.NodeIdValue)); err != nil {
fmt.Println("Host lookup failed: %+v", err)
fmt.Printf("Host lookup failed for Node: %v with error %v ", upNode.NodeID, err)
ip = net.IPv4zero
} else {
ip = net.ParseIP(ns[0]).To4()
Expand Down
3 changes: 1 addition & 2 deletions pfcp/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,13 @@ func HandlePfcpHeartbeatResponse(msg *pfcpUdp.Message) {

//Get NodeId from Seq:NodeId Map
seq := msg.PfcpMessage.Header.SequenceNumber
nodeID := pfcp_message.PfcpTxns[seq]
nodeID := pfcp_message.FetchPfcpTxn(seq)

if nodeID == nil {
logger.PfcpLog.Errorln("No pending pfcp heartbeat response for sequence no: %v", seq)
metrics.IncrementN4MsgStats(smf_context.SMF_Self().NfInstanceID, pfcpmsgtypes.PfcpMsgTypeString(msg.PfcpMessage.Header.MessageType), "In", "Failure", "invalid_seqno")
return
}
delete(pfcp_message.PfcpTxns, seq)

logger.PfcpLog.Infof("Handle PFCP Heartbeat Response Seq[%d] with NodeID[%s]", seq, nodeID.ResolveNodeIdToIp().String())

Expand Down
23 changes: 21 additions & 2 deletions pfcp/message/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package message

import (
"net"
"sync"

"sync/atomic"

Expand All @@ -23,7 +24,25 @@ func init() {
PfcpTxns = make(map[uint32]*pfcpType.NodeID)
}

var PfcpTxns map[uint32]*pfcpType.NodeID
var (
PfcpTxns map[uint32]*pfcpType.NodeID
PfcpTxnLock sync.Mutex
)

func FetchPfcpTxn(seqNo uint32) (upNodeID *pfcpType.NodeID) {
PfcpTxnLock.Lock()
defer PfcpTxnLock.Unlock()
if upNodeID = PfcpTxns[seqNo]; upNodeID != nil {
delete(PfcpTxns, seqNo)
}
return upNodeID
}

func InsertPfcpTxn(seqNo uint32, upNodeID *pfcpType.NodeID) {
PfcpTxnLock.Lock()
defer PfcpTxnLock.Unlock()
PfcpTxns[seqNo] = upNodeID
}

func SendHeartbeatRequest(upNodeID pfcpType.NodeID) error {
pfcpMsg, err := BuildPfcpHeartbeatRequest()
Expand Down Expand Up @@ -52,7 +71,7 @@ func SendHeartbeatRequest(upNodeID pfcpType.NodeID) error {
return err
}
logger.PfcpLog.Infof("Sent PFCP Heartbeat Request Seq[%d] to NodeID[%s]", seq, upNodeID.ResolveNodeIdToIp().String())
PfcpTxns[message.Header.SequenceNumber] = &upNodeID
InsertPfcpTxn(message.Header.SequenceNumber, &upNodeID)
return nil
}

Expand Down
4 changes: 4 additions & 0 deletions producer/pdu_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,10 @@ func HandlePDUSessionSMContextUpdate(smContextRef string, body models.UpdateSmCo
DLPDR.FAR.ApplyAction.Forw = false
DLPDR.FAR.ApplyAction.Buff = true
DLPDR.FAR.ApplyAction.Nocp = true
//Set DL Tunnel info to nil
if DLPDR.FAR.ForwardingParameters != nil {
DLPDR.FAR.ForwardingParameters.OuterHeaderCreation = nil
}
smContext.PendingUPF[ANUPF.GetNodeIP()] = true
}

Expand Down