@@ -2923,6 +2923,8 @@ dns_build_ptr_answer(
2923
2923
free (encoded_answer );
2924
2924
}
2925
2925
2926
+ #define DNS_QUERY_TYPE_CLASS_LEN (2 * sizeof(ovs_be16))
2927
+
2926
2928
/* Called with in the pinctrl_handler thread context. */
2927
2929
static void
2928
2930
pinctrl_handle_dns_lookup (
@@ -2984,18 +2986,13 @@ pinctrl_handle_dns_lookup(
2984
2986
goto exit ;
2985
2987
}
2986
2988
2987
- /* Check if there is an additional record present, which is unsupported */
2988
- if (in_dns_header -> arcount ) {
2989
- VLOG_DBG_RL (& rl , "Received DNS query with additional records, which"
2990
- " is unsupported" );
2991
- goto exit ;
2992
- }
2993
-
2994
2989
struct udp_header * in_udp = dp_packet_l4 (pkt_in );
2995
2990
size_t udp_len = ntohs (in_udp -> udp_len );
2996
2991
size_t l4_len = dp_packet_l4_size (pkt_in );
2992
+ uint8_t * l4_start = (uint8_t * ) in_udp ;
2997
2993
uint8_t * end = (uint8_t * )in_udp + MIN (udp_len , l4_len );
2998
2994
uint8_t * in_dns_data = (uint8_t * )(in_dns_header + 1 );
2995
+ uint8_t * in_dns_data_start = in_dns_data ;
2999
2996
uint8_t * in_queryname = in_dns_data ;
3000
2997
uint16_t idx = 0 ;
3001
2998
struct ds query_name ;
@@ -3019,7 +3016,7 @@ pinctrl_handle_dns_lookup(
3019
3016
in_dns_data += idx ;
3020
3017
3021
3018
/* Query should have TYPE and CLASS fields */
3022
- if (in_dns_data + ( 2 * sizeof ( ovs_be16 )) > end ) {
3019
+ if (in_dns_data + DNS_QUERY_TYPE_CLASS_LEN > end ) {
3023
3020
ds_destroy (& query_name );
3024
3021
goto exit ;
3025
3022
}
@@ -3033,6 +3030,10 @@ pinctrl_handle_dns_lookup(
3033
3030
goto exit ;
3034
3031
}
3035
3032
3033
+ uint8_t * rest = in_dns_data + DNS_QUERY_TYPE_CLASS_LEN ;
3034
+ uint32_t query_size = rest - in_dns_data_start ;
3035
+ uint32_t query_l4_size = rest - l4_start ;
3036
+
3036
3037
uint64_t dp_key = ntohll (pin -> flow_metadata .flow .metadata );
3037
3038
const char * answer_data = NULL ;
3038
3039
struct shash_node * iter ;
@@ -3101,7 +3102,7 @@ pinctrl_handle_dns_lookup(
3101
3102
goto exit ;
3102
3103
}
3103
3104
3104
- uint16_t new_l4_size = ntohs ( in_udp -> udp_len ) + dns_answer .size ;
3105
+ uint16_t new_l4_size = query_l4_size + dns_answer .size ;
3105
3106
size_t new_packet_size = pkt_in -> l4_ofs + new_l4_size ;
3106
3107
struct dp_packet pkt_out ;
3107
3108
dp_packet_init (& pkt_out , new_packet_size );
@@ -3134,7 +3135,7 @@ pinctrl_handle_dns_lookup(
3134
3135
out_dns_header -> arcount = 0 ;
3135
3136
3136
3137
/* Copy the Query section. */
3137
- dp_packet_put (& pkt_out , dp_packet_data (pkt_in ), dp_packet_size ( pkt_in ) );
3138
+ dp_packet_put (& pkt_out , dp_packet_data (pkt_in ), query_size );
3138
3139
3139
3140
/* Copy the answer sections. */
3140
3141
dp_packet_put (& pkt_out , dns_answer .data , dns_answer .size );
0 commit comments