Pre-Submission Checklist

Type Of Change

Checklist:

Description

It has been noticed, that after a list of contributions into lcr:

the gateways matching when a search is being done based on
the IP address and the src_port (through the array of GWs with the same IP)
works, but not fully correct.

It is only related to the usage with the third parameter 'src_port',
when calling from_gw() and from_any_gw(), and, only when the search
is done through the gateways array, which have the same IP address
,but different ports (let's say one has 30 GWs with the same IP in the lcr_gw).
If gateways have different IPs, the issue is not catchable.

The problem is in the algorithm used for matching based on
two objects (ip_addr and src_port) - the binary search.
It's not fully suitable for a search based on two (or more) objects.

The binary works completely fine, when only one object is used for searching,
but works not fully correct when the search is based on a comparison
of two (or more) objects. A division happening based on the value of
the first object, gives a chance that the second object will never
be found in the current half being looked up.

This commit concerns switching to a full cycling through the array of
gateways of the same lcr_id, and gives a proper work of the do_from_gw().

The slight drawback of the new method is that we have to do a cycling
through the whole array of GWs of the same lcr_id, but on the other hand
it is much more efficient than trying to build up a matching using binary search
based on two objects (ip_addr and src_port) being used for comparison.

If we had to build this using bsearch() as well, then we would have to:


You can view, comment on, or merge this pull request online at:

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

Commit Summary

File Changes

Patch Links:


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.