[sr-dev] [kamailio/kamailio] TOPOH error after topology hiding disabling in event_route (#2437)

leonid-xorcom notifications at github.com
Tue Aug 11 11:55:25 CEST 2020


### Description
Kamailio has two IP interfaces: one (192.168.0.206) towards the Internet-based endpoints and the second (10.197.184.1) - toward my internal SIP servers.
I am trying to disable the topology hiding when the messages are sent to my internal SIP servers.
In order to achieve this, I added the special event_route block:
```
event_route[topoh:msg-outgoing] {
     if ($sndfrom(ip) == "10.197.184.1" ) {
        drop;
     }
}
```
The problem is that the topoh module generates ERROR when trying to parse the response for the "dropped" request:
```
Aug 11 09:32:57 weyl kamailio[31439]: 19(31536) DEBUG: topoh [th_msg.c:401]: th_unmask_via(): =======via[1]
Aug 11 09:32:57 weyl kamailio[31439]: 19(31536) DEBUG: topoh [th_msg.c:402]: th_unmask_via(): hdr: [Via]
Aug 11 09:32:57 weyl kamailio[31439]: 19(31536) DEBUG: topoh [th_msg.c:404]: th_unmask_via(): body: 100: [SIP/2.0/UDP 10.197.184.1;branch=z9hG4bK3fe4.fc634d55237786cb052f1c0d4fd7d949.0;received=10.197.184.1]
Aug 11 09:32:57 weyl kamailio[31439]: 19(31536) DEBUG: topoh [th_msg.c:401]: th_unmask_via(): =======via[2]
Aug 11 09:32:57 weyl kamailio[31439]: 19(31536) DEBUG: topoh [th_msg.c:402]: th_unmask_via(): hdr: [Via]
Aug 11 09:32:57 weyl kamailio[31439]: 19(31536) DEBUG: topoh [th_msg.c:404]: th_unmask_via(): body: 96: [SIP/2.0/UDP 192.168.6.108:5260;received=192.168.6.108;TH=div;rport=5260;branch=z9hG4bK2821386093]
Aug 11 09:32:57 weyl kamailio[31439]: 19(31536) DEBUG: topoh [th_msg.c:438]: th_unmask_via(): +body: 5: [DÏã#Ã]
Aug 11 09:32:57 weyl kamailio[31439]: 19(31536) ERROR: <core> [core/parser/parse_via.c:1808]: parse_via(): bad char <D> on state 100
Aug 11 09:32:57 weyl kamailio[31439]: 19(31536) ERROR: <core> [core/parser/parse_via.c:2704]: parse_via(): parsing via on: <DÏã#Ã
Aug 11 09:32:57 weyl kamailio[31439]: X>
Aug 11 09:32:57 weyl kamailio[31439]: 19(31536) ERROR: <core> [core/parser/parse_via.c:2710]: parse_via(): via parse error
Aug 11 09:32:57 weyl kamailio[31439]: 19(31536) ERROR: topoh [th_msg.c:464]: th_unmask_via(): cannot find cookie in via2
Aug 11 09:32:57 weyl kamailio[31439]: 19(31536) DEBUG: topoh [th_msg.c:597]: th_flip_record_route(): no record route header
Aug 11 09:32:57 weyl kamailio[31439]: 19(31536) DEBUG: topoh [topoh_mod.c:389]: th_msg_received(): adding cookie: uc
Aug 11 09:32:57 weyl kamailio[31439]: 19(31536) DEBUG: topoh [th_msg.c:1034]: th_add_hdr_cookie(): added cookie header [TH: uch
Aug 11 09:32:57 weyl kamailio[31439]: ]
```
This problem was also 
[topoh-error-logs.tar.gz](https://github.com/kamailio/kamailio/files/5056198/topoh-error-logs.tar.gz)
discussed here: https://lists.kamailio.org/pipermail/sr-users/2019-February/104730.html. 
### Troubleshooting

#### Reproduction

<!--
If the issue can be reproduced, describe how it can be done.
-->

#### Debugging Data

[topoh-error-logs.tar.gz](https://github.com/kamailio/kamailio/files/5056184/topoh-error-logs.tar.gz)

```
(paste your debugging data here)
```

#### Log Messages

ref. the attached file
```
(paste your log messages here)
```

#### SIP Traffic
Ref. the attached file. A relevant SIP messages trace excerpt is here:
```
====================
tag: rcv
pid: 31533
process: 16
time: 1597138377.884735
date: Tue Aug 11 09:32:57 2020
proto: udp ipv4
srcip: 192.168.6.108
srcport: 5260
dstip: 192.168.0.206
dstport: 5060
~~~~~~~~~~~~~~~~~~~~
INVITE sip:9992003 at leotst.weyl.in.xorcom.com:5060 SIP/2.0^M
Via: SIP/2.0/UDP 192.168.6.108:5260;rport;branch=z9hG4bK2821386093^M
From: "9000" <sip:2001 at leotst.weyl.in.xorcom.com>;tag=399dbddb56237da^M
To: <sip:9992003 at leotst.weyl.in.xorcom.com:5060>^M
Call-ID: 9d993e292700d20 at 192.168.6.108^M
CSeq: 20 INVITE^M
Contact: <sip:2001 at 192.168.6.108:5260;transport=UDP>^M
Max-Forwards: 70^M
User-Agent: Htek UC903 V2.0.4.6.15 001fc11cc555^M
Supported: replaces^M
Subject: SIP Call^M
Expires: 120^M
Allow: INVITE, ACK, UPDATE, INFO, CANCEL, BYE, OPTIONS, REFER, SUBSCRIBE, NOTIFY, MESSAGE, PRACK^M
Content-Type: application/sdp^M
Content-Length: 236^M
^M
v=0^M
o=- 887 886 IN IP4 192.168.6.108^M
s=SIP Call^M
c=IN IP4 192.168.6.108^M
t=0 0^M
m=audio 12100 RTP/AVP 0 8 101^M
a=rtpmap:0 PCMU/8000^M
a=ptime:20^M
a=rtpmap:8 PCMA/8000^M
a=rtpmap:101 telephone-event/8000^M
a=fmtp:101 0-11,16^M
a=sendrecv^M
..........................
====================
tag: snd
pid: 31533
process: 16
time: 1597138377.929560
date: Tue Aug 11 09:32:57 2020
proto: udp ipv4
srcip: 10.197.184.1
srcport: 5060
dstip: 10.197.184.108
dstport: 5060
~~~~~~~~~~~~~~~~~~~~
INVITE sip:9992003 at leotst.weyl.in.xorcom.com:5060 SIP/2.0^M
Record-Route: <sip:10.197.184.1;r2=on;lr;did=67a.f1e1>^M
Record-Route: <sip:192.168.0.206;r2=on;lr;did=67a.f1e1>^M
Via: SIP/2.0/UDP 10.197.184.1;branch=z9hG4bK3fe4.fc634d55237786cb052f1c0d4fd7d949.0^M
Via: SIP/2.0/UDP 192.168.6.108:5260;received=192.168.6.108;TH=div;rport=5260;branch=z9hG4bK2821386093^M
From: "9000" <sip:2001 at leotst.weyl.in.xorcom.com>;tag=399dbddb56237da^M
To: <sip:9992003 at leotst.weyl.in.xorcom.com:5060>^M
Call-ID: 9d993e292700d20 at 192.168.6.108^M
CSeq: 20 INVITE^M
Contact: <sip:2001 at 192.168.6.108:5260;transport=UDP;alias=192.168.6.108~5260~1>^M
Max-Forwards: 69^M
User-Agent: Htek UC903 V2.0.4.6.15 001fc11cc555^M
Supported: replaces^M
Subject: SIP Call^M
Expires: 120^M
Allow: INVITE, ACK, UPDATE, INFO, CANCEL, BYE, OPTIONS, REFER, SUBSCRIBE, NOTIFY, MESSAGE, PRACK^M
Content-Type: application/sdp^M
Content-Length: 252^M
TH: dih^M
X-cpbxmt-srcip: 192.168.6.108^M
^M
v=0^M
o=- 887 886 IN IP4 10.197.184.1^M
s=SIP Call^M
c=IN IP4 10.197.184.1^M
t=0 0^M
m=audio 11554 RTP/AVP 0 8 101^M
a=rtpmap:0 PCMU/8000^M
a=ptime:20^M
a=rtpmap:8 PCMA/8000^M
a=rtpmap:101 telephone-event/8000^M
a=fmtp:101 0-11,16^M
a=sendrecv^M
a=nortpproxy:yes^M
||||||||||||||||||||
====================
||||||||||||||||||||
====================
tag: rcv
pid: 31536
process: 19
time: 1597138377.930085
date: Tue Aug 11 09:32:57 2020
proto: udp ipv4
srcip: 10.197.184.108
srcport: 5060
dstip: 10.197.184.1
dstport: 5060
~~~~~~~~~~~~~~~~~~~~
SIP/2.0 401 Unauthorized^M
Via: SIP/2.0/UDP 10.197.184.1;branch=z9hG4bK3fe4.fc634d55237786cb052f1c0d4fd7d949.0;received=10.197.184.1^M
Via: SIP/2.0/UDP 192.168.6.108:5260;received=192.168.6.108;TH=div;rport=5260;branch=z9hG4bK2821386093^M
From: "9000" <sip:2001 at leotst.weyl.in.xorcom.com>;tag=399dbddb56237da^M
To: <sip:9992003 at leotst.weyl.in.xorcom.com:5060>;tag=as36995166^M
Call-ID: 9d993e292700d20 at 192.168.6.108^M
CSeq: 20 INVITE^M
Server: GHJ-5.1.10^M
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE^M
Supported: replaces, timer^M
WWW-Authenticate: Digest algorithm=MD5, realm="asterisk", nonce="34e38346"^M
Content-Length: 0^M

```

### 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`

```
# kamailio -v
version: kamailio 5.4.0 (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 7.5.0

```

* **Operating System**:

```
Ubuntu 18.04
```


-- 
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/2437
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-dev/attachments/20200811/0350b21f/attachment-0001.htm>


More information about the sr-dev mailing list