-
Notifications
You must be signed in to change notification settings - Fork 95
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
Add Delete REST API to user_plane_information (upNodes, links). #69
Changes from all commits
cdebee6
3f4b2bd
2a56573
ebadae4
db10b07
6543443
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package upi | ||
|
||
import ( | ||
"context" | ||
"net/http" | ||
|
||
"github.com/gin-gonic/gin" | ||
|
@@ -13,6 +14,9 @@ import ( | |
|
||
func GetUpNodesLinks(c *gin.Context) { | ||
upi := smf_context.SMF_Self().UserPlaneInformation | ||
upi.Mu.RLock() | ||
defer upi.Mu.RUnlock() | ||
|
||
nodes := upi.UpNodesToConfiguration() | ||
links := upi.LinksToConfiguration() | ||
|
||
|
@@ -31,6 +35,9 @@ func GetUpNodesLinks(c *gin.Context) { | |
|
||
func PostUpNodesLinks(c *gin.Context) { | ||
upi := smf_context.SMF_Self().UserPlaneInformation | ||
upi.Mu.Lock() | ||
defer upi.Mu.Unlock() | ||
|
||
var json factory.UserPlaneInformation | ||
if err := c.ShouldBindJSON(&json); err != nil { | ||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()}) | ||
|
@@ -43,8 +50,33 @@ func PostUpNodesLinks(c *gin.Context) { | |
for _, upf := range upi.UPFs { | ||
// only associate new ones | ||
if upf.UPF.UPFStatus == smf_context.NotAssociated { | ||
upf.UPF.Ctx, upf.UPF.CancelFunc = context.WithCancel(context.Background()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Save context and cancel function on the UPF data model so that it can be used to cancel heartbeat thread of this UPF. |
||
go association.ToBeAssociatedWithUPF(smf_context.SMF_Self().Ctx, upf.UPF) | ||
} | ||
} | ||
c.JSON(http.StatusOK, gin.H{"status": "OK"}) | ||
} | ||
|
||
func DeleteUpNodeLink(c *gin.Context) { | ||
// current version does not allow node deletions when ulcl is enabled | ||
if smf_context.SMF_Self().ULCLSupport { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest to support ULCL case under a different PR. |
||
c.JSON(http.StatusForbidden, gin.H{}) | ||
} else { | ||
req := httpwrapper.NewRequest(c.Request, nil) | ||
req.Params["upNodeRef"] = c.Params.ByName("upNodeRef") | ||
upNodeRef := req.Params["upNodeRef"] | ||
upi := smf_context.SMF_Self().UserPlaneInformation | ||
upi.Mu.Lock() | ||
defer upi.Mu.Unlock() | ||
if upNode, ok := upi.UPNodes[upNodeRef]; ok { | ||
if upNode.Type == smf_context.UPNODE_UPF { | ||
go association.ReleaseAllResourcesOfUPF(upNode.UPF) | ||
} | ||
upi.UpNodeDelete(upNodeRef) | ||
upNode.UPF.CancelFunc() | ||
c.JSON(http.StatusOK, gin.H{"status": "OK"}) | ||
} else { | ||
c.JSON(http.StatusNotFound, gin.H{}) | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Read lock is being used for session creation because it seems that multiple session creations are allowed in respect to user_plane_information consistency. Same comment for
HandlePDUSessionSMContextUpdate
.