[asterisk-dev] [Code Review] 4528: dns: Add SRV recording parsing, sorting/weighting, and unit tests
rmudgett
reviewboard at asterisk.org
Tue Mar 31 10:41:17 CDT 2015
> On March 31, 2015, 10:28 a.m., Mark Michelson wrote:
> > /trunk/main/dns_srv.c, lines 98-100
> > <https://reviewboard.asterisk.org/r/4528/diff/2/?file=72947#file72947line98>
> >
> > Let's talk alignment.
> >
> > In DNS, there is no padding used for variable-length elements. There is no guarantee that RRs (or their RDATA) lie on word-boundaries. This means that the "data" pointer passed to ast_dns_srv_alloc() may be pointing to data that is not word-aligned (or not even on a half-word).
> >
> > So in this case, you've overlaid a byte array on top of a struct that contains 16-bit unsigned integers. Typically, 16-bit values should be aligned on word or half-word boundaries, but because of the data layout of the DNS record, this cannot be guaranteed. This means you may be performing some unaligned reads here.
> >
> > Now the question is, how bad is this? I'm pretty sure that on x86 architectures, an unaligned read isn't a big deal, performance-wise, but I can't make any claims for other architectures simply because I don't know. Can someone more familiar with these sorts of things chime in with some info?
For x86 platforms, misaligned values are handled without a problem but with a performance penalty. On other processors such as the 68000 you get an alignment exception.
- rmudgett
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/4528/#review14971
-----------------------------------------------------------
On March 26, 2015, 1:50 p.m., Joshua Colp wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/4528/
> -----------------------------------------------------------
>
> (Updated March 26, 2015, 1:50 p.m.)
>
>
> Review request for Asterisk Developers.
>
>
> Repository: Asterisk
>
>
> Description
> -------
>
> This change adds the following:
>
> 1. As SRV records are added to a result the information is parsed and stored away in additional storage in the record. The SRV API can then be used to return this information.
> 2. Before invoking the DNS query callback the list of records on the result are sorted based on priority and weight.
> 3. Unit tests have been added which verify the record parsing, sorting, and weighting. There are also some off nominal which cover the cases when an invalid/corrupt record is received.
> 4. A unit test has also been added to res_resolver_unbound which adds an SRV record to a zone and confirms it is retrieved and parsed correctly.
>
>
> Diffs
> -----
>
> /trunk/tests/test_dns_srv.c PRE-CREATION
> /trunk/res/res_resolver_unbound.c 433370
> /trunk/main/dns_srv.c 433370
> /trunk/main/dns_core.c 433370
> /trunk/include/asterisk/dns_internal.h 433370
>
> Diff: https://reviewboard.asterisk.org/r/4528/diff/
>
>
> Testing
> -------
>
> Executed unit tests and confirmed they pass.
>
>
> Thanks,
>
> Joshua Colp
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20150331/b8cc16cc/attachment.html>
More information about the asterisk-dev
mailing list