IP Pool is allocated per PDN

This commit is contained in:
Sukchan Lee 2017-07-29 00:53:54 +09:00
parent e7f68794d9
commit d3234014f7
4 changed files with 16 additions and 15 deletions

View File

@ -143,6 +143,7 @@ typedef struct _pdn_t {
c_uint8_t pre_emption_vulnerability;
void *context;
void *ip_pool;
} pdn_t;
/**************************************************

View File

@ -416,10 +416,6 @@ pgw_bearer_t *pgw_sess_add(c_uint8_t id)
d_assert(bearer, pgw_sess_remove(sess); return NULL,
"Can't add default bearer context");
sess->ip_pool = pgw_ip_pool_alloc();
d_assert(sess->ip_pool, pgw_sess_remove(sess); return NULL,
"Can't alloc IP pool");
return bearer;
}
@ -427,8 +423,6 @@ status_t pgw_sess_remove(pgw_sess_t *sess)
{
d_assert(sess, return CORE_ERROR, "Null param");
pgw_ip_pool_free(sess->ip_pool);
pgw_pdn_remove_all(sess);
pgw_bearer_remove_all(sess);
@ -488,6 +482,10 @@ pdn_t* pgw_pdn_add(pgw_sess_t *sess, c_int8_t *apn)
memset(pdn, 0, sizeof(pdn_t));
strcpy(pdn->apn, apn);
pdn->ip_pool = pgw_ip_pool_alloc();
d_assert(pdn->ip_pool, pgw_pdn_remove(pdn); return NULL,
"Can't alloc IP pool");
pdn->context = sess;
list_append(&sess->pdn_list, pdn);
@ -503,6 +501,8 @@ status_t pgw_pdn_remove(pdn_t *pdn)
sess = pdn->context;
d_assert(sess, return CORE_ERROR, "Null param");
pgw_ip_pool_free(pdn->ip_pool);
list_remove(&sess->pdn_list, pdn);
pool_free_node(&pgw_pdn_pool, pdn);

View File

@ -49,12 +49,6 @@ typedef struct _pgw_context_t {
list_t ip_pool_list;
} pgw_context_t;
typedef struct _pgw_ip_pool_t {
lnode_t node; /**< A node of list_t */
c_uint32_t ue_addr;
} pgw_ip_pool_t;
typedef struct _pgw_sess_t {
lnode_t node; /**< A node of list_t */
index_t index; /**< An index of this node */
@ -69,7 +63,6 @@ typedef struct _pgw_sess_t {
list_t pdn_list;
list_t bearer_list;
pgw_ip_pool_t *ip_pool;
} pgw_sess_t;
typedef struct _pgw_bearer_t {
@ -89,6 +82,12 @@ typedef struct _pgw_bearer_t {
pgw_sess_t *sess;
} pgw_bearer_t;
typedef struct _pgw_ip_pool_t {
lnode_t node; /**< A node of list_t */
c_uint32_t ue_addr;
} pgw_ip_pool_t;
CORE_DECLARE(status_t) pgw_context_init(void);
CORE_DECLARE(status_t) pgw_context_parse_config(void);
CORE_DECLARE(status_t) pgw_context_final(void);

View File

@ -151,8 +151,6 @@ void pgw_handle_create_session_request(
d_assert(bearer, return, "No Bearer Context");
sess = bearer->sess;
d_assert(sess, return, "Null param");
ip_pool = sess->ip_pool;
d_assert(ip_pool, return, "Null param");
memcpy(apn, req->access_point_name.data, req->access_point_name.len);
apn[req->access_point_name.len] = 0;
@ -163,6 +161,9 @@ void pgw_handle_create_session_request(
}
d_assert(pdn, pgw_sess_remove(sess); return, "No PDN Context");
ip_pool = pdn->ip_pool;
d_assert(ip_pool, pgw_sess_remove(sess); return, "No IP Pool");
memset(&gtp_message, 0, sizeof(gtp_message_t));
memset(&cause, 0, sizeof(cause));