Packet Api Rewrite
So, here it is #8 (closed) and more in the wiki page. It's a lot of code, but feel free to ask anything.
Here's the general overview of the state of things:
- Packet API
- Streamlined, compression reworked, checks in one place, ...
- Query processing
- Basically everything from the old name-server.c was remade so it stacks
-
name-server.h
and thens_proc_*
API, which is an API for a state machine that just accepts wireformat and does all the conversions between parsed packets and backwards. -
ns_proc_query.h
is the implementation of query processing and implements thens_proc_*
API
- It serves as a generic
query -> response
machine using solvers. - It also covers transaction security and stuff, so the solvers don't need to worry about this.
internet.h, chaos.h, axfr.h, ixfr.h, update.h, notify.h
- Solver implementations for various queries
- IN answers / DNSSEC proofs are now RFC compliant in several cases
- Transfers now also show message and byte counts
- Since all the bitpushing is done by the upper layers, they just do answer solving
- UDP & TCP handlers
- Simplified, using memory context for query processing
- TCP threads are now coherent, no through-the-pipe "fair" queueing
- XFR handler is simplified as well (all threads coherent)
- Basic unit tests for packet, query processing and stuff
- I don't know what else, just ask.
Pitfalls
- UPDATE forwarding is disabled until #189 (closed) is finished, as to not create more duplicated code and this is already complex enough.
Review
Merge request reports
Activity
jvcelak: pkt.h: almost all packet flags start withmvavrusa: resolved in 48cecedbKNOT_PF_
, why doesKNOT_PACKET_DUPL_NO_MERGE
not?jvcelak:
knot_pkt_new
- I'm thinking about a separate function for allocation. If you incidentally supply non-initialized variable as thewire
parameter, you may get into trouble. Having a separate function for allocation would be safer. mvavrusa: I don't see how that helps, if you supply non-initialized variables as thewire
you're screwed anyway? jvcelak: I meant that with the current approach you expect initialization. If there is a separate function for allocation, the purpose will be clear from the function's name. But not a big deal.jvcelak:knot_pkt_opt_set()
- I would rather see a separate function for each option. But fine. mvavrusa: I'd like to leave it to #190 (closed) , more work is needed on OPT... jvcelak: okjvcelak:
knot_pkt_put_question
: small copy&pastesize_t question_len = 2 * sizeof(uint16_t) + qname_len;
mvavrusa: I don't see it, but I've changed it a bit in 056c64c7 jvcelak: resolvedjvcelak:
knot_pkt_question_size()
includes a size of the header ... it's not really a question size jvcelak: the same withknot_pkt_parse_question()
- it also parses the header. mvavrusa:knot_pkt_question_size()
is reworked,knot_pkt_parse_question()
has updated doc to reflect that it checks sanity of the header as well a5738f67 (I don't think it makes sense to separate question and header parsing, as it's a glorified size check) jvcelak: agreedjvcelak:
knot_pkt_put_opt()
should probably check a current section, should not it? mvavrusa: I'd like to leave it to #190 (closed) , more work is needed on OPT... but I put a check there anyway 17cba1c8 jvcelak:jvcelak: injvcelak:knot_pkt_put
, in the check for a duplicated RR set:pkt_contains(pkt, rr, KNOT_RRSET_COMPARE_PTR)
will evaluate to true in case of error. The input parameters are not checked, so it can easily happen. (In addition, the assignments to rr_info and rr can me moved after the duplicated RR set check.) fixedjvcelak: There are also some inconsistencies in types naming:jvcelak:knot_packet_type_t
->knot_pkt_type_t
,knot_section_t
->knot_pkt_section_t
? mvavrusa: I likeknot_pkt_type_t
, butknot_pkt_section_t
is too long mvavrusa:knot_packet_type_t
renamed and moved,knot_section_t
left in consts unchanged in 48cecedb @jvcelak ? perfectjvcelak:jvcelak:knot_packet_type_t
: there is no constant for value 0, I guess it should be. And the usage of flag-like values is quite strange. mvavrusa:KNOT_QUERY_INVALID
is the new0
, they are flag-like because response is always odd, query is even (KNOT_RESPONSE
is1
) see 48cecedbjvcelak:knot_rrset_header_to_wire
,if (compr && compr->rrinfo->compress_ptr[0] > 0)
->if (compr && compr->rrinfo->compress_ptr[0] != COMPR_HINT_NONE)
?mvavrusa: same thing, depends on whether you view compress_ptr as packet offset or a "hint" (special number < HEADER_SIZE), I'll leave it up to your considerationjvcelak: - ok, let's keep it this way.jvcelak: I'm looking atjvcelak:rrl_slip_roll
, we probably discussed it some time ago but I do not recall what was the result. Functionknot_random_uint16_t
is quite slow. Is therrl_slip_roll
called for each positive response when RRL is enabled? Won't it create unwanted performance drop for non-slipped replies? mvavrusa: it is slower, but so is whole RRL processing code for each packet, I don't think it matters . lawyeredjvcelak:jvcelak:axfr_process_item
has confusing and too generic name, what aboutaxfr_process_node
? mvavrusa: fine, fine 9884e06ejvcelakdname_cname_can_synth
returns true if the synthesized dname is longer than allowed and therefore cannot be synthesized. The description is correct, but the function name indicates reverse meaning. mvavrusa: right, fixed in c4770131jvcelak: functionput_answer()
does not differentiate between UDP and TCP. If ANY requests over UDP are prohibited, also TCP ANY requests will be rejected. mvavrusa: I reworked the processing flags, see fc08b7c0 for code and commit message jvcelak: Much, much, much better.jvcelak:jvcelak:put_rr()
,put_authority_soa()
: ifknot_pkt_put()
fails due to limited packet size, the copied RR set will leak. mvavrusa: good catch! there was another one, see 5cc27092jvcelak: Can
ns_proc_query_reset
function be written less cryptically? Why do not call the destructors, clear the whole structure, and reset just the preserved fields? mvavrusa: can you check 42e36fc5 ? jvcelak: looks betterFinally. The first review is finished.
I have checked everything except the NSEC3 proves (src/libknot/nameserver/nsec_proofs
), which are a subject of a next refactoring #191 (closed)To sum it up, the merge request looks pretty good and can be merged as soon as the opened questions are resolved.
mentioned in issue #197 (closed)