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

mtree can't handle prefixes of 32 characters #179

Closed
beorn247 opened this issue May 28, 2015 · 3 comments
Closed

mtree can't handle prefixes of 32 characters #179

beorn247 opened this issue May 28, 2015 · 3 comments

Comments

@beorn247
Copy link

mtree.h defines MT_MAX_DEPTH as 32 and the tprefix database table field is defined as a varchar(32) but the module fails to start if a prefix of 32 characters is present in the database table mapped to the mtree. The error message on start is:

0(10465) ERROR: mtree [mtree.c:156]: mt_add_to_tree(): max prefix len exceeded
0(10465) ERROR: mtree [mtree_mod.c:603]: mt_load_db(): Error adding info to tree

To reproduce do the following:

Kamailio script:

loadmodule "mtree.so"
modparam("mtree", "db_url", DBURL)
modparam("mtree", "mtree", "name=mtree;dbtable=mtree;type=0;multi=0")
modparam("mtree", "char_list", "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+-.")

MySQL:
(create a table called mtree per the code in utils/kamctl/mysql/mtree-create.sql)

insert into mtree values (1, '12345678901234567890123456789012', 'foo', 'bar', current_timestamp, 'baz');

Start kamailio and observe that it fails to start. Enable debugging to see the error messages specified above.

Changing the tprefix to '1234567890123456789012345678901' makes Kamailio start successfully.

I propose a fix would entail making Kamailio support prefixes of 32 characters since we then can use GUIDs/UUIDs as "prefixes" without alteration and also adding to the mtree documentation that the maximum prefix length is 32 characters. Another fix would be to let the mtree code be but change the table creation scripts under utils/kamctl/ to create the tprefix field as varchar(31) (and add info about the constraint to the documentation).

@beorn247
Copy link
Author

beorn247 commented Jun 1, 2015

I propose a fix would entail making Kamailio support prefixes of 32 characters since we then can use GUIDs/UUIDs as "prefixes" without alteration

GUIDs/UUIDs with the hyphens removed that is.

@miconda
Copy link
Member

miconda commented Jun 3, 2015

I changed the internal limit to 64, which is 63 chars + ending 0 -- added relevant info to docs. The database definition stays with lower size, can be increased by need.

@miconda miconda closed this as completed Jun 3, 2015
@beorn247
Copy link
Author

beorn247 commented Jun 3, 2015

Thank you very much!

The issue was fixed through the following commits:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants