EDNS refactoring v2
Refactored the EDNS even more. The edns_parameters
structure has been removed, only the OPT RR is used everywhere. Also removed any EDNS-related stuff from the packet functions, except for a getter, but there is one for TSIG as well, so it's not an issue probably. It's also possible to remove it, as it only saves a few characters of code.
Unittests pass, functional tests also.
Please review again.
Merge request reports
Activity
551 551 const uint8_t *rdata, const uint16_t size, 552 552 const uint32_t ttl, mm_ctx_t *mm) 553 553 { 554 if (rrset == NULL || rdata == NULL) { 554 if (rrset == NULL || (rdata == NULL && size > 0)) { Not good, if someone tried to access NULL data, it would not work - you need to fix in the rdata getter as well (knot_rdata_data - check for 0 size). EDIT: while you're at it, fix usage around rrset.c:464. EDIT 2: And to be really sure, knot_rdata_init() should be fixed too - do not copy into memory you got from knot_rdata_data() without check. There might be more places where we need to fix this.
- Last updated by Ghost User
236 uint8_t *new_data = (uint8_t *)mm_alloc(mm, new_data_len); 237 CHECK_ALLOC_LOG(new_data, KNOT_ENOMEM); 238 239 dbg_edns_verb("EDNS: Adding option. Code: %u, length: %u, data:\n", 240 code, length); 241 dbg_edns_hex_verb((char *)data, length); 242 243 memcpy(new_data, old_data, old_data_len); 244 // write length and code in wireformat (convert endian) 245 knot_wire_write_u16(new_data + old_data_len, code); 246 knot_wire_write_u16(new_data + old_data_len + 2, length); 247 // write the option data 248 memcpy(new_data + old_data_len + 4, data, length); 249 250 /* 2) Create new RDATA structure (we need to preserve the TTL). 251 */ - Last updated by Ghost User
- Last updated by Ghost User
338 } 292 return knot_edns_has_option(opt_rr, KNOT_EDNS_OPTION_NSID); 339 293 } 340 294 341 295 /*----------------------------------------------------------------------------*/ 342 296 343 void knot_edns_free(knot_opt_rr_t **opt_rr) 297 bool knot_edns_check_record(knot_rrset_t *opt_rr) 344 298 { 345 if (opt_rr == NULL || *opt_rr == NULL) { 346 return; 299 knot_rdata_t *rdata = knot_rdataset_at(&opt_rr->rrs, 0); 300 if (rdata == NULL) { 301 return false; 347 302 } 348 303 - Last updated by Ghost User
Moved the code to
libknot/rdata
and renamed toopt.h/c
. All comments dealt with. Please do one last quick sweep and then merge. Unit tests pass, functional tests pass, except for occasional errors in axfr test and permanent error in ddns/forward test. These should not be related to this MR.mentioned in issue #190 (closed)