On 2013-09-27 at 13:42, Øyvind Kolbu wrote: > On 2013-09-27 at 11:49, Daniel-Constantin Mierla wrote: > > Haven't got time to get back to it -- hope to happen soon. > > I've taken a small peak and think I at least found some of the problem, but > also got quite confused. > > What is the relationship between > dns_cache.c:dns_srv_sip_resolvehost() and > dns_cache.c:dns_srv_sip_resolve()? They look very much copy and paste, with > the same error in them. Both will only search for UDP records if *proto is > not set. They also mangle the *proto value as they both set it to > PROTO_UDP if it is unset, and the leaves it that way instead of resetting > it to 0. > > In resolve.c:no_naptr_srv_sip_resolvehost() a proper SRV lookup function is > defined, but not used at least for the t_relay() case. Perhaps change both > functions in dns_cache.c to use no_naptr_srv_sip_resolvehost?
The patch attached fixes the no NAPTR and no UDP case, but only when use_dns_failover is set to off. We usually have it on, but I can't recall why.. Anyhow the patch is rather trivial, just store *proto before overwriting it and restore it before calling no_naptr_srv_sip_resolvehost. -- Øyvind Kolbu
diff --git a/dns_cache.c b/dns_cache.c index 1243c92..8edd14f 100644 --- a/dns_cache.c +++ b/dns_cache.c @@ -2857,8 +2857,10 @@ struct hostent* dns_naptr_sip_resolvehost(str* name, unsigned short* port, naptr_bmp_t tried_bmp; struct dns_hash_entry* e; char n_proto; + char origproto; str srv_name; + origproto=*proto; he=0; if (dns_hash==0){ /* not init => use normal, non-cached version */ LOG(L_WARN, "WARNING: dns_sip_resolvehost: called before dns cache" @@ -2903,6 +2905,7 @@ struct hostent* dns_naptr_sip_resolvehost(str* name, unsigned short* port, dns_hash_put(e); } naptr_not_found: + *proto = origproto; return no_naptr_srv_sip_resolvehost(name,port,proto); } #endif /* USE_NAPTR */ diff --git a/resolve.c b/resolve.c index e739f4b..36e9d55 100644 --- a/resolve.c +++ b/resolve.c @@ -1519,21 +1519,8 @@ struct hostent* no_naptr_srv_sip_resolvehost(str* name, unsigned short* port, ch } if (default_order){ for (i=0; i<list_len;i++) { - switch ( srv_proto_list[i].proto) { - case PROTO_UDP: - srv_proto_list[i].proto_pref=4; - break; - case PROTO_TCP: - srv_proto_list[i].proto_pref=3; - break; - case PROTO_TLS: - srv_proto_list[i].proto_pref=2; - break; - case PROTO_SCTP: - srv_proto_list[i].proto_pref=1; - break; - } - } + srv_proto_list[i].proto_pref=proto_pref_score(i);; + } } /* sorting the list */ @@ -1592,6 +1579,9 @@ struct hostent* no_naptr_srv_sip_resolvehost(str* name, unsigned short* port, ch if ((port)&&(*port==0)){ *port=(srv_proto_list[i].proto==PROTO_TLS)?SIPS_PORT:SIP_PORT; /* just in case we don't find another */ } + if ((proto)&&(*proto==0)){ + *proto = PROTO_UDP; + } srv_name.s=tmp_srv; srv_name.len=len; #ifdef USE_DNS_CACHE @@ -1632,9 +1622,10 @@ struct hostent* naptr_sip_resolvehost(str* name, unsigned short* port, char n_proto; str srv_name; naptr_bmp_t tried_bmp; /* tried bitmap */ + char origproto; - + origproto = *proto; naptr_head=0; he=0; if (name->len >= MAX_DNS_NAME) { @@ -1673,6 +1664,7 @@ struct hostent* naptr_sip_resolvehost(str* name, unsigned short* port, #endif } /* fallback to srv lookup */ + *proto = origproto; he=no_naptr_srv_sip_resolvehost(name,port,proto); end: if (naptr_head)
_______________________________________________ SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users