Implement removal of endpoint

For unit testing, allow to remove endpoints such that we could reuse a
port/IP combination.

The function does not take care of endpoints that are still "dangling",
it is the user's responsibility to remove all existing TEIDs.
This commit is contained in:
Robert Schmidt
2026-02-17 13:52:32 +01:00
parent d290850e59
commit d6c7321077
3 changed files with 20 additions and 0 deletions
+14
View File
@@ -613,6 +613,20 @@ instance_t gtpv1Init(openAddr_t context)
return id;
}
/* \brief remove the GTP instance from the list of instances. Does not make an
* attempt to free corresponding TEIDs, as we have many and will simply not
* reuse it later. */
int gtpv1Term(instance_t instance)
{
pthread_mutex_lock(&globGtp.gtp_lock);
getInstRetInt(compatInst(instance));
gtpv1uReceiverCancel(inst->thrData.t);
close(instance);
globGtp.instances.erase(instance);
pthread_mutex_unlock(&globGtp.gtp_lock);
return 0;
}
void GtpuUpdateTunnelOutgoingAddressAndTeid(instance_t instance,
ue_id_t ue_id,
ebi_t bearer_id,
+1
View File
@@ -130,6 +130,7 @@ typedef struct gtpv1u_gnb_delete_tunnel_req_s gtpv1u_gnb_delete_tunnel_req_t;
size_t len);
instance_t gtpv1Init(openAddr_t context);
int gtpv1Term(instance_t inst);
void *gtpv1uTask(void *args);
#ifdef __cplusplus
+5
View File
@@ -136,6 +136,11 @@ static void run_basic_test(uint32_t ue_id,
EXPECT_EQ(ret, 0);
ret = newGtpuDeleteAllTunnels(ep2, ue_id);
EXPECT_EQ(ret, 0);
ret = gtpv1Term(ep1);
EXPECT_EQ(ret, 0);
ret = gtpv1Term(ep2);
EXPECT_EQ(ret, 0);
}
static int recv_count_qfi = 0;