diff --git a/debian/patches/series b/debian/patches/series index bc188458e..ec12fee9f 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -56,6 +56,7 @@ sipwise/db_redis_sscan_fix_empty_key.patch sipwise/kamctl-TMPDIR-config.patch ### active development sipwise/lcr-stopper_mode-parameter.patch +sipwise/lcr_improve_comparison_based_on_gws_port.patch # ### Don't just put stuff in any order ### use gbp pq import/export tooling to help maintain patches diff --git a/debian/patches/sipwise/lcr_improve_comparison_based_on_gws_port.patch b/debian/patches/sipwise/lcr_improve_comparison_based_on_gws_port.patch new file mode 100644 index 000000000..3ee0f624d --- /dev/null +++ b/debian/patches/sipwise/lcr_improve_comparison_based_on_gws_port.patch @@ -0,0 +1,40 @@ +--- a/src/modules/lcr/lcr_mod.c ++++ b/src/modules/lcr/lcr_mod.c +@@ -951,6 +951,27 @@ static int comp_gws_include_port(const v + return memcmp(g1->ip_addr.u.addr, g2->ip_addr.u.addr, g1->ip_addr.len); + } + ++/* ++ * Find a gateway using IP address and the src port ++ */ ++static struct gw_info * find_gateway_by_ip_and_port(struct gw_info * gw, struct gw_info * gws) { ++ int tmp = 0, gw_index = 0; ++ ++ for (int i = 1; i <= gws[0].ip_addr.u.addr32[0]; i++) { ++ tmp = memcmp(gws[i].ip_addr.u.addr, gw->ip_addr.u.addr, gws[i].ip_addr.len); ++ if (gws[i].ip_addr.af == gw->ip_addr.af && ++ gws[i].ip_addr.len == gw->ip_addr.len && ++ tmp == 0 && /* a comparison of the IP address value */ ++ gws[i].port == gw->port) { ++ gw_index = i; ++ break; ++ } ++ } ++ if (gw_index != 0) return &(gws[gw_index]); ++ ++ return NULL; ++} ++ + /* + * Insert gw info into index i or gws table + */ +@@ -3061,8 +3082,7 @@ static int do_from_gw(struct sip_msg *_m + if (src_port != 0) { + /* Search for gw based on its ip address and port */ + gw.port = src_port; +- res = (struct gw_info *)bsearch(&gw, &(gws[1]), gws[0].ip_addr.u.addr32[0], +- sizeof(struct gw_info), comp_gws_include_port); ++ res = find_gateway_by_ip_and_port(&gw, gws); + } else { + /* Search for gw based on its ip address */ + res = (struct gw_info *)bsearch(&gw, &(gws[1]), gws[0].ip_addr.u.addr32[0],