### Description
If the SIP request URI has a parameter ;user=phone, then the match with `myself` fails with error in log.
### Troubleshooting
Sending an OPTIONS request through the proxy:
``` OPTIONS sip:+358removed@example.com;user=phone SIP/2.0. ... From: sip:+358removed@example.com;user=phone;tag=JJhksk01ou7PFTq8xz1-GlhgGNG-c94A. To: sip:+358removed@example.com;user=phone. ... Content-Length: 0.
``` Note: The R-URI does NOT match myself. It never does in my case unless it's an attacker.
#### Reproduction
My config is very simple in terms of aliases:
``` auto_aliases=no alias=172.29.1.21:5060 ```
and in routing block:
` if (uri==myself) return;`
Log shows:
``` Listening on udp: 172.29.1.21 [172.29.1.21]:5060 Aliases: *: 172.29.1.21:5060
... 7(20681) ERROR: <core> [core/resolve.c:1808]: str2ip6buf(): invalid name, no conversion to IP address possible ... ```
### Possible Solutions
Sorry, I couldn't figure out where in the source this call to resolve.c functions happens.
### Additional Information
* **Kamailio Version** - output of `kamailio -v`
``` version: kamailio 5.3.6 (x86_64/linux) bf6c08 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 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: bf6c08 compiled on 09:25:09 Sep 10 2020 with gcc 4.8.5 ```
* **Operating System**:
``` Amazon Linux 2 (up to date) on AWS ```
`uri==myself` is true if the domain part of r-uri is a listen ip or a domain associated to the server via alias or domain module (with register_myself on). Also, you do not need to put alias with listen ip and port, only with the FQDN's you want to associated with the sip server . Your r-uri has example.com (FQDN) as domain part, thus not matching myself condition.
This is a topic about using kamailio, not a bug in the source code. If you want discuss further, write to sr-users mailing list.
Closed #2482.
I understand perfectly how uri==myself works... or doesn't in this case. This is not about how to use Kamailio, I have only 8 years of experience with Kamailio but I think I can wrangle it a bit.
The example.com is not supposed to match myself, I know that. This is beside the point, the point is that my log floods with errors: ` 5(22698) ERROR: <core> [core/resolve.c:1808]: str2ip6buf(): invalid name, no conversion to IP address possible`
Looking at the source code in resolve.c this error is generated if str2ip6buf(str* st, ip_addr_t* ipb) is called with a null or zero length string. This is obviously an error somewhere higher up in the processing. And I have isolated that in the config this error is emitted always when `ruri==myself` is evaluated and there is `;user=phone` as part of the ruri.
I have removed the unnecessary ip:port alias (now there are now aliases listed on startup) and the situation is the same. Also the same if I add the FQDN of the server there (with port).
Reopened #2482.
This sounds more like an issue with the resolve.c code or upper parts, as you suggested as well.
While initially I misunderstood what you reported, it still is a matter of the configuration file, either setting r-uri host part to null via uri2tel or other operations, so here I spent some time to prove it.
Next is the diff to master branch default config file:
``` diff --git a/etc/kamailio.cfg b/etc/kamailio.cfg index e31d112839..5031062247 100644 --- a/etc/kamailio.cfg +++ b/etc/kamailio.cfg @@ -502,6 +502,11 @@ modparam("debugger", "log_level_name", "exec") * - note: this is the same as route { ... } */ request_route {
+ if(uri==myself) { + xinfo("r-uri is myself: $ru\n"); + } else { + xinfo("r-uri is not myself: $ru\n"); + } # per request initial checks route(REQINIT); ```
I run kamailio (master and 5.3 branches) in source code folder with:
``` ./src/kamailio -w . -f etc/kamailio.cfg -L src/modules/ -a no -n 2 -E -e -dd ```
Then shoot an OPTIONS with sipsak and all is fine (note in the middle the INFO log message printed by the diff added above to default config, no other errors):
``` $ sipsak -vvv -p 127.0.0.1 -s "sip:+4930303030openrcs.com;user=phone" fqdnhostname: 192.168.188.20 warning: need raw socket (root privileges) to receive all ICMP errors our Via-Line: Via: SIP/2.0/UDP 192.168.188.20:63827;branch=z9hG4bK.44f4a309;rport;alias
New message with Via-Line: OPTIONS sip:+4930303030openrcs.com;user=phone SIP/2.0 Via: SIP/2.0/UDP 192.168.188.20:63827;branch=z9hG4bK.44f4a309;rport;alias From: sip:sipsak@192.168.188.20:63827;tag=72dc047d To: sip:+4930303030openrcs.com;user=phone Call-ID: 1927021693@192.168.188.20 CSeq: 1 OPTIONS Contact: sip:sipsak@192.168.188.20:63827 Content-Length: 0 Max-Forwards: 70 User-Agent: sipsak 0.9.7pre Accept: text/plain
request: OPTIONS sip:+4930303030openrcs.com;user=phone SIP/2.0 Via: SIP/2.0/UDP 192.168.188.20:63827;branch=z9hG4bK.44f4a309;rport;alias From: sip:sipsak@192.168.188.20:63827;tag=72dc047d To: sip:+4930303030openrcs.com;user=phone Call-ID: 1927021693@192.168.188.20 CSeq: 1 OPTIONS Contact: sip:sipsak@192.168.188.20:63827 Content-Length: 0 Max-Forwards: 70 User-Agent: sipsak 0.9.7pre Accept: text/plain
send to: UDP:127.0.0.1:5060
1(71486) INFO: {1 1 OPTIONS 1927021693@192.168.188.20} <script>: r-uri is not myself: sip:+4930303030openrcs.com;user=phone
message received received from: UDP:127.0.0.1:5060 SIP/2.0 403 Not relaying Via: SIP/2.0/UDP 192.168.188.20:63827;branch=z9hG4bK.44f4a309;rport=56671;alias;received=127.0.0.1 From: sip:sipsak@192.168.188.20:63827;tag=72dc047d To: sip:+4930303030openrcs.com;user=phone;tag=9dd61ff61e802d8e2bef5f14621ef3c2.76a5bc12 Call-ID: 1927021693@192.168.188.20 CSeq: 1 OPTIONS Server: kamailio (5.5.0-dev2 (x86_64/darwin)) Content-Length: 0
** reply received after 7.553 ms ** SIP/2.0 403 Not relaying final received ```
So again, it should be specific to your config.
If one wants to silent log errors when using functions that require host part in the uri with values without host, then is another scope, it should be an enhancement at least controlled by a parameter, because such errors are useful to alert when one does wrong config operations.
Ok thanks for taking the time to recreate this. We are actually using tel2sip in the config so your idea about empty host part may be right. Unfortunately this environment is not something we can easily duplicate in a test setup but we'll go through it.
I think comparing a null uri, uri with no host or tel: URI to `myself` with `==` is not worthy of an L_ERR message, clearly any URI without a host simply doesn't match and the equality is false. Now if I called `is_myself()` with such an URI, I could expect a log message like "is_myself() called without a host part in request URI" but again maybe not L_ERR...
Actually I expect an error message, because after converting to tel uri in config, one is aware of no-host part and can avoid testing conditions that need the host part. But if an operation fails to set the host part when it should, then is good to have error logs on these kind of conditions. Anyhow, if one wants to tune this behaviour, just make a pull request. Closing one more time this issue, proved not to be in the code. Further discussions can be done on mailing list.
Closed #2482.