@@ -2828,6 +2828,8 @@ dns_build_ptr_answer(
2828
2828
free (encoded_answer );
2829
2829
}
2830
2830
2831
+ #define DNS_QUERY_TYPE_CLASS_LEN (2 * sizeof(ovs_be16))
2832
+
2831
2833
/* Called with in the pinctrl_handler thread context. */
2832
2834
static void
2833
2835
pinctrl_handle_dns_lookup (
@@ -2889,18 +2891,13 @@ pinctrl_handle_dns_lookup(
2889
2891
goto exit ;
2890
2892
}
2891
2893
2892
- /* Check if there is an additional record present, which is unsupported */
2893
- if (in_dns_header -> arcount ) {
2894
- VLOG_DBG_RL (& rl , "Received DNS query with additional records, which"
2895
- " is unsupported" );
2896
- goto exit ;
2897
- }
2898
-
2899
2894
struct udp_header * in_udp = dp_packet_l4 (pkt_in );
2900
2895
size_t udp_len = ntohs (in_udp -> udp_len );
2901
2896
size_t l4_len = dp_packet_l4_size (pkt_in );
2897
+ uint8_t * l4_start = (uint8_t * ) in_udp ;
2902
2898
uint8_t * end = (uint8_t * )in_udp + MIN (udp_len , l4_len );
2903
2899
uint8_t * in_dns_data = (uint8_t * )(in_dns_header + 1 );
2900
+ uint8_t * in_dns_data_start = in_dns_data ;
2904
2901
uint8_t * in_queryname = in_dns_data ;
2905
2902
uint16_t idx = 0 ;
2906
2903
struct ds query_name ;
@@ -2924,7 +2921,7 @@ pinctrl_handle_dns_lookup(
2924
2921
in_dns_data += idx ;
2925
2922
2926
2923
/* Query should have TYPE and CLASS fields */
2927
- if (in_dns_data + ( 2 * sizeof ( ovs_be16 )) > end ) {
2924
+ if (in_dns_data + DNS_QUERY_TYPE_CLASS_LEN > end ) {
2928
2925
ds_destroy (& query_name );
2929
2926
goto exit ;
2930
2927
}
@@ -2938,6 +2935,10 @@ pinctrl_handle_dns_lookup(
2938
2935
goto exit ;
2939
2936
}
2940
2937
2938
+ uint8_t * rest = in_dns_data + DNS_QUERY_TYPE_CLASS_LEN ;
2939
+ uint32_t query_size = rest - in_dns_data_start ;
2940
+ uint32_t query_l4_size = rest - l4_start ;
2941
+
2941
2942
uint64_t dp_key = ntohll (pin -> flow_metadata .flow .metadata );
2942
2943
const char * answer_data = NULL ;
2943
2944
struct shash_node * iter ;
@@ -3006,7 +3007,7 @@ pinctrl_handle_dns_lookup(
3006
3007
goto exit ;
3007
3008
}
3008
3009
3009
- uint16_t new_l4_size = ntohs ( in_udp -> udp_len ) + dns_answer .size ;
3010
+ uint16_t new_l4_size = query_l4_size + dns_answer .size ;
3010
3011
size_t new_packet_size = pkt_in -> l4_ofs + new_l4_size ;
3011
3012
struct dp_packet pkt_out ;
3012
3013
dp_packet_init (& pkt_out , new_packet_size );
@@ -3039,7 +3040,7 @@ pinctrl_handle_dns_lookup(
3039
3040
out_dns_header -> arcount = 0 ;
3040
3041
3041
3042
/* Copy the Query section. */
3042
- dp_packet_put (& pkt_out , dp_packet_data (pkt_in ), dp_packet_size ( pkt_in ) );
3043
+ dp_packet_put (& pkt_out , dp_packet_data (pkt_in ), query_size );
3043
3044
3044
3045
/* Copy the answer sections. */
3045
3046
dp_packet_put (& pkt_out , dns_answer .data , dns_answer .size );
0 commit comments