Skip to content
This repository has been archived by the owner on Jun 30, 2022. It is now read-only.

Fix improper handling of PfcpXact during UPF PFCP message processing. #41

Merged
merged 1 commit into from
Nov 6, 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
28 changes: 15 additions & 13 deletions lib/pfcp/src/pfcp_xact.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,21 @@ PfcpXact *PfcpXactLocalCreate(PfcpNode *gnode, PfcpHeader *header, Bufblk *bufBl
}
*/

status = PfcpXactUpdateTx(xact, header, bufBlk);
UTLT_Assert(status == STATUS_OK, goto err, "Update Tx failed");

// Both of xact->gnode->localList and xact->gnode->remoteList had been already initialized in PfcpAddNode()
if (xact->origin == PFCP_LOCAL_ORIGINATOR) {
ListInsert(xact, &xact->gnode->localList);
} else {
ListInsert(xact, &xact->gnode->remoteList);
}

status = PfcpXactUpdateTx(xact, header, bufBlk);
UTLT_Assert(status == STATUS_OK, goto err, "Update Tx failed");

UTLT_Trace("[%d] %s Create peer [%s]:%d\n",
xact->transactionId, xact->origin == PFCP_LOCAL_ORIGINATOR ?
"local" : "remote",
GetIP(&gnode->sock->remoteAddr), GetPort(&gnode->sock->remoteAddr));
GetIP(&gnode->sock->remoteAddr), GetPort(&gnode->sock->remoteAddr));

return xact;

err:
Expand Down Expand Up @@ -151,11 +153,10 @@ PfcpXact *PfcpXactRemoteCreate(PfcpNode *gnode, uint32_t sqn) {
xact->holdingReCount = PFCP_T3_DUPLICATED_RETRY_COUNT;
}

// Both of xact->gnode->localList and xact->gnode->remoteList had been already initialized in PfcpAddNode()
if (xact->origin == PFCP_LOCAL_ORIGINATOR) {
ListHeadInit(&xact->gnode->localList);
ListInsert(xact, &xact->gnode->localList);
} else {
ListHeadInit(&xact->gnode->remoteList);
ListInsert(xact, &xact->gnode->remoteList);
}

Expand All @@ -166,6 +167,9 @@ PfcpXact *PfcpXactRemoteCreate(PfcpNode *gnode, uint32_t sqn) {
return xact;

err:
if (xact->timerResponse) {
TimerDelete(xact->timerResponse);
}
IndexFree(&pfcpXactPool, xact);
return NULL;
}
Expand All @@ -190,14 +194,12 @@ Status PfcpXactDelete(PfcpXact *xact) {
UTLT_Trace("[%d] %s Delete peer [%s]:%d\n", xact->transactionId,
xact->origin == PFCP_LOCAL_ORIGINATOR ? "local" : "remote",
GetIP(&xact->gnode->sock->remoteAddr), GetPort(&xact->gnode->sock->remoteAddr));
if (xact->origin == PFCP_LOCAL_ORIGINATOR) {
ListRemove(xact);
} else if (xact->origin == PFCP_REMOTE_ORIGINATOR) {
ListRemove(xact);
}

ListRemove(xact);

xact->origin = 0;
xact->transactionId = 0;
xact->gnode = NULL;
xact->step = 0;
xact->seq[0].type = 0;
xact->seq[1].type = 0;
Expand Down Expand Up @@ -352,7 +354,7 @@ Status PfcpXactUpdateTx(PfcpXact *xact, PfcpHeader *header, Bufblk *bufBlk) {
memset(localHeader, 0, headerLen);
localHeader->version = PFCP_VERSION;
localHeader->type = header->type;
if(header->type >= PFCP_SESSION_ESTABLISHMENT_REQUEST) { // with SEID
if (header->type >= PFCP_SESSION_ESTABLISHMENT_REQUEST) { // with SEID
localHeader->seidP = 1;
localHeader->seid = htobe64(header->seid);
localHeader->sqn = PfcpTransactionId2Sqn(xact->transactionId);
Expand Down Expand Up @@ -709,7 +711,7 @@ Status PfcpXactReceive(PfcpNode *gnode, PfcpHeader *header, PfcpXact **xact) {

status = PfcpXactUpdateRx(newXact, header->type);
if (status != STATUS_OK) {
IndexFree(&pfcpXactPool, newXact);
PfcpXactDelete(newXact);
return status;
}

Expand Down
3 changes: 2 additions & 1 deletion src/n4/n4_dispatcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void UpfDispatcher(const Event *event) {
UTLT_Assert(xact, BufblkFree(bufBlk); return, "pfcpXactLocalCreate error");

status = PfcpXactCommit(xact);
UTLT_Assert(status == STATUS_OK, return, "xact commit error");
UTLT_Assert(status == STATUS_OK, PfcpXactDelete(xact); return, "xact commit error");

break;
}
Expand Down Expand Up @@ -133,6 +133,7 @@ void UpfDispatcher(const Event *event) {
UTLT_Info("[PFCP] Handle PFCP session report response");
UpfN4HandleSessionReportResponse(session, xact,
&pfcpMessage->pFCPSessionReportResponse);
if (xact->gnode) PfcpXactDelete(xact);
break;
default:
UTLT_Error("No implement pfcp type: %d", pfcpMessage->header.type);
Expand Down