[sr-dev] [kamailio/kamailio] Kamailio ignore 404 as part of transaction during REGISTER (#2271)

jpVm5jYYRE1VIKL notifications at github.com
Thu Apr 2 11:17:23 CEST 2020


### Description

In following configuration : 

UA -> KAMALIO PROXY -> REGISTRAR

In case if REGISTRAR answer 404 on first REGISTER kamailio just ignore it and reply not passed to onreply_route. ie 404 just dropped and not passed to UA. 
In case if REGISTRAR answer 401 on first REGISTER kamailio works like it have to be.

Grepped example :

```
77.77.77.77 - UA
88.88.88.88 - Kamailio
10.34.64.2 - registrar

U 2020/04/02 10:47:02.345372 77.77.77.77:5060 -> 88.88.88.88:7060 #26887
REGISTER sip:proxy.domain.com:7060 SIP/2.0.
Via: SIP/2.0/UDP 10.32.0.9:5060;branch=z9hG4bK4153798595.
From: "999100044" <sip:999100044 at proxy.domain.com:7060>;tag=3123330837.
To: "999100044" <sip:999100044 at proxy.domain.com:7060>.
Call-ID: 2_912627073 at 10.32.0.9.
CSeq: 1 REGISTER.
Contact: <sip:999100044 at 10.32.0.9:5060>.
Allow: INVITE, INFO, PRACK, ACK, BYE, CANCEL, OPTIONS, NOTIFY, REGISTER, SUBSCRIBE, REFER, PUBLISH, UPDATE, MESSAGE.
Max-Forwards: 70.
User-Agent: Yealink SIP-T46G 28.81.188.7 001565b577b2.
Expires: 3600.
Allow-Events: talk,hold,conference,refer,check-sync.
Content-Length: 0.
..


U 2020/04/02 10:47:04.289850 88.88.88.88:7060 -> 10.34.64.2:5060 #26888
REGISTER sip:proxy.domain.com:7060 SIP/2.0.
Record-Route: <sip:88.88.88.88:7060;lr>.
Via: SIP/2.0/UDP 88.88.88.88:7060;branch=z9hG4bK0636.d927d7e86ebc02302d9ad6ae7d778817.0.
Via: SIP/2.0/UDP 10.32.0.9:5060;received=77.77.77.77;branch=z9hG4bK4153798595.
From: "999100044" <sip:999100044 at proxy.domain.com:7060>;tag=3123330837.
To: "999100044" <sip:999100044 at proxy.domain.com:7060>.
Call-ID: 2_912627073 at 10.32.0.9.
CSeq: 1 REGISTER.
Contact: <sip:999100044 at 10.32.0.9:5060>.
Allow: INVITE, INFO, PRACK, ACK, BYE, CANCEL, OPTIONS, NOTIFY, REGISTER, SUBSCRIBE, REFER, PUBLISH, UPDATE, MESSAGE.
Max-Forwards: 69.
User-Agent: Yealink SIP-T46G 28.81.188.7 001565b577b2.
Expires: 3600.
Allow-Events: talk,hold,conference,refer,check-sync.
Content-Length: 0.
Path: <sip:88.88.88.88:7060;lr;received=sip:77.77.77.77:5060>.
Supported: path.
..


U 2020/04/02 10:47:04.290295 10.34.64.2:5060 -> 88.88.88.88:7060 #26889
SIP/2.0 404 Not Found.
Via: SIP/2.0/UDP 88.88.88.88:7060;branch=z9hG4bK0636.d927d7e86ebc02302d9ad6ae7d778817.0.
Via: SIP/2.0/UDP 10.32.0.9:5060;received=77.77.77.77;branch=z9hG4bK4153798595.
From: "999100044" <sip:999100044 at proxy.domain.com:7060>;tag=3123330837.
To: "999100044" <sip:999100044 at proxy.domain.com:7060>;tag=1598650872.
Call-ID: 2_912627073 at 10.32.0.9.
CSeq: 1 REGISTER.
Content-Length: 0.
Date: Thu, 02 Apr 2020 10:47:03 GMT.
Warning: Not maintaining bindings for domain.
..
```

### Troubleshooting

After checking RFC 3261 i found that 
```
 5. The registrar extracts the address-of-record from the To header
         field of the request.  If the address-of-record is not valid
         for the domain in the Request-URI, the registrar MUST send a
         404 (Not Found) response and skip the remaining steps. 
```

#### Reproduction
following schema : 
UA -> KAMALIO PROXY -> REGISTRAR

modules  related to issue: 
in kamailio.cfg

loadmodule "tm.so"
loadmodule "tmx.so"
loadmodule "sl.so"
loadmodule "rr.so"
loadmodule "db_mysql"
loadmodule "domain"
loadmodule "outbound"
loadmodule "path"

simple conception route config which illustrate issue : 
```
request_route 
{

        # per request initial checks
        route(REQINIT);

        route(CATCH_CANCEL);

        route(RR_PARSE);

        route(REGISTRATION);

        xlog("L_INFO", "Initial relay packet\n");
        $du = "sip:10.34.64.2:5060";

        route(FORWARD);

        # update $du to set the destination address for proxying
        exit;
}

route[CATCH_CANCEL]
{
    if (is_method("CANCEL") == true)
    {
        if (t_check_trans() == true)
        {
            route(FORWARD);
        }
        sl_reply("500", "Internal Server Error");
        drop;
    }
}


route[RR_PARSE]
{
    if(loose_route() == true )
    {
        xlog("L_INFO", "RR-enforced\n");
        append_hf("P-hint: rr-enforced\r\n"); 
        route(FORWARD);

    } else 
        {
            xlog("L_INFO", "RR simple\n");
            record_route();
        }
}

route[REGISTRATION]
{
    if(is_method("REGISTER") == true)
    {
        add_path_received();
        append_hf("Supported: path\r\n");
        xlog("L_INFO", "GOT REGISTER\n");
    }
}

route[FORWARD]
{
    if(t_relay() == false)
    {
        sl_reply_error();
    }
    
    drop;
}


onreply_route
{
    xlog("Reply SIP message from $si:$sp\n");
    if (t_check_trans() == false)
    {
        drop;
    }
}
```

#### Debugging Data

#### Log Messages

```
Apr  2 11:05:26 fsinnosbc /usr/sbin/kamailio[16037]: INFO: {1 1 REGISTER 2_1386563412 at 10.32.0.9} <script>: RR simple
Apr  2 11:05:26 fsinnosbc /usr/sbin/kamailio[16037]: INFO: {1 1 REGISTER 2_1386563412 at 10.32.0.9} <script>: GOT REGISTER
Apr  2 11:05:26 fsinnosbc /usr/sbin/kamailio[16037]: INFO: {1 1 REGISTER 2_1386563412 at 10.32.0.9} <script>: Initial relay packet
```


#### SIP Traffic

<!--
If the issue is exposed by processing specific SIP messages, grab them with ngrep or save in a pcap file, then add them next, or attach to issue, or provide a link to download them (e.g., to a pastebin site).
-->

```
(paste your sip traffic here)
```

### Possible Solutions

<!--
If you found a solution or workaround for the issue, describe it. Ideally, provide a pull request with a fix.
-->

### Additional Information

  * **Kamailio Version** - output of `kamailio -v`

```
version: kamailio 5.3.3 (x86_64/linux) 
flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MMAP, PKG_MALLOC, 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_BLACKLIST, HAVE_RESOLV_RES, TLS_PTHREAD_MUTEX_SHARED
ADAPTIVE_WAIT_LOOPS 1024, MAX_RECV_BUFFER_SIZE 262144, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: unknown 
compiled with gcc 8.3.0
```

* **Operating System**:

<!--
Details about the operating system, the type: Linux (e.g.,: Debian 8.4, Ubuntu 16.04, CentOS 7.1, ...), MacOS, xBSD, Solaris, ...;
Kernel details (output of `uname -a`)
-->

```
root at fsinnosbc:~# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 10 (buster)
Release:        10
Codename:       buster
root at fsinnosbc:~# 
```


-- 
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/2271
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-dev/attachments/20200402/2e77c8be/attachment-0001.html>


More information about the sr-dev mailing list