@@ -2885,6 +2885,7 @@ dns_build_ptr_answer(
2885
2885
free (encoded );
2886
2886
}
2887
2887
2888
+ #define DNS_QUERY_TYPE_CLASS_LEN (2 * sizeof(ovs_be16))
2888
2889
#define DNS_RCODE_SERVER_REFUSE 0x5
2889
2890
2890
2891
/* Called with in the pinctrl_handler thread context. */
@@ -2949,18 +2950,13 @@ pinctrl_handle_dns_lookup(
2949
2950
goto exit ;
2950
2951
}
2951
2952
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
-
2959
2953
struct udp_header * in_udp = dp_packet_l4 (pkt_in );
2960
2954
size_t udp_len = ntohs (in_udp -> udp_len );
2961
2955
size_t l4_len = dp_packet_l4_size (pkt_in );
2956
+ uint8_t * l4_start = (uint8_t * ) in_udp ;
2962
2957
uint8_t * end = (uint8_t * )in_udp + MIN (udp_len , l4_len );
2963
2958
uint8_t * in_dns_data = (uint8_t * )(in_dns_header + 1 );
2959
+ uint8_t * in_dns_data_start = in_dns_data ;
2964
2960
uint8_t * in_queryname = in_dns_data ;
2965
2961
uint16_t idx = 0 ;
2966
2962
struct ds query_name ;
@@ -2984,7 +2980,7 @@ pinctrl_handle_dns_lookup(
2984
2980
in_dns_data += idx ;
2985
2981
2986
2982
/* 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 ) {
2988
2984
ds_destroy (& query_name );
2989
2985
goto exit ;
2990
2986
}
@@ -2998,6 +2994,10 @@ pinctrl_handle_dns_lookup(
2998
2994
goto exit ;
2999
2995
}
3000
2996
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
+
3001
3001
uint64_t dp_key = ntohll (pin -> flow_metadata .flow .metadata );
3002
3002
const char * answer_data = NULL ;
3003
3003
bool ovn_owned = false;
@@ -3080,7 +3080,7 @@ pinctrl_handle_dns_lookup(
3080
3080
goto exit ;
3081
3081
}
3082
3082
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 ;
3084
3084
size_t new_packet_size = pkt_in -> l4_ofs + new_l4_size ;
3085
3085
struct dp_packet pkt_out ;
3086
3086
dp_packet_init (& pkt_out , new_packet_size );
@@ -3117,7 +3117,7 @@ pinctrl_handle_dns_lookup(
3117
3117
out_dns_header -> arcount = 0 ;
3118
3118
3119
3119
/* 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 );
3121
3121
3122
3122
/* Copy the answer sections. */
3123
3123
dp_packet_put (& pkt_out , dns_answer .data , dns_answer .size );
0 commit comments