I can confirm there is a change in behaviour between 5.3 and 5.4 (I tested with 
master, but it is the same code).

I made some small changes to the config to have more debug messages and be able 
to test with OPTIONS sent by sipsak -- the full config is next:

```

####### Global Parameters #########
debug = 2
log_stderror = no
children = 2

####### Modules Section ########
# mpath="/usr/lib64/kamailio/modules/"

loadmodule "jsonrpcs.so"
loadmodule "kex.so"
loadmodule "corex.so"
loadmodule "tm.so"
loadmodule "tmx.so"
loadmodule "sl.so"
loadmodule "rr.so"
loadmodule "pv.so"
loadmodule "maxfwd.so"
loadmodule "textops.so"
loadmodule "siputils.so"
loadmodule "xlog.so"
loadmodule "sanity.so"
loadmodule "ctl.so"
loadmodule "debugger.so"
loadmodule "htable.so"

# ----- tm params -----
modparam("tm", "failure_reply_mode", 3)
modparam("tm", "remap_503_500", 0)
modparam("tm", "contacts_avp", "tm_contacts")
modparam("tm", "contact_flows_avp", "tm_contact_flows")

# ----- rr params -----
modparam("rr", "enable_full_lr", 0)
modparam("rr", "append_fromtag", 1)

# ----- htable params -----
modparam("htable", "htable", "gateways=>size=4")

request_route
{
    if (!is_method("ACK")) {
        if(t_precheck_trans()) {
            t_check_trans();
            exit;
        }
        t_check_trans();
    }

    if (!sanity_check("1535", "7")) {
        exit;
    }

    if (!mf_process_maxfwd_header("10")) {
        send_reply("483", "Too Many Hops");
        exit;
    }

    if (has_totag()) {
        if (is_method("INVITE")) {
            record_route();
        }
        if (loose_route()) {
            route(RELAY);
        }
        if (is_method("ACK")) {
            if (t_check_trans()) {
                route(RELAY);
            }
            exit;
        }
        send_reply("481", "Call Leg/Transaction Does Not Exist");
        exit;
    }

    if (is_method("CANCEL")) {
        if (t_check_trans()) {
            route(RELAY);
        } else {
            send_reply("481", "Call leg/transaction does not exist");
        }
        exit;
    } else if (is_method("ACK")) {
        if (t_check_trans()) {
            route(RELAY);
        }
        exit;
    }

    remove_hf("Route");
    record_route();

    $var(i) = 1;
    while ($var(i) < 10) {
        $sht(gateways=>$var(i)) = "host=" + 
$_s($var(i).$var(i).$var(i).$var(i)) + ";priority=" + $var(i);
        xnotice("==== Storing: $sht(gateways=>$var(i))\n");
        $var(i) = $var(i) + 1;
    }

    sht_iterator_start("i", "gateways");
    while(sht_iterator_next("i")) {
        xnotice("==== Appending: sip:$rU@$(shtitval(i){param.value,host}) - p: 
$_s(0.$(shtitval(i){param.value,priority}))\n");
        append_branch("sip:$rU@$(shtitval(i){param.value,host})", 
"$_s(0.$(shtitval(i){param.value,priority}))");
    }
    sht_iterator_end("i");
    t_load_contacts();
    xwarn("Route order:\n");
    $var(i) = 1;
    while (t_next_contacts()) {
        xinfo("==== $var(i): $ru\n");
        $var(i) = $var(i) + 1;
    }
    sl_send_reply("404", "Not routing");
    exit;
    route(RELAY);
}

route[RELAY] {
    xlog ("L_INFO", "Routing to $rd/$du\n");
    t_on_failure("OB_FAILURE");
    if (!t_relay()) {
        sl_reply_error();
    }
    exit;
}

failure_route[OB_FAILURE] {
    if (t_is_canceled()) {
        xlog("L_INFO", "Transaction cancelled\n");
        exit;
    }
    if (!t_next_contacts() && $ru==$ou) {
        send_reply("503", "Service Unavailable");
        exit;
    }
    t_on_failure("OB_FAILURE");
    route(RELAY);
    exit;
}
```

The output with 5.3 branch was:

```
 1(42162) NOTICE: <script>: ==== Storing: host=1.1.1.1;priority=1
 1(42162) NOTICE: <script>: ==== Storing: host=2.2.2.2;priority=2
 1(42162) NOTICE: <script>: ==== Storing: host=3.3.3.3;priority=3
 1(42162) NOTICE: <script>: ==== Storing: host=4.4.4.4;priority=4
 1(42162) NOTICE: <script>: ==== Storing: host=5.5.5.5;priority=5
 1(42162) NOTICE: <script>: ==== Storing: host=6.6.6.6;priority=6
 1(42162) NOTICE: <script>: ==== Storing: host=7.7.7.7;priority=7
 1(42162) NOTICE: <script>: ==== Storing: host=8.8.8.8;priority=8
 1(42162) NOTICE: <script>: ==== Storing: host=9.9.9.9;priority=9
 1(42162) NOTICE: <script>: ==== Appending: sip:[email protected] - p: 0.6
 1(42162) NOTICE: <script>: ==== Appending: sip:[email protected] - p: 0.7
 1(42162) NOTICE: <script>: ==== Appending: sip:[email protected] - p: 0.4
 1(42162) NOTICE: <script>: ==== Appending: sip:[email protected] - p: 0.5
 1(42162) NOTICE: <script>: ==== Appending: sip:[email protected] - p: 0.2
 1(42162) NOTICE: <script>: ==== Appending: sip:[email protected] - p: 0.3
 1(42162) NOTICE: <script>: ==== Appending: sip:[email protected] - p: 0.1
 1(42162) NOTICE: <script>: ==== Appending: sip:[email protected] - p: 0.9
 1(42162) NOTICE: <script>: ==== Appending: sip:[email protected] - p: 0.8
 1(42162) WARNING: <script>: Route order:
 1(42162) INFO: <script>: ==== 1: sip:[email protected]
 1(42162) INFO: <script>: ==== 2: sip:[email protected]
 1(42162) INFO: <script>: ==== 3: sip:[email protected]
 1(42162) INFO: <script>: ==== 4: sip:[email protected]
 1(42162) INFO: <script>: ==== 5: sip:[email protected]
 1(42162) INFO: <script>: ==== 6: sip:[email protected]
 1(42162) INFO: <script>: ==== 7: sip:[email protected]
 1(42162) INFO: <script>: ==== 8: sip:[email protected]
 1(42162) INFO: <script>: ==== 9: sip:[email protected]
 1(42162) INFO: <script>: ==== 10: sip:[email protected]
```

The output with 5.4 (master) is:

```
 1(41335) NOTICE: <script>: ==== Storing: host=1.1.1.1;priority=1
 1(41335) NOTICE: <script>: ==== Storing: host=2.2.2.2;priority=2
 1(41335) NOTICE: <script>: ==== Storing: host=3.3.3.3;priority=3
 1(41335) NOTICE: <script>: ==== Storing: host=4.4.4.4;priority=4
 1(41335) NOTICE: <script>: ==== Storing: host=5.5.5.5;priority=5
 1(41335) NOTICE: <script>: ==== Storing: host=6.6.6.6;priority=6
 1(41335) NOTICE: <script>: ==== Storing: host=7.7.7.7;priority=7
 1(41335) NOTICE: <script>: ==== Storing: host=8.8.8.8;priority=8
 1(41335) NOTICE: <script>: ==== Storing: host=9.9.9.9;priority=9
 1(41335) NOTICE: <script>: ==== Appending: sip:[email protected] - p: 0.6
 1(41335) NOTICE: <script>: ==== Appending: sip:[email protected] - p: 0.7
 1(41335) NOTICE: <script>: ==== Appending: sip:[email protected] - p: 0.4
 1(41335) NOTICE: <script>: ==== Appending: sip:[email protected] - p: 0.5
 1(41335) NOTICE: <script>: ==== Appending: sip:[email protected] - p: 0.2
 1(41335) NOTICE: <script>: ==== Appending: sip:[email protected] - p: 0.3
 1(41335) NOTICE: <script>: ==== Appending: sip:[email protected] - p: 0.1
 1(41335) NOTICE: <script>: ==== Appending: sip:[email protected] - p: 0.9
 1(41335) NOTICE: <script>: ==== Appending: sip:[email protected] - p: 0.8
 1(41335) WARNING: <script>: Route order:
 1(41335) INFO: <script>: ==== 1: sip:[email protected]
 1(41335) INFO: <script>: ==== 2: sip:[email protected]
 1(41335) INFO: <script>: ==== 3: sip:[email protected]
 1(41335) INFO: <script>: ==== 4: sip:[email protected]
 1(41335) INFO: <script>: ==== 5: sip:[email protected]
 1(41335) INFO: <script>: ==== 6: sip:[email protected]
 1(41335) INFO: <script>: ==== 7: sip:[email protected]
 1(41335) INFO: <script>: ==== 8: sip:[email protected]
 1(41335) INFO: <script>: ==== 9: sip:[email protected]
```

I run kamailio from source directory of each version with the command:

```
./src/kamailio -f ../kamailio-t-load-contacts-order.cfg -L src/modules/ -w . -a 
no -E -e -dd
```

The sent an OPTIONS with sipsak:

```
sipsak -s sip:[email protected]
```

The 5.3 keeps the original R-URI, but becomes the last destination, having the 
priority 0. The 5.4 keeps the original URI on the top of the list and loses the 
address with highest priority added by append branch.

-- 
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/issues/2449#issuecomment-694788373
_______________________________________________
Kamailio (SER) - Development Mailing List
[email protected]
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to