[sr-dev] [kamailio/kamailio] lcr: improve binary search to support a match including src port (#2859)

zenichev notifications at github.com
Fri Sep 17 12:49:09 CEST 2021


#### Pre-Submission Checklist
- [X] Commit message has the format required by CONTRIBUTING guide
- [X] Commits are split per component (core, individual modules, libs, utils, ...)
- [X] Each component has a single commit (if not, squash them into one commit)
- [X] 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
- [X] 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
- [X] Tested changes locally
- [ ] Related to issue #XXXX (replace XXXX with an open issue number)

#### Description
Improve binary search in the lcr module and add a possibility
to do a matching not only based on an IP address of a GW, but also using a source port.

When a possibility to use 'src_port' parameter in from_gw() and from_any_gw()
was introduced here: 14e6fc80b3d2389567c73c4a2196bf8e6d92d8d2
the bsearch() remained untouched, and hence the matching (iteration through existing GWs)
is now done only based on an IP address.

This leads to the issue, when there are more than one GW with the same IP address in gws table,
and from_gw() and from_any_gw() functions are used with the 'src_port' parameter,
it can happen that a wrong GW is picked out by bsearch() from gws table (lcr_gw) and
a check by from_gw() and from_any_gw() returns False.

Hence the matching based on IP address and source port is required for bsearch(),
when from_gw() and from_any_gw() functions are used with the 'src_port' parameter.

This means backwards compatibility is still present (when one uses functions without 'src_port').
You can view, comment on, or merge this pull request online at:

  https://github.com/kamailio/kamailio/pull/2859

-- Commit Summary --

  * lcr: improve binary search to support a match including src port

-- File Changes --

    M src/modules/lcr/lcr_mod.c (37)

-- Patch Links --

https://github.com/kamailio/kamailio/pull/2859.patch
https://github.com/kamailio/kamailio/pull/2859.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/2859
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-dev/attachments/20210917/6c3fad88/attachment.htm>


More information about the sr-dev mailing list