@@ -2949,6 +2949,8 @@ dns_build_ptr_answer(
2949
2949
free (encoded_answer );
2950
2950
}
2951
2951
2952
+ #define DNS_QUERY_TYPE_CLASS_LEN (2 * sizeof(ovs_be16))
2953
+
2952
2954
/* Called with in the pinctrl_handler thread context. */
2953
2955
static void
2954
2956
pinctrl_handle_dns_lookup (
@@ -3010,18 +3012,13 @@ pinctrl_handle_dns_lookup(
3010
3012
goto exit ;
3011
3013
}
3012
3014
3013
- /* Check if there is an additional record present, which is unsupported */
3014
- if (in_dns_header -> arcount ) {
3015
- VLOG_DBG_RL (& rl , "Received DNS query with additional records, which"
3016
- " is unsupported" );
3017
- goto exit ;
3018
- }
3019
-
3020
3015
struct udp_header * in_udp = dp_packet_l4 (pkt_in );
3021
3016
size_t udp_len = ntohs (in_udp -> udp_len );
3022
3017
size_t l4_len = dp_packet_l4_size (pkt_in );
3018
+ uint8_t * l4_start = (uint8_t * ) in_udp ;
3023
3019
uint8_t * end = (uint8_t * )in_udp + MIN (udp_len , l4_len );
3024
3020
uint8_t * in_dns_data = (uint8_t * )(in_dns_header + 1 );
3021
+ uint8_t * in_dns_data_start = in_dns_data ;
3025
3022
uint8_t * in_queryname = in_dns_data ;
3026
3023
uint16_t idx = 0 ;
3027
3024
struct ds query_name ;
@@ -3045,7 +3042,7 @@ pinctrl_handle_dns_lookup(
3045
3042
in_dns_data += idx ;
3046
3043
3047
3044
/* Query should have TYPE and CLASS fields */
3048
- if (in_dns_data + ( 2 * sizeof ( ovs_be16 )) > end ) {
3045
+ if (in_dns_data + DNS_QUERY_TYPE_CLASS_LEN > end ) {
3049
3046
ds_destroy (& query_name );
3050
3047
goto exit ;
3051
3048
}
@@ -3059,6 +3056,10 @@ pinctrl_handle_dns_lookup(
3059
3056
goto exit ;
3060
3057
}
3061
3058
3059
+ uint8_t * rest = in_dns_data + DNS_QUERY_TYPE_CLASS_LEN ;
3060
+ uint32_t query_size = rest - in_dns_data_start ;
3061
+ uint32_t query_l4_size = rest - l4_start ;
3062
+
3062
3063
uint64_t dp_key = ntohll (pin -> flow_metadata .flow .metadata );
3063
3064
const char * answer_data = NULL ;
3064
3065
struct shash_node * iter ;
@@ -3127,7 +3128,7 @@ pinctrl_handle_dns_lookup(
3127
3128
goto exit ;
3128
3129
}
3129
3130
3130
- uint16_t new_l4_size = ntohs ( in_udp -> udp_len ) + dns_answer .size ;
3131
+ uint16_t new_l4_size = query_l4_size + dns_answer .size ;
3131
3132
size_t new_packet_size = pkt_in -> l4_ofs + new_l4_size ;
3132
3133
struct dp_packet pkt_out ;
3133
3134
dp_packet_init (& pkt_out , new_packet_size );
@@ -3160,7 +3161,7 @@ pinctrl_handle_dns_lookup(
3160
3161
out_dns_header -> arcount = 0 ;
3161
3162
3162
3163
/* Copy the Query section. */
3163
- dp_packet_put (& pkt_out , dp_packet_data (pkt_in ), dp_packet_size ( pkt_in ) );
3164
+ dp_packet_put (& pkt_out , dp_packet_data (pkt_in ), query_size );
3164
3165
3165
3166
/* Copy the answer sections. */
3166
3167
dp_packet_put (& pkt_out , dns_answer .data , dns_answer .size );
0 commit comments