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

multiple subsytems: unsigned integer conversion fixes #3828

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

devopsec
Copy link
Contributor

@devopsec devopsec commented Apr 25, 2024

Pre-Submission Checklist

  • Commit message has the format required by CONTRIBUTING guide
  • Commits are split per component (core, individual modules, libs, utils, ...)
  • Each component has a single commit (if not, squash them into one commit)
  • No commits to README files for modules (changes must be done to docbook files
    in doc/ subfolder, the README file is autogenerated)

Type Of Change

  • Small bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds new functionality)
  • Breaking change (fix or feature that would change existing functionality)

Checklist:

  • PR should be backported to stable branches
  • Tested changes locally
  • Related to issue #XXXX (replace XXXX with an open issue number)

Description

Adding support for converting unsigned integers from database tables into kamailio pseudo variables usable in the routing config.
This is quite useful when pulling int unsigned fields from a database, in modules that support "extra fields" in their module parameters.

@devopsec
Copy link
Contributor Author

devopsec commented Apr 25, 2024

For testing this was validated on master with the setup below.

environment

root@kam:~# uname -a
Linux kam 6.1.0-9-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.27-1 (2023-05-08) x86_64 GNU/Linux
root@kam:~# lsb_release -a
Distributor ID:	Debian
Description:	Debian GNU/Linux 12 (bookworm)
Release:	12
Codename:	bookworm
root@kam:~# kamailio -I
Print out of kamailio internals
  Version: kamailio 5.9.0-dev1 (x86_64/linux) 
  Default config: /usr/local/etc/kamailio/kamailio.cfg
  Default paths to modules: /usr/local/lib64/kamailio/modules
  Compile flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MMAP, PKG_MALLOC, MEM_JOIN_FREE, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLOCKLIST, HAVE_RESOLV_RES, TLS_PTHREAD_MUTEX_SHARED
  MAX_RECV_BUFFER_SIZE=262144
  MAX_SEND_BUFFER_SIZE=262144
  MAX_URI_SIZE=1024
  BUF_SIZE=65535
  DEFAULT PKG_SIZE=8MB
  DEFAULT SHM_SIZE=64MB
  ADAPTIVE_WAIT_LOOPS=1024
  TCP poll methods: poll, epoll_lt, epoll_et, sigio_rt, select
  Source code revision ID: unknown 
  Compiled with: gcc 12.2.0
  Compiled architecture: x86_64
  Compiled on: 16:39:25 Apr 23 2024
Thank you for flying kamailio!

setup

  1. compile kamalio and all modules outlined in kamailio.cfg (a simplified version of a routing config with the most popular modules loaded to ensure none of them crash from the changes)
  2. install mariadb-server and run kamdbctl create
  3. add test table / data to kamailio DB using test.sql
  4. create a self signed key/cert pair in /usr/local/etc/kamailio
  5. configure network defines per your server in /usr/local/etc/kamailio/kamailio.cfg
  6. run kamailio: kamailio -P /var/run/kamailio/kamailio.pid -m 512 -M 128 -E -e -DD

run test

send a call via any uac to the server and watch the output from the foreground kamailio process:

(65041) INFO: [/usr/local/etc/kamailio/kamailio.cfg:876:DEFAULT_ROUTE] [skpqdsqmwemdnhx@devbox1:INVITE:<null>] test1: -2,147,483,000
(65041) INFO: [/usr/local/etc/kamailio/kamailio.cfg:877:DEFAULT_ROUTE] [skpqdsqmwemdnhx@devbox1:INVITE:<null>] test2: 0
(65041) INFO: [/usr/local/etc/kamailio/kamailio.cfg:878:DEFAULT_ROUTE] [skpqdsqmwemdnhx@devbox1:INVITE:<null>] test3: 2,147,483,000
(65041) INFO: [/usr/local/etc/kamailio/kamailio.cfg:879:DEFAULT_ROUTE] [skpqdsqmwemdnhx@devbox1:INVITE:<null>] test4: 4,294,967,000
(65041) INFO: [/usr/local/etc/kamailio/kamailio.cfg:881:DEFAULT_ROUTE] [skpqdsqmwemdnhx@devbox1:INVITE:<null>] (local) var(test1)=-2147483000 vn(test1)=-2147483000 avp(test1)=-2147483000 shv(test1)=-2147483000
(65041) INFO: [/usr/local/etc/kamailio/kamailio.cfg:883:DEFAULT_ROUTE] [skpqdsqmwemdnhx@devbox1:INVITE:<null>] (local) var(test2)=0 vn(test2)=0 avp(test2)=0 shv(test2)=0
(65041) INFO: [/usr/local/etc/kamailio/kamailio.cfg:885:DEFAULT_ROUTE] [skpqdsqmwemdnhx@devbox1:INVITE:<null>] (local) var(test3)=2147483000 vn(test3)=2147483000 avp(test3)=2147483000 shv(test3)=2147483000
(65041) INFO: [/usr/local/etc/kamailio/kamailio.cfg:887:DEFAULT_ROUTE] [skpqdsqmwemdnhx@devbox1:INVITE:<null>] (local) var(test4)=-296 vn(test4)=-296 avp(test4)=-296 shv(test4)=-296
(65041) INFO: [/usr/local/etc/kamailio/kamailio.cfg:889:DEFAULT_ROUTE] [skpqdsqmwemdnhx@devbox1:INVITE:<null>] (signed) test1: -2,147,483,000
(65041) INFO: [/usr/local/etc/kamailio/kamailio.cfg:890:DEFAULT_ROUTE] [skpqdsqmwemdnhx@devbox1:INVITE:<null>] (signed) test2: 0
(65041) INFO: [/usr/local/etc/kamailio/kamailio.cfg:891:DEFAULT_ROUTE] [skpqdsqmwemdnhx@devbox1:INVITE:<null>] (signed) test3: 2,147,483,000
(65041) INFO: [/usr/local/etc/kamailio/kamailio.cfg:892:DEFAULT_ROUTE] [skpqdsqmwemdnhx@devbox1:INVITE:<null>] (unsigned) test4: 0
(65041) INFO: [/usr/local/etc/kamailio/kamailio.cfg:893:DEFAULT_ROUTE] [skpqdsqmwemdnhx@devbox1:INVITE:<null>] (unsigned) test5: 2,147,483,000
(65041) INFO: [/usr/local/etc/kamailio/kamailio.cfg:894:DEFAULT_ROUTE] [skpqdsqmwemdnhx@devbox1:INVITE:<null>] (unsigned) test6: 4,294,967,000
(65041) INFO: [/usr/local/etc/kamailio/kamailio.cfg:896:DEFAULT_ROUTE] [skpqdsqmwemdnhx@devbox1:INVITE:<null>] (db) var(test1)=-2147483000 vn(test1)=-2147483000 avp(test1)=-2147483000 shv(test1)=-2147483000
(65041) INFO: [/usr/local/etc/kamailio/kamailio.cfg:898:DEFAULT_ROUTE] [skpqdsqmwemdnhx@devbox1:INVITE:<null>] (db) var(test2)=0 vn(test2)=0 avp(test2)=0 shv(test2)=0
(65041) INFO: [/usr/local/etc/kamailio/kamailio.cfg:900:DEFAULT_ROUTE] [skpqdsqmwemdnhx@devbox1:INVITE:<null>] (db) var(test3)=2147483000 vn(test3)=2147483000 avp(test3)=2147483000 shv(test3)=2147483000
(65041) INFO: [/usr/local/etc/kamailio/kamailio.cfg:902:DEFAULT_ROUTE] [skpqdsqmwemdnhx@devbox1:INVITE:<null>] (db) var(test4)=0 vn(test4)=0 avp(test4)=0 shv(test4)=0
(65041) INFO: [/usr/local/etc/kamailio/kamailio.cfg:904:DEFAULT_ROUTE] [skpqdsqmwemdnhx@devbox1:INVITE:<null>] (db) var(test5)=2147483000 vn(test5)=2147483000 avp(test5)=2147483000 shv(test5)=2147483000
(65041) INFO: [/usr/local/etc/kamailio/kamailio.cfg:906:DEFAULT_ROUTE] [skpqdsqmwemdnhx@devbox1:INVITE:<null>] (db) var(test6)=4294967000 vn(test6)=4294967000 avp(test6)=4294967000 shv(test6)=4294967000

The private variables hold the correct unsigned value with the patches applied..

@devopsec devopsec changed the title Uint fixes multiple subsytems: unsigned integer conversion fixes Apr 25, 2024
@henningw
Copy link
Contributor

Thanks for the PR. Could you please fix the format by running clang-format on the files and do a force-push to update the individual commits? This check is right now failing.

@devopsec devopsec force-pushed the uint_fixes branch 2 times, most recently from f19e574 to db04240 Compare April 26, 2024 13:45
- add support for converting unsigned integer values directly,
  in address table rpc reload.
- add support for packing unsigned integer values from DB,
  into hash tables.
- add support for converting unsigned integers into PVs.
@devopsec
Copy link
Contributor Author

Thanks for the PR. Could you please fix the format by running clang-format on the files and do a force-push to update the individual commits? This check is right now failing.

Fixed the formatting, let me know if further tests need provided for this PR.

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

Successfully merging this pull request may close these issues.

None yet

2 participants