Commit 38ace905 authored by Robert Schmidt's avatar Robert Schmidt

Check for shared objects beforing setting scheduler

parent 21dcd834
...@@ -33,6 +33,9 @@ ...@@ -33,6 +33,9 @@
#include "flexran_agent_mac_internal.h" #include "flexran_agent_mac_internal.h"
#include "flexran_agent_mac_slice_verification.h" #include "flexran_agent_mac_slice_verification.h"
extern SLIST_HEAD(flexran_so_handle,
flexran_agent_so_handle_s) flexran_handles[NUM_MAX_ENB];
Protocol__FlexranMessage * flexran_agent_generate_diff_mac_stats_report(Protocol__FlexranMessage *new_message, Protocol__FlexranMessage * flexran_agent_generate_diff_mac_stats_report(Protocol__FlexranMessage *new_message,
Protocol__FlexranMessage *old_message) { Protocol__FlexranMessage *old_message) {
...@@ -1025,6 +1028,15 @@ int load_dl_scheduler_function(mid_t mod_id, const char *function_name) { ...@@ -1025,6 +1028,15 @@ int load_dl_scheduler_function(mid_t mod_id, const char *function_name) {
} }
void *search_so(mid_t mod_id, char *name) {
flexran_agent_so_handle_t *so = NULL;
SLIST_FOREACH(so, &flexran_handles[mod_id], entries) {
if (strcmp(so->name, name) == 0)
return so->dl_handle;
}
return NULL;
}
void update_or_remove_dl(mid_t mod_id, Protocol__FlexSlice *s) { void update_or_remove_dl(mid_t mod_id, Protocol__FlexSlice *s) {
if (s->params_case == PROTOCOL__FLEX_SLICE__PARAMS__NOT_SET if (s->params_case == PROTOCOL__FLEX_SLICE__PARAMS__NOT_SET
&& !s->label && !s->scheduler) { && !s->label && !s->scheduler) {
...@@ -1033,8 +1045,12 @@ void update_or_remove_dl(mid_t mod_id, Protocol__FlexSlice *s) { ...@@ -1033,8 +1045,12 @@ void update_or_remove_dl(mid_t mod_id, Protocol__FlexSlice *s) {
if (!rc) if (!rc)
LOG_W(FLEXRAN_AGENT, "error while removing slice ID %d\n", s->id); LOG_W(FLEXRAN_AGENT, "error while removing slice ID %d\n", s->id);
} else { } else {
LOG_I(FLEXRAN_AGENT, "updating DL slice ID %d\n", s->id); void *lib = search_so(mod_id, s->scheduler);
const int rc = flexran_create_dl_slice(mod_id, s); LOG_I(FLEXRAN_AGENT,
"updating DL slice ID %d (library handle %p)\n",
s->id,
lib);
const int rc = flexran_create_dl_slice(mod_id, s, lib);
if (rc < 0) if (rc < 0)
LOG_W(FLEXRAN_AGENT, LOG_W(FLEXRAN_AGENT,
"error while update slice ID %d: flexran_create_dl_slice() -> %d\n", "error while update slice ID %d: flexran_create_dl_slice() -> %d\n",
...@@ -1050,8 +1066,12 @@ void update_or_remove_ul(mid_t mod_id, Protocol__FlexSlice *s) { ...@@ -1050,8 +1066,12 @@ void update_or_remove_ul(mid_t mod_id, Protocol__FlexSlice *s) {
if (!rc) if (!rc)
LOG_W(FLEXRAN_AGENT, "error while removing slice ID %d\n", s->id); LOG_W(FLEXRAN_AGENT, "error while removing slice ID %d\n", s->id);
} else { } else {
LOG_I(FLEXRAN_AGENT, "updating UL slice ID %d\n", s->id); void *lib = search_so(mod_id, s->scheduler);
const int rc = flexran_create_ul_slice(mod_id, s); LOG_I(FLEXRAN_AGENT,
"updating UL slice ID %d (library handle %p)\n",
s->id,
lib);
const int rc = flexran_create_ul_slice(mod_id, s, lib);
if (rc < 0) if (rc < 0)
LOG_W(FLEXRAN_AGENT, LOG_W(FLEXRAN_AGENT,
"error while updating slice ID %d: flexran_create_ul_slice() -> %d)\n", "error while updating slice ID %d: flexran_create_ul_slice() -> %d)\n",
...@@ -1099,8 +1119,12 @@ void apply_update_dl_slice_config(mid_t mod_id, Protocol__FlexSliceDlUlConfig *d ...@@ -1099,8 +1119,12 @@ void apply_update_dl_slice_config(mid_t mod_id, Protocol__FlexSliceDlUlConfig *d
LOG_E(FLEXRAN_AGENT, "cannot update scheduling algorithm: slice algorithm loaded\n"); LOG_E(FLEXRAN_AGENT, "cannot update scheduling algorithm: slice algorithm loaded\n");
return; return;
} }
LOG_I(FLEXRAN_AGENT, "loading DL new scheduling algorithm '%s'\n", dl->scheduler); void *lib = search_so(mod_id, dl->scheduler);
const int rc = flexran_set_dl_scheduler(mod_id, dl->scheduler); LOG_I(FLEXRAN_AGENT,
"loading DL new scheduling algorithm '%s' (library handle %p)\n",
dl->scheduler,
lib);
const int rc = flexran_set_dl_scheduler(mod_id, dl->scheduler, lib);
if (rc < 0) { if (rc < 0) {
LOG_E(FLEXRAN_AGENT, LOG_E(FLEXRAN_AGENT,
"error while updating scheduling algorithm: " "error while updating scheduling algorithm: "
...@@ -1147,8 +1171,12 @@ void apply_update_ul_slice_config(mid_t mod_id, Protocol__FlexSliceDlUlConfig *u ...@@ -1147,8 +1171,12 @@ void apply_update_ul_slice_config(mid_t mod_id, Protocol__FlexSliceDlUlConfig *u
LOG_E(FLEXRAN_AGENT, "cannot update scheduling algorithm: slice algorithm loaded\n"); LOG_E(FLEXRAN_AGENT, "cannot update scheduling algorithm: slice algorithm loaded\n");
return; return;
} }
LOG_I(FLEXRAN_AGENT, "loading new UL scheduling algorithm '%s'\n", ul->scheduler); void *lib = search_so(mod_id, ul->scheduler);
const int rc = flexran_set_ul_scheduler(mod_id, ul->scheduler); LOG_I(FLEXRAN_AGENT,
"loading new UL scheduling algorithm '%s' (library handle %p)\n",
ul->scheduler,
lib);
const int rc = flexran_set_ul_scheduler(mod_id, ul->scheduler, lib);
if (rc < 0) { if (rc < 0) {
LOG_E(FLEXRAN_AGENT, LOG_E(FLEXRAN_AGENT,
"error while updating scheduling algorithm: " "error while updating scheduling algorithm: "
......
...@@ -3116,7 +3116,7 @@ void flexran_set_ue_ul_slice_id(mid_t mod_id, mid_t ue_id, slice_id_t slice_id) ...@@ -3116,7 +3116,7 @@ void flexran_set_ue_ul_slice_id(mid_t mod_id, mid_t ue_id, slice_id_t slice_id)
ul->move_UE(ul->slices, ue_id, idx); ul->move_UE(ul->slices, ue_id, idx);
} }
int flexran_create_dl_slice(mid_t mod_id, const Protocol__FlexSlice *s) { int flexran_create_dl_slice(mid_t mod_id, const Protocol__FlexSlice *s, void *object) {
if (!mac_is_present(mod_id)) return 0; if (!mac_is_present(mod_id)) return 0;
void *params = NULL; void *params = NULL;
switch (s->params_case) { switch (s->params_case) {
...@@ -3133,7 +3133,7 @@ int flexran_create_dl_slice(mid_t mod_id, const Protocol__FlexSlice *s) { ...@@ -3133,7 +3133,7 @@ int flexran_create_dl_slice(mid_t mod_id, const Protocol__FlexSlice *s) {
char *l = s->label ? strdup(s->label) : NULL; char *l = s->label ? strdup(s->label) : NULL;
void *algo = &dl->dl_algo; // default scheduler void *algo = &dl->dl_algo; // default scheduler
if (s->scheduler) { if (s->scheduler) {
algo = dlsym(NULL, s->scheduler); algo = dlsym(object, s->scheduler);
if (!algo) { if (!algo) {
free(params); free(params);
LOG_E(FLEXRAN_AGENT, "cannot locate scheduler '%s'\n", s->scheduler); LOG_E(FLEXRAN_AGENT, "cannot locate scheduler '%s'\n", s->scheduler);
...@@ -3193,7 +3193,7 @@ int flexran_get_num_dl_slices(mid_t mod_id) { ...@@ -3193,7 +3193,7 @@ int flexran_get_num_dl_slices(mid_t mod_id) {
return RC.mac[mod_id]->pre_processor_dl.slices->num; return RC.mac[mod_id]->pre_processor_dl.slices->num;
} }
int flexran_create_ul_slice(mid_t mod_id, const Protocol__FlexSlice *s) { int flexran_create_ul_slice(mid_t mod_id, const Protocol__FlexSlice *s, void *object) {
if (!mac_is_present(mod_id)) return -1; if (!mac_is_present(mod_id)) return -1;
void *params = NULL; void *params = NULL;
switch (s->params_case) { switch (s->params_case) {
...@@ -3210,7 +3210,7 @@ int flexran_create_ul_slice(mid_t mod_id, const Protocol__FlexSlice *s) { ...@@ -3210,7 +3210,7 @@ int flexran_create_ul_slice(mid_t mod_id, const Protocol__FlexSlice *s) {
char *l = s->label ? strdup(s->label) : NULL; char *l = s->label ? strdup(s->label) : NULL;
void *algo = &ul->ul_algo; // default scheduler void *algo = &ul->ul_algo; // default scheduler
if (s->scheduler) { if (s->scheduler) {
algo = dlsym(NULL, s->scheduler); algo = dlsym(object, s->scheduler);
if (!algo) { if (!algo) {
free(params); free(params);
LOG_E(FLEXRAN_AGENT, "cannot locate scheduler '%s'\n", s->scheduler); LOG_E(FLEXRAN_AGENT, "cannot locate scheduler '%s'\n", s->scheduler);
...@@ -3276,9 +3276,9 @@ char *flexran_get_dl_scheduler_name(mid_t mod_id) { ...@@ -3276,9 +3276,9 @@ char *flexran_get_dl_scheduler_name(mid_t mod_id) {
return RC.mac[mod_id]->pre_processor_dl.dl_algo.name; return RC.mac[mod_id]->pre_processor_dl.dl_algo.name;
} }
int flexran_set_dl_scheduler(mid_t mod_id, char *sched) { int flexran_set_dl_scheduler(mid_t mod_id, char *sched, void *object) {
if (!mac_is_present(mod_id)) return -1; if (!mac_is_present(mod_id)) return -1;
void *d = dlsym(NULL, sched); void *d = dlsym(object, sched);
if (!d) return -2; if (!d) return -2;
pp_impl_param_t *dl_pp = &RC.mac[mod_id]->pre_processor_dl; pp_impl_param_t *dl_pp = &RC.mac[mod_id]->pre_processor_dl;
dl_pp->dl_algo.unset(&dl_pp->dl_algo.data); dl_pp->dl_algo.unset(&dl_pp->dl_algo.data);
...@@ -3292,9 +3292,9 @@ char *flexran_get_ul_scheduler_name(mid_t mod_id) { ...@@ -3292,9 +3292,9 @@ char *flexran_get_ul_scheduler_name(mid_t mod_id) {
return RC.mac[mod_id]->pre_processor_ul.ul_algo.name; return RC.mac[mod_id]->pre_processor_ul.ul_algo.name;
} }
int flexran_set_ul_scheduler(mid_t mod_id, char *sched) { int flexran_set_ul_scheduler(mid_t mod_id, char *sched, void *object) {
if (!mac_is_present(mod_id)) return -1; if (!mac_is_present(mod_id)) return -1;
void *d = dlsym(NULL, sched); void *d = dlsym(object, sched);
if (!d) return -2; if (!d) return -2;
pp_impl_param_t *ul_pp = &RC.mac[mod_id]->pre_processor_ul; pp_impl_param_t *ul_pp = &RC.mac[mod_id]->pre_processor_ul;
ul_pp->ul_algo.unset(&ul_pp->ul_algo.data); ul_pp->ul_algo.unset(&ul_pp->ul_algo.data);
......
...@@ -676,8 +676,9 @@ int flexran_get_ue_ul_slice_id(mid_t mod_id, mid_t ue_id); ...@@ -676,8 +676,9 @@ int flexran_get_ue_ul_slice_id(mid_t mod_id, mid_t ue_id);
/* Set the UL slice for a UE */ /* Set the UL slice for a UE */
void flexran_set_ue_ul_slice_id(mid_t mod_id, mid_t ue_id, slice_id_t slice_id); void flexran_set_ue_ul_slice_id(mid_t mod_id, mid_t ue_id, slice_id_t slice_id);
/* Create slice in DL, returns the new slice index */ /* Create slice in DL, returns the new slice index, object can be shared
int flexran_create_dl_slice(mid_t mod_id, const Protocol__FlexSlice *s); * library for the scheduler or NULL */
int flexran_create_dl_slice(mid_t mod_id, const Protocol__FlexSlice *s, void *object);
/* Remove slice in DL, returns new number of slices or -1 on error */ /* Remove slice in DL, returns new number of slices or -1 on error */
int flexran_remove_dl_slice(mid_t mod_id, const Protocol__FlexSlice *s); int flexran_remove_dl_slice(mid_t mod_id, const Protocol__FlexSlice *s);
...@@ -691,8 +692,9 @@ void flexran_get_dl_slice(mid_t mod_id, ...@@ -691,8 +692,9 @@ void flexran_get_dl_slice(mid_t mod_id,
/* Get the number of slices in DL */ /* Get the number of slices in DL */
int flexran_get_num_dl_slices(mid_t mod_id); int flexran_get_num_dl_slices(mid_t mod_id);
/* Create slice in UL, returns the new slice index */ /* Create slice in UL, returns the new slice index, object can be shared library
int flexran_create_ul_slice(mid_t mod_id, const Protocol__FlexSlice *s); * for the scheduler or NULL */
int flexran_create_ul_slice(mid_t mod_id, const Protocol__FlexSlice *s, void *object);
/* Remove slice in UL */ /* Remove slice in UL */
int flexran_remove_ul_slice(mid_t mod_id, const Protocol__FlexSlice *s); int flexran_remove_ul_slice(mid_t mod_id, const Protocol__FlexSlice *s);
...@@ -708,14 +710,14 @@ int flexran_get_num_ul_slices(mid_t mod_id); ...@@ -708,14 +710,14 @@ int flexran_get_num_ul_slices(mid_t mod_id);
/* Get the name of/Set the DL scheduling algorithm. If slicing is active, this /* Get the name of/Set the DL scheduling algorithm. If slicing is active, this
* corresponds to the default algorithm for slices, otherwise the currently * corresponds to the default algorithm for slices, otherwise the currently
* used one. */ * used one. object is a shared object in which to find the scheduler */
char *flexran_get_dl_scheduler_name(mid_t mod_id); char *flexran_get_dl_scheduler_name(mid_t mod_id);
int flexran_set_dl_scheduler(mid_t mod_id, char *sched); int flexran_set_dl_scheduler(mid_t mod_id, char *sched, void *object);
/* Get the name of/Set the UL scheduler algorithm. Same applies as for the DL /* Get the name of/Set the UL scheduler algorithm. Same applies as for the DL
* case */ * case. object is a shared object in which to find the scheduler */
char *flexran_get_ul_scheduler_name(mid_t mod_id); char *flexran_get_ul_scheduler_name(mid_t mod_id);
int flexran_set_ul_scheduler(mid_t mod_id, char *sched); int flexran_set_ul_scheduler(mid_t mod_id, char *sched, void *object);
/************************** S1AP **************************/ /************************** S1AP **************************/
/* Get the number of MMEs to be connected */ /* Get the number of MMEs to be connected */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment