Commit 50c66c18 authored by Marek Vavruša's avatar Marek Vavruša

packet: removed RR merging as its deprecated

parent 21f67661
......@@ -479,7 +479,7 @@ int remote_recv(int sock, struct sockaddr *addr, uint8_t* buf, size_t *buflen)
int remote_parse(knot_pkt_t* pkt)
{
return knot_pkt_parse(pkt, KNOT_PF_NO_MERGE);
return knot_pkt_parse(pkt, 0);
}
static int remote_send_chunk(int c, knot_pkt_t *query, const char* d, uint16_t len)
......
......@@ -403,7 +403,7 @@ static int ratelimit_apply(int state, knot_pkt_t *pkt, knot_process_t *ctx)
rrl_rq.w = pkt->wire;
rrl_rq.query = qdata->query;
if (!EMPTY_LIST(qdata->wildcards)) {
rrl_rq.flags = KNOT_PF_WILDCARD;
rrl_rq.flags = RRL_WILDCARD;
}
if (rrl_query(server->rrl, qdata->param->query_source,
&rrl_rq, qdata->zone) == KNOT_EOK) {
......
......@@ -94,7 +94,7 @@ static uint8_t rrl_clsid(rrl_req_t *p)
}
/* Check if answered from a qname */
if (ret == CLS_NORMAL && p->flags & KNOT_PF_WILDCARD) {
if (ret == CLS_NORMAL && p->flags & RRL_WILDCARD) {
return CLS_WILDCARD;
}
......
......@@ -36,6 +36,12 @@
#define RRL_SLIP_MAX 100
#define RRL_LOCK_GRANULARITY 32 /* Last digit granularity */
/*! \brief RRL flags. */
enum {
RRL_NOFLAG = 0 << 0, /*!< No flags. */
RRL_WILDCARD = 1 << 1 /*!< Query to wildcard name. */
};
struct zone_t;
/*!
......
......@@ -637,7 +637,7 @@ static int xfr_task_resp(xfrhandler_t *xfr, knot_ns_xfr_t *rq, knot_pkt_t *pkt)
return KNOT_EOK; /* Ignore */
}
int ret = knot_pkt_parse_payload(pkt, KNOT_PF_NO_MERGE);
int ret = knot_pkt_parse_payload(pkt, 0);
if (ret != KNOT_EOK) {
return KNOT_EOK; /* Ignore */
}
......@@ -728,7 +728,7 @@ static int xfr_parse_packet(knot_pkt_t *pkt)
{
/* This is important, don't merge RRs together. The SOAs are ordered
* in a special way for a reason. */
int ret = knot_pkt_parse(pkt, KNOT_PF_NO_MERGE);
int ret = knot_pkt_parse(pkt, 0);
if (ret != KNOT_EOK) {
return ret;
}
......
......@@ -629,41 +629,6 @@ int knot_pkt_parse_question(knot_pkt_t *pkt)
return KNOT_EOK;
}
static int knot_pkt_merge_rr(knot_pkt_t *pkt, knot_rrset_t *rr, unsigned flags)
{
dbg_packet("%s(%p, %p, %u)\n", __func__, pkt, rr, flags);
assert(pkt);
assert(rr);
/* Don't want to merge, okay. */
if (flags & KNOT_PF_NO_MERGE) {
return KNOT_ENOENT;
}
// try to find the RRSet in this array of RRSets
for (int i = 0; i < pkt->rrset_count; ++i) {
if (knot_rrset_equal(pkt->rr[i], rr, KNOT_RRSET_COMPARE_HEADER)) {
int merged = 0;
int deleted_rrs = 0;
int rc = knot_rrset_merge_sort((knot_rrset_t *)pkt->rr[i],
rr, &merged, &deleted_rrs,
&pkt->mm);
if (rc != KNOT_EOK) {
dbg_packet("%s: failed to merge RR %p (%d)\n", __func__, rr, rc);
return rc;
}
dbg_packet("%s: merged RR %p\n", __func__, rr);
knot_rrset_free(&rr, &pkt->mm);
return KNOT_EOK;
}
}
return KNOT_ENOENT;
}
/*! \note Legacy code, mainly for transfers and updates.
* RRSets should use packet memory context for allocation and
* should be copied if they are supposed to be stored in zone permanently.
......@@ -753,11 +718,6 @@ int knot_pkt_parse_rr(knot_pkt_t *pkt, unsigned flags)
/* Calculate parsed RR size from before/after parsing. */
rr_size = (pkt->parsed - rr_size);
/* Merge with existing RRSet if possible, otherwise add new RR set. */
if (knot_pkt_merge_rr(pkt, rr, flags) == KNOT_EOK) {
return KNOT_EOK;
}
/* Append to RR list. */
pkt->rr[pkt->rrset_count] = rr;
++pkt->rrset_count;
......
......@@ -69,11 +69,9 @@ typedef enum {
*/
enum {
KNOT_PF_NULL = 0 << 0, /*!< No flags. */
KNOT_PF_WILDCARD = 1 << 1, /*!< Query to wildcard name. */
KNOT_PF_FREE = 1 << 2, /*!< Free with packet. */
KNOT_PF_NOTRUNC = 1 << 3, /*!< Don't truncate. */
KNOT_PF_CHECKDUP = 1 << 4, /*!< Check for duplicates. */
KNOT_PF_NO_MERGE = 1 << 5 /* Don't add duplicate rdata to rrset. */
KNOT_PF_FREE = 1 << 1, /*!< Free with packet. */
KNOT_PF_NOTRUNC = 1 << 2, /*!< Don't truncate. */
KNOT_PF_CHECKDUP = 1 << 3 /*!< Check for duplicates. */
};
/*!
......
......@@ -318,7 +318,7 @@ static int process_query_packet(const knot_pkt_t *query,
}
// Parse reply to the packet structure.
if (knot_pkt_parse(reply, KNOT_PF_NO_MERGE) != KNOT_EOK) {
if (knot_pkt_parse(reply, 0) != KNOT_EOK) {
ERR("malformed reply packet from %s\n", net->remote_str);
knot_pkt_free(&reply);
net_close(net);
......@@ -539,7 +539,7 @@ static int process_packet_xfr(const knot_pkt_t *query,
}
// Parse reply to the packet structure.
if (knot_pkt_parse(reply, KNOT_PF_NO_MERGE) != KNOT_EOK) {
if (knot_pkt_parse(reply, 0) != KNOT_EOK) {
ERR("malformed reply packet from %s\n", net->remote_str);
knot_pkt_free(&reply);
net_close(net);
......
......@@ -718,7 +718,7 @@ int cmd_send(const char* lp, nsupdate_params_t *params)
}
/* Parse response. */
ret = knot_pkt_parse(params->answer, KNOT_PF_NO_MERGE);
ret = knot_pkt_parse(params->answer, 0);
if (ret != KNOT_EOK) {
ERR("failed to parse response, %s\n", knot_strerror(ret));
free_sign_context(&sign_ctx);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment