@@ -2872,6 +2872,7 @@ dns_build_ptr_answer(
2872
2872
}
2873
2873
2874
2874
#define DNS_RCODE_SERVER_REFUSE 0x5
2875
+ #define DNS_QUERY_TYPE_CLASS_LEN (2 * sizeof(ovs_be16))
2875
2876
2876
2877
/* Called with in the pinctrl_handler thread context. */
2877
2878
static void
@@ -2935,18 +2936,13 @@ pinctrl_handle_dns_lookup(
2935
2936
goto exit ;
2936
2937
}
2937
2938
2938
- /* Check if there is an additional record present, which is unsupported */
2939
- if (in_dns_header -> arcount ) {
2940
- VLOG_DBG_RL (& rl , "Received DNS query with additional records, which"
2941
- " is unsupported" );
2942
- goto exit ;
2943
- }
2944
-
2945
2939
struct udp_header * in_udp = dp_packet_l4 (pkt_in );
2946
2940
size_t udp_len = ntohs (in_udp -> udp_len );
2947
2941
size_t l4_len = dp_packet_l4_size (pkt_in );
2942
+ uint8_t * l4_start = (uint8_t * ) in_udp ;
2948
2943
uint8_t * end = (uint8_t * )in_udp + MIN (udp_len , l4_len );
2949
2944
uint8_t * in_dns_data = (uint8_t * )(in_dns_header + 1 );
2945
+ uint8_t * in_dns_data_start = in_dns_data ;
2950
2946
uint8_t * in_queryname = in_dns_data ;
2951
2947
uint16_t idx = 0 ;
2952
2948
struct ds query_name ;
@@ -2970,7 +2966,7 @@ pinctrl_handle_dns_lookup(
2970
2966
in_dns_data += idx ;
2971
2967
2972
2968
/* Query should have TYPE and CLASS fields */
2973
- if (in_dns_data + ( 2 * sizeof ( ovs_be16 )) > end ) {
2969
+ if (in_dns_data + DNS_QUERY_TYPE_CLASS_LEN > end ) {
2974
2970
ds_destroy (& query_name );
2975
2971
goto exit ;
2976
2972
}
@@ -2984,6 +2980,10 @@ pinctrl_handle_dns_lookup(
2984
2980
goto exit ;
2985
2981
}
2986
2982
2983
+ uint8_t * rest = in_dns_data + DNS_QUERY_TYPE_CLASS_LEN ;
2984
+ uint32_t query_size = rest - in_dns_data_start ;
2985
+ uint32_t query_l4_size = rest - l4_start ;
2986
+
2987
2987
uint64_t dp_key = ntohll (pin -> flow_metadata .flow .metadata );
2988
2988
const char * answer_data = NULL ;
2989
2989
bool ovn_owned = false;
@@ -3066,7 +3066,7 @@ pinctrl_handle_dns_lookup(
3066
3066
goto exit ;
3067
3067
}
3068
3068
3069
- uint16_t new_l4_size = ntohs ( in_udp -> udp_len ) + dns_answer .size ;
3069
+ uint16_t new_l4_size = query_l4_size + dns_answer .size ;
3070
3070
size_t new_packet_size = pkt_in -> l4_ofs + new_l4_size ;
3071
3071
struct dp_packet pkt_out ;
3072
3072
dp_packet_init (& pkt_out , new_packet_size );
@@ -3103,7 +3103,7 @@ pinctrl_handle_dns_lookup(
3103
3103
out_dns_header -> arcount = 0 ;
3104
3104
3105
3105
/* Copy the Query section. */
3106
- dp_packet_put (& pkt_out , dp_packet_data (pkt_in ), dp_packet_size ( pkt_in ) );
3106
+ dp_packet_put (& pkt_out , dp_packet_data (pkt_in ), query_size );
3107
3107
3108
3108
/* Copy the answer sections. */
3109
3109
dp_packet_put (& pkt_out , dns_answer .data , dns_answer .size );
0 commit comments