Skip to content
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

drouting: allow DB_BIGINT for dr_rules.ruleid column #3203

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
14 changes: 7 additions & 7 deletions modules/drouting/dr_load.c
Original file line number Diff line number Diff line change
@@ -368,9 +368,9 @@ rt_data_t* dr_load_routing_info(struct head_db *part,
for(i=0; i < RES_ROW_N(res); i++) {
row = RES_ROWS(res) + i;
/* DB ID column */
if ( VAL_TYPE( ROW_VALUES(row) ) == DB_INT ) {
/* if INT type, convert it to string */
check_val( id_drd_col, ROW_VALUES(row), DB_INT, 1, 0);
if ( VAL_TYPE( ROW_VALUES(row) ) == DB_INT || VAL_TYPE( ROW_VALUES(row) ) == DB_BIGINT ) {
/* if INT or BIGINT type, convert it to string */
check_val2( id_drd_col, ROW_VALUES(row), DB_INT, DB_BIGINT, 1, 0);
/* int2bstr returns a null terminated string */
str_vals[STR_VALS_ID_DRD_COL] =
int2bstr((unsigned long)VAL_INT(ROW_VALUES(row)),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we need to read as VAL_INT or VAL_BIGINT, to ensure correctness.

@@ -522,9 +522,9 @@ rt_data_t* dr_load_routing_info(struct head_db *part,
for(i=0; i < RES_ROW_N(res); i++) {
row = RES_ROWS(res) + i;
/* DB ID column */
if ( VAL_TYPE( ROW_VALUES(row) ) == DB_INT ) {
/* if INT type, convert it to string */
check_val( id_drc_col, ROW_VALUES(row), DB_INT, 1, 0);
if ( VAL_TYPE( ROW_VALUES(row) ) == DB_INT || VAL_TYPE( ROW_VALUES(row) ) == DB_BIGINT ) {
/* if INT or BIGINT type, convert it to string */
check_val2( id_drc_col, ROW_VALUES(row), DB_INT, DB_BIGINT, 1, 0);
/* int2bstr returns a null terminated string */
str_vals[STR_VALS_ID_DRC_COL] =
int2bstr((unsigned long)VAL_INT(ROW_VALUES(row)),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar, read as VAL_INT or VAL_BIGINT.

@@ -641,7 +641,7 @@ rt_data_t* dr_load_routing_info(struct head_db *part,
for(i=0; i < RES_ROW_N(res); i++) {
row = RES_ROWS(res) + i;
/* RULE_ID column */
check_val( rule_id_drr_col, ROW_VALUES(row), DB_INT, 1, 0);
check_val2( rule_id_drr_col, ROW_VALUES(row), DB_INT, DB_BIGINT, 1, 0);
int_vals[INT_VALS_RULE_ID_DRR_COL] = VAL_INT (ROW_VALUES(row));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar, read as VAL_INT or VAL_BIGINT.

Also, the rule ID is exposed as AVP to script, so as an integer :-/ (for Carriers and GWs we have string ID which is used only for log printing and it is not stored into internal structures), so it may be subject to an overflow (while reading 64b from DB)

So, at least, we need to upgrade the rule->id to long long (and also check the implications of that - not sure where this ID is used further in the code). And the rule_id_avp to expose the ID as string, not int.

/* GROUP column */
check_val( group_drr_col, ROW_VALUES(row)+1, DB_STRING, 1, 1);