[asterisk-dev] [Code Review]: chan_sip check_via does a hostname lookup but discards results anyway

wdoekes reviewboard at asterisk.org
Mon Mar 18 13:57:11 CDT 2013



> On March 18, 2013, 12:44 p.m., elguero wrote:
> > This change makes sense to me.  No need to do a DNS lookup if all we want is the port information.
> > 
> > In 11 and trunk, we use the resolved address in attempting to determine if the UA is behind NAT and set the natdetected flag.  So, I think the patch there would be slightly different from this one.

Good point.

   Before a request is sent, the client transport MUST insert a value of
   the "sent-by" field into the Via header field.  This field contains
   an IP address or host name, and port.  The usage of an FQDN is
   RECOMMENDED.  This field is used for sending responses under certain
   conditions, described below.  If the port is absent, the default
   value depends on the transport.  It is 5060 for UDP, TCP and SCTP,
   5061 for TLS.

And since it is recommended, I guess we must leave the resolving in place, even though we won't use it most of the time.

Regard this as a blocked-for-11-and-up patch for now.


On March 18, 2013, 12:44 p.m., wdoekes wrote:
> > These were just some ideas that I had when looking at this review.

Thanks for the review.

PARSE_PORT_REQUIRED is not good, since not supplying a port is valid. 

Using ast_parse_arg() could be an option, I didn't know that existed.

Checking peer ports against >= 1024 is wrong. There is nothing that says a port cannot be below that. (And technically I think port 0 might be legal too.. but using that would be.. strange.)


- wdoekes


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/2400/#review8075
-----------------------------------------------------------


On March 18, 2013, 9:16 a.m., wdoekes wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/2400/
> -----------------------------------------------------------
> 
> (Updated March 18, 2013, 9:16 a.m.)
> 
> 
> Review request for Asterisk Developers.
> 
> 
> Summary
> -------
> 
> The sent-by-addr address in the Via is supposed to get ignored and the sent-by-port is only used if we're not doing force_rport.
> 
> Nevertheless did check_via do hostname lookups even though it only wanted to get at the port.
> 
> I've changed the code around so it uses ast_sockaddr_split_hostport() instead of ast_sockaddr_resolve_first(). This also removes an ERROR notice which isn't worthy of such severity.
> 
> 
> Before, when someone sent something resolvable in the Via:
> 
>   chan_sip did an DNS A lookup, but ignored the results.
> 
> Now:
> 
>   chan_sip just looks at the port.
> 
> 
> Before, when someone sent a bad via header:
> 
>   ERROR[29769]: netsock2.c:269 ast_sockaddr_resolve: getaddrinfo("127.0.1.1", "5061branch=z9hG4bK-11063-1-0", ...): Servname not supported for ai_socktype
>   WARNING[29769]: chan_sip.c:16921 check_via: Could not resolve socket address for '127.0.1.1:5061branch=z9hG4bK-11063-1-0'
> 
> Now:
> 
>   WARNING[10229]: chan_sip.c:16928 check_via: Could not split host/port for '127.0.1.1:5061branch=z9hG4bK-11049-1-0'
> 
> 
> Diffs
> -----
> 
>   /branches/1.8/channels/chan_sip.c 383308 
> 
> Diff: https://reviewboard.asterisk.org/r/2400/diff
> 
> 
> Testing
> -------
> 
> 57 SIP tests ran successfully with and without the patch.
> 
> 
> Thanks,
> 
> wdoekes
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20130318/bd689724/attachment-0001.htm>


More information about the asterisk-dev mailing list