@@ -2882,6 +2882,8 @@ dns_build_ptr_answer(
2882
2882
free (encoded_answer );
2883
2883
}
2884
2884
2885
+ #define DNS_QUERY_TYPE_CLASS_LEN (2 * sizeof(ovs_be16))
2886
+
2885
2887
/* Called with in the pinctrl_handler thread context. */
2886
2888
static void
2887
2889
pinctrl_handle_dns_lookup (
@@ -2943,18 +2945,13 @@ pinctrl_handle_dns_lookup(
2943
2945
goto exit ;
2944
2946
}
2945
2947
2946
- /* Check if there is an additional record present, which is unsupported */
2947
- if (in_dns_header -> arcount ) {
2948
- VLOG_DBG_RL (& rl , "Received DNS query with additional records, which"
2949
- " is unsupported" );
2950
- goto exit ;
2951
- }
2952
-
2953
2948
struct udp_header * in_udp = dp_packet_l4 (pkt_in );
2954
2949
size_t udp_len = ntohs (in_udp -> udp_len );
2955
2950
size_t l4_len = dp_packet_l4_size (pkt_in );
2951
+ uint8_t * l4_start = (uint8_t * ) in_udp ;
2956
2952
uint8_t * end = (uint8_t * )in_udp + MIN (udp_len , l4_len );
2957
2953
uint8_t * in_dns_data = (uint8_t * )(in_dns_header + 1 );
2954
+ uint8_t * in_dns_data_start = in_dns_data ;
2958
2955
uint8_t * in_queryname = in_dns_data ;
2959
2956
uint16_t idx = 0 ;
2960
2957
struct ds query_name ;
@@ -2978,7 +2975,7 @@ pinctrl_handle_dns_lookup(
2978
2975
in_dns_data += idx ;
2979
2976
2980
2977
/* Query should have TYPE and CLASS fields */
2981
- if (in_dns_data + ( 2 * sizeof ( ovs_be16 )) > end ) {
2978
+ if (in_dns_data + DNS_QUERY_TYPE_CLASS_LEN > end ) {
2982
2979
ds_destroy (& query_name );
2983
2980
goto exit ;
2984
2981
}
@@ -2992,6 +2989,10 @@ pinctrl_handle_dns_lookup(
2992
2989
goto exit ;
2993
2990
}
2994
2991
2992
+ uint8_t * rest = in_dns_data + DNS_QUERY_TYPE_CLASS_LEN ;
2993
+ uint32_t query_size = rest - in_dns_data_start ;
2994
+ uint32_t query_l4_size = rest - l4_start ;
2995
+
2995
2996
uint64_t dp_key = ntohll (pin -> flow_metadata .flow .metadata );
2996
2997
const char * answer_data = NULL ;
2997
2998
struct shash_node * iter ;
@@ -3060,7 +3061,7 @@ pinctrl_handle_dns_lookup(
3060
3061
goto exit ;
3061
3062
}
3062
3063
3063
- uint16_t new_l4_size = ntohs ( in_udp -> udp_len ) + dns_answer .size ;
3064
+ uint16_t new_l4_size = query_l4_size + dns_answer .size ;
3064
3065
size_t new_packet_size = pkt_in -> l4_ofs + new_l4_size ;
3065
3066
struct dp_packet pkt_out ;
3066
3067
dp_packet_init (& pkt_out , new_packet_size );
@@ -3093,7 +3094,7 @@ pinctrl_handle_dns_lookup(
3093
3094
out_dns_header -> arcount = 0 ;
3094
3095
3095
3096
/* Copy the Query section. */
3096
- dp_packet_put (& pkt_out , dp_packet_data (pkt_in ), dp_packet_size ( pkt_in ) );
3097
+ dp_packet_put (& pkt_out , dp_packet_data (pkt_in ), query_size );
3097
3098
3098
3099
/* Copy the answer sections. */
3099
3100
dp_packet_put (& pkt_out , dns_answer .data , dns_answer .size );
0 commit comments