Skip to content

Commit 6fab3fb

Browse files
dcearaovsrobot
authored andcommitted
pinctrl: dns: Ignore additional additional records.
EDNS is backwards compatible so it's safe to just ignore additional ARs. Reported-at: ovn-org#228 Reported-at: https://issues.redhat.com/browse/FDP-222 Signed-off-by: Dumitru Ceara <dceara@redhat.com> Signed-off-by: 0-day Robot <robot@bytheb.org>
1 parent 425f699 commit 6fab3fb

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

controller/pinctrl.c

+10-10
Original file line numberDiff line numberDiff line change
@@ -2885,6 +2885,7 @@ dns_build_ptr_answer(
28852885
free(encoded);
28862886
}
28872887

2888+
#define DNS_QUERY_TYPE_CLASS_LEN (2 * sizeof(ovs_be16))
28882889
#define DNS_RCODE_SERVER_REFUSE 0x5
28892890

28902891
/* Called with in the pinctrl_handler thread context. */
@@ -2949,18 +2950,13 @@ pinctrl_handle_dns_lookup(
29492950
goto exit;
29502951
}
29512952

2952-
/* Check if there is an additional record present, which is unsupported */
2953-
if (in_dns_header->arcount) {
2954-
VLOG_DBG_RL(&rl, "Received DNS query with additional records, which"
2955-
" is unsupported");
2956-
goto exit;
2957-
}
2958-
29592953
struct udp_header *in_udp = dp_packet_l4(pkt_in);
29602954
size_t udp_len = ntohs(in_udp->udp_len);
29612955
size_t l4_len = dp_packet_l4_size(pkt_in);
2956+
uint8_t *l4_start = (uint8_t *) in_udp;
29622957
uint8_t *end = (uint8_t *)in_udp + MIN(udp_len, l4_len);
29632958
uint8_t *in_dns_data = (uint8_t *)(in_dns_header + 1);
2959+
uint8_t *in_dns_data_start = in_dns_data;
29642960
uint8_t *in_queryname = in_dns_data;
29652961
uint16_t idx = 0;
29662962
struct ds query_name;
@@ -2984,7 +2980,7 @@ pinctrl_handle_dns_lookup(
29842980
in_dns_data += idx;
29852981

29862982
/* Query should have TYPE and CLASS fields */
2987-
if (in_dns_data + (2 * sizeof(ovs_be16)) > end) {
2983+
if (in_dns_data + DNS_QUERY_TYPE_CLASS_LEN > end) {
29882984
ds_destroy(&query_name);
29892985
goto exit;
29902986
}
@@ -2998,6 +2994,10 @@ pinctrl_handle_dns_lookup(
29982994
goto exit;
29992995
}
30002996

2997+
uint8_t *rest = in_dns_data + DNS_QUERY_TYPE_CLASS_LEN;
2998+
uint32_t query_size = rest - in_dns_data_start;
2999+
uint32_t query_l4_size = rest - l4_start;
3000+
30013001
uint64_t dp_key = ntohll(pin->flow_metadata.flow.metadata);
30023002
const char *answer_data = NULL;
30033003
bool ovn_owned = false;
@@ -3080,7 +3080,7 @@ pinctrl_handle_dns_lookup(
30803080
goto exit;
30813081
}
30823082

3083-
uint16_t new_l4_size = ntohs(in_udp->udp_len) + dns_answer.size;
3083+
uint16_t new_l4_size = query_l4_size + dns_answer.size;
30843084
size_t new_packet_size = pkt_in->l4_ofs + new_l4_size;
30853085
struct dp_packet pkt_out;
30863086
dp_packet_init(&pkt_out, new_packet_size);
@@ -3117,7 +3117,7 @@ pinctrl_handle_dns_lookup(
31173117
out_dns_header->arcount = 0;
31183118

31193119
/* Copy the Query section. */
3120-
dp_packet_put(&pkt_out, dp_packet_data(pkt_in), dp_packet_size(pkt_in));
3120+
dp_packet_put(&pkt_out, dp_packet_data(pkt_in), query_size);
31213121

31223122
/* Copy the answer sections. */
31233123
dp_packet_put(&pkt_out, dns_answer.data, dns_answer.size);

0 commit comments

Comments
 (0)